Skip to content

Commit c9ba366

Browse files
authored
[PWGJE] MC fixes for jetCorrelationD0 task (#16818)
1 parent e92a9e0 commit c9ba366

1 file changed

Lines changed: 65 additions & 29 deletions

File tree

PWGJE/Tasks/jetCorrelationD0.cxx

Lines changed: 65 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,14 @@
2020

2121
#include "Common/Core/RecoDecay.h"
2222

23-
#include <CommonConstants/MathConstants.h>
24-
#include <Framework/ASoA.h>
2523
#include <Framework/AnalysisDataModel.h>
26-
#include <Framework/AnalysisHelpers.h>
2724
#include <Framework/AnalysisTask.h>
28-
#include <Framework/Configurable.h>
2925
#include <Framework/HistogramRegistry.h>
30-
#include <Framework/HistogramSpec.h>
31-
#include <Framework/InitContext.h>
32-
#include <Framework/OutputObjHeader.h>
26+
#include <Framework/Logger.h>
3327
#include <Framework/runDataProcessing.h>
3428

35-
#include <cstdlib>
3629
#include <string>
30+
#include <type_traits>
3731
#include <vector>
3832

3933
#include <math.h>
@@ -84,7 +78,8 @@ DECLARE_SOA_COLUMN(D0MD, d0MD, float);
8478
DECLARE_SOA_COLUMN(D0PtD, d0PtD, float);
8579
DECLARE_SOA_COLUMN(D0EtaD, d0EtaD, float);
8680
DECLARE_SOA_COLUMN(D0PhiD, d0PhiD, float);
87-
DECLARE_SOA_COLUMN(D0Reflection, d0Reflection, int);
81+
DECLARE_SOA_COLUMN(D0MatchedFrom, d0MatchedFrom, int);
82+
DECLARE_SOA_COLUMN(D0SelectedAs, d0SelectedAs, int);
8883
} // namespace d0Info
8984

