Skip to content
123 changes: 87 additions & 36 deletions PWGHF/TableProducer/candidateCreator2Prong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ struct HfCandidateCreator2Prong {
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.)};
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.)};
OutputObj<TH1F> hVertexerType{TH1F("hVertexerType", "Use KF or DCAFitterN;Vertexer type;entries", 2, -0.5, 1.5)}; // See o2::aod::hf_cand::VertexerType
OutputObj<TH1D> hCollisions{TH1D("hCollisions", "HF event counter", ValuesEvSel::NEvSel, -0.5f, static_cast<float>(ValuesEvSel::NEvSel) - 0.5f)};
OutputObj<TH1D> hPosZBeforeEvSel{TH1D("hPosZBeforeEvSel", "PV position Z before ev. selection;posZ (cm);entries", 400, -20, 20)};
OutputObj<TH1D> hPosZAfterEvSel{TH1D("hPosZAfterEvSel", "PV position Z after ev. selection;posZ (cm);entries", 400, -20, 20)};

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

std::array<bool, 3> processesCollisions = {doprocessCollisions, doprocessCollisionsCentFT0C, doprocessCollisionsCentFT0M};
const int nProcessesCollisions = std::accumulate(processesCollisions.begin(), processesCollisions.end(), 0);
if (nProcessesCollisions > 1) {
LOGP(fatal, "At most one process function for collision monitoring can be enabled at a time.");
}
if (nProcessesCollisions == 1) {
if ((doprocessPvRefitWithDCAFitterN || doprocessNoPvRefitWithDCAFitterN || doprocessPvRefitWithKFParticle || doprocessNoPvRefitWithKFParticle) && !doprocessCollisions) {
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisions\"?");
}
Comment thread
mfaggin marked this conversation as resolved.
if ((doprocessPvRefitWithDCAFitterNCentFT0C || doprocessNoPvRefitWithDCAFitterNCentFT0C || doprocessPvRefitWithKFParticleCentFT0C || doprocessNoPvRefitWithKFParticleCentFT0C) && !doprocessCollisionsCentFT0C) {
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0C\"?");
}
if ((doprocessPvRefitWithDCAFitterNCentFT0M || doprocessNoPvRefitWithDCAFitterNCentFT0M || doprocessPvRefitWithKFParticleCentFT0M || doprocessNoPvRefitWithKFParticleCentFT0M) && !doprocessCollisionsCentFT0M) {
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0M\"?");
}
}

massPi = MassPiPlus;
massK = MassKPlus;

Expand All @@ -139,9 +159,12 @@ struct HfCandidateCreator2Prong {
ccdb->setLocalObjectValidityChecking();
lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(ccdbPathLut));
runNumber = 0;

/// collision monitoring
setLabelHistoEvSel(hCollisions.object);
}

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

// reject candidates in collisions outside the centrality range
/// reject candidates not satisfying the event selections
auto collision = rowTrackIndexProng2.template collision_as<Coll>();
float centrality = -1.;
if constexpr (centEstimator != CentralityEstimator::None) {
if constexpr (centEstimator == CentralityEstimator::FT0C) {
centrality = collision.centFT0C();
} else if constexpr (centEstimator == CentralityEstimator::FT0M) {
centrality = collision.centFT0M();
} else {
LOGP(fatal, "Centrality estimator different from FT0C and FT0M, fix it!");
}
if (centrality < centralityMin || centrality > centralityMax) {
continue;
}
}

/// event selection: sel8, PV posZ, TF border cut
if (!isHfCollisionSelected(collision, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut)) {
const auto rejectionMask = getHfCollisionRejectionMask<centEstimator>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
if (rejectionMask != 0) {
/// at least one event selection not satisfied --> reject the candidate
continue;
}

Expand Down Expand Up @@ -283,7 +293,7 @@ struct HfCandidateCreator2Prong {
}
}

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

for (const auto& rowTrackIndexProng2 : rowsTrackIndexProng2) {

// reject candidates in collisions outside the centrality range
/// reject candidates in collisions not satisfying the event selections
auto collision = rowTrackIndexProng2.template collision_as<Coll>();
float centrality = -1.;
if constexpr (centEstimator != CentralityEstimator::None) {
if constexpr (centEstimator == CentralityEstimator::FT0C) {
centrality = collision.centFT0C();
} else if constexpr (centEstimator == CentralityEstimator::FT0M) {
centrality = collision.centFT0M();
} else {
LOGP(fatal, "Centrality estimator different from FT0C and FT0M, fix it!");
}
if (centrality < centralityMin || centrality > centralityMax) {
continue;
}
}

/// event selection: sel8, PV posZ, TF border cut
if (!isHfCollisionSelected(collision, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut)) {
const auto rejectionMask = getHfCollisionRejectionMask<centEstimator>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
if (rejectionMask != 0) {
/// at least one event selection not satisfied --> reject the candidate
continue;
}

Expand Down Expand Up @@ -572,6 +569,60 @@ struct HfCandidateCreator2Prong {
runCreator2ProngWithKFParticle</*doPvRefit*/ false, CentralityEstimator::FT0M>(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps);
}
PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithKFParticleCentFT0M, "Run candidate creator using KFParticle package w/o PV refit and w/ centrality selection on FT0M", false);

///////////////////////////////////////////////////////////
/// ///
/// Process functions only for collision monitoring ///
/// ///
///////////////////////////////////////////////////////////

/// @brief process function to monitor collisions - no centrality
void processCollisions(soa::Join<aod::Collisions, aod::EvSels> const& collisions)
{
/// loop over collisions
for (const auto& collision : collisions) {

/// bitmask with event. selection info
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::None>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);

/// monitor the satisfied event selections
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);

} /// end loop over collisions
}
PROCESS_SWITCH(HfCandidateCreator2Prong, processCollisions, "Collision monitoring - no centrality", true);

/// @brief process function to monitor collisions - FT0C centrality
void processCollisionsCentFT0C(soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Cs> const& collisions)
{
/// loop over collisions
for (const auto& collision : collisions) {

/// bitmask with event. selection info
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0C>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);

/// monitor the satisfied event selections
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);

} /// end loop over collisions
}
PROCESS_SWITCH(HfCandidateCreator2Prong, processCollisionsCentFT0C, "Collision monitoring - FT0C centrality", false);

/// @brief process function to monitor collisions - FT0M centrality
void processCollisionsCentFT0M(soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Ms> const& collisions)
{
/// loop over collisions
for (const auto& collision : collisions) {

/// bitmask with event. selection info
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0M>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);

/// monitor the satisfied event selections
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);

} /// end loop over collisions
}
PROCESS_SWITCH(HfCandidateCreator2Prong, processCollisionsCentFT0M, "Collision monitoring - FT0M centrality", false);
};

/// Extends the base table with expression columns.
Expand Down
100 changes: 82 additions & 18 deletions PWGHF/TableProducer/candidateCreator3Prong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ struct HfCandidateCreator3Prong {
OutputObj<TH1F> hCovSVZZ{TH1F("hCovSVZZ", "3-prong candidates;ZZ element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)};
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.)};
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.)};
OutputObj<TH1D> hCollisions{TH1D("hCollisions", "HF event counter", ValuesEvSel::NEvSel, -0.5f, static_cast<float>(ValuesEvSel::NEvSel) - 0.5f)};
OutputObj<TH1D> hPosZBeforeEvSel{TH1D("hPosZBeforeEvSel", "PV position Z before ev. selection;posZ (cm);entries", 400, -20, 20)};
OutputObj<TH1D> hPosZAfterEvSel{TH1D("hPosZAfterEvSel", "PV position Z after ev. selection;posZ (cm);entries", 400, -20, 20)};

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

std::array<bool, 3> processesCollisions = {doprocessCollisions, doprocessCollisionsCentFT0C, doprocessCollisionsCentFT0M};
const int nProcessesCollisions = std::accumulate(processesCollisions.begin(), processesCollisions.end(), 0);
if (nProcessesCollisions > 1) {
LOGP(fatal, "At most one process function for collision monitoring can be enabled at a time.");
}
if (nProcessesCollisions == 1) {
if ((doprocessPvRefit || doprocessNoPvRefit) && !doprocessCollisions) {
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisions\"?");
}
if ((doprocessPvRefitCentFT0C || doprocessNoPvRefitCentFT0C) && !doprocessCollisionsCentFT0C) {
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0C\"?");
}
if ((doprocessPvRefitCentFT0M || doprocessNoPvRefitCentFT0M) && !doprocessCollisionsCentFT0M) {
LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0M\"?");
}
}

