Skip to content

Commit 9cfa928

Browse files
[PWGLF] centrality variable with less memory consuption (#12629)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 2446731 commit 9cfa928

File tree

1 file changed

+96
-116
lines changed

1 file changed

+96
-116
lines changed

PWGLF/Tasks/Nuspex/nucleitpcpbpb.cxx

Lines changed: 96 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,25 @@ constexpr double kBetheBlochDefault[nParticles][nBetheParams]{
6767
{5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09}, // triton
6868
{-126.557359, -0.858569, 1.111643, 1.210323, 2.656374, 0.09}, // helion
6969
{-126.557359, -0.858569, 1.111643, 1.210323, 2.656374, 0.09}}; // alpha
70-
const int nTrkSettings = 19;
71-
static const std::vector<std::string> trackPIDsettingsNames{"useBBparams", "minITSnCls", "minITSnClscos", "minTPCnCls", "maxTPCchi2", "minTPCchi2", "maxITSchi2", "minRigidity", "maxRigidity", "maxTPCnSigma", "TOFrequiredabove", "minTOFmass", "maxTOFmass", "maxDcaXY", "maxDcaZ", "minITSclsSize", "maxITSclsSize", "minTPCnClsCrossedRows", "minReqClusterITSib"};
70+
const int nTrkSettings = 14;
71+
static const std::vector<std::string> trackPIDsettingsNames{"useBBparams", "minITSnCls", "minITSnClscos", "minTPCnCls", "maxTPCchi2", "minTPCchi2", "maxITSchi2", "maxTPCnSigma", "maxDcaXY", "maxDcaZ", "minITSclsSize", "maxITSclsSize", "minTPCnClsCrossedRows", "minReqClusterITSib"};
7272
constexpr double kTrackPIDSettings[nParticles][nTrkSettings]{
73-
{0, 0, 4, 60, 4.0, 0.5, 100, 0.15, 1.2, 2.5, -1, 0, 100, 2., 2., 0., 1000, 70, 1},
74-
{1, 0, 4, 70, 4.0, 0.5, 100, 0.20, 4.0, 3.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1},
75-
{1, 0, 4, 70, 4.0, 0.5, 100, 0.50, 5.0, 3.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1},
76-
{1, 0, 4, 70, 4.0, 0.5, 100, 0.50, 5.0, 3.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1},
77-
{1, 0, 4, 75, 4.0, 0.5, 100, 0.50, 5.0, 5.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1},
78-
{1, 0, 4, 70, 4.0, 0.5, 100, 0.50, 5.0, 5.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1}};
73+
{0, 0, 4, 60, 4.0, 0.5, 100, 2.5, 2., 2., 0., 1000, 70, 1},
74+
{1, 0, 4, 70, 4.0, 0.5, 100, 3.0, 2., 2., 0., 1000, 70, 1},
75+
{1, 0, 4, 70, 4.0, 0.5, 100, 3.0, 2., 2., 0., 1000, 70, 1},
76+
{1, 0, 4, 70, 4.0, 0.5, 100, 3.0, 2., 2., 0., 1000, 70, 1},
77+
{1, 0, 4, 75, 4.0, 0.5, 100, 5.0, 2., 2., 0., 1000, 70, 1},
78+
{1, 0, 4, 70, 4.0, 0.5, 100, 5.0, 2., 2., 0., 1000, 70, 1}};
7979

80-
const int nTrkSettings2 = 3;
81-
static const std::vector<std::string> trackPIDsettingsNames2{"useITSnsigma", "minITSnsigma", "maxITSnsigma"};
80+
const int nTrkSettings2 = 4;
81+
static const std::vector<std::string> trackPIDsettingsNames2{"useITSnsigma", "minITSnsigma", "maxITSnsigma", "fillsparsh"};
8282
constexpr double kTrackPIDSettings2[nParticles][nTrkSettings2]{
83-
{1, -5, 4},
84-
{1, -5, 4},
85-
{1, -5, 4},
86-
{1, -5, 4},
87-
{1, -5, 4},
88-
{1, -5, 4}};
83+
{1, -5, 4, 0},
84+
{1, -5, 4, 0},
85+
{1, -5, 4, 0},
86+
{1, -5, 4, 1},
87+
{1, -5, 4, 1},
88+
{1, -5, 4, 1}};
8989

