1919#include " PWGLF/DataModel/LFStrangenessTables.h"
2020#include " PWGLF/DataModel/mcCentrality.h"
2121#include " PWGLF/Utils/collisionCuts.h"
22+ #include " PWGLF/Utils/inelGt.h"
2223
2324#include " Common/CCDB/RCTSelectionFlags.h"
2425#include " Common/Core/RecoDecay.h"
@@ -79,8 +80,19 @@ struct Chargedkstaranalysis {
7980 FT0C = 1 ,
8081 FT0M = 2
8182 };
83+ enum EvtStep {
84+ kAll = 0 ,
85+ kZvtx ,
86+ kINELgt0 ,
87+ kAssocReco ,
88+ kNSteps
89+ };
90+
91+ const int nSteps = static_cast <int >(EvtStep::kNSteps );
92+
8293 SliceCache cache;
8394 Preslice<aod::Tracks> perCollision = aod::track::collisionId;
95+ Preslice<aod::McParticles> perMCCollision = o2::aod::mcparticle::mcCollisionId;
8496 bool currentIsGen = false ;
8597 struct : ConfigurableGroup {
8698 ConfigurableAxis cfgvtxbins{" cfgvtxbins" , {VARIABLE_WIDTH, -10 .0f , -8 .f , -6 .f , -4 .f , -2 .f , 0 .f , 2 .f , 4 .f , 6 .f , 8 .f , 10 .f }, " Mixing bins - z-vertex" };
@@ -116,6 +128,9 @@ struct Chargedkstaranalysis {
116128 int noOfDaughters = 2 ;
117129 } helicityCfgs;
118130
131+ Configurable<bool > cfgTruthUseInelGt0{" cfgTruthUseInelGt0" , true , " Truth denominator: require INEL>0" };
132+ Configurable<bool > cfgTruthIncludeZvtx{" cfgTruthIncludeZvtx" , true , " Truth denominator: also require |vtxz|<cfgEvtZvtx" };
133+
119134 using EventCandidates = soa::Join<aod::Collisions, aod::EvSels, aod::FT0Mults, aod::FV0Mults, aod::TPCMults, aod::CentFV0As, aod::CentFT0Ms, aod::CentFT0Cs, aod::CentFT0As, aod::Mults>;
120135 // using EventCandidates = soa::Join<aod::Collisions, aod::EvSels, aod::FT0Mults, aod::FV0Mults, aod::TPCMults, aod::Mults>;
121136 // using TrackCandidates = soa::Join<aod::FullTracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection, aod::TrackSelectionExtension, aod::pidTPCPi, aod::pidTP CKa, aod::pidTPCPr, aod::pidTOFPi, aod::pidTOFKa, aod::pidTOFPr>;
@@ -295,7 +310,7 @@ struct Chargedkstaranalysis {
295310 // Variable declaration
296311 ROOT::Math::PxPyPzEVector beam1{0 ., 0 ., -helicityCfgs.beamMomentum , 13600 . / 2 .};
297312 ROOT::Math::PxPyPzEVector beam2{0 ., 0 ., helicityCfgs.beamMomentum , 13600 . / 2 .};
298-
313+ double fMaxPosPV = 1e-2 ;
299314 void init (o2::framework::InitContext&)
300315 {
301316 centrality = -999 ;
@@ -558,6 +573,18 @@ struct Chargedkstaranalysis {
558573
559574 histos.add (" EffKstar/recoKstar" , " Kstar Reco matched (final all)" , HistType::kTH2F , {ptAxis, centAxis});
560575 histos.add (" MCReco/hInvmass_Kstar_true" , " MC-reco truth-tagged chK(892)" , HistType::kTHnSparseD , {centAxis, ptAxis, invMassAxisReso});
576+ histos.add (" Correction/sigLoss_den" , " Gen Kstar (|y|<0.5) in truth class" , HistType::kTH2F , {ptAxis, centAxis});
577+ histos.add (" Correction/sigLoss_den_pri" , " Gen primary Kstar (|y|<0.5) in truth class" , HistType::kTH2F , {ptAxis, centAxis});
578+ histos.add (" Correction/sigLoss_num" , " Gen Kstar (|y|<0.5, selected events) in reco class" , HistType::kTH2F , {ptAxis, centAxis});
579+ histos.add (" Correction/sigLoss_num_pri" , " Gen primary Kstar (|y|<0.5, selected events) in reco class" , HistType::kTH2F , {ptAxis, centAxis});
580+ histos.add (" Correction/EF_den" , " Gen events (truth class)" , HistType::kTH1F , {centAxis});
581+ histos.add (" Correction/EF_num" , " Reco events (selected events)" , HistType::kTH1F , {centAxis});
582+ histos.add (" Correction/hNEventsMCTruth" , " hNEventsMCTruth" , HistType::kTH1F , {AxisSpec{nSteps, 0.5 , nSteps + 0.5 , " " }});
583+ auto hstep = histos.get <TH1>(HIST (" Correction/hNEventsMCTruth" ));
584+ hstep->GetXaxis ()->SetBinLabel (1 , " All" );
585+ hstep->GetXaxis ()->SetBinLabel (2 , " zvtx" );
586+ hstep->GetXaxis ()->SetBinLabel (3 , " INEL>0" );
587+ hstep->GetXaxis ()->SetBinLabel (4 , " Assoc with reco coll" );
561588 }
562589
563590 ccdb->setURL (cfgURL);
@@ -573,7 +600,8 @@ struct Chargedkstaranalysis {
573600
574601 std::unordered_set<int64_t > allowedMcIds;
575602 std::unordered_map<int64_t , float > centTruthByAllowed;
576-
603+ std::unordered_set<int64_t > refClassIds;
604+ std::unordered_map<int64_t , float > refCentByMcId;
577605 float lMultiplicity;
578606 template <typename CollisionType>
579607 float getCentrality (CollisionType const & collision)
@@ -1210,12 +1238,13 @@ struct Chargedkstaranalysis {
12101238 }
12111239 PROCESS_SWITCH (Chargedkstaranalysis, processDataME, " Process Event for data without Partitioning" , true );
12121240
1213- void processMC (soa::Join<aod::McCollisions, aod::McCentFT0Ms> const &, aod::McParticles const & mcParticles, soa::Join<EventCandidates, aod::McCollisionLabels> const & events, MCV0Candidates const & v0s, MCTrackCandidates const & tracks)
1241+ void processMC (soa::Join<aod::McCollisions, aod::McCentFT0Ms> const & mccolls , aod::McParticles const & mcParticles, soa::Join<EventCandidates, aod::McCollisionLabels> const & events, MCV0Candidates const & v0s, MCTrackCandidates const & tracks)
12141242 {
12151243 allowedMcIds.clear ();
12161244 centTruthByAllowed.clear ();
1217-
1218- // To apply event selection and store the collision IDs of reconstructed tracks that pass the selection criteria
1245+ refClassIds.clear ();
1246+ refCentByMcId.clear ();
1247+ // To apply event selection and store the collision IDs of reconstructed events that pass the selection criteria
12191248 for (const auto & coll : events) {
12201249
12211250 if (!coll.has_mcCollision ())
@@ -1252,6 +1281,30 @@ struct Chargedkstaranalysis {
12521281 allowedMcIds.insert (mcid);
12531282 centTruthByAllowed.emplace (mcid, lCentrality);
12541283 }
1284+
1285+ // To builds a list of accepted MC collisions ID's for the truth candidates: i.e. the total number of generated events
1286+ for (const auto & coll : mccolls) {
1287+ bool pass = true ;
1288+
1289+ if (cfgTruthIncludeZvtx && std::abs (coll.posZ ()) >= eventCutCfgs.confEvtZvtx )
1290+ pass = false ;
1291+
1292+ if (pass && cfgTruthUseInelGt0) {
1293+ auto partsThisMc = mcParticles.sliceBy (perMCCollision, coll.globalIndex ()); // This is to slice all MC particles belonging to the current MC collision.
1294+ // To check the INEL > 0
1295+ if (!pwglf::isINELgtNmc (partsThisMc, 0 , pdg))
1296+ pass = false ;
1297+ }
1298+
1299+ if (!pass)
1300+ continue ;
1301+
1302+ const auto mcid = coll.globalIndex ();
1303+ refClassIds.insert (mcid);
1304+ const float lCentrality = coll.centFT0M ();
1305+ refCentByMcId.emplace (mcid, lCentrality);
1306+ }
1307+
12551308 // Calculating the generated Kstar
12561309 for (const auto & part : mcParticles) {
12571310 currentIsGen = true ;
@@ -1408,6 +1461,88 @@ struct Chargedkstaranalysis {
14081461 histos.fill (HIST (" MCReco/hInvmass_Kstar_true" ), lCentrality, ptreco, lResoKstar.M ());
14091462 }
14101463 }
1464+ // To calculate the event losses to store the generated KstartPlus --> To check the number of events remains after passing all the event selection criteria for chk892
1465+ for (auto const & part : mcParticles) {
1466+ if (!part.has_mcCollision ())
1467+ continue ;
1468+ if (std::abs (part.pdgCode ()) != kKstarPlus )
1469+ continue ;
1470+ if (std::abs (part.y ()) > kstarCutCfgs.cKstarMaxRap )
1471+ continue ;
1472+
1473+ const auto mcid = part.mcCollisionId ();
1474+ if (allowedMcIds.count (mcid) == 0 )
1475+ continue ;
1476+
1477+ auto iter = centTruthByAllowed.find (mcid);
1478+ if (iter == centTruthByAllowed.end ())
1479+ continue ;
1480+
1481+ const float lCentrality = iter->second ;
1482+
1483+ histos.fill (HIST (" Correction/sigLoss_num" ), part.pt (), lCentrality);
1484+ if (part.vt () == 0 ) {
1485+ histos.fill (HIST (" Correction/sigLoss_num_pri" ), part.pt (), lCentrality);
1486+ }
1487+ }
1488+ // To calculate the denominator -> To check the all the events have chk892
1489+ for (auto const & part : mcParticles) {
1490+ if (!part.has_mcCollision ())
1491+ continue ;
1492+ if (std::abs (part.pdgCode ()) != kKstarPlus )
1493+ continue ;
1494+ if (std::abs (part.y ()) > kstarCutCfgs.cKstarMaxRap )
1495+ continue ;
1496+
1497+ const auto mcid = part.mcCollisionId ();
1498+ if (refClassIds.count (mcid) == 0 )
1499+ continue ;
1500+
1501+ auto iter = refCentByMcId.find (mcid);
1502+ if (iter == refCentByMcId.end ())
1503+ continue ;
1504+
1505+ const float lCentrality = iter->second ;
1506+
1507+ histos.fill (HIST (" Correction/sigLoss_den" ), part.pt (), lCentrality);
1508+ if (part.vt () == 0 ) {
1509+ histos.fill (HIST (" Correction/sigLoss_den_pri" ), part.pt (), lCentrality);
1510+ }
1511+ }
1512+ // To calculate the event fraction correction
1513+ for (const auto & mcid : refClassIds) {
1514+ histos.fill (HIST (" Correction/EF_den" ), refCentByMcId[mcid]);
1515+ }
1516+ for (const auto & mcid : allowedMcIds) {
1517+ auto iter = centTruthByAllowed.find (mcid);
1518+ if (iter == centTruthByAllowed.end ())
1519+ continue ;
1520+
1521+ const float lCentrality = iter->second ;
1522+ histos.fill (HIST (" Correction/EF_num" ), lCentrality);
1523+ }
1524+
1525+ for (auto const & mcc : mccolls) {
1526+ const auto mcid = mcc.globalIndex ();
1527+
1528+ histos.fill (HIST (" Correction/hNEventsMCTruth" ), 1.0 );
1529+
1530+ bool passZvtx = true ;
1531+ if (cfgTruthIncludeZvtx && std::abs (mcc.posZ ()) > eventCutCfgs.confEvtZvtx ) {
1532+ passZvtx = false ;
1533+ }
1534+ if (passZvtx) {
1535+ histos.fill (HIST (" Correction/hNEventsMCTruth" ), 2.0 );
1536+
1537+ auto partsThisMc = mcParticles.sliceBy (perMCCollision, mcid);
1538+ if (pwglf::isINELgtNmc (partsThisMc, 0 , pdg)) {
1539+ histos.fill (HIST (" Correction/hNEventsMCTruth" ), 3.0 );
1540+ }
1541+ }
1542+ if (allowedMcIds.count (mcid)) {
1543+ histos.fill (HIST (" Correction/hNEventsMCTruth" ), 4.0 );
1544+ }
1545+ }
14111546 }
14121547 PROCESS_SWITCH (Chargedkstaranalysis, processMC, " Process Event for MC" , false );
14131548};
0 commit comments