Skip to content

Commit f0042e7

Browse files
committed
Fix event selection for generated signals
1 parent 7d10012 commit f0042e7

10 files changed

+220
-104
lines changed

PWGHF/D2H/DataModel/ReducedDataModel.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,10 @@ DECLARE_SOA_TABLE(HfMcGenRedB0s, "AOD", "HFMCGENREDB0", //! Generation-level MC
831831
hf_b0_mc::EtaProng0,
832832
hf_b0_mc::PtProng1,
833833
hf_b0_mc::YProng1,
834-
hf_b0_mc::EtaProng1);
834+
hf_b0_mc::EtaProng1,
835+
hf_reduced_collision::HfCollisionRejectionMap,
836+
cent::CentFT0C,
837+
cent::CentFT0M);
835838

836839
// store all configurables values used in the first part of the workflow
837840
// so we can use them in the B0 part
@@ -922,7 +925,10 @@ DECLARE_SOA_TABLE(HfMcGenRedBps, "AOD", "HFMCGENREDBP", //! Generation-level MC
922925
hf_bplus_mc::EtaProng0,
923926
hf_bplus_mc::PtProng1,
924927
hf_bplus_mc::YProng1,
925-
hf_bplus_mc::EtaProng1);
928+
hf_bplus_mc::EtaProng1,
929+
hf_reduced_collision::HfCollisionRejectionMap,
930+
cent::CentFT0C,
931+
cent::CentFT0M);
926932

927933
// store all configurables values used in the first part of the workflow
928934
// so we can use them in the Bplus part
@@ -1024,7 +1030,10 @@ DECLARE_SOA_TABLE(HfMcGenRedBss, "AOD", "HFMCGENREDBS", //! Generation-level MC
10241030
hf_bs_mc::EtaProng0,
10251031
hf_bs_mc::PtProng1,
10261032
hf_bs_mc::YProng1,
1027-
hf_bs_mc::EtaProng1);
1033+
hf_bs_mc::EtaProng1,
1034+
hf_reduced_collision::HfCollisionRejectionMap,
1035+
cent::CentFT0C,
1036+
cent::CentFT0M);
10281037

10291038
// store all configurables values used in the first part of the workflow
10301039
// so we can use them in the Bs part
@@ -1108,7 +1117,10 @@ DECLARE_SOA_TABLE(HfMcGenRedLbs, "AOD", "HFMCGENREDLB", //! Generation-level MC
11081117
hf_lb_mc::EtaProng0,
11091118
hf_lb_mc::PtProng1,
11101119
hf_lb_mc::YProng1,
1111-
hf_lb_mc::EtaProng1);
1120+
hf_lb_mc::EtaProng1,
1121+
hf_reduced_collision::HfCollisionRejectionMap,
1122+
cent::CentFT0C,
1123+
cent::CentFT0M);
11121124

11131125
// store all configurables values used in the first part of the workflow
11141126
// so we can use them in the B0 part

PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx

Lines changed: 141 additions & 76 deletions
Large diffs are not rendered by default.

PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <Framework/O2DatabasePDGPlugin.h>
5252
#include <Framework/WorkflowSpec.h>
5353
#include <Framework/runDataProcessing.h>
54+
#include "Framework/RunningWorkflowInfo.h"
5455
#include <ReconstructionDataFormats/DCA.h>
5556
#include <ReconstructionDataFormats/Track.h>
5657