std::array<bool, 4> creationFlags = {createDplus, createDs, createLc, createXic};
if (std::accumulate(creationFlags.begin(), creationFlags.end(), 0) == 0) {
LOGP(fatal, "At least one particle specie should be enabled for the creation.");
Expand All @@ -132,9 +152,12 @@ struct HfCandidateCreator3Prong {
ccdb->setLocalObjectValidityChecking();
lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(ccdbPathLut));
runNumber = 0;

/// collision monitoring
setLabelHistoEvSel(hCollisions.object);
}

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

// reject candidates in collisions outside the centrality range
/// reject candidates in collisions not satisfying the event selections
auto collision = rowTrackIndexProng3.template collision_as<Coll>();
float centrality = -1.;
if constexpr (centEstimator != CentralityEstimator::None) {
if constexpr (centEstimator == CentralityEstimator::FT0C) {
centrality = collision.centFT0C();
} else if constexpr (centEstimator == CentralityEstimator::FT0M) {
centrality = collision.centFT0M();
} else {
LOGP(fatal, "Centrality estimator different from FT0C and FT0M, fix it!");
}
if (centrality < centralityMin || centrality > centralityMax) {
continue;
}
}

/// event selection: sel8, PV posZ, TF border cut
if (!isHfCollisionSelected(collision, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut)) {
const auto rejectionMask = getHfCollisionRejectionMask<centEstimator>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);
if (rejectionMask != 0) {
/// at least one event selection not satisfied --> reject the candidate
continue;
}

Expand Down Expand Up @@ -364,6 +374,60 @@ struct HfCandidateCreator3Prong {
runCreator3Prong</*doPvRefit*/ false, CentralityEstimator::FT0M>(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps);
}
PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitCentFT0M, "Run candidate creator without PV refit and w/ centrality selection on FT0M", false);

///////////////////////////////////////////////////////////
/// ///
/// Process functions only for collision monitoring ///
/// ///
///////////////////////////////////////////////////////////

/// @brief process function to monitor collisions - no centrality
void processCollisions(soa::Join<aod::Collisions, aod::EvSels> const& collisions)
{
/// loop over collisions
for (const auto& collision : collisions) {

/// bitmask with event. selection info
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::None>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);

/// monitor the satisfied event selections
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);

} /// end loop over collisions
}
PROCESS_SWITCH(HfCandidateCreator3Prong, processCollisions, "Collision monitoring - no centrality", true);

/// @brief process function to monitor collisions - FT0C centrality
void processCollisionsCentFT0C(soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Cs> const& collisions)
{
/// loop over collisions
for (const auto& collision : collisions) {

/// bitmask with event. selection info
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0C>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);

/// monitor the satisfied event selections
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);

} /// end loop over collisions
}
PROCESS_SWITCH(HfCandidateCreator3Prong, processCollisionsCentFT0C, "Collision monitoring - FT0C centrality", false);

/// @brief process function to monitor collisions - FT0M centrality
void processCollisionsCentFT0M(soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Ms> const& collisions)
{
/// loop over collisions
for (const auto& collision : collisions) {

/// bitmask with event. selection info
const auto rejectionMask = getHfCollisionRejectionMask<CentralityEstimator::FT0M>(collision, centralityMin, centralityMax, useSel8Trigger, maxPvPosZ, useTimeFrameBorderCut);

/// monitor the satisfied event selections
monitorCollision(collision, rejectionMask, hCollisions.object, hPosZBeforeEvSel.object, hPosZAfterEvSel.object);

} /// end loop over collisions
}
PROCESS_SWITCH(HfCandidateCreator3Prong, processCollisionsCentFT0M, "Collision monitoring - FT0M centrality", false);
};

/// Extends the base table with expression columns.
Expand Down
Loading