Skip to content

Commit 985f17a

Browse files
committed
Removing processMCMatched in jetCorrelationD0
1 parent 84d4b7d commit 985f17a

File tree

1 file changed

+60
-140
lines changed

1 file changed

+60
-140
lines changed

PWGJE/Tasks/jetCorrelationD0.cxx

Lines changed: 60 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ using namespace o2::framework::expressions;
4141

4242
namespace o2::aod
4343
{
44-
namespace d0s
44+
namespace d0Info
4545
{
4646
// D0
4747
DECLARE_SOA_COLUMN(D0PromptBDT, d0PromptBDT, float);
@@ -56,85 +56,89 @@ DECLARE_SOA_COLUMN(D0MD, d0MD, float);
5656
DECLARE_SOA_COLUMN(D0PtD, d0PtD, float);
5757
DECLARE_SOA_COLUMN(D0EtaD, d0EtaD, float);
5858
DECLARE_SOA_COLUMN(D0PhiD, d0PhiD, float);
59-
DECLARE_SOA_COLUMN(D0CollisionIdx, d0CollisionIdx, int);
6059
DECLARE_SOA_COLUMN(D0Reflection, d0Reflection, int);
61-
} // namespace d0s
60+
} // namespace d0Info
6261

63-
namespace jets
62+
namespace jetInfo
6463
{
6564
// Jet
6665
DECLARE_SOA_COLUMN(JetPt, jetPt, float);
6766
DECLARE_SOA_COLUMN(JetEta, jetEta, float);
6867
DECLARE_SOA_COLUMN(JetPhi, jetPhi, float);
69-
DECLARE_SOA_COLUMN(CollID, jetCollID, int);
7068
// D0-jet
7169
DECLARE_SOA_COLUMN(D0JetDeltaPhi, d0JetDeltaPhi, float);
72-
} // namespace jets
70+
} // namespace jetInfo
7371

7472
DECLARE_SOA_TABLE(CollisionTables, "AOD", "COLLISIONINFOTABLE",
7573
o2::soa::Index<>,
7674
collision::PosZ);
7775

76+
namespace indexColumns
77+
{
7878
DECLARE_SOA_INDEX_COLUMN(CollisionTable, collisionTable);
79+
} // namespace o2::indexColumns
7980

8081
DECLARE_SOA_TABLE(D0DataTables, "AOD", "D0DATATABLE",
8182
o2::soa::Index<>,
82-
CollisionTableId,
83-
d0s::D0PromptBDT,
84-
d0s::D0NonPromptBDT,
85-
d0s::D0BkgBDT,
86-
d0s::D0M,
87-
d0s::D0Pt,
88-
d0s::D0Eta,
89-
d0s::D0Phi);
83+
indexColumns::CollisionTableId,
84+
d0Info::D0PromptBDT,
85+
d0Info::D0NonPromptBDT,
86+
d0Info::D0BkgBDT,
87+
d0Info::D0M,
88+
d0Info::D0Pt,
89+
d0Info::D0Eta,
90+
d0Info::D0Phi);
9091

9192
DECLARE_SOA_TABLE(D0McPTables, "AOD", "D0MCPARTICLELEVELTABLE",
9293
o2::soa::Index<>,
93-
CollisionTableId,
94-
d0s::D0McOrigin,
95-
d0s::D0Pt,
96-
d0s::D0Eta,
97-
d0s::D0Phi);
94+
indexColumns::CollisionTableId,
95+
d0Info::D0McOrigin,
96+
d0Info::D0Pt,
97+
d0Info::D0Eta,
98+
d0Info::D0Phi);
9899

