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;
@@ -187,8 +189,10 @@ struct FemtoUniversePairTaskTrackPhi {
187189
188190 ColumnBinningPolicy<aod::collision::PosZ, aod::femtouniversecollision::MultNtr> colBinning{{ConfBinsVtx, ConfBinsMult}, true };
189191
190- EfficiencyConfigurableGroup effConfGroup;
191- EfficiencyCalculator<TH1> efficiencyCalculator{&effConfGroup};
192+ HistogramRegistry effCorrRegistry{" EfficiencyCorrection" , {}, OutputObjHandlingPolicy::AnalysisObject};
193+
194+ EffCorConfigurableGroup effCorConfGroup;
195+ EfficiencyCorrection effCorrection{&effCorConfGroup};
192196
193197 float weight = 1 ;
194198
@@ -372,6 +376,12 @@ struct FemtoUniversePairTaskTrackPhi {
372376 }
373377 }
374378
379+ // / @returns 1 if positive, -1 if negative, 0 if zero
380+ auto sign (auto number) -> int8_t
381+ {
382+ return (number > 0 ) - (number < 0 );
383+ }
384+
375385 void init (InitContext&)
376386 {
377387 if (ConfIsMC) {
@@ -383,7 +393,14 @@ struct FemtoUniversePairTaskTrackPhi {
383393 registryMCpT.add (" MCReco/C_p_pT" , " ; #it{p_T} (GeV/#it{c}); Counts" , kTH1F , {{100 , 0 , 10 }});
384394 registryMCpT.add (" MCReco/NC_p_pT" , " ; #it{p_T} (GeV/#it{c}); Counts" , kTH1F , {{100 , 0 , 10 }});
385395 }
386- efficiencyCalculator.init ();
396+
397+ effCorrection.init (
398+ &effCorrRegistry,
399+ {
400+ static_cast <framework::AxisSpec>(ConfBinsTempFitVarpT),
401+ {ConfBinsEta, -1 , 1 },
402+ ConfBinsMult,
403+ });
387404
388405 eventHisto.init (&qaRegistry);
389406 qaRegistry.add (" PhiDaugh_pos/nSigmaTPC" , " ; #it{p} (GeV/#it{c}); n#sigma_{TPC}" , kTH2F , {{100 , 0 , 10 }, {200 , -4.975 , 5.025 }});
@@ -467,7 +484,7 @@ struct FemtoUniversePairTaskTrackPhi {
467484 }
468485 }
469486
470- template <typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t >
487+ template <bool isMC, typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t >
471488 void doSameEvent (PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartType parts, float magFieldTesla, int multCol, [[maybe_unused]] MCParticles mcParts = nullptr )
472489 {
473490 for (auto const & phicandidate : groupPartsPhi) {
@@ -493,6 +510,17 @@ struct FemtoUniversePairTaskTrackPhi {
493510 qaRegistry.fill (HIST (" PhiDaugh_neg/hDCAxy" ), negChild.p (), negChild.tempFitVar ());
494511
495512 trackHistoPartPhi.fillQA <false , false >(phicandidate);
513+ if constexpr (isMC) {
514+ // reco
515+ effCorrection.fillRecoHist <ParticleNo::ONE, FilteredFDCollisions>(phicandidate, 333 );
516+ // truth
517+ auto mcPartId1 = phicandidate.fdMCParticleId ();
518+ auto const & mcpart1 = mcParts.iteratorAt (mcPartId1);
519+ if (mcpart1.pdgMCTruth () != 333 ) {
520+ continue ;
521+ }
522+ effCorrection.fillTruthHist <ParticleNo::ONE, FilteredFDCollisions>(phicandidate);
523+ }
496524 }
497525
498526 for (auto const & track : groupPartsTrack) {
@@ -529,6 +557,18 @@ struct FemtoUniversePairTaskTrackPhi {
529557 qaRegistry.fill (HIST (" Hadron_neg/nSigmaTOFPr" ), track.p (), tofNSigmaPr);
530558 }
531559 trackHistoPartTrack.fillQA <false , false >(track);
560+
561+ if constexpr (isMC) {
562+ effCorrection.fillRecoHist <ParticleNo::TWO, FilteredFDCollisions>(track, ConfTrackPDGCode);
563+
564+ // truth
565+ auto mcPartId2 = track.fdMCParticleId ();
566+ auto const & mcpart2 = mcParts.iteratorAt (mcPartId2);
567+ if (mcpart2.pdgMCTruth () != ConfTrackPDGCode) {
568+ continue ;
569+ }
570+ effCorrection.fillTruthHist <ParticleNo::TWO, FilteredFDCollisions>(track);
571+ }
532572 }
533573
534574 // / Now build the combinations
@@ -556,13 +596,8 @@ struct FemtoUniversePairTaskTrackPhi {
556596 if (!pairCleaner.isCleanPair (track, phicandidate, parts)) {
557597 continue ;
558598 }
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);
599+ weight = effCorrection.getWeight <FilteredFDCollisions>(ParticleNo::ONE, phicandidate) * effCorrection.getWeight <FilteredFDCollisions>(ParticleNo::TWO, track);
600+ sameEventCont.setPair <isMC>(track, phicandidate, multCol, ConfUse3D, weight);
566601 }
567602
568603 // // Used for better fitting of invariant mass background.
@@ -592,7 +627,7 @@ struct FemtoUniversePairTaskTrackPhi {
592627 // }
593628 }
594629
595- template <typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t >
630+ template <bool isMC, typename PartitionType, typename PartType, typename MCParticles = std::nullptr_t >
596631 void doMixedEvent (PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartType parts, float magFieldTesla, int multCol, [[maybe_unused]] MCParticles mcParts = nullptr )
597632 {
598633 for (auto const & [track, phicandidate] : combinations (CombinationsFullIndexPolicy (groupPartsTrack, groupPartsPhi))) {
@@ -612,31 +647,23 @@ struct FemtoUniversePairTaskTrackPhi {
612647 continue ;
613648 }
614649 }
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);
650+ weight = effCorrection.getWeight <FilteredFDCollisions>(ParticleNo::ONE, phicandidate) * effCorrection.getWeight <FilteredFDCollisions>(ParticleNo::TWO, track);
651+ mixedEventCont.setPair <isMC>(track, phicandidate, multCol, ConfUse3D, weight);
622652 }
623653 }
624654
625655 void processSameEvent (FilteredFDCollision const & col, FilteredFemtoFullParticles const & parts)
626656 {
627657 auto thegroupPartsTrack = partsTrack->sliceByCached (aod::femtouniverseparticle::fdCollisionId, col.globalIndex (), cache);
628658 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);
631659 eventHisto.fillQA (col);
632- doSameEvent (thegroupPartsTrack, thegroupPartsPhi, parts, col.magField (), col.multNtr ());
660+ doSameEvent< false > (thegroupPartsTrack, thegroupPartsPhi, parts, col.magField (), col.multNtr ());
633661 }
634662 PROCESS_SWITCH (FemtoUniversePairTaskTrackPhi, processSameEvent, " Enable processing same event" , true );
635663
636664 void processMixedEvent (FilteredFDCollisions const & cols, FilteredFemtoFullParticles const & parts)
637665 {
638666 for (auto const & [collision1, collision2] : soa::selfCombinations (colBinning, 5 , -1 , cols, cols)) {
639-
640667 const int multiplicityCol = collision1.multNtr ();
641668 mixQaRegistry.fill (HIST (" MixingQA/hMECollisionBins" ), colBinning.getBin ({collision1.posZ (), multiplicityCol}));
642669
@@ -650,20 +677,19 @@ struct FemtoUniversePairTaskTrackPhi {
650677 continue ;
651678 }
652679
653- doMixedEvent (groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol);
680+ doMixedEvent< false > (groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol);
654681 }
655682 }
656683 PROCESS_SWITCH (FemtoUniversePairTaskTrackPhi, processMixedEvent, " Enable processing mixed events" , true );
657684
658685 // /--------------------------------------------MC-------------------------------------------------///
659686 void processSameEventMCReco (FilteredFDCollision const & col, FemtoRecoParticles const & parts, aod::FdMCParticles const & mcparts)
660687 {
688+ eventHisto.fillQA (col);
689+ // Reco
661690 auto thegroupPartsTrack = partsTrackMCReco->sliceByCached (aod::femtouniverseparticle::fdCollisionId, col.globalIndex (), cache);
662691 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);
692+ doSameEvent<true >(thegroupPartsTrack, thegroupPartsPhi, parts, col.magField (), col.multNtr (), mcparts);
667693 }
668694 PROCESS_SWITCH (FemtoUniversePairTaskTrackPhi, processSameEventMCReco, " Enable processing same event for MC Reco" , true );
669695
@@ -684,7 +710,7 @@ struct FemtoUniversePairTaskTrackPhi {
684710 auto groupPartsTrack = partsTrackMCReco->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex (), cache);
685711 auto groupPartsPhi = partsPhiMCReco->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex (), cache);
686712
687- doMixedEvent (groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol, mcparts);
713+ doMixedEvent< true > (groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol, mcparts);
688714 }
689715 }
690716 PROCESS_SWITCH (FemtoUniversePairTaskTrackPhi, processMixedEventMCReco, " Enable processing mixed events for MC Reco" , false );
@@ -750,12 +776,12 @@ struct FemtoUniversePairTaskTrackPhi {
750776
751777 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))) {
752778 registryMCpT.fill (HIST (" MCReco/NC_p_pT" ), part.pt ());
753- float weightTrack = efficiencyCalculator .getWeight (ParticleNo::TWO, part. pt () );
779+ float weightTrack = effCorrection .getWeight <FilteredFDCollisions> (ParticleNo::TWO, part);
754780 registryMCpT.fill (HIST (" MCReco/C_p_pT" ), part.pt (), weightTrack);
755781 }
756782 if ((mcpart.pdgMCTruth () == 333 ) && (part.partType () == aod::femtouniverseparticle::ParticleType::kPhi ) && (part.pt () > ConfPhiPtLow) && (part.pt () < ConfPhiPtHigh)) {
757783 registryMCpT.fill (HIST (" MCReco/NC_phi_pT" ), part.pt ());
758- float weightPhi = efficiencyCalculator .getWeight (ParticleNo::ONE, part. pt () );
784+ float weightPhi = effCorrection .getWeight <FilteredFDCollisions> (ParticleNo::ONE, part);
759785 registryMCpT.fill (HIST (" MCReco/C_phi_pT" ), part.pt (), weightPhi);
760786 }
761787
@@ -778,7 +804,6 @@ struct FemtoUniversePairTaskTrackPhi {
778804 registryMCreco.fill (HIST (" MCrecoPnegPt" ), mcpart.pt ());
779805 }
780806 }
781-
782807 } // partType kTrack
783808 }
784809 }
0 commit comments