![]() |
|
|||
File indexing completed on 2025-08-05 08:14:27
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.0 [262656] 0011 ROOT Release : 5.34/38 [336422] 0012 Creator : vassalli 0013 Date : Fri Aug 23 18:39:02 2019 0014 Host : Linux cvmfswrite02.sdcc.bnl.gov 3.10.0-693.11.6.el7.x86_64 #1 SMP Wed Jan 3 18:09:42 CST 2018 x86_64 x86_64 x86_64 GNU/Linux 0015 Dir : /direct/phenix+u/vassalli/sphenix/single/Training 0016 Training events: 3275 0017 Analysis type : [Classification] 0018 0019 0020 #OPT -*-*-*-*-*-*-*-*-*-*-*-*- options -*-*-*-*-*-*-*-*-*-*-*-*- 0021 0022 # Set by User: 0023 # Default: 0024 V: "False" [Verbose output (short form of "VerbosityLevel" below - overrides the latter one)] 0025 VerbosityLevel: "Default" [Verbosity level] 0026 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)"] 0027 H: "False" [Print method-specific help message] 0028 CreateMVAPdfs: "False" [Create PDFs for classifier outputs (signal and background)] 0029 IgnoreNegWeightsInTraining: "False" [Events with negative weights are ignored in the training (but are included for testing and performance evaluation)] 0030 FitMethod: "GA" [Minimisation Method (GA, SA, and MC are the primary methods to be used; the others have been introduced for testing purposes and are depreciated)] 0031 EffMethod: "EffSel" [Selection Method] 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 CutRangeMax[0]: "-1.000000e+00" [Maximum of allowed cut range (set per variable)] 0036 CutRangeMax[1]: "-1.000000e+00" 0037 CutRangeMax[2]: "-1.000000e+00" 0038 VarProp[0]: "NotEnforced" [Categorisation of cuts] 0039 VarProp[1]: "NotEnforced" 0040 VarProp[2]: "NotEnforced" 0041 ## 0042 0043 0044 #VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*- 0045 0046 NVar 3 0047 vtx_radius vtx_radius vtx_radius vtx_radius 'F' [-1,209.624893188] 0048 photon_m photon_m photon_m photon_m 'F' [-0.00132509833202,544.017456055] 0049 photon_pT photon_pT photon_pT photon_pT 'F' [1.40129846432e-45,476207616] 0050 NSpec 9 0051 track_layer track_layer track_layer I 'F' [0,20] 0052 track_pT track_pT track_pT F 'F' [2.0459113121,1520.48986816] 0053 track_dca track_dca track_dca F 'F' [1.29460659082e-05,64.1267471313] 0054 cluster_prob cluster_prob cluster_prob F 'F' [0,0.999049782753] 0055 abs(track_deta) abs_track_deta_ abs(track_deta) F 'F' [1.19209289551e-07,0.010913586244] 0056 abs(cluster_deta) abs_cluster_deta_ abs(cluster_deta) F 'F' [0,0.0315845087171] 0057 abs(cluster_dphi) abs_cluster_dphi_ abs(cluster_dphi) F 'F' [0,6.23594331741] 0058 abs(track_dlayer) abs_track_dlayer_ abs(track_dlayer) I 'F' [0,14] 0059 approach_dist approach_dist approach_dist F 'F' [1.41833572798e-06,54.7429046631] 0060 0061 0062 ============================================================================ */ 0063 0064 #include <vector> 0065 #include <cmath> 0066 #include <string> 0067 #include <iostream> 0068 0069 #ifndef IClassifierReader__def 0070 #define IClassifierReader__def 0071 0072 class IClassifierReader { 0073 0074 public: 0075 0076 // constructor 0077 IClassifierReader() : fStatusIsClean( true ) {} 0078 virtual ~IClassifierReader() {} 0079 0080 // return classifier response 0081 virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0; 0082 0083 // returns classifier status 0084 bool IsStatusClean() const { return fStatusIsClean; } 0085 0086 protected: 0087 0088 bool fStatusIsClean; 0089 }; 0090 0091 #endif 0092 0093 class ReadCuts : public IClassifierReader { 0094 0095 public: 0096 0097 // constructor 0098 ReadCuts( std::vector<std::string>& theInputVars ) 0099 : IClassifierReader(), 0100 fClassName( "ReadCuts" ), 0101 fNvars( 3 ), 0102 fIsNormalised( false ) 0103 { 0104 // the training input variables 0105 const char* inputVars[] = { "vtx_radius", "photon_m", "photon_pT" }; 0106 0107 // sanity checks 0108 if (theInputVars.size() <= 0) { 0109 std::cout << "Problem in class \"" << fClassName << "\": empty input vector" << std::endl; 0110 fStatusIsClean = false; 0111 } 0112 0113 if (theInputVars.size() != fNvars) { 0114 std::cout << "Problem in class \"" << fClassName << "\": mismatch in number of input values: " 0115 << theInputVars.size() << " != " << fNvars << std::endl; 0116 fStatusIsClean = false; 0117 } 0118 0119 // validate input variables 0120 for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) { 0121 if (theInputVars[ivar] != inputVars[ivar]) { 0122 std::cout << "Problem in class \"" << fClassName << "\": mismatch in input variable names" << std::endl 0123 << " for variable [" << ivar << "]: " << theInputVars[ivar].c_str() << " != " << inputVars[ivar] << std::endl; 0124 fStatusIsClean = false; 0125 } 0126 } 0127 0128 // initialize min and max vectors (for normalisation) 0129 fVmin[0] = 0; 0130 fVmax[0] = 0; 0131 fVmin[1] = 0; 0132 fVmax[1] = 0; 0133 fVmin[2] = 0; 0134 fVmax[2] = 0; 0135 0136 // initialize input variable types 0137 fType[0] = 'F'; 0138 fType[1] = 'F'; 0139 fType[2] = 'F'; 0140 0141 // initialize constants 0142 Initialize(); 0143 0144 } 0145 0146 // destructor 0147 virtual ~ReadCuts() { 0148 Clear(); // method-specific 0149 } 0150 0151 // the classifier response 0152 // "inputValues" is a vector of input values in the same order as the 0153 // variables given to the constructor 0154 double GetMvaValue( const std::vector<double>& inputValues ) const; 0155 0156 private: 0157 0158 // method-specific destructor 0159 void Clear(); 0160 0161 // common member variables 0162 const char* fClassName; 0163 0164 const size_t fNvars; 0165 size_t GetNvar() const { return fNvars; } 0166 char GetType( int ivar ) const { return fType[ivar]; } 0167 0168 // normalisation of input variables 0169 const bool fIsNormalised; 0170 bool IsNormalised() const { return fIsNormalised; } 0171 double fVmin[3]; 0172 double fVmax[3]; 0173 double NormVariable( double x, double xmin, double xmax ) const { 0174 // normalise to output range: [-1, 1] 0175 return 2*(x - xmin)/(xmax - xmin) - 1.0; 0176 } 0177 0178 // type of input variable: 'F' or 'I' 0179 char fType[3]; 0180 0181 // initialize internal variables 0182 void Initialize(); 0183 double GetMvaValue__( const std::vector<double>& inputValues ) const; 0184 0185 // private members (method specific) 0186 // not implemented for class: "ReadCuts" 0187 }; 0188 inline double ReadCuts::GetMvaValue( const std::vector<double>& inputValues ) const 0189 { 0190 // classifier response value 0191 double retval = 0; 0192 0193 // classifier response, sanity check first 0194 if (!IsStatusClean()) { 0195 std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response" 0196 << " because status is dirty" << std::endl; 0197 retval = 0; 0198 } 0199 else { 0200 if (IsNormalised()) { 0201 // normalise variables 0202 std::vector<double> iV; 0203 iV.reserve(inputValues.size()); 0204 int ivar = 0; 0205 for (std::vector<double>::const_iterator varIt = inputValues.begin(); 0206 varIt != inputValues.end(); varIt++, ivar++) { 0207 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] )); 0208 } 0209 retval = GetMvaValue__( iV ); 0210 } 0211 else { 0212 retval = GetMvaValue__( inputValues ); 0213 } 0214 } 0215 0216 return retval; 0217 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |