Skip to content

Commit c0d42f9

Browse files
author
Stefanie Mrozinski
committed
add selected free leg storage for derived data production in the co-reco mixed event
1 parent 0249407 commit c0d42f9

5 files changed

Lines changed: 538 additions & 77 deletions

File tree

‎PWGEM/PhotonMeson/DataModel/gammaTables.h‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,10 @@ DECLARE_SOA_COLUMN(RunNumber, runNumber, int); //! run of the so
617617
DECLARE_SOA_COLUMN(Timestamp, timestamp, uint64_t); //! CCDB timestamp of the source collision (builder run 2 on derived data: no BCs)
618618
DECLARE_SOA_COLUMN(MultNTracksPVeta1, multNTracksPVeta1, int); //! PV contributors with |eta| < 1 of the source collision
619619
DECLARE_SOA_COLUMN(MultFT0M, multFT0M, float); //! FT0A + FT0C amplitude of the source collision
620+
DECLARE_SOA_COLUMN(PartnerDz, partnerDz, float); //! mixed: z_vtx(partner) - z_vtx(current) (cm); N-photon mixing: mean |difference| over the N partners; same event: 0
621+
DECLARE_SOA_COLUMN(PartnerDCent, partnerDCent, float); //! as PartnerDz for the centrality (%)
622+
DECLARE_SOA_COLUMN(PartnerDOcc, partnerDOcc, float); //! as PartnerDz for the occupancy
623+
DECLARE_SOA_COLUMN(PartnerDt, partnerDt, float); //! as PartnerDz for the time, |timestamp(partner) - timestamp(current)| (s)
620624
} // namespace pcmmixcol
621625
DECLARE_SOA_TABLE(PCMMixCollisions, "AOD", "PCMMIXCOL", //!
622626
o2::soa::Index<>, collision::PosX, collision::PosY, collision::PosZ,
@@ -625,7 +629,8 @@ DECLARE_SOA_TABLE(PCMMixCollisions, "AOD", "PCMMIXCOL", //!
625629
pcmmixcol::CentFT0M, pcmmixcol::CentFT0A, pcmmixcol::CentFT0C,
626630
pcmmixcol::IsMixed, pcmmixcol::SourceCollisionId, pcmmixcol::SourceEventUid,
627631
pcmmixcol::ZBin, pcmmixcol::OccBin, pcmmixcol::Occupancy, pcmmixcol::FirstLeg, pcmmixcol::NLegs,
628-
pcmmixcol::RunNumber, pcmmixcol::MultNTracksPVeta1, pcmmixcol::MultFT0M, pcmmixcol::Timestamp);
632+
pcmmixcol::RunNumber, pcmmixcol::MultNTracksPVeta1, pcmmixcol::MultFT0M, pcmmixcol::Timestamp,
633+
pcmmixcol::PartnerDz, pcmmixcol::PartnerDCent, pcmmixcol::PartnerDOcc, pcmmixcol::PartnerDt);
629634
using PCMMixCollision = PCMMixCollisions::iterator;
630635

