Skip to content

Commit

Permalink
[tmva][NFC] Run clang-format on Result* headers
Browse files Browse the repository at this point in the history
  • Loading branch information
vepadulano committed Feb 29, 2024
1 parent e8ef690 commit acd75d3
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 176 deletions.
92 changes: 45 additions & 47 deletions tmva/tmva/inc/TMVA/Results.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,52 +51,50 @@ class TGraph;

namespace TMVA {

class DataSet;
class MsgLogger;

class Results:public TObject {

public:

Results( const DataSetInfo* dsi, TString resultsName );
Results();
virtual ~Results();

// setters
void Store( TObject* obj, const char* alias=nullptr );
void SetTreeType( Types::ETreeType type ) { fTreeType = type; }

// getters
Types::ETreeType GetTreeType() const { return fTreeType; }
const DataSetInfo* GetDataSetInfo() const { return fDsi; }
DataSet* GetDataSet() const { return fDsi->GetDataSet(); }
TList* GetStorage() const { return fStorage; }
TObject* GetObject(const TString & alias) const;
TH1* GetHist(const TString & alias) const;
TH2* GetHist2D(const TString & alias) const;
TGraph* GetGraph(const TString & alias) const;
virtual Types::EAnalysisType GetAnalysisType() { return Types::kNoAnalysisType; }
//test
Bool_t DoesExist(const TString & alias) const;

// delete all stored data
// using TObject::Delete;
void Delete(Option_t *option="") override;

virtual const std::vector< Float_t >& operator [] ( Int_t ievt ) const = 0;

private:
Types::ETreeType fTreeType; ///< tree type for this result
const DataSetInfo *fDsi; ///<-> a pointer to the datasetinfo-object
TList *fStorage; ///<-> stores all the result-histograms
std::map<TString, TObject *> *fHistAlias; ///<-> internal map for quick access to stored histograms
mutable MsgLogger* fLogger; ///<! message logger
MsgLogger& Log() const { return *fLogger; }
public:

ClassDefOverride(Results,2);

};
}
class DataSet;
class MsgLogger;

class Results : public TObject {

public:
Results(const DataSetInfo *dsi, TString resultsName);
Results();
virtual ~Results();

// setters
void Store(TObject *obj, const char *alias = nullptr);
void SetTreeType(Types::ETreeType type) { fTreeType = type; }

// getters
Types::ETreeType GetTreeType() const { return fTreeType; }
const DataSetInfo *GetDataSetInfo() const { return fDsi; }
DataSet *GetDataSet() const { return fDsi->GetDataSet(); }
TList *GetStorage() const { return fStorage; }
TObject *GetObject(const TString &alias) const;
TH1 *GetHist(const TString &alias) const;
TH2 *GetHist2D(const TString &alias) const;
TGraph *GetGraph(const TString &alias) const;
virtual Types::EAnalysisType GetAnalysisType() { return Types::kNoAnalysisType; }
// test
Bool_t DoesExist(const TString &alias) const;

// delete all stored data
// using TObject::Delete;
void Delete(Option_t *option = "") override;

virtual const std::vector<Float_t> &operator[](Int_t ievt) const = 0;

private:
Types::ETreeType fTreeType; ///< tree type for this result
const DataSetInfo *fDsi; ///<-> a pointer to the datasetinfo-object
TList *fStorage; ///<-> stores all the result-histograms
std::map<TString, TObject *> *fHistAlias; ///<-> internal map for quick access to stored histograms
mutable MsgLogger *fLogger; ///<! message logger
MsgLogger &Log() const { return *fLogger; }

public:
ClassDefOverride(Results, 2);
};
} // namespace TMVA

#endif
89 changes: 47 additions & 42 deletions tmva/tmva/inc/TMVA/ResultsClassification.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,47 +43,52 @@

namespace TMVA {

class MsgLogger;

class ResultsClassification : public Results {

public:

ResultsClassification( const DataSetInfo* dsi, TString resultsName );
~ResultsClassification();

// setters : set score value and type for each single event.
// note type=TRUE for signal and FLASE for background
void SetValue( Float_t value, Int_t ievt, Bool_t type );

void Resize( Int_t entries ) {
fMvaValues.resize( entries );
fMvaValuesTypes.resize(entries);
}
using TObject::Clear;
void Clear(Option_t *) override { fMvaValues.clear(); fMvaValuesTypes.clear(); }

// getters
Long64_t GetSize() const { return fMvaValues.size(); }
const std::vector< Float_t >& operator []( Int_t ievt ) const override { fRet[0] = fMvaValues[ievt]; return fRet; }
std::vector<Float_t>* GetValueVector() { return &fMvaValues; }
std::vector<Bool_t>* GetValueVectorTypes() { return &fMvaValuesTypes; }

Types::EAnalysisType GetAnalysisType() override { return Types::kClassification; }


private:

std::vector< Float_t > fMvaValues; ///< mva values (Results)
std::vector< Bool_t> fMvaValuesTypes; ///< mva values type(sig/bkg) (Results)
mutable std::vector< Float_t > fRet; ///< return val
mutable MsgLogger* fLogger; ///<! message logger
MsgLogger& Log() const { return *fLogger; }
protected:

ClassDefOverride(ResultsClassification,3);

};
}
class MsgLogger;

