1616// / \author Anton Riedel, TU München, anton.riedel@tum.de
1717// / \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch
1818
19- #include < vector>
20- #include < string>
19+ #include " PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h"
20+ #include " PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h"
21+ #include " PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCorrection.h"
22+ #include " PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h"
23+ #include " PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h"
24+ #include " PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h"
25+ #include " PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h"
26+ #include " PWGCF/FemtoUniverse/DataModel/FemtoDerived.h"
27+
28+ #include " Framework/ASoAHelpers.h"
2129#include " Framework/AnalysisTask.h"
22- #include " Framework/runDataProcessing.h"
2330#include " Framework/HistogramRegistry.h"
24- #include " Framework/ASoAHelpers.h"
2531#include " Framework/O2DatabasePDGPlugin.h"
32+ #include " Framework/runDataProcessing.h"
2633#include " ReconstructionDataFormats/PID.h"
2734
28- #include " PWGCF/FemtoUniverse/DataModel/FemtoDerived.h"
29- #include " PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h"
30- #include " PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h"
31- #include " PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h"
32- #include " PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h"
33- #include " PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h"
34- #include " PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h"
35- #include " PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCalculator.h"
3635#include < TFile.h>
3736#include < TH1.h>
3837
38+ #include < string>
39+ #include < vector>
40+
3941using namespace o2 ;
4042using namespace o2 ::analysis::femto_universe;
41- using namespace o2 ::analysis::femto_universe::efficiency ;
43+ using namespace o2 ::analysis::femto_universe::efficiency_correction ;
4244using namespace o2 ::framework;
4345using namespace o2 ::framework::expressions;
4446using namespace o2 ::soa;
@@ -115,6 +117,11 @@ struct FemtoUniversePairTaskTrackPhi {
115117 (aod::femtouniverseparticle::pt > ConfTrackPtLow) &&
116118 (aod::femtouniverseparticle::pt < ConfTrackPtHigh);
117119
120+ // Partition<soa::Join<FilteredFemtoFullParticles, aod::FDMCLabels>> partsTrackMCTruth =
121+ // aod::femtouniverseparticle::partType == static_cast<uint8_t>(aod::femtouniverseparticle::ParticleType::kMCTruthTrack) &&
122+ // aod::femtouniverseparticle::pt < ConfTrackPtHigh &&
123+ // aod::femtouniverseparticle::pt > ConfTrackPtLow;
124+
118125 // / Particle 2 --- PHI MESON
119126 Configurable<float > ConfPhiPtLow{" ConfPhiPtLow" , 0.8 , " Lower limit of the Phi pT." };
120127 Configurable<float > ConfPhiPtHigh{" ConfPhiPtHigh" , 4.0 , " Higher limit of the Phi pT." };
@@ -134,6 +141,11 @@ struct FemtoUniversePairTaskTrackPhi {
134141 (aod::femtouniverseparticle::tempFitVar > confInvMassLowLimitPhi) &&
135142 (aod::femtouniverseparticle::tempFitVar < confInvMassUpLimitPhi);
136143
144+ // Partition<soa::Join<FilteredFemtoFullParticles, aod::FDMCLabels>> partsPhiMCTruth =
145+ // aod::femtouniverseparticle::partType == static_cast<uint8_t>(aod::femtouniverseparticle::ParticleType::kMCTruthTrack) &&
146+ // aod::femtouniverseparticle::pt < ConfPhiPtHigh &&
147+ // aod::femtouniverseparticle::pt > ConfPhiPtLow;
148+
137149 // / Partitions for Phi daughters kPhiChild
138150 Partition<FilteredFemtoFullParticles> partsPhiDaugh = (aod::femtouniverseparticle::partType == uint8_t (aod::femtouniverseparticle::ParticleType::kPhiChild ));
139151 Partition<soa::Join<FilteredFemtoFullParticles, aod::FDMCLabels>> partsPhiDaughMC = (aod::femtouniverseparticle::partType == uint8_t (aod::femtouniverseparticle::ParticleType::kPhiChild ));
@@ -187,8 +199,10 @@ struct FemtoUniversePairTaskTrackPhi {
187199
188200 ColumnBinningPolicy<aod::collision::PosZ, aod::femtouniversecollision::MultNtr> colBinning{{ConfBinsVtx, ConfBinsMult}, true };
189201
190- EfficiencyConfigurableGroup effConfGroup;
191- EfficiencyCalculator<TH1> efficiencyCalculator{&effConfGroup};
202+ HistogramRegistry effCorrRegistry{" EfficiencyCorrection" , {}, OutputObjHandlingPolicy::AnalysisObject};
203+
204+ EffCorConfigurableGroup effCorConfGroup;
205+ EfficiencyCorrection effCorrection{&effCorConfGroup};
192206
193207 float weight = 1 ;
194208
@@ -372,6 +386,12 @@ struct FemtoUniversePairTaskTrackPhi {
372386 }
373387 }
374388
389+ // / @returns 1 if positive, -1 if negative, 0 if zero
390+ auto sign (auto number) -> int8_t
391+ {
392+ return (number > 0 ) - (number < 0 );
393+ }
394+
375395 void init (InitContext&)
376396 {
377397 if (ConfIsMC) {
@@ -383,7 +403,14 @@ struct FemtoUniversePairTaskTrackPhi {
383403 registryMCpT.add (" MCReco/C_p_pT" , " ; #it{p_T} (GeV/#it{c}); Counts" , kTH1F , {{100 , 0 , 10 }});
384404 registryMCpT.add (" MCReco/NC_p_pT" , " ; #it{p_T} (GeV/#it{c}); Counts" , kTH1F , {{100 , 0 , 10 }});
385405 }
386- efficiencyCalculator.init ();
406+
407+ effCorrection.init (
408+ &effCorrRegistry,
409+ {
410+ static_cast <framework::AxisSpec>(ConfBinsTempFitVarpT),
411+ {ConfBinsEta, -1 , 1 },
412+ ConfBinsMult,
413+ });
387414
388415 eventHisto.init (&qaRegistry);
389416 qaRegistry.add (" PhiDaugh_pos/nSigmaTPC" , " ; #it{p} (GeV/#it{c}); n#sigma_{TPC}" , kTH2F , {{100 , 0 , 10 }, {200 , -4.975 , 5.025 }});
@@ -467,7 +494,7 @@ struct FemtoUniversePairTaskTrackPhi {
467494 }
468495 }
469496
470- template <typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t >
497+ template <bool isMC, typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t >
471498 void doSameEvent (PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartType parts, float magFieldTesla, int multCol, [[maybe_unused]] MCParticles mcParts = nullptr )
472499 {
473500 for (auto const & phicandidate : groupPartsPhi) {
@@ -493,6 +520,17 @@ struct FemtoUniversePairTaskTrackPhi {
493520 qaRegistry.fill (HIST (" PhiDaugh_neg/hDCAxy" ), negChild.p (), negChild.tempFitVar ());
494521
495522 trackHistoPartPhi.fillQA <false , false >(phicandidate);
523+ if constexpr (isMC) {
524+ // reco
525+ effCorrection.fillRecoHist <ParticleNo::ONE, FilteredFDCollisions>(phicandidate, 333 );
526+ // truth
527+ auto mcPartId1 = phicandidate.fdMCParticleId ();
528+ auto const & mcpart1 = mcParts.iteratorAt (mcPartId1);
529+ if (mcpart1.pdgMCTruth () != 333 ) {
530+ continue ;
531+ }
532+ effCorrection.fillTruthHist <ParticleNo::ONE, FilteredFDCollisions>(phicandidate);
533+ }
496534 }
497535
498536 for (auto const & track : groupPartsTrack) {
@@ -529,6 +567,18 @@ struct FemtoUniversePairTaskTrackPhi {
529567 qaRegistry.fill (HIST (" Hadron_neg/nSigmaTOFPr" ), track.p (), tofNSigmaPr);
530568 }
531569 trackHistoPartTrack.fillQA <false , false >(track);
570+
571+ if constexpr (isMC) {
572+ effCorrection.fillRecoHist <ParticleNo::TWO, FilteredFDCollisions>(track, ConfTrackPDGCode);
573+
574+ // truth
575+ auto mcPartId2 = track.fdMCParticleId ();
576+ auto const & mcpart2 = mcParts.iteratorAt (mcPartId2);
577+ if (mcpart2.pdgMCTruth () != ConfTrackPDGCode) {
578+ continue ;
579+ }
580+ effCorrection.fillTruthHist <ParticleNo::TWO, FilteredFDCollisions>(track);
581+ }
532582 }
533583
534584 // / Now build the combinations
@@ -556,13 +606,8 @@ struct FemtoUniversePairTaskTrackPhi {
556606 if (!pairCleaner.isCleanPair (track, phicandidate, parts)) {
557607 continue ;
558608 }
559-
560- weight = efficiencyCalculator.getWeight (ParticleNo::ONE, phicandidate.pt ()) * efficiencyCalculator.getWeight (ParticleNo::TWO, track.pt ());
561-
562- if constexpr (std::is_same<PartType, FemtoRecoParticles>::value)
563- sameEventCont.setPair <true >(track, phicandidate, multCol, ConfUse3D, weight);
564- else
565- sameEventCont.setPair <false >(track, phicandidate, multCol, ConfUse3D, weight);
609+ weight = effCorrection.getWeight <FilteredFDCollisions>(ParticleNo::ONE, phicandidate) * effCorrection.getWeight <FilteredFDCollisions>(ParticleNo::TWO, track);
610+ sameEventCont.setPair <isMC>(track, phicandidate, multCol, ConfUse3D, weight);
566611 }
567612
568613 // // Used for better fitting of invariant mass background.
@@ -592,7 +637,7 @@ struct FemtoUniversePairTaskTrackPhi {
592637 // }
593638 }
594639
595- template <typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t >
640+ template <bool isMC, typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t >
596641 void doMixedEvent (PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartType parts, float magFieldTesla, int multCol, [[maybe_unused]] MCParticles mcParts = nullptr )
597642 {
598643 for (auto const & [track, phicandidate] : combinations (CombinationsFullIndexPolicy (groupPartsTrack, groupPartsPhi))) {
@@ -612,31 +657,23 @@ struct FemtoUniversePairTaskTrackPhi {
612657 continue ;
613658 }
614659 }
615-
616- weight = efficiencyCalculator.getWeight (ParticleNo::ONE, phicandidate.pt ()) * efficiencyCalculator.getWeight (ParticleNo::TWO, track.pt ());
617-
618- if constexpr (std::is_same<PartType, FemtoRecoParticles>::value)
619- mixedEventCont.setPair <true >(track, phicandidate, multCol, ConfUse3D, weight);
620- else
621- mixedEventCont.setPair <false >(track, phicandidate, multCol, ConfUse3D, weight);
660+ weight = effCorrection.getWeight <FilteredFDCollisions>(ParticleNo::ONE, phicandidate) * effCorrection.getWeight <FilteredFDCollisions>(ParticleNo::TWO, track);
661+ mixedEventCont.setPair <isMC>(track, phicandidate, multCol, ConfUse3D, weight);
622662 }
623663 }
624664
625665 void processSameEvent (FilteredFDCollision const & col, FilteredFemtoFullParticles const & parts)
626666 {
627667 auto thegroupPartsTrack = partsTrack->sliceByCached (aod::femtouniverseparticle::fdCollisionId, col.globalIndex (), cache);
628668 auto thegroupPartsPhi = partsPhi->sliceByCached (aod::femtouniverseparticle::fdCollisionId, col.globalIndex (), cache);
629- // auto thegroupPartsPhiDaugh = partsPhiDaugh->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
630- // auto thegroupPartsKaons = partsKaons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
631669 eventHisto.fillQA (col);
632- doSameEvent (thegroupPartsTrack, thegroupPartsPhi, parts, col.magField (), col.multNtr ());
670+ doSameEvent< false > (thegroupPartsTrack, thegroupPartsPhi, parts, col.magField (), col.multNtr ());
633671 }
634672 PROCESS_SWITCH (FemtoUniversePairTaskTrackPhi, processSameEvent, " Enable processing same event" , true );
635673
636674 void processMixedEvent (FilteredFDCollisions const & cols, FilteredFemtoFullParticles const & parts)
637675 {
638676 for (auto const & [collision1, collision2] : soa::selfCombinations (colBinning, 5 , -1 , cols, cols)) {
639-
640677 const int multiplicityCol = collision1.multNtr ();
641678 mixQaRegistry.fill (HIST (" MixingQA/hMECollisionBins" ), colBinning.getBin ({collision1.posZ (), multiplicityCol}));
642679
@@ -650,20 +687,19 @@ struct FemtoUniversePairTaskTrackPhi {
650687 continue ;
651688 }
652689
653- doMixedEvent (groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol);
690+ doMixedEvent< false > (groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol);
654691 }
655692 }
656693 PROCESS_SWITCH (FemtoUniversePairTaskTrackPhi, processMixedEvent, " Enable processing mixed events" , true );
657694
658695 // /--------------------------------------------MC-------------------------------------------------///
659696 void processSameEventMCReco (FilteredFDCollision const & col, FemtoRecoParticles const & parts, aod::FdMCParticles const & mcparts)
660697 {
698+ eventHisto.fillQA (col);
699+ // Reco
661700 auto thegroupPartsTrack = partsTrackMCReco->sliceByCached (aod::femtouniverseparticle::fdCollisionId, col.globalIndex (), cache);
662701 auto thegroupPartsPhi = partsPhiMCReco->sliceByCached (aod::femtouniverseparticle::fdCollisionId, col.globalIndex (), cache);
663- // auto thegroupPartsPhiDaugh = partsPhiDaugh->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
664- // auto thegroupPartsKaons = partsKaons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
665- eventHisto.fillQA (col);
666- doSameEvent (thegroupPartsTrack, thegroupPartsPhi, parts, col.magField (), col.multNtr (), mcparts);
702+ doSameEvent<true >(thegroupPartsTrack, thegroupPartsPhi, parts, col.magField (), col.multNtr (), mcparts);
667703 }
668704 PROCESS_SWITCH (FemtoUniversePairTaskTrackPhi, processSameEventMCReco, " Enable processing same event for MC Reco" , true );
669705
@@ -684,7 +720,7 @@ struct FemtoUniversePairTaskTrackPhi {
684720 auto groupPartsTrack = partsTrackMCReco->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex (), cache);
685721 auto groupPartsPhi = partsPhiMCReco->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex (), cache);
686722
687- doMixedEvent (groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol, mcparts);
723+ doMixedEvent< true > (groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol, mcparts);
688724 }
689725 }
690726 PROCESS_SWITCH (FemtoUniversePairTaskTrackPhi, processMixedEventMCReco, " Enable processing mixed events for MC Reco" , false );
@@ -750,12 +786,12 @@ struct FemtoUniversePairTaskTrackPhi {
750786
751787 if (mcpart.pdgMCTruth () == ConfTrackPDGCode && (part.pt () > ConfTrackPtLow) && (part.pt () < ConfTrackPtHigh) && isParticleNSigmaAccepted (part.p (), trackCuts.getNsigmaTPC (part, o2::track::PID::Proton), trackCuts.getNsigmaTOF (part, o2::track::PID::Proton), trackCuts.getNsigmaTPC (part, o2::track::PID::Pion), trackCuts.getNsigmaTOF (part, o2::track::PID::Pion), trackCuts.getNsigmaTPC (part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF (part, o2::track::PID::Kaon))) {
752788 registryMCpT.fill (HIST (" MCReco/NC_p_pT" ), part.pt ());
753- float weightTrack = efficiencyCalculator .getWeight (ParticleNo::TWO, part. pt () );
789+ float weightTrack = effCorrection .getWeight <FilteredFDCollisions> (ParticleNo::TWO, part);
754790 registryMCpT.fill (HIST (" MCReco/C_p_pT" ), part.pt (), weightTrack);
755791 }
756792 if ((mcpart.pdgMCTruth () == 333 ) && (part.partType () == aod::femtouniverseparticle::ParticleType::kPhi ) && (part.pt () > ConfPhiPtLow) && (part.pt () < ConfPhiPtHigh)) {
757793 registryMCpT.fill (HIST (" MCReco/NC_phi_pT" ), part.pt ());
758- float weightPhi = efficiencyCalculator .getWeight (ParticleNo::ONE, part. pt () );
794+ float weightPhi = effCorrection .getWeight <FilteredFDCollisions> (ParticleNo::ONE, part);
759795 registryMCpT.fill (HIST (" MCReco/C_phi_pT" ), part.pt (), weightPhi);
760796 }
761797
@@ -778,7 +814,6 @@ struct FemtoUniversePairTaskTrackPhi {
778814 registryMCreco.fill (HIST (" MCrecoPnegPt" ), mcpart.pt ());
779815 }
780816 }
781-
782817 } // partType kTrack
783818 }
784819 }
0 commit comments