Skip to content

Commit 5455b42

Browse files
Added MC and RECO collisions diagnosis columns to tables, corrected associated configurables, removed unused library includes, corrected reflection bitmaps usage
1 parent 50598af commit 5455b42

1 file changed

Lines changed: 51 additions & 36 deletions

File tree

‎PWGJE/Tasks/hfFragmentationFunction.cxx‎

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@
1818
/// profile and/or jet momentum fraction for charmed hadrons
1919

2020
#include "PWGJE/Core/JetDerivedDataUtilities.h"
21-
#include "PWGJE/Core/JetHFUtilities.h"
2221
#include "PWGJE/Core/JetUtilities.h"
2322
#include "PWGJE/DataModel/Jet.h"
2423
#include "PWGJE/DataModel/JetReducedData.h"
2524

26-
#include "PWGHF/Core/DecayChannels.h"
27-
2825
#include "Common/Core/RecoDecay.h"
2926

3027
#include <CommonConstants/MathConstants.h>
@@ -77,7 +74,7 @@ namespace collisionSelections
7774
kMCCollisions = 0, ///< raw mccollisions with no selection, starts with 0
7875
kMCCollisionsZCut, ///< mccollisions with z vtx selection
7976
kMCCollisionsZCutSel8, ///< mccollisions with z vtx and sel8 mc emulated selections
80-
kMCCollisionsZCutSel8HasCollisions, ///< mccollisions with z vtx and sel8 mc emulated selections, with at least one reconstructed collisions
77+
kMCCollisionsZCutSel8HasCollisions, ///< mccollisions with z vtx and sel8 mc emulated selections, with at least one reconstructed collisions
8178
kMCCollisionsZCutSel8SplitCollisions, ///< mccollisions with z vtx and sel8 mc emulated selections, with no split reconstructed collisions
8279
kRecoCollisions, ///< raw reconstructed collisions after previous mccollisions selection
8380
kRecoCollisionsZcut, ///< reconstructed collisions with z vtx selection after previous mccollisions selection
@@ -106,6 +103,8 @@ DECLARE_SOA_COLUMN(HfMlScore1, hfMlScore1, float);
106103
DECLARE_SOA_COLUMN(HfMlScore2, hfMlScore2, float);
107104
DECLARE_SOA_COLUMN(HfMatchedFrom, hfMatchedFrom, int);
108105
DECLARE_SOA_COLUMN(HfSelectedAs, hfSelectedAs, int);
106+
DECLARE_SOA_COLUMN(RecoCollZCut, recoCollZCut, bool);
107+
DECLARE_SOA_COLUMN(RecoCollSel8, recoCollSel8, bool);
109108
DECLARE_SOA_COLUMN(McJetHfDist, mcJetHfDist, float);
110109
DECLARE_SOA_COLUMN(McJetPt, mcJetPt, float);
111110
DECLARE_SOA_COLUMN(McJetEta, mcJetEta, float);
@@ -117,6 +116,10 @@ DECLARE_SOA_COLUMN(McHfPhi, mcHfPhi, float);
117116
DECLARE_SOA_COLUMN(McHfY, mcHfY, float);
118117
DECLARE_SOA_COLUMN(McHfPrompt, mcHfPrompt, bool);
119118
DECLARE_SOA_COLUMN(McHfMatch, mcHfMatch, bool);
119+
DECLARE_SOA_COLUMN(McCollZCut, mcCollZCut, bool);
120+
DECLARE_SOA_COLUMN(McCollSel8, mcCollSel8, bool);
121+
DECLARE_SOA_COLUMN(McCollNumCollisions, mcCollNumCollisions, int);
122+
DECLARE_SOA_COLUMN(McCollNumSelectedCollisions, mcCollNumSelectedCollisions, int);
120123
} // namespace jet_distance
121124
DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE",
122125
jet_distance::JetHfDist,
@@ -173,6 +176,10 @@ DECLARE_SOA_TABLE(MatchJetDistanceTable, "AOD", "MATCHTABLE",
173176
jet_distance::McHfPhi,
174177
jet_distance::McHfY,
175178
jet_distance::McHfPrompt,
179+
jet_distance::McCollZCut,
180+
jet_distance::McCollSel8,
181+
jet_distance::McCollNumCollisions,
182+
jet_distance::McCollNumSelectedCollisions,
176183
jet_distance::JetHfDist,
177184
jet_distance::JetPt,
178185
jet_distance::JetEta,
@@ -188,7 +195,9 @@ DECLARE_SOA_TABLE(MatchJetDistanceTable, "AOD", "MATCHTABLE",
188195
jet_distance::HfMlScore1,
189196
jet_distance::HfMlScore2,
190197
jet_distance::HfMatchedFrom,
191-
jet_distance::HfSelectedAs);
198+
jet_distance::HfSelectedAs,
199+
jet_distance::RecoCollZCut,
200+
jet_distance::RecoCollSel8);
192201
} // namespace o2::aod
193202

