Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vtxback_Cuts.class.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file vtxback_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.0 [262656]
11 ROOT Release : 5.34/38 [336422]
12 Creator : vassalli
13 Date : Fri Aug 23 18:39:02 2019
14 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
15 Dir : /direct/phenix+u/vassalli/sphenix/single/Training
16 Training events: 3275
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 CutRangeMax[0]: "-1.000000e+00" [Maximum of allowed cut range (set per variable)]
36  CutRangeMax[1]: "-1.000000e+00"
37  CutRangeMax[2]: "-1.000000e+00"
38 VarProp[0]: "NotEnforced" [Categorisation of cuts]
39  VarProp[1]: "NotEnforced"
40  VarProp[2]: "NotEnforced"
41 ##
42 
43 
44 #VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-
45 
46 NVar 3
47 vtx_radius vtx_radius vtx_radius vtx_radius 'F' [-1,209.624893188]
48 photon_m photon_m photon_m photon_m 'F' [-0.00132509833202,544.017456055]
49 photon_pT photon_pT photon_pT photon_pT 'F' [1.40129846432e-45,476207616]
50 NSpec 9
51 track_layer track_layer track_layer I 'F' [0,20]
52 track_pT track_pT track_pT F 'F' [2.0459113121,1520.48986816]
53 track_dca track_dca track_dca F 'F' [1.29460659082e-05,64.1267471313]
54 cluster_prob cluster_prob cluster_prob F 'F' [0,0.999049782753]
55 abs(track_deta) abs_track_deta_ abs(track_deta) F 'F' [1.19209289551e-07,0.010913586244]
56 abs(cluster_deta) abs_cluster_deta_ abs(cluster_deta) F 'F' [0,0.0315845087171]
57 abs(cluster_dphi) abs_cluster_dphi_ abs(cluster_dphi) F 'F' [0,6.23594331741]
58 abs(track_dlayer) abs_track_dlayer_ abs(track_dlayer) I 'F' [0,14]
59 approach_dist approach_dist approach_dist F 'F' [1.41833572798e-06,54.7429046631]
60 
61 
62 ============================================================================ */
63 
64 #include <vector>
65 #include <cmath>
66 #include <string>
67 #include <iostream>
68 
69 #ifndef IClassifierReader__def
70 #define IClassifierReader__def
71 
72 class IClassifierReader {
73 
74  public:
75 
76  // constructor
78  virtual ~IClassifierReader() {}
79 
80  // return classifier response
81  virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;
82 
83  // returns classifier status
84  bool IsStatusClean() const { return fStatusIsClean; }
85 
86  protected:
87 
88  bool fStatusIsClean;
89 };
90 
91 #endif
92 
93 class ReadCuts : public IClassifierReader {
94 
95  public:
96 
97  // constructor
98  ReadCuts( std::vector<std::string>& theInputVars )
100  fClassName( "ReadCuts" ),
101  fNvars( 3 ),
103  {
104  // the training input variables
105  const char* inputVars[] = { "vtx_radius", "photon_m", "photon_pT" };
106 
107  // sanity checks
108  if (theInputVars.size() <= 0) {
109  std::cout << "Problem in class \"" << fClassName << "\": empty input vector" << std::endl;
110  fStatusIsClean = false;
111  }
112 
113  if (theInputVars.size() != fNvars) {
114  std::cout << "Problem in class \"" << fClassName << "\": mismatch in number of input values: "
115  << theInputVars.size() << " != " << fNvars << std::endl;
116  fStatusIsClean = false;
117  }
118 
119  // validate input variables
120  for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
121  if (theInputVars[ivar] != inputVars[ivar]) {
122  std::cout << "Problem in class \"" << fClassName << "\": mismatch in input variable names" << std::endl
123  << " for variable [" << ivar << "]: " << theInputVars[ivar].c_str() << " != " << inputVars[ivar] << std::endl;
124  fStatusIsClean = false;
125  }
126  }
127 
128  // initialize min and max vectors (for normalisation)
129  fVmin[0] = 0;
130  fVmax[0] = 0;
131  fVmin[1] = 0;
132  fVmax[1] = 0;
133  fVmin[2] = 0;
134  fVmax[2] = 0;
135 
136  // initialize input variable types
137  fType[0] = 'F';
138  fType[1] = 'F';
139  fType[2] = 'F';
140 
141  // initialize constants
142  Initialize();
143 
144  }
145 
146  // destructor
147  virtual ~ReadCuts() {
148  Clear(); // method-specific
149  }
150 
151  // the classifier response
152  // "inputValues" is a vector of input values in the same order as the
153  // variables given to the constructor
154  double GetMvaValue( const std::vector<double>& inputValues ) const;
155 
156  private:
157 
158  // method-specific destructor
159  void Clear();
160 
161  // common member variables
162  const char* fClassName;
163 
164  const size_t fNvars;
165  size_t GetNvar() const { return fNvars; }
166  char GetType( int ivar ) const { return fType[ivar]; }
167 
168  // normalisation of input variables
169  const bool fIsNormalised;
170  bool IsNormalised() const { return fIsNormalised; }
171  double fVmin[3];
172  double fVmax[3];
173  double NormVariable( double x, double xmin, double xmax ) const {
174  // normalise to output range: [-1, 1]
175  return 2*(x - xmin)/(xmax - xmin) - 1.0;
176  }
177 
178  // type of input variable: 'F' or 'I'
179  char fType[3];
180 
181  // initialize internal variables
182  void Initialize();
183  double GetMvaValue__( const std::vector<double>& inputValues ) const;
184 
185  // private members (method specific)
186  // not implemented for class: "ReadCuts"
187 };
188  inline double ReadCuts::GetMvaValue( const std::vector<double>& inputValues ) const
189  {
190  // classifier response value
191  double retval = 0;
192 
193  // classifier response, sanity check first
194  if (!IsStatusClean()) {
195  std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response"
196  << " because status is dirty" << std::endl;
197  retval = 0;
198  }
199  else {
200  if (IsNormalised()) {
201  // normalise variables
202  std::vector<double> iV;
203  iV.reserve(inputValues.size());
204  int ivar = 0;
205  for (std::vector<double>::const_iterator varIt = inputValues.begin();
206  varIt != inputValues.end(); varIt++, ivar++) {
207  iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
208  }
209  retval = GetMvaValue__( iV );
210  }
211  else {
212  retval = GetMvaValue__( inputValues );
213  }
214  }
215 
216  return retval;
217  }