Skip to content

Commit 0ddaf27

Browse files
[PWGLF]: Fill DCA THnSparse with pdgcode in MCProcess, add pt correction for He tof Mass (#7005)
1 parent 2b54595 commit 0ddaf27

1 file changed

Lines changed: 78 additions & 30 deletions

File tree

PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx

Lines changed: 78 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,16 @@ struct NucleusCandidate {
7676
float TPCsignal;
7777
float ITSchi2;
7878
float TPCchi2;
79+
std::array<float, 5> nSigmaTPC;
80+
std::array<float, 5> tofMasses;
81+
bool fillTree;
82+
bool fillDCAHist;
7983
uint16_t flags;
8084
uint8_t TPCfindableCls;
8185
uint8_t TPCcrossedRows;
8286
uint8_t ITSclsMap;
8387
uint8_t TPCnCls;
88+
uint8_t ITSnCls;
8489
uint32_t clusterSizesITS;
8590
};
8691

@@ -143,12 +148,12 @@ constexpr int FlowHistDefault[5][1]{
143148
{0},
144149
{0},
145150
{0}};
146-
constexpr int DCAHistDefault[5][1]{
147-
{0},
148-
{0},
149-
{0},
150-
{0},
151-
{0}};
151+
constexpr int DCAHistDefault[5][2]{
152+
{0, 0},
153+
{0, 0},
154+
{0, 0},
155+
{0, 0},
156+
{0, 0}};
152157
constexpr double DownscalingDefault[5][1]{
153158
{1.},
154159
{1.},
@@ -165,7 +170,7 @@ static const std::vector<std::string> pidName{"TPC", "TOF"};
165170
static const std::vector<std::string> names{"proton", "deuteron", "triton", "He3", "alpha"};
166171
static const std::vector<std::string> treeConfigNames{"Filter trees", "Use TOF selection"};
167172
static const std::vector<std::string> flowConfigNames{"Save flow hists"};
168-
static const std::vector<std::string> DCAConfigNames{"Save DCA hists"};
173+
static const std::vector<std::string> DCAConfigNames{"Save DCA hist", "Matter/Antimatter"};
169174
static const std::vector<std::string> nSigmaConfigName{"nsigma_min", "nsigma_max"};
170175
static const std::vector<std::string> nDCAConfigName{"max DCAxy", "max DCAz"};
171176
static const std::vector<std::string> DownscalingConfigName{"Fraction of kept candidates"};
@@ -242,8 +247,8 @@ struct nucleiSpectra {
242247
Configurable<LabeledArray<double>> cfgDCAcut{"cfgDCAcut", {nuclei::DCAcutDefault[0], 5, 2, nuclei::names, nuclei::nDCAConfigName}, "Max DCAxy and DCAz for light nuclei"};
243248
Configurable<LabeledArray<double>> cfgDownscaling{"cfgDownscaling", {nuclei::DownscalingDefault[0], 5, 1, nuclei::names, nuclei::DownscalingConfigName}, "Fraction of kept candidates for light nuclei"};
244249
Configurable<LabeledArray<int>> cfgTreeConfig{"cfgTreeConfig", {nuclei::TreeConfigDefault[0], 5, 2, nuclei::names, nuclei::treeConfigNames}, "Filtered trees configuration"};
250+
Configurable<LabeledArray<int>> cfgDCAHists{"cfgDCAHists", {nuclei::DCAHistDefault[0], 5, 2, nuclei::names, nuclei::DCAConfigNames}, "DCA hist configuration"};
245251
Configurable<LabeledArray<int>> cfgFlowHist{"cfgFlowHist", {nuclei::FlowHistDefault[0], 5, 1, nuclei::names, nuclei::flowConfigNames}, "Flow hist configuration"};
246-
Configurable<LabeledArray<int>> cfgDCAHist{"cfgDCAHist", {nuclei::DCAHistDefault[0], 5, 1, nuclei::names, nuclei::DCAConfigNames}, "DCA hist configuration"};
247252

248253
ConfigurableAxis cfgDCAxyBinsProtons{"cfgDCAxyBinsProtons", {1500, -1.5f, 1.5f}, "DCAxy binning for Protons"};
249254
ConfigurableAxis cfgDCAxyBinsDeuterons{"cfgDCAxyBinsDeuterons", {1500, -1.5f, 1.5f}, "DCAxy binning for Deuterons"};
@@ -501,10 +506,12 @@ struct nucleiSpectra {
501506
}
502507

503508
bool selectedTPC[5]{false}, goodToAnalyse{false};
509+
std::array<float, 5> nSigmaTPC;
504510
for (int iS{0}; iS < nuclei::species; ++iS) {
505511
double expBethe{tpc::BetheBlochAleph(static_cast<double>(correctedTpcInnerParam * bgScalings[iS][iC]), cfgBetheBlochParams->get(iS, 0u), cfgBetheBlochParams->get(iS, 1u), cfgBetheBlochParams->get(iS, 2u), cfgBetheBlochParams->get(iS, 3u), cfgBetheBlochParams->get(iS, 4u))};
506512
double expSigma{expBethe * cfgBetheBlochParams->get(iS, 5u)};
507513
nSigma[0][iS] = static_cast<float>((track.tpcSignal() - expBethe) / expSigma);
514+
nSigmaTPC[iS] = nSigma[0][iS];
508515
selectedTPC[iS] = (nSigma[0][iS] > nuclei::pidCuts[0][iS][0] && nSigma[0][iS] < nuclei::pidCuts[0][iS][1]);
509516
goodToAnalyse = goodToAnalyse || selectedTPC[iS];
510517
if (selectedTPC[iS] && track.p() > 0.2) {
@@ -524,6 +531,10 @@ struct nucleiSpectra {
524531
spectra.fill(HIST("hTofSignalData"), correctedTpcInnerParam, beta);
525532
beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked
526533
uint16_t flag = static_cast<uint16_t>((track.pidForTracking() & 0xF) << 12);
534+
std::array<float, 5> tofMasses{0.f, 0.f, 0.f, 0.f, 0.f};
535+
bool fillTree{false};
536+
bool fillDCAHist{false};
537+
527538
if (track.hasTOF()) {
528539
flag |= kHasTOF;
529540
}
@@ -540,7 +551,6 @@ struct nucleiSpectra {
540551
}
541552
ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<float>> fvector{trackParCov.getPt() * nuclei::charges[iS], trackParCov.getEta(), trackParCov.getPhi(), nuclei::masses[iS]};
542553
float y{fvector.Rapidity() + cfgCMrapidity};
543-
544554
for (int iPID{0}; iPID < 2; ++iPID) {
545555
if (selectedTPC[iS]) {
546556
if (iPID && !track.hasTOF()) {
@@ -552,46 +562,49 @@ struct nucleiSpectra {
552562
nuclei::hDCAxy[iPID][iS][iC]->Fill(centrality, fvector.pt(), dcaInfo[0]);
553563
nuclei::hDCAz[iPID][iS][iC]->Fill(centrality, fvector.pt(), dcaInfo[1]);
554564
if (std::abs(dcaInfo[0]) < cfgDCAcut->get(iS, 0u)) {
555-
float tofMass = -10.f;
556565
if (!iPID) { /// temporary exclusion of the TOF nsigma PID for the He3 and Alpha
557566
nuclei::hNsigma[iPID][iS][iC]->Fill(centrality, fvector.pt(), nSigma[iPID][iS]);
558567
nuclei::hNsigmaEta[iPID][iS][iC]->Fill(fvector.eta(), fvector.pt(), nSigma[iPID][iS]);
559568
}
560569
if (iPID) {
561-
tofMass = correctedTpcInnerParam * std::sqrt(1.f / (beta * beta) - 1.f) - nuclei::masses[iS];
562-
nuclei::hTOFmass[iS][iC]->Fill(centrality, fvector.pt(), tofMass);
563-
nuclei::hTOFmassEta[iS][iC]->Fill(fvector.eta(), fvector.pt(), tofMass);
570+
float charge{1};
571+
if (iS == 3 || iS == 4)
572+
charge = 2;
573+
tofMasses[iS] = correctedTpcInnerParam * charge * std::sqrt(1.f / (beta * beta) - 1.f) - nuclei::masses[iS];
574+
nuclei::hTOFmass[iS][iC]->Fill(centrality, fvector.pt(), tofMasses[iS]);
575+
nuclei::hTOFmassEta[iS][iC]->Fill(fvector.eta(), fvector.pt(), tofMasses[iS]);
564576
}
565577

566578
if (cfgFlowHist->get(iS) && doprocessDataFlow) {
567579
if constexpr (std::is_same<Tcoll, CollWithEP>::value) {
568580
auto deltaPhiInRange = getPhiInRange(fvector.phi() - collision.psiFT0C());
569581
auto v2 = std::cos(2.0 * deltaPhiInRange);
570-
nuclei::hFlowHists[iC][iS]->Fill(collision.centFT0C(), fvector.pt(), nSigma[0][iS], tofMass, v2, track.itsNCls(), track.tpcNClsFound());
582+
nuclei::hFlowHists[iC][iS]->Fill(collision.centFT0C(), fvector.pt(), nSigma[0][iS], tofMasses[iS], v2, track.itsNCls(), track.tpcNClsFound());
571583
}
572584
} else if (cfgFlowHist->get(iS) && doprocessDataFlowAlternative) {
573585
if constexpr (std::is_same<Tcoll, CollWithQvec>::value) {
574586
auto deltaPhiInRange = getPhiInRange(fvector.phi() - computeEventPlane(collision.qvecFT0CIm(), collision.qvecFT0CRe()));
575587
auto v2 = std::cos(2.0 * deltaPhiInRange);
576-
nuclei::hFlowHists[iC][iS]->Fill(collision.centFT0C(), fvector.pt(), nSigma[0][iS], tofMass, v2, track.itsNCls(), track.tpcNClsFound());
588+
nuclei::hFlowHists[iC][iS]->Fill(collision.centFT0C(), fvector.pt(), nSigma[0][iS], tofMasses[iS], v2, track.itsNCls(), track.tpcNClsFound());
577589
}
578590
}
579-
if (cfgDCAHist->get(iS)) {
580-
nuclei::hDCAHists[iC][iS]->Fill(fvector.pt(), dcaInfo[0], dcaInfo[1], nSigma[0][iS], tofMass, track.itsNCls(), track.tpcNClsFound());
581-
}
582591
}
583592
}
584593
}
585594
}
586-
587-
if (cfgTreeConfig->get(iS, 0u) && selectedTPC[iS]) {
595+
if (selectedTPC[iS]) {
588596
if (cfgTreeConfig->get(iS, 1u) && !selectedTOF) {
589597
continue;
590598
}
591-
if (cfgDownscaling->get(iS) < 1. && gRandom->Rndm() > cfgDownscaling->get(iS)) {
592-
continue;
599+
!fillTree && cfgTreeConfig->get(iS, 0u) ? fillTree = true : fillTree;
600+
!fillDCAHist && cfgDCAHists->get(iS, iC) ? fillDCAHist = true : fillDCAHist;
601+
bool setPartFlag = cfgTreeConfig->get(iS, 0u) || cfgDCAHists->get(iS, iC);
602+
if (setPartFlag) {
603+
if (cfgDownscaling->get(iS) < 1. && gRandom->Rndm() > cfgDownscaling->get(iS)) {
604+
continue;
605+
}
606+
flag |= BIT(iS);
593607
}
594-
flag |= BIT(iS);
595608
}
596609
}
597610
if (flag & (kProton | kDeuteron | kTriton | kHe3 | kHe4) || doprocessMC) { /// ignore PID pre-selections for the MC
@@ -624,7 +637,11 @@ struct nucleiSpectra {
624637
computeEventPlane(collision.qvecBPosIm(), collision.qvecBPosRe()),
625638
collision.multTPC()});
626639
}
627-
nuclei::candidates.emplace_back(NucleusCandidate{static_cast<int>(track.globalIndex()), (1 - 2 * iC) * trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), correctedTpcInnerParam, beta, collision.posZ(), dcaInfo[0], dcaInfo[1], track.tpcSignal(), track.itsChi2NCl(), track.tpcChi2NCl(), flag, track.tpcNClsFindable(), static_cast<uint8_t>(track.tpcNClsCrossedRows()), track.itsClusterMap(), static_cast<uint8_t>(track.tpcNClsFound()), static_cast<uint32_t>(track.itsClusterSizes())});
640+
nuclei::candidates.emplace_back(NucleusCandidate{
641+
static_cast<int>(track.globalIndex()), (1 - 2 * iC) * trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(),
642+
correctedTpcInnerParam, beta, collision.posZ(), dcaInfo[0], dcaInfo[1], track.tpcSignal(), track.itsChi2NCl(), track.tpcChi2NCl(),
643+
nSigmaTPC, tofMasses, fillTree, fillDCAHist, flag, track.tpcNClsFindable(), static_cast<uint8_t>(track.tpcNClsCrossedRows()), track.itsClusterMap(),
644+
static_cast<uint8_t>(track.tpcNClsFound()), static_cast<uint8_t>(track.itsNCls()), static_cast<uint32_t>(track.itsClusterSizes())});
628645
}
629646
} // end loop over tracks
630647

@@ -644,7 +661,16 @@ struct nucleiSpectra {
644661

645662
fillDataInfo(collision, tracks);
646663
for (auto& c : nuclei::candidates) {
647-
nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS);
664+
if (c.fillTree) {
665+
nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS);
666+
}
667+
if (c.fillDCAHist) {
668+
for (int iS{0}; iS < nuclei::species; ++iS) {
669+
if (c.flags & BIT(iS)) {
670+
nuclei::hDCAHists[c.pt < 0][iS]->Fill(std::abs(c.pt), c.DCAxy, c.DCAz, c.nSigmaTPC[iS], c.tofMasses[iS], c.ITSnCls, c.TPCnCls);
671+
}
672+
}
673+
}
648674
}
649675
}
650676
PROCESS_SWITCH(nucleiSpectra, processData, "Data analysis", true);
@@ -661,7 +687,16 @@ struct nucleiSpectra {
661687
}
662688
fillDataInfo(collision, tracks);
663689
for (auto& c : nuclei::candidates) {
664-
nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS);
690+
if (c.fillTree) {
691+
nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS);
692+
}
693+
if (c.fillDCAHist) {
694+
for (int iS{0}; iS < nuclei::species; ++iS) {
695+
if (c.flags & BIT(iS)) {
696+
nuclei::hDCAHists[c.pt < 0][iS]->Fill(std::abs(c.pt), c.DCAxy, c.DCAz, c.nSigmaTPC[iS], c.tofMasses[iS], c.ITSnCls, c.TPCnCls);
697+
}
698+
}
699+
}
665700
}
666701
for (auto& c : nuclei::candidates_flow) {
667702
nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.multFT0A, c.psiFT0C, c.multFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.multTPC);
@@ -681,7 +716,16 @@ struct nucleiSpectra {
681716
}
682717
fillDataInfo(collision, tracks);
683718
for (auto& c : nuclei::candidates) {
684-
nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS);
719+
if (c.fillTree) {
720+
nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS);
721+
}
722+
if (c.fillDCAHist) {
723+
for (int iS{0}; iS < nuclei::species; ++iS) {
724+
if (c.flags & BIT(iS)) {
725+
nuclei::hDCAHists[c.pt < 0][iS]->Fill(std::abs(c.pt), c.DCAxy, c.DCAz, c.nSigmaTPC[iS], c.tofMasses[iS], c.ITSnCls, c.TPCnCls);
726+
}
727+
}
728+
}
685729
}
686730
for (auto& c : nuclei::candidates_flow) {
687731
nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.multFT0A, c.psiFT0C, c.multFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.multTPC);
@@ -715,9 +759,13 @@ struct nucleiSpectra {
715759
bool storeIt{false};
716760
for (int iS{0}; iS < nuclei::species; ++iS) {
717761
if (std::abs(particle.pdgCode()) == nuclei::codes[iS]) {
718-
nuclei::hMomRes[iS][particle.pdgCode() < 0]->Fill(1., std::abs(c.pt * nuclei::charges[iS]), 1. - std::abs(c.pt * nuclei::charges[iS]) / particle.pt());
719-
storeIt = cfgTreeConfig->get(iS, 0u) || cfgTreeConfig->get(iS, 1u); /// store only the particles of interest
720-
break;
762+
if (c.fillTree && !storeIt) {
763+
nuclei::hMomRes[iS][particle.pdgCode() < 0]->Fill(1., std::abs(c.pt * nuclei::charges[iS]), 1. - std::abs(c.pt * nuclei::charges[iS]) / particle.pt());
764+
storeIt = cfgTreeConfig->get(iS, 0u) || cfgTreeConfig->get(iS, 1u); /// store only the particles of interest
765+
}
766+
if (c.fillDCAHist && cfgDCAHists->get(iS, c.pt < 0) && particle.isPhysicalPrimary()) {
767+
nuclei::hDCAHists[c.pt < 0][iS]->Fill(std::abs(c.pt), c.DCAxy, c.DCAz, c.nSigmaTPC[iS], c.tofMasses[iS], c.ITSnCls, c.TPCnCls);
768+
}
721769
}
722770
}
723771
if (!storeIt) {

0 commit comments

Comments
 (0)