Crombie Tools
FormulaCorrector.cc
Go to the documentation of this file.
1 /**
2  @file FormulaCorrector.cc
3  Describes the FormulaCorrector class.
4  @author Daniel Abercrombie <dabercro@mit.edu>
5 */
6 
7 #include "FormulaCorrector.h"
8 
10 
11 //--------------------------------------------------------------------
12 FormulaCorrector::FormulaCorrector(TString name, TString formula)
13 : Corrector(name),
14  fFormulaString{formula}
15 {}
16 
17 //--------------------------------------------------------------------
19 {
20  if (fFormula)
21  delete fFormula;
22 }
23 
24 //--------------------------------------------------------------------
25 void FormulaCorrector::SetInTree(TTree* tree)
26 {
28  if (fFormula)
29  delete fFormula;
30 
31  fFormula = new TTreeFormula(fFormulaString, fFormulaString, fInTree);
32 }
33 
34 //--------------------------------------------------------------------
35 
37 {
38  return fFormula->EvalInstance();
39 }
40 
41 //--------------------------------------------------------------------
43 {
45  *newFormulaCorrector = *this;
46  newFormulaCorrector->fIsCopy = true;
47  return newFormulaCorrector;
48 }
49 
50 std::vector<TString> FormulaCorrector::GetFormulas() {
51  std::vector<TString> all_formulas {Corrector::GetFormulas()};
52  all_formulas.push_back(fFormulaString);
53  return all_formulas;
54 }