Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pairback_Cuts.class.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pairback_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:30:11 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: 6750
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 CutRangeMax[0]: "-1.000000e+00" [Maximum of allowed cut range (set per variable)]
38  CutRangeMax[1]: "-1.000000e+00"
39  CutRangeMax[2]: "-1.000000e+00"
40  CutRangeMax[3]: "-1.000000e+00"
41  CutRangeMax[4]: "-1.000000e+00"
42 VarProp[0]: "NotEnforced" [Categorisation of cuts]
43  VarProp[1]: "NotEnforced"
44  VarProp[2]: "NotEnforced"
45  VarProp[3]: "NotEnforced"
46  VarProp[4]: "NotEnforced"
47 ##
48 
49 
50 #VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-
51 
52 NVar 5
53 abs(track_deta) abs_track_deta_ abs(track_deta) abs(track_deta) 'F' [3.57627868652e-07,1.97799444199]
54 abs(cluster_deta) abs_cluster_deta_ abs(cluster_deta) abs(cluster_deta) 'F' [0,0.0315845087171]
55 abs(cluster_dphi) abs_cluster_dphi_ abs(cluster_dphi) abs(cluster_dphi) 'F' [0,6.23594331741]
56 abs(track_dlayer) abs_track_dlayer_ abs(track_dlayer) abs(track_dlayer) 'I' [0,15]
57 approach_dist approach_dist approach_dist approach_dist 'F' [1.41833572798e-06,73.1929855347]
58 NSpec 4
59 track_layer track_layer track_layer I 'F' [0,22]
60 track_pT track_pT track_pT F 'F' [2.01860404015,9702.08203125]
61 track_dca track_dca track_dca F 'F' [1.29460659082e-05,64.1267471313]
62 cluster_prob cluster_prob cluster_prob F 'F' [0,0.999049782753]
63 
64 
65 ============================================================================ */
66 
67 #include <vector>
68 #include <cmath>
69 #include <string>
70 #include <iostream>
71 
72 #ifndef IClassifierReader__def
73 #define IClassifierReader__def
74 
75 class IClassifierReader {
76 
77  public:
78 
79  // constructor
81  virtual ~IClassifierReader() {}
82 
83  // return classifier response
84  virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;
85 
86  // returns classifier status
87  bool IsStatusClean() const { return fStatusIsClean; }
88 
89  protected:
90 
91  bool fStatusIsClean;
92 };
93 
94 #endif
95 
96 class ReadCuts : public IClassifierReader {
97 
98  public:
99 
100  // constructor
101  ReadCuts( std::vector<std::string>& theInputVars )
102  : IClassifierReader(),
103  fClassName( "ReadCuts" ),
104  fNvars( 5 ),
106  {
107  // the training input variables
108  const char* inputVars[] = { "abs(track_deta)", "abs(cluster_deta)", "abs(cluster_dphi)", "abs(track_dlayer)", "approach_dist" };
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 
143  // initialize input variable types
144  fType[0] = 'F';
145  fType[1] = 'F';
146  fType[2] = 'F';
147  fType[3] = 'I';
148  fType[4] = 'F';
149 
150  // initialize constants
151  Initialize();
152 
153  }
154 
155  // destructor
156  virtual ~ReadCuts() {
157  Clear(); // method-specific
158  }
159 
160  // the classifier response
161  // "inputValues" is a vector of input values in the same order as the
162  // variables given to the constructor
163  double GetMvaValue( const std::vector<double>& inputValues ) const;
164 
165  private:
166 
167  // method-specific destructor
168  void Clear();
169 
170  // common member variables
171  const char* fClassName;
172 
173  const size_t fNvars;
174  size_t GetNvar() const { return fNvars; }
175  char GetType( int ivar ) const { return fType[ivar]; }
176 
177  // normalisation of input variables
178  const bool fIsNormalised;
179  bool IsNormalised() const { return fIsNormalised; }
180  double fVmin[5];
181  double fVmax[5];
182  double NormVariable( double x, double xmin, double xmax ) const {
183  // normalise to output range: [-1, 1]
184  return 2*(x - xmin)/(xmax - xmin) - 1.0;
185  }
186 
187  // type of input variable: 'F' or 'I'
188  char fType[5];
189 
190  // initialize internal variables
191  void Initialize();
192  double GetMvaValue__( const std::vector<double>& inputValues ) const;
193 
194  // private members (method specific)
195  // not implemented for class: "ReadCuts"
196 };
197  inline double ReadCuts::GetMvaValue( const std::vector<double>& inputValues ) const
198  {
199  // classifier response value
200  double retval = 0;
201 
202  // classifier response, sanity check first
203  if (!IsStatusClean()) {
204  std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response"
205  << " because status is dirty" << std::endl;
206  retval = 0;
207  }
208  else {
209  if (IsNormalised()) {
210  // normalise variables
211  std::vector<double> iV;
212  iV.reserve(inputValues.size());
213  int ivar = 0;
214  for (std::vector<double>::const_iterator varIt = inputValues.begin();
215  varIt != inputValues.end(); varIt++, ivar++) {
216  iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
217  }
218  retval = GetMvaValue__( iV );
219  }
220  else {
221  retval = GetMvaValue__( inputValues );
222  }
223  }
224 
225  return retval;
226  }