class ResultsClassification : public Results {

public:
ResultsClassification(const DataSetInfo *dsi, TString resultsName);
~ResultsClassification();

// setters : set score value and type for each single event.
// note type=TRUE for signal and FLASE for background
void SetValue(Float_t value, Int_t ievt, Bool_t type);

void Resize(Int_t entries)
{
fMvaValues.resize(entries);
fMvaValuesTypes.resize(entries);
}
using TObject::Clear;
void Clear(Option_t *) override
{
fMvaValues.clear();
fMvaValuesTypes.clear();
}

// getters
Long64_t GetSize() const { return fMvaValues.size(); }
const std::vector<Float_t> &operator[](Int_t ievt) const override
{
fRet[0] = fMvaValues[ievt];
return fRet;
}
std::vector<Float_t> *GetValueVector() { return &fMvaValues; }
std::vector<Bool_t> *GetValueVectorTypes() { return &fMvaValuesTypes; }

Types::EAnalysisType GetAnalysisType() override { return Types::kClassification; }

private:
std::vector<Float_t> fMvaValues; ///< mva values (Results)
std::vector<Bool_t> fMvaValuesTypes; ///< mva values type(sig/bkg) (Results)
mutable std::vector<Float_t> fRet; ///< return val
mutable MsgLogger *fLogger; ///<! message logger
MsgLogger &Log() const { return *fLogger; }

protected:
ClassDefOverride(ResultsClassification, 3);
};
} // namespace TMVA

#endif
110 changes: 53 additions & 57 deletions tmva/tmva/inc/TMVA/ResultsMulticlass.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,62 +50,58 @@

namespace TMVA {

class MsgLogger;

class ResultsMulticlass : public Results, public IFitterTarget {

public:

ResultsMulticlass( const DataSetInfo* dsi, TString resultsName );
~ResultsMulticlass();

// setters
void SetValue( std::vector<Float_t>& value, Int_t ievt );
void Resize( Int_t entries ) { fMultiClassValues.resize( entries ); }
using TObject::Clear;
void Clear(Option_t *) override { fMultiClassValues.clear(); }

// getters
Long64_t GetSize() const { return fMultiClassValues.size(); }
const std::vector< Float_t >& operator[] ( Int_t ievt ) const override { return fMultiClassValues.at(ievt); }
std::vector<std::vector< Float_t> >* GetValueVector() { return &fMultiClassValues; }

Types::EAnalysisType GetAnalysisType() override { return Types::kMulticlass; }
Float_t GetAchievableEff(UInt_t cls){return fAchievableEff.at(cls);}
Float_t GetAchievablePur(UInt_t cls){return fAchievablePur.at(cls);}
std::vector<Float_t>& GetAchievableEff(){return fAchievableEff;}
std::vector<Float_t>& GetAchievablePur(){return fAchievablePur;}

TMatrixD GetConfusionMatrix(Double_t effB);

// histogramming
void CreateMulticlassPerformanceHistos(TString prefix);
void CreateMulticlassHistos( TString prefix, Int_t nbins, Int_t nbins_high);

Double_t EstimatorFunction( std::vector<Double_t> & ) override;
std::vector<Double_t> GetBestMultiClassCuts(UInt_t targetClass);

private:

mutable std::vector<std::vector< Float_t> > fMultiClassValues; ///< mva values (Results)
mutable MsgLogger* fLogger; ///<! message logger
MsgLogger& Log() const { return *fLogger; }
UInt_t fClassToOptimize;
std::vector<Float_t> fAchievableEff;
std::vector<Float_t> fAchievablePur;
std::vector<std::vector<Double_t> > fBestCuts;

// Temporary storage used during GetBestMultiClassCuts
std::vector<Float_t> fClassSumWeights;
std::vector<Float_t> fEventWeights;
std::vector<UInt_t> fEventClasses;

protected:

ClassDefOverride(ResultsMulticlass,3);

};

}
class MsgLogger;

