Skip to content

Commit eb1299e

Browse files
author
Isabel Kantak
committed
Update Configurable for ML based photon cuts and add Configurable for selecting centrality variable for 2D ML model selection.
1 parent 9ec7555 commit eb1299e

File tree

6 files changed

+177
-38
lines changed

6 files changed

+177
-38
lines changed

PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,20 @@ struct Pi0EtaToGammaGamma {
143143
o2::framework::Configurable<bool> cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"};
144144

145145
o2::framework::Configurable<bool> cfg_apply_ml_cuts{"cfg_apply_ml", false, "flag to apply ML cut"};
146-
o2::framework::Configurable<bool> cfg_use_2d_binning{"cfg_use_2d_binning", true, "flag to use 2D binning (pT, cent)"};
146+
o2::framework::Configurable<bool> cfg_use_2d_binning{"cfg_use_2d_binning", false, "flag to use 2D binning (pT, cent)"};
147147
o2::framework::Configurable<bool> cfg_load_ml_models_from_ccdb{"cfg_load_ml_models_from_ccdb", true, "flag to load ML models from CCDB"};
148148
o2::framework::Configurable<int> cfg_timestamp_ccdb{"cfg_timestamp_ccdb", -1, "timestamp for CCDB"};
149149
o2::framework::Configurable<int> cfg_nclasses_ml{"cfg_nclasses_ml", static_cast<int>(o2::analysis::em_cuts_ml::NCutScores), "number of classes for ML"};
150+
o2::framework::Configurable<std::string> cfg_cent_type_ml{"cfg_cent_type_ml", "CentFT0C", "centrality type for 2D ML application: CentFT0C, CentFT0M, or CentFT0A"};
150151
o2::framework::Configurable<std::vector<int>> cfg_cut_dir_ml{"cfg_cut_dir_ml", std::vector<int>{o2::analysis::em_cuts_ml::vecCutDir}, "cut direction for ML"};
151152
o2::framework::Configurable<std::vector<std::string>> cfg_input_feature_names{"cfg_input_feature_names", std::vector<std::string>{"feature1", "feature2"}, "input feature names for ML models"};
152153
o2::framework::Configurable<std::vector<std::string>> cfg_model_paths_ccdb{"cfg_model_paths_ccdb", std::vector<std::string>{"path_ccdb/BDT_PCM/"}, "CCDB paths for ML models"};
153154
o2::framework::Configurable<std::vector<std::string>> cfg_onnx_file_names{"cfg_onnx_file_names", std::vector<std::string>{"ModelHandler_onnx_PCM.onnx"}, "ONNX file names for ML models"};
154-
o2::framework::Configurable<std::vector<double>> cfg_bins_pt_ml{"cfg_bins_pt_ml", std::vector<double>{o2::analysis::em_cuts_ml::vecBinsPt}, "pT bins for ML"};
155+
o2::framework::Configurable<std::vector<std::string>> cfg_labels_bins_ml{"cfg_labels_bins_ml", std::vector<std::string>{"bin 0", "bin 1"}, "Labels for bins"};
156+
o2::framework::Configurable<std::vector<std::string>> cfg_labels_cut_scores_ml{"cfg_labels_cut_scores_ml", std::vector<std::string>{o2::analysis::em_cuts_ml::labelsCutScore}, "Labels for cut scores"};
157+
o2::framework::Configurable<std::vector<double>> cfg_bins_pt_ml{"cfg_bins_pt_ml", std::vector<double>{0.0, +1e+10}, "pT bin limits for ML application"};
155158
o2::framework::Configurable<std::vector<double>> cfg_bins_cent_ml{"cfg_bins_cent_ml", std::vector<double>{o2::analysis::em_cuts_ml::vecBinsCent}, "centrality bins for ML"};
156-
o2::framework::Configurable<o2::framework::LabeledArray<double>> cfg_cuts_pcm_ml{"cfg_cuts_pcm_ml", {o2::analysis::em_cuts_ml::Cuts[0], o2::analysis::em_cuts_ml::NBinsPt, o2::analysis::em_cuts_ml::NCutScores, o2::analysis::em_cuts_ml::labelsPt, o2::analysis::em_cuts_ml::labelsCutScore}, "ML selections per pT bin"};
159+
o2::framework::Configurable<std::vector<double>> cfg_cuts_ml_flat{"cfg_cuts_ml_flat", {0.5}, "Flattened ML cuts: [bin0_score0, bin0_score1, ..., binN_scoreM]"};
157160
} pcmcuts;
158161

159162
DalitzEECut fDileptonCut;
@@ -435,6 +438,7 @@ struct Pi0EtaToGammaGamma {
435438
d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f);
436439
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG";
437440
}
441+
fV0PhotonCut.SetD_Bz(d_bz);
438442
mRunNumber = collision.runNumber();
439443
}
440444

