Skip to content

Commit eb16bb2

Browse files
committed
Move all to header, do not compile lib
1 parent e1a7669 commit eb16bb2

File tree

5 files changed

+118
-147
lines changed

5 files changed

+118
-147
lines changed

PWGLF/TableProducer/Strangeness/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ o2physics_add_dpl_workflow(strangederivedbuilder
109109

110110
o2physics_add_dpl_workflow(strangenessbuilder
111111
SOURCES strangenessbuilder.cxx
112-
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2Physics::strangenessBuilderHelper
112+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase
113113
COMPONENT_NAME Analysis)
114114

115115
o2physics_add_dpl_workflow(v0-selector

PWGLF/Utils/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,4 @@ o2physics_add_library(v0SelectionGroup
1515

1616
o2physics_target_root_dictionary(v0SelectionGroup
1717
HEADERS v0SelectionGroup.h
18-
LINKDEF v0SelectionGroupLinkDef.h)
19-
20-
o2physics_add_library(strangenessBuilderHelper
21-
SOURCES strangenessBuilderHelper.cxx
22-
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore)
23-
24-
o2physics_target_root_dictionary(strangenessBuilderHelper
25-
HEADERS strangenessBuilderHelper.h
26-
LINKDEF strangenessBuilderHelperLinkDef.h)
18+
LINKDEF v0SelectionGroupLinkDef.h)

PWGLF/Utils/strangenessBuilderHelper.cxx

Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,7 @@ namespace pwglf
2828
{
2929
//_______________________________________________________________
3030
strangenessBuilderHelper::strangenessBuilderHelper() {
31-
// standards hardcoded in builder ...
32-
// ...but can be changed easily since fitter is public
33-
fitter.setPropagateToPCA(true);
34-
fitter.setMaxR(200.);
35-
fitter.setMinParamChange(1e-3);
36-
fitter.setMinRelChi2Change(0.9);
37-
fitter.setMaxDZIni(1e9);
38-
fitter.setMaxDXYIni(4.0f);
39-
fitter.setMaxChi2(1e9);
40-
fitter.setUseAbsDCA(true);
41-
fitter.setWeightedFinalPCA(false);
4231

43-
// LUT has to be loaded later
44-
lut = nullptr;
45-
fitter.setMatCorrType(o2::base::Propagator::MatCorrType::USEMatCorrLUT);
46-
47-
// mag field has to be set later
48-
fitter.setBz(-999.9f); // will NOT make sense if not changed
4932
}
5033

5134
//_______________________________________________________________
@@ -54,94 +37,12 @@ strangenessBuilderHelper::strangenessBuilderHelper() {
5437
// Resulting properties can be checked with strangenessBuilderHelper::v0
5538

5639
template <typename TTrack>
57-
bool strangenessBuilderHelper::buildV0Candidate(
58-
o2::aod::Collision const& collision,
59-
TTrack const& positiveTrack,
60-
TTrack const& negativeTrack,
61-
bool useCollinearFit){
62-
// Calculate DCA with respect to the collision associated to the V0, not individual tracks
63-
gpu::gpustd::array<float, 2> dcaInfo;
64-
65-
auto posTrackPar = getTrackPar(positiveTrack);
66-
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, posTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo);
67-
v0.positiveDCAxy = dcaInfo[0];
68-
69-
auto negTrackPar = getTrackPar(negativeTrack);
70-
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, negTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo);
71-
v0.negativeDCAxy = dcaInfo[0];
72-
73-
o2::track::TrackParCov positiveTrackParam = getTrackParCov(positiveTrack);
74-
o2::track::TrackParCov negativeTrackParam = getTrackParCov(negativeTrack);
75-
76-
// Perform DCA fit
77-
int nCand = 0;
78-
fitter.setCollinear(useCollinearFit);
79-
try {
80-
nCand = fitter.process(positiveTrackParam, negativeTrackParam);
81-
} catch (...) {
82-
return false;
83-
}
84-
if (nCand == 0) {
85-
return false;
86-
}
87-
88-
v0.positiveTrackX = fitter.getTrack(0).getX();
89-
v0.negativeTrackX = fitter.getTrack(1).getX();
90-
positiveTrackParam = fitter.getTrack(0);
91-
negativeTrackParam = fitter.getTrack(1);
92-
positiveTrackParam.getPxPyPzGlo(v0.positiveMomentum);
93-
negativeTrackParam.getPxPyPzGlo(v0.negativeMomentum);
94-
positiveTrackParam.getXYZGlo(v0.positivePosition);
95-
negativeTrackParam.getXYZGlo(v0.negativePosition);
96-
97-
// get decay vertex coordinates
98-
const auto& vtx = fitter.getPCACandidate();
99-
for (int i = 0; i < 3; i++) {
100-
v0.position[i] = vtx[i];
101-
}
102-
103-
v0.daughterDCA = TMath::Sqrt(fitter.getChi2AtPCACandidate());
104-
v0.pointingAngle = TMath::ACos(RecoDecay::cpa(
105-
std::array{collision.posX(), collision.posY(), collision.posZ()},
106-
std::array{v0.position[0], v0.position[1], v0.position[2]},
107-
std::array{v0.positiveMomentum[0] + v0.negativeMomentum[0], v0.positiveMomentum[1] + v0.negativeMomentum[1], v0.positiveMomentum[2] + v0.negativeMomentum[2]}
108-
));
109-
110-
v0.dcaXY = CalculateDCAStraightToPV(
111-
v0.position[0], v0.position[1], v0.position[2],
112-
v0.positiveMomentum[0] + v0.negativeMomentum[0],
113-
v0.positiveMomentum[1] + v0.negativeMomentum[1],
114-
v0.positiveMomentum[2] + v0.negativeMomentum[2],
115-
collision.posX(), collision.posY(), collision.posZ());
116-
117-
// Calculate masses
118-
v0.massGamma = RecoDecay::m(std::array{
119-
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
120-
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
121-
std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassElectron});
122-
v0.massK0Short = RecoDecay::m(std::array{
123-
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
124-
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
125-
std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged});
126-
v0.massLambda = RecoDecay::m(std::array{
127-
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
128-
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
129-
std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged});
130-
v0.massAntiLambda = RecoDecay::m(std::array{
131-
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
132-
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
133-
std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton});
134-
135-
// information validated, V0 built successfully. Signal OK
136-
return true;
137-
}
40+
bool strangenessBuilderHelper::buildV0Candidate
13841

13942
//_______________________________________________________________
14043
// internal helper to calculate DCAxy of a straight line to a given PV analytically
14144
float strangenessBuilderHelper::CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ)
142-
{
143-
return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz));
144-
}
45+
14546

