![]() |
|
|||
File indexing completed on 2025-08-06 08:13:51
0001 // Class: ReadCuts 0002 // Automatically generated by MethodBase::MakeClass 0003 // 0004 0005 /* configuration options ===================================================== 0006 0007 #GEN -*-*-*-*-*-*-*-*-*-*-*- general info -*-*-*-*-*-*-*-*-*-*-*- 0008 0009 Method : Cuts::Cuts 0010 TMVA Release : 4.2.1 [262657] 0011 ROOT Release : 6.22/02 [398850] 0012 Creator : cdean 0013 Date : Tue Apr 20 16:38:02 2021 0014 Host : Linux cvmfswrite02.sdcc.bnl.gov 3.10.0-957.12.2.el7.x86_64 #1 SMP Tue May 14 15:23:27 CDT 2019 x86_64 x86_64 x86_64 GNU/Linux 0015 Dir : /gpfs/mnt/gpfs02/sphenix/user/cdean/scripts/HF_trigger_ML/TMVA/Odd/wCalo 0016 Training events: 31922 0017 Analysis type : [Classification] 0018 0019 0020 #OPT -*-*-*-*-*-*-*-*-*-*-*-*- options -*-*-*-*-*-*-*-*-*-*-*-*- 0021 0022 # Set by User: 0023 V: "False" [Verbose output (short form of "VerbosityLevel" below - overrides the latter one)] 0024 H: "False" [Print method-specific help message] 0025 FitMethod: "MC" [Minimisation Method (GA, SA, and MC are the primary methods to be used; the others have been introduced for testing purposes and are depreciated)] 0026 EffMethod: "EffSel" [Selection Method] 0027 # Default: 0028 VerbosityLevel: "Default" [Verbosity level] 0029 VarTransform: "None" [List of variable transformations performed before training, e.g., "D_Background,P_Signal,G,N_AllClasses" for: "Decorrelation, PCA-transformation, Gaussianisation, Normalisation, each for the given class of events ('AllClasses' denotes all events of all classes, if no class indication is given, 'All' is assumed)"] 0030 CreateMVAPdfs: "False" [Create PDFs for classifier outputs (signal and background)] 0031 IgnoreNegWeightsInTraining: "False" [Events with negative weights are ignored in the training (but are included for testing and performance evaluation)] 0032 CutRangeMin[0]: "-1.000000e+00" [Minimum of allowed cut range (set per variable)] 0033 CutRangeMin[1]: "-1.000000e+00" 0034 CutRangeMin[2]: "-1.000000e+00" 0035 CutRangeMin[3]: "-1.000000e+00" 0036 CutRangeMax[0]: "-1.000000e+00" [Maximum of allowed cut range (set per variable)] 0037 CutRangeMax[1]: "-1.000000e+00" 0038 CutRangeMax[2]: "-1.000000e+00" 0039 CutRangeMax[3]: "-1.000000e+00" 0040 VarProp[0]: "FSmart" [Categorisation of cuts] 0041 VarProp[1]: "FSmart" 0042 VarProp[2]: "FSmart" 0043 VarProp[3]: "FSmart" 0044 ## 0045 0046 0047 #VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*- 0048 0049 NVar 4 0050 max(track_1_IP,track_2_IP) maxTrackDCA_3D maxTrackDCA_3D track-vertex 3D DCA, max units 'F' [0.00383873376995,4.99581956863] 0051 max(abs(track_1_IP_xy),abs(track_2_IP_xy)) maxTrackDCA_2D maxTrackDCA_2D track-vertex 2D DCA, max units 'F' [9.33057162911e-05,4.8996257782] 0052 track_1_track_2_DCA track_1_track_2_DCA track_1_track_2_DCA track-track 3D DCA units 'F' [1.57269468559e-07,0.0499997623265] 0053 INTT_meanHits INTT_meanHits INTT_meanHits INTT avg. hits units 'F' [0,93] 0054 NSpec 0 0055 0056 0057 ============================================================================ */ 0058 0059 #include <array> 0060 #include <vector> 0061 #include <cmath> 0062 #include <string> 0063 #include <iostream> 0064 0065 #ifndef IClassifierReader__def 0066 #define IClassifierReader__def 0067 0068 class IClassifierReader { 0069 0070 public: 0071 0072 // constructor 0073 IClassifierReader() : fStatusIsClean( true ) {} 0074 virtual ~IClassifierReader() {} 0075 0076 // return classifier response 0077 virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0; 0078 0079 // returns classifier status 0080 bool IsStatusClean() const { return fStatusIsClean; } 0081 0082 protected: 0083 0084 bool fStatusIsClean; 0085 }; 0086 0087 #endif 0088 0089 class ReadCuts : public IClassifierReader { 0090 0091 public: 0092 0093 // constructor 0094 ReadCuts( std::vector<std::string>& theInputVars ) 0095 : IClassifierReader(), 0096 fClassName( "ReadCuts" ), 0097 fNvars( 4 ) 0098 { 0099 // the training input variables 0100 const char* inputVars[] = { "max(track_1_IP,track_2_IP)", "max(abs(track_1_IP_xy),abs(track_2_IP_xy))", "track_1_track_2_DCA", "INTT_meanHits" }; 0101 0102 // sanity checks 0103 if (theInputVars.size() <= 0) { 0104 std::cout << "Problem in class \"" << fClassName << "\": empty input vector" << std::endl; 0105 fStatusIsClean = false; 0106 } 0107 0108 if (theInputVars.size() != fNvars) { 0109 std::cout << "Problem in class \"" << fClassName << "\": mismatch in number of input values: " 0110 << theInputVars.size() << " != " << fNvars << std::endl; 0111 fStatusIsClean = false; 0112 } 0113 0114 // validate input variables 0115 for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) { 0116 if (theInputVars[ivar] != inputVars[ivar]) { 0117 std::cout << "Problem in class \"" << fClassName << "\": mismatch in input variable names" << std::endl 0118 << " for variable [" << ivar << "]: " << theInputVars[ivar].c_str() << " != " << inputVars[ivar] << std::endl; 0119 fStatusIsClean = false; 0120 } 0121 } 0122 0123 // initialize min and max vectors (for normalisation) 0124 fVmin[0] = 0; 0125 fVmax[0] = 0; 0126 fVmin[1] = 0; 0127 fVmax[1] = 0; 0128 fVmin[2] = 0; 0129 fVmax[2] = 0; 0130 fVmin[3] = 0; 0131 fVmax[3] = 0; 0132 0133 // initialize input variable types 0134 fType[0] = 'F'; 0135 fType[1] = 'F'; 0136 fType[2] = 'F'; 0137 fType[3] = 'F'; 0138 0139 // initialize constants 0140 Initialize(); 0141 0142 } 0143 0144 // destructor 0145 virtual ~ReadCuts() { 0146 Clear(); // method-specific 0147 } 0148 0149 // the classifier response 0150 // "inputValues" is a vector of input values in the same order as the 0151 // variables given to the constructor 0152 double GetMvaValue( const std::vector<double>& inputValues ) const override; 0153 0154 private: 0155 0156 // method-specific destructor 0157 void Clear(); 0158 0159 // common member variables 0160 const char* fClassName; 0161 0162 const size_t fNvars; 0163 size_t GetNvar() const { return fNvars; } 0164 char GetType( int ivar ) const { return fType[ivar]; } 0165 0166 // normalisation of input variables 0167 double fVmin[4]; 0168 double fVmax[4]; 0169 double NormVariable( double x, double xmin, double xmax ) const { 0170 // normalise to output range: [-1, 1] 0171 return 2*(x - xmin)/(xmax - xmin) - 1.0; 0172 } 0173 0174 // type of input variable: 'F' or 'I' 0175 char fType[4]; 0176 0177 // initialize internal variables 0178 void Initialize(); 0179 double GetMvaValue__( const std::vector<double>& inputValues ) const; 0180 0181 // private members (method specific) 0182 // not implemented for class: "ReadCuts" 0183 }; 0184 inline double ReadCuts::GetMvaValue( const std::vector<double>& inputValues ) const 0185 { 0186 // classifier response value 0187 double retval = 0; 0188 0189 // classifier response, sanity check first 0190 if (!IsStatusClean()) { 0191 std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response" 0192 << " because status is dirty" << std::endl; 0193 } 0194 else { 0195 retval = GetMvaValue__( inputValues ); 0196 } 0197 0198 return retval; 0199 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |