Crombie Tools
TMVACorrector.h
Go to the documentation of this file.
1 /**
2  @file TMVACorrector.h
3 
4  Header file for the TMVACorrector class.
5 
6  @author Daniel Abercrombie <dabercro@mit.edu>
7 */
8 
9 #ifndef CROMBIETOOLS_SKIMMINGTOOLS_TMVACORRECTOR_H
10 #define CROMBIETOOLS_SKIMMINGTOOLS_TMVACORRECTOR_H
11 
12 #include <vector>
13 
14 #include "TString.h"
15 #include "TTreeFormula.h"
16 #include "TMVA/IMethod.h"
17 #include "TMVA/Reader.h"
18 
19 #include "Corrector.h"
20 
21 /**
22  @ingroup skimminggroup
23  @class TMVACorrector
24  @brief Can be created using the CrombieTools.SkimmingTools.TMVACorrector module.
25 
26  A TMVAcorrector Takes a given formulat and saves a branch with the formula result.
27 
28 */
29 
30 class TMVACorrector : public Corrector
31 {
32  public:
33  TMVACorrector(TString name, TString weights_file);
35 
36  /// Read a configuration file consisting of two columns: variable name and formula expression
37  void ReadVarConfig (const char* config);
38 
39  /// Copy this TMVACorrector for parallelization
40  TMVACorrector* Copy ();
41 
42  private:
43  Float_t DoEval (); ///< Evaluate the MVA weights at the current entry
44  TMVA::Reader* reader {new TMVA::Reader("Silent")}; ///< The reader used by this object
45  std::vector<Float_t> fFormulaResults; ///< Results of the formulae are stored in here for the reader
46  std::vector<TString> fVarNames; ///< Keep the variable names for copy operations
47  TString fWeightsFile; ///< Keep this variable for copy operations
48  TMVA::IMethod* method {}; ///< Pointer to method to evaluate
49 
50 };
51 
52 #endif