194203
struct HfFragmentationFunction {
@@ -217,8 +226,9 @@ struct HfFragmentationFunction {
217226
Configurable<float> vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"};
218227
Configurable<std::string> eventSelections{"eventSelections", "sel8", "choose event selection"};
219228
Configurable<bool> applyMcEventSelection{"applyMcEventSelection", false, "Choose a boolean value"};
220-
Configurable<bool> applyRecoEventSelection{"applyRecoEventSelection", true, "Choose a boolean value"};
221-
Configurable<bool> rejectSplitCollisions{"rejectSplitCollisions", true, "reject generated events associated to more than one reconstructed collision"};
229+
Configurable<bool> applyRecoEventSelection{"applyRecoEventSelection", false, "Choose a boolean value"};
230+
Configurable<bool> rejectMCCollisionNoRecoCollision{"rejectMCCollisionNoRecoCollision", false, "reject generated events with no reconstructed collision"};
231+
Configurable<bool> rejectSplitCollisions{"rejectSplitCollisions", false, "reject generated events associated to more than one reconstructed collision"};
222232

223233
std::vector<int> eventSelectionBits;
224234

@@ -374,9 +384,9 @@ struct HfFragmentationFunction {
374384
int selectedAs = 0;
375385

376386
// bitwise AND operation: Checks whether BIT(i) is set, regardless of other bits
377-
if (mcdd0cand.candidateSelFlag() & BIT(0)) { // CandidateSelFlag == BIT(0) -> selected as D0
387+
if ((mcdd0cand.candidateSelFlag() & BIT(0)) != 0) { // CandidateSelFlag == BIT(0) -> selected as D0
378388
selectedAs = 1;
379-
} else if (mcdd0cand.candidateSelFlag() & BIT(1)) { // CandidateSelFlag == BIT(1) -> selected as D0bar
389+
} else if ((mcdd0cand.candidateSelFlag() & BIT(1)) != 0) { // CandidateSelFlag == BIT(1) -> selected as D0bar
380390
selectedAs = -1;
381391
}
382392

@@ -438,10 +448,10 @@ struct HfFragmentationFunction {
438448
}
439449
registry.fill(HIST("h_collision_counter"), collisionSelections::kMCCollisionsZCutSel8);
440450

441-
// reconstructed collisions associated to same mccollision
451+
// reconstructed collisions associated to this mccollision
442452
const auto collisionsPerMCCollision = collisions.sliceBy(collisionsPerMCCollisionPreslice, mccollision.globalIndex());
443453
// only consider events with at least one reconstructed collision
444-
if (collisionsPerMCCollision.size() == 0) {
454+
if (rejectMCCollisionNoRecoCollision && (collisionsPerMCCollision.size() == 0)) {
445455
continue;
446456
}
447457
// only consider events with no split vertices (one mccollision-to-one collision)
@@ -451,25 +461,26 @@ struct HfFragmentationFunction {
451461
}
452462
registry.fill(HIST("h_collision_counter"), collisionSelections::kMCCollisionsZCutSel8SplitCollisions);
453463

454-
bool hasSelectedCollision = false;
464+
int numSelectedCollisions = 0;
455465
for (const auto& collision : collisionsPerMCCollision) {
456466

457467
registry.fill(HIST("h_collision_counter"), collisionSelections::kRecoCollisions);
458-
if (applyRecoEventSelection && !(std::abs(collision.posZ()) < vertexZCut)) {
468+
if (!(std::abs(collision.posZ()) < vertexZCut)) {
459469
continue;
460470
}
461471
registry.fill(HIST("h_collision_counter"), collisionSelections::kRecoCollisionsZcut);
462-
if (applyRecoEventSelection && !jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
472+
if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
463473
continue;
464474
}
465475
registry.fill(HIST("h_collision_counter"), collisionSelections::kRecoCollisionsZcutSel8);
466-
hasSelectedCollision = true;
476+
numSelectedCollisions++;
467477
} // end of collisions loop
468478

469-
if (!hasSelectedCollision) {
479+
// separate reconstructed collision selection from the case with no existing reconstructed collision per mccollision
480+
if (applyRecoEventSelection && (numSelectedCollisions == 0) && (collisionsPerMCCollision.size() != 0)) {
470481
continue;
471482
}
472-
483+
473484
// --- begin particle level jets storage
474485
// hf particle level jets associated to same mccollision
475486
const auto mcpJetsPerMCCollision = mcpjets.sliceBy(MCPJetsPerMCCollisionPreslice, mccollision.globalIndex());
@@ -493,40 +504,42 @@ struct HfFragmentationFunction {
493504
int selectedAs = 0;
494505

495506
// bitwise AND operation: Checks whether BIT(i) is set, regardless of other bits
496-
if (mcdcand.candidateSelFlag() & BIT(0)) { // CandidateSelFlag == BIT(0) -> selected as HF
507+
if ((mcdcand.candidateSelFlag() & BIT(0)) != 0) { // CandidateSelFlag == BIT(0) -> selected as HF
497508
selectedAs = 1;
498-
} else if (mcdcand.candidateSelFlag() & BIT(1)) { // CandidateSelFlag == BIT(1) -> selected as HFbar
509+
} else if ((mcdcand.candidateSelFlag() & BIT(1)) != 0) { // CandidateSelFlag == BIT(1) -> selected as HFbar
499510
selectedAs = -1;
500511
}
501-
512+
513+
// fetch collision associated to the detector level jet
514+
const auto& collision = mcdjet.template collision_as<aod::JetCollisionsMCD>();
515+
502516
// store matched particle and detector level data in one single table (calculate angular distance in eta-phi plane on the fly)
503517
matchJetTable(jetutilities::deltaR(mcpjet, mcpcand), mcpjet.pt(), mcpjet.eta(), mcpjet.phi(), mcpjet.template tracks_as<aod::JetParticles>().size() + mcpjet.template candidates_as<TCandidatesMCP>().size(), // particle level jet
504518
mcpcand.pt(), mcpcand.eta(), mcpcand.phi(), mcpcand.y(), (mcpcand.originMcGen() == RecoDecay::OriginType::Prompt), // particle level HF
519+
std::abs(mccollision.posZ()) < vertexZCut, jetderiveddatautilities::selectCollision(mccollision, eventSelectionBits), static_cast<int>(collisionsPerMCCollision.size()), numSelectedCollisions, // MC collision selections
505520
jetutilities::deltaR(mcdjet, mcdcand), mcdjet.pt(), mcdjet.eta(), mcdjet.phi(), mcdjet.template tracks_as<aod::JetTracks>().size() + mcdjet.template candidates_as<TCandidatesMCD>().size(), // detector level jet
506521
mcdcand.pt(), mcdcand.eta(), mcdcand.phi(), mcdcand.m(), mcdcand.y(), (mcdcand.originMcRec() == RecoDecay::OriginType::Prompt), // detector level HF
507522
mcdcand.mlScores()[0], mcdcand.mlScores()[1], mcdcand.mlScores()[2], // Machine Learning PID scores: background, prompt, non-prompt
508-
static_cast<int>(mcdcand.flagMcMatchRec()), selectedAs); // HF = +1, HFbar = -1, neither = 0
523+
static_cast<int>(mcdcand.flagMcMatchRec()), selectedAs, // HF = +1, HFbar = -1, neither = 0
524+
std::abs(collision.posZ()) < vertexZCut, jetderiveddatautilities::selectCollision(collision, eventSelectionBits)); // Reconstructed collision selections
509525
}
510526
} else {
511527
// store matched particle and detector level data in one single table (calculate angular distance in eta-phi plane on the fly)
512-
matchJetTable(jetutilities::deltaR(mcpjet, mcpcand), mcpjet.pt(), mcpjet.eta(), mcpjet.phi(), mcpjet.template tracks_as<aod::JetParticles>().size() + mcpjet.template candidates_as<TCandidatesMCP>().size(), // particle level jet
513-
mcpcand.pt(), mcpcand.eta(), mcpcand.phi(), mcpcand.y(), (mcpcand.originMcGen() == RecoDecay::OriginType::Prompt), // particle level HF
514-
-2, -2, -2, -2, -2, // no detector-level jet found
515-
-2, -2, -2, -2, -2, false, // no detector-level jet found
516-
-2, -2, -2, // no detector-level jet found
517-
-2, -2); // no detector-level jet found
528+
matchJetTable(jetutilities::deltaR(mcpjet, mcpcand), mcpjet.pt(), mcpjet.eta(), mcpjet.phi(), mcpjet.template tracks_as<aod::JetParticles>().size() + mcpjet.template candidates_as<TCandidatesMCP>().size(), // particle level jet
529+
mcpcand.pt(), mcpcand.eta(), mcpcand.phi(), mcpcand.y(), (mcpcand.originMcGen() == RecoDecay::OriginType::Prompt), // particle level HF
530+
std::abs(mccollision.posZ()) < vertexZCut, jetderiveddatautilities::selectCollision(mccollision, eventSelectionBits), static_cast<int>(collisionsPerMCCollision.size()), numSelectedCollisions, // MC collision selections
531+
-2, -2, -2, -2, -2, // no detector-level jet found
532+
-2, -2, -2, -2, -2, false, // no detector-level jet found
533+
-2, -2, -2, // no detector-level jet found
534+
-2, -2, // no detector-level jet found
535+
false, false); // no detector-level jet found
518536
}
519537
} // end of mcpjets loop
520538

521539
// --- begin non-matched detector level jets storage (fake candidates and correlated background if present)
522540
// reconstructed collisions associated to same mccollision
523541
for (const auto& collision : collisionsPerMCCollision) {
524542

525-
// Also apply the reconstructed level collisions selections
526-
if (applyRecoEventSelection && (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || !(std::abs(collision.posZ()) < vertexZCut))) {
527-
continue;
528-
}
529-
530543
// d0 detector level jets associated to the current same collision
531544
const auto mcdJetsPerCollision = mcdjets.sliceBy(MCDJetsPerCollisionPreslice, collision.globalIndex());
532545
for (const auto& mcdjet : mcdJetsPerCollision) {
@@ -544,19 +557,21 @@ struct HfFragmentationFunction {
544557
int selectedAs = 0;
545558

546559
// bitwise AND operation: Checks whether BIT(i) is set, regardless of other bits
547-
if (mcdcand.candidateSelFlag() & BIT(0)) { // CandidateSelFlag == BIT(0) -> selected as D0
560+
if ((mcdcand.candidateSelFlag() & BIT(0)) != 0) { // CandidateSelFlag == BIT(0) -> selected as D0
548561
selectedAs = 1;
549-
} else if (mcdcand.candidateSelFlag() & BIT(1)) { // CandidateSelFlag == BIT(1) -> selected as D0bar
562+
} else if ((mcdcand.candidateSelFlag() & BIT(1)) != 0) { // CandidateSelFlag == BIT(1) -> selected as D0bar
550563
selectedAs = -1;
551564
}
552565

553566
// store matched particle and detector level data in one single table (calculate angular distance in eta-phi plane on the fly)
554567
matchJetTable(-2, -2, -2, -2, -2, // particle level jet
555-
-2, -2, -2, -2, false, // particle level HF
568+
-2, -2, -2, -2, false, // particle level HF
569+
std::abs(mccollision.posZ()) < vertexZCut, jetderiveddatautilities::selectCollision(mccollision, eventSelectionBits), static_cast<int>(collisionsPerMCCollision.size()), numSelectedCollisions, // MC collision selections
556570
jetutilities::deltaR(mcdjet, mcdcand), mcdjet.pt(), mcdjet.eta(), mcdjet.phi(), mcdjet.template tracks_as<aod::JetTracks>().size() + mcdjet.template candidates_as<TCandidatesMCD>().size(), // detector level jet
557571
mcdcand.pt(), mcdcand.eta(), mcdcand.phi(), mcdcand.m(), mcdcand.y(), (mcdcand.originMcRec() == RecoDecay::OriginType::Prompt), // detector level HF
558572
mcdcand.mlScores()[0], mcdcand.mlScores()[1], mcdcand.mlScores()[2], // Machine Learning PID scores: background, prompt, non-prompt
559-
static_cast<int>(mcdcand.flagMcMatchRec()), selectedAs); // HF = +1, HFbar = -1, neither = 0
573+
static_cast<int>(mcdcand.flagMcMatchRec()), selectedAs, // HF = +1, HFbar = -1, neither = 0
574+
std::abs(collision.posZ()) < vertexZCut, jetderiveddatautilities::selectCollision(collision, eventSelectionBits)); // Reconstructed collision selections
560575
}
561576
} // end of non-matched detector level jets loop
562577
} // end of collisions loop

0 commit comments

Comments
 (0)