class ResultsMulticlass : public Results, public IFitterTarget {

public:
ResultsMulticlass(const DataSetInfo *dsi, TString resultsName);
~ResultsMulticlass();

// setters
void SetValue(std::vector<Float_t> &value, Int_t ievt);
void Resize(Int_t entries) { fMultiClassValues.resize(entries); }
using TObject::Clear;
void Clear(Option_t *) override { fMultiClassValues.clear(); }

// getters
Long64_t GetSize() const { return fMultiClassValues.size(); }
const std::vector<Float_t> &operator[](Int_t ievt) const override { return fMultiClassValues.at(ievt); }
std::vector<std::vector<Float_t>> *GetValueVector() { return &fMultiClassValues; }

Types::EAnalysisType GetAnalysisType() override { return Types::kMulticlass; }
Float_t GetAchievableEff(UInt_t cls) { return fAchievableEff.at(cls); }
Float_t GetAchievablePur(UInt_t cls) { return fAchievablePur.at(cls); }
std::vector<Float_t> &GetAchievableEff() { return fAchievableEff; }
std::vector<Float_t> &GetAchievablePur() { return fAchievablePur; }

TMatrixD GetConfusionMatrix(Double_t effB);

// histogramming
void CreateMulticlassPerformanceHistos(TString prefix);
void CreateMulticlassHistos(TString prefix, Int_t nbins, Int_t nbins_high);

Double_t EstimatorFunction(std::vector<Double_t> &) override;
std::vector<Double_t> GetBestMultiClassCuts(UInt_t targetClass);

private:
mutable std::vector<std::vector<Float_t>> fMultiClassValues; ///< mva values (Results)
mutable MsgLogger *fLogger; ///<! message logger
MsgLogger &Log() const { return *fLogger; }
UInt_t fClassToOptimize;
std::vector<Float_t> fAchievableEff;
std::vector<Float_t> fAchievablePur;
std::vector<std::vector<Double_t>> fBestCuts;

// Temporary storage used during GetBestMultiClassCuts
std::vector<Float_t> fClassSumWeights;
std::vector<Float_t> fEventWeights;
std::vector<UInt_t> fEventClasses;

protected:
ClassDefOverride(ResultsMulticlass, 3);
};

} // namespace TMVA

#endif
56 changes: 26 additions & 30 deletions tmva/tmva/inc/TMVA/ResultsRegression.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,44 +47,40 @@

namespace TMVA {

class MsgLogger;
class MsgLogger;

class ResultsRegression : public Results {
class ResultsRegression : public Results {

public:
public:
ResultsRegression(const DataSetInfo *dsi, TString resultsName);
~ResultsRegression();

ResultsRegression( const DataSetInfo* dsi, TString resultsName );
~ResultsRegression();
// setters
void SetValue(std::vector<Float_t> &value, Int_t ievt);
void Resize(Int_t entries) { fRegValues.resize(entries); }

// setters
void SetValue( std::vector<Float_t>& value, Int_t ievt );
void Resize( Int_t entries ) { fRegValues.resize( entries ); }
using TObject::Clear;
void Clear(Option_t *) override { fRegValues.clear(); }

using TObject::Clear;
void Clear(Option_t *) override { fRegValues.clear(); }
// getters
Long64_t GetSize() const { return fRegValues.size(); }
const std::vector<Float_t> &operator[](Int_t ievt) const override { return fRegValues.at(ievt); }
std::vector<std::vector<Float_t>> *GetValueVector() { return &fRegValues; }

// getters
Long64_t GetSize() const { return fRegValues.size(); }
const std::vector< Float_t >& operator [] ( Int_t ievt ) const override { return fRegValues.at(ievt); }
std::vector<std::vector< Float_t> >* GetValueVector() { return &fRegValues; }
TH2F *DeviationAsAFunctionOf(UInt_t varNum, UInt_t tgtNum);
TH1F *QuadraticDeviation(UInt_t tgtNum, Bool_t truncate = false, Double_t truncvalue = 0.);
void CreateDeviationHistograms(TString prefix);

TH2F* DeviationAsAFunctionOf( UInt_t varNum, UInt_t tgtNum );
TH1F* QuadraticDeviation( UInt_t tgtNum, Bool_t truncate = false, Double_t truncvalue = 0. );
void CreateDeviationHistograms( TString prefix );
Types::EAnalysisType GetAnalysisType() override { return Types::kRegression; }

Types::EAnalysisType GetAnalysisType() override { return Types::kRegression; }
private:
mutable std::vector<std::vector<Float_t>> fRegValues; ///< mva values (Results)
mutable MsgLogger *fLogger; ///<! message logger
MsgLogger &Log() const { return *fLogger; }


private:

mutable std::vector<std::vector< Float_t> > fRegValues; ///< mva values (Results)
mutable MsgLogger* fLogger; ///<! message logger
MsgLogger& Log() const { return *fLogger; }
protected:

ClassDefOverride(ResultsRegression,3);

};
}
protected:
ClassDefOverride(ResultsRegression, 3);
};
} // namespace TMVA

#endif

0 comments on commit acd75d3

Please sign in to comment.