Skip to content

Commit 0abf31d

Browse files
MC Gen Event mixing
1 parent 594c432 commit 0abf31d

2 files changed

Lines changed: 73 additions & 15 deletions

File tree

PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ struct HfCorrelatorDstarHadrons {
196196

197197
ConfigurableAxis binsMultiplicity{"binsMultiplicity", {VARIABLE_WIDTH, 0.0f, 2000.0f, 6000.0f, 100000.0f}, "Mixing bins - multiplicity"};
198198
ConfigurableAxis binsZVtx{"binsZVtx", {VARIABLE_WIDTH, -10.0f, -2.5f, 2.5f, 10.0f}, "Mixing bins - z-vertex"};
199+
Configurable<int> numberEventsMixed{"numberEventsMixed", 5, "number of events to mix"};
199200
BinningType binningScheme{{binsZVtx, binsMultiplicity}, true};
200201
// Eta Phi Axes
201202
ConfigurableAxis axisEta{"axisEta", {16, -1.0, 1.0}, "Eta Axis"};
@@ -209,7 +210,7 @@ struct HfCorrelatorDstarHadrons {
209210

210211
void init(InitContext&)
211212
{
212-
std::array<bool, 3> processes = {doprocessDataSameEvent, doprocessDataWithMixedEvent, doprocessSeMcGen};
213+
std::array<bool, 4> processes = {doprocessDataSameEvent, doprocessDataWithMixedEvent, doprocessSeMcGen, doprocessMcGenME};
213214
if (std::accumulate(processes.begin(), processes.end(), 0) != 1) {
214215
LOGP(fatal, "One and only one process function must be enabled at a time.");
215216
}
@@ -504,6 +505,59 @@ struct HfCorrelatorDstarHadrons {
504505
} // McCollision loop
505506
} // processSeMcGen
506507
PROCESS_SWITCH(HfCorrelatorDstarHadrons, processSeMcGen, "Process MC Gen same-event mode", false);
508+
509+
/// D*-Hadron correlation pair builder at MC Gen mixed-event level
510+
void processMcGenME(McCollisionsWithMult const& collisions,
511+
CandDstarMcGen const& mcParticles)
512+
{
513+
BinningTypeMcGen const corrBinningMcGen{{binsZVtx, binsMultiplicity}, true};
514+
auto tracksTuple = std::make_tuple(mcParticles, mcParticles);
515+
Pair<McCollisionsWithMult, CandDstarMcGen, CandDstarMcGen, BinningTypeMcGen> const pairMcGen{corrBinningMcGen, numberEventsMixed, -1, collisions, tracksTuple, &cache};
516+
517+
for (const auto& [c1, tracks1, c2, tracks2] : pairMcGen) {
518+
int const poolBin = corrBinningMcGen.getBin(std::make_tuple(c1.posZ(), c1.multMCFT0A()));
519+
for (const auto& [particle, particleAssoc] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) {
520+
if (std::abs(particle.flagMcMatchGen()) != hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) {
521+
continue;
522+
}
523+
auto yDstar = RecoDecay::y(particle.pVector(), constants::physics::MassDStar);
524+
if (std::abs(yDstar) > yAbsDstarMax) {
525+
continue;
526+
}
527+
if (std::abs(particleAssoc.eta()) > etaAbsAssoTrackMax ||
528+
particleAssoc.pt() < ptAssoTrackMin ||
529+
particleAssoc.pt() > ptAssoTrackMax) {
530+
continue;
531+
}
532+
if (!particleAssoc.isPhysicalPrimary()) {
533+
continue;
534+
}
535+
// select only charged hadrons: e, mu, pi, K, p
536+
if ((std::abs(particleAssoc.pdgCode()) != kElectron) &&
537+
(std::abs(particleAssoc.pdgCode()) != kMuonMinus) &&
538+
(std::abs(particleAssoc.pdgCode()) != kPiPlus) &&
539+
(std::abs(particleAssoc.pdgCode()) != kKPlus) &&
540+
(std::abs(particleAssoc.pdgCode()) != kProton)) {
541+
continue;
542+
}
543+
bool const isDstarPrompt = particle.originMcGen() == RecoDecay::OriginType::Prompt;
544+
// use full mcParticles (not sliced) since particles come from different collisions in ME
545+
int const trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true);
546+
547+
rowsDstarHadronMcGenPair(particle.phi(),
548+
particle.eta(),
549+
particle.pt(),
550+
particleAssoc.phi(),
551+
particleAssoc.eta(),
552+
particleAssoc.pt(),
553+
poolBin);
554+
rowsDstarHadronGenInfo(isDstarPrompt,
555+
particleAssoc.isPhysicalPrimary(),
556+
trackOrigin);
557+
} // associated particle loop
558+
} // ME pair loop
559+
} // processMcGenME
560+
PROCESS_SWITCH(HfCorrelatorDstarHadrons, processMcGenME, "Process MC Gen mixed-event mode", false);
507561
};
508562

509563
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,22 @@ struct HfTaskCorrelationDstarHadrons {
131131
AxisSpec const axisSpecPtHadron = {ptHadronBinsEdges};
132132
AxisSpec const axisSpecPoolBin = {9, 0., 9.};
133133

134-
registry.add("hCorrel2DVsPtSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
135-
registry.add("hCorrel2DPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2D, {axisSpecDeltaPhi, axisSpecDeltaEta}}, true);
136-
registry.add("hDeltaEtaPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1D, {axisSpecDeltaEta}}, true);
137-
registry.add("hDeltaPhiPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1D, {axisSpecDeltaPhi}}, true);
138-
registry.add("hCorrel2DVsPtSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
139-
registry.add("hCorrel2DPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2D, {axisSpecDeltaPhi, axisSpecDeltaEta}}, true);
140-
registry.add("hDeltaEtaPtIntSidebands", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1D, {axisSpecDeltaEta}}, true);
141-
registry.add("hDeltaPhiPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1D, {axisSpecDeltaPhi}}, true);
134+
if (doprocessData) {
135+
registry.add("hCorrel2DVsPtSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
136+
registry.add("hCorrel2DPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2D, {axisSpecDeltaPhi, axisSpecDeltaEta}}, true);
137+
registry.add("hDeltaEtaPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1D, {axisSpecDeltaEta}}, true);
138+
registry.add("hDeltaPhiPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1D, {axisSpecDeltaPhi}}, true);
139+
registry.add("hCorrel2DVsPtSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
140+
registry.add("hCorrel2DPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2D, {axisSpecDeltaPhi, axisSpecDeltaEta}}, true);
141+
registry.add("hDeltaEtaPtIntSidebands", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1D, {axisSpecDeltaEta}}, true);
142+
registry.add("hDeltaPhiPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1D, {axisSpecDeltaPhi}}, true);
143+
}
142144
// MC Gen histograms
143-
registry.add("hCorrel2DVsPtMcGen", stringDHadron + "MC Gen;" + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
144-
registry.add("hCorrel2DVsPtMcGenPrompt", stringDHadron + "MC Gen Prompt;" + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
145-
registry.add("hCorrel2DVsPtMcGenNonPrompt", stringDHadron + "MC Gen NonPrompt;" + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
145+
if (doprocessMcGen) {
146+
registry.add("hCorrel2DVsPtMcGen", stringDHadron + "MC Gen;" + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
147+
registry.add("hCorrel2DVsPtMcGenPrompt", stringDHadron + "MC Gen Prompt;" + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
148+
registry.add("hCorrel2DVsPtMcGenNonPrompt", stringDHadron + "MC Gen NonPrompt;" + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {axisSpecDeltaPhi, axisSpecDeltaEta, axisSpecPtDstar, axisSpecPtHadron, axisSpecPoolBin}}, true);
149+
}
146150

147151
if (applyEfficiency && useCcdbEfficiency) {
148152
ccdbApi.init(ccdbUrl);
@@ -264,8 +268,8 @@ struct HfTaskCorrelationDstarHadrons {
264268
}
265269
PROCESS_SWITCH(HfTaskCorrelationDstarHadrons, processData, " process data only", true);
266270

267-
/// Fill THnSparse histograms with D*-hadron pairs at MC Gen same-event level
268-
void processSeMcGen(soa::Join<aod::DstarHadronMcGenPair, aod::DstarHadronGenInfo> const& pairsMcGen)
271+
/// Fill THnSparse histograms with D*-hadron pairs at MC Gen level (both SE and ME)
272+
void processMcGen(soa::Join<aod::DstarHadronMcGenPair, aod::DstarHadronGenInfo> const& pairsMcGen)
269273
{
270274
for (const auto& pair : pairsMcGen) {
271275
float const deltaPhi = pair.deltaPhi();
@@ -283,7 +287,7 @@ struct HfTaskCorrelationDstarHadrons {
283287
}
284288
}
285289
}
286-
PROCESS_SWITCH(HfTaskCorrelationDstarHadrons, processSeMcGen, "Process MC Gen same-event", false);
290+
PROCESS_SWITCH(HfTaskCorrelationDstarHadrons, processMcGen, "Process MC Gen", false);
287291
};
288292

289293
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)