Skip to content

Commit 6db908a

Browse files
committed
Fix event selection for generated signals
1 parent 8fb6e00 commit 6db908a

10 files changed

+219
-106
lines changed

PWGHF/D2H/DataModel/ReducedDataModel.h

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

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

928934
// store all configurables values used in the first part of the workflow
929935
// so we can use them in the Bplus part
@@ -1025,7 +1031,10 @@ DECLARE_SOA_TABLE(HfMcGenRedBss, "AOD", "HFMCGENREDBS", //! Generation-level MC
10251031
hf_bs_mc::EtaProng0,
10261032
hf_bs_mc::PtProng1,
10271033
hf_bs_mc::YProng1,
1028-
hf_bs_mc::EtaProng1);
1034+
hf_bs_mc::EtaProng1,
1035+
hf_reduced_collision::HfCollisionRejectionMap,
1036+
cent::CentFT0C,
1037+
cent::CentFT0M);
10291038

10301039
// store all configurables values used in the first part of the workflow
10311040
// so we can use them in the Bs part
@@ -1109,7 +1118,10 @@ DECLARE_SOA_TABLE(HfMcGenRedLbs, "AOD", "HFMCGENREDLB", //! Generation-level MC
11091118
hf_lb_mc::EtaProng0,
11101119
hf_lb_mc::PtProng1,
11111120
hf_lb_mc::YProng1,
1112-
hf_lb_mc::EtaProng1);
1121+
hf_lb_mc::EtaProng1,
1122+
hf_reduced_collision::HfCollisionRejectionMap,
1123+
cent::CentFT0C,
1124+
cent::CentFT0M);
11131125

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

PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx

Lines changed: 140 additions & 78 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
@@ -52,6 +52,7 @@
5252
#include <Framework/O2DatabasePDGPlugin.h>
5353
#include <Framework/WorkflowSpec.h>
5454
#include <Framework/runDataProcessing.h>
55+
#include "Framework/RunningWorkflowInfo.h"
5556
#include <ReconstructionDataFormats/DCA.h>
5657
#include <ReconstructionDataFormats/Track.h>
5758

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

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

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

170174
o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE;
171175
int runNumber;
@@ -174,13 +178,15 @@ struct HfDataCreatorJpsiHadReduced {
174178
bool isHfCandBhadConfigFilled = false;
175179

176180
o2::hf_evsel::HfEventSelection hfEvSel;
181+
o2::hf_evsel::HfEventSelectionMc hfEvSelMc;
182+
177183
o2::vertexing::DCAFitterN<2> df2;
178184
o2::vertexing::DCAFitterN<3> df3;
179185
o2::vertexing::DCAFitterN<4> df4;
180186

181187
HistogramRegistry registry{"registry"};
182188

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

275294
/// Topological cuts
@@ -512,10 +531,23 @@ struct HfDataCreatorJpsiHadReduced {
512531
}
513532

514533
template <uint8_t decChannel>
515-
void runMcGen(aod::McParticles const& particlesMc)
534+
void runMcGen(aod::McCollision const& mcCollision,
535+
aod::McParticles const& particlesMc,
536+
CollisionsWCMcLabels const& collisions,
537+
BCsInfo const&)
516538
{
539+
// Check event selection
540+
float centDummy{-1.f}, centFT0C{-1.f}, centFT0M{-1.f};
541+
const auto collSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex());
542+
auto hfRejMap = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo, o2::hf_centrality::CentralityEstimator::None>(mcCollision, collSlice, centDummy);
543+
if (skipRejectedCollisions && hfRejMap!= 0) {
544+
return;
545+
}
546+
547+
const auto mcParticlesPerMcColl = particlesMc.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
548+
517549
// Match generated particles.
518-
for (const auto& particle : particlesMc) {
550+
for (const auto& particle : mcParticlesPerMcColl) {
519551
int8_t sign{0}, flag{0}, channel{0};
520552
if constexpr (decChannel == DecayChannel::BplusToJpsiK) {
521553
// B+ → J/Psi K+ → (µ+µ-) K+
@@ -556,7 +588,7 @@ struct HfDataCreatorJpsiHadReduced {
556588
}
557589
rowHfBpMcGenReduced(flag, channel, ptParticle, yParticle, etaParticle,
558590
ptProngs[0], yProngs[0], etaProngs[0],
559-
ptProngs[1], yProngs[1], etaProngs[1]);
591+
ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M);
560592
} else if constexpr (decChannel == DecayChannel::BsToJpsiPhi) {
561593
// Bs → J/Psi phi → (µ+µ-) (K+K-)
562594
if (RecoDecay::isMatchedMCGen<true>(particlesMc, particle, Pdg::kBS, std::array{static_cast<int>(Pdg::kJPsi), +kKPlus, -kKPlus}, true, &sign, 2)) {
@@ -596,22 +628,29 @@ struct HfDataCreatorJpsiHadReduced {
596628
}
597629
rowHfBsMcGenReduced(flag, channel, ptParticle, yParticle, etaParticle,
598630
ptProngs[0], yProngs[0], etaProngs[0],
599-
ptProngs[1], yProngs[1], etaProngs[1]);
631+
ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M);
600632
}
601633
} // gen
602634
}
603635

