2121
2222#include " PWGLF/DataModel/EPCalibrationTables.h"
2323#include " PWGLF/DataModel/LFSlimNucleiTables.h"
24+ #include " PWGLF/Utils/inelGt.h"
2425
2526#include " Common/Core/EventPlaneHelper.h"
2627#include " Common/Core/PID/PIDTOF.h"
5253#include " ReconstructionDataFormats/Track.h"
5354
5455#include < Math/Vector4D.h>
56+ #include < TDatabasePDG.h>
5557#include < TMCProcess.h>
5658#include < TPDGCode.h> // for PDG codes
59+ #include < TParticlePDG.h>
5760#include < TRandom3.h>
5861
5962#include < algorithm>
@@ -248,6 +251,13 @@ constexpr int EvSelDefault[9][1]{
248251 {0 },
249252 {0 },
250253 {0 }};
254+
255+ enum EvGenSel : uint8_t {
256+ kGenTVX = 1 << 0 ,
257+ kGenZvtx = 1 << 1 ,
258+ kGenINELgt0 = 1 << 2 ,
259+ };
260+
251261} // namespace nuclei
252262
253263struct nucleiSpectra {
@@ -269,7 +279,9 @@ struct nucleiSpectra {
269279 Produces<o2::aod::NucleiTable> nucleiTable;
270280 Produces<o2::aod::NucleiPairTable> nucleiPairTable;
271281 Produces<o2::aod::NucleiTableMC> nucleiTableMC;
282+ Produces<o2::aod::NucleiTableMCExtension> nucleiTableMCExtension;
272283 Produces<o2::aod::NucleiTableFlow> nucleiTableFlow;
284+ Produces<o2::aod::GenEventMCSel> GenEventMCSel;
273285 Service<o2::ccdb::BasicCCDBManager> ccdb;
274286 Zorro zorro;
275287 OutputObj<ZorroSummary> zorroSummary{" zorroSummary" };
@@ -334,6 +346,7 @@ struct nucleiSpectra {
334346 ConfigurableAxis cfgNTPCClusBins{" cfgNTPCClusBins" , {3 , 89.5 , 159.5 }, " N TPC clusters binning" };
335347
336348 Configurable<bool > cfgSkimmedProcessing{" cfgSkimmedProcessing" , false , " Skimmed dataset processing" };
349+ Configurable<std::string> cfgTriggerList{" cfgTriggerList" , " fHe" , " Trigger List" };
337350
338351 // running variables for track tuner
339352 o2::dataformats::DCA mDcaInfoCov ;
@@ -453,7 +466,7 @@ struct nucleiSpectra {
453466 return ;
454467 }
455468 if (cfgSkimmedProcessing) {
456- zorro.initCCDB (ccdb.service , bc.runNumber (), bc.timestamp (), " fHe " );
469+ zorro.initCCDB (ccdb.service , bc.runNumber (), bc.timestamp (), cfgTriggerList );
457470 zorro.populateHistRegistry (spectra, bc.runNumber ());
458471 }
459472 auto timestamp = bc.timestamp ();
@@ -911,13 +924,64 @@ struct nucleiSpectra {
911924 PROCESS_SWITCH (nucleiSpectra, processDataFlowAlternative, " Data analysis with flow - alternative framework" , false );
912925
913926 Preslice<TrackCandidates> tracksPerCollisions = aod::track::collisionId;
927+ Preslice<aod::McParticles> particlesPerMcCollision = aod::mcparticle::mcCollisionId;
914928 void processMC (soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels> const & collisions, aod::McCollisions const & mcCollisions, soa::Join<TrackCandidates, aod::McTrackLabels> const & tracks, aod::McParticles const & particlesMC, aod::BCsWithTimestamps const &)
915929 {
916930 nuclei::candidates.clear ();
931+
932+ bool selectINELgt0 = cfgEventSelections->get (nuclei::evSel::kINELgt0 );
933+ std::vector<bool > goodCollisions (mcCollisions.size (), false );
934+ std::vector<uint8_t > eventMask (mcCollisions.size (), 0 );
935+
936+ auto * pdgDB = TDatabasePDG::Instance (); // Useful for evaluating the particle charge
937+
917938 for (const auto & c : mcCollisions) {
939+
940+ uint8_t mask = 0 ;
941+
942+ const auto & slicedParticles = particlesMC.sliceBy (particlesPerMcCollision, c.globalIndex ());
943+
944+ bool hasHitFT0A (false );
945+ bool hasHitFT0C (false );
946+
947+ // TVX trigger
948+ for (const auto & p : slicedParticles) {
949+ if (!p.isPhysicalPrimary ())
950+ continue ;
951+
952+ auto * pdg = pdgDB->GetParticle (p.pdgCode ());
953+ if (!pdg || pdg->Charge () == 0 )
954+ continue ;
955+
956+ // Apply the TVX trigger condition
957+ if (p.eta () > 3 .5f && p.eta () < 4 .9f )
958+ hasHitFT0A = true ;
959+ else if (p.eta () > -3 .3f && p.eta () < -2 .1f )
960+ hasHitFT0C = true ;
961+
962+ if (hasHitFT0A && hasHitFT0C)
963+ break ;
964+ }
965+
966+ if (hasHitFT0A && hasHitFT0C)
967+ mask |= nuclei::kGenTVX ;
968+
969+ // |z| condition
970+ if (std::abs (c.posZ ()) < cfgCutVertex)
971+ mask |= nuclei::kGenZvtx ;
972+
973+ // INEL > 0 selection
974+ if (selectINELgt0) {
975+ if (o2::pwglf::isINELgt0mc (slicedParticles, pdgDB)) {
976+ mask |= nuclei::kGenINELgt0 ;
977+ }
978+ }
979+
980+ eventMask[c.globalIndex ()] = mask;
981+ GenEventMCSel (mask);
918982 spectra.fill (HIST (" hGenVtxZ" ), c.posZ ());
919983 }
920- std::vector< bool > goodCollisions (mcCollisions. size (), false );
984+
921985 for (const auto & collision : collisions) {
922986 if (!eventSelectionWithHisto (collision)) {
923987 continue ;
@@ -926,6 +990,7 @@ struct nucleiSpectra {
926990 const auto & slicedTracks = tracks.sliceBy (tracksPerCollisions, collision.globalIndex ());
927991 fillDataInfo (collision, slicedTracks);
928992 }
993+
929994 std::vector<bool > isReconstructed (particlesMC.size (), false );
930995 for (auto & c : nuclei::candidates) {
931996 auto label = tracks.iteratorAt (c.globalIndex );
@@ -987,7 +1052,7 @@ struct nucleiSpectra {
9871052
9881053 isReconstructed[particle.globalIndex ()] = true ;
9891054 float absoDecL = computeAbsoDecL (particle);
990- nucleiTableMC (c.pt , c.eta , c.phi , c.tpcInnerParam , c.beta , c.zVertex , c.nContrib , c.DCAxy , c.DCAz , c.TPCsignal , c.ITSchi2 , c.TPCchi2 , c.TOFchi2 , c.flags , c.TPCfindableCls , c.TPCcrossedRows , c.ITSclsMap , c.TPCnCls , c.TPCnClsShared , c.clusterSizesITS , goodCollisions[particle.mcCollisionId ()], particle.pt (), particle.eta (), particle.phi (), particle.pdgCode (), motherPdgCode, motherDecRadius, absoDecL);
1055+ nucleiTableMCExtension (c.pt , c.eta , c.phi , c.tpcInnerParam , c.beta , c.zVertex , c.nContrib , c.DCAxy , c.DCAz , c.TPCsignal , c.ITSchi2 , c.TPCchi2 , c.TOFchi2 , c.flags , c.TPCfindableCls , c.TPCcrossedRows , c.ITSclsMap , c.TPCnCls , c.TPCnClsShared , c.clusterSizesITS , goodCollisions[particle.mcCollisionId ()], particle.pt (), particle.eta (), particle.phi (), particle.pdgCode (), motherPdgCode, motherDecRadius, absoDecL, eventMask[particle. mcCollisionId ()] );
9911056 }
9921057
9931058 int index{0 };
@@ -1039,7 +1104,7 @@ struct nucleiSpectra {
10391104 continue ; // skip secondaries from material if not requested
10401105 }
10411106 float absDecL = computeAbsoDecL (particle);
1042- nucleiTableMC (999 ., 999 ., 999 ., 0 ., 0 ., 999 ., -1 , 999 ., 999 ., -1 , -1 , -1 , -1 , flags, 0 , 0 , 0 , 0 , 0 , 0 , goodCollisions[particle.mcCollisionId ()], particle.pt (), particle.eta (), particle.phi (), particle.pdgCode (), motherPdgCode, motherDecRadius, absDecL);
1107+ nucleiTableMCExtension (999 ., 999 ., 999 ., 0 ., 0 ., 999 ., -1 , 999 ., 999 ., -1 , -1 , -1 , -1 , flags, 0 , 0 , 0 , 0 , 0 , 0 , goodCollisions[particle.mcCollisionId ()], particle.pt (), particle.eta (), particle.phi (), particle.pdgCode (), motherPdgCode, motherDecRadius, absDecL, eventMask[particle. mcCollisionId ()] );
10431108 }
10441109 break ;
10451110 }
0 commit comments