Skip to content

Commit f90b771

Browse files
committed
apply comments
1 parent 6516a47 commit f90b771

File tree

3 files changed

+42
-40
lines changed

3 files changed

+42
-40
lines changed

PWGDQ/Core/VarManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5531,6 +5531,8 @@ float VarManager::calculatePhiV(T1 const& t1, T2 const& t2)
55315531
return pairPhiV;
55325532
}
55335533

5534+
/// Fill BDT score values.
5535+
/// Supports binary (1 output) and multiclass (3 outputs) models.
55345536
template <typename T1>
55355537
void VarManager::FillBdtScore(T1 const& bdtScore, float* values)
55365538
{

PWGDQ/Tasks/tableReader.cxx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ struct AnalysisSameEventPairing {
10571057
Configurable<std::string> fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"};
10581058
// ML inference
10591059
Configurable<bool> applyBDT{"applyBDT", false, "Flag to apply ML selections"};
1060-
Configurable<string> fConfigBdtCutsJSON{"fConfigBdtCutsJSON", "", "Additional list of BDT cuts in JSON format"};
1060+
Configurable<std::string> fConfigBdtCutsJSON{"fConfigBdtCutsJSON", "", "Additional list of BDT cuts in JSON format"};
10611061
Configurable<std::vector<std::string>> modelPathsCCDB{"modelPathsCCDB", std::vector<std::string>{"Users/j/jseo/ML/PbPbPsi/default/"}, "Paths of models on CCDB"};
10621062
Configurable<int64_t> timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"};
10631063
Configurable<bool> loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"};
@@ -1078,8 +1078,8 @@ struct AnalysisSameEventPairing {
10781078

10791079
HistogramManager* fHistMan;
10801080

1081-
o2::analysis::DQMlResponse<float> dqMlResponse;
1082-
std::vector<float> outputMlPsi2ee = {}; // TODO: check this is needed or not
1081+
o2::analysis::DQMlResponse<float> fDQMlResponse;
1082+
std::vector<float> fOutputMlPsi2ee = {}; // TODO: check this is needed or not
10831083
o2::ccdb::CcdbApi ccdbApi;
10841084

10851085
// NOTE: The track filter produced by the barrel track selection contain a number of electron cut decisions and one last cut for hadrons used in the
@@ -1151,9 +1151,9 @@ struct AnalysisSameEventPairing {
11511151
cutDirMl = cfg.cutDirs;
11521152
namesInputFeatures = cfg.inputFeatures;
11531153
onnxFileNames = cfg.onnxFiles;
1154-
dqMlResponse.setBinsCent(cfg.binsCent);
1155-
dqMlResponse.setBinsPt(cfg.binsPt);
1156-
dqMlResponse.setCentType(cfg.centType);
1154+
fDQMlResponse.setBinsCent(cfg.binsCent);
1155+
fDQMlResponse.setBinsPt(cfg.binsPt);
1156+
fDQMlResponse.setCentType(cfg.centType);
11571157
LOG(info) << "Using BDT cuts for binary classification";
11581158
} else {
11591159
auto& cfg = std::get<dqmlcuts::MultiClassBdtScoreConfig>(config);
@@ -1163,21 +1163,21 @@ struct AnalysisSameEventPairing {
11631163
cutDirMl = cfg.cutDirs;
11641164
namesInputFeatures = cfg.inputFeatures;
11651165
onnxFileNames = cfg.onnxFiles;
1166-
dqMlResponse.setBinsCent(cfg.binsCent);
1167-
dqMlResponse.setBinsPt(cfg.binsPt);
1168-
dqMlResponse.setCentType(cfg.centType);
1166+
fDQMlResponse.setBinsCent(cfg.binsCent);
1167+
fDQMlResponse.setBinsPt(cfg.binsPt);
1168+
fDQMlResponse.setCentType(cfg.centType);
11691169
LOG(info) << "Using BDT cuts for multiclass classification";
11701170
}
11711171

1172-
dqMlResponse.configure(binsMl, cutsMl, cutDirMl, nClassesMl);
1172+
fDQMlResponse.configure(binsMl, cutsMl, cutDirMl, nClassesMl);
11731173
if (loadModelsFromCCDB) {
11741174
ccdbApi.init(ccdburl);
1175-
dqMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB);
1175+
fDQMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB);
11761176
} else {
1177-
dqMlResponse.setModelPathsLocal(onnxFileNames);
1177+
fDQMlResponse.setModelPathsLocal(onnxFileNames);
11781178
}
1179-
dqMlResponse.cacheInputFeaturesIndices(namesInputFeatures);
1180-
dqMlResponse.init();
1179+
fDQMlResponse.cacheInputFeaturesIndices(namesInputFeatures);
1180+
fDQMlResponse.init();
11811181
}
11821182

11831183
if (context.mOptions.get<bool>("processDecayToEESkimmed") || context.mOptions.get<bool>("processDecayToEESkimmedNoTwoProngFitter") || context.mOptions.get<bool>("processDecayToEESkimmedWithCov") || context.mOptions.get<bool>("processDecayToEESkimmedWithCovNoTwoProngFitter") || context.mOptions.get<bool>("processDecayToEEVertexingSkimmed") || context.mOptions.get<bool>("processVnDecayToEESkimmed") || context.mOptions.get<bool>("processDecayToEEPrefilterSkimmed") || context.mOptions.get<bool>("processDecayToEEPrefilterSkimmedNoTwoProngFitter") || context.mOptions.get<bool>("processDecayToEESkimmedWithColl") || context.mOptions.get<bool>("processDecayToEESkimmedWithCollNoTwoProngFitter") || context.mOptions.get<bool>("processDecayToPiPiSkimmed") || context.mOptions.get<bool>("processAllSkimmed")) {
@@ -1457,17 +1457,17 @@ struct AnalysisSameEventPairing {
14571457
}
14581458
if constexpr ((TPairType == pairTypeEE) && (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelPID) > 0) {
14591459
if (applyBDT) {
1460-
std::vector<float> dqInputFeatures = dqMlResponse.getInputFeatures(t1, t2, VarManager::fgValues);
1460+
std::vector<float> dqInputFeatures = fDQMlResponse.getInputFeatures(t1, t2, VarManager::fgValues);
14611461

14621462
if (dqInputFeatures.empty()) {
14631463
LOG(fatal) << "Input features for ML selection are empty! Please check your configuration.";
14641464
return;
14651465
}
14661466

14671467
int modelIndex = -1;
1468-
const auto& binsCent = dqMlResponse.getBinsCent();
1469-
const auto& binsPt = dqMlResponse.getBinsPt();
1470-
const std::string& centType = dqMlResponse.getCentType();
1468+
const auto& binsCent = fDQMlResponse.getBinsCent();
1469+
const auto& binsPt = fDQMlResponse.getBinsPt();
1470+
const std::string& centType = fDQMlResponse.getCentType();
14711471

14721472
if ("kCentFT0C" == centType) {
14731473
modelIndex = o2::aod::dqmlcuts::getMlBinIndex(VarManager::fgValues[VarManager::kCentFT0C], VarManager::fgValues[VarManager::kPt], binsCent, binsPt);
@@ -1486,8 +1486,8 @@ struct AnalysisSameEventPairing {
14861486
}
14871487

14881488
LOG(debug) << "Model index: " << modelIndex << ", pT: " << VarManager::fgValues[VarManager::kPt] << ", centrality (kCentFT0C): " << VarManager::fgValues[VarManager::kCentFT0C];
1489-
isSelectedBDT = dqMlResponse.isSelectedMl(dqInputFeatures, modelIndex, outputMlPsi2ee);
1490-
VarManager::FillBdtScore(outputMlPsi2ee); // TODO: check if this is needed or not
1489+
isSelectedBDT = fDQMlResponse.isSelectedMl(dqInputFeatures, modelIndex, fOutputMlPsi2ee);
1490+
VarManager::FillBdtScore(fOutputMlPsi2ee); // TODO: check if this is needed or not
14911491
}
14921492

14931493
if (applyBDT && !isSelectedBDT)

PWGDQ/Tasks/tableReader_withAssoc.cxx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ struct AnalysisSameEventPairing {
12491249
} fConfigOptions;
12501250
struct : ConfigurableGroup {
12511251
Configurable<bool> applyBDT{"applyBDT", false, "Flag to apply ML selections"};
1252-
Configurable<string> fConfigBdtCutsJSON{"fConfigBdtCutsJSON", "", "Additional list of BDT cuts in JSON format"};
1252+
Configurable<std::string> fConfigBdtCutsJSON{"fConfigBdtCutsJSON", "", "Additional list of BDT cuts in JSON format"};
12531253

12541254
Configurable<std::vector<std::string>> modelPathsCCDB{"modelPathsCCDB", std::vector<std::string>{"Users/j/jseo/ML/PbPbPsi/default/"}, "Paths of models on CCDB"};
12551255
Configurable<int64_t> timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"};
@@ -1263,8 +1263,8 @@ struct AnalysisSameEventPairing {
12631263

12641264
HistogramManager* fHistMan;
12651265

1266-
o2::analysis::DQMlResponse<float> dqMlResponse;
1267-
std::vector<float> outputMlPsi2ee = {}; // TODO: check this is needed or not
1266+
o2::analysis::DQMlResponse<float> fDQMlResponse;
1267+
std::vector<float> fOutputMlPsi2ee = {}; // TODO: check this is needed or not
12681268

12691269
// keep histogram class names in maps, so we don't have to buld their names in the pair loops
12701270
std::map<int, std::vector<TString>> fTrackHistNames;
@@ -1352,9 +1352,9 @@ struct AnalysisSameEventPairing {
13521352
cutDirMl = cfg.cutDirs;
13531353
namesInputFeatures = cfg.inputFeatures;
13541354
onnxFileNames = cfg.onnxFiles;
1355-
dqMlResponse.setBinsCent(cfg.binsCent);
1356-
dqMlResponse.setBinsPt(cfg.binsPt);
1357-
dqMlResponse.setCentType(cfg.centType);
1355+
fDQMlResponse.setBinsCent(cfg.binsCent);
1356+
fDQMlResponse.setBinsPt(cfg.binsPt);
1357+
fDQMlResponse.setCentType(cfg.centType);
13581358
LOG(info) << "Using BDT cuts for binary classification";
13591359
} else {
13601360
auto& cfg = std::get<dqmlcuts::MultiClassBdtScoreConfig>(config);
@@ -1364,21 +1364,21 @@ struct AnalysisSameEventPairing {
13641364
cutDirMl = cfg.cutDirs;
13651365
namesInputFeatures = cfg.inputFeatures;
13661366
onnxFileNames = cfg.onnxFiles;
1367-
dqMlResponse.setBinsCent(cfg.binsCent);
1368-
dqMlResponse.setBinsPt(cfg.binsPt);
1369-
dqMlResponse.setCentType(cfg.centType);
1367+
fDQMlResponse.setBinsCent(cfg.binsCent);
1368+
fDQMlResponse.setBinsPt(cfg.binsPt);
1369+
fDQMlResponse.setCentType(cfg.centType);
13701370
LOG(info) << "Using BDT cuts for multiclass classification";
13711371
}
13721372

1373-
dqMlResponse.configure(binsMl, cutsMl, cutDirMl, nClassesMl);
1373+
fDQMlResponse.configure(binsMl, cutsMl, cutDirMl, nClassesMl);
13741374
if (fConfigML.loadModelsFromCCDB) {
13751375
fCCDBApi.init(fConfigCCDB.url);
1376-
dqMlResponse.setModelPathsCCDB(onnxFileNames, fCCDBApi, fConfigML.modelPathsCCDB, fConfigML.timestampCCDB);
1376+
fDQMlResponse.setModelPathsCCDB(onnxFileNames, fCCDBApi, fConfigML.modelPathsCCDB, fConfigML.timestampCCDB);
13771377
} else {
1378-
dqMlResponse.setModelPathsLocal(onnxFileNames);
1378+
fDQMlResponse.setModelPathsLocal(onnxFileNames);
13791379
}
1380-
dqMlResponse.cacheInputFeaturesIndices(namesInputFeatures);
1381-
dqMlResponse.init();
1380+
fDQMlResponse.cacheInputFeaturesIndices(namesInputFeatures);
1381+
fDQMlResponse.init();
13821382
}
13831383

13841384
// get the barrel track selection cuts
@@ -1769,17 +1769,17 @@ struct AnalysisSameEventPairing {
17691769
dielectronsExtraList(t1.globalIndex(), t2.globalIndex(), VarManager::fgValues[VarManager::kVertexingTauzProjected], VarManager::fgValues[VarManager::kVertexingLzProjected], VarManager::fgValues[VarManager::kVertexingLxyProjected]);
17701770
if constexpr ((TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelPID) > 0) {
17711771
if (fConfigML.applyBDT) {
1772-
std::vector<float> dqInputFeatures = dqMlResponse.getInputFeatures(t1, t2, VarManager::fgValues);
1772+
std::vector<float> dqInputFeatures = fDQMlResponse.getInputFeatures(t1, t2, VarManager::fgValues);
17731773

17741774
if (dqInputFeatures.empty()) {
17751775
LOG(fatal) << "Input features for ML selection are empty! Please check your configuration.";
17761776
return;
17771777
}
17781778

17791779
int modelIndex = -1;
1780-
const auto& binsCent = dqMlResponse.getBinsCent();
1781-
const auto& binsPt = dqMlResponse.getBinsPt();
1782-
const std::string& centType = dqMlResponse.getCentType();
1780+
const auto& binsCent = fDQMlResponse.getBinsCent();
1781+
const auto& binsPt = fDQMlResponse.getBinsPt();
1782+
const std::string& centType = fDQMlResponse.getCentType();
17831783

17841784
if ("kCentFT0C" == centType) {
17851785
modelIndex = o2::aod::dqmlcuts::getMlBinIndex(VarManager::fgValues[VarManager::kCentFT0C], VarManager::fgValues[VarManager::kPt], binsCent, binsPt);
@@ -1798,8 +1798,8 @@ struct AnalysisSameEventPairing {
17981798
}
17991799

18001800
LOG(debug) << "Model index: " << modelIndex << ", pT: " << VarManager::fgValues[VarManager::kPt] << ", centrality (kCentFT0C): " << VarManager::fgValues[VarManager::kCentFT0C];
1801-
isSelectedBDT = dqMlResponse.isSelectedMl(dqInputFeatures, modelIndex, outputMlPsi2ee);
1802-
VarManager::FillBdtScore(outputMlPsi2ee); // TODO: check if this is needed or not
1801+
isSelectedBDT = fDQMlResponse.isSelectedMl(dqInputFeatures, modelIndex, fOutputMlPsi2ee);
1802+
VarManager::FillBdtScore(fOutputMlPsi2ee); // TODO: check if this is needed or not
18031803
}
18041804

18051805
if (fConfigML.applyBDT && !isSelectedBDT)

0 commit comments

Comments
 (0)