99100
DECLARE_SOA_TABLE(D0McMatchedTables, "AOD", "D0MCMATCHEDTABLE",
100101
o2::soa::Index<>,
101-
CollisionTableId,
102-
d0s::D0Pt,
103-
d0s::D0Eta,
104-
d0s::D0Phi,
105-
d0s::D0McOrigin,
106-
d0s::D0Reflection);
107-
108-
DECLARE_SOA_INDEX_COLUMN(D0DataTable, d0Data);
109-
DECLARE_SOA_INDEX_COLUMN(D0McPTable, d0MCP);
110-
DECLARE_SOA_INDEX_COLUMN(D0McMatchedTable, d0MCMatched);
102+
indexColumns::CollisionTableId,
103+
d0Info::D0Pt,
104+
d0Info::D0Eta,
105+
d0Info::D0Phi,
106+
d0Info::D0McOrigin,
107+
d0Info::D0Reflection);
108+
109+
namespace indexColumns
110+
{
111+
DECLARE_SOA_INDEX_COLUMN(D0DataTable, d0Data);
112+
DECLARE_SOA_INDEX_COLUMN(D0McPTable, d0MCP);
113+
DECLARE_SOA_INDEX_COLUMN(D0McMatchedTable, d0MCMatched);
114+
} // namespace o2::indexColumns
111115

112116
DECLARE_SOA_TABLE_STAGED(JetDataTables, "JETDATATABLE",
113117
o2::soa::Index<>,
114-
CollisionTableId,
115-
D0DataTableId,
116-
jets::JetPt,
117-
jets::JetEta,
118-
jets::JetPhi,
119-
jets::D0JetDeltaPhi);
118+
indexColumns::CollisionTableId,
119+
indexColumns::D0DataTableId,
120+
jetInfo::JetPt,
121+
jetInfo::JetEta,
122+
jetInfo::JetPhi,
123+
jetInfo::D0JetDeltaPhi);
120124

121125
DECLARE_SOA_TABLE_STAGED(JetMCPTables, "JETMCPARTICLELEVELTABLE",
122126
o2::soa::Index<>,
123-
CollisionTableId,
124-
D0McPTableId,
125-
jets::JetPt,
126-
jets::JetEta,
127-
jets::JetPhi,
128-
jets::D0JetDeltaPhi);
127+
indexColumns::CollisionTableId,
128+
indexColumns::D0McPTableId,
129+
jetInfo::JetPt,
130+
jetInfo::JetEta,
131+
jetInfo::JetPhi,
132+
jetInfo::D0JetDeltaPhi);
129133

130134
DECLARE_SOA_TABLE_STAGED(JetMCMatchedTables, "JETMCMATCHEDTABLE",
131135
o2::soa::Index<>,
132-
CollisionTableId,
133-
D0McMatchedTableId,
134-
jets::JetPt,
135-
jets::JetEta,
136-
jets::JetPhi,
137-
jets::D0JetDeltaPhi);
136+
indexColumns::CollisionTableId,
137+
indexColumns::D0McMatchedTableId,
138+
jetInfo::JetPt,
139+
jetInfo::JetEta,
140+
jetInfo::JetPhi,
141+
jetInfo::D0JetDeltaPhi);
138142
} // namespace o2::aod
139143