9090
struct PrimParticles {
9191
TString name;
@@ -139,30 +139,23 @@ struct NucleitpcPbPb {
139139
Configurable<bool> cfgminReqClusterITSibRequire{"cfgminReqClusterITSibRequire", true, " Require min number of clusters required in ITS inner barrel"};
140140
Configurable<bool> cfgmaxITSchi2Require{"cfgmaxITSchi2Require", true, "Require maxITSchi2 Cut"};
141141
Configurable<bool> cfgmaxTPCnSigmaRequire{"cfgmaxTPCnSigmaRequire", true, "Require maxTPCnSigma Cut"};
142-
Configurable<bool> cfgmaxITSnSigmaRequire{"cfgmaxITSnSigmaRequire", true, "Require maxITSnSigma Cut for helium"};
143142
Configurable<bool> cfgminGetMeanItsClsSizeRequire{"cfgminGetMeanItsClsSizeRequire", true, "Require minGetMeanItsClsSize Cut"};
144143
Configurable<bool> cfgmaxGetMeanItsClsSizeRequire{"cfgmaxGetMeanItsClsSizeRequire", true, "Require maxGetMeanItsClsSize Cut"};
145-
Configurable<bool> cfgRigidityCutRequire{"cfgRigidityCutRequire", true, "Require Rigidity Cut"};
146-
Configurable<bool> cfgmassRequire{"cfgmassRequire", true, "Require mass Cuts"};
147144
Configurable<bool> cfgDCAwithptRequire{"cfgDCAwithptRequire", true, "Require DCA cuts with pt dependance"};
148145
Configurable<bool> cfgDCAnopt{"cfgDCAnopt", true, "Require DCA cuts without pt dependance"};
149-
Configurable<bool> cfgTwicemass{"cfgTwicemass", true, "multiply mass by its charge"};
150146
Configurable<bool> cfgRequirebetaplot{"cfgRequirebetaplot", true, "Require beta plot"};
151-
Configurable<bool> cfgRequireMCposZ{"cfgRequireMCposZ", true, "Require beta plot"};
152147

153148
Configurable<LabeledArray<double>> cfgBetheBlochParams{"cfgBetheBlochParams", {kBetheBlochDefault[0], nParticles, nBetheParams, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for light nuclei"};
154149
Configurable<LabeledArray<double>> cfgTrackPIDsettings{"cfgTrackPIDsettings", {kTrackPIDSettings[0], nParticles, nTrkSettings, particleNames, trackPIDsettingsNames}, "track selection and PID criteria"};
155150
Configurable<LabeledArray<double>> cfgTrackPIDsettings2{"cfgTrackPIDsettings2", {kTrackPIDSettings2[0], nParticles, nTrkSettings2, particleNames, trackPIDsettingsNames2}, "track selection and PID criteria"};
156151
Configurable<bool> cfgFillhspectra{"cfgFillhspectra", true, "fill data sparsh"};
157-
Configurable<bool> cfgFillQAplots{"cfgFillQAplots", false, "Fill QA sparsh"};
158152
Configurable<bool> cfgFillmass{"cfgFillmass", false, "Fill mass histograms"};
159153
Configurable<float> centcut{"centcut", 80.0f, "centrality cut"};
160154
Configurable<float> cfgCutRapidity{"cfgCutRapidity", 0.5f, "Rapidity range"};
161155
Configurable<float> cfgZvertex{"cfgZvertex", 10, "Min Z Vertex"};
162156
Configurable<bool> cfgZvertexRequire{"cfgZvertexRequire", true, "Pos Z cut require"};
163157
Configurable<bool> cfgZvertexRequireMC{"cfgZvertexRequireMC", true, "Pos Z cut require for generated particles"};
164158
Configurable<bool> cfgsel8Require{"cfgsel8Require", true, "sel8 cut require"};
165-
Configurable<float> cfgITSnsigma{"cfgITSnsigma", 5, "Max ITS nsigma value"};
166159
Configurable<float> cfgtpcNClsFound{"cfgtpcNClsFound", 100.0f, "min. no. of tpcNClsFound"};
167160
Configurable<float> cfgitsNCls{"cfgitsNCls", 2.0f, "min. no. of itsNCls"};
168161
o2::track::TrackParametrizationWithError<float> mTrackParCov;
@@ -242,8 +235,6 @@ struct NucleitpcPbPb {
242235

243236
histos.add<THnSparse>("hSpectra", " ", HistType::kTHnSparseF, {speciesBitAxis, ptAxis, nsigmaAxis, {5, -2.5, 2.5}, axisCent, axisRigidity, axisdEdx, axisDCA, axisDCA, nsigmaAxis});
244237

245-
histos.add<THnSparse>("hQAtest", "", HistType::kTHnSparseF, {speciesBitAxis, ptAxis, {5, -2.5, 2.5}, axisTPCcls, axisITScls, axisITSchi2, axisTPCchi2});
246-
247238
if (doprocessMC) {
248239
histomc.add("histVtxZgen", "histVtxZgen", kTH1F, {axisVtxZ});
249240
histomc.add("ImptParameter", "ImptParameter", kTH1F, {axisImpt});
@@ -267,90 +258,6 @@ struct NucleitpcPbPb {
267258
}
268259
}
269260
//----------------------------------------------------------------------------------------------------------------
270-
void findprimaryParticles(aod::TrackAssoc const& tracksByColl, TracksFull const& tracks, float cent)
271-
{
272-
for (const auto& trackId : tracksByColl) {
273-
const auto& track = tracks.rawIteratorAt(trackId.trackId());
274-
if (!track.isPVContributor() && cfgUsePVcontributors)
275-
continue;
276-
if (!track.hasITS() && cfgITSrequire)
277-
continue;
278-
if (!track.hasTPC() && cfgTPCrequire)
279-
continue;
280-
if (!track.passedITSRefit() && cfgPassedITSRefit)
281-
continue;
282-
if (!track.passedTPCRefit() && cfgPassedTPCRefit)
283-
continue;
284-
if (std::abs(track.eta()) > cfgCutEta && cfgetaRequire)
285-
continue;
286-
for (size_t i = 0; i < primaryParticles.size(); i++) {
287-
288-
float ptMomn;
289-
setTrackParCov(track, mTrackParCov);
290-
mTrackParCov.setPID(track.pidForTracking());
291-
ptMomn = (i == he3 || i == he4) ? 2 * mTrackParCov.getPt() : mTrackParCov.getPt();
292-
int sign = 0;
293-
if (track.sign() > 0) {
294-
sign = 1;
295-
}
296-
if (track.sign() < 0) {
297-
sign = -1;
298-
} // <- This redeclares a new local variable!
299-
if (cfgFillQAplots) {
300-
histos.fill(HIST("hQAtest"), i, ptMomn, sign, track.tpcNClsFound(), track.itsNCls(), track.itsChi2NCl(), track.tpcChi2NCl());
301-
}
302-
if (std::abs(getRapidity(track, i)) > cfgCutRapidity && cfgRapidityRequire)
303-
continue;
304-
if (track.tpcNClsFound() < cfgTrackPIDsettings->get(i, "minTPCnCls") && cfgTPCNClsfoundRequire)
305-
continue;
306-
if (((track.tpcNClsCrossedRows() < cfgTrackPIDsettings->get(i, "minTPCnClsCrossedRows")) || track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable()) && cfgTPCNClsCrossedRowsRequire) // o2-linter: disable=magic-number (To be checked)
307-
continue;
308-
if (track.tpcChi2NCl() > cfgTrackPIDsettings->get(i, "maxTPCchi2") && cfgmaxTPCchi2Require)
309-
continue;
310-
if (track.tpcChi2NCl() < cfgTrackPIDsettings->get(i, "minTPCchi2") && cfgminTPCchi2Require)
311-
continue;
312-
if (track.itsNCls() < cfgTrackPIDsettings->get(i, "minITSnCls") && cfgminITSnClsRequire)
313-
continue;
314-
double cosheta = std::cosh(track.eta());
315-
if ((track.itsNCls() / cosheta) < cfgTrackPIDsettings->get(i, "minITSnClscos") && cfgminITSnClscosRequire)
316-
continue;
317-
if ((track.itsNClsInnerBarrel() < cfgTrackPIDsettings->get(i, "minReqClusterITSib")) && cfgminReqClusterITSibRequire)
318-
continue;
319-
if (track.itsChi2NCl() > cfgTrackPIDsettings->get(i, "maxITSchi2") && cfgmaxITSchi2Require)
320-
continue;
321-
if (getMeanItsClsSize(track) < cfgTrackPIDsettings->get(i, "minITSclsSize") && cfgminGetMeanItsClsSizeRequire)
322-
continue;
323-
if (getMeanItsClsSize(track) > cfgTrackPIDsettings->get(i, "maxITSclsSize") && cfgmaxGetMeanItsClsSizeRequire)
324-
continue;
325-
326-
bool insideDCAxy = (std::abs(track.dcaXY()) <= (cfgTrackPIDsettings->get(i, "maxDcaXY") * (0.0105f + 0.0350f / std::pow(ptMomn, 1.1f)))); // o2-linter: disable=magic-number (To be checked)
327-
if ((!(insideDCAxy) || std::abs(track.dcaZ()) > dcazSigma(ptMomn, cfgTrackPIDsettings->get(i, "maxDcaZ"))) && cfgDCAwithptRequire)
328-
continue;
329-
330-
float tpcNsigma = getTPCnSigma(track, primaryParticles.at(i));
331-
if ((std::abs(tpcNsigma) > cfgTrackPIDsettings->get(i, "maxTPCnSigma")) && cfgmaxTPCnSigmaRequire)
332-
continue;
333-
float itsSigma = getITSnSigma(track, primaryParticles.at(i));
334-
335-
if (itsSigma < cfgTrackPIDsettings2->get(i, "minITSnsigma") && cfgTrackPIDsettings2->get(i, "useITSnsigma") < 1)
336-
continue;
337-
if (itsSigma > cfgTrackPIDsettings2->get(i, "maxITSnsigma") && cfgTrackPIDsettings2->get(i, "useITSnsigma") < 1)
338-
continue;
339-
340-
fillhmass(track, i);
341-
if (cfgFillhspectra) {
342-
histos.fill(HIST("hSpectra"), i, ptMomn, tpcNsigma, sign, cent, getRigidity(track) * track.sign(), track.tpcSignal(), track.dcaZ(), track.dcaXY(), itsSigma);
343-
}
344-
if (cfgRequirebetaplot) {
345-
histos.fill(HIST("Tofsignal"), getRigidity(track) * track.sign(), o2::pid::tof::Beta::GetBeta(track));
346-
}
347-
}
348-
if (track.tpcNClsFound() < cfgtpcNClsFound || track.itsNCls() < cfgitsNCls) {
349-
histos.fill(HIST("Tpcsignal"), getRigidity(track) * track.sign(), track.tpcSignal());
350-
}
351-
histos.fill(HIST("histeta"), track.eta());
352-
} // track loop
353-
}
354261
//----------------------------------------------------------------------------------------------------------------
355262
void processData(CollisionsFull const& collisions, TracksFull const& tracks, aod::BCsWithTimestamps const&, aod::TrackAssoc const& tracksColl)
356263
{
@@ -375,10 +282,86 @@ struct NucleitpcPbPb {
375282
histos.fill(HIST("histCentFTOC_cut"), collision.centFT0C());
376283
const uint64_t collIdx = collision.globalIndex();
377284
auto tracksByColl = tracksColl.sliceBy(perCollision, collIdx);
285+
/////////////////////////////////////////////////////////////////////////////////
286+
for (const auto& trackId : tracksByColl) {
287+
const auto& track = tracks.rawIteratorAt(trackId.trackId());
288+
if (!track.isPVContributor() && cfgUsePVcontributors)
289+
continue;
290+
if (!track.hasITS() && cfgITSrequire)
291+
continue;
292+
if (!track.hasTPC() && cfgTPCrequire)
293+
continue;
294+
if (!track.passedITSRefit() && cfgPassedITSRefit)
295+
continue;
296+
if (!track.passedTPCRefit() && cfgPassedTPCRefit)
297+
continue;
298+
if (std::abs(track.eta()) > cfgCutEta && cfgetaRequire)
299+
continue;
300+
for (size_t i = 0; i < primaryParticles.size(); i++) {
378301

379-
findprimaryParticles(tracksByColl, tracks, collision.centFT0C());
380-
if (!collHasCandidate)
381-
continue;
302+
float ptMomn;
303+
setTrackParCov(track, mTrackParCov);
304+
mTrackParCov.setPID(track.pidForTracking());
305+
ptMomn = (i == he3 || i == he4) ? 2 * mTrackParCov.getPt() : mTrackParCov.getPt();
306+
int sign = 0;
307+
if (track.sign() > 0) {
308+
sign = 1;
309+
}
310+
if (track.sign() < 0) {
311+
sign = -1;
312+
} // <- This redeclares a new local variable!
313+
if (std::abs(getRapidity(track, i)) > cfgCutRapidity && cfgRapidityRequire)
314+
continue;
315+
if (track.tpcNClsFound() < cfgTrackPIDsettings->get(i, "minTPCnCls") && cfgTPCNClsfoundRequire)
316+
continue;
317+
if (((track.tpcNClsCrossedRows() < cfgTrackPIDsettings->get(i, "minTPCnClsCrossedRows")) || track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable()) && cfgTPCNClsCrossedRowsRequire) // o2-linter: disable=magic-number (To be checked)
318+
continue;
319+
if (track.tpcChi2NCl() > cfgTrackPIDsettings->get(i, "maxTPCchi2") && cfgmaxTPCchi2Require)
320+
continue;
321+
if (track.tpcChi2NCl() < cfgTrackPIDsettings->get(i, "minTPCchi2") && cfgminTPCchi2Require)
322+
continue;
323+
if (track.itsNCls() < cfgTrackPIDsettings->get(i, "minITSnCls") && cfgminITSnClsRequire)
324+
continue;
325+
double cosheta = std::cosh(track.eta());
326+
if ((track.itsNCls() / cosheta) < cfgTrackPIDsettings->get(i, "minITSnClscos") && cfgminITSnClscosRequire)
327+
continue;
328+
if ((track.itsNClsInnerBarrel() < cfgTrackPIDsettings->get(i, "minReqClusterITSib")) && cfgminReqClusterITSibRequire)
329+
continue;
330+
if (track.itsChi2NCl() > cfgTrackPIDsettings->get(i, "maxITSchi2") && cfgmaxITSchi2Require)
331+
continue;
332+
if (getMeanItsClsSize(track) < cfgTrackPIDsettings->get(i, "minITSclsSize") && cfgminGetMeanItsClsSizeRequire)
333+
continue;
334+
if (getMeanItsClsSize(track) > cfgTrackPIDsettings->get(i, "maxITSclsSize") && cfgmaxGetMeanItsClsSizeRequire)
335+
continue;
336+
337+
bool insideDCAxy = (std::abs(track.dcaXY()) <= (cfgTrackPIDsettings->get(i, "maxDcaXY") * (0.0105f + 0.0350f / std::pow(ptMomn, 1.1f)))); // o2-linter: disable=magic-number (To be checked)
338+
if ((!(insideDCAxy) || std::abs(track.dcaZ()) > dcazSigma(ptMomn, cfgTrackPIDsettings->get(i, "maxDcaZ"))) && cfgDCAwithptRequire)
339+
continue;
340+
341+
float tpcNsigma = getTPCnSigma(track, primaryParticles.at(i));
342+
if ((std::abs(tpcNsigma) > cfgTrackPIDsettings->get(i, "maxTPCnSigma")) && cfgmaxTPCnSigmaRequire)
343+
continue;
344+
float itsSigma = getITSnSigma(track, primaryParticles.at(i));
345+
346+
if (itsSigma < cfgTrackPIDsettings2->get(i, "minITSnsigma") && cfgTrackPIDsettings2->get(i, "useITSnsigma") < 1)
347+
continue;
348+
if (itsSigma > cfgTrackPIDsettings2->get(i, "maxITSnsigma") && cfgTrackPIDsettings2->get(i, "useITSnsigma") < 1)
349+
continue;
350+
351+
fillhmass(track, i);
352+
if (cfgFillhspectra && cfgTrackPIDsettings2->get(i, "fillsparsh") == 1) {
353+
histos.fill(HIST("hSpectra"), i, ptMomn, tpcNsigma, sign, collision.centFT0C(), getRigidity(track) * track.sign(), track.tpcSignal(), track.dcaZ(), track.dcaXY(), itsSigma);
354+
}
355+
if (cfgRequirebetaplot) {
356+
histos.fill(HIST("Tofsignal"), getRigidity(track) * track.sign(), o2::pid::tof::Beta::GetBeta(track));
357+
}
358+
}
359+
if (track.tpcNClsFound() > cfgtpcNClsFound || track.itsNCls() > cfgitsNCls) {
360+
histos.fill(HIST("Tpcsignal"), getRigidity(track) * track.sign(), track.tpcSignal());
361+
}
362+
histos.fill(HIST("histeta"), track.eta());
363+
} // track loop
364+
///////////////////////////////////////////////
382365
}
383366
}
384367
PROCESS_SWITCH(NucleitpcPbPb, processData, "data analysis", false);
@@ -496,9 +479,6 @@ struct NucleitpcPbPb {
496479
if (track.sign() < 0) {
497480
sign = -1;
498481
} // <- This redeclares a new local variable!
499-
if (cfgFillQAplots) {
500-
histos.fill(HIST("hQAtest"), i, ptMomn, sign, track.tpcNClsFound(), track.itsNCls(), track.itsChi2NCl(), track.tpcChi2NCl());
501-
}
502482
if (std::abs(getRapidity(track, i)) > cfgCutRapidity && cfgRapidityRequire)
503483
continue;
504484
if (track.tpcNClsFound() < cfgTrackPIDsettings->get(i, "minTPCnCls") && cfgTPCNClsfoundRequire)
@@ -538,7 +518,7 @@ struct NucleitpcPbPb {
538518
continue;
539519

540520
fillhmass(track, i);
541-
if (cfgFillhspectra) {
521+
if (cfgFillhspectra && cfgTrackPIDsettings2->get(i, "fillsparsh") == 1) {
542522
histos.fill(HIST("hSpectra"), i, ptMomn, tpcNsigma, sign, collision.centFT0C(), getRigidity(track) * track.sign(), track.tpcSignal(), track.dcaZ(), track.dcaXY(), itsSigma);
543523
}
544524
if (cfgRequirebetaplot) {

0 commit comments

Comments
 (0)