Skip to content

Commit f641b6d

Browse files
author
sandeep dudi
committed
Track selection cuts are tuned for MC
1 parent 2f97caa commit f641b6d

File tree

1 file changed

+50
-63
lines changed

1 file changed

+50
-63
lines changed

PWGLF/Tasks/Nuspex/spectraKinkPiKa.cxx

Lines changed: 50 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ using CollisionsFullMC = soa::Join<aod::Collisions, aod::McCollisionLabels, aod:
6868
namespace
6969
{
7070
constexpr std::array<float, 7> LayerRadii{2.33959f, 3.14076f, 3.91924f, 19.6213f, 24.5597f, 34.388f, 39.3329f};
71-
constexpr double betheBlochDefault[1][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}};
71+
constexpr double BetheBlochDefault[1][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}};
7272
static const std::vector<std::string> betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"};
7373
static const std::vector<std::string> particleNames{"Daughter"};
7474

7575
} // namespace
7676

77-
struct kinkCandidate {
77+
struct KinkCandidate {
7878
int mothTrackID;
7979
int daugTrackID;
8080
int collisionID;
@@ -90,7 +90,7 @@ struct kinkCandidate {
9090
float dcaXYmoth = -999;
9191
float kinkAngle = -999;
9292
};
93-
struct kinkBuilder {
93+
struct KinkBuilder {
9494
// kink analysis
9595
Produces<aod::KinkCands> outputDataTable;
9696
Service<o2::ccdb::BasicCCDBManager> ccdb;
@@ -116,7 +116,7 @@ struct kinkBuilder {
116116
svPoolCreator svCreator;
117117

118118
// bethe bloch parameters
119-
Configurable<LabeledArray<double>> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 1, 6, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for charged daughter"};
119+
Configurable<LabeledArray<double>> cfgBetheBlochParams{"cfgBetheBlochParams", {BetheBlochDefault[0], 1, 6, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for charged daughter"};
120120
Configurable<int> cfgMaterialCorrection{"cfgMaterialCorrection", static_cast<int>(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"};
121121
Configurable<float> customVertexerTimeMargin{"customVertexerTimeMargin", 800, "Time margin for custom vertexer (ns)"};
122122
Configurable<bool> skipAmbiTracks{"skipAmbiTracks", false, "Skip ambiguous tracks"};
@@ -128,7 +128,7 @@ struct kinkBuilder {
128128
Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
129129

130130
// std vector of candidates
131-
std::vector<kinkCandidate> kinkCandidates;
131+
std::vector<KinkCandidate> kinkCandidates;
132132
int mRunNumber;
133133
float mBz;
134134
std::array<float, 6> mBBparamsDaug;
@@ -139,10 +139,8 @@ struct kinkBuilder {
139139
{
140140
// dummy values, 1 for mother, 0 for daughter
141141
svCreator.setPDGs(1, 0);
142-
143142
mRunNumber = 0;
144143
mBz = 0;
145-
146144
ccdb->setURL(ccdbPath);
147145
ccdb->setCaching(true);
148146
ccdb->setLocalObjectValidityChecking();
@@ -158,7 +156,8 @@ struct kinkBuilder {
158156
if (skipAmbiTracks) {
159157
svCreator.setSkipAmbiTracks();
160158
}
161-
for (int i = 0; i < 5; i++) {
159+
const int blpar = 5;
160+
for (int i = 0; i < blpar; i++) {
162161
mBBparamsDaug[i] = cfgBetheBlochParams->get("Daughter", Form("p%i", i));
163162
}
164163
mBBparamsDaug[5] = cfgBetheBlochParams->get("Daughter", "resolution");
@@ -167,12 +166,14 @@ struct kinkBuilder {
167166
template <typename T>
168167
bool selectMothTrack(const T& candidate)
169168
{
169+
const int itscls = 6;
170+
const int itsclsinb = 3;
170171
// ITS-standalone (no TPC, no TOF)
171172
if (!kaontopologhy) {
172173
if (candidate.has_collision() && candidate.hasITS() && !candidate.hasTPC() && !candidate.hasTOF() &&
173-
candidate.itsNCls() < 6 &&
174-
candidate.itsNClsInnerBarrel() == 3 &&
175-
candidate.itsChi2NCl() < 36 &&
174+
candidate.itsNCls() < itscls &&
175+
candidate.itsNClsInnerBarrel() == itsclsinb &&
176+
candidate.itsChi2NCl() < itsChi2cut &&
176177
candidate.pt() > minPtMoth) {
177178
return true;
178179
}
@@ -188,7 +189,6 @@ struct kinkBuilder {
188189
}
189190
return false;
190191
}
191-
192192
return false; // fallback
193193
}
194194

@@ -198,11 +198,9 @@ struct kinkBuilder {
198198
if (!kaontopologhy && (!candidate.hasTPC() || !candidate.hasITS())) {
199199
return false;
200200
}
201-
202201
if (kaontopologhy && (!candidate.hasTPC() || candidate.hasITS())) {
203202
return false;
204203
}
205-
206204
if (askTOFforDaug && !candidate.hasTOF()) {
207205
return false;
208206
}
@@ -214,17 +212,14 @@ struct kinkBuilder {
214212
{
215213
svCreator.clearPools();
216214
svCreator.fillBC2Coll(collisions, bcs);
217-
218215
for (const auto& track : tracks) {
219-
220216
bool isDaug = selectDaugTrack(track);
221217
bool isMoth = selectMothTrack(track);
222218

223219
if (!isDaug && !isMoth)
224220
continue;
225221
if (isDaug && std::abs(track.eta()) > etaMaxDaug)
226222
continue;
227-
228223
if (isMoth && std::abs(track.eta()) > etaMaxMoth)
229224
continue;
230225

@@ -234,7 +229,7 @@ struct kinkBuilder {
234229
auto& kinkPool = svCreator.getSVCandPool(collisions, !unlikeSignBkg);
235230

236231
for (const auto& svCand : kinkPool) {
237-
kinkCandidate kinkCand;
232+
KinkCandidate kinkCand;
238233

239234
auto trackMoth = tracks.rawIteratorAt(svCand.tr0Idx);
240235
auto trackDaug = tracks.rawIteratorAt(svCand.tr1Idx);
@@ -263,14 +258,12 @@ struct kinkBuilder {
263258
if ((std::abs(trackParCovMoth.getPhi() - trackParCovDaug.getPhi()) * radToDeg) > maxPhiDiff) {
264259
continue;
265260
}
266-
267261
// propagate to PV
268262
std::array<float, 2> dcaInfoDaug;
269263
o2::base::Propagator::Instance()->propagateToDCABxByBz({primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, trackParCovDaug, 2.f, static_cast<o2::base::Propagator::MatCorrType>(cfgMaterialCorrection.value), &dcaInfoDaug);
270264
if (std::abs(dcaInfoDaug[0]) < minDCADaugToPV) {
271265
continue;
272266
}
273-
274267
int nCand = 0;
275268
try {
276269
nCand = fitter.process(trackParCovMoth, trackParCovDaug);
@@ -281,21 +274,19 @@ struct kinkBuilder {
281274
if (nCand == 0) {
282275
continue;
283276
}
284-
285277
if (!fitter.propagateTracksToVertex()) {
286278
continue;
287279
}
288-
289280
auto propMothTrack = fitter.getTrack(0);
290281
auto propDaugTrack = fitter.getTrack(1);
291282
kinkCand.decVtx = fitter.getPCACandidatePos();
292-
293-
for (int i = 0; i < 3; i++) {
283+
const int vtxp = 3;
284+
for (int i = 0; i < vtxp; i++) {
294285
kinkCand.decVtx[i] -= kinkCand.primVtx[i];
295286
}
296287
propMothTrack.getPxPyPzGlo(kinkCand.momMoth);
297288
propDaugTrack.getPxPyPzGlo(kinkCand.momDaug);
298-
for (int i = 0; i < 3; i++) {
289+
for (int i = 0; i < vtxp; i++) {
299290
kinkCand.momMoth[i] *= charge;
300291
kinkCand.momDaug[i] *= charge;
301292
}
@@ -352,19 +343,19 @@ struct kinkBuilder {
352343
kinkCand.dcaXYmoth, kinkCand.dcaXYdaug, kinkCand.dcaKinkTopo);
353344
}
354345
}
355-
PROCESS_SWITCH(kinkBuilder, process, "Produce kink tables", false);
346+
PROCESS_SWITCH(KinkBuilder, process, "Produce kink tables", false);
356347
};
357348

358-
struct spectraKinkPiKa {
349+
struct SpectraKinkPiKa {
359350
Service<o2::framework::O2DatabasePDG> pdg;
360351
// Histograms are defined with HistogramRegistry
361352
HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
362353
HistogramRegistry rpiKkink{"rpiKkink", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
363354

364355
// Configurable for event selection
365356
Configurable<float> cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"};
366-
Configurable<float> cutNSigmaKa{"cutNSigmaKa", 4, "NSigmaTPCKaon"};
367-
Configurable<float> cutNSigmaMu{"cutNSigmaMu", 4, "cutNSigmaMu"};
357+
Configurable<float> cutNsigmaKa{"cutNsigmaKa", 4, "NSigmaTPCKaon"};
358+
Configurable<float> cutNsigmaMu{"cutNsigmaMu", 4, "cutNSigmaMu"};
368359
Configurable<float> etaCut{"etaCut", 0.8, "etaCut"};
369360
Configurable<float> rapCut{"rapCut", 0.8, "rapCut"};
370361
Configurable<float> kinkanglecut{"kinkanglecut", 2.0, "kinkanglecut"};
@@ -388,8 +379,8 @@ struct spectraKinkPiKa {
388379
Configurable<bool> onlykaon{"onlykaon", 0, "kaon"};
389380
Configurable<bool> additionalhist{"additionalhist", 1, "additional histogram"};
390381
Configurable<bool> pvtrack{"pvtrack", 1, "pvtrack"};
391-
Configurable<bool> cfgUseITSRefit{"cfgUseITSRefit", 1, "ITS refit"};
392-
Configurable<bool> cfgUseTPCRefit{"cfgUseTPCRefit", 1, "TPC refit"};
382+
Configurable<bool> cfgUseItsRefit{"cfgUseItsRefit", 1, "ITS refit"};
383+
Configurable<bool> cfgUseTpcRefit{"cfgUseTpcRefit", 1, "TPC refit"};
393384

394385
ConfigurableAxis ptAxis{"ptAxis", {150, 0, 15}, ""};
395386
ConfigurableAxis qtAxis{"qtAxis", {2000, 0.0, 2.0}, ""};
@@ -493,30 +484,26 @@ struct spectraKinkPiKa {
493484
}
494485
}
495486

496-
double computeMotherMass(ROOT::Math::PxPyPzMVector p_moth, ROOT::Math::PxPyPzMVector p_daug)
487+
double computeMotherMass(ROOT::Math::PxPyPzMVector pmoth, ROOT::Math::PxPyPzMVector pdaug)
497488
{
498489
// Infer neutrino momentum from conservation
499-
ROOT::Math::XYZVector p_nu_vec = p_moth.Vect() - p_daug.Vect();
500-
490+
ROOT::Math::XYZVector pnuvec = pmoth.Vect() - pdaug.Vect();
501491
// Neutrino energy (massless): E_nu = |p_nu|
502-
double E_nu = p_nu_vec.R();
503-
492+
double enu = pnuvec.R();
504493
// Total energy of the system
505-
double E_total = p_daug.E() + E_nu;
506-
494+
double etotal = pdaug.E() + enu;
507495
// Total momentum = p_nu + p_daug
508-
ROOT::Math::XYZVector p_total_vec = p_nu_vec + p_daug.Vect();
509-
double p_total_sq = p_total_vec.Mag2();
510-
496+
ROOT::Math::XYZVector ptotalvec = pnuvec + pdaug.Vect();
497+
double ptotalsq = ptotalvec.Mag2();
511498
// Invariant mass from E² - |p|²
512-
double m2 = E_total * E_total - p_total_sq;
499+
double m2 = etotal * etotal - ptotalsq;
513500
return (m2 > 0) ? std::sqrt(m2) : -1.0;
514501
}
515-
double computeQt(ROOT::Math::PxPyPzMVector p_moth, ROOT::Math::PxPyPzMVector p_daug)
502+
double computeQt(ROOT::Math::PxPyPzMVector pmoth, ROOT::Math::PxPyPzMVector pdaug)
516503
{
517-
TVector3 pdlab(p_daug.Px(), p_daug.Py(), p_daug.Pz());
504+
TVector3 pdlab(pdaug.Px(), pdaug.Py(), pdaug.Pz());
518505
// Compute transverse component
519-
TVector3 motherDir(p_moth.Px(), p_moth.Py(), p_moth.Pz());
506+
TVector3 motherDir(pmoth.Px(), pmoth.Py(), pmoth.Pz());
520507
double ptd = pdlab.Perp(motherDir); // or p_d_lab.Mag() * sin(theta)
521508
return ptd;
522509
}
@@ -575,9 +562,9 @@ struct spectraKinkPiKa {
575562
continue;
576563

577564
rpiKkink.fill(HIST("h1_tracks_data"), 4.0);
578-
if (cfgUseITSRefit && !(o2::aod::track::ITSrefit))
565+
if (cfgUseItsRefit && !(o2::aod::track::ITSrefit))
579566
continue;
580-
if (cfgUseTPCRefit && !(o2::aod::track::TPCrefit))
567+
if (cfgUseTpcRefit && !(o2::aod::track::TPCrefit))
581568
continue;
582569
rpiKkink.fill(HIST("h1_tracks_data"), 5.0);
583570
bool kaon = false;
@@ -605,14 +592,14 @@ struct spectraKinkPiKa {
605592
if (mothTrack.tpcNClsFound() > maxtpcncle || mothTrack.tpcNClsFound() < mintpcncle)
606593
continue;
607594
rpiKkink.fill(HIST("h1_tracks_data"), 8.0);
608-
if (std::abs(mothTrack.tpcNSigmaKa()) < cutNSigmaKa) {
595+
if (std::abs(mothTrack.tpcNSigmaKa()) < cutNsigmaKa) {
609596
kaon = true;
610597
}
611598
if (!kaon) {
612599
continue;
613600
}
614601
rpiKkink.fill(HIST("h1_tracks_data"), 9.0);
615-
if (cutNSigmaMu != -1 && std::abs(dauTrack.tpcNSigmaMu()) > cutNSigmaMu) {
602+
if (cutNsigmaMu != -1 && std::abs(dauTrack.tpcNSigmaMu()) > cutNsigmaMu) {
616603
continue;
617604
}
618605
double radiusxy = std::sqrt(kinkCand.xDecVtx() * kinkCand.xDecVtx() + kinkCand.yDecVtx() * kinkCand.yDecVtx());
@@ -685,7 +672,7 @@ struct spectraKinkPiKa {
685672
}
686673
}
687674
}
688-
PROCESS_SWITCH(spectraKinkPiKa, processData, "Data processing", true);
675+
PROCESS_SWITCH(SpectraKinkPiKa, processData, "Data processing", true);
689676

690677
void processMC(CollisionsFullMC const& collisions, aod::KinkCands const& KinkCands, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const& particlesMC, TracksFull const&)
691678
{
@@ -745,10 +732,10 @@ struct spectraKinkPiKa {
745732
rpiKkink.fill(HIST("h2_kaon_pt_vs_rap_rec_full"), v0.Pt(), v0.Rapidity());
746733
}
747734
}
748-
if (cfgUseITSRefit && !(o2::aod::track::ITSrefit))
735+
if (cfgUseItsRefit && !(o2::aod::track::ITSrefit))
749736
continue;
750737
rpiKkink.fill(HIST("h1_tracks"), 4.0);
751-
if (cfgUseTPCRefit && !(o2::aod::track::TPCrefit))
738+
if (cfgUseTpcRefit && !(o2::aod::track::TPCrefit))
752739
continue;
753740
rpiKkink.fill(HIST("h1_tracks"), 5.0);
754741

@@ -770,7 +757,7 @@ struct spectraKinkPiKa {
770757
continue;
771758
rpiKkink.fill(HIST("h1_tracks"), 7.0);
772759
bool kaon = false;
773-
if (std::abs(mothTrack.tpcNSigmaKa()) < cutNSigmaKa) {
760+
if (std::abs(mothTrack.tpcNSigmaKa()) < cutNsigmaKa) {
774761
kaon = true;
775762
}
776763
if (dptCut && v1.Pt() > v0.Pt())
@@ -840,7 +827,8 @@ struct spectraKinkPiKa {
840827
if (!mcTrackDau.has_mothers())
841828
continue;
842829
rpiKkink.fill(HIST("h1_tracks"), 14.0);
843-
if (mcTrackDau.getProcess() != 4)
830+
const int process = 4;
831+
if (mcTrackDau.getProcess() != process)
844832
continue;
845833

846834
rpiKkink.fill(HIST("h1_tracks"), 15.0);
@@ -914,18 +902,17 @@ struct spectraKinkPiKa {
914902
int piond = 0;
915903
int eld = 0;
916904
double ptd = 0;
905+
const int process = 4;
917906
for (const auto& daughter : mcPart.daughters_as<aod::McParticles>()) {
918-
if (daughter.getProcess() != 4)
907+
if (daughter.getProcess() != process)
919908
continue;
920909
v1.SetCoordinates(daughter.px(), daughter.py(), daughter.pz(), o2::constants::physics::MassMuon);
921910
ptd = computeQt(v0, v1);
922-
if (std::abs(daughter.pdgCode()) == 11) {
911+
if (std::abs(daughter.pdgCode()) == kElectron) {
923912
eld++;
924-
} else if (std::abs(daughter.pdgCode()) == 13) {
913+
} else if (std::abs(daughter.pdgCode()) == kMuonPlus) {
925914
muond++;
926-
}
927-
928-
else if (std::abs(daughter.pdgCode()) == 211) {
915+
} else if (std::abs(daughter.pdgCode()) == kPiPlus) {
929916
piond++;
930917
}
931918
}
@@ -959,12 +946,12 @@ struct spectraKinkPiKa {
959946
}
960947
}
961948
}
962-
PROCESS_SWITCH(spectraKinkPiKa, processMC, "MC processing", false);
949+
PROCESS_SWITCH(SpectraKinkPiKa, processMC, "MC processing", false);
963950
};
964951

965952
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
966953
{
967-
auto builderTask = adaptAnalysisTask<kinkBuilder>(cfgc);
968-
auto spectraTask = adaptAnalysisTask<spectraKinkPiKa>(cfgc);
954+
auto builderTask = adaptAnalysisTask<KinkBuilder>(cfgc);
955+
auto spectraTask = adaptAnalysisTask<SpectraKinkPiKa>(cfgc);
969956
return {builderTask, spectraTask}; // Just return both tasks
970957
}

0 commit comments

Comments
 (0)