File indexing completed on 2026-09-24 09:24:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #ifndef ROOT_TMVA_MethodCuts
0034 #define ROOT_TMVA_MethodCuts
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 #include <vector>
0047
0048
0049 #include "TMVA/MethodBase.h"
0050 #include "TMVA/BinarySearchTree.h"
0051 #include "TMVA/PDF.h"
0052 #include "TMatrixDfwd.h"
0053 #include "IFitterTarget.h"
0054
0055 class TRandom;
0056
0057 namespace TMVA {
0058
0059 class Interval;
0060
0061 class MethodCuts : public MethodBase, public IFitterTarget {
0062
0063 public:
0064
0065 MethodCuts( const TString& jobName,
0066 const TString& methodTitle,
0067 DataSetInfo& theData,
0068 const TString& theOption = "MC:150:10000:");
0069
0070 MethodCuts( DataSetInfo& theData,
0071 const TString& theWeightFile);
0072
0073 virtual ~MethodCuts( void );
0074
0075 Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets ) override;
0076
0077
0078 void Train( void ) override;
0079
0080 using MethodBase::ReadWeightsFromStream;
0081
0082 void AddWeightsXMLTo ( void* parent ) const override;
0083
0084 void ReadWeightsFromStream( std::istream & i ) override;
0085 void ReadWeightsFromXML ( void* wghtnode ) override;
0086
0087
0088 Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr ) override;
0089
0090
0091 void WriteMonitoringHistosToFile( void ) const override;
0092
0093
0094 void TestClassification() override;
0095
0096
0097 Double_t GetSeparation ( TH1*, TH1* ) const override { return -1; }
0098 Double_t GetSeparation ( PDF* = nullptr, PDF* = nullptr ) const override { return -1; }
0099 Double_t GetSignificance( void ) const override { return -1; }
0100 Double_t GetmuTransform ( TTree *) { return -1; }
0101 Double_t GetEfficiency ( const TString&, Types::ETreeType, Double_t& ) override;
0102 Double_t GetTrainingEfficiency(const TString& ) override;
0103
0104
0105 Double_t GetRarity( Double_t, Types::ESBType ) const override { return 0; }
0106
0107
0108 Double_t ComputeEstimator( std::vector<Double_t> & );
0109
0110 Double_t EstimatorFunction( std::vector<Double_t> & ) override;
0111 Double_t EstimatorFunction( Int_t ievt1, Int_t ievt2 );
0112
0113 void SetTestSignalEfficiency( Double_t effS ) { fTestSignalEff = effS; }
0114
0115
0116 void PrintCuts( Double_t effS ) const;
0117 Double_t GetCuts ( Double_t effS, std::vector<Double_t>& cutMin, std::vector<Double_t>& cutMax ) const;
0118 Double_t GetCuts ( Double_t effS, Double_t* cutMin, Double_t* cutMax ) const;
0119
0120
0121 const Ranking* CreateRanking() override { return nullptr; }
0122
0123 void DeclareOptions() override;
0124 void ProcessOptions() override;
0125
0126
0127 static const Double_t fgMaxAbsCutVal;
0128
0129
0130 void CheckSetup() override {}
0131
0132 protected:
0133
0134
0135 void MakeClassSpecific( std::ostream&, const TString& ) const override;
0136
0137
0138 void GetHelpMessage() const override;
0139
0140 private:
0141
0142
0143 enum EFitMethodType { kUseMonteCarlo = 0,
0144 kUseGeneticAlgorithm,
0145 kUseSimulatedAnnealing,
0146 kUseMinuit,
0147 kUseEventScan,
0148 kUseMonteCarloEvents };
0149
0150
0151
0152
0153
0154 enum EEffMethod { kUseEventSelection = 0,
0155 kUsePDFs };
0156
0157
0158 enum EFitParameters { kNotEnforced = 0,
0159 kForceMin,
0160 kForceMax,
0161 kForceSmart };
0162
0163
0164 TString fFitMethodS;
0165 EFitMethodType fFitMethod;
0166 TString fEffMethodS;
0167 EEffMethod fEffMethod;
0168 std::vector<EFitParameters>* fFitParams;
0169 Double_t fTestSignalEff;
0170 Double_t fEffSMin;
0171 Double_t fEffSMax;
0172 Double_t* fCutRangeMin;
0173 Double_t* fCutRangeMax;
0174 std::vector<Interval*> fCutRange;
0175
0176
0177 BinarySearchTree* fBinaryTreeS;
0178 BinarySearchTree* fBinaryTreeB;
0179
0180
0181 Double_t** fCutMin;
0182 Double_t** fCutMax;
0183 Double_t* fTmpCutMin;
0184 Double_t* fTmpCutMax;
0185 TString* fAllVarsI;
0186
0187
0188 Int_t fNpar;
0189 Double_t fEffRef;
0190 std::vector<Int_t>* fRangeSign;
0191 TRandom* fRandom;
0192
0193
0194 std::vector<Double_t>* fMeanS;
0195 std::vector<Double_t>* fMeanB;
0196 std::vector<Double_t>* fRmsS;
0197 std::vector<Double_t>* fRmsB;
0198
0199 TH1* fEffBvsSLocal;
0200
0201
0202 std::vector<TH1*>* fVarHistS;
0203 std::vector<TH1*>* fVarHistB;
0204 std::vector<TH1*>* fVarHistS_smooth;
0205 std::vector<TH1*>* fVarHistB_smooth;
0206 std::vector<PDF*>* fVarPdfS;
0207 std::vector<PDF*>* fVarPdfB;
0208
0209
0210 Bool_t fNegEffWarning;
0211
0212
0213
0214
0215 void MatchParsToCuts( const std::vector<Double_t>&, Double_t*, Double_t* );
0216 void MatchParsToCuts( Double_t*, Double_t*, Double_t* );
0217
0218 void MatchCutsToPars( std::vector<Double_t>&, Double_t*, Double_t* );
0219 void MatchCutsToPars( std::vector<Double_t>&, Double_t**, Double_t**, Int_t ibin );
0220
0221
0222
0223 void CreateVariablePDFs( void );
0224
0225
0226 void GetEffsfromSelection( Double_t* cutMin, Double_t* cutMax,
0227 Double_t& effS, Double_t& effB );
0228
0229 void GetEffsfromPDFs( Double_t* cutMin, Double_t* cutMax,
0230 Double_t& effS, Double_t& effB );
0231
0232
0233 void Init( void ) override;
0234
0235 ClassDefOverride(MethodCuts,0);
0236 };
0237
0238 }
0239
0240 #endif