Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
aback_Cuts.class.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file aback_Cuts.class.C
1 // Class: ReadCuts
2 // Automatically generated by MethodBase::MakeClass
3 //
4 
5 /* configuration options =====================================================
6 
7 #GEN -*-*-*-*-*-*-*-*-*-*-*- general info -*-*-*-*-*-*-*-*-*-*-*-
8 
9 Method : Cuts::Cuts
10 TMVA Release : 4.2.1 [262657]
11 ROOT Release : 6.16/00 [397312]
12 Creator : vassalli
13 Date : Tue Jul 23 11:56:01 2019
14 Host : Linux cvmfswrite01.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
15 Dir : /direct/phenix+u/vassalli/sphenix/single/Training
16 Training events: 16285
17 Analysis type : [Classification]
18 
19 
20 #OPT -*-*-*-*-*-*-*-*-*-*-*-*- options -*-*-*-*-*-*-*-*-*-*-*-*-
21 
22 # Set by User:
23 # Default:
24 V: "False" [Verbose output (short form of "VerbosityLevel" below - overrides the latter one)]
25 VerbosityLevel: "Default" [Verbosity level]
26 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)"]
27 H: "False" [Print method-specific help message]
28 CreateMVAPdfs: "False" [Create PDFs for classifier outputs (signal and background)]
29 IgnoreNegWeightsInTraining: "False" [Events with negative weights are ignored in the training (but are included for testing and performance evaluation)]
30 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)]
31 EffMethod: "EffSel" [Selection Method]
32 CutRangeMin[0]: "-1.000000e+00" [Minimum of allowed cut range (set per variable)]
33  CutRangeMin[1]: "-1.000000e+00"
34  CutRangeMin[2]: "-1.000000e+00"
35  CutRangeMin[3]: "-1.000000e+00"
36  CutRangeMin[4]: "-1.000000e+00"
37  CutRangeMin[5]: "-1.000000e+00"
38  CutRangeMin[6]: "-1.000000e+00"
39  CutRangeMin[7]: "-1.000000e+00"
40  CutRangeMin[8]: "-1.000000e+00"
41  CutRangeMin[9]: "-1.000000e+00"
42 CutRangeMax[0]: "-1.000000e+00" [Maximum of allowed cut range (set per variable)]
43  CutRangeMax[1]: "-1.000000e+00"
44  CutRangeMax[2]: "-1.000000e+00"
45  CutRangeMax[3]: "-1.000000e+00"
46  CutRangeMax[4]: "-1.000000e+00"
47  CutRangeMax[5]: "-1.000000e+00"
48  CutRangeMax[6]: "-1.000000e+00"
49  CutRangeMax[7]: "-1.000000e+00"
50  CutRangeMax[8]: "-1.000000e+00"
51  CutRangeMax[9]: "-1.000000e+00"
52 VarProp[0]: "NotEnforced" [Categorisation of cuts]
53  VarProp[1]: "NotEnforced"
54  VarProp[2]: "NotEnforced"
55  VarProp[3]: "NotEnforced"
56  VarProp[4]: "NotEnforced"
57  VarProp[5]: "NotEnforced"
58  VarProp[6]: "NotEnforced"
59  VarProp[7]: "NotEnforced"
60  VarProp[8]: "NotEnforced"
61  VarProp[9]: "NotEnforced"
62 ##
63 
64 
65 #VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-
66 
67 NVar 10
68 track_deta track_deta track_deta track_deta 'F' [5.96046447754e-08,1.94615316391]
69 track_dlayer track_dlayer track_dlayer track_dlayer 'I' [-31,31]
70 track_layer track_layer track_layer track_layer 'I' [0,38]
71 track_pT track_pT track_pT track_pT 'F' [0.169785350561,79.8480682373]
72 approach_dist approach_dist approach_dist approach_dist 'F' [1.25233009385e-06,44.061088562]
73 vtx_radius vtx_radius vtx_radius vtx_radius 'F' [3.56204419596e-37,102.31892395]
74 vtx_chi2 vtx_chi2 vtx_chi2 vtx_chi2 'F' [5.22654283354e-38,23.2217674255]
75 vtxTrackRZ_dist vtxTrackRZ_dist vtxTrackRZ_dist vtxTrackRZ_dist 'F' [0,114.041381836]
76 photon_pT photon_pT photon_pT photon_pT 'F' [0.00301368604414,12548.6572266]
77 cluster_prob cluster_prob cluster_prob cluster_prob 'F' [0,0.999658644199]
78 NSpec 0
79 
80 
81 ============================================================================ */
82 
83 #include <array>
84 #include <vector>
85 #include <cmath>
86 #include <string>
87 #include <iostream>
88 
89 #ifndef IClassifierReader__def
90 #define IClassifierReader__def
91 
92 class IClassifierReader {
93 
94  public:
95 
96  // constructor
98  virtual ~IClassifierReader() {}
99 
100  // return classifier response
101  virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;
102 
103  // returns classifier status
104  bool IsStatusClean() const { return fStatusIsClean; }
105 
106  protected:
107 
108  bool fStatusIsClean;
109 };
110 
111 #endif
112 
113 class ReadCuts : public IClassifierReader {
114 
115  public:
116 
117  // constructor
118  ReadCuts( std::vector<std::string>& theInputVars )
119  : IClassifierReader(),
120  fClassName( "ReadCuts" ),
121  fNvars( 10 )
122  {
123  // the training input variables
124  const char* inputVars[] = { "track_deta", "track_dlayer", "track_layer", "track_pT", "approach_dist", "vtx_radius", "vtx_chi2", "vtxTrackRZ_dist", "photon_pT", "cluster_prob" };
125 
126  // sanity checks
127  if (theInputVars.size() <= 0) {
128  std::cout << "Problem in class \"" << fClassName << "\": empty input vector" << std::endl;
129  fStatusIsClean = false;
130  }
131 
132  if (theInputVars.size() != fNvars) {
133  std::cout << "Problem in class \"" << fClassName << "\": mismatch in number of input values: "
134  << theInputVars.size() << " != " << fNvars << std::endl;
135  fStatusIsClean = false;
136  }
137 
138  // validate input variables
139  for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
140  if (theInputVars[ivar] != inputVars[ivar]) {
141  std::cout << "Problem in class \"" << fClassName << "\": mismatch in input variable names" << std::endl
142  << " for variable [" << ivar << "]: " << theInputVars[ivar].c_str() << " != " << inputVars[ivar] << std::endl;
143  fStatusIsClean = false;
144  }
145  }
146 
147  // initialize min and max vectors (for normalisation)
148  fVmin[0] = 0;
149  fVmax[0] = 0;
150  fVmin[1] = 0;
151  fVmax[1] = 0;
152  fVmin[2] = 0;
153  fVmax[2] = 0;
154  fVmin[3] = 0;
155  fVmax[3] = 0;
156  fVmin[4] = 0;
157  fVmax[4] = 0;
158  fVmin[5] = 0;
159  fVmax[5] = 0;
160  fVmin[6] = 0;
161  fVmax[6] = 0;
162  fVmin[7] = 0;
163  fVmax[7] = 0;
164  fVmin[8] = 0;
165  fVmax[8] = 0;
166  fVmin[9] = 0;
167  fVmax[9] = 0;
168 
169  // initialize input variable types
170  fType[0] = 'F';
171  fType[1] = 'I';
172  fType[2] = 'I';
173  fType[3] = 'F';
174  fType[4] = 'F';
175  fType[5] = 'F';
176  fType[6] = 'F';
177  fType[7] = 'F';
178  fType[8] = 'F';
179  fType[9] = 'F';
180 
181  // initialize constants
182  Initialize();
183 
184  }
185 
186  // destructor
187  virtual ~ReadCuts() {
188  Clear(); // method-specific
189  }
190 
191  // the classifier response
192  // "inputValues" is a vector of input values in the same order as the
193  // variables given to the constructor
194  double GetMvaValue( const std::vector<double>& inputValues ) const override;
195 
196  private:
197 
198  // method-specific destructor
199  void Clear();
200 
201  // common member variables
202  const char* fClassName;
203 
204  const size_t fNvars;
205  size_t GetNvar() const { return fNvars; }
206  char GetType( int ivar ) const { return fType[ivar]; }
207 
208  // normalisation of input variables
209  double fVmin[10];
210  double fVmax[10];
211  double NormVariable( double x, double xmin, double xmax ) const {
212  // normalise to output range: [-1, 1]
213  return 2*(x - xmin)/(xmax - xmin) - 1.0;
214  }
215 
216  // type of input variable: 'F' or 'I'
217  char fType[10];
218 
219  // initialize internal variables
220  void Initialize();
221  double GetMvaValue__( const std::vector<double>& inputValues ) const;
222 
223  // private members (method specific)
224  // not implemented for class: "ReadCuts"
225 };
226  inline double ReadCuts::GetMvaValue( const std::vector<double>& inputValues ) const
227  {
228  // classifier response value
229  double retval = 0;
230 
231  // classifier response, sanity check first
232  if (!IsStatusClean()) {
233  std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response"
234  << " because status is dirty" << std::endl;
235  retval = 0;
236  }
237  else {
238  retval = GetMvaValue__( inputValues );
239  }
240 
241  return retval;
242  }