Skip to content

Commit fa068eb

Browse files
INFNuserINFNuser
authored andcommitted
Code review of AE inclusion
1 parent 0107b3a commit fa068eb

2 files changed

Lines changed: 28 additions & 17 deletions

File tree

PWGHF/Core/HfAeToMseXicToPKPi.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
// Copyright 2020-2022 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
112
/// \file HfAeToMseXicToPKPi.h
213
/// \brief Class to compute the mse for the Autoencoder for Xic+ → p K- π+ analysis selections
314
/// \author Maria Teresa Camerlingo
@@ -13,13 +24,13 @@ namespace o2::analysis
1324
template <typename TypeOutputScore = float>
1425
class HfAeToMseXicToPKPi : public HfMlResponse<TypeOutputScore>
1526
{
16-
public:
27+
public:
1728
/// Default constructor
18-
HfAeToMseXicToPKPi() = default;
19-
/// Default destructor
20-
virtual ~HfAeToMseXicToPKPi() = default;
21-
22-
std::vector<float> yScaled, yOutRescaled;
29+
HfAeToMseXicToPKPi() = default;
30+
/// Default destructor
31+
virtual ~HfAeToMseXicToPKPi() = default;
32+
33+
std::vector<float> yScaled, yOutRescaled;
2334
//private :
2435
void setMinMaxScaling(std::vector<float>& yOut, std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
2536
{ yOut.clear();//initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
@@ -88,7 +99,7 @@ namespace o2::analysis
8899
}
89100
else{//MSE
90101
for (size_t j = 0; j < yPred.size(); ++j) { //for over the features
91-
sum += pow(((yTrueScaled).at(j) - (yPred).at(j)), 2); //has dimensions
102+
sum += std::pow(((yTrueScaled).at(j) - (yPred).at(j)), 2); //has dimensions
92103
LOG(debug)<<"getMse Local feature = "<<j<<" ----> input = "<<yTrueScaled.at(j)<<" AE prediction = "<< yPred.at(j);
93104
}
94105
mse = sum/yPred.size(); //MSE of a candidate

PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ struct HfCandidateSelectorXicToPKPi {
8787
Configurable<bool> applyMSE{"applyMSE", false, "Flag to calculate MSE for autoencoders"};
8888
Configurable<bool> applyMinMax{"applyMinMax", false, "Flag to MinMax feature preprocessing"};
8989
/// Parameter vectors for feature preprocessing - external scaling
90-
Configurable<std::vector<float>> ScaleMin{"ScaleMin", {0.,0.,0.}, "vector of scaling parameter min"};
91-
Configurable<std::vector<float>> ScaleMax{"ScaleMax", {1.,1.,1.}, "vector of scaling parameter max"};
90+
Configurable<std::vector<float>> scaleMin{"scaleMin", {0.,0.,0.}, "vector of scaling parameter min"};
91+
Configurable<std::vector<float>> scaleMax{"scaleMax", {1.,1.,1.}, "vector of scaling parameter max"};
9292
// CCDB configuration
9393
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
9494
Configurable<std::vector<std::string>> modelPathsCCDB{"modelPathsCCDB", std::vector<std::string>{"EventFiltering/PWGHF/BDTXic"}, "Paths of models on CCDB"};
@@ -414,25 +414,25 @@ struct HfCandidateSelectorXicToPKPi {
414414
isSelectedMlXicToPKPi = hfMlResponse.isSelectedMl(inputFeaturesXicToPKPi, ptCand, outputMlXicToPKPi);
415415
if(applyMSE){
416416
/// fill outputAeXicToPKPi with rescaled AE output since ML output is automatically scaled
417-
hfAeResponse.unsetScaling(applyMSE, scaleType, outputMlXicToPKPi, ScaleMin, ScaleMax);
417+
hfAeResponse.unsetScaling(applyMSE, scaleType, outputMlXicToPKPi, scaleMin, scaleMax);
418418
outputAeXicToPKPi = hfAeResponse.getPostprocessedOutput();
419419
/// fill outputMSEXicToPKPi vector with MSE
420-
hfAeResponse.setScaling(applyMSE, scaleType, inputFeaturesXicToPKPi, ScaleMin, ScaleMax);
421-
float MsePKPi = hfAeResponse.getMse(inputFeaturesXicToPKPi, outputMlXicToPKPi); /// args are not-scaled input, automatically scaled ML output
422-
outputMseXicToPKPi.push_back(MsePKPi);
420+
hfAeResponse.setScaling(applyMSE, scaleType, inputFeaturesXicToPKPi, scaleMin, scaleMax);
421+
float msePKPi = hfAeResponse.getMse(inputFeaturesXicToPKPi, outputMlXicToPKPi); /// args are not-scaled input, automatically scaled ML output
422+
outputMseXicToPKPi.push_back(msePKPi);
423423
}
424424
}
425425
if (topolXicToPiKP && pidXicToPiKP) {
426426
std::vector<float> inputFeaturesXicToPiKP = hfMlResponse.getInputFeatures(candidate, false);
427427
isSelectedMlXicToPiKP = hfMlResponse.isSelectedMl(inputFeaturesXicToPiKP, ptCand, outputMlXicToPiKP);
428428
if(applyMSE){
429429
/// fill outputAeXicToPiKP with rescaled AE output since ML output is automatically scaled
430-
hfAeResponse.unsetScaling(applyMSE, scaleType, outputMlXicToPiKP, ScaleMin, ScaleMax);
430+
hfAeResponse.unsetScaling(applyMSE, scaleType, outputMlXicToPiKP, scaleMin, scaleMax);
431431
outputAeXicToPiKP = hfAeResponse.getPostprocessedOutput();
432432
/// fill outputMSEXicToPiKP vector with MSE
433-
hfAeResponse.setScaling(applyMSE, scaleType, inputFeaturesXicToPiKP, ScaleMin, ScaleMax);
434-
float MsePiKP = hfAeResponse.getMse(inputFeaturesXicToPiKP, outputMlXicToPiKP); /// args are not-scaled input, automatically scaled ML output
435-
outputMseXicToPiKP.push_back(MsePiKP);
433+
hfAeResponse.setScaling(applyMSE, scaleType, inputFeaturesXicToPiKP, scaleMin, scaleMax);
434+
float msePiKP = hfAeResponse.getMse(inputFeaturesXicToPiKP, outputMlXicToPiKP); /// args are not-scaled input, automatically scaled ML output
435+
outputMseXicToPiKP.push_back(msePiKP);
436436
}
437437
}
438438

0 commit comments

Comments
 (0)