Hall C ROOT/C++ Analyzer (hcana)
THcFormula.cxx
Go to the documentation of this file.
1 
17 #include "THcFormula.h"
18 #include "THcParmList.h"
19 #include "THaArrayString.h"
20 #include "THaVarList.h"
21 #include "THaCutList.h"
22 #include "THaCut.h"
23 #include "TMath.h"
24 
25 #include <iostream>
26 #include <cassert>
27 #include <numeric>
28 
29 using namespace std;
30 
31 static const Double_t kBig = 1e38; // Error value
32 
35 
36 #define ALL(c) (c).begin(), (c).end()
37 
38 //_____________________________________________________________________________
39 THcFormula::THcFormula(const char* name, const char* expression,
40  const THcParmList* plst, const THaVarList* vlst,
41  const THaCutList* clst ) :
42  THaFormula()
43 {
44  Bool_t do_register=0;
45 
46  fParmList = plst;
47  fVarList = vlst;
48  fCutList = clst;
49 
50  if( Init( name, expression ) != 0 ) {
51  RegisterFormula(false);
52  return;
53  }
54 
55  SetBit(kNotGlobal,!do_register);
56 
57  Compile(); // This calls our own Compile()
58 
59  if( do_register )
60  RegisterFormula();
61 }
62 
63 //_____________________________________________________________________________
65 {
66  if( this != &rhs ) {
67  THaFormula::operator=(rhs);
68  fParmList = rhs.fParmList;
69  }
70  return *this;
71 }
72 
73 //_____________________________________________________________________________
75  THaFormula(rhs), fParmList(rhs.fParmList)
76 {
77  // Copy ctor
78 }
79 
80 //_____________________________________________________________________________
82 {
83  // Destructor
84 }
85 
86 //_____________________________________________________________________________
88 {
89  // Check if 'name' is a known cut. If so, enter it in the local list of
90  // variables used in this formula.
91 
92  EVariableType thistype;
93  TString realname;
94  Int_t period = name.Index('.');
95  if(period < 0) {
96  realname = name;
97  thistype = kCut;
98  } else {
99  realname = name(0,period);
100  TString attribute(name(period+1,name.Length()-period-1));
101  if(attribute.CompareTo("scaler")==0 || attribute.CompareTo("npassed")==0) {
102  thistype = (EVariableType) kCutScaler;
103  } else if (attribute.CompareTo("ncalled")==0) {
104  thistype = (EVariableType) kCutNCalled;
105  } else {
106  thistype = kCut;
107  }
108  }
109  return DefinedCutWithType(realname, thistype);
110 }
111 
112 //_____________________________________________________________________________
114 {
115 
116  return DefinedGlobalVariableExtraList(name, (THaVarList*) fParmList);
117 }
118 
119 
120 //_____________________________________________________________________________
121 
THcFormula(const char *name, const char *formula, const THcParmList *, const THaVarList *, const THaCutList *clst)
Definition: THcFormula.cxx:39
virtual Int_t DefinedCut(TString &variable)
Definition: THcFormula.cxx:87
virtual ~THcFormula()
Definition: THcFormula.cxx:81
Ssiz_t Length() const
int Int_t
bool Bool_t
STL namespace.
virtual Int_t DefinedGlobalVariable(TString &variable)
Definition: THcFormula.cxx:113
THcFormula & operator=(const THcFormula &rhs)
Definition: THcFormula.cxx:64
EFuncCode
Definition: THcFormula.cxx:33
Enhanced THaFormula for use in report files.
Definition: THcFormula.h:15
double Double_t
ClassImp(THcDCLookupTTDConv) THcDCLookupTTDConv
const THcParmList * fParmList
Definition: THcFormula.h:31
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
static const Double_t kBig
Definition: THcFormula.cxx:31
A list parameters and their values.
Definition: THcParmList.h:27
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const