Skip to content

Commit 8d9eb4c

Browse files
DelloStrittoLuigi Dello Strittovkucerafcatalan92
authored
PWGHF: Add utility to apply event selection at the generated level (#6302)
* PWGHF: add TF border cut at the particle generate level * Adding utility for the event selection at the generated level * fix clang * fix * Propagating PR to all candidate creators * Splitting sel8 in the reco part * Add monitoring * fix * fix * Fix type of loop variable * Revert bad idea * Update PWGHF/TableProducer/candidateCreator2Prong.cxx Co-authored-by: Fabio Catalano <fabio.catalano372@gmail.com> * Update PWGHF/TableProducer/candidateCreatorCascade.cxx Co-authored-by: Fabio Catalano <fabio.catalano372@gmail.com> * Update PWGHF/TableProducer/candidateCreator3Prong.cxx Co-authored-by: Fabio Catalano <fabio.catalano372@gmail.com> --------- Co-authored-by: Luigi Dello Stritto <ldellost@alicecerno2.cern.ch> Co-authored-by: Vít Kučera <vit.kucera@cern.ch> Co-authored-by: Fabio Catalano <fabio.catalano372@gmail.com>
1 parent 307bdf3 commit 8d9eb4c

File tree

6 files changed

+186
-81
lines changed

6 files changed

+186
-81
lines changed

PWGHF/TableProducer/candidateCreator2Prong.cxx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -653,29 +653,28 @@ struct HfCandidateCreator2ProngExpressions {
653653
Produces<aod::HfCand2ProngMcRec> rowMcMatchRec;
654654
Produces<aod::HfCand2ProngMcGen> rowMcMatchGen;
655655

656-
float zPvPosMax{1000.f};
656+
HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring
657+
using BCsInfo = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;
658+
HistogramRegistry registry{"registry"};
657659

658660
// inspect for which zPvPosMax cut was set for reconstructed
659661
void init(InitContext& initContext)
660662
{
661663
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
662664
for (const DeviceSpec& device : workflows.devices) {
663665
if (device.name.compare("hf-candidate-creator-2prong") == 0) {
664-
for (const auto& option : device.options) {
665-
if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
666-
zPvPosMax = option.defaultValue.get<float>();
667-
break;
668-
}
669-
}
666+
hfEvSelMc.configureFromDevice(device);
670667
break;
671668
}
672669
}
670+
hfEvSelMc.addHistograms(registry); // particles monitoring
673671
}
674672

675673
/// Performs MC matching.
676674
void processMc(aod::TracksWMc const& tracks,
677675
aod::McParticles const& mcParticles,
678-
aod::McCollisions const&)
676+
aod::McCollisions const&,
677+
BCsInfo const&)
679678
{
680679
rowCandidateProng2->bindExternalIndices(&tracks);
681680

@@ -734,8 +733,11 @@ struct HfCandidateCreator2ProngExpressions {
734733
std::vector<int> idxBhadMothers{};
735734

736735
auto mcCollision = particle.mcCollision();
737-
float zPv = mcCollision.posZ();
738-
if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them
736+
737+
const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo>(mcCollision);
738+
hfEvSelMc.fillHistograms(rejectionMask);
739+
if (rejectionMask != 0) {
740+
/// at least one event selection not satisfied --> reject the gen particle
739741
rowMcMatchGen(flag, origin, -1);
740742
continue;
741743
}

PWGHF/TableProducer/candidateCreator3Prong.cxx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,10 @@ struct HfCandidateCreator3ProngExpressions {
457457
bool createDs{false};
458458
bool createLc{false};
459459
bool createXic{false};
460-
float zPvPosMax{1000.f};
460+
461+
HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring
462+
using BCsInfo = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;
463+
HistogramRegistry registry{"registry"};
461464

462465
void init(InitContext& initContext)
463466
{
@@ -466,6 +469,7 @@ struct HfCandidateCreator3ProngExpressions {
466469
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
467470
for (const DeviceSpec& device : workflows.devices) {
468471
if (device.name.compare("hf-candidate-creator-3prong") == 0) {
472+
hfEvSelMc.configureFromDevice(device);
469473
for (const auto& option : device.options) {
470474
if (option.name.compare("createDplus") == 0) {
471475
createDplus = option.defaultValue.get<bool>();
@@ -475,14 +479,14 @@ struct HfCandidateCreator3ProngExpressions {
475479
createLc = option.defaultValue.get<bool>();
476480
} else if (option.name.compare("createXic") == 0) {
477481
createXic = option.defaultValue.get<bool>();
478-
} else if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
479-
zPvPosMax = option.defaultValue.get<float>();
480482
}
481483
}
482484
break;
483485
}
484486
}
485487

488+
hfEvSelMc.addHistograms(registry); // particles monitoring
489+
486490
LOGP(info, "Flags for candidate creation from the reco workflow:");
487491
LOGP(info, " --> createDplus = {}", createDplus);
488492
LOGP(info, " --> createDs = {}", createDs);
@@ -493,7 +497,8 @@ struct HfCandidateCreator3ProngExpressions {
493497
/// Performs MC matching.
494498
void processMc(aod::TracksWMc const& tracks,
495499
aod::McParticles const& mcParticles,
496-
aod::McCollisions const&)
500+
aod::McCollisions const&,
501+
BCsInfo const&)
497502
{
498503
rowCandidateProng3->bindExternalIndices(&tracks);
499504

@@ -617,8 +622,11 @@ struct HfCandidateCreator3ProngExpressions {
617622
std::vector<int> idxBhadMothers{};
618623

619624
auto mcCollision = particle.mcCollision();
620-
float zPv = mcCollision.posZ();
621-
if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them
625+
626+
const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo>(mcCollision);
627+
hfEvSelMc.fillHistograms(rejectionMask);
628+
if (rejectionMask != 0) {
629+
/// at least one event selection not satisfied --> reject the gen particle
622630
rowMcMatchGen(flag, origin, channel, -1);
623631
continue;
624632
}

PWGHF/TableProducer/candidateCreatorCascade.cxx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -431,30 +431,28 @@ struct HfCandidateCreatorCascadeMc {
431431
Produces<aod::HfCandCascadeMcRec> rowMcMatchRec;
432432
Produces<aod::HfCandCascadeMcGen> rowMcMatchGen;
433433

434+
HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring
434435
using MyTracksWMc = soa::Join<aod::TracksWCov, aod::McTrackLabels>;
435-
436-
float zPvPosMax{1000.f};
436+
using BCsInfo = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;
437+
HistogramRegistry registry{"registry"};
437438

438439
// inspect for which zPvPosMax cut was set for reconstructed
439440
void init(InitContext& initContext)
440441
{
441442
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
442443
for (const DeviceSpec& device : workflows.devices) {
443444
if (device.name.compare("hf-candidate-creator-cascade") == 0) {
444-
for (const auto& option : device.options) {
445-
if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
446-
zPvPosMax = option.defaultValue.get<float>();
447-
break;
448-
}
449-
}
445+
hfEvSelMc.configureFromDevice(device);
450446
break;
451447
}
452448
}
449+
hfEvSelMc.addHistograms(registry); // particles monitoring
453450
}
454451

455452
void processMc(MyTracksWMc const& tracks,
456453
aod::McParticles const& mcParticles,
457-
aod::McCollisions const&)
454+
aod::McCollisions const&,
455+
BCsInfo const&)
458456
{
459457
int8_t sign = 0;
460458
int8_t origin = 0;
@@ -502,8 +500,11 @@ struct HfCandidateCreatorCascadeMc {
502500
std::vector<int> idxBhadMothers{};
503501

504502
auto mcCollision = particle.mcCollision();
505-
float zPv = mcCollision.posZ();
506-
if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them
503+
504+
const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo>(mcCollision);
505+
hfEvSelMc.fillHistograms(rejectionMask);
506+
if (rejectionMask != 0) {
507+
/// at least one event selection not satisfied --> reject the gen particle
507508
rowMcMatchGen(sign, origin, -1);
508509
continue;
509510
}

PWGHF/TableProducer/candidateCreatorDstar.cxx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -504,29 +504,28 @@ struct HfCandidateCreatorDstarExpressions {
504504
Produces<aod::HfCandDstarMcRec> rowsMcMatchRecDstar;
505505
Produces<aod::HfCandDstarMcGen> rowsMcMatchGenDstar;
506506

507-
float zPvPosMax{1000.f};
507+
HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring
508+
using BCsInfo = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;
509+
HistogramRegistry registry{"registry"};
508510

509511
// inspect for which zPvPosMax cut was set for reconstructed
510512
void init(InitContext& initContext)
511513
{
512514
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
513515
for (const DeviceSpec& device : workflows.devices) {
514516
if (device.name.compare("hf-candidate-creator-dstar") == 0) {
515-
for (const auto& option : device.options) {
516-
if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
517-
zPvPosMax = option.defaultValue.get<float>();
518-
break;
519-
}
520-
}
517+
hfEvSelMc.configureFromDevice(device);
521518
break;
522519
}
523520
}
521+
hfEvSelMc.addHistograms(registry); // particles monitoring
524522
}
525523

526524
/// Perform MC Matching.
527525
void processMc(aod::TracksWMc const& tracks,
528526
aod::McParticles const& mcParticles,
529-
aod::McCollisions const&)
527+
aod::McCollisions const&,
528+
BCsInfo const&)
530529
{
531530
rowsCandidateD0->bindExternalIndices(&tracks);
532531
rowsCandidateDstar->bindExternalIndices(&tracks);
@@ -590,8 +589,11 @@ struct HfCandidateCreatorDstarExpressions {
590589
std::vector<int> idxBhadMothers{};
591590

592591
auto mcCollision = particle.mcCollision();
593-
float zPv = mcCollision.posZ();
594-
if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them
592+
593+
const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo>(mcCollision);
594+
hfEvSelMc.fillHistograms(rejectionMask);
595+
if (rejectionMask != 0) {
596+
/// at least one event selection not satisfied --> reject the gen particle
595597
rowsMcMatchGenDstar(flagDstar, originDstar, -1);
596598
rowsMcMatchGenD0(flagD0, originD0, -1);
597599
continue;

PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -661,26 +661,21 @@ struct HfCandidateCreatorXic0Omegac0Mc {
661661
Produces<aod::HfToOmegaKMCRec> rowMCMatchRecToOmegaK;
662662
Produces<aod::HfToOmegaKMCGen> rowMCMatchGenToOmegaK;
663663

664-
Configurable<bool> rejGenTFAndITSROFBorders{"rejGenTFAndITSROFBorders", true, "Reject generated particles coming from bc close to TF and ITSROF borders"};
665-
float zPvPosMax{1000.f};
666-
664+
HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring
667665
using BCsInfo = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;
666+
HistogramRegistry registry{"registry"};
668667

669668
// inspect for which zPvPosMax cut was set for reconstructed
670669
void init(InitContext& initContext)
671670
{
672671
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
673672
for (const DeviceSpec& device : workflows.devices) {
674673
if (device.name.compare("hf-candidate-creator-xic0-omegac0") == 0) {
675-
for (const auto& option : device.options) {
676-
if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
677-
zPvPosMax = option.defaultValue.get<float>();
678-
break;
679-
}
680-
}
674+
hfEvSelMc.configureFromDevice(device);
681675
break;
682676
}
683677
}
678+
hfEvSelMc.addHistograms(registry); // particles monitoring
684679
}
685680

686681
template <int decayChannel, typename TMyRecoCand>
@@ -906,27 +901,11 @@ struct HfCandidateCreatorXic0Omegac0Mc {
906901
origin = RecoDecay::OriginType::None;
907902
std::vector<int> idxBhadMothers{};
908903

909-
// accept only mc particles coming from bc that are far away from TF border and ITSROFrame
910-
if (rejGenTFAndITSROFBorders) {
911-
auto coll = particle.mcCollision_as<aod::McCollisions>();
912-
auto bc = coll.bc_as<BCsInfo>();
913-
if (!bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) {
914-
if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) {
915-
rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1);
916-
} else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) {
917-
rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1);
918-
} else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) {
919-
rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1);
920-
} else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) {
921-
rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1);
922-
}
923-
continue;
924-
}
925-
}
926-
927904
auto mcCollision = particle.mcCollision();
928-
float zPv = mcCollision.posZ();
929-
if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them
905+
const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo>(mcCollision);
906+
hfEvSelMc.fillHistograms(rejectionMask);
907+
if (rejectionMask != 0) {
908+
/// at least one event selection not satisfied --> reject the gen particle
930909
if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) {
931910
rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin, -1);
932911
} else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) {

0 commit comments

Comments
 (0)