631636
namespace pcmmixleg
@@ -668,6 +673,9 @@ DECLARE_SOA_COLUMN(SourcePvCovYZ, sourcePvCovYZ, float); //!
668673
DECLARE_SOA_COLUMN(SourcePvCovZZ, sourcePvCovZZ, float); //!
669674
DECLARE_SOA_COLUMN(SourcePvChi2, sourcePvChi2, float); //!
670675
DECLARE_SOA_COLUMN(SourcePvNContrib, sourcePvNContrib, uint16_t); //!
676+
DECLARE_SOA_COLUMN(AlignDx, alignDx, float); //!
677+
DECLARE_SOA_COLUMN(AlignDy, alignDy, float); //!
678+
DECLARE_SOA_COLUMN(AlignDz, alignDz, float); //!
671679
DECLARE_SOA_COLUMN(OrigTrackId, origTrackId, int); //! AO2D track (DF of the source event)
672680
DECLARE_SOA_COLUMN(McParticleId, mcParticleId, int); //! MC: particle of the leg (DF of the source event), -1 without
673681
DECLARE_SOA_COLUMN(McMotherId, mcMotherId, int); //! MC: first mother (DF of the source event), -1 without
@@ -702,6 +710,7 @@ DECLARE_SOA_TABLE(PCMMixLegs, "AOD", "PCMMIXLEG", //!
702710
pcmmixleg::SourcePx, pcmmixleg::SourcePy, pcmmixleg::SourcePz, pcmmixleg::SourceVx, pcmmixleg::SourceVy, pcmmixleg::SourceVz,
703711
pcmmixleg::SourcePvX, pcmmixleg::SourcePvY, pcmmixleg::SourcePvZ, pcmmixleg::SourcePvCovXX, pcmmixleg::SourcePvCovXY, pcmmixleg::SourcePvCovXZ,
704712
pcmmixleg::SourcePvCovYY, pcmmixleg::SourcePvCovYZ, pcmmixleg::SourcePvCovZZ, pcmmixleg::SourcePvChi2, pcmmixleg::SourcePvNContrib,
713+
pcmmixleg::AlignDx, pcmmixleg::AlignDy, pcmmixleg::AlignDz,
705714
pcmmixleg::OrigTrackId, pcmmixleg::McParticleId, pcmmixleg::McMotherId, pcmmixleg::McPdg, pcmmixleg::McMotherPdg,
706715
pcmmixleg::McMotherPx, pcmmixleg::McMotherPy, pcmmixleg::McMotherPz, pcmmixleg::McGrandMotherId, pcmmixleg::McGrandMotherPdg, pcmmixleg::McAncestorId,
707716
pcmmixleg::McGGMotherId, pcmmixleg::McGGMotherPdg, pcmmixleg::McRootId, pcmmixleg::McRootPdg, pcmmixleg::McRootDepth, pcmmixleg::McVx, pcmmixleg::McVy, pcmmixleg::McVz,
@@ -745,7 +754,8 @@ DECLARE_SOA_COLUMN(TrackIdDelta, trackIdDelta, int); //! AO2D track index minus
745754
DECLARE_SOA_TABLE(PCMFreeLegIds, "AOD", "PCMFREELEGID", //! rows in increasing track order; track index = running sum of TrackIdDelta over the DF
746755
o2::soa::Index<>, pcmfreeleg::CollisionId, pcmfreelegid::TrackIdDelta);
747756
using PCMFreeLegId = PCMFreeLegIds::iterator;
748-
DECLARE_SOA_TABLE(PCMFreeLegEMEventIds, "AOD", "PCMFREELEGEVID", pcmfreelegid::PMEventId); //! to be joined with PCMFreeLegIds
757+
DECLARE_SOA_TABLE(PCMFreeLegEMEventIds, "AOD", "PCMFREELEGEVID", pcmfreelegid::PMEventId); //! to be joined with PCMFreeLegIds
758+
DECLARE_SOA_TABLE(PCMFreeLegMCLabels, "AOD", "PCMFLMCLABEL", v0legmclabel::EMMCParticleId, v0legmclabel::McMask); //! MC label of a free leg (derived MC), to be joined with PCMFreeLegs
749759

750760
// builder run 2 output (same columns as the run-1 tables; collisionId = PCMMixCollisions row, trackId = PCMMixLegs row,
751761
// v0Id >= 0: original pairing of run 1, -1: crossed pairing)

‎PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct AssociateMCInfoPhoton {
8484
Produces<o2::aod::EMMCEventLabels> mceventlabels;
8585
Produces<o2::aod::EMMCParticles> emmcparticles;
8686
Produces<o2::aod::V0LegMCLabels> v0legmclabels;
87+
Produces<o2::aod::PCMFreeLegMCLabels> pcmfreelegmclabels;
8788
Produces<o2::aod::EMPrimaryElectronMCLabels> emprimaryelectronmclabels;
8889
Produces<o2::aod::EMEMCClusterMCLabels_001> ememcclustermclabels;
8990

@@ -401,7 +402,7 @@ struct AssociateMCInfoPhoton {
401402
}
402403

403404
template <uint8_t system, typename TTracks, typename TFwdTracks, typename TPCMs, typename TPCMLegs, typename TPHOSs, typename TEMCs, typename TEMPrimaryElectrons>
404-
void skimmingMC(MyCollisionsMC const& collisions, aod::BCs const&, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles, TTracks const& o2tracks, TFwdTracks const&, TPCMs const& v0photons, TPCMLegs const& legs, TPHOSs const&, TEMCs const& emcclusters, TEMPrimaryElectrons const& emprimaryelectrons)
405+
void skimmingMC(MyCollisionsMC const& collisions, aod::BCs const&, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles, TTracks const& o2tracks, TFwdTracks const&, TPCMs const& v0photons, TPCMLegs const& legs, TPHOSs const&, TEMCs const& emcclusters, TEMPrimaryElectrons const& emprimaryelectrons, aod::PCMFreeLegs const* freeLegs = nullptr)
405406
{
406407
// temporary variables used for the indexing of the skimmed MC stack
407408
std::unordered_map<uint64_t, int> fNewLabels;
@@ -637,6 +638,40 @@ struct AssociateMCInfoPhoton {
637638
}
638639
} // end of loop over legs {pos, ele}
639640
} // end of v0 loop
641+
642+
// for each free leg, check if it has a valid MC particle. If yes, store it in the skimmed MC stack and also store its mother chain. If not, just store a row with -1 and kNoMcParticleMask.
643+
if (freeLegs != nullptr) {
644+
for (const auto& freeLeg : *freeLegs) {
645+
collisionIter.setCursor(freeLeg.collisionId());
646+
bool validMc = false;
647+
if (passesCollisionGate(collisionIter)) {
648+
mcCollisionIter.setCursor(collisionIter.mcCollisionId());
649+
o2TrackIter.setCursor(freeLeg.trackId());
650+
validMc = o2TrackIter.has_mcParticle();
651+
}
652+
if (!validMc) {
653+
pcmfreelegmclabels(-1, kNoMcParticleMask); // the row must exist
654+
continue;
655+
}
656+
mcParticleIter.setCursor(o2TrackIter.mcParticleId());
657+
auto [iter, isNew] = fNewLabels.try_emplace(mcParticleIter.globalIndex(), fCounter.particles);
658+
if (isNew) {
659+
fNewLabelsReversed[fCounter.particles] = mcParticleIter.globalIndex();
660+
auto evIt = fEventLabels.find(mcCollisionIter.globalIndex());
661+
if (evIt != fEventLabels.end()) {
662+
fEventIdx[mcParticleIter.globalIndex()] = evIt->second;
663+
}
664+
fCounter.particles++;
665+
}
666+
pcmfreelegmclabels(iter->second, o2TrackIter.mcMask());
667+
int motherid = -999;
668+
if (mcParticleIter.has_mothers()) {
669+
motherid = mcParticleIter.mothersIds()[0];
670+
}
671+
selectMothersToStore(motherid, mcParticles.size(), motherParticle, daughterIter, mcCollisionIter,
672+
fNewLabels, fNewLabelsReversed, fEventIdx, fEventLabels, fCounter);
673+
}
674+
}
640675
}
641676

