KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVEventClassifier.h
Go to the documentation of this file.
1 #ifndef __KVEVENTCLASSIFIER_H
2 #define __KVEVENTCLASSIFIER_H
3 
4 #include "KVVarGlob1.h"
5 
91 class KVEventClassifier : public KVVarGlob1 {
94  std::vector<double> fCuts;
95  bool fBcuts;
96  bool fBins;
97  bool fWithVal;
100  std::unique_ptr<TFormula> fFormula;
101  std::vector<std::string> fValues;
102 
103  int calc_where() const;
104 
105 public:
106  KVEventClassifier() : KVVarGlob1("KVEventClassifier"), fVar(nullptr), fVal(""), fBcuts(false),
107  fBins(false), fWithVal(false), fWithExpression(false), fIntegerVariable(false), fFormula(nullptr)
108  {}
109  KVEventClassifier(KVVarGlob* b, const TString& value = "")
110  : KVVarGlob1((value == "") ? Form("%s_EC", b->GetName()) : Form("%s_%s_EC", b->GetName(), value.Data())),
111  fVar(b), fVal(value), fBcuts(false), fBins(false), fWithVal(value != ""), fWithExpression(false), fIntegerVariable(false), fFormula(nullptr)
112  {
116  }
117  virtual ~KVEventClassifier() {}
118  ROOT_COPY_CTOR(KVEventClassifier, KVVarGlob1)
119  ROOT_COPY_ASSIGN_OP(KVEventClassifier)
120 
121  void Copy(TObject& other) const
122  {
124  KVVarGlob1::Copy(other);
125  ((KVEventClassifier&)other).fVar = fVar;
126  ((KVEventClassifier&)other).fVal = fVal;
127  ((KVEventClassifier&)other).fCuts = fCuts;
128  ((KVEventClassifier&)other).fBcuts = fBcuts;
129  ((KVEventClassifier&)other).fBins = fBins;
130  ((KVEventClassifier&)other).fWithVal = fWithVal;
131  ((KVEventClassifier&)other).fWithExpression = fWithExpression;
132  ((KVEventClassifier&)other).fIntegerVariable = fIntegerVariable;
133  ((KVEventClassifier&)other).fFormula.reset(new TFormula(*(fFormula.get())));
134  ((KVEventClassifier&)other).fValues = fValues;
135  }
137  {
138  return kFALSE;
139  }
141  {
146 
147  int where = calc_where();
148  if (fBins) {
150  if (where % 2) {
151  return where / 2;
152  }
153  return -1;
154  }
155  return where;
156  }
158  {
163 
164  if (fBins) return fCuts.size() / 2;
165  return fCuts.size();
166  }
167 
168  void AddCut(double x)
169  {
192 
193  if (fBins) {
194  Error("AddCut", "You cannot mix cuts & bins (and you already defined some bins)");
195  return;
196  }
197  fBcuts = true;
198  fCuts.push_back(x);
199  }
200  void AddBin(double xmin, double xmax)
201  {
219 
220  if (fBcuts) {
221  Error("AddBin", "You cannot mix cuts & bins (and you already defined some cuts)");
222  return;
223  }
224  fBins = true;
225  fCuts.push_back(xmin);
226  fCuts.push_back(xmax);
227  }
228 
229  void Init();
230  void Reset() {}
231  void Calculate()
232  {
234  }
235 
236  ClassDef(KVEventClassifier, 1) //Simple class for sorting events according to global variables
237 };
238 
239 #endif
#define b(i)
const Bool_t kFALSE
bool Bool_t
#define ClassDef(name, id)
float xmin
float xmax
char * Form(const char *fmt,...)
Simple class for sorting events according to global variables.
bool fBcuts
true if cuts are to be used
std::unique_ptr< TFormula > fFormula
in case a combination of values is used
void AddBin(double xmin, double xmax)
virtual ~KVEventClassifier()
Bool_t IsGlobalVariable() const
int GetMaxEventClassNumber() const
bool fWithExpression
true if an expression using several values is used
std::vector< double > fCuts
cuts in variable to define event classes
KVEventClassifier(KVVarGlob *b, const TString &value="")
std::vector< std::string > fValues
indices of values in parsed expression
void AddCut(double x)
int GetEventClassification() const
bool fBins
true if separate bins are to be used
bool fWithVal
true if named value given
bool fIntegerVariable
true if global variable used for cuts has integer values
KVVarGlob * fVar
variable used for event classification
void Copy(TObject &other) const
Make a copy of this object.
TString fVal
optional name of value calculated by variable to use
Abstract base class for global variables which calculate a single value.
Definition: KVVarGlob1.h:13
void SetValue(Double_t val)
Definition: KVVarGlob1.h:26
void Copy(TObject &obj) const
Make a copy of this object.
Definition: KVVarGlob1.h:50
Base class for all global variable implementations.
Definition: KVVarGlob.h:231
virtual const char * GetName() const
virtual void Error(const char *method, const char *msgfmt,...) const
Double_t x[n]