@@ -504,13 +508,16 @@ struct Pi0EtaToGammaGamma {
504508
fV0PhotonCut.SetNClassesMl(pcmcuts.cfg_nclasses_ml);
505509
fV0PhotonCut.SetMlTimestampCCDB(pcmcuts.cfg_timestamp_ccdb);
506510
fV0PhotonCut.SetCcdbUrl(ccdburl);
511+
fV0PhotonCut.SetCentralityTypeMl(pcmcuts.cfg_cent_type_ml);
507512
fV0PhotonCut.SetCutDirMl(pcmcuts.cfg_cut_dir_ml);
508513
fV0PhotonCut.SetMlModelPathsCCDB(pcmcuts.cfg_model_paths_ccdb);
509514
fV0PhotonCut.SetMlOnnxFileNames(pcmcuts.cfg_onnx_file_names);
510515
fV0PhotonCut.SetBinsPtMl(pcmcuts.cfg_bins_pt_ml);
511516
fV0PhotonCut.SetBinsCentMl(pcmcuts.cfg_bins_cent_ml);
512-
fV0PhotonCut.SetCutsPCMMl(pcmcuts.cfg_cuts_pcm_ml);
517+
fV0PhotonCut.SetCutsMl(pcmcuts.cfg_cuts_ml_flat);
513518
fV0PhotonCut.SetNamesInputFeatures(pcmcuts.cfg_input_feature_names);
519+
fV0PhotonCut.SetLabelsBinsMl(pcmcuts.cfg_labels_bins_ml);
520+
fV0PhotonCut.SetLabelsCutScoresMl(pcmcuts.cfg_labels_cut_scores_ml);
514521

515522
if (pcmcuts.cfg_apply_ml_cuts) {
516523
fV0PhotonCut.initV0MlModels(ccdbApi);
@@ -695,8 +702,7 @@ struct Pi0EtaToGammaGamma {
695702
{
696703
for (const auto& collision : collisions) {
697704
initCCDB(collision);
698-
fV0PhotonCut.SetCentrality(collision.centFT0M());
699-
fV0PhotonCut.SetD_Bz(d_bz);
705+
fV0PhotonCut.SetCentrality(collision.centFT0A(), collision.centFT0C(), collision.centFT0M());
700706
int ndiphoton = 0;
701707
if ((pairtype == o2::aod::pwgem::photonmeson::photonpair::PairType::kPHOSPHOS || pairtype == o2::aod::pwgem::photonmeson::photonpair::PairType::kPCMPHOS) && !collision.alias_bit(triggerAliases::kTVXinPHOS)) {
702708
continue;

PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,20 @@ struct Pi0EtaToGammaGammaMC {
132132
o2::framework::Configurable<bool> cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"};
133133

134134
o2::framework::Configurable<bool> cfg_apply_ml_cuts{"cfg_apply_ml", false, "flag to apply ML cut"};
135-
o2::framework::Configurable<bool> cfg_use_2d_binning{"cfg_use_2d_binning", true, "flag to use 2D binning (pT, cent)"};
135+
o2::framework::Configurable<bool> cfg_use_2d_binning{"cfg_use_2d_binning", false, "flag to use 2D binning (pT, cent)"};
136136
o2::framework::Configurable<bool> cfg_load_ml_models_from_ccdb{"cfg_load_ml_models_from_ccdb", true, "flag to load ML models from CCDB"};
137137
o2::framework::Configurable<int> cfg_timestamp_ccdb{"cfg_timestamp_ccdb", -1, "timestamp for CCDB"};
138138
o2::framework::Configurable<int> cfg_nclasses_ml{"cfg_nclasses_ml", static_cast<int>(o2::analysis::em_cuts_ml::NCutScores), "number of classes for ML"};
139+
o2::framework::Configurable<std::string> cfg_cent_type_ml{"cfg_cent_type_ml", "CentFT0C", "centrality type for 2D ML application: CentFT0C, CentFT0M, or CentFT0A"};
139140
o2::framework::Configurable<std::vector<int>> cfg_cut_dir_ml{"cfg_cut_dir_ml", std::vector<int>{o2::analysis::em_cuts_ml::vecCutDir}, "cut direction for ML"};
140141
o2::framework::Configurable<std::vector<std::string>> cfg_input_feature_names{"cfg_input_feature_names", std::vector<std::string>{"feature1", "feature2"}, "input feature names for ML models"};
141142
o2::framework::Configurable<std::vector<std::string>> cfg_model_paths_ccdb{"cfg_model_paths_ccdb", std::vector<std::string>{"path_ccdb/BDT_PCM/"}, "CCDB paths for ML models"};
142143
o2::framework::Configurable<std::vector<std::string>> cfg_onnx_file_names{"cfg_onnx_file_names", std::vector<std::string>{"ModelHandler_onnx_PCM.onnx"}, "ONNX file names for ML models"};
143-
o2::framework::Configurable<std::vector<double>> cfg_bins_pt_ml{"cfg_bins_pt_ml", std::vector<double>{o2::analysis::em_cuts_ml::vecBinsPt}, "pT bins for ML"};
144+
o2::framework::Configurable<std::vector<std::string>> cfg_labels_bins_ml{"cfg_labels_bins_ml", std::vector<std::string>{"bin 0", "bin 1"}, "Labels for bins"};
145+
o2::framework::Configurable<std::vector<std::string>> cfg_labels_cut_scores_ml{"cfg_labels_cut_scores_ml", std::vector<std::string>{o2::analysis::em_cuts_ml::labelsCutScore}, "Labels for cut scores"};
146+
o2::framework::Configurable<std::vector<double>> cfg_bins_pt_ml{"cfg_bins_pt_ml", std::vector<double>{0.0, +1e+10}, "pT bin limits for ML application"};
144147
o2::framework::Configurable<std::vector<double>> cfg_bins_cent_ml{"cfg_bins_cent_ml", std::vector<double>{o2::analysis::em_cuts_ml::vecBinsCent}, "centrality bins for ML"};
145-
o2::framework::Configurable<o2::framework::LabeledArray<double>> cfg_cuts_pcm_ml{"cfg_cuts_pcm_ml", {o2::analysis::em_cuts_ml::Cuts[0], o2::analysis::em_cuts_ml::NBinsPt, o2::analysis::em_cuts_ml::NCutScores, o2::analysis::em_cuts_ml::labelsPt, o2::analysis::em_cuts_ml::labelsCutScore}, "ML selections per pT bin"};
148+
o2::framework::Configurable<std::vector<double>> cfg_cuts_ml_flat{"cfg_cuts_ml_flat", {0.5}, "Flattened ML cuts: [bin0_score0, bin0_score1, ..., binN_scoreM]"};
146149
} pcmcuts;
147150

148151
DalitzEECut fDileptonCut;
@@ -283,6 +286,7 @@ struct Pi0EtaToGammaGammaMC {
283286
d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f);
284287
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG";
285288
}
289+
fV0PhotonCut.SetD_Bz(d_bz);
286290
mRunNumber = collision.runNumber();
287291
}
288292

@@ -344,13 +348,16 @@ struct Pi0EtaToGammaGammaMC {
344348
fV0PhotonCut.SetNClassesMl(pcmcuts.cfg_nclasses_ml);
345349
fV0PhotonCut.SetMlTimestampCCDB(pcmcuts.cfg_timestamp_ccdb);
346350
fV0PhotonCut.SetCcdbUrl(ccdburl);
351+
fV0PhotonCut.SetCentralityTypeMl(pcmcuts.cfg_cent_type_ml);
347352
fV0PhotonCut.SetCutDirMl(pcmcuts.cfg_cut_dir_ml);
348353
fV0PhotonCut.SetMlModelPathsCCDB(pcmcuts.cfg_model_paths_ccdb);
349354
fV0PhotonCut.SetMlOnnxFileNames(pcmcuts.cfg_onnx_file_names);
350355
fV0PhotonCut.SetBinsPtMl(pcmcuts.cfg_bins_pt_ml);
351356
fV0PhotonCut.SetBinsCentMl(pcmcuts.cfg_bins_cent_ml);
352-
fV0PhotonCut.SetCutsPCMMl(pcmcuts.cfg_cuts_pcm_ml);
357+
fV0PhotonCut.SetCutsMl(pcmcuts.cfg_cuts_ml_flat);
353358
fV0PhotonCut.SetNamesInputFeatures(pcmcuts.cfg_input_feature_names);
359+
fV0PhotonCut.SetLabelsBinsMl(pcmcuts.cfg_labels_bins_ml);
360+
fV0PhotonCut.SetLabelsCutScoresMl(pcmcuts.cfg_labels_cut_scores_ml);
354361

355362
if (pcmcuts.cfg_apply_ml_cuts) {
356363
fV0PhotonCut.initV0MlModels(ccdbApi);
@@ -553,8 +560,7 @@ struct Pi0EtaToGammaGammaMC {
553560
{
554561
for (auto& collision : collisions) {
555562
initCCDB(collision);
556-
fV0PhotonCut.SetCentrality(collision.centFT0M());
557-
fV0PhotonCut.SetD_Bz(d_bz);
563+
fV0PhotonCut.SetCentrality(collision.centFT0A(), collision.centFT0C(), collision.centFT0M());
558564
if ((pairtype == o2::aod::pwgem::photonmeson::photonpair::PairType::kPHOSPHOS || pairtype == o2::aod::pwgem::photonmeson::photonpair::PairType::kPCMPHOS) && !collision.alias_bit(triggerAliases::kTVXinPHOS)) {
559565
continue;
560566
}

PWGEM/PhotonMeson/Core/V0PhotonCandidate.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ struct V0PhotonCandidate {
4848
float psipair;
4949
float cospa;
5050
float chi2ndf;
51-
float centrality;
51+
float centFT0M;
52+
float centFT0C;
53+
float centFT0A;
5254
float pca;
5355

5456
public:
@@ -89,11 +91,13 @@ struct V0PhotonCandidate {
8991
phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(posPx, posPy, posPz, elePx, elePy, elePz, posSign, eleSign, d_bz);
9092
psipair = o2::aod::pwgem::dilepton::utils::pairutil::getPsiPair(posPx, posPy, posPz, elePx, elePy, elePz);
9193

92-
centrality = collision.centFT0M();
94+
centFT0M = collision.centFT0M();
95+
centFT0C = collision.centFT0C();
96+
centFT0A = collision.centFT0A();
9397
}
9498

9599
// Constructor for V0PhotonCut
96-
V0PhotonCandidate(const auto& v0, const auto& pos, const auto& ele, float cent, float d_bz) : centrality(cent)
100+
V0PhotonCandidate(const auto& v0, const auto& pos, const auto& ele, float centFT0A, float centFT0C, float centFT0M, float d_bz) : centFT0A(centFT0A), centFT0C(centFT0C), centFT0M(centFT0M)
97101
{
98102
px = v0.px();
99103
py = v0.py();
@@ -144,7 +148,9 @@ struct V0PhotonCandidate {
144148
float GetElePx() const { return elePx; }
145149
float GetElePy() const { return elePy; }
146150
float GetElePz() const { return elePz; }
147-
float GetCent() const { return centrality; }
151+
float GetCentFT0M() const { return centFT0M; }
152+
float GetCentFT0C() const { return centFT0C; }
153+
float GetCentFT0A() const { return centFT0A; }
148154
float GetPCA() const { return pca; }
149155
};
150156

PWGEM/PhotonMeson/Core/V0PhotonCut.cxx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ void V0PhotonCut::SetBinsCentMl(const std::vector<double>& binsCent)
297297
LOG(info) << "V0 Photon Cut, set bins centrality ML with size:" << mBinsCentMl.size();
298298
}
299299

300-
void V0PhotonCut::SetCutsPCMMl(const o2::framework::LabeledArray<double>& cuts)
300+
void V0PhotonCut::SetCutsMl(const std::vector<double>& cuts)
301301
{
302-
mCutsPCMMl = cuts;
303-
LOG(info) << "V0 Photon Cut, set cuts PCM ML";
302+
mCutsMlFlat = cuts;
303+
LOG(info) << "V0 Photon Cut, set cuts ML with size:" << mCutsMlFlat.size();
304304
}
305305

306306
void V0PhotonCut::SetNClassesMl(int nClasses)
@@ -315,9 +315,11 @@ void V0PhotonCut::SetNamesInputFeatures(const std::vector<std::string>& featureN
315315
LOG(info) << "V0 Photon Cut, set ML input feature names with size:" << mNamesInputFeatures.size();
316316
}
317317

318-
void V0PhotonCut::SetCentrality(float cent)
318+
void V0PhotonCut::SetCentrality(float centFT0A, float centFT0C, float centFT0M)
319319
{
320-
mCent = cent;
320+
mCentFT0A = centFT0A;
321+
mCentFT0C = centFT0C;
322+
mCentFT0M = centFT0M;
321323
}
322324
void V0PhotonCut::SetD_Bz(float d_bz)
323325
{
@@ -329,3 +331,21 @@ void V0PhotonCut::SetCutDirMl(const std::vector<int>& cutDirMl)
329331
mCutDirMl = cutDirMl;
330332
LOG(info) << "V0 Photon Cut, set ML cut directions with size:" << mCutDirMl.size();
331333
}
334+
335+
void V0PhotonCut::SetCentralityTypeMl(const std::string& centType)
336+
{
337+
mCentralityTypeMl = centType;
338+
LOG(info) << "V0 Photon Cut, set centrality type ML: " << mCentralityTypeMl;
339+
}
340+
341+
void V0PhotonCut::SetLabelsBinsMl(const std::vector<std::string>& labelsBins)
342+
{
343+
mLabelsBinsMl = labelsBins;
344+
LOG(info) << "V0 Photon Cut, set ML labels bins with size:" << mLabelsBinsMl.size();
345+
}
346+
347+
void V0PhotonCut::SetLabelsCutScoresMl(const std::vector<std::string>& labelsCutScores)
348+
{
349+
mLabelsCutScoresMl = labelsCutScores;
350+
LOG(info) << "V0 Photon Cut, set ML labels cut scores with size:" << mLabelsCutScoresMl.size();
351+
}

0 commit comments

Comments
 (0)