Skip to content

Commit eda4e6a

Browse files
authored
PWGHF: Add bitmask for ev. selection and collision process in candidate creators. (#5141)
1 parent 34a63e0 commit eda4e6a

6 files changed

Lines changed: 436 additions & 111 deletions

File tree

PWGHF/TableProducer/candidateCreator2Prong.cxx

Lines changed: 87 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ struct HfCandidateCreator2Prong {
102102
OutputObj<TH2F> hDcaXYProngs{TH2F("hDcaXYProngs", "DCAxy of 2-prong candidates;#it{p}_{T} (GeV/#it{c};#it{d}_{xy}) (#mum);entries", 100, 0., 20., 200, -500., 500.)};
103103
OutputObj<TH2F> hDcaZProngs{TH2F("hDcaZProngs", "DCAz of 2-prong candidates;#it{p}_{T} (GeV/#it{c};#it{d}_{z}) (#mum);entries", 100, 0., 20., 200, -500., 500.)};
104104
OutputObj<TH1F> hVertexerType{TH1F("hVertexerType", "Use KF or DCAFitterN;Vertexer type;entries", 2, -0.5, 1.5)}; // See o2::aod::hf_cand::VertexerType
105+
OutputObj<TH1D> hCollisions{TH1D("hCollisions", "HF event counter", ValuesEvSel::NEvSel, -0.5f, static_cast<float>(ValuesEvSel::NEvSel) - 0.5f)};
106+
OutputObj<TH1D> hPosZBeforeEvSel{TH1D("hPosZBeforeEvSel", "PV position Z before ev. selection;posZ (cm);entries", 400, -20, 20)};
107+
OutputObj<TH1D> hPosZAfterEvSel{TH1D("hPosZAfterEvSel", "PV position Z after ev. selection;posZ (cm);entries", 400, -20, 20)};
105108

106109
void init(InitContext const&)
107110
{
@@ -115,6 +118,23 @@ struct HfCandidateCreator2Prong {
115118
LOGP(fatal, "One and only one process function must be enabled at a time.");
116119
}
117120

121+
std::array<bool, 3> processesCollisions = {doprocessCollisions, doprocessCollisionsCentFT0C, doprocessCollisionsCentFT0M};
122+
const int nProcessesCollisions = std::accumulate(processesCollisions.begin(), processesCollisions.end(), 0);
123+
if (nProcessesCollisions > 1) {
124+
LOGP(fatal, "At most one process function for collision monitoring can be enabled at a time.");
125+
}
126+
if (nProcessesCollisions == 1) {
127+
if ((doprocessPvRefitWithDCAFitterN || doprocessNoPvRefitWithDCAFitterN || doprocessPvRefitWithKFParticle || doprocessNoPvRefitWithKFParticle) && !doprocessCollisions) {
128+
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisions\"?");
129+
}
130+
if ((doprocessPvRefitWithDCAFitterNCentFT0C || doprocessNoPvRefitWithDCAFitterNCentFT0C || doprocessPvRefitWithKFParticleCentFT0C || doprocessNoPvRefitWithKFParticleCentFT0C) && !doprocessCollisionsCentFT0C) {
131+
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0C\"?");
132+
}
133+
if ((doprocessPvRefitWithDCAFitterNCentFT0M || doprocessNoPvRefitWithDCAFitterNCentFT0M || doprocessPvRefitWithKFParticleCentFT0M || doprocessNoPvRefitWithKFParticleCentFT0M) && !doprocessCollisionsCentFT0M) {
134+
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0M\"?");
135+
}
136+
}
137+
118138
massPi = MassPiPlus;
119139
massK = MassKPlus;
120140

@@ -139,9 +159,12 @@ struct HfCandidateCreator2Prong {
139159
ccdb->setLocalObjectValidityChecking();
140160
lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(ccdbPathLut));
141161
runNumber = 0;
162+
163+
/// collision monitoring
164+
setLabelHistoEvSel(hCollisions.object);
142165
}
143166

