@@ -88,6 +88,7 @@ struct MeanptFluctuations {
8888 Configurable<bool > cfgEvSelkNoTimeFrameBorder{" cfgEvSelkNoTimeFrameBorder" , true , " TimeFrame border event selection cut" };
8989 Configurable<bool > cfgEvSelUseGoodZvtxFT0vsPV{" cfgEvSelUseGoodZvtxFT0vsPV" , true , " GoodZvertex and FT0 vs PV cut" };
9090 Configurable<int > cfgCentralityEstimator{" cfgCentralityEstimator" , 1 , " Centrlaity estimatore choice: 1-->FT0C, 2-->FT0A; 3-->FT0M, 4-->FV0A" };
91+ Configurable<bool > cfgUseParticlePDGsInProcessMcReco{" cfgUseParticlePDGsInProcessMcReco" , true , " Check partcile PDG codes in reco" };
9192
9293 // pT dep DCAxy and DCAz cuts
9394 Configurable<bool > cfgUsePtDepDCAxy{" cfgUsePtDepDCAxy" , true , " Use pt-dependent DCAxy cut" };
@@ -224,6 +225,7 @@ struct MeanptFluctuations {
224225 histos.add (" AnalysisProfiles/Prof_skew_t1" , " " , {HistType::kTProfile2D , {centAxis, multAxis}});
225226 histos.add (" AnalysisProfiles/Prof_kurt_t1" , " " , {HistType::kTProfile2D , {centAxis, multAxis}});
226227 histos.add (" AnalysisProfiles/Hist2D_Nch_centrality" , " " , {HistType::kTH2D , {centAxis, multAxis}});
228+ histos.add (" AnalysisProfiles/Hist2D_Ngen_centrality" , " " , {HistType::kTH2D , {centAxis, multAxis}});
227229 histos.add (" AnalysisProfiles/Hist2D_meanpt_centrality" , " " , {HistType::kTH2D , {centAxis, meanpTAxis}});
228230
229231 // Analysis Profiles for error (reconstructed data)
@@ -349,7 +351,7 @@ struct MeanptFluctuations {
349351 } // ! end init function
350352
351353 template <typename TCollision>
352- bool eventSelected (TCollision const & collision, const int & multTrk, const float & centrality)
354+ bool eventSelected (TCollision const & collision, const int multTrk, const float centrality)
353355 {
354356 if (collision.alias_bit (kTVXinTRD )) {
355357 // TRD triggered
@@ -658,6 +660,54 @@ struct MeanptFluctuations {
658660 return ; // this generated event was never reconstructed at all
659661 }
660662
663+ histos.fill (HIST (" MCGenerated/hMC" ), 6.5 );
664+
665+ std::vector<int64_t > selectedEvents (collisions.size ());
666+ int nevts = 0 ;
667+
668+ for (const auto & collision : collisions) {
669+ if (!collision.sel8 () || std::abs (collision.mcCollision ().posZ ()) > cfgCutVertex) {
670+ continue ;
671+ }
672+ if (cfgUseGoodITSLayerAllCut && !(collision.selection_bit (o2::aod::evsel::kIsGoodITSLayersAll ))) {
673+ continue ;
674+ }
675+ if (cfgEvSelkNoSameBunchPileup && !(collision.selection_bit (o2::aod::evsel::kNoSameBunchPileup ))) {
676+ continue ;
677+ }
678+ if (cfgEvSelkNoITSROFrameBorder && !(collision.selection_bit (o2::aod::evsel::kNoITSROFrameBorder ))) {
679+ continue ;
680+ }
681+ if (cfgEvSelkNoTimeFrameBorder && !(collision.selection_bit (o2::aod::evsel::kNoTimeFrameBorder ))) {
682+ continue ;
683+ }
684+ if (cfgEvSelUseGoodZvtxFT0vsPV && !(collision.selection_bit (o2::aod::evsel::kIsGoodZvtxFT0vsPV ))) {
685+ continue ;
686+ }
687+
688+ auto rectrackspart = tracks.sliceBy (perCollision, collision.globalIndex ());
689+ auto cent = collision.centFT0C ();
690+
691+ fillMultCorrPlotsBeforeSel (collision, rectrackspart);
692+
693+ if (cfgUseSmallIonAdditionalEventCutInMC && !eventSelectedSmallion (collision, rectrackspart.size (), cent)) {
694+ continue ;
695+ }
696+
697+ if (cfgUseSmallIonAdditionalEventCutInMC) {
698+ fillMultCorrPlotsAfterSel (collision, rectrackspart);
699+ }
700+
701+ selectedEvents[nevts++] = collision.mcCollision_as <aod::McCollisions>().globalIndex ();
702+ }
703+ selectedEvents.resize (nevts);
704+ const auto evtReconstructedAndSelected = std::find (selectedEvents.begin (), selectedEvents.end (), mcCollision.globalIndex ()) != selectedEvents.end ();
705+
706+ if (!evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection
707+ return ;
708+ }
709+ histos.fill (HIST (" MCGenerated/hMC" ), 7.5 );
710+
661711 auto bestColl = collisions.begin ();
662712 bool foundValidColl = false ;
663713 for (auto const & coll : collisions) {
@@ -669,38 +719,12 @@ struct MeanptFluctuations {
669719 if (!foundValidColl) {
670720 return ;
671721 }
722+ histos.fill (HIST (" MCGenerated/hMC" ), 8.5 );
672723
673724 if (!bestColl.has_mcCollision ()) {
674725 return ;
675726 }
676- histos.fill (HIST (" MCGenerated/hMC" ), 6.5 );
677-
678- if (std::abs (bestColl.posZ ()) >= cfgCutVertex) {
679- return ;
680- }
681- if (!eventSelectionDefaultCuts (bestColl)) {
682- return ;
683- }
684- histos.fill (HIST (" MCGenerated/hMC" ), 7.5 );
685-
686- auto tracksThisCollision = tracks.sliceBy (perCollision, bestColl.globalIndex ());
687-
688- fillMultCorrPlotsBeforeSel (bestColl, tracksThisCollision);
689-
690- const auto centralityFT0C = bestColl.centFT0C ();
691- if (cfgUse22sEventCut && !eventSelected (bestColl, tracksThisCollision.size (), centralityFT0C)) {
692- return ;
693- }
694- if (cfgUseSmallIonAdditionalEventCut && !eventSelectedSmallion (bestColl, tracksThisCollision.size (), centralityFT0C)) {
695- return ;
696- }
697-
698- if (cfgUseSmallIonAdditionalEventCut) {
699- fillMultCorrPlotsAfterSel (bestColl, tracksThisCollision);
700- }
701-
702- histos.fill (HIST (" MCGenerated/hMC" ), 8.5 );
703- histos.fill (HIST (" hZvtx_after_sel" ), bestColl.posZ ());
727+ histos.fill (HIST (" MCGenerated/hMC" ), 9.5 );
704728
705729 double cent = 0.0 ;
706730 int centChoiceFT0C = 1 ;
@@ -718,16 +742,15 @@ struct MeanptFluctuations {
718742 }
719743
720744 histos.fill (HIST (" hCentrality" ), cent);
745+ histos.fill (HIST (" hZvtx_after_sel" ), bestColl.posZ ());
721746
747+ auto tracksThisCollision = tracks.sliceBy (perCollision, bestColl.globalIndex ());
722748 histos.fill (HIST (" Hist2D_globalTracks_PVTracks" ), bestColl.multNTracksPV (), tracksThisCollision.size ());
723- histos.fill (HIST (" Hist2D_cent_nch" ), tracksThisCollision.size (), centralityFT0C );
749+ histos.fill (HIST (" Hist2D_cent_nch" ), tracksThisCollision.size (), cent );
724750
725751 // Calculating generated no of particles for the collision event
726752 double noGen = 0.0 ;
727- // Slice particles belonging only to this MC collision
728- auto particlesThisEvent = mcParticles.sliceBy (perMcCollision, mcCollision.globalIndex ());
729-
730- for (const auto & mcParticle : particlesThisEvent) {
753+ for (const auto & mcParticle : mcParticles) {
731754 if (!mcParticle.has_mcCollision ()) {
732755 continue ;
733756 }
@@ -754,7 +777,6 @@ struct MeanptFluctuations {
754777 // variables
755778 double pTsum = 0.0 ;
756779 double nN = 0.0 ;
757-
758780 float q1 = 0.0 ;
759781 float q2 = 0.0 ;
760782 float q3 = 0.0 ;
@@ -775,6 +797,21 @@ struct MeanptFluctuations {
775797 continue ;
776798 }
777799
800+ if (particle.mcCollisionId () != mcCollision.globalIndex ()) { // reject tracks whose true particle belongs to a DIFFERENT generated collision (pileup contamination in bestColl)
801+ continue ;
802+ }
803+
804+ if (cfgUseParticlePDGsInProcessMcReco) {
805+ auto pdgPart = std::abs (particle.pdgCode ());
806+ if (pdgPart != PDG_t::kPiPlus &&
807+ pdgPart != PDG_t::kKPlus &&
808+ pdgPart != PDG_t::kProton &&
809+ pdgPart != PDG_t::kElectron &&
810+ pdgPart != PDG_t::kMuonMinus ) {
811+ continue ; // skip this track
812+ }
813+ }
814+
778815 if (!track.isPVContributor ()) {
779816 continue ;
780817 }
@@ -848,6 +885,7 @@ struct MeanptFluctuations {
848885 histos.get <TProfile2D>(HIST (" AnalysisProfilesV2/Prof_var_t1" ))->Fill (noGen, nCh, varianceTerm1);
849886 histos.get <TProfile2D>(HIST (" AnalysisProfilesV2/Prof_skew_t1" ))->Fill (noGen, nCh, skewnessTerm1);
850887 histos.get <TProfile2D>(HIST (" AnalysisProfilesV2/Prof_kurt_t1" ))->Fill (noGen, nCh, kurtosisTerm1);
888+ histos.fill (HIST (" AnalysisProfiles/Hist2D_Ngen_centrality" ), cent, noGen);
851889
852890 // selecting subsample and filling profiles
853891 float lRandom = fRndm ->Rndm ();
0 commit comments