14647
//_______________________________________________________________
14748
} // namespace pwglf

PWGLF/Utils/strangenessBuilderHelper.h

Lines changed: 114 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include <array>
1818
#include "DCAFitter/DCAFitterN.h"
1919
#include "Framework/AnalysisDataModel.h"
20+
#include "ReconstructionDataFormats/Track.h"
21+
#include "DetectorsBase/GeometryManager.h"
22+
#include "CommonConstants/PhysicsConstants.h"
23+
#include "Common/Core/trackUtilities.h"
2024

2125
namespace o2
2226
{
@@ -108,13 +112,108 @@ struct cascadeCandidate {
108112
class strangenessBuilderHelper
109113
{
110114
public:
111-
strangenessBuilderHelper();
115+
strangenessBuilderHelper(){
116+
// standards hardcoded in builder ...
117+
// ...but can be changed easily since fitter is public
118+
fitter.setPropagateToPCA(true);
119+
fitter.setMaxR(200.);
120+
fitter.setMinParamChange(1e-3);
121+
fitter.setMinRelChi2Change(0.9);
122+
fitter.setMaxDZIni(1e9);
123+
fitter.setMaxDXYIni(4.0f);
124+
fitter.setMaxChi2(1e9);
125+
fitter.setUseAbsDCA(true);
126+
fitter.setWeightedFinalPCA(false);
127+
128+
// LUT has to be loaded later
129+
lut = nullptr;
130+
fitter.setMatCorrType(o2::base::Propagator::MatCorrType::USEMatCorrLUT);
131+
132+
// mag field has to be set later
133+
fitter.setBz(-999.9f); // will NOT make sense if not changed
134+
};
112135

113136
template <typename TTrack>
114137
bool buildV0Candidate(o2::aod::Collision const& collision,
115138
TTrack const& positiveTrack,
116139
TTrack const& negativeTrack,
117-
bool useCollinearFit = false);
140+
bool useCollinearFit){
141+
// Calculate DCA with respect to the collision associated to the V0, not individual tracks
142+
gpu::gpustd::array<float, 2> dcaInfo;
143+
144+
auto posTrackPar = getTrackPar(positiveTrack);
145+
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, posTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo);
146+
v0.positiveDCAxy = dcaInfo[0];
147+
148+
auto negTrackPar = getTrackPar(negativeTrack);
149+
o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, negTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo);
150+
v0.negativeDCAxy = dcaInfo[0];
151+
152+
o2::track::TrackParCov positiveTrackParam = getTrackParCov(positiveTrack);
153+
o2::track::TrackParCov negativeTrackParam = getTrackParCov(negativeTrack);
154+
155+
// Perform DCA fit
156+
int nCand = 0;
157+
fitter.setCollinear(useCollinearFit);
158+
try {
159+
nCand = fitter.process(positiveTrackParam, negativeTrackParam);
160+
} catch (...) {
161+
return false;
162+
}
163+
if (nCand == 0) {
164+
return false;
165+
}
166+
167+
v0.positiveTrackX = fitter.getTrack(0).getX();
168+
v0.negativeTrackX = fitter.getTrack(1).getX();
169+
positiveTrackParam = fitter.getTrack(0);
170+
negativeTrackParam = fitter.getTrack(1);
171+
positiveTrackParam.getPxPyPzGlo(v0.positiveMomentum);
172+
negativeTrackParam.getPxPyPzGlo(v0.negativeMomentum);
173+
positiveTrackParam.getXYZGlo(v0.positivePosition);
174+
negativeTrackParam.getXYZGlo(v0.negativePosition);
175+
176+
// get decay vertex coordinates
177+
const auto& vtx = fitter.getPCACandidate();
178+
for (int i = 0; i < 3; i++) {
179+
v0.position[i] = vtx[i];
180+
}
181+
182+
v0.daughterDCA = TMath::Sqrt(fitter.getChi2AtPCACandidate());
183+
v0.pointingAngle = TMath::ACos(RecoDecay::cpa(
184+
std::array{collision.posX(), collision.posY(), collision.posZ()},
185+
std::array{v0.position[0], v0.position[1], v0.position[2]},
186+
std::array{v0.positiveMomentum[0] + v0.negativeMomentum[0], v0.positiveMomentum[1] + v0.negativeMomentum[1], v0.positiveMomentum[2] + v0.negativeMomentum[2]}
187+
));
188+
189+
v0.dcaXY = CalculateDCAStraightToPV(
190+
v0.position[0], v0.position[1], v0.position[2],
191+
v0.positiveMomentum[0] + v0.negativeMomentum[0],
192+
v0.positiveMomentum[1] + v0.negativeMomentum[1],
193+
v0.positiveMomentum[2] + v0.negativeMomentum[2],
194+
collision.posX(), collision.posY(), collision.posZ());
195+
196+
// Calculate masses
197+
v0.massGamma = RecoDecay::m(std::array{
198+
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
199+
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
200+
std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassElectron});
201+
v0.massK0Short = RecoDecay::m(std::array{
202+
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
203+
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
204+
std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged});
205+
v0.massLambda = RecoDecay::m(std::array{
206+
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
207+
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
208+
std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged});
209+
v0.massAntiLambda = RecoDecay::m(std::array{
210+
std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]},
211+
std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}},
212+
std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton});
213+
214+
// information validated, V0 built successfully. Signal OK
215+
return true;
216+
}
118217

