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"
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;
5758using MyCollisionsMC = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels, aod::EMEvSels>;
5859using TracksMC = soa::Join<aod::TracksIU, aod::McTrackLabels>;
5960using 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
6263struct 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}
0 commit comments