140144
struct JetCorrelationD0 {
@@ -163,12 +167,10 @@ struct JetCorrelationD0 {
163167

164168
// Filters
165169
Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut);
166-
167-
// Histogram registry: an object to hold your histograms
168-
HistogramRegistry registry{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
169-
170170
std::vector<int> eventSelectionBits;
171171

172+
// Histograms
173+
HistogramRegistry registry{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
172174
template <typename T, typename U>
173175
void fillD0Histograms(T const& d0, U const& scores)
174176
{
@@ -208,15 +210,8 @@ struct JetCorrelationD0 {
208210
void fillMatchedHistograms(T const& jetsBase, U const&, float weight = 1.0, float rho = 0.0)
209211
{
210212
for (const auto& jetBase : jetsBase) {
211-
float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); // calculated from pythia event weights
212-
if (jetBase.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { // reject events that are too hard / soft
213-
return;
214-
}
215213
if (jetBase.has_matchedJetGeo()) { // geometric matching
216214
for (auto& jetTag : jetBase.template matchedJetGeo_as<std::decay_t<U>>()) {
217-
if (jetTag.pt() > pTHatMaxMCP * pTHat) { // cuts overly hard jets from jettag (mcp) sample
218-
continue;
219-
}
220215
registry.fill(HIST("hPtMatched"), jetBase.pt() - (rho * jetBase.area()), jetTag.pt(), weight);
221216
registry.fill(HIST("hPtMatched1d"), jetTag.pt(), weight);
222217
registry.fill(HIST("hPhiMatched"), jetBase.phi(), jetTag.phi(), weight);
@@ -279,7 +274,7 @@ struct JetCorrelationD0 {
279274
for (const auto& d0Candidate : d0Candidates) {
280275
const auto scores = d0Candidate.mlScores();
281276
if (d0Candidate.pt() < d0PtCutMin) {
282-
return;
277+
continue;
283278
}
284279
fillD0Histograms(d0Candidate, scores);
285280
tableD0(tableCollision.lastIndex(),
@@ -292,11 +287,11 @@ struct JetCorrelationD0 {
292287
d0Candidate.phi());
293288
for (const auto& jet : jets) {
294289
if (jet.pt() < jetPtCutMin) {
295-
return;
290+
continue;
296291
}
297292
float dphi = RecoDecay::constrainAngle(jet.phi() - d0Candidate.phi());
298293
if (abs(dphi - M_PI) > (M_PI / 2)) {
299-
return;
294+
continue;
300295
}
301296
fillJetHistograms(jet, dphi);
302297
tableJet(tableCollision.lastIndex(),
@@ -315,11 +310,12 @@ struct JetCorrelationD0 {
315310
soa::Filtered<soa::Join<aod::ChargedMCParticleLevelJets, aod::ChargedMCParticleLevelJetConstituents>> const& jets)
316311
{
317312
// applyCollisionSelections(collision, eventSelectionBits);
313+
// Need to select on pz
318314
tableCollision(collision.posZ());
319315

320316
for (const auto& d0MCPCandidate : d0MCPCandidates) {
321317
if (d0MCPCandidate.pt() < d0PtCutMin) {
322-
return;
318+
continue;
323319
}
324320
tableD0MCParticle(tableCollision.lastIndex(),
325321
d0MCPCandidate.originMcGen(),
@@ -329,11 +325,11 @@ struct JetCorrelationD0 {
329325

330326
for (const auto& jet : jets) {
331327
if (jet.pt() < jetPtCutMin) {
332-
return;
328+
continue;
333329
}
334330
float dphi = RecoDecay::constrainAngle(jet.phi() - d0MCPCandidate.phi());
335331
if (abs(dphi - M_PI) > (M_PI / 2)) {
336-
return;
332+
continue;
337333
}
338334
fillJetHistograms(jet, dphi);
339335
tableJetMCParticle(tableCollision.lastIndex(),
@@ -346,82 +342,6 @@ struct JetCorrelationD0 {
346342
}
347343
}
348344
PROCESS_SWITCH(JetCorrelationD0, processMCParticle, "process MC Particle jets", false);
349-
350-
void processMCMatched(soa::Filtered<soa::Join<aod::JetCollisions, aod::JMcCollisionLbs>>::iterator const& collision,
351-
aod::JetMcCollisions const&,
352-
aod::CandidatesD0MCP const& d0MCPCandidates,
353-
aod::CandidatesD0MCD const& d0MCDCandidates,
354-
TracksSelQuality const&,
355-
soa::Join<aod::McParticles, aod::HfCand2ProngMcGen> const& mcParticles,
356-
soa::Filtered<soa::Join<aod::ChargedMCParticleLevelJets, aod::ChargedMCParticleLevelJetConstituents, aod::ChargedMCDetectorLevelJetsMatchedToChargedMCParticleLevelJets>> const& mcpJets,
357-
soa::Filtered<soa::Join<aod::ChargedMCDetectorLevelJets, aod::ChargedMCDetectorLevelJetConstituents, aod::ChargedMCParticleLevelJetsMatchedToChargedMCDetectorLevelJets>> const& mcdJets)
358-
{
359-
// applyCollisionSelections(collision, eventSelectionBits);
360-
361-
const auto CollIdx = collision.mcCollisionId();
362-
363-
for (const auto& d0MCDCandidate : d0MCDCandidates) {
364-
365-
// D or D bar?
366-
int matchedFrom = 0;
367-
int selectedAs = 0;
368-
int reflection = 0;
369-
constexpr int decayChannel = o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK;
370-
if (d0MCDCandidate.flagMcMatchRec() == decayChannel) {
371-
matchedFrom = 1;
372-
} else if (d0MCDCandidate.flagMcMatchRec() == -decayChannel) {
373-
matchedFrom = -1;
374-
}
375-
if (d0MCDCandidate.candidateSelFlag() & BIT(0)) {
376-
selectedAs = 1;
377-
} else if (d0MCDCandidate.candidateSelFlag() & BIT(1)) {
378-
selectedAs = -1;
379-
}
380-
if (matchedFrom != 0 && selectedAs != 0) {
381-
reflection = (matchedFrom == selectedAs) ? 1 : -1;
382-
}
383-
384-
// Skip non D0 / D0 bars
385-
if (std::abs(d0MCDCandidate.flagMcMatchRec()) != decayChannel) {
386-
continue; // unmatched detector-level D0 → skip
387-
}
388-
auto trackPos = d0MCDCandidate.template prong0_as<TracksSelQuality>(); // positive daughter
389-
auto trackNeg = d0MCDCandidate.template prong1_as<TracksSelQuality>(); // negative daughter
390-
391-
auto indexMother = RecoDecay::getMother(mcParticles,
392-
trackPos.template mcParticle_as<soa::Join<aod::McParticles, aod::HfCand2ProngMcGen>>(),
393-
o2::constants::physics::Pdg::kD0,
394-
true);
395-
auto particleMother = mcParticles.rawIteratorAt(indexMother); // This is the particle level D0 corresponding to a matched D0 index
396-
LOGF(info, "trackPos pt %.2f, eta %.2f, phi %.2f, trackNeg pt %.2f, eta %.2f, phi %.2f, indexMother %.2f, particleMother pt %.2f eta %.2f phi %.2f", trackPos.pt(), trackPos.eta(), trackPos.phi(), trackNeg.pt(), trackNeg.eta(), trackNeg.phi(), indexMother, particleMother.pt(), particleMother.eta(), particleMother.phi());
397-
398-
// Loop over particle level that have been matched
399-
for (const auto& particleMother : d0MCPCandidates) {
400-
tableD0MCMatched(CollIdx,
401-
particleMother.pt(),
402-
particleMother.eta(),
403-
particleMother.phi(),
404-
particleMother.originMcGen(),
405-
reflection);
406-
LOGF(info, "Collision ID %i, D0 pt %.2f, D0 eta %.2f, D0 phi %.2f, MCP origin %hhd, Reflection %i", CollIdx, particleMother.pt(), particleMother.eta(), particleMother.phi(), particleMother.originMcGen(), reflection);
407-
408-
// Jet matching
409-
fillMatchedHistograms(mcdJets, mcpJets); // Do I need to include pthat cuts in loop rather than this function to actually do jet matching?
410-
411-
for (const auto& mcpJet : mcpJets) {
412-
float dphi = RecoDecay::constrainAngle(mcpJet.phi() - d0MCDCandidate.phi());
413-
fillJetHistograms(mcpJet, dphi);
414-
tableJetMCMatched(tableD0MCMatched.lastIndex(),
415-
CollIdx,
416-
mcpJet.pt(),
417-
mcpJet.eta(),
418-
mcpJet.phi(),
419-
dphi);
420-
}
421-
}
422-
}
423-
}
424-
PROCESS_SWITCH(JetCorrelationD0, processMCMatched, "process MC Matched jets", false);
425345
};
426346

427347
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)