119218
o2::base::MatLayerCylSet* lut; // material LUT for DCA fitter
120219
o2::vertexing::DCAFitterN<2> fitter; // 2-prong o2 dca fitter
@@ -124,26 +223,27 @@ class strangenessBuilderHelper
124223

125224
private:
126225
// internal helper to calculate DCAxy of a straight line to a given PV analytically
127-
float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ);
226+
float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ){
227+
return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz));
228+
}
128229
};
129230

130231
} // namespace pwglf
131232
} // namespace o2
132233

133234
// specific specializations that are foreseen
134235
// Run 3 case: tracks at IU
135-
extern template<o2::soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator>
136-
bool o2::pwglf::strangenessBuilderHelper::buildV0Candidate(o2::aod::Collision const& collision,
137-
o2::soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator const& positiveTrack,
138-
o2::soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator const& negativeTrack,
139-
bool useCollinearFit);
236+
extern template
237+
bool o2::pwglf::strangenessBuilderHelper::buildV0Candidate<o2::soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator>(o2::aod::Collision const& collision,
238+
o2::soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator const& positiveTrack,
239+
o2::soa::Join<o2::aod::TracksIU, o2::aod::TracksExtra, o2::aod::TracksCovIU>::iterator const& negativeTrack,
240+
bool useCollinearFit);
140241

141242
// Run 2 case: tracks at PV
142-
extern template<o2::soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, o2::aod::TracksCov>::iterator>
143-
bool o2::pwglf::strangenessBuilderHelper::buildV0Candidate(o2::aod::Collision const& collision,
144-
o2::soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, o2::aod::TracksCov>::iterator const& positiveTrack,
145-
o2::soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, o2::aod::TracksCov>::iterator const& negativeTrack,
146-
bool useCollinearFit);
147-
243+
extern template
244+
bool o2::pwglf::strangenessBuilderHelper::buildV0Candidate<o2::soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, o2::aod::TracksCov>::iterator>(o2::aod::Collision const& collision,
245+
o2::soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, o2::aod::TracksCov>::iterator const& positiveTrack,
246+
o2::soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, o2::aod::TracksCov>::iterator const& negativeTrack,
247+
bool useCollinearFit);
148248

149249
#endif // PWGLF_UTILS_STRANGENESSBUILDERHELPER_H_

PWGLF/Utils/strangenessBuilderHelperLinkDef.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)