642677
if constexpr (static_cast<bool>(system & kElectron)) {
@@ -808,6 +843,12 @@ struct AssociateMCInfoPhoton {
808843
}
809844
PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM, "create em mc event table for PCM", false);
810845

846+
void processMC_PCM_FreeLegs(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::PCMFreeLegs const& freeLegs)
847+
{
848+
skimmingMC<kPCM>(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, v0photons, v0legs, nullptr, nullptr, nullptr, &freeLegs);
849+
}
850+
PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_FreeLegs, "create em mc event table for PCM incl. the free legs of run 1 (PCMFreeLegs -> PCMFreeLegMCLabels)", false);
851+
811852
void processMC_PCM_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons)
812853
{
813854
const uint8_t sysflag = kPCM | kElectron;

‎PWGEM/PhotonMeson/TableProducer/createEMEventPhoton.cxx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,19 @@ struct AssociatePhotonToEMEvent {
333333
}
334334
}
335335

336+
// free legs of run 1 with their parameters (PCMFreeLegs, self-contained derived data, donor events only)
337+
void processPCMFreeLegsFull(aod::PMEvents const& collisions, aod::PCMFreeLegs const& freeLegs)
338+
{
339+
std::unordered_map<int, int> eventOf;
340+
for (const auto& collision : collisions) {
341+
eventOf[collision.collisionId()] = collision.globalIndex();
342+
}
343+
for (const auto& leg : freeLegs) {
344+
const auto it = eventOf.find(leg.collisionId());
345+
freelegeventid(it == eventOf.end() ? -1 : it->second);
346+
}
347+
}
348+
336349
void processElectronFromDalitz(aod::PMEvents const& collisions, aod::EMPrimaryElectronsFromDalitz const& tracks)
337350
{
338351
fillEventId(collisions, tracks, prmeleventid, perCollisionEl);
@@ -357,6 +370,7 @@ struct AssociatePhotonToEMEvent {
357370

358371
PROCESS_SWITCH(AssociatePhotonToEMEvent, processPCM, "process pcm-event indexing", false);
359372
PROCESS_SWITCH(AssociatePhotonToEMEvent, processPCMFreeLegs, "free legs of run 1 (PCMFreeLegIds) -> derived event index, for the mixer on linked derived data", false);
373+
PROCESS_SWITCH(AssociatePhotonToEMEvent, processPCMFreeLegsFull, "free legs of run 1 with parameters (PCMFreeLegs) -> derived event index, for the mixer on self-contained derived data", false);
360374
PROCESS_SWITCH(AssociatePhotonToEMEvent, processElectronFromDalitz, "process dalitzee-event indexing", false);
361375
PROCESS_SWITCH(AssociatePhotonToEMEvent, processPHOS, "process phos-event indexing", false);
362376
PROCESS_SWITCH(AssociatePhotonToEMEvent, processEMC, "process emc-event indexing", false);

0 commit comments

Comments
 (0)