Skip to content

Commit f3a65fa

Browse files
committed
Please consider the following formatting changes
1 parent 42b2f89 commit f3a65fa

4 files changed

Lines changed: 75 additions & 78 deletions

File tree

PWGHF/Core/HfAeToMseXicToPKPi.h

Lines changed: 66 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ namespace o2::analysis
2424
template <typename TypeOutputScore = float>
2525
class HfAeToMseXicToPKPi : public HfMlResponse<TypeOutputScore>
2626
{
27-
public:
27+
public:
2828
/// Default constructor
2929
HfAeToMseXicToPKPi() = default;
3030
/// Default destructor
3131
virtual ~HfAeToMseXicToPKPi() = default;
3232

3333
std::vector<float> yScaled, yOutRescaled;
34-
//private :
34+
// private :
3535
void setMinMaxScaling(std::vector<float>& yOut, std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
36-
{
37-
yOut.clear(); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
38-
for (size_t j = 0; j < yIn.size(); ++j){ // loop for over the features
36+
{
37+
yOut.clear(); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
38+
for (size_t j = 0; j < yIn.size(); ++j) { // loop for over the features
3939
// MinMax scaling of the input features
4040
LOG(debug) << "--------------> MinMax scaling Debug \t" << scaleMin.at(j) << "\t" << scaleMax.at(j);
41-
yOut.push_back((yIn.at(j) - scaleMin.at(j))/(scaleMax.at(j)- scaleMin.at(j)));
41+
yOut.push_back((yIn.at(j) - scaleMin.at(j)) / (scaleMax.at(j) - scaleMin.at(j)));
4242
LOG(debug) << "Feature = " << j << " ----> input = " << yIn.at(j) << " scaled feature = " << yOut.at(j);
4343
}
4444
}
@@ -53,73 +53,70 @@ class HfAeToMseXicToPKPi : public HfMlResponse<TypeOutputScore>
5353
if (scaleType == 1) {
5454
LOG(debug) << "MinMax scaling will be applied";
5555
setMinMaxScaling(yScaled, yIn, scaleMin, scaleMax);
56-
} // ... with scaleType > 1 we could add other preprocessing trasformations
57-
}
56+
} // ... with scaleType > 1 we could add other preprocessing trasformations
5857
}
59-
std::vector<float> getPreprocessedFeatures()
60-
{
61-
for (size_t j = 0; j < yScaled.size(); ++j)
62-
LOG(debug) << "Global scaled feature = " << yScaled.at(j);
63-
return yScaled;
58+
}
59+
std::vector<float> getPreprocessedFeatures()
60+
{
61+
for (size_t j = 0; j < yScaled.size(); ++j)
62+
LOG(debug) << "Global scaled feature = " << yScaled.at(j);
63+
return yScaled;
64+
}
65+
// Reverse preprocessing - output postprocessing
66+
void unsetMinMaxScaling(std::vector<float>& yOut, std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
67+
{
68+
yOut.clear(); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
69+
for (size_t j = 0; j < yIn.size(); ++j) { // loop for over the features
70+
// MinMax scaling of the input features
71+
LOG(debug) << "--------------> MinMax unscaling Debug \t" << scaleMin.at(j) << "\t" << scaleMax.at(j);
72+
yOut.push_back(yIn.at(j) * (scaleMax.at(j) - scaleMin.at(j)) + scaleMin.at(j));
73+
LOG(debug) << "Unscaling output = " << j << " ----> input = " << yIn.at(j) << " rescaled output = " << yOut.at(j);
6474
}
65-
// Reverse preprocessing - output postprocessing
66-
void unsetMinMaxScaling(std::vector<float>& yOut, std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
67-
{
68-
yOut.clear(); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
69-
for (size_t j = 0; j < yIn.size(); ++j){ // loop for over the features
70-
// MinMax scaling of the input features
71-
LOG(debug) << "--------------> MinMax unscaling Debug \t" << scaleMin.at(j) << "\t" << scaleMax.at(j);
72-
yOut.push_back(yIn.at(j)*(scaleMax.at(j)- scaleMin.at(j))+ scaleMin.at(j));
73-
LOG(debug) << "Unscaling output = " << j << " ----> input = " << yIn.at(j) << " rescaled output = " << yOut.at(j);
74-
}
75-
}
75+
}
7676

77-
void unsetScaling(bool scaleFlag, int scaleType, /*AE output*/ std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
78-
{ // it takes the bool flag and scaling parameters configurables in taskXic
79-
yOutRescaled.clear();
80-
if (scaleFlag == false) {
81-
LOG(debug) << "No external preprocessing transformation will be applied";
82-
yOutRescaled.assign(yIn.begin(), yIn.end());
83-
} else {
84-
if (scaleType == 1) {
85-
LOG(debug) << "MinMax unscaling will be applied";
86-
unsetMinMaxScaling(yOutRescaled, yIn, scaleMin, scaleMax);
87-
} //... with scaleType > 1 we could add other preprocessing trasformations
88-
}
89-
}
77+
void unsetScaling(bool scaleFlag, int scaleType, /*AE output*/ std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
78+
{ // it takes the bool flag and scaling parameters configurables in taskXic
79+
yOutRescaled.clear();
80+
if (scaleFlag == false) {
81+
LOG(debug) << "No external preprocessing transformation will be applied";
82+
yOutRescaled.assign(yIn.begin(), yIn.end());
83+
} else {
84+
if (scaleType == 1) {
85+
LOG(debug) << "MinMax unscaling will be applied";
86+
unsetMinMaxScaling(yOutRescaled, yIn, scaleMin, scaleMax);
87+
} //... with scaleType > 1 we could add other preprocessing trasformations
88+
}
89+
}
9090

91-
std::vector<float> getPostprocessedOutput()
92-
{
93-
for (size_t j = 0; j < yOutRescaled.size(); ++j)
94-
LOG(debug)<<"Global rescaled AE output = "<< yOutRescaled.at(j);
95-
return yOutRescaled;
96-
}
97-
//---- MSE function
98-
float getMse(std::vector<float> yTrue, std::vector<float> yPred)
99-
{
100-
LOG(debug) << "Inside getMse sizes " << yTrue.size() << "\t" << yPred.size();
101-
float mse= 0.0f;
102-
float sum = 0.0f;
103-
for (size_t j = 0; j < yTrue.size(); ++j)
104-
LOG(debug) << "Local Feature = " << j << " ----> input = " << yTrue.at(j) << " scaled feature = " << yPred.at(j);
105-
std::vector<float> yTrueScaled = getPreprocessedFeatures(); // to make the input features adimensional
106-
if (yTrue.size() != yPred.size())
107-
{
108-
LOG(debug) << "size of input vector =" << yTrue.size();
109-
LOG(debug) << "size of AE output vector =" << yPred.size();
110-
LOG(fatal) << "vectors of input and predictions don't have the same size";
111-
}
112-
else
113-
{ //MSE
114-
for (size_t j = 0; j < yPred.size(); ++j) {
115-
sum += std::pow(((yTrueScaled).at(j) - (yPred).at(j)), 2); //AE model gives adimensional predictions by design choice
116-
LOG(debug) << "getMse Local feature = " << j << " ----> input = " << yTrueScaled.at(j) << " AE prediction = " << yPred.at(j);
117-
}
118-
mse = sum/yPred.size(); // MSE of a candidate
119-
LOG(debug) << "Local mse " << mse;
120-
}
121-
return mse;
122-
}
91+
std::vector<float> getPostprocessedOutput()
92+
{
93+
for (size_t j = 0; j < yOutRescaled.size(); ++j)
94+
LOG(debug) << "Global rescaled AE output = " << yOutRescaled.at(j);
95+
return yOutRescaled;
96+
}
97+
//---- MSE function
98+
float getMse(std::vector<float> yTrue, std::vector<float> yPred)
99+
{
100+
LOG(debug) << "Inside getMse sizes " << yTrue.size() << "\t" << yPred.size();
101+
float mse = 0.0f;
102+
float sum = 0.0f;
103+
for (size_t j = 0; j < yTrue.size(); ++j)
104+
LOG(debug) << "Local Feature = " << j << " ----> input = " << yTrue.at(j) << " scaled feature = " << yPred.at(j);
105+
std::vector<float> yTrueScaled = getPreprocessedFeatures(); // to make the input features adimensional
106+
if (yTrue.size() != yPred.size()) {
107+
LOG(debug) << "size of input vector =" << yTrue.size();
108+
LOG(debug) << "size of AE output vector =" << yPred.size();
109+
LOG(fatal) << "vectors of input and predictions don't have the same size";
110+
} else { // MSE
111+
for (size_t j = 0; j < yPred.size(); ++j) {
112+
sum += std::pow(((yTrueScaled).at(j) - (yPred).at(j)), 2); // AE model gives adimensional predictions by design choice
113+
LOG(debug) << "getMse Local feature = " << j << " ----> input = " << yTrueScaled.at(j) << " AE prediction = " << yPred.at(j);
114+
}
115+
mse = sum / yPred.size(); // MSE of a candidate
116+
LOG(debug) << "Local mse " << mse;
117+
}
118+
return mse;
119+
}
123120
}; // end of the class
124121

125122
} // namespace o2::analysis

PWGHF/D2H/Tasks/taskXic.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ struct HfTaskXic {
8181
ConfigurableAxis thnConfigAxisBdtScoreBkg{"thnConfigAxisBdtScoreBkg", {100, 0., 1.}, ""};
8282
ConfigurableAxis thnConfigAxisBdtScoreSignal{"thnConfigAxisBdtScoreSignal", {100, 0., 1.}, ""};
8383
ConfigurableAxis thnConfigAxisYMC{"thnConfigAxisYMC", {100, -2., 2.}, ""};
84-
ConfigurableAxis thnConfigAxisMseXic{"thnConfigAxisMseXic", {502, -0.0002, 1}, ""}; // MSE axis
85-
ConfigurableAxis thnConfigAxisAeOutputXic{"thnConfigAxisAeOutputXic", {20, 0.8, 1},""}; // an AE output axis
84+
ConfigurableAxis thnConfigAxisMseXic{"thnConfigAxisMseXic", {502, -0.0002, 1}, ""}; // MSE axis
85+
ConfigurableAxis thnConfigAxisAeOutputXic{"thnConfigAxisAeOutputXic", {20, 0.8, 1}, ""}; // an AE output axis
8686
//
8787

8888
float etaMaxAcceptance = 0.8;
@@ -547,8 +547,8 @@ struct HfTaskXic {
547547
// add here the pT_Mother, y_Mother, level (reco, Gen, Gen + Acc)
548548
registry.get<THnSparse>(HIST("hnXicVarsWithBdt"))->Fill(massXicToPiKP, ptCandidate, outputBkg, outputPrompt, outputFD, origin);
549549
} else {
550-
outputAE = candidate.aeOutputXicToPiKP()[0]; /// AE output of feature 0
551-
outputMSE = candidate.mseXicToPiKP()[0]; /// MSE
550+
outputAE = candidate.aeOutputXicToPiKP()[0]; /// AE output of feature 0
551+
outputMSE = candidate.mseXicToPiKP()[0]; /// MSE
552552
registry.get<THnSparse>(HIST("hnXicVarsWithMse"))->Fill(massXicToPiKP, ptCandidate, candidate.decayLength(), candidate.cpa(), outputAE, origin, outputMSE);
553553
}
554554
} else {

PWGHF/DataModel/CandidateSelectionTables.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ DECLARE_SOA_COLUMN(IsSelXicToPKPi, isSelXicToPKPi, int); //!
314314
DECLARE_SOA_COLUMN(IsSelXicToPiKP, isSelXicToPiKP, int); //!
315315
DECLARE_SOA_COLUMN(MlProbXicToPKPi, mlProbXicToPKPi, std::vector<float>); //!
316316
DECLARE_SOA_COLUMN(MlProbXicToPiKP, mlProbXicToPiKP, std::vector<float>); //!
317-
DECLARE_SOA_COLUMN(MseXicToPKPi, mseXicToPKPi, std::vector<float>); //! new column for MSE
318-
DECLARE_SOA_COLUMN(MseXicToPiKP, mseXicToPiKP, std::vector<float>); //! new column for MSE
317+
DECLARE_SOA_COLUMN(MseXicToPKPi, mseXicToPKPi, std::vector<float>); //! new column for MSE
318+
DECLARE_SOA_COLUMN(MseXicToPiKP, mseXicToPiKP, std::vector<float>); //! new column for MSE
319319
DECLARE_SOA_COLUMN(AeOutputXicToPKPi, aeOutputXicToPKPi, std::vector<float>); //! new column for AE output
320320
DECLARE_SOA_COLUMN(AeOutputXicToPiKP, aeOutputXicToPiKP, std::vector<float>); //! new column for AE output
321321
// XicPlus to Xi Pi Pi

PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
/// \author Vít Kučera <vit.kucera@cern.ch>, CERN
1818
/// \author Cristina Terrevoli <cristina.terrevoli@cern.ch>, INFN BARI
1919

20+
#include "PWGHF/Core/HfAeToMseXicToPKPi.h"
2021
#include "PWGHF/Core/HfHelper.h"
2122
#include "PWGHF/Core/HfMlResponseXicToPKPi.h"
2223
#include "PWGHF/Core/SelectorCuts.h"
23-
#include "PWGHF/Core/HfAeToMseXicToPKPi.h"
2424
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
2525
#include "PWGHF/DataModel/CandidateSelectionTables.h"
2626

@@ -156,9 +156,9 @@ struct HfCandidateSelectorXicToPKPi {
156156
hfMlResponse.init();
157157
/// AE feature preprocessing - MinMax scaling initialization
158158
if (applyMinMax == 1) {
159-
LOG(info)<<"MinMax scaling will be applied";
159+
LOG(info) << "MinMax scaling will be applied";
160160
scaleType = 1;
161-
} else
161+
} else
162162
LOG(info) << "No external preprocessing transformation will be applied";
163163
}
164164
}

0 commit comments

Comments
 (0)