@@ -123,6 +124,7 @@ struct HfDataCreatorJpsiHadReduced {
123124
Produces<aod::HfCfgBpToJpsi> rowCandidateConfigBplus;
124125
Produces<aod::HfCfgBsToJpsis> rowCandidateConfigBs;
125126

127+
Configurable<bool> skipRejectedCollisions{"skipRejectedCollisions", true, "skips collisions rejected by the event selection, instead of flagging only"};
126128
Configurable<bool> propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"};
127129
Configurable<bool> useAbsDCA{"useAbsDCA", false, "Minimise abs. distance rather than chi2"};
128130
Configurable<bool> useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"};
@@ -163,10 +165,12 @@ struct HfDataCreatorJpsiHadReduced {
163165
using TracksSel = soa::Join<aod::TracksWDcaExtra, aod::TracksPidPi, aod::PidTpcTofFullPi, aod::TracksPidKa, aod::PidTpcTofFullKa>;
164166
using TracksPidWithSelAndMc = soa::Join<TracksPidWithSel, aod::McTrackLabels>;
165167
using CollisionsWCMcLabels = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels>;
168+
using BCsInfo = soa::Join<aod::BCsWithTimestamps, aod::BcSels>;
166169

167170
Preslice<aod::HfCand2ProngWPid> candsJpsiPerCollision = aod::track_association::collisionId;
168171
Preslice<aod::TrackAssoc> trackIndicesPerCollision = aod::track_association::collisionId;
169172
PresliceUnsorted<CollisionsWCMcLabels> colPerMcCollision = aod::mccollisionlabel::mcCollisionId;
173+
Preslice<aod::McParticles> mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId;
170174

171175
o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE;
172176
int runNumber;
@@ -175,13 +179,15 @@ struct HfDataCreatorJpsiHadReduced {
175179
bool isHfCandBhadConfigFilled = false;
176180

177181
o2::hf_evsel::HfEventSelection hfEvSel;
182+
o2::hf_evsel::HfEventSelectionMc hfEvSelMc;
183+
178184
o2::vertexing::DCAFitterN<2> df2;
179185
o2::vertexing::DCAFitterN<3> df3;
180186
o2::vertexing::DCAFitterN<4> df4;
181187

182188
HistogramRegistry registry{"registry"};
183189

184-
void init(InitContext const&)
190+
void init(InitContext& initContext)
185191
{
186192
std::array<int, 4> doProcess = {doprocessJpsiKData, doprocessJpsiKMc, doprocessJpsiPhiData, doprocessJpsiPhiMc};
187193
if (std::accumulate(doProcess.begin(), doProcess.end(), 0) != 1) {
@@ -271,6 +277,19 @@ struct HfDataCreatorJpsiHadReduced {
271277
invMass2JpsiHadMin = (MassBS - invMassWindowJpsiHad) * (MassBS - invMassWindowJpsiHad);
272278
invMass2JpsiHadMax = (MassBS + invMassWindowJpsiHad) * (MassBS + invMassWindowJpsiHad);
273279
}
280+
281+
// init HF event selection helper
282+
hfEvSel.init(registry);
283+
if (doprocessJpsiKMc || doprocessJpsiPhiMc) {
284+
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
285+
for (const DeviceSpec& device : workflows.devices) {
286+
if (device.name.compare("hf-data-creator-jpsi-had-reduced") == 0) {
287+
// init HF event selection helper
288+
hfEvSelMc.init(device, registry);
289+
break;
290+
}
291+
}
292+
}
274293
}
275294

276295
/// Topological cuts
@@ -513,10 +532,23 @@ struct HfDataCreatorJpsiHadReduced {
513532
}
514533

515534
template <uint8_t decChannel>
516-
void runMcGen(aod::McParticles const& particlesMc)
535+
void runMcGen(aod::McCollision const& mcCollision,
536+
aod::McParticles const& particlesMc,
537+
CollisionsWCMcLabels const& collisions,
538+
BCsInfo const&)
517539
{
540+
// Check event selection
541+
float centDummy{-1.f}, centFT0C{-1.f}, centFT0M{-1.f};
542+
const auto collSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex());
543+
auto hfRejMap = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo, o2::hf_centrality::CentralityEstimator::None>(mcCollision, collSlice, centDummy);
544+
if (skipRejectedCollisions && hfRejMap!= 0) {
545+
return;
546+
}
547+
548+
const auto mcParticlesPerMcColl = particlesMc.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
549+
518550
// Match generated particles.
519-
for (const auto& particle : particlesMc) {
551+
for (const auto& particle : mcParticlesPerMcColl) {
520552
int8_t sign{0}, flag{0}, channel{0};
521553
if constexpr (decChannel == DecayChannel::BplusToJpsiK) {
522554
// B+ → J/Psi K+ → (µ+µ-) K+
@@ -557,7 +589,7 @@ struct HfDataCreatorJpsiHadReduced {
557589
}
558590
rowHfBpMcGenReduced(flag, channel, ptParticle, yParticle, etaParticle,
559591
ptProngs[0], yProngs[0], etaProngs[0],
560-
ptProngs[1], yProngs[1], etaProngs[1]);
592+
ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M);
561593
} else if constexpr (decChannel == DecayChannel::BsToJpsiPhi) {
562594
// Bs → J/Psi phi → (µ+µ-) (K+K-)
563595
if (RecoDecay::isMatchedMCGen<true>(particlesMc, particle, Pdg::kBS, std::array{static_cast<int>(Pdg::kJPsi), +kKPlus, -kKPlus}, true, &sign, 2)) {
@@ -597,22 +629,29 @@ struct HfDataCreatorJpsiHadReduced {
597629
}
598630
rowHfBsMcGenReduced(flag, channel, ptParticle, yParticle, etaParticle,
599631
ptProngs[0], yProngs[0], etaProngs[0],
600-
ptProngs[1], yProngs[1], etaProngs[1]);
632+
ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M);
601633
}
602634
} // gen
603635
}
604636

605637
// Jpsi candidate selection
606-
template <bool doMc, uint8_t decChannel, typename Coll, typename JpsiCands, typename TTracks, typename PParticles>
638+
template <bool doMc, uint8_t decChannel, typename Coll, typename JpsiCands, typename TTracks, typename PParticles, typename BBCs>
607639
void runDataCreation(Coll const& collision,
608640
JpsiCands const& candsJpsi,
609641
aod::TrackAssoc const& trackIndices,
610642
TTracks const&,
611643
PParticles const& particlesMc,
612644
uint64_t const& indexCollisionMaxNumContrib,
613-
aod::BCsWithTimestamps const&)
645+
BBCs const&)
614646
{
615647

648+
registry.fill(HIST("hEvents"), 1 + Event::Processed);
649+
float centrality = -1.f;
650+
auto hfRejMap = hfEvSel.getHfCollisionRejectionMask<true, o2::hf_centrality::CentralityEstimator::None, aod::BCsWithTimestamps>(collision, centrality, ccdb, registry);
651+
if (skipRejectedCollisions && hfRejMap != 0) {
652+
return;
653+
}
654+
616655
// helpers for ReducedTables filling
617656
int indexHfReducedCollision = hfReducedCollision.lastIndex() + 1;
618657
// std::map where the key is the track.globalIndex() and
@@ -960,14 +999,11 @@ struct HfDataCreatorJpsiHadReduced {
960999
}
9611000
} // candsJpsi loop
9621001

963-
registry.fill(HIST("hEvents"), 1 + Event::Processed);
9641002
if (!fillHfReducedCollision) {
9651003
registry.fill(HIST("hEvents"), 1 + Event::NoCharmHadPiSelected);
9661004
return;
9671005
}
9681006
registry.fill(HIST("hEvents"), 1 + Event::CharmHadPiSelected);
969-
float centrality = -1.f;
970-
uint16_t hfRejMap = hfEvSel.getHfCollisionRejectionMask<true, o2::hf_centrality::CentralityEstimator::None, aod::BCsWithTimestamps>(collision, centrality, ccdb, registry);
9711007
// fill collision table if it contains a J/Psi K pair at minimum
9721008
hfReducedCollision(collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), hfRejMap, bz);
9731009
hfReducedCollExtra(collision.covXX(), collision.covXY(), collision.covYY(),
@@ -1048,8 +1084,8 @@ struct HfDataCreatorJpsiHadReduced {
10481084
aod::TrackAssoc const& trackIndices,
10491085
TracksPidWithSelAndMc const& tracks,
10501086
aod::McParticles const& particlesMc,
1051-
aod::BCsWithTimestamps const& bcs,
1052-
McCollisions const&)
1087+
BCsInfo const& bcs,
1088+
McCollisions const& mcCollisions)
10531089
{
10541090
// store configurables needed for B+ workflow
10551091
if (!isHfCandBhadConfigFilled) {
@@ -1074,7 +1110,9 @@ struct HfDataCreatorJpsiHadReduced {
10741110
}
10751111
// handle normalization by the right number of collisions
10761112
hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl);
1077-
runMcGen<DecayChannel::BplusToJpsiK>(particlesMc);
1113+
for (const auto& mcCollision: mcCollisions) {
1114+
runMcGen<DecayChannel::BplusToJpsiK>(mcCollision, particlesMc, collisions, bcs);
1115+
}
10781116
}
10791117
PROCESS_SWITCH(HfDataCreatorJpsiHadReduced, processJpsiKMc, "Process J/Psi K with MC info", false);
10801118

@@ -1083,8 +1121,8 @@ struct HfDataCreatorJpsiHadReduced {
10831121
aod::TrackAssoc const& trackIndices,
10841122
TracksPidWithSelAndMc const& tracks,
10851123
aod::McParticles const& particlesMc,
1086-
aod::BCsWithTimestamps const& bcs,
1087-
McCollisions const&)
1124+
BCsInfo const& bcs,
1125+
McCollisions const& mcCollisions)
10881126
{
10891127
// store configurables needed for B+ workflow
10901128
if (!isHfCandBhadConfigFilled) {
@@ -1109,7 +1147,9 @@ struct HfDataCreatorJpsiHadReduced {
11091147
}
11101148
// handle normalization by the right number of collisions
11111149
hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl);
1112-
runMcGen<DecayChannel::BsToJpsiPhi>(particlesMc);
1150+
for (const auto& mcCollision: mcCollisions) {
1151+
runMcGen<DecayChannel::BsToJpsiPhi>(mcCollision, particlesMc, collisions, bcs);
1152+
}
11131153
}
11141154
PROCESS_SWITCH(HfDataCreatorJpsiHadReduced, processJpsiPhiMc, "Process J/Psi phi with MC info", false);
11151155
};

PWGHF/TableProducer/candidateCreator2Prong.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ struct HfCandidateCreator2ProngExpressions {
995995
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
996996
// Slice the collisions table to get the collision info for the current MC collision
997997
float centrality{-1.f};
998-
uint16_t rejectionMask{0};
998+
uint32_t rejectionMask{0u};
999999
int nSplitColl = 0;
10001000
if constexpr (centEstimator == CentralityEstimator::FT0C) {
10011001
const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex());

PWGHF/TableProducer/candidateCreator3Prong.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ struct HfCandidateCreator3ProngExpressions {
12841284
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
12851285
// Slice the collisions table to get the collision info for the current MC collision
12861286
float centrality{-1.f};
1287-
uint16_t rejectionMask{0};
1287+
uint32_t rejectionMask{0u};
12881288
int nSplitColl = 0;
12891289
if constexpr (centEstimator == CentralityEstimator::FT0C) {
12901290
const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex());

PWGHF/TableProducer/candidateCreatorCascade.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ struct HfCandidateCreatorCascadeMc {
549549
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
550550
// Slice the collisions table to get the collision info for the current MC collision
551551
float centrality{-1.f};
552-
uint16_t rejectionMask{0};
552+
uint32_t rejectionMask{0u};
553553
int nSplitColl = 0;
554554
if constexpr (centEstimator == CentralityEstimator::FT0C) {
555555
const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex());

PWGHF/TableProducer/candidateCreatorDstar.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ struct HfCandidateCreatorDstarExpressions {
714714
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
715715
// Slice the collisions table to get the collision info for the current MC collision
716716
float centrality{-1.f};
717-
uint16_t rejectionMask{0};
717+
uint32_t rejectionMask{0u};
718718
int nSplitColl = 0;
719719
if constexpr (centEstimator == CentralityEstimator::FT0C) {
720720
const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex());

PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,8 @@ struct HfCandidateSigmac0plusplusMc {
566566
/// In case of need, readapt the code templetizing the function
567567
auto mcCollision = particle.mcCollision();
568568
float centrality{-1.f};
569-
uint16_t rejectionMask{0};
570569
const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex());
571-
rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo, o2::hf_centrality::CentralityEstimator::None>(mcCollision, collSlice, centrality);
570+
auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo, o2::hf_centrality::CentralityEstimator::None>(mcCollision, collSlice, centrality);
572571
hfEvSelMc.fillHistograms<o2::hf_centrality::CentralityEstimator::None>(mcCollision, rejectionMask, 0);
573572
if (rejectionMask != 0) {
574573
// at least one event selection not satisfied --> reject gen particles from this collision

PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
10701070
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
10711071
// Slice the collisions table to get the collision info for the current MC collision
10721072
float centrality{-1.f};
1073-
uint16_t rejectionMask{0};
1073+
uint32_t rejectionMask{0u};
10741074
int nSplitColl = 0;
10751075
if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0C) {
10761076
const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex());

PWGHF/Tasks/taskMcValidation.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ struct HfTaskMcValidationGen {
261261
if (storeOccupancy) {
262262
occupancy = getOccupancyGenColl(recoCollisions, OccupancyEstimator::Its);
263263
}
264-
uint16_t rejectionMask{0};
264+
uint32_t rejectionMask{0u};
265265
if constexpr (centEstimator == CentralityEstimator::FT0C) {
266266
rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo, centEstimator>(mcCollision, recoCollisions, centrality);
267267
} else if constexpr (centEstimator == CentralityEstimator::FT0M) {

0 commit comments

Comments
 (0)