Skip to content

Commit

Permalink
Propagating PR to all candidate creators
Browse files Browse the repository at this point in the history
  • Loading branch information
Luigi Dello Stritto committed May 30, 2024
1 parent 63ad2df commit f56d4dc
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 56 deletions.
23 changes: 16 additions & 7 deletions PWGHF/TableProducer/candidateCreator2Prong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
using namespace o2;
using namespace o2::analysis;
using namespace o2::hf_evsel;
using namespace o2::hf_evsel_mc;
using namespace o2::hf_trkcandsel;
using namespace o2::aod::hf_cand_2prong;
using namespace o2::hf_centrality;
Expand Down Expand Up @@ -653,7 +654,8 @@ struct HfCandidateCreator2ProngExpressions {
Produces<aod::HfCand2ProngMcRec> rowMcMatchRec;
Produces<aod::HfCand2ProngMcGen> rowMcMatchGen;

float zPvPosMax{1000.f};
HfEventSelectionMc hfEvSelMc; // mc event selection
using BCsInfo = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;

// inspect for which zPvPosMax cut was set for reconstructed
void init(InitContext& initContext)
Expand All @@ -662,9 +664,14 @@ struct HfCandidateCreator2ProngExpressions {
for (const DeviceSpec& device : workflows.devices) {
if (device.name.compare("hf-candidate-creator-2prong") == 0) {
for (const auto& option : device.options) {
if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
zPvPosMax = option.defaultValue.get<float>();
break;
if (option.name.compare("hfEvSel.useSel8Trigger") == 0) {
hfEvSelMc.useItsRoBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) {
hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.zPvPosMin") == 0) {
hfEvSelMc.zPvPosMin = option.defaultValue.get<float>();
} else if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
hfEvSelMc.zPvPosMax = option.defaultValue.get<float>();
}
}
break;
Expand All @@ -675,7 +682,8 @@ struct HfCandidateCreator2ProngExpressions {
/// Performs MC matching.
void processMc(aod::TracksWMc const& tracks,
aod::McParticles const& mcParticles,
aod::McCollisions const&)
aod::McCollisions const&,
BCsInfo const&)
{
rowCandidateProng2->bindExternalIndices(&tracks);

Expand Down Expand Up @@ -729,8 +737,9 @@ struct HfCandidateCreator2ProngExpressions {
origin = 0;

auto mcCollision = particle.mcCollision();
float zPv = mcCollision.posZ();
if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them
const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo>(mcCollision);
if (rejectionMask != 0) {
/// at least one event selection not satisfied --> reject the gen particle
rowMcMatchGen(flag, origin);
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions PWGHF/TableProducer/candidateCreator3Prong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ struct HfCandidateCreator3ProngExpressions {
createLc = option.defaultValue.get<bool>();
} else if (option.name.compare("createXic") == 0) {
createXic = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.iseSel8Trigger") == 0) {
hfEvSelMc.useITSROBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.useSel8Trigger") == 0) {
hfEvSelMc.useItsRoBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) {
hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.zPvPosMin") == 0) {
Expand Down
24 changes: 16 additions & 8 deletions PWGHF/TableProducer/candidateCreatorCascade.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
using namespace o2;
using namespace o2::analysis;
using namespace o2::hf_evsel;
using namespace o2::hf_evsel_mc;
using namespace o2::hf_trkcandsel;
using namespace o2::hf_centrality;
using namespace o2::constants::physics;
Expand Down Expand Up @@ -431,9 +432,9 @@ struct HfCandidateCreatorCascadeMc {
Produces<aod::HfCandCascadeMcRec> rowMcMatchRec;
Produces<aod::HfCandCascadeMcGen> rowMcMatchGen;

HfEventSelectionMc hfEvSelMc; // mc event selection
using MyTracksWMc = soa::Join<aod::TracksWCov, aod::McTrackLabels>;

float zPvPosMax{1000.f};
using BCsInfo = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;

// inspect for which zPvPosMax cut was set for reconstructed
void init(InitContext& initContext)
Expand All @@ -442,9 +443,14 @@ struct HfCandidateCreatorCascadeMc {
for (const DeviceSpec& device : workflows.devices) {
if (device.name.compare("hf-candidate-creator-cascade") == 0) {
for (const auto& option : device.options) {
if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
zPvPosMax = option.defaultValue.get<float>();
break;
if (option.name.compare("hfEvSel.useSel8Trigger") == 0) {
hfEvSelMc.useItsRoBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) {
hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.zPvPosMin") == 0) {
hfEvSelMc.zPvPosMin = option.defaultValue.get<float>();
} else if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
hfEvSelMc.zPvPosMax = option.defaultValue.get<float>();
}
}
break;
Expand All @@ -454,7 +460,8 @@ struct HfCandidateCreatorCascadeMc {

void processMc(MyTracksWMc const& tracks,
aod::McParticles const& mcParticles,
aod::McCollisions const&)
aod::McCollisions const&,
BCsInfo const&)
{
int8_t sign = 0;
int8_t origin = 0;
Expand Down Expand Up @@ -503,8 +510,9 @@ struct HfCandidateCreatorCascadeMc {
origin = 0;

auto mcCollision = particle.mcCollision();
float zPv = mcCollision.posZ();
if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them
const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo>(mcCollision);
if (rejectionMask != 0) {
/// at least one event selection not satisfied --> reject the gen particle
rowMcMatchGen(sign, origin);
continue;
}
Expand Down
24 changes: 17 additions & 7 deletions PWGHF/TableProducer/candidateCreatorDstar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

using namespace o2;
using namespace o2::hf_evsel;
using namespace o2::hf_evsel_mc;
using namespace o2::hf_trkcandsel;
using namespace o2::hf_centrality;
using namespace o2::constants::physics;
Expand Down Expand Up @@ -504,7 +505,8 @@ struct HfCandidateCreatorDstarExpressions {
Produces<aod::HfCandDstarMcRec> rowsMcMatchRecDstar;
Produces<aod::HfCandDstarMcGen> rowsMcMatchGenDstar;

float zPvPosMax{1000.f};
HfEventSelectionMc hfEvSelMc; // mc event selection
using BCsInfo = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;

// inspect for which zPvPosMax cut was set for reconstructed
void init(InitContext& initContext)
Expand All @@ -513,9 +515,14 @@ struct HfCandidateCreatorDstarExpressions {
for (const DeviceSpec& device : workflows.devices) {
if (device.name.compare("hf-candidate-creator-dstar") == 0) {
for (const auto& option : device.options) {
if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
zPvPosMax = option.defaultValue.get<float>();
break;
if (option.name.compare("hfEvSel.useSel8Trigger") == 0) {
hfEvSelMc.useItsRoBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) {
hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.zPvPosMin") == 0) {
hfEvSelMc.zPvPosMin = option.defaultValue.get<float>();
} else if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
hfEvSelMc.zPvPosMax = option.defaultValue.get<float>();
}
}
break;
Expand All @@ -526,7 +533,8 @@ struct HfCandidateCreatorDstarExpressions {
/// Perform MC Matching.
void processMc(aod::TracksWMc const& tracks,
aod::McParticles const& mcParticles,
aod::McCollisions const&)
aod::McCollisions const&,
BCsInfo const&)
{
rowsCandidateD0->bindExternalIndices(&tracks);
rowsCandidateDstar->bindExternalIndices(&tracks);
Expand Down Expand Up @@ -590,8 +598,10 @@ struct HfCandidateCreatorDstarExpressions {
std::vector<int> idxBhadMothers{};

auto mcCollision = particle.mcCollision();
float zPv = mcCollision.posZ();
if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them

const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo>(mcCollision);
if (rejectionMask != 0) {
/// at least one event selection not satisfied --> reject the gen particle
rowsMcMatchGenDstar(flagDstar, originDstar, -1);
rowsMcMatchGenD0(flagD0, originD0);
continue;
Expand Down
43 changes: 15 additions & 28 deletions PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ using namespace o2::constants::physics;
using namespace o2::framework;
using namespace o2::framework::expressions;
using namespace o2::hf_evsel;
using namespace o2::hf_evsel_mc;

// Reconstruction of omegac0 and xic0 candidates
struct HfCandidateCreatorXic0Omegac0 {
Expand Down Expand Up @@ -661,9 +662,7 @@ struct HfCandidateCreatorXic0Omegac0Mc {
Produces<aod::HfToOmegaKMCRec> rowMCMatchRecToOmegaK;
Produces<aod::HfToOmegaKMCGen> rowMCMatchGenToOmegaK;

Configurable<bool> rejGenTFAndITSROFBorders{"rejGenTFAndITSROFBorders", true, "Reject generated particles coming from bc close to TF and ITSROF borders"};
float zPvPosMax{1000.f};

HfEventSelectionMc hfEvSelMc; // mc event selection
using BCsInfo = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels>;

// inspect for which zPvPosMax cut was set for reconstructed
Expand All @@ -673,9 +672,14 @@ struct HfCandidateCreatorXic0Omegac0Mc {
for (const DeviceSpec& device : workflows.devices) {
if (device.name.compare("hf-candidate-creator-xic0-omegac0") == 0) {
for (const auto& option : device.options) {
if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
zPvPosMax = option.defaultValue.get<float>();
break;
if (option.name.compare("hfEvSel.useSel8Trigger") == 0) {
hfEvSelMc.useItsRoBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.useTimeFrameBorderCut") == 0) {
hfEvSelMc.useTimeFrameBorderCut = option.defaultValue.get<bool>();
} else if (option.name.compare("hfEvSel.zPvPosMin") == 0) {
hfEvSelMc.zPvPosMin = option.defaultValue.get<float>();
} else if (option.name.compare("hfEvSel.zPvPosMax") == 0) {
hfEvSelMc.zPvPosMax = option.defaultValue.get<float>();
}
}
break;
Expand Down Expand Up @@ -885,12 +889,11 @@ struct HfCandidateCreatorXic0Omegac0Mc {
debugGenLambda = 0;
origin = RecoDecay::OriginType::None;

// accept only mc particles coming from bc that are far away from TF border and ITSROFrame
if (rejGenTFAndITSROFBorders) {
auto coll = particle.mcCollision_as<aod::McCollisions>();
auto bc = coll.bc_as<BCsInfo>();
if (!bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) {
if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) {
auto mcCollision = particle.mcCollision();
const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask<BCsInfo>(mcCollision);
if (rejectionMask != 0) {
/// at least one event selection not satisfied --> reject the gen particle
if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) {
rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin);
} else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) {
rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin);
Expand All @@ -901,22 +904,6 @@ struct HfCandidateCreatorXic0Omegac0Mc {
}
continue;
}
}

auto mcCollision = particle.mcCollision();
float zPv = mcCollision.posZ();
if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them
if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) {
rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin);
} else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) {
rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin);
} else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) {
rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin);
} else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) {
rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, etaCharmBaryonGen, origin);
}
continue;
}

if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) {
// Xic → Xi pi
Expand Down
8 changes: 4 additions & 4 deletions PWGHF/Utils/utilsEvSelHf.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ namespace o2::hf_evsel_mc
enum McCollisionRejection {
None = 0,
TimeFrameBorderCut,
ITSROFrameBorderCut,
ItsRoFrameBorderCut,
PositionZ,
NMcCollisionRejection
};

struct HfEventSelectionMc {
// event selection parameters (in chronological order of application)
bool useITSROBorderCut{false}; // Apply the ITS RO frame border cut
bool useItsRoBorderCut{false}; // Apply the ITS RO frame border cut
bool useTimeFrameBorderCut{true}; // Apply TF border cut
float zPvPosMin{-1000.f}; // Minimum PV posZ (cm)
float zPvPosMax{1000.f}; // Maximum PV posZ (cm)
Expand All @@ -223,8 +223,8 @@ struct HfEventSelectionMc {
auto bc = mcCollision.template bc_as<TBc>();

/// ITS RO frame border cut
if (useITSROBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) {
SETBIT(rejectionMask, McCollisionRejection::ITSROFrameBorderCut);
if (useItsRoBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) {
SETBIT(rejectionMask, McCollisionRejection::ItsRoFrameBorderCut);
}
/// time frame border cut
if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) {
Expand Down

0 comments on commit f56d4dc

Please sign in to comment.