1616#include " PWGEM/PhotonMeson/DataModel/EventTables.h"
1717#include " PWGEM/PhotonMeson/DataModel/GammaTablesRedux.h"
1818#include " PWGEM/PhotonMeson/DataModel/gammaTables.h"
19+ #include " PWGEM/PhotonMeson/Utils/DalitzBinning.h"
1920#include " PWGEM/PhotonMeson/Utils/MCUtilities.h"
2021
2122#include " Common/DataModel/EventSelection.h"
3435
3536#include < TH1.h>
3637#include < TH2.h>
38+ #include < TH3.h>
3739#include < TPDGCode.h>
3840#include < TString.h>
3941
@@ -86,6 +88,7 @@ struct AssociateMCInfoPhoton {
8688 Produces<o2::aod::EMEMCClusterMCLabels_001> ememcclustermclabels;
8789
8890 Produces<o2::aod::BinnedGenPts> binnedGenPt;
91+ Produces<o2::aod::BinnedGenDalitzs> binnedGenDalitz;
8992
9093 Configurable<float > max_eta_gen_secondary{" max_eta_gen_secondary" , 0.9 , " max eta to store generated information" };
9194 Configurable<float > margin_z_gen{" margin_z_gen" , 15 .f , " margin for Z of true photon conversion point to store generated information" };
@@ -94,6 +97,7 @@ struct AssociateMCInfoPhoton {
9497 Configurable<float > cfg_max_eta_photon{" cfg_max_eta_gamma" , 0.8 , " max eta for photons at PV" };
9598 Configurable<float > maxPt{" maxPt" , 20 .f , " max pT for BinnedGenPts table" };
9699 Configurable<float > maxY{" maxY" , 0 .9f , " max |rapidity| for BinnedGenPts table" };
100+ Configurable<bool > fillBinnedGenDalitz{" fillBinnedGenDalitz" , false , " produce binned generated Dalitz decays and QA histograms" };
97101 Configurable<bool > doStoreAllDaughters{" doStoreAllDaughters" , false , " flag to enable storing of all photon, pi0, eta, eta' and omega daughters. This will increase the dervied data size!" };
98102 Configurable<bool > useIsSelected{" useIsSelected" , true , " flag to enable the usage of isSelected from our EM event selection. Disabling this will increase the derived data size!" };
99103 Configurable<bool > useIsEOI{" useIsEOI" , true , " flag to enable the usage of the EOI table" };
@@ -157,6 +161,18 @@ struct AssociateMCInfoPhoton {
157161 genGamma.resize (hBinFinder->GetNcells (), 0 );
158162 genPi0.resize (hBinFinder->GetNcells (), 0 );
159163 genEta.resize (hBinFinder->GetNcells (), 0 );
164+
165+ if (fillBinnedGenDalitz) {
166+ namespace dalitzbinning = o2::aod::pwgem::photonmeson::utils::dalitzbinning;
167+ const AxisSpec axisPtDalitz{dalitzbinning::ptBins (), " p_{T} (GeV/c)" };
168+ const AxisSpec axisYDalitz{dalitzbinning::yBins (), " rapidity |y|" };
169+ const AxisSpec axisMee{dalitzbinning::meeBins (), " m_{ee} (GeV/c^{2})" };
170+ registry.add <TH3 >(" Generated/h3PtYMee_Pi0Dalitz" , " Generated #pi^{0} #rightarrow e^{+}e^{-}#gamma" , kTH3F , {axisPtDalitz, axisYDalitz, axisMee}, true );
171+ registry.add <TH3 >(" Generated/h3PtYMee_EtaDalitz" , " Generated #eta #rightarrow e^{+}e^{-}#gamma" , kTH3F , {axisPtDalitz, axisYDalitz, axisMee}, true );
172+ const auto ncellsDalitz = registry.get <TH3 >(HIST (" Generated/h3PtYMee_Pi0Dalitz" ))->GetNcells ();
173+ genPi0Dalitz.resize (ncellsDalitz, 0 );
174+ genEtaDalitz.resize (ncellsDalitz, 0 );
175+ }
160176 }
161177
162178 Preslice<aod::McParticles> perMcCollision = aod::mcparticle::mcCollisionId;
@@ -165,10 +181,44 @@ struct AssociateMCInfoPhoton {
165181 Preslice<aod::PHOSClusters> perCollisionPHOS = aod::skimmedcluster::collisionId;
166182 Preslice<MyEMCClusters> perCollisionEMC = aod::skimmedcluster::collisionId;
167183
168- std::vector<uint16_t > genGamma; // primary, pt, y
169- std::vector<uint16_t > genPi0; // primary, pt, y
170- std::vector<uint16_t > genEta; // primary, pt, y
184+ std::vector<uint16_t > genGamma; // primary, pt, y
185+ std::vector<uint16_t > genPi0; // primary, pt, y
186+ std::vector<uint16_t > genEta; // primary, pt, y
187+ std::vector<uint16_t > genPi0Dalitz; // primary, pt, y, mee
188+ std::vector<uint16_t > genEtaDalitz; // primary, pt, y, mee
171189
190+ // invariant mass of the e+e- pair of a Dalitz decay (daughters: gamma, e+, e-); false for any other decay
191+ template <typename TMCParticle, typename TMCParticles>
192+ bool getDalitzMee (TMCParticle const & mother, TMCParticles const & mcParticles, float & mee)
193+ {
194+ if (!mother.has_daughters ()) {
195+ return false ;
196+ }
197+ int ngamma = 0 , npos = 0 , nele = 0 ;
198+ float e = 0 .f , px = 0 .f , py = 0 .f , pz = 0 .f ;
199+ for (int id = mother.daughtersIds ()[0 ]; id <= mother.daughtersIds ()[1 ]; ++id) {
200+ if (id < 0 || id >= mcParticles.size ()) {
201+ return false ;
202+ }
203+ const auto d = mcParticles.rawIteratorAt (id);
204+ if (d.pdgCode () == PDG_t::kGamma ) {
205+ ngamma++;
206+ } else if (d.pdgCode () == PDG_t::kElectron || d.pdgCode () == PDG_t::kPositron ) {
207+ (d.pdgCode () == PDG_t::kElectron ) ? nele++ : npos++;
208+ e += d.e ();
209+ px += d.px ();
210+ py += d.py ();
211+ pz += d.pz ();
212+ } else {
213+ return false ;
214+ }
215+ }
216+ if (ngamma != 1 || npos != 1 || nele != 1 ) {
217+ return false ;
218+ }
219+ mee = std::sqrt (std::max (0 .f , e * e - px * px - py * py - pz * pz));
220+ return true ;
221+ }
172222 template <o2::soa::is_iterator TMCParticle, o2::soa::is_iterator TMCDaughter>
173223 void selectDaughtersToStore (TMCParticle& particle, int64_t mcParticleSize, TMCDaughter& daughterIter, int eventIdx, std::unordered_map<uint64_t , int >& fNewLabels , std::map<uint64_t , int >& fNewLabelsReversed , std::unordered_map<uint64_t , int >& fEventIdx , Counter& fCounter )
174224 {
@@ -361,6 +411,7 @@ struct AssociateMCInfoPhoton {
361411 std::unordered_map<uint64_t , int > fEventLabels ;
362412 Counter fCounter {.particles = 0 , .events = 0 }; // ! [0] - particle counter, [1] - event counter
363413 auto hBinFinder = registry.get <TH2 >(HIST (" Generated/h2PtY_Gamma" ));
414+ auto hBinFinderDalitz = fillBinnedGenDalitz ? registry.get <TH3 >(HIST (" Generated/h3PtYMee_Pi0Dalitz" )) : nullptr ;
364415
365416 // collision iterator from EMCal cluster
366417 auto collisionIter = collisions.begin ();
@@ -417,7 +468,8 @@ struct AssociateMCInfoPhoton {
417468 std::fill (genGamma.begin (), genGamma.end (), 0 );
418469 std::fill (genPi0.begin (), genPi0.end (), 0 );
419470 std::fill (genEta.begin (), genEta.end (), 0 );
420-
471+ std::fill (genPi0Dalitz.begin (), genPi0Dalitz.end (), 0 );
472+ std::fill (genEtaDalitz.begin (), genEtaDalitz.end (), 0 );
421473 mcCollisionIter.setCursor (collision.mcCollisionId ());
422474 // store mc particles
423475 auto groupedMcParticles = mcParticles.sliceBy (perMcCollision, mcCollisionIter.globalIndex ());
@@ -440,6 +492,10 @@ struct AssociateMCInfoPhoton {
440492 genGamma[binNumber]++;
441493 break ;
442494 case PDG_t::kPi0 :
495+ if (float meeDalitz = 0 .f ; fillBinnedGenDalitz && getDalitzMee (mcParticle, mcParticles, meeDalitz)) {
496+ registry.fill (HIST (" Generated/h3PtYMee_Pi0Dalitz" ), mcParticle.pt (), std::fabs (mcParticle.y ()), meeDalitz);
497+ genPi0Dalitz[hBinFinderDalitz->FindBin (mcParticle.pt (), std::fabs (mcParticle.y ()), meeDalitz)]++;
498+ }
443499 if (requireGammaGammaDecay && !isGammaGammaDecay (mcParticle, mcParticles)) {
444500 continue ;
445501 }
@@ -450,6 +506,10 @@ struct AssociateMCInfoPhoton {
450506 }
451507 break ;
452508 case Pdg::kEta :
509+ if (float meeDalitz = 0 .f ; fillBinnedGenDalitz && getDalitzMee (mcParticle, mcParticles, meeDalitz)) {
510+ registry.fill (HIST (" Generated/h3PtYMee_EtaDalitz" ), mcParticle.pt (), std::fabs (mcParticle.y ()), meeDalitz);
511+ genEtaDalitz[hBinFinderDalitz->FindBin (mcParticle.pt (), std::fabs (mcParticle.y ()), meeDalitz)]++;
512+ }
453513 if (requireGammaGammaDecay && !isGammaGammaDecay (mcParticle, mcParticles)) {
454514 continue ;
455515 }
@@ -474,6 +534,9 @@ struct AssociateMCInfoPhoton {
474534 fEventLabels [mcCollisionIter.globalIndex ()] = fCounter .events ;
475535 fCounter .events ++;
476536 binnedGenPt (genGamma, genPi0, genEta);
537+ if (fillBinnedGenDalitz) {
538+ binnedGenDalitz (genPi0Dalitz, genEtaDalitz);
539+ }
477540 }
478541
479542 // LOGF(info, "collision.globalIndex() = %d , mceventlabels.lastIndex() = %d", collision.globalIndex(), mceventlabels.lastIndex());
0 commit comments