144-
template <bool doPvRefit, int centEstimator, typename Coll, typename CandType, typename TTracks>
167+
template <bool doPvRefit, o2::aod::hf_collision_centrality::CentralityEstimator centEstimator, typename Coll, typename CandType, typename TTracks>
145168
void runCreator2ProngWithDCAFitterN(Coll const& collisions,
146169
CandType const& rowsTrackIndexProng2,
147170
TTracks const& tracks,
@@ -150,24 +173,11 @@ struct HfCandidateCreator2Prong {
150173
// loop over pairs of track indices
151174
for (const auto& rowTrackIndexProng2 : rowsTrackIndexProng2) {
152175

153-
// reject candidates in collisions outside the centrality range
176+
/// reject candidates not satisfying the event selections
154177
auto collision = rowTrackIndexProng2.template collision_as<Coll>();
155-
float centrality = -1.;
156-
if constexpr (centEstimator != CentralityEstimator::None) {
157-
if constexpr (centEstimator == CentralityEstimator::FT0C) {
158-
centrality = collision.centFT0C();
159-
} else if constexpr (centEstimator == CentralityEstimator::FT0M) {
160-
centrality = collision.centFT0M();
161-
} else {
162-
LOGP(fatal, "Centrality estimator different from FT0C and FT0M, fix it!");
163-
}
164-
if (centrality < centralityMin || centrality > centralityMax) {
165-
continue;
166-
}
167-
}
168-
169-
/// event selection: sel8, PV posZ, TF border cut
170-
if (!isHfCollisionSelected(collision, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut)) {
178+
const auto rejectionMask = getHfCollisionRejectionMask<centEstimator>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
179+
if (rejectionMask != 0) {
180+
/// at least one event selection not satisfied --> reject the candidate
171181
continue;
172182
}
173183

@@ -283,7 +293,7 @@ struct HfCandidateCreator2Prong {
283293
}
284294
}
285295

286-
template <bool doPvRefit, int centEstimator, typename Coll, typename CandType, typename TTracks>
296+
template <bool doPvRefit, o2::aod::hf_collision_centrality::CentralityEstimator centEstimator, typename Coll, typename CandType, typename TTracks>
287297
void runCreator2ProngWithKFParticle(Coll const& collisions,
288298
CandType const& rowsTrackIndexProng2,
289299
TTracks const& tracks,
@@ -292,24 +302,11 @@ struct HfCandidateCreator2Prong {
292302

293303
for (const auto& rowTrackIndexProng2 : rowsTrackIndexProng2) {
294304

295-
// reject candidates in collisions outside the centrality range
305+
/// reject candidates in collisions not satisfying the event selections
296306
auto collision = rowTrackIndexProng2.template collision_as<Coll>();
297-
float centrality = -1.;
298-
if constexpr (centEstimator != CentralityEstimator::None) {
299-
if constexpr (centEstimator == CentralityEstimator::FT0C) {
300-
centrality = collision.centFT0C();
301-
} else if constexpr (centEstimator == CentralityEstimator::FT0M) {
302-
centrality = collision.centFT0M();
303-
} else {
304-
LOGP(fatal, "Centrality estimator different from FT0C and FT0M, fix it!");
305-
}
306-
if (centrality < centralityMin || centrality > centralityMax) {
307-
continue;
308-
}
309-
}
310-
311-
/// event selection: sel8, PV posZ, TF border cut
312-
if (!isHfCollisionSelected(collision, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut)) {
307+
const auto rejectionMask = getHfCollisionRejectionMask<centEstimator>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
308+
if (rejectionMask != 0) {
309+
/// at least one event selection not satisfied --> reject the candidate
313310
continue;
314311
}
315312

@@ -572,6 +569,60 @@ struct HfCandidateCreator2Prong {
572569
runCreator2ProngWithKFParticle</*doPvRefit*/ false, CentralityEstimator::FT0M>(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps);
573570
}
574571
PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithKFParticleCentFT0M, "Run candidate creator using KFParticle package w/o PV refit and w/ centrality selection on FT0M", false);
572+
573+
///////////////////////////////////////////////////////////
574+
/// ///
575+
/// Process functions only for collision monitoring ///
576+
/// ///
577+
///////////////////////////////////////////////////////////
578+
579+
/// @brief process function to monitor collisions - no centrality
580+
void processCollisions(soa::Join<aod::Collisions, aod::EvSels> const& collisions)
581+
{
582+
/// loop over collisions
583+
for (const auto& collision : collisions) {
584+
585+
/// bitmask with event. selection info
586+
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::None>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
587+
588+
/// monitor the satisfied event selections
589+
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);
590+
591+
} /// end loop over collisions
592+
}
593+
PROCESS_SWITCH(HfCandidateCreator2Prong, processCollisions, "Collision monitoring - no centrality", true);
594+
595+
/// @brief process function to monitor collisions - FT0C centrality
596+
void processCollisionsCentFT0C(soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Cs> const& collisions)
597+
{
598+
/// loop over collisions
599+
for (const auto& collision : collisions) {
600+
601+
/// bitmask with event. selection info
602+
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0C>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
603+
604+
/// monitor the satisfied event selections
605+
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);
606+
607+
} /// end loop over collisions
608+
}
609+
PROCESS_SWITCH(HfCandidateCreator2Prong, processCollisionsCentFT0C, "Collision monitoring - FT0C centrality", false);
610+
611+
/// @brief process function to monitor collisions - FT0M centrality
612+
void processCollisionsCentFT0M(soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Ms> const& collisions)
613+
{
614+
/// loop over collisions
615+
for (const auto& collision : collisions) {
616+
617+
/// bitmask with event. selection info
618+
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0M>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
619+
620+
/// monitor the satisfied event selections
621+
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);
622+
623+
} /// end loop over collisions
624+
}
625+
PROCESS_SWITCH(HfCandidateCreator2Prong, processCollisionsCentFT0M, "Collision monitoring - FT0M centrality", false);
575626
};
576627

577628
/// Extends the base table with expression columns.

PWGHF/TableProducer/candidateCreator3Prong.cxx

Lines changed: 82 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ struct HfCandidateCreator3Prong {
9999
OutputObj<TH1F> hCovSVZZ{TH1F("hCovSVZZ", "3-prong candidates;ZZ element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)};
100100
OutputObj<TH2F> hDcaXYProngs{TH2F("hDcaXYProngs", "DCAxy of 3-prong candidates;#it{p}_{T} (GeV/#it{c};#it{d}_{xy}) (#mum);entries", 100, 0., 20., 200, -500., 500.)};
101101
OutputObj<TH2F> hDcaZProngs{TH2F("hDcaZProngs", "DCAz of 3-prong candidates;#it{p}_{T} (GeV/#it{c};#it{d}_{z}) (#mum);entries", 100, 0., 20., 200, -500., 500.)};
102+
OutputObj<TH1D> hCollisions{TH1D("hCollisions", "HF event counter", ValuesEvSel::NEvSel, -0.5f, static_cast<float>(ValuesEvSel::NEvSel) - 0.5f)};
103+
OutputObj<TH1D> hPosZBeforeEvSel{TH1D("hPosZBeforeEvSel", "PV position Z before ev. selection;posZ (cm);entries", 400, -20, 20)};
104+
OutputObj<TH1D> hPosZAfterEvSel{TH1D("hPosZAfterEvSel", "PV position Z after ev. selection;posZ (cm);entries", 400, -20, 20)};
102105

103106
void init(InitContext const&)
104107
{
@@ -109,6 +112,23 @@ struct HfCandidateCreator3Prong {
109112
LOGP(fatal, "One and only one process function must be enabled at a time.");
110113
}
111114

115+
std::array<bool, 3> processesCollisions = {doprocessCollisions, doprocessCollisionsCentFT0C, doprocessCollisionsCentFT0M};
116+
const int nProcessesCollisions = std::accumulate(processesCollisions.begin(), processesCollisions.end(), 0);
117+
if (nProcessesCollisions > 1) {
118+
LOGP(fatal, "At most one process function for collision monitoring can be enabled at a time.");
119+
}
120+
if (nProcessesCollisions == 1) {
121+
if ((doprocessPvRefit || doprocessNoPvRefit) && !doprocessCollisions) {
122+
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisions\"?");
123+
}
124+
if ((doprocessPvRefitCentFT0C || doprocessNoPvRefitCentFT0C) && !doprocessCollisionsCentFT0C) {
125+
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0C\"?");
126+
}
127+
if ((doprocessPvRefitCentFT0M || doprocessNoPvRefitCentFT0M) && !doprocessCollisionsCentFT0M) {
128+
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0M\"?");
129+
}
130+
}
131+
112132
std::array<bool, 4> creationFlags = {createDplus, createDs, createLc, createXic};
113133
if (std::accumulate(creationFlags.begin(), creationFlags.end(), 0) == 0) {
114134
LOGP(fatal, "At least one particle specie should be enabled for the creation.");
@@ -132,9 +152,12 @@ struct HfCandidateCreator3Prong {
132152
ccdb->setLocalObjectValidityChecking();
133153
lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(ccdbPathLut));
134154
runNumber = 0;
155+
156+
/// collision monitoring
157+
setLabelHistoEvSel(hCollisions.object);
135158
}
136159

137-
template <bool doPvRefit = false, int centEstimator = 0, typename Coll, typename Cand>
160+
template <bool doPvRefit = false, o2::aod::hf_collision_centrality::CentralityEstimator centEstimator, typename Coll, typename Cand>
138161
void runCreator3Prong(Coll const& collisions,
139162
Cand const& rowsTrackIndexProng3,
140163
aod::TracksWCovExtra const& tracks,
@@ -143,24 +166,11 @@ struct HfCandidateCreator3Prong {
143166
// loop over triplets of track indices
144167
for (const auto& rowTrackIndexProng3 : rowsTrackIndexProng3) {
145168

146-
// reject candidates in collisions outside the centrality range
169+
/// reject candidates in collisions not satisfying the event selections
147170
auto collision = rowTrackIndexProng3.template collision_as<Coll>();
148-
float centrality = -1.;
149-
if constexpr (centEstimator != CentralityEstimator::None) {
150-
if constexpr (centEstimator == CentralityEstimator::FT0C) {
151-
centrality = collision.centFT0C();
152-
} else if constexpr (centEstimator == CentralityEstimator::FT0M) {
153-
centrality = collision.centFT0M();
154-
} else {
155-
LOGP(fatal, "Centrality estimator different from FT0C and FT0M, fix it!");
156-
}
157-
if (centrality < centralityMin || centrality > centralityMax) {
158-
continue;
159-
}
160-
}
161-
162-
/// event selection: sel8, PV posZ, TF border cut
163-
if (!isHfCollisionSelected(collision, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut)) {
171+
const auto rejectionMask = getHfCollisionRejectionMask<centEstimator>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
172+
if (rejectionMask != 0) {
173+
/// at least one event selection not satisfied --> reject the candidate
164174
continue;
165175
}
166176

@@ -364,6 +374,60 @@ struct HfCandidateCreator3Prong {
364374
runCreator3Prong</*doPvRefit*/ false, CentralityEstimator::FT0M>(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps);
365375
}
366376
PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitCentFT0M, "Run candidate creator without PV refit and w/ centrality selection on FT0M", false);
377+
378+
///////////////////////////////////////////////////////////
379+
/// ///
380+
/// Process functions only for collision monitoring ///
381+
/// ///
382+
///////////////////////////////////////////////////////////
383+
384+
/// @brief process function to monitor collisions - no centrality
385+
void processCollisions(soa::Join<aod::Collisions, aod::EvSels> const& collisions)
386+
{
387+
/// loop over collisions
388+
for (const auto& collision : collisions) {
389+
390+
/// bitmask with event. selection info
391+
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::None>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
392+
393+
/// monitor the satisfied event selections
394+
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);
395+
396+
} /// end loop over collisions
397+
}
398+
PROCESS_SWITCH(HfCandidateCreator3Prong, processCollisions, "Collision monitoring - no centrality", true);
399+
400+
/// @brief process function to monitor collisions - FT0C centrality
401+
void processCollisionsCentFT0C(soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Cs> const& collisions)
402+
{
403+
/// loop over collisions
404+
for (const auto& collision : collisions) {
405+
406+
/// bitmask with event. selection info
407+
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0C>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
408+
409+
/// monitor the satisfied event selections
410+
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);
411+
412+
} /// end loop over collisions
413+
}
414+
PROCESS_SWITCH(HfCandidateCreator3Prong, processCollisionsCentFT0C, "Collision monitoring - FT0C centrality", false);
415+
416+
/// @brief process function to monitor collisions - FT0M centrality
417+
void processCollisionsCentFT0M(soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Ms> const& collisions)
418+
{
419+
/// loop over collisions
420+
for (const auto& collision : collisions) {
421+
422+
/// bitmask with event. selection info
423+
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0M>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
424+
425+
/// monitor the satisfied event selections
426+
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);
427+
428+
} /// end loop over collisions
429+
}
430+
PROCESS_SWITCH(HfCandidateCreator3Prong, processCollisionsCentFT0M, "Collision monitoring - FT0M centrality", false);
367431
};
368432

369433
/// Extends the base table with expression columns.

0 commit comments

Comments
 (0)