9085
DECLARE_SOA_TABLE(D0Tables, "AOD", "D0TABLE",
@@ -99,6 +94,20 @@ DECLARE_SOA_TABLE(D0Tables, "AOD", "D0TABLE",
9994
d0Info::D0Phi,
10095
d0Info::D0Y);
10196

97+
DECLARE_SOA_TABLE(D0McDTables, "AOD", "D0MCDTABLE",
98+
o2::soa::Index<>,
99+
collisionInfo::McCollisionTableId,
100+
d0Info::D0PromptBDT,
101+
d0Info::D0NonPromptBDT,
102+
d0Info::D0BkgBDT,
103+
d0Info::D0M,
104+
d0Info::D0Pt,
105+
d0Info::D0Eta,
106+
d0Info::D0Phi,
107+
d0Info::D0Y,
108+
d0Info::D0MatchedFrom,
109+
d0Info::D0SelectedAs);
110+
102111
DECLARE_SOA_TABLE(D0McPTables, "AOD", "D0MCPTABLE",
103112
o2::soa::Index<>,
104113
collisionInfo::McCollisionTableId,
@@ -112,6 +121,7 @@ namespace jetInfo
112121
{
113122
// D0 tables
114123
DECLARE_SOA_INDEX_COLUMN(D0Table, d0Table);
124+
DECLARE_SOA_INDEX_COLUMN(D0McDTable, d0McDTable);
115125
DECLARE_SOA_INDEX_COLUMN(D0McPTable, d0McPTable);
116126
// Jet
117127
DECLARE_SOA_COLUMN(JetPt, jetPt, float);
@@ -134,6 +144,15 @@ DECLARE_SOA_TABLE_STAGED(JetTables, "JETTABLE",
134144
jetInfo::JetPhi,
135145
jetInfo::D0JetDeltaPhi);
136146

147+
DECLARE_SOA_TABLE_STAGED(JetMcDTables, "JETMCDTABLE",
148+
o2::soa::Index<>,
149+
collisionInfo::CollisionTableId,
150+
jetInfo::D0McDTableId,
151+
jetInfo::JetPt,
152+
jetInfo::JetEta,
153+
jetInfo::JetPhi,
154+
jetInfo::D0JetDeltaPhi);
155+
137156
DECLARE_SOA_TABLE_STAGED(JetMcPTables, "JETMCPTABLE",
138157
o2::soa::Index<>,
139158
collisionInfo::McCollisionTableId,
@@ -160,18 +179,20 @@ DECLARE_SOA_TABLE_STAGED(JetMatchedTables, "JETMATCHEDTABLE",
160179
struct JetCorrelationD0 {
161180
// Define new table
162181
Produces<aod::CollisionTables> tableCollision;
163-
Produces<aod::MatchCollTables> tableMatchedCollision;
164182
Produces<aod::McCollisionTables> tableMcCollision;
183+
Produces<aod::MatchCollTables> tableMatchedCollision;
165184
Produces<aod::D0Tables> tableD0;
185+
Produces<aod::D0McDTables> tableD0McDetector;
166186
Produces<aod::D0McPTables> tableD0McParticle;
167187
Produces<aod::JetTables> tableJet;
188+
Produces<aod::JetMcDTables> tableJetMcDetector;
168189
Produces<aod::JetMcPTables> tableJetMcParticle;
169190
Produces<aod::JetMatchedTables> tableJetMatched;
170191

171192
// Configurables
172193
Configurable<std::string> eventSelections{"eventSelections", "sel8", "choose event selection"};
173194
Configurable<bool> skipMBGapEvents{"skipMBGapEvents", false, "decide to run over MB gap events or not"};
174-
Configurable<bool> applyRCTSelections{"applyRCTSelections", true, "decide to apply RCT selections"};
195+
Configurable<bool> applyRCTSelections{"applyRCTSelections", false, "decide to apply RCT selections"};
175196
Configurable<float> jetPtCutMin{"jetPtCutMin", 5.0, "minimum value of jet pt"};
176197
Configurable<float> d0PtCutMin{"d0PtCutMin", 1.0, "minimum value of d0 pt"};
177198
Configurable<float> jetMcPtCutMin{"jetMcPtCutMin", 3.0, "minimum value of jet pt particle level"};
@@ -318,15 +339,33 @@ struct JetCorrelationD0 {
318339
}
319340
const auto scores = d0Candidate.mlScores();
320341
fillD0Histograms(d0Candidate, scores);
321-
tableD0(tableCollision.lastIndex(), // might want to add some more detector level D0 quantities like prompt or non prompt info
322-
scores[2],
323-
scores[1],
324-
scores[0],
325-
d0Candidate.m(),
326-
d0Candidate.pt(),
327-
d0Candidate.eta(),
328-
d0Candidate.phi(),
329-
d0Candidate.y());
342+
343+
int matchedFrom = 0;
344+
int decayChannel = o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK;
345+
int selectedAs = 0;
346+
347+
if (d0Candidate.flagMcMatchRec() == decayChannel) { // matched to D0 on truth level
348+
matchedFrom = 1;
349+
} else if (d0Candidate.flagMcMatchRec() == -decayChannel) { // matched to D0bar on truth level
350+
matchedFrom = -1;
351+
}
352+
if (d0Candidate.candidateSelFlag() & BIT(0)) { // CandidateSelFlag == BIT(0) -> selected as D0
353+
selectedAs = 1;
354+
} else if (d0Candidate.candidateSelFlag() & BIT(1)) { // CandidateSelFlag == BIT(1) -> selected as D0bar
355+
selectedAs = -1;
356+
}
357+
358+
tableD0McDetector(tableCollision.lastIndex(), // might want to add some more detector level D0 quantities like prompt or non prompt info
359+
scores[2],
360+
scores[1],
361+
scores[0],
362+
d0Candidate.m(),
363+
d0Candidate.pt(),
364+
d0Candidate.eta(),
365+
d0Candidate.phi(),
366+
d0Candidate.y(),
367+
matchedFrom,
368+
selectedAs);
330369
for (const auto& jet : jets) {
331370
if (jet.pt() < jetPtCutMin) {
332371
continue;
@@ -336,12 +375,12 @@ struct JetCorrelationD0 {
336375
continue;
337376
}
338377
fillJetHistograms(jet, dPhi);
339-
tableJet(tableCollision.lastIndex(),
340-
tableD0.lastIndex(),
341-
jet.pt(),
342-
jet.eta(),
343-
jet.phi(),
344-
dPhi);
378+
tableJetMcDetector(tableCollision.lastIndex(),
379+
tableD0McDetector.lastIndex(),
380+
jet.pt(),
381+
jet.eta(),
382+
jet.phi(),
383+
dPhi);
345384
}
346385
}
347386
}
@@ -417,9 +456,6 @@ struct JetCorrelationD0 {
417456
if (McDJet.has_matchedJetGeo()) { // geometric matching
418457
for (auto const& McPJet : McDJet.template matchedJetGeo_as<aod::ChargedMCParticleLevelJets>()) {
419458
float dPhiP = RecoDecay::constrainAngle(McPJet.phi() - d0Particle.phi(), -o2::constants::math::PI);
420-
// if (std::abs(dPhiP - o2::constants::math::PI) > (o2::constants::math::PI / 2)) {
421-
// continue;
422-
// }
423459
tableJetMatched(tableMatchedCollision.lastIndex(),
424460
McDJet.pt(),
425461
McDJet.eta(),

0 commit comments

Comments
 (0)