@@ -66,10 +66,11 @@ enum PIDCutType {
6666};
6767
6868struct Lambda1520analysisinpp {
69- // Define slice per Resocollision
70- SliceCache cache;
69+ // Define slice per collision
7170 Preslice<Tracks> perCollision = o2::aod::track::collisionId;
71+ SliceCache cache;
7272 Preslice<McParticles> perMcCollision = o2::aod::mcparticle::mcCollisionId;
73+ SliceCache cacheMC;
7374
7475 HistogramRegistry histos{" histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
7576
@@ -391,6 +392,7 @@ struct Lambda1520analysisinpp {
391392
392393 // MC QA
393394 histos.add (" Event/hMCEventIndices" , " hMCEventIndices" , kTH2D , {axisMult, idxMCAxis});
395+
394396 if (doprocessMCGen) {
395397 histos.add (" QA/Gen" , " Gen histogram" , kTH1D , {{10 , 0 , 10 , " index" }});
396398 histos.add (" QA/MC/h2GenEtaPt_beforeanycut" , " #eta-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;" , HistType::kTHnSparseF , {axisEta, axisPtQA});
@@ -1158,6 +1160,9 @@ struct Lambda1520analysisinpp {
11581160 aod::McCollisions const &,
11591161 MCTrackCandidates const & tracks, aod::McParticles const &)
11601162 {
1163+ if (!collision.has_mcCollision ())
1164+ return ;
1165+
11611166 if (!isSelected (collision))
11621167 return ;
11631168
@@ -1174,6 +1179,9 @@ struct Lambda1520analysisinpp {
11741179
11751180 void processMCGen (MCEventCandidates::iterator const & collision, aod::McCollisions const &, aod::McParticles const & mcParticles)
11761181 {
1182+ if (!collision.has_mcCollision ())
1183+ return ;
1184+
11771185 bool isInAfterAllCuts = isSelected (collision, false );
11781186 bool inVtx10 = (std::abs (collision.mcCollision ().posZ ()) > configEvents.cfgEvtZvtx ) ? false : true ;
11791187 bool isTriggerTVX = collision.selection_bit (aod::evsel::kIsTriggerTVX );
@@ -1298,9 +1306,6 @@ struct Lambda1520analysisinpp {
12981306 if (!isInAfterAllCuts)
12991307 return ;
13001308
1301- // if (!collision.has_mcCollision())
1302- // return;
1303-
13041309 for (const auto & part : mcPartsAll) {
13051310
13061311 if (!part.isPhysicalPrimary ())
@@ -1350,14 +1355,15 @@ struct Lambda1520analysisinpp {
13501355 }
13511356 PROCESS_SWITCH (Lambda1520analysisinpp, processMCGen, " Process Event for MC only" , false );
13521357
1353- void processEventFactor (soa::Join<aod::McCollisions, aod::McCentFT0Ms> const & mcCollisions, aod::McParticles const & mcParticles)
1358+ void processEventFactor (MCEventCandidates const & collisions, soa::Join<aod::McCollisions, aod::McCentFT0Ms> const & mcCollisions, aod::McParticles const & mcParticles)
13541359 {
1360+ // Loop on generated collisions to fill the event factor for the INEL>0 correction
13551361 for (const auto & mccolls : mcCollisions) {
13561362 float centrality = mccolls.centFT0M ();
13571363 bool inVtx10 = std::abs (mccolls.posZ ()) <= configEvents.cfgEvtZvtx ;
13581364
1359- auto mcPartsThis = mcParticles.sliceBy (perMcCollision , mccolls.globalIndex ());
1360- bool isTrueINELgt0 = pwglf::isINELgt0mc (mcPartsThis , pdg); // QA for Trigger efficiency
1365+ const auto & particlesInCollision = mcParticles.sliceByCached (aod::mcparticle::mcCollisionId , mccolls.globalIndex (), cacheMC );
1366+ bool isTrueINELgt0 = pwglf::isINELgt0mc (particlesInCollision , pdg); // QA for Trigger efficiency
13611367
13621368 histos.fill (HIST (" Event/hMCEventIndices" ), centrality, Inel);
13631369 if (inVtx10)
@@ -1377,8 +1383,8 @@ struct Lambda1520analysisinpp {
13771383
13781384 bool inVtx10 = std::abs (mccolls.posZ ()) <= configEvents.cfgEvtZvtx ;
13791385
1380- auto mcPartsThis = mcParticles.sliceBy (perMcCollision , mccolls.globalIndex ());
1381- bool isTrueINELgt0 = pwglf::isINELgt0mc (mcPartsThis , pdg);
1386+ const auto & particlesInCollision = mcParticles.sliceByCached (aod::mcparticle::mcCollisionId , mccolls.globalIndex (), cacheMC );
1387+ bool isTrueINELgt0 = pwglf::isINELgt0mc (particlesInCollision , pdg);
13821388
13831389 if (!(inVtx10 && isTrueINELgt0))
13841390 continue ;
@@ -1388,10 +1394,7 @@ struct Lambda1520analysisinpp {
13881394 return (ptL2 > 0 ) ? std::sqrt (ptL2) : -1 .f ;
13891395 };
13901396
1391- for (const auto & part : mcPartsThis) {
1392-
1393- // if (!part.has_mcCollision())
1394- // continue;
1397+ for (const auto & part : particlesInCollision) {
13951398
13961399 if (cUseRapcutMC && std::abs (part.y ()) > configTracks.cfgCutRapidity )
13971400 continue ;
0 commit comments