@@ -61,7 +61,6 @@ static const float cutsTable[nPart][nCuts]{
6161struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended {
6262
6363 Service<o2::framework::O2DatabasePDG> pdg;
64- Service<o2::framework::O2DatabasePDG> pdgMC;
6564
6665 // / Particle selection part
6766
@@ -716,40 +715,41 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended {
716715 void doSameEventMCTruth (PartitionType groupPartsOne, PartitionType groupPartsTwo, int multCol, int ContType, bool fillQA)
717716 {
718717
718+ randgen = new TRandom2 (0 );
719719 // / Histogramming same event
720- if ((ContType == 1 || ContType == 2 ) && fillQA) {
720+ if ((cfgProcessPM || cfgProcessPP ) && fillQA) {
721721 for (const auto & part : groupPartsOne) {
722722 if (part.partType () == uint8_t (aod::femtouniverseparticle::ParticleType::kMCTruthTrack )) {
723723 int pdgCode = static_cast <int >(part.tempFitVar ());
724- const auto & pdgParticle = pdgMC ->GetParticle (pdgCode);
724+ const auto & pdgParticle = pdg ->GetParticle (pdgCode);
725725 if (pdgParticle) {
726726 trackHistoPartOne.fillQA <isMC, false >(part);
727727 }
728728 }
729729 }
730730 }
731731
732- if ((ContType == 1 || ContType == 3 ) && fillQA) {
732+ if ((cfgProcessPM || cfgProcessMM ) && fillQA) {
733733 for (const auto & part : groupPartsTwo) {
734734 if (part.partType () == uint8_t (aod::femtouniverseparticle::ParticleType::kMCTruthTrack )) {
735735 int pdgCode = static_cast <int >(part.tempFitVar ());
736- const auto & pdgParticle = pdgMC ->GetParticle (pdgCode);
736+ const auto & pdgParticle = pdg ->GetParticle (pdgCode);
737737 if (pdgParticle) {
738738 trackHistoPartTwo.fillQA <isMC, false >(part);
739739 }
740740 }
741741 }
742742 }
743743
744- if (ContType == 1 ) {
744+ if (cfgProcessPM ) {
745745
746746 // / Now build the combinations for non-identical particle pairs
747747 for (const auto & [p1, p2] : combinations (CombinationsFullIndexPolicy (groupPartsOne, groupPartsTwo))) {
748748
749749 int pdgCodePartOne = static_cast <int >(p1.tempFitVar ());
750- const auto & pdgParticleOne = pdgMC ->GetParticle (pdgCodePartOne);
750+ const auto & pdgParticleOne = pdg ->GetParticle (pdgCodePartOne);
751751 int pdgCodePartTwo = static_cast <int >(p2.tempFitVar ());
752- const auto & pdgParticleTwo = pdgMC ->GetParticle (pdgCodePartTwo);
752+ const auto & pdgParticleTwo = pdg ->GetParticle (pdgCodePartTwo);
753753 if (pdgParticleOne && pdgParticleTwo && (pdgCodePartOne == trackonefilter.ConfPDGCodePartOne ) && (pdgCodePartTwo == tracktwofilter.ConfPDGCodePartTwo )) {
754754 float kT = FemtoUniverseMath::getkT (p1, mass1, p2, mass2);
755755 sameEventMultCont.fillMultNumDen (p1, p2, femto_universe_sh_container::EventType::same, 2 , multCol, kT , ConfIsIden);
@@ -759,9 +759,9 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended {
759759 for (const auto & [p1, p2] : combinations (CombinationsStrictlyUpperIndexPolicy (groupPartsOne, groupPartsOne))) {
760760
761761 int pdgCodePartOne = static_cast <int >(p1.tempFitVar ());
762- const auto & pdgParticleOne = pdgMC ->GetParticle (pdgCodePartOne);
762+ const auto & pdgParticleOne = pdg ->GetParticle (pdgCodePartOne);
763763 int pdgCodePartTwo = static_cast <int >(p2.tempFitVar ());
764- const auto & pdgParticleTwo = pdgMC ->GetParticle (pdgCodePartTwo);
764+ const auto & pdgParticleTwo = pdg ->GetParticle (pdgCodePartTwo);
765765
766766 float kT = FemtoUniverseMath::getkT (p1, mass1, p2, mass2);
767767 double rand;
@@ -793,6 +793,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended {
793793 }
794794 }
795795 }
796+ delete randgen;
796797 }
797798
798799 // / process function for to call doSameEvent with Monte Carlo
@@ -807,30 +808,37 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended {
807808 auto thegroupPartsOne = partsOneMCTruth->sliceByCached (aod::femtouniverseparticle::fdCollisionId, col.globalIndex (), cache);
808809 auto thegroupPartsTwo = partsTwoMCTruth->sliceByCached (aod::femtouniverseparticle::fdCollisionId, col.globalIndex (), cache);
809810 bool fillQA = true ;
810- randgen = new TRandom2 (0 );
811+
812+ int pairType = 0 ;
813+ if (cfgProcessPM) {
814+ pairType = 1 ;
815+ } else if (cfgProcessPP) {
816+ pairType = 2 ;
817+ } else if (cfgProcessMM) {
818+ pairType = 3 ;
819+ }
811820
812821 if (ConfIsCent) {
813822 if (cfgProcessPM) {
814- doSameEventMCTruth<false >(thegroupPartsOne, thegroupPartsTwo, col.multV0M (), 1 , fillQA);
823+ doSameEventMCTruth<false >(thegroupPartsOne, thegroupPartsTwo, col.multV0M (), pairType , fillQA);
815824 }
816825 if (cfgProcessPP) {
817- doSameEventMCTruth<false >(thegroupPartsOne, thegroupPartsOne, col.multV0M (), 2 , fillQA);
826+ doSameEventMCTruth<false >(thegroupPartsOne, thegroupPartsOne, col.multV0M (), pairType , fillQA);
818827 }
819828 if (cfgProcessMM) {
820- doSameEventMCTruth<false >(thegroupPartsTwo, thegroupPartsTwo, col.multV0M (), 3 , fillQA);
829+ doSameEventMCTruth<false >(thegroupPartsTwo, thegroupPartsTwo, col.multV0M (), pairType , fillQA);
821830 }
822831 } else {
823832 if (cfgProcessPM) {
824- doSameEventMCTruth<false >(thegroupPartsOne, thegroupPartsTwo, col.multNtr (), 1 , fillQA);
833+ doSameEventMCTruth<false >(thegroupPartsOne, thegroupPartsTwo, col.multNtr (), pairType , fillQA);
825834 }
826835 if (cfgProcessPP) {
827- doSameEventMCTruth<false >(thegroupPartsOne, thegroupPartsOne, col.multNtr (), 2 , fillQA);
836+ doSameEventMCTruth<false >(thegroupPartsOne, thegroupPartsOne, col.multNtr (), pairType , fillQA);
828837 }
829838 if (cfgProcessMM) {
830- doSameEventMCTruth<false >(thegroupPartsTwo, thegroupPartsTwo, col.multNtr (), 3 , fillQA);
839+ doSameEventMCTruth<false >(thegroupPartsTwo, thegroupPartsTwo, col.multNtr (), pairType , fillQA);
831840 }
832841 }
833- delete randgen;
834842 }
835843 PROCESS_SWITCH (femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processSameEventMCTruth, " Enable processing same event for MC truth" , false );
836844
@@ -1104,13 +1112,13 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended {
11041112 template <bool isMC, typename PartitionType>
11051113 void doMixedEventMCTruth (PartitionType groupPartsOne, PartitionType groupPartsTwo, int multCol, int ContType)
11061114 {
1107-
1115+ randgen = new TRandom2 ( 0 );
11081116 for (const auto & [p1, p2] : combinations (CombinationsFullIndexPolicy (groupPartsOne, groupPartsTwo))) {
11091117
11101118 int pdgCodePartOne = static_cast <int >(p1.tempFitVar ());
1111- const auto & pdgParticleOne = pdgMC ->GetParticle (pdgCodePartOne);
1119+ const auto & pdgParticleOne = pdg ->GetParticle (pdgCodePartOne);
11121120 int pdgCodePartTwo = static_cast <int >(p2.tempFitVar ());
1113- const auto & pdgParticleTwo = pdgMC ->GetParticle (pdgCodePartTwo);
1121+ const auto & pdgParticleTwo = pdg ->GetParticle (pdgCodePartTwo);
11141122
11151123 float kT = FemtoUniverseMath::getkT (p1, mass1, p2, mass2);
11161124 double rand;
@@ -1149,6 +1157,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended {
11491157 }
11501158 }
11511159 }
1160+ delete randgen;
11521161 }
11531162
11541163 // / process function for to call doMixedEvent with Data
@@ -1157,7 +1166,14 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended {
11571166 void processMixedEventNtrMCTruth (o2::aod::FdCollisions const & cols,
11581167 FemtoTruthParticles const &)
11591168 {
1160- randgen = new TRandom2 (0 );
1169+ int pairType = 0 ;
1170+ if (cfgProcessPM) {
1171+ pairType = 1 ;
1172+ } else if (cfgProcessPP) {
1173+ pairType = 2 ;
1174+ } else if (cfgProcessMM) {
1175+ pairType = 3 ;
1176+ }
11611177
11621178 for (const auto & [collision1, collision2] : soa::selfCombinations (colBinningNtr, ConfNEventsMix, -1 , cols, cols)) {
11631179
@@ -1167,20 +1183,19 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended {
11671183 if (cfgProcessPM) {
11681184 auto groupPartsOne = partsOneMCTruth->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex (), cache);
11691185 auto groupPartsTwo = partsTwoMCTruth->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex (), cache);
1170- doMixedEventMCTruth<false >(groupPartsOne, groupPartsTwo, multiplicityCol, 1 );
1186+ doMixedEventMCTruth<false >(groupPartsOne, groupPartsTwo, multiplicityCol, pairType );
11711187 }
11721188 if (cfgProcessPP) {
11731189 auto groupPartsOne = partsOneMCTruth->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex (), cache);
11741190 auto groupPartsTwo = partsOneMCTruth->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex (), cache);
1175- doMixedEventMCTruth<false >(groupPartsOne, groupPartsTwo, multiplicityCol, 2 );
1191+ doMixedEventMCTruth<false >(groupPartsOne, groupPartsTwo, multiplicityCol, pairType );
11761192 }
11771193 if (cfgProcessMM) {
11781194 auto groupPartsOne = partsTwoMCTruth->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex (), cache);
11791195 auto groupPartsTwo = partsTwoMCTruth->sliceByCached (aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex (), cache);
1180- doMixedEventMCTruth<false >(groupPartsOne, groupPartsTwo, multiplicityCol, 3 );
1196+ doMixedEventMCTruth<false >(groupPartsOne, groupPartsTwo, multiplicityCol, pairType );
11811197 }
11821198 }
1183- delete randgen;
11841199 }
11851200 PROCESS_SWITCH (femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processMixedEventNtrMCTruth, " Enable processing MC Truth mixed events for multiplicity" , false );
11861201};
0 commit comments