@@ -111,10 +111,13 @@ struct lambdak0sflattenicity {
111111 // Histograms
112112 // Event selection
113113 rEventSelection.add (" hVertexZ" , " hVertexZ" , {HistType::kTH1F , {vertexZAxis}});
114- rEventSelection.add (" hVertexZGen" , " hVertexZGen" , {HistType::kTH1F , {vertexZAxis}});
115114 rEventSelection.add (" hEventsRejected" , " hEventsRejected" , {HistType::kTH1F , {{11 , -0.5 , 10.5 }}});
116115 rEventSelection.add (" hEventsSelected" , " hEventsSelected" , {HistType::kTH1F , {{11 , -0.5 , 10.5 }}});
117116
117+ if (doprocessGenMC) {
118+ rEventSelection.add (" hVertexZGen" , " hVertexZGen" , {HistType::kTH1F , {vertexZAxis}});
119+ rEventSelection.add (" hEventSelectionMCGen" , " hEventSelectionMCGen" , {HistType::kTH1F , {{11 , -0.5 , 10.5 }}});
120+ }
118121 // K0s reconstruction
119122 // Mass
120123 rKzeroShort.add (" hMassK0s" , " hMassK0s" , {HistType::kTH1F , {K0sMassAxis}});
@@ -129,8 +132,11 @@ struct lambdak0sflattenicity {
129132 rKzeroShort.add (" hNSigmaPosPionFromK0s" , " hNSigmaPosPionFromK0s" , {HistType::kTH2F , {{100 , -5 .f , 5 .f }, {ptAxis}}});
130133 rKzeroShort.add (" hNSigmaNegPionFromK0s" , " hNSigmaNegPionFromK0s" , {HistType::kTH2F , {{100 , -5 .f , 5 .f }, {ptAxis}}});
131134 rKzeroShort.add (" hMassK0spT" , " hMassK0spT" , {HistType::kTH2F , {{K0sMassAxis}, {ptAxis}}});
132- rKzeroShort.add (" hPtK0ShortGen" , " hPtK0ShortGen" , {HistType::kTH1F , {ptAxis}});
133135
136+ if (doprocessGenMC) {
137+ rKzeroShort.add (" hPtK0ShortGen" , " hPtK0ShortGen" , {HistType::kTH1F , {ptAxis}});
138+ rKzeroShort.add (" K0sCounterMCGen" , " K0sCounterMCGen" , {HistType::kTH1F , {{10 , 0 , 10 }}});
139+ }
134140 // Lambda reconstruction
135141 // Mass
136142 rLambda.add (" hMassLambda" , " hMassLambda" , {HistType::kTH1F , {LambdaMassAxis}});
@@ -145,8 +151,11 @@ struct lambdak0sflattenicity {
145151 rLambda.add (" hctauLambda" , " hctauLambda" , {HistType::kTH1F , {{40 , 0 .0f , 40 .0f , " c#tau (cm)" }}});
146152 rLambda.add (" h2DdecayRadiusLambda" , " h2DdecayRadiusLambda" , {HistType::kTH1F , {{100 , 0 .0f , 1 .0f , " c#tau (cm)" }}});
147153 rLambda.add (" hMassLambdapT" , " hMassLambdapT" , {HistType::kTH2F , {{LambdaMassAxis}, {ptAxis}}});
148- rLambda.add (" hPtLambdaGen" , " hPtLambdaGen" , {HistType::kTH1F , {ptAxis}});
149154
155+ if (doprocessGenMC) {
156+ rLambda.add (" hPtLambdaGen" , " hPtLambdaGen" , {HistType::kTH1F , {ptAxis}});
157+ rLambda.add (" LambdaCounterMCGen" , " LambdaCounterMCGen" , {HistType::kTH1F , {{10 , 0 , 10 }}});
158+ }
150159 // AntiLambda reconstruction
151160 // Mass
152161 rAntiLambda.add (" hMassAntiLambda" , " hMassAntiLambda" , {HistType::kTH1F , {AntiLambdaMassAxis}});
@@ -161,7 +170,11 @@ struct lambdak0sflattenicity {
161170 rAntiLambda.add (" hctauAntiLambda" , " hctauAntiLambda" , {HistType::kTH1F , {{40 , 0 .0f , 40 .0f , " c#tau (cm)" }}});
162171 rAntiLambda.add (" h2DdecayRadiusAntiLambda" , " h2DdecayRadiusAntiLambda" , {HistType::kTH1F , {{100 , 0 .0f , 1 .0f , " c#tau (cm)" }}});
163172 rAntiLambda.add (" hMassAntiLambdapT" , " hMassAntiLambdapT" , {HistType::kTH2F , {{AntiLambdaMassAxis}, {ptAxis}}});
164- rAntiLambda.add (" hPtAntiLambdaGen" , " hPtAntiLambdaGen" , {HistType::kTH1F , {ptAxis}});
173+
174+ if (doprocessGenMC) {
175+ rAntiLambda.add (" hPtAntiLambdaGen" , " hPtAntiLambdaGen" , {HistType::kTH1F , {ptAxis}});
176+ rAntiLambda.add (" AntiLambdaCounterMCGen" , " AntiLambdaCounterMCGen" , {HistType::kTH1F , {{10 , 0 , 10 }}});
177+ }
165178
166179 rFlattenicity.add (" hEv" , " Ev" , HistType::kTH1F , {{6 , -0.5 , 5.5 , " index activated detector" }});
167180 rFlattenicity.add (" hFV0amplRing1to4" , " FV01to4" , HistType::kTH1F , {{4000 , -0.5 , +49999.5 , " FV0 amplitude" }});
@@ -419,38 +432,38 @@ struct lambdak0sflattenicity {
419432 {
420433 rEventSelection.fill (HIST (" hEventsSelected" ), 0 );
421434
422- if (! collision.selection_bit (o2::aod::evsel:: kNoTimeFrameBorder ) ) {
423- rEventSelection.fill (HIST (" hEventsRejected" ), 0 );
435+ if (collision.isInelGt0 () == false ) {
436+ rEventSelection.fill (HIST (" hEventsRejected" ), 1 );
424437 return false ;
425438 }
426439 rEventSelection.fill (HIST (" hEventsSelected" ), 1 );
427440
428- if (!collision.selection_bit (o2::aod::evsel::kNoITSROFrameBorder )) {
429- rEventSelection.fill (HIST (" hEventsRejected" ), 1 );
441+ if (!collision.selection_bit (o2::aod::evsel::kNoTimeFrameBorder )) {
442+ rEventSelection.fill (HIST (" hEventsRejected" ), 2 );
430443 return false ;
431444 }
432445 rEventSelection.fill (HIST (" hEventsSelected" ), 2 );
433446
434- if (!collision.selection_bit (o2::aod::evsel::kNoSameBunchPileup )) {
435- rEventSelection.fill (HIST (" hEventsRejected" ), 2 );
447+ if (!collision.selection_bit (o2::aod::evsel::kNoITSROFrameBorder )) {
448+ rEventSelection.fill (HIST (" hEventsRejected" ), 3 );
436449 return false ;
437450 }
438451 rEventSelection.fill (HIST (" hEventsSelected" ), 3 );
439452
440- if (!collision.selection_bit (o2::aod::evsel::kIsGoodZvtxFT0vsPV )) {
441- rEventSelection.fill (HIST (" hEventsRejected" ), 3 );
453+ if (!collision.selection_bit (o2::aod::evsel::kIsVertexITSTPC )) {
454+ rEventSelection.fill (HIST (" hEventsRejected" ), 4 );
442455 return false ;
443456 }
444457 rEventSelection.fill (HIST (" hEventsSelected" ), 4 );
445458
446- if (!collision.selection_bit (o2::aod::evsel::kIsVertexITSTPC )) {
447- rEventSelection.fill (HIST (" hEventsRejected" ), 4 );
459+ if (!collision.selection_bit (o2::aod::evsel::kNoSameBunchPileup )) {
460+ rEventSelection.fill (HIST (" hEventsRejected" ), 5 );
448461 return false ;
449462 }
450463 rEventSelection.fill (HIST (" hEventsSelected" ), 5 );
451464
452- if (collision.isInelGt0 () == false ) {
453- rEventSelection.fill (HIST (" hEventsRejected" ), 5 );
465+ if (! collision.selection_bit (o2::aod::evsel:: kIsGoodZvtxFT0vsPV ) ) {
466+ rEventSelection.fill (HIST (" hEventsRejected" ), 6 );
454467 return false ;
455468 }
456469 rEventSelection.fill (HIST (" hEventsSelected" ), 6 );
@@ -944,32 +957,83 @@ struct lambdak0sflattenicity {
944957 }
945958 }
946959
947- Filter posZFilterMC = (nabs(o2::aod::mccollision::posZ) < cutzvertex);
948- void processGenMC (soa::Filtered< aod::McCollisions>::iterator const & mcCollision,
960+ // Filter posZFilterMC = (nabs(o2::aod::mccollision::posZ) < cutzvertex);
961+ void processGenMC (o2:: aod::McCollision const & mcCollision,
949962 const soa::SmallGroups<soa::Join<o2::aod::Collisions, o2::aod::McCollisionLabels, o2::aod::EvSels>>& collisions,
950- aod::McParticles const & mcParticles)
963+ o2:: aod::McParticles const & mcParticles)
951964 {
952- if (collisions.size () < 1 ) // to process generated collisions that've been reconstructed at least once
953- {
965+ // if (collisions.size() < 1) // to process generated collisions that've been reconstructed at least once
966+ // {
967+ // return;
968+ // }
969+
970+ std::vector<int64_t > SelectedEvents (collisions.size ());
971+ int nevts = 0 ;
972+ for (const auto & collision : collisions) {
973+ if (!collision.sel8 ()) {
974+ continue ;
975+ }
976+ SelectedEvents[nevts++] = collision.mcCollision_as <aod::McCollisions>().globalIndex ();
977+ }
978+ SelectedEvents.resize (nevts);
979+
980+ const auto evtReconstructedAndSelected = std::find (SelectedEvents.begin (), SelectedEvents.end (), mcCollision.globalIndex ()) != SelectedEvents.end ();
981+
982+ rEventSelection.fill (HIST (" hEventSelectionMCGen" ), 0 );
983+
984+ if (!evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection
985+ return ;
986+ }
987+ rEventSelection.fill (HIST (" hEventSelectionMCGen" ), 1 ); // hSelAndRecoMcCollCounter
988+
989+ if (abs (mcCollision.posZ ()) > cutzvertex) { // 10cm
954990 return ;
955991 }
992+ rEventSelection.fill (HIST (" hEventSelectionMCGen" ), 2 );
956993
957994 rEventSelection.fill (HIST (" hVertexZGen" ), mcCollision.posZ ());
958995
959996 for (const auto & mcParticle : mcParticles) {
960997
961998 if (mcParticle.isPhysicalPrimary () && mcParticle.y () < 0.5 ) {
999+ if (!mcParticle.has_daughters ()) {
1000+ continue ;
1001+ }
9621002
9631003 if (mcParticle.pdgCode () == 310 ) {
1004+ rKzeroShort.fill (HIST (" K0sCounterMCGen" ), 0 );
9641005 rKzeroShort.fill (HIST (" hPtK0ShortGen" ), mcParticle.pt ());
1006+ for (auto & mcparticleDaughter0 : mcParticle.daughters_as <aod::McParticles>()) {
1007+ for (auto & mcparticleDaughter1 : mcParticle.daughters_as <aod::McParticles>()) {
1008+ if (mcparticleDaughter0.pdgCode () == 211 && mcparticleDaughter1.pdgCode () == -211 ) {
1009+ rKzeroShort.fill (HIST (" K0sCounterMCGen" ), 1 );
1010+ }
1011+ }
1012+ }
9651013 }
9661014
9671015 if (mcParticle.pdgCode () == 3122 ) {
1016+ rLambda.fill (HIST (" LambdaCounterMCGen" ), 0 );
9681017 rLambda.fill (HIST (" hPtLambdaGen" ), mcParticle.pt ());
1018+ for (auto & mcparticleDaughter0 : mcParticle.daughters_as <aod::McParticles>()) {
1019+ for (auto & mcparticleDaughter1 : mcParticle.daughters_as <aod::McParticles>()) {
1020+ if (mcparticleDaughter0.pdgCode () == -211 && mcparticleDaughter1.pdgCode () == 2212 ) {
1021+ rLambda.fill (HIST (" LambdaCounterMCGen" ), 1 );
1022+ }
1023+ }
1024+ }
9691025 }
9701026
9711027 if (mcParticle.pdgCode () == -3122 ) {
1028+ rAntiLambda.fill (HIST (" AntiLambdaCounterMCGen" ), 0.5 );
9721029 rAntiLambda.fill (HIST (" hPtAntiLambdaGen" ), mcParticle.pt ());
1030+ for (auto & mcparticleDaughter0 : mcParticle.daughters_as <aod::McParticles>()) {
1031+ for (auto & mcparticleDaughter1 : mcParticle.daughters_as <aod::McParticles>()) {
1032+ if (mcparticleDaughter0.pdgCode () == 211 && mcparticleDaughter1.pdgCode () == -2212 ) {
1033+ rAntiLambda.fill (HIST (" AntiLambdaCounterMCGen" ), 1 );
1034+ }
1035+ }
1036+ }
9731037 }
9741038 }
9751039 }
0 commit comments