Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions PWGEM/PhotonMeson/DataModel/gammaTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ DECLARE_SOA_TABLE(BinnedGenPts, "AOD", "BINNEDGENPT", // To be joined with EMMCE
);
using BinnedGenPt = BinnedGenPts::iterator;

namespace emmcbinnedgendalitz
{
DECLARE_SOA_COLUMN(GeneratedPi0Dalitz, generatedPi0Dalitz, std::vector<uint16_t>); //! pi0 -> e+e-gamma binned generated data (pT, |y|, m_ee)
DECLARE_SOA_COLUMN(GeneratedEtaDalitz, generatedEtaDalitz, std::vector<uint16_t>); //! eta -> e+e-gamma binned generated data (pT, |y|, m_ee)
} // namespace emmcbinnedgendalitz

DECLARE_SOA_TABLE(BinnedGenDalitzs, "AOD", "BINNEDGENDAL", // To be joined with EMMCEvents table at analysis level.
emmcbinnedgendalitz::GeneratedPi0Dalitz,
emmcbinnedgendalitz::GeneratedEtaDalitz);
using BinnedGenDalitz = BinnedGenDalitzs::iterator;

// DECLARE_SOA_TABLE(BinnedGenPtAccs, "AOD", "BINNEDGENPTACC", // To be joined with EMMCEvents table at analysis level.
// emmcbinnedgen::GeneratedPi0_Acc_gg,
// emmcbinnedgen::GeneratedPi0_Acc_eeg,
Expand Down
71 changes: 67 additions & 4 deletions PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "PWGEM/PhotonMeson/DataModel/EventTables.h"
#include "PWGEM/PhotonMeson/DataModel/GammaTablesRedux.h"
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"
#include "PWGEM/PhotonMeson/Utils/DalitzBinning.h"
#include "PWGEM/PhotonMeson/Utils/MCUtilities.h"

#include "Common/DataModel/EventSelection.h"
Expand All @@ -34,6 +35,7 @@

#include <TH1.h>
#include <TH2.h>
#include <TH3.h>
#include <TPDGCode.h>
#include <TString.h>

