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 : Mon Jul 22 19:11:42 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 : /home/condor/local/sdcc/execute/dir_48382/training
16 Training events: 52985
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 CutRangeMax[0]: "-1.000000e+00" [Maximum of allowed cut range (set per variable)]
39  CutRangeMax[1]: "-1.000000e+00"
40  CutRangeMax[2]: "-1.000000e+00"
41  CutRangeMax[3]: "-1.000000e+00"
42  CutRangeMax[4]: "-1.000000e+00"
43  CutRangeMax[5]: "-1.000000e+00"
44 VarProp[0]: "NotEnforced" [Categorisation of cuts]
45  VarProp[1]: "NotEnforced"
46  VarProp[2]: "NotEnforced"
47  VarProp[3]: "NotEnforced"
48  VarProp[4]: "NotEnforced"
49  VarProp[5]: "NotEnforced"
50 ##
51 
52 
53 #VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-
54 
55 NVar 6
56 track_deta track_deta track_deta track_deta 'F' [0,1.75113081932]
57 track_pT track_pT track_pT track_pT 'F' [0.201775103807,270.302978516]
58 approach_dist approach_dist approach_dist approach_dist 'F' [5.6726735238e-06,201.640762329]
59 vtx_radius vtx_radius vtx_radius vtx_radius 'F' [2.12119351505e-32,335.550384521]
60 vtx_chi2 vtx_chi2 vtx_chi2 vtx_chi2 'F' [-0.0747850388288,305.772888184]
61 cluster_prob cluster_prob cluster_prob cluster_prob 'F' [0,0.999983727932]
62 NSpec 0
63 
64 
65 ============================================================================ */
66 
67 #include <array>
68 #include <vector>
69 #include <cmath>
70 #include <string>
71 #include <iostream>
72 
73 #ifndef IClassifierReader__def
74 #define IClassifierReader__def
75 
76 class IClassifierReader {
77 
78  public:
79 
80  // constructor
82  virtual ~IClassifierReader() {}
83 
84  // return classifier response
85  virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;
86 
87  // returns classifier status
88  bool IsStatusClean() const { return fStatusIsClean; }
89 
90  protected:
91 
92  bool fStatusIsClean;
93 };
94 
95 #endif
96 
97 class ReadCuts : public IClassifierReader {
98 
99  public:
100 
101  // constructor
102  ReadCuts( std::vector<std::string>& theInputVars )
103  : IClassifierReader(),
104  fClassName( "ReadCuts" ),
105  fNvars( 6 )
106  {
107  // the training input variables
108  const char* inputVars[] = { "track_deta", "track_pT", "approach_dist", "vtx_radius", "vtx_chi2", "cluster_prob" };
109 
110  // sanity checks
111  if (theInputVars.size() <= 0) {
112  std::cout << "Problem in class \"" << fClassName << "\": empty input vector" << std::endl;
113  fStatusIsClean = false;
114  }
115 
116  if (theInputVars.size() != fNvars) {
117  std::cout << "Problem in class \"" << fClassName << "\": mismatch in number of input values: "
118  << theInputVars.size() << " != " << fNvars << std::endl;
119  fStatusIsClean = false;
120  }
121 
122  // validate input variables
123  for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
124  if (theInputVars[ivar] != inputVars[ivar]) {
125  std::cout << "Problem in class \"" << fClassName << "\": mismatch in input variable names" << std::endl
126  << " for variable [" << ivar << "]: " << theInputVars[ivar].c_str() << " != " << inputVars[ivar] << std::endl;
127  fStatusIsClean = false;
128  }
129  }
130 
131  // initialize min and max vectors (for normalisation)
132  fVmin[0] = 0;
133  fVmax[0] = 0;
134  fVmin[1] = 0;
135  fVmax[1] = 0;
136  fVmin[2] = 0;
137  fVmax[2] = 0;
138  fVmin[3] = 0;
139  fVmax[3] = 0;
140  fVmin[4] = 0;
141  fVmax[4] = 0;
142  fVmin[5] = 0;
143  fVmax[5] = 0;
144 
145  // initialize input variable types
146  fType[0] = 'F';
147  fType[1] = 'F';
148  fType[2] = 'F';
149  fType[3] = 'F';
150  fType[4] = 'F';
151  fType[5] = 'F';
152 
153  // initialize constants
154  Initialize();
155 
156  }
157 
158  // destructor
159  virtual ~ReadCuts() {
160  Clear(); // method-specific
161  }
162 
163  // the classifier response
164  // "inputValues" is a vector of input values in the same order as the
165  // variables given to the constructor
166  double GetMvaValue( const std::vector<double>& inputValues ) const override;
167 
168  private:
169 
170  // method-specific destructor
171  void Clear();
172 
173  // common member variables
174  const char* fClassName;
175 
176  const size_t fNvars;
177  size_t GetNvar() const { return fNvars; }
178  char GetType( int ivar ) const { return fType[ivar]; }
179 
180  // normalisation of input variables
181  double fVmin[6];
182  double fVmax[6];
183  double NormVariable( double x, double xmin, double xmax ) const {
184  // normalise to output range: [-1, 1]
185  return 2*(x - xmin)/(xmax - xmin) - 1.0;
186  }
187 
188  // type of input variable: 'F' or 'I'
189  char fType[6];
190 
191  // initialize internal variables
192  void Initialize();
193  double GetMvaValue__( const std::vector<double>& inputValues ) const;
194 
195  // private members (method specific)
196  // not implemented for class: "ReadCuts"
197 };
198  inline double ReadCuts::GetMvaValue( const std::vector<double>& inputValues ) const
199  {
200  // classifier response value
201  double retval = 0;
202 
203  // classifier response, sanity check first
204  if (!IsStatusClean()) {
205  std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response"
206  << " because status is dirty" << std::endl;
207  retval = 0;
208  }
209  else {
210  retval = GetMvaValue__( inputValues );
211  }
212 
213  return retval;
214  }