2727#include < TLorentzVector.h>
2828#include < TPDGCode.h>
2929#include < TDatabasePDG.h>
30-
30+ # include < Math/Vector4D.h >
3131#include < cmath>
3232#include < array>
3333#include < cstdlib>
@@ -98,8 +98,9 @@ struct phianalysisrun3 {
9898 histos.add (" h3PhiInvMassMixedCside" , " Invariant mass of Phi meson Mixed C side" , kTH3F , {{201 , -0.5 , 200.5 }, {100 , 0 .0f , 10 .0f }, {200 , 0.9 , 1.1 }});
9999 }
100100 } else if (isMC) {
101- histos.add (" hMC" , " MC Event statistics" , kTH1F , {{2 , 0 .0f , 2 .0f }});
101+ histos.add (" hMC" , " MC Event statistics" , kTH1F , {{5 , 0 .0f , 4 .0f }});
102102 histos.add (" h1PhiGen" , " Phi meson Gen" , kTH1F , {{100 , 0 .0f , 10 .0f }});
103+ histos.add (" h1PhiGensamecoll" , " Phi meson Gen same coll" , kTH1F , {{100 , 0 .0f , 10 .0f }});
103104 histos.add (" h2PhiRec" , " Phi meson Rec" , kTH2F , {{100 , 0 .0f , 10 .0f }, {200 , -0.1 , 0.1 }});
104105 }
105106 }
@@ -311,38 +312,64 @@ struct phianalysisrun3 {
311312 }
312313
313314 PROCESS_SWITCH (phianalysisrun3, processMixedEvent, " Process Mixed event" , false );
314- void processGen (aod::McCollision const & mcCollision, aod::McParticles& mcParticles)
315+ void processGen (aod::McCollision const & mcCollision, aod::McParticles& mcParticles, const soa::SmallGroups<EventCandidatesMC>& collisions )
315316 {
317+ histos.fill (HIST (" hMC" ), 0.5 );
316318 if (std::abs (mcCollision.posZ ()) < cfgCutVertex) {
317- histos.fill (HIST (" hMC" ), 0 .5 );
318- for ( auto & mcParticle : mcParticles) {
319-
320- if ( std::abs (mcParticle. y ()) > 0.5 ) {
321- continue ;
322- }
323- if (mcParticle.pdgCode () != 333 ) {
324- continue ;
319+ histos.fill (HIST (" hMC" ), 1 .5 );
320+ }
321+ int Nchinel = 0 ;
322+ for ( auto & mcParticle : mcParticles ) {
323+ auto pdgcode = std::abs (mcParticle. pdgCode ()) ;
324+ if (mcParticle. isPhysicalPrimary () && (pdgcode == 211 || pdgcode == 321 || pdgcode == 2212 || pdgcode == 11 || pdgcode == 13 )) {
325+ if (std::abs ( mcParticle.eta ()) < 1.0 ) {
326+ Nchinel = Nchinel + 1 ;
325327 }
326- auto kDaughters = mcParticle.daughters_as <aod::McParticles>();
327- if (kDaughters .size () != 2 ) {
328+ }
329+ }
330+ if (Nchinel > 0 && std::abs (mcCollision.posZ ()) < cfgCutVertex)
331+ histos.fill (HIST (" hMC" ), 2.5 );
332+ std::vector<int64_t > SelectedEvents (collisions.size ());
333+ int nevts = 0 ;
334+ for (const auto & collision : collisions) {
335+ if (!collision.sel8 () || std::abs (collision.mcCollision ().posZ ()) > cfgCutVertex) {
336+ continue ;
337+ }
338+ SelectedEvents[nevts++] = collision.mcCollision_as <aod::McCollisions>().globalIndex ();
339+ }
340+ SelectedEvents.resize (nevts);
341+ const auto evtReconstructedAndSelected = std::find (SelectedEvents.begin (), SelectedEvents.end (), mcCollision.globalIndex ()) != SelectedEvents.end ();
342+
343+ if (!evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection
344+ return ;
345+ }
346+ histos.fill (HIST (" hMC" ), 3.5 );
347+ for (auto & mcParticle : mcParticles) {
348+ if (std::abs (mcParticle.y ()) > 0.5 ) {
349+ continue ;
350+ }
351+ if (mcParticle.pdgCode () != 333 ) {
352+ continue ;
353+ }
354+ auto kDaughters = mcParticle.daughters_as <aod::McParticles>();
355+ if (kDaughters .size () != 2 ) {
356+ continue ;
357+ }
358+ auto daughtp = false ;
359+ auto daughtm = false ;
360+ for (auto kCurrentDaughter : kDaughters ) {
361+ if (!kCurrentDaughter .isPhysicalPrimary ()) {
328362 continue ;
329363 }
330- auto daughtp = false ;
331- auto daughtm = false ;
332- for (auto kCurrentDaughter : kDaughters ) {
333- if (!kCurrentDaughter .isPhysicalPrimary ()) {
334- continue ;
335- }
336- if (kCurrentDaughter .pdgCode () == +321 ) {
337- daughtp = true ;
338- } else if (kCurrentDaughter .pdgCode () == -321 ) {
339- daughtm = true ;
340- }
341- }
342- if (daughtp && daughtm) {
343- histos.fill (HIST (" h1PhiGen" ), mcParticle.pt ());
364+ if (kCurrentDaughter .pdgCode () == +321 ) {
365+ daughtp = true ;
366+ } else if (kCurrentDaughter .pdgCode () == -321 ) {
367+ daughtm = true ;
344368 }
345369 }
370+ if (daughtp && daughtm) {
371+ histos.fill (HIST (" h1PhiGen" ), mcParticle.pt ());
372+ }
346373 }
347374 }
348375
@@ -355,7 +382,7 @@ struct phianalysisrun3 {
355382 if (std::abs (collision.mcCollision ().posZ ()) > cfgCutVertex || !collision.sel8 ()) {
356383 return ;
357384 }
358- histos.fill (HIST (" hMC" ), 1 .5 );
385+ histos.fill (HIST (" hMC" ), 4 .5 );
359386 for (auto track1 : tracks) {
360387 if (!selectionTrack (track1)) {
361388 continue ;
0 commit comments