604636
// Jpsi candidate selection
605-
template <bool doMc, uint8_t decChannel, typename Coll, typename JpsiCands, typename TTracks, typename PParticles>
637+
template <bool doMc, uint8_t decChannel, typename Coll, typename JpsiCands, typename TTracks, typename PParticles, typename BBCs>
606638
void runDataCreation(Coll const& collision,
607639
JpsiCands const& candsJpsi,
608640
aod::TrackAssoc const& trackIndices,
609641
TTracks const&,
610642
PParticles const& particlesMc,
611643
uint64_t const& indexCollisionMaxNumContrib,
612-
aod::BCsWithTimestamps const&)
644+
BBCs const&)
613645
{
614646

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

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

@@ -1082,8 +1120,8 @@ struct HfDataCreatorJpsiHadReduced {
10821120
aod::TrackAssoc const& trackIndices,
10831121
TracksPidWithSelAndMc const& tracks,
10841122
aod::McParticles const& particlesMc,
1085-
aod::BCsWithTimestamps const& bcs,
1086-
McCollisions const&)
1123+
BCsInfo const& bcs,
1124+
McCollisions const& mcCollisions)
10871125
{
10881126
// store configurables needed for B+ workflow
10891127
if (!isHfCandBhadConfigFilled) {
@@ -1108,7 +1146,9 @@ struct HfDataCreatorJpsiHadReduced {
11081146
}
11091147
// handle normalization by the right number of collisions
11101148
hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl);
1111-
runMcGen<DecayChannel::BsToJpsiPhi>(particlesMc);
1149+
for (const auto& mcCollision: mcCollisions) {
1150+
runMcGen<DecayChannel::BsToJpsiPhi>(mcCollision, particlesMc, collisions, bcs);
1151+
}
11121152
}
11131153
PROCESS_SWITCH(HfDataCreatorJpsiHadReduced, processJpsiPhiMc, "Process J/Psi phi with MC info", false);
11141154
};

PWGHF/TableProducer/candidateCreator2Prong.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ struct HfCandidateCreator2ProngExpressions {
10151015
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
10161016
// Slice the collisions table to get the collision info for the current MC collision
10171017
float centrality{-1.f};
1018-
uint16_t rejectionMask{0};
1018+
uint32_t rejectionMask{0u};
10191019
int nSplitColl = 0;
10201020
if constexpr (centEstimator == CentralityEstimator::FT0C) {
10211021
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
@@ -1304,7 +1304,7 @@ struct HfCandidateCreator3ProngExpressions {
13041304
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
13051305
// Slice the collisions table to get the collision info for the current MC collision
13061306
float centrality{-1.f};
1307-
uint16_t rejectionMask{0};
1307+
uint32_t rejectionMask{0u};
13081308
int nSplitColl = 0;
13091309
if constexpr (centEstimator == CentralityEstimator::FT0C) {
13101310
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
@@ -564,7 +564,7 @@ struct HfCandidateCreatorCascadeMc {
564564
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
565565
// Slice the collisions table to get the collision info for the current MC collision
566566
float centrality{-1.f};
567-
uint16_t rejectionMask{0};
567+
uint32_t rejectionMask{0u};
568568
int nSplitColl = 0;
569569
if constexpr (centEstimator == CentralityEstimator::FT0C) {
570570
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
@@ -732,7 +732,7 @@ struct HfCandidateCreatorDstarExpressions {
732732
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
733733
// Slice the collisions table to get the collision info for the current MC collision
734734
float centrality{-1.f};
735-
uint16_t rejectionMask{0};
735+
uint32_t rejectionMask{0u};
736736
int nSplitColl = 0;
737737
if constexpr (centEstimator == CentralityEstimator::FT0C) {
738738
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
@@ -586,9 +586,8 @@ struct HfCandidateSigmac0plusplusMc {
586586
/// In case of need, readapt the code templetizing the function
587587
auto mcCollision = particle.mcCollision();
588588
float centrality{-1.f};
589-
uint16_t rejectionMask{0};
590589
const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex());
591-
rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo, o2::hf_centrality::CentralityEstimator::None>(mcCollision, collSlice, centrality);
590+
auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo, o2::hf_centrality::CentralityEstimator::None>(mcCollision, collSlice, centrality);
592591
hfEvSelMc.fillHistograms<o2::hf_centrality::CentralityEstimator::None>(mcCollision, rejectionMask, 0);
593592
if (rejectionMask != 0) {
594593
// 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
@@ -1088,7 +1088,7 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
10881088
const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex());
10891089
// Slice the collisions table to get the collision info for the current MC collision
10901090
float centrality{-1.f};
1091-
uint16_t rejectionMask{0};
1091+
uint32_t rejectionMask{0u};
10921092
int nSplitColl = 0;
10931093
if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0C) {
10941094
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
@@ -287,7 +287,7 @@ struct HfTaskMcValidationGen {
287287
if (storeOccupancy) {
288288
occupancy = getOccupancyGenColl(recoCollisions, OccupancyEstimator::Its);
289289
}
290-
uint16_t rejectionMask{0};
290+
uint32_t rejectionMask{0u};
291291
if constexpr (centEstimator == CentralityEstimator::FT0C) {
292292
rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo, centEstimator>(mcCollision, recoCollisions, centrality);
293293
} else if constexpr (centEstimator == CentralityEstimator::FT0M) {

0 commit comments

Comments
 (0)