Expand Down Expand Up @@ -86,6 +88,7 @@ struct AssociateMCInfoPhoton {
Produces<o2::aod::EMEMCClusterMCLabels_001> ememcclustermclabels;

Produces<o2::aod::BinnedGenPts> binnedGenPt;
Produces<o2::aod::BinnedGenDalitzs> binnedGenDalitz;

Configurable<float> max_eta_gen_secondary{"max_eta_gen_secondary", 0.9, "max eta to store generated information"};
Configurable<float> margin_z_gen{"margin_z_gen", 15.f, "margin for Z of true photon conversion point to store generated information"};
Expand All @@ -94,6 +97,7 @@ struct AssociateMCInfoPhoton {
Configurable<float> cfg_max_eta_photon{"cfg_max_eta_gamma", 0.8, "max eta for photons at PV"};
Configurable<float> maxPt{"maxPt", 20.f, "max pT for BinnedGenPts table"};
Configurable<float> maxY{"maxY", 0.9f, "max |rapidity| for BinnedGenPts table"};
Configurable<bool> fillBinnedGenDalitz{"fillBinnedGenDalitz", false, "produce binned generated Dalitz decays and QA histograms"};
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!"};
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!"};
Configurable<bool> useIsEOI{"useIsEOI", true, "flag to enable the usage of the EOI table"};
Expand Down Expand Up @@ -157,6 +161,18 @@ struct AssociateMCInfoPhoton {
genGamma.resize(hBinFinder->GetNcells(), 0);
genPi0.resize(hBinFinder->GetNcells(), 0);
genEta.resize(hBinFinder->GetNcells(), 0);

if (fillBinnedGenDalitz) {
namespace dalitzbinning = o2::aod::pwgem::photonmeson::utils::dalitzbinning;
const AxisSpec axisPtDalitz{dalitzbinning::ptBins(), "p_{T} (GeV/c)"};
const AxisSpec axisYDalitz{dalitzbinning::yBins(), "rapidity |y|"};
const AxisSpec axisMee{dalitzbinning::meeBins(), "m_{ee} (GeV/c^{2})"};
registry.add<TH3>("Generated/h3PtYMee_Pi0Dalitz", "Generated #pi^{0} #rightarrow e^{+}e^{-}#gamma", kTH3F, {axisPtDalitz, axisYDalitz, axisMee}, true);
registry.add<TH3>("Generated/h3PtYMee_EtaDalitz", "Generated #eta #rightarrow e^{+}e^{-}#gamma", kTH3F, {axisPtDalitz, axisYDalitz, axisMee}, true);
const auto ncellsDalitz = registry.get<TH3>(HIST("Generated/h3PtYMee_Pi0Dalitz"))->GetNcells();
genPi0Dalitz.resize(ncellsDalitz, 0);
genEtaDalitz.resize(ncellsDalitz, 0);
}
}

Preslice<aod::McParticles> perMcCollision = aod::mcparticle::mcCollisionId;
Expand All @@ -165,10 +181,44 @@ struct AssociateMCInfoPhoton {
Preslice<aod::PHOSClusters> perCollisionPHOS = aod::skimmedcluster::collisionId;
Preslice<MyEMCClusters> perCollisionEMC = aod::skimmedcluster::collisionId;

std::vector<uint16_t> genGamma; // primary, pt, y
std::vector<uint16_t> genPi0; // primary, pt, y
std::vector<uint16_t> genEta; // primary, pt, y
std::vector<uint16_t> genGamma; // primary, pt, y
std::vector<uint16_t> genPi0; // primary, pt, y
std::vector<uint16_t> genEta; // primary, pt, y
std::vector<uint16_t> genPi0Dalitz; // primary, pt, y, mee
std::vector<uint16_t> genEtaDalitz; // primary, pt, y, mee

// invariant mass of the e+e- pair of a Dalitz decay (daughters: gamma, e+, e-); false for any other decay
Comment thread
mhemmer-cern marked this conversation as resolved.
Resolved
template <typename TMCParticle, typename TMCParticles>
bool getDalitzMee(TMCParticle const& mother, TMCParticles const& mcParticles, float& mee)
{
if (!mother.has_daughters()) {
return false;
}
int ngamma = 0, npos = 0, nele = 0;
float e = 0.f, px = 0.f, py = 0.f, pz = 0.f;
for (int id = mother.daughtersIds()[0]; id <= mother.daughtersIds()[1]; ++id) {
if (id < 0 || id >= mcParticles.size()) {
return false;
}
const auto d = mcParticles.rawIteratorAt(id);
if (d.pdgCode() == PDG_t::kGamma) {
ngamma++;
} else if (d.pdgCode() == PDG_t::kElectron || d.pdgCode() == PDG_t::kPositron) {
(d.pdgCode() == PDG_t::kElectron) ? nele++ : npos++;
e += d.e();
px += d.px();
py += d.py();
pz += d.pz();
} else {
return false;
}
}
if (ngamma != 1 || npos != 1 || nele != 1) {
return false;
}
mee = std::sqrt(std::max(0.f, e * e - px * px - py * py - pz * pz));
return true;
}
template <o2::soa::is_iterator TMCParticle, o2::soa::is_iterator TMCDaughter>
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)
{
Expand Down Expand Up @@ -361,6 +411,7 @@ struct AssociateMCInfoPhoton {
std::unordered_map<uint64_t, int> fEventLabels;
Counter fCounter{.particles = 0, .events = 0}; //! [0] - particle counter, [1] - event counter
auto hBinFinder = registry.get<TH2>(HIST("Generated/h2PtY_Gamma"));
auto hBinFinderDalitz = fillBinnedGenDalitz ? registry.get<TH3>(HIST("Generated/h3PtYMee_Pi0Dalitz")) : nullptr;

// collision iterator from EMCal cluster
auto collisionIter = collisions.begin();
Expand Down Expand Up @@ -417,7 +468,8 @@ struct AssociateMCInfoPhoton {
std::fill(genGamma.begin(), genGamma.end(), 0);
std::fill(genPi0.begin(), genPi0.end(), 0);
std::fill(genEta.begin(), genEta.end(), 0);

std::fill(genPi0Dalitz.begin(), genPi0Dalitz.end(), 0);
std::fill(genEtaDalitz.begin(), genEtaDalitz.end(), 0);
mcCollisionIter.setCursor(collision.mcCollisionId());
// store mc particles
auto groupedMcParticles = mcParticles.sliceBy(perMcCollision, mcCollisionIter.globalIndex());
Expand All @@ -440,6 +492,10 @@ struct AssociateMCInfoPhoton {
genGamma[binNumber]++;
break;
case PDG_t::kPi0:
if (float meeDalitz = 0.f; fillBinnedGenDalitz && getDalitzMee(mcParticle, mcParticles, meeDalitz)) {
registry.fill(HIST("Generated/h3PtYMee_Pi0Dalitz"), mcParticle.pt(), std::fabs(mcParticle.y()), meeDalitz);
genPi0Dalitz[hBinFinderDalitz->FindBin(mcParticle.pt(), std::fabs(mcParticle.y()), meeDalitz)]++;
}
if (requireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles)) {
continue;
}
Expand All @@ -450,6 +506,10 @@ struct AssociateMCInfoPhoton {
}
break;
case Pdg::kEta:
if (float meeDalitz = 0.f; fillBinnedGenDalitz && getDalitzMee(mcParticle, mcParticles, meeDalitz)) {
registry.fill(HIST("Generated/h3PtYMee_EtaDalitz"), mcParticle.pt(), std::fabs(mcParticle.y()), meeDalitz);
genEtaDalitz[hBinFinderDalitz->FindBin(mcParticle.pt(), std::fabs(mcParticle.y()), meeDalitz)]++;
}
if (requireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles)) {
continue;
}
Expand All @@ -474,6 +534,9 @@ struct AssociateMCInfoPhoton {
fEventLabels[mcCollisionIter.globalIndex()] = fCounter.events;
fCounter.events++;
binnedGenPt(genGamma, genPi0, genEta);
if (fillBinnedGenDalitz) {
binnedGenDalitz(genPi0Dalitz, genEtaDalitz);
}
}

// LOGF(info, "collision.globalIndex() = %d , mceventlabels.lastIndex() = %d", collision.globalIndex(), mceventlabels.lastIndex());
Expand Down
5 changes: 5 additions & 0 deletions PWGEM/PhotonMeson/Tasks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ o2physics_add_dpl_workflow(pi0eta-to-gammagamma-pcmdalitzee
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore O2Physics::MLCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(pi0eta-meson-dalitz-form-factor
SOURCES Pi0EtaMesonDalitzFormFactor.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore O2Physics::MLCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(pi0eta-to-gammagamma-emcemc
SOURCES Pi0EtaToGammaGammaEMCEMC.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore
Expand Down
Loading
Loading