KaliVeda  1.12/06
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 
78 class KVEventClassifier : public KVVarGlob1 {
80  std::vector<double> fCuts;
81  bool fBcuts;
82  bool fBins;
83 
84  int calc_where() const;
85 
86 public:
87  KVEventClassifier() : KVVarGlob1("KVEventClassifier"), fVar(nullptr), fBcuts(false), fBins(false) {}
88  KVEventClassifier(KVVarGlob* b) : KVVarGlob1(Form("%s_EC", b->GetName())), fVar(b), fBcuts(false), fBins(false) {}
89  virtual ~KVEventClassifier() {}
90  ROOT_COPY_CTOR(KVEventClassifier, KVVarGlob1)
91  ROOT_COPY_ASSIGN_OP(KVEventClassifier)
92 
93  void Copy(TObject& other) const
94  {
96  KVVarGlob1::Copy(other);
97  ((KVEventClassifier&)other).fVar = fVar;
98  ((KVEventClassifier&)other).fCuts = fCuts;
99  ((KVEventClassifier&)other).fBcuts = fBcuts;
100  ((KVEventClassifier&)other).fBins = fBins;
101  }
103  {
104  return kFALSE;
105  }
107  {
112 
113  int where = calc_where();
114  if (fBins) {
116  if (where % 2) {
117  return where / 2;
118  }
119  return -1;
120  }
121  return where;
122  }
124  {
129 
130  if (fBins) return fCuts.size() / 2;
131  return fCuts.size();
132  }
133 
134  void AddCut(double x)
135  {
158 
159  if (fBins) {
160  Error("AddCut", "You cannot mix cuts & bins (and you already defined some bins)");
161  return;
162  }
163  fBcuts = true;
164  fCuts.push_back(x);
165  }
166  void AddBin(double xmin, double xmax)
167  {
185 
186  if (fBcuts) {
187  Error("AddBin", "You cannot mix cuts & bins (and you already defined some cuts)");
188  return;
189  }
190  fBins = true;
191  fCuts.push_back(xmin);
192  fCuts.push_back(xmax);
193  }
194 
195  void Init()
196  {
198  std::sort(fCuts.begin(), fCuts.end());
199  }
200  void Reset() {}
201  void Calculate()
202  {
204  }
205 
206  ClassDef(KVEventClassifier, 1) //Simple class for sorting events according to global variables
207 };
208 
209 #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
void AddBin(double xmin, double xmax)
virtual ~KVEventClassifier()
Bool_t IsGlobalVariable() const
int GetMaxEventClassNumber() const
std::vector< double > fCuts
cuts in variable to define event classes
KVEventClassifier(KVVarGlob *b)
void AddCut(double x)
int GetEventClassification() const
bool fBins
true if separate bins are to be used
KVVarGlob * fVar
variable used for event classification
void Copy(TObject &other) const
Make a copy of this object.
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:217
virtual const char * GetName() const
virtual void Error(const char *method, const char *msgfmt,...) const
Double_t x[n]