Skip to content

Commit 31c9e5d

Browse files
authored
[PWGEM] Add option to separate EMCal and DCal cluster pairing for flow task (#17246)
1 parent a70296c commit 31c9e5d

9 files changed

Lines changed: 209 additions & 96 deletions

File tree

PWGEM/PhotonMeson/DataModel/GammaTablesRedux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ enum Observable {
4747
};
4848

4949
// Values in tables are stored in downscaled format to save disk space
50-
const std::array<float, nObservables> downscalingFactors{
50+
constexpr std::array<float, nObservables> downscalingFactors{
5151
1E0, // Cluster definition
5252
1E3, // Cluster energy
5353
1E4, // Cluster eta

PWGEM/PhotonMeson/DataModel/gammaTables.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,31 @@ using V0LegMCLabel = V0LegMCLabels::iterator;
102102
// 3. EMEMCClusterMCLabels: Vector of EM MC particle ID of largest contributor to cluster
103103
namespace emcclustermclabel
104104
{
105-
DECLARE_SOA_ARRAY_INDEX_COLUMN(McParticle, emmcparticle) //!
105+
DECLARE_SOA_ARRAY_INDEX_COLUMN(McParticle, mcParticle) //! Array of indice of McParticles
106+
DECLARE_SOA_COLUMN(Amplitude, amplitude, std::vector<float>); //! vector of aplitudes stored in cluster. Ordering is identical to the ordering of EMMCParticleId
106107
} // namespace emcclustermclabel
107108

108109
// NOTE: MC labels. This table has one vector of global mc particle ids for each reconstructed emc cluster (joinable with emccluster table)
109110
DECLARE_SOA_TABLE(EMCClusterMCLabels, "AOD", "EMCClsMCLABEL", //!
110111
emcclustermclabel::McParticleIds);
111-
using EMCClusterMCLabel = EMCClusterMCLabels::iterator;
112+
113+
DECLARE_SOA_TABLE_VERSIONED(EMCClusterMCLabels_001, "AOD", "EMCClsMCLABEL", 1, //!
114+
emcclustermclabel::McParticleIds, emcclustermclabel::Amplitude);
115+
using EMCClusterMCLabel = EMCClusterMCLabels_001::iterator;
112116

113117
namespace ememcclustermclabel
114118
{
115-
DECLARE_SOA_ARRAY_INDEX_COLUMN(EMMCParticle, emmcparticle); //!
119+
DECLARE_SOA_ARRAY_INDEX_COLUMN(EMMCParticle, emmcparticle); //! Array of indice of EmMcParticles
120+
DECLARE_SOA_COLUMN(Amplitude, amplitude, std::vector<float>); //! vector of aplitudes stored in cluster. Ordering is identical to the ordering of EMMCParticleId
116121
} // namespace ememcclustermclabel
117122

118123
// NOTE: MC labels. This table has a vector of entries for each reconstructed emc cluster (joinable with emccluster table)
119124
DECLARE_SOA_TABLE(EMEMCClusterMCLabels, "AOD", "EMEMCClsMCLABEL", //!
120125
ememcclustermclabel::EMMCParticleIds);
121-
using EMEMCClusterMCLabel = EMEMCClusterMCLabels::iterator;
126+
127+
DECLARE_SOA_TABLE_VERSIONED(EMEMCClusterMCLabels_001, "AOD", "EMEMCClsMCLABEL", 1, //!
128+
ememcclustermclabel::EMMCParticleIds, ememcclustermclabel::Amplitude);
129+
using EMEMCClusterMCLabel = EMEMCClusterMCLabels_001::iterator;
122130

123131
namespace v0leg
124132
{
@@ -146,9 +154,8 @@ DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITS, meanClusterSizeITS, [](uint32_t i
146154
}
147155
if (nl > 0) {
148156
return static_cast<float>(total_cluster_size) / static_cast<float>(nl);
149-
} else {
150-
return 0;
151157
}
158+
return 0;
152159
});
153160
DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITSib, meanClusterSizeITSib, [](uint32_t itsClusterSizes) -> float {
154161
int total_cluster_size = 0, nl = 0;
@@ -161,9 +168,8 @@ DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITSib, meanClusterSizeITSib, [](uint32
161168
}
162169
if (nl > 0) {
163170
return static_cast<float>(total_cluster_size) / static_cast<float>(nl);
164-
} else {
165-
return 0;
166171
}
172+
return 0;
167173
});
168174
DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITSob, meanClusterSizeITSob, [](uint32_t itsClusterSizes) -> float {
169175
int total_cluster_size = 0, nl = 0;
@@ -176,9 +182,8 @@ DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITSob, meanClusterSizeITSob, [](uint32
176182
}
177183
if (nl > 0) {
178184
return static_cast<float>(total_cluster_size) / static_cast<float>(nl);
179-
} else {
180-
return 0;
181185
}
186+
return 0;
182187
});
183188
} // namespace v0leg
184189
DECLARE_SOA_TABLE(V0Legs_000, "AOD", "V0LEG", //!

PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// or submit itself to any jurisdiction.
1111

1212
/// \file associateMCinfoPhoton.cxx
13-
/// \brief This code produces reduced events for photon analyses
14-
/// \author Daiki Sekihata (daiki.sekihata@cern.ch)
13+
/// \brief This code produces EmMc tables were the McParticleIds get reshuffled due to not storing all McParticles
14+
/// \author Daiki Sekihata (daiki.sekihata@cern.ch), Marvin Hemmer (marvin.hemmer@cern.ch), Nicolas Strangmann (nicolas.strangmann@cern.ch)
1515

1616
#include "PWGEM/PhotonMeson/DataModel/GammaTablesRedux.h"
1717
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"
@@ -38,6 +38,7 @@
3838
#include <sys/types.h>
3939

4040
#include <algorithm>
41+
#include <array>
4142
#include <cmath>
4243
#include <cstddef>
4344
#include <cstdint>
@@ -57,7 +58,7 @@ using namespace o2::constants::physics;
5758
using MyCollisionsMC = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels, aod::EMEvSels>;
5859
using TracksMC = soa::Join<aod::TracksIU, aod::McTrackLabels>;
5960
using FwdTracksMC = soa::Join<aod::FwdTracks, aod::McFwdTrackLabels>;
60-
using MyEMCClusters = soa::Join<aod::MinClusters, aod::EMCClusterMCLabels>;
61+
using MyEMCClusters = soa::Join<aod::MinClusters, aod::EMCClusterMCLabels_001>;
6162

6263
struct Counter {
6364
int particles{0};
@@ -77,7 +78,7 @@ struct AssociateMCInfoPhoton {
7778
Produces<o2::aod::EMMCParticles> emmcparticles;
7879
Produces<o2::aod::V0LegMCLabels> v0legmclabels;
7980
Produces<o2::aod::EMPrimaryElectronMCLabels> emprimaryelectronmclabels;
80-
Produces<o2::aod::EMEMCClusterMCLabels> ememcclustermclabels;
81+
Produces<o2::aod::EMEMCClusterMCLabels_001> ememcclustermclabels;
8182

8283
Produces<o2::aod::BinnedGenPts> binnedGenPt;
8384

@@ -100,6 +101,7 @@ struct AssociateMCInfoPhoton {
100101

101102
// !!Don't change pt,eta,y binning. These binnings have to be consistent with binned data at analysis.!!
102103
std::vector<double> ptbins;
104+
ptbins.reserve(72);
103105
for (int i = 0; i < 2; i++) { // o2-linter: disable=magic-number (just numbers for binning)
104106
ptbins.emplace_back(0.05 * (i - 0) + 0.0); // from 0 to 0.05 GeV/c, every 0.05 GeV/c
105107
}
@@ -116,7 +118,7 @@ struct AssociateMCInfoPhoton {
116118
const AxisSpec axisRapidity{{0.0, +0.8, +0.9}, "rapidity |y|"};
117119

118120
static constexpr uint NParticleNames = 9;
119-
static constexpr std::string_view ParticleNames[NParticleNames] = {
121+
static constexpr std::array<std::string_view, NParticleNames> ParticleNames = {
120122
"Gamma", "Pi0", "Eta", "Omega", "Phi",
121123
"ChargedPion", "ChargedKaon", "K0S", "Lambda"};
122124

@@ -267,17 +269,19 @@ struct AssociateMCInfoPhoton {
267269
genGamma[binNumber]++;
268270
break;
269271
case PDG_t::kPi0:
270-
if (requireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles))
272+
if (requireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles)) {
271273
continue;
274+
}
272275
registry.fill(HIST("Generated/h2PtY_Pi0"), mcParticle.pt(), std::fabs(mcParticle.y()));
273276
genPi0[binNumber]++;
274277
if (isMesonAccepted) {
275278
registry.fill(HIST("Generated/h2PtY_Accepted_Pi0"), mcParticle.pt(), std::fabs(mcParticle.y()));
276279
}
277280
break;
278281
case Pdg::kEta:
279-
if (requireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles))
282+
if (requireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles)) {
280283
continue;
284+
}
281285
registry.fill(HIST("Generated/h2PtY_Eta"), mcParticle.pt(), std::fabs(mcParticle.y()));
282286
genEta[binNumber]++;
283287
if (isMesonAccepted) {
@@ -291,7 +295,7 @@ struct AssociateMCInfoPhoton {
291295
} // end of mc track loop
292296

293297
// make an entry for this MC event only if it was not already added to the table
294-
if (!(fEventLabels.find(mcCollisionIter.globalIndex()) != fEventLabels.end())) {
298+
if (!fEventLabels.contains(mcCollisionIter.globalIndex())) {
295299
mcevents(mcCollisionIter.globalIndex(), mcCollisionIter.generatorsID(), mcCollisionIter.posX(), mcCollisionIter.posY(), mcCollisionIter.posZ(), mcCollisionIter.impactParameter(), mcCollisionIter.eventPlaneAngle());
296300
fEventLabels[mcCollisionIter.globalIndex()] = fCounter.events;
297301
fCounter.events++;
@@ -438,15 +442,17 @@ struct AssociateMCInfoPhoton {
438442
mcCollisionIter.setCursor(collisionIter.mcCollisionId());
439443

440444
// TODO: test
441-
if (emccluster.emmcparticleIds().size() <= 0) {
445+
if (emccluster.mcParticleIds().size() <= 0) {
442446
continue;
443447
}
444448
std::vector<int32_t> vEmcMcParticleIds;
449+
std::vector<float> vAmplitudes;
445450

446-
vEmcMcParticleIds.reserve(emccluster.emmcparticleIds().size());
451+
vEmcMcParticleIds.reserve(emccluster.mcParticleIds().size());
452+
vAmplitudes.reserve(emccluster.mcParticleIds().size());
447453

448-
for (const auto& emcParticleId : emccluster.emmcparticleIds()) {
449-
mcPhoton.setCursor(emcParticleId);
454+
for (size_t iCont = 0; iCont < emccluster.mcParticleIds().size(); iCont++) {
455+
mcPhoton.setCursor(emccluster.mcParticleIds()[iCont]);
450456

451457
// if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack
452458
auto [iter, isNew] = fNewLabels.try_emplace(mcPhoton.globalIndex(), fCounter.particles);
@@ -456,6 +462,7 @@ struct AssociateMCInfoPhoton {
456462
fCounter.particles++;
457463
}
458464
vEmcMcParticleIds.emplace_back(iter->second);
465+
vAmplitudes.emplace_back(emccluster.amplitude()[iCont]);
459466
// ememcclustermclabels(fNewLabels.find(mcPhoton.index())->second);
460467

461468
// Next, store mother-chain of this reconstructed track.
@@ -465,7 +472,7 @@ struct AssociateMCInfoPhoton {
465472
}
466473
selectMothersToStore(motherid, mcParticles.size(), motherParticle, daughterIter, mcCollisionIter, fNewLabels, fNewLabelsReversed, fEventIdx, fEventLabels, fCounter);
467474
} // end of loop over mc particles of the current emc cluster
468-
ememcclustermclabels(vEmcMcParticleIds);
475+
ememcclustermclabels(vEmcMcParticleIds, vAmplitudes);
469476

470477
} // end of em emc cluster loop
471478
}
@@ -625,8 +632,8 @@ struct AssociateMCInfoPhoton {
625632
PROCESS_SWITCH(AssociateMCInfoPhoton, processDummy, "processDummy", true);
626633
};
627634

628-
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
635+
WorkflowSpec defineDataProcessing(ConfigContext const& context)
629636
{
630637
return WorkflowSpec{
631-
adaptAnalysisTask<AssociateMCInfoPhoton>(cfgc, TaskName{"associate-mc-info-photon"})};
638+
adaptAnalysisTask<AssociateMCInfoPhoton>(context, TaskName{"associate-mc-info-photon"})};
632639
}

PWGEM/PhotonMeson/TableProducer/skimmerGammaCalo.cxx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct SkimmerGammaCalo {
5353
Preslice<o2::aod::EMCMatchSecs> psMSperCluster = o2::aod::emcalclustercell::emcalclusterId;
5454

5555
Produces<aod::SkimEMCClusters_001> tableGammaEMCReco;
56-
Produces<aod::EMCClusterMCLabels> tableEMCClusterMCLabels;
56+
Produces<aod::EMCClusterMCLabels_001> tableEMCClusterMCLabels;
5757
Produces<aod::SkimEMCCells> tableCellEMCReco;
5858

5959
Produces<aod::EmEmcClusters_000> tableEmEmcClusters;
@@ -331,15 +331,16 @@ struct SkimmerGammaCalo {
331331
continue;
332332
}
333333
std::vector<int32_t> mcLabels;
334+
std::vector<float> amplitudes;
335+
mcLabels.reserve(emccluster.amplitudeA().size());
336+
amplitudes.reserve(emccluster.amplitudeA().size());
334337
for (size_t iCont = 0; iCont < emccluster.amplitudeA().size(); iCont++) {
335338
mcLabels.push_back(emccluster.mcParticleIds()[iCont]);
339+
amplitudes.push_back(emccluster.amplitudeA()[iCont]);
336340
}
337-
// LOGF(info, "---- New Cluster ---");
338-
// for (unsigned long int iCont = 0; iCont < mcLabels.size(); iCont++) {
339-
// LOGF(info, "iCont = %d, mcParticle = %d, amplitudeA = %.5f", iCont, mcLabels.at(iCont), emccluster.amplitudeA()[iCont]);
340-
// }
341-
tableEMCClusterMCLabels(mcLabels);
341+
tableEMCClusterMCLabels(mcLabels, amplitudes);
342342
mcLabels.clear();
343+
amplitudes.clear();
343344
}
344345
}
345346
PROCESS_SWITCH(SkimmerGammaCalo, processMC, "process MC info", false); // Run this in addition to processRec for MCs to copy the cluster mc labels from the EMCALMCClusters to the skimmed EMCClusterMCLabels table

0 commit comments

Comments
 (0)