Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions PWGHF/Core/HfMlResponseXicToXiPiPi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@
// Fill the map of available input features
// the key is the feature's name (std::string)
// the value is the corresponding value in EnumInputFeatures
#define FILL_MAP_XICTOXIPIPI(FEATURE) \
{ \
#FEATURE, static_cast < uint8_t>(InputFeaturesXicToXiPiPi::FEATURE) \
#define FILL_MAP_XICTOXIPIPI(FEATURE) \
{ \
#FEATURE, static_cast<uint8_t>(InputFeaturesXicToXiPiPi::FEATURE) \
}

// Check if the index of mCachedIndices (index associated to a FEATURE)
// matches the entry in EnumInputFeatures associated to this FEATURE
// if so, the inputFeatures vector is filled with the FEATURE's value
// by calling the corresponding GETTER from OBJECT
#define CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(OBJECT, FEATURE, GETTER) \
case static_cast<uint8_t>(InputFeaturesXicToXiPiPi::FEATURE): { \
inputFeatures.emplace_back(OBJECT.GETTER()); \
break; \
#define CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(OBJECT, FEATURE, GETTER) \
case static_cast<uint8_t>(InputFeaturesXicToXiPiPi::FEATURE): { \
inputFeatures.emplace_back(OBJECT.GETTER()); \
break; \
}

// Specific case of CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(OBJECT, FEATURE, GETTER)
// where OBJECT is named candidate and FEATURE = GETTER
#define CHECK_AND_FILL_VEC_XICTOXIPIPI(GETTER) \
case static_cast<uint8_t>(InputFeaturesXicToXiPiPi::GETTER): { \
inputFeatures.emplace_back(candidate.GETTER()); \
break; \
#define CHECK_AND_FILL_VEC_XICTOXIPIPI(GETTER) \
case static_cast<uint8_t>(InputFeaturesXicToXiPiPi::GETTER): { \
inputFeatures.emplace_back(candidate.GETTER()); \
break; \
}

namespace o2::analysis
Expand Down
55 changes: 28 additions & 27 deletions PWGHF/D2H/Tasks/taskXicToXiPiPi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ struct HfTaskXicToXiPiPi {
if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) == 0) {
LOGP(fatal, "No process function enabled. Please enable one.");
}
if((doprocessWithDCAFitter || doprocessWithDCAFitterAndML || doprocessMcWithDCAFitter || doprocessMcWithDCAFitterAndML) && (doprocessWithKFParticle || doprocessWithKFParticleAndML || doprocessMcWithKFParticle || doprocessMcWithKFParticleAndML)) {
if ((doprocessWithDCAFitter || doprocessWithDCAFitterAndML || doprocessMcWithDCAFitter || doprocessMcWithDCAFitterAndML) && (doprocessWithKFParticle || doprocessWithKFParticleAndML || doprocessMcWithKFParticle || doprocessMcWithKFParticleAndML)) {
LOGP(fatal, "Cannot enable DCAFitter and KFParticle at the same time. Please choose one.");
}
if((doprocessWithDCAFitter || doprocessWithKFParticle || doprocessMcWithDCAFitter || doprocessMcWithKFParticle) && (doprocessWithDCAFitterAndML || doprocessWithKFParticleAndML || doprocessMcWithDCAFitterAndML || doprocessMcWithKFParticleAndML)) {
if ((doprocessWithDCAFitter || doprocessWithKFParticle || doprocessMcWithDCAFitter || doprocessMcWithKFParticle) && (doprocessWithDCAFitterAndML || doprocessWithKFParticleAndML || doprocessMcWithDCAFitterAndML || doprocessMcWithKFParticleAndML)) {
LOGP(fatal, "Cannot enable process function with ML and process function without ML at the same time. Please choose one.");
}

Expand Down Expand Up @@ -242,7 +242,7 @@ struct HfTaskXicToXiPiPi {
}
}

if(enableTHn){
if (enableTHn) {
const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"};
const AxisSpec thnAxisMass{thnConfigAxisMass, "inv. mass #Xi^{#mp} #pi^{#pm} #pi^{#pm}"};
const AxisSpec thnAxisChi2PCA{thnConfigAxisChi2PCA, "Chi2PCA to sec. vertex (cm)"};
Expand All @@ -252,38 +252,39 @@ struct HfTaskXicToXiPiPi {
const AxisSpec thnAxisBdtScoreBkg{thnConfigAxisBdtScoreBkg, "BDT score of background"};
const AxisSpec thnAxisBdtScoreSignal{thnConfigAxisBdtScoreSignal, "BDT score of prompt Xic"};

if(doprocessWithKFParticleAndML || doprocessWithDCAFitterAndML || doprocessMcWithKFParticleAndML || doprocessMcWithDCAFitterAndML){
// with ML information
if (doprocessWithKFParticleAndML || doprocessWithDCAFitterAndML || doprocessMcWithKFParticleAndML || doprocessMcWithDCAFitterAndML) {
// with ML information
registry.add("hXicToXiPiPiVarsWithML", "THnSparse for Xic with ML", HistType::kTHnSparseF, {thnAxisPt, thnAxisMass, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisBdtScoreBkg, thnAxisBdtScoreSignal});
} else {
// without ML information
registry.add("hXicToXiPiPiVars", "THnSparse for Xic", HistType::kTHnSparseF, {thnAxisPt, thnAxisMass, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA});
}
} // enable THnSpare
} // enable THnSpare

} // end init
} // end init

/// Fill THnSpare depending on whether ML selection is used
/// Fill THnSpare depending on whether ML selection is used
// \param candidate is candidate
template <bool useMl, typename T1>
template <bool useMl, typename T1>
void fillTHnSparse(const T1& candidate)
{
if(!enableTHn) {return;}
if (!enableTHn) {
return;
}

if constexpr (useMl) {
// with ML information
double outputBkg = -99.;
double outputPrompt = -99.;
if(candidate.mlProbXicToXiPiPi().size() > 0){
if (candidate.mlProbXicToXiPiPi().size() > 0) {
outputBkg = candidate.mlProbXicToXiPiPi()[0];
outputPrompt = candidate.mlProbXicToXiPiPi()[1];
}
registry.get<THnSparse>(HIST("hXicToXiPiPiVarsWithML"))->Fill(candidate.pt(), candidate.invMassXic(), candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), outputBkg, outputPrompt);
} else {
// without ML information
registry.get<THnSparse>(HIST("hXicToXiPiPiVars"))->Fill(candidate.pt(), candidate.invMassXic(), candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa());
registry.get<THnSparse>(HIST("hXicToXiPiPiVars"))->Fill(candidate.pt(), candidate.invMassXic(), candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa());
}

}

/// Selection of Xic daughter in geometrical acceptance
Expand Down Expand Up @@ -350,10 +351,10 @@ struct HfTaskXicToXiPiPi {
}

// fill THnSparse
if(enableTHn){
if (enableTHn) {
if constexpr (useMl) {
fillTHnSparse<true>(candidate);
} else {
} else {
fillTHnSparse<false>(candidate);
}
}
Expand Down Expand Up @@ -472,7 +473,7 @@ struct HfTaskXicToXiPiPi {
}
}
// fill THnSparse
if(enableTHn){
if (enableTHn) {
if constexpr (useMl) {
fillTHnSparse<true>(candidate);
} else {
Expand Down Expand Up @@ -543,7 +544,7 @@ struct HfTaskXicToXiPiPi {
/// Data analysis and fill histograms
void processWithDCAFitter(soa::Filtered<soa::Join<aod::HfCandXic, aod::HfSelXicToXiPiPi>> const& candidates)
{
fillHistograms<false, false>(candidates);
fillHistograms<false, false>(candidates);
}
PROCESS_SWITCH(HfTaskXicToXiPiPi, processWithDCAFitter, "Process data with DCAFitter", true);

Expand All @@ -562,7 +563,7 @@ struct HfTaskXicToXiPiPi {

void processWithKFParticleAndML(soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicKF, aod::HfSelXicToXiPiPi, aod::HfMlXicToXiPiPi>> const& candidates)
{
fillHistograms<true, true>(candidates);
fillHistograms<true, true>(candidates);
}
PROCESS_SWITCH(HfTaskXicToXiPiPi, processWithKFParticleAndML, "Process data with KFParticle and ML approach", false);

Expand All @@ -571,7 +572,7 @@ struct HfTaskXicToXiPiPi {
soa::Join<aod::McParticles, aod::HfCandXicMcGen> const& mcParticles,
aod::TracksWMc const& tracksWMc)
{
fillHistogramsMc<false, false>(candidates, mcParticles, tracksWMc);
fillHistogramsMc<false, false>(candidates, mcParticles, tracksWMc);
}
PROCESS_SWITCH(HfTaskXicToXiPiPi, processMcWithDCAFitter, "Process MC with DCAFitter", false);

Expand All @@ -580,26 +581,26 @@ struct HfTaskXicToXiPiPi {
soa::Join<aod::McParticles, aod::HfCandXicMcGen> const& mcParticles,
aod::TracksWMc const& tracksWMc)
{
fillHistogramsMc<true, false>(candidates, mcParticles, tracksWMc);
fillHistogramsMc<true, false>(candidates, mcParticles, tracksWMc);
}
PROCESS_SWITCH(HfTaskXicToXiPiPi, processMcWithKFParticle, "Process MC with KFParticle", false);

// MC analysis and fill histograms with ML
void processMcWithDCAFitterAndML(soa::Filtered<soa::Join<aod::HfCandXic, aod::HfSelXicToXiPiPi, aod::HfMlXicToXiPiPi, aod::HfCandXicMcRec>> const& candidates,
soa::Join<aod::McParticles, aod::HfCandXicMcGen> const& mcParticles,
aod::TracksWMc const& tracksWMc)
soa::Join<aod::McParticles, aod::HfCandXicMcGen> const& mcParticles,
aod::TracksWMc const& tracksWMc)
{
fillHistogramsMc<false, true>(candidates, mcParticles, tracksWMc);
fillHistogramsMc<false, true>(candidates, mcParticles, tracksWMc);
}
PROCESS_SWITCH(HfTaskXicToXiPiPi, processMcWithDCAFitterAndML, "Process MC with DCAFitter and ML approach", false);

void processMcWithKFParticleAndML(soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicKF, aod::HfSelXicToXiPiPi, aod::HfMlXicToXiPiPi, aod::HfCandXicMcRec>> const& candidates,
soa::Join<aod::McParticles, aod::HfCandXicMcGen> const& mcParticles,
aod::TracksWMc const& tracksWMc)
soa::Join<aod::McParticles, aod::HfCandXicMcGen> const& mcParticles,
aod::TracksWMc const& tracksWMc)
{
fillHistogramsMc<true, true>(candidates, mcParticles, tracksWMc);
fillHistogramsMc<true, true>(candidates, mcParticles, tracksWMc);
}
PROCESS_SWITCH(HfTaskXicToXiPiPi, processMcWithKFParticleAndML, "Process MC with KFParticle and ML approach", false);
PROCESS_SWITCH(HfTaskXicToXiPiPi, processMcWithKFParticleAndML, "Process MC with KFParticle and ML approach", false);

}; // struct

Expand Down
4 changes: 2 additions & 2 deletions PWGHF/DataModel/CandidateSelectionTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ DECLARE_SOA_COLUMN(MlProbXicToPKPi, mlProbXicToPKPi, std::vector<float>); //!
DECLARE_SOA_COLUMN(MlProbXicToPiKP, mlProbXicToPiKP, std::vector<float>); //!
// XicPlus to Xi Pi Pi
DECLARE_SOA_COLUMN(IsSelXicToXiPiPi, isSelXicToXiPiPi, int); //!
DECLARE_SOA_COLUMN(MlProbXicToXiPiPi, mlProbXicToXiPiPi, std::vector<float>); //!
DECLARE_SOA_COLUMN(MlProbXicToXiPiPi, mlProbXicToXiPiPi, std::vector<float>); //!
} // namespace hf_sel_candidate_xic

DECLARE_SOA_TABLE(HfSelXicToPKPi, "AOD", "HFSELXIC", //!
Expand All @@ -319,7 +319,7 @@ DECLARE_SOA_TABLE(HfMlXicToPKPi, "AOD", "HFMLXIC", //!
DECLARE_SOA_TABLE(HfSelXicToXiPiPi, "AOD", "HFSELXICTOXI2PI", //!
hf_sel_candidate_xic::IsSelXicToXiPiPi);
DECLARE_SOA_TABLE(HfMlXicToXiPiPi, "AOD", "HFMLXICTOXI2PI", //!
hf_sel_candidate_xic::MlProbXicToXiPiPi);
hf_sel_candidate_xic::MlProbXicToXiPiPi);

namespace hf_sel_candidate_xicc
{
Expand Down
25 changes: 12 additions & 13 deletions PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "Common/Core/TrackSelectorPID.h"

#include "PWGHF/Core/HfMlResponseXicToXiPiPi.h"
#include "PWGHF/Core/HfMlResponseXicToXiPiPi.h"
#include "PWGHF/Core/SelectorCuts.h"
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
#include "PWGHF/DataModel/CandidateSelectionTables.h"
Expand All @@ -33,7 +33,7 @@ using namespace o2::analysis;

struct HfCandidateSelectorXicToXiPiPi {
Produces<aod::HfSelXicToXiPiPi> hfSelXicToXiPiPiCandidate;
Produces<aod::HfMlXicToXiPiPi> hfMlXicToXiPiPiCandidate;
Produces<aod::HfMlXicToXiPiPi> hfMlXicToXiPiPiCandidate;

Configurable<float> ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"};
Configurable<float> ptCandMax{"ptCandMax", 36., "Upper bound of candidate pT"};
Expand Down Expand Up @@ -70,8 +70,8 @@ struct HfCandidateSelectorXicToXiPiPi {
Configurable<bool> loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"};

o2::analysis::HfMlResponseXicToXiPiPi<float> hfMlResponse;
std::vector<float> outputMlXicToXiPiPi = {};
o2::ccdb::CcdbApi ccdbApi;
std::vector<float> outputMlXicToXiPiPi = {};
o2::ccdb::CcdbApi ccdbApi;
TrackSelectorPi selectorPion;
TrackSelectorPr selectorProton;

Expand Down Expand Up @@ -124,7 +124,6 @@ struct HfCandidateSelectorXicToXiPiPi {
hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures);
hfMlResponse.init();
}

}

/// Conjugate-independent topological cuts
Expand Down Expand Up @@ -238,7 +237,7 @@ struct HfCandidateSelectorXicToXiPiPi {
// topological cuts
if (!selectionTopol(hfCandXic)) {
hfSelXicToXiPiPiCandidate(statusXicToXiPiPi);
if(applyMl){
if (applyMl) {
hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi);
}
continue;
Expand Down Expand Up @@ -271,7 +270,7 @@ struct HfCandidateSelectorXicToXiPiPi {

if (!selectionPid(pidTrackPi0, pidTrackPi1, pidTrackPr, pidTrackPiLam, pidTrackPiXi, acceptPIDNotApplicable.value)) {
hfSelXicToXiPiPiCandidate(statusXicToXiPiPi);
if(applyMl){
if (applyMl) {
hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi);
}
continue;
Expand All @@ -284,20 +283,20 @@ struct HfCandidateSelectorXicToXiPiPi {

// ML selections

if(applyMl){
bool isSelectedMlXicToXiPiPi = false;
if (applyMl) {
bool isSelectedMlXicToXiPiPi = false;
std::vector<float> inputFeaturesXicToXiPiPi = hfMlResponse.getInputFeatures(hfCandXic);

isSelectedMlXicToXiPiPi = hfMlResponse.isSelectedMl(inputFeaturesXicToXiPiPi, ptCandXic, outputMlXicToXiPiPi);

hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi);

if(!isSelectedMlXicToXiPiPi){
hfSelXicToXiPiPiCandidate(statusXicToXiPiPi);
continue;
if (!isSelectedMlXicToXiPiPi) {
hfSelXicToXiPiPiCandidate(statusXicToXiPiPi);
continue;
}
SETBIT(statusXicToXiPiPi, aod::SelectionStep::RecoMl);
}
}

hfSelXicToXiPiPiCandidate(statusXicToXiPiPi);
}
Expand Down
Loading