KaliVeda
Toolkit for HIC analysis
KVEventClassifier.h
1 #ifndef __KVEVENTCLASSIFIER_H
2 #define __KVEVENTCLASSIFIER_H
3 
4 #include "KVVarGlob1.h"
5 
92 class KVEventClassifier : public KVVarGlob1 {
93  KVVarGlob* fVar;
94  TString fVal;
95  std::vector<double> fCuts;
96  bool fBcuts;
97  bool fBins;
98  bool fWithVal;
99  bool fWithExpression;
100  bool fIntegerVariable;
101  std::unique_ptr<TFormula> fFormula;
102  std::vector<std::string> fValues;
103 
104  int calc_where() const;
105 
106 public:
107  KVEventClassifier() : KVVarGlob1("KVEventClassifier"), fVar(nullptr), fVal(""), fBcuts(false),
108  fBins(false), fWithVal(false), fWithExpression(false), fIntegerVariable(false), fFormula(nullptr)
109  {}
110  KVEventClassifier(KVVarGlob* b, const TString& value = "")
111  : KVVarGlob1((value == "") ? Form("%s_EC", b->GetName()) : Form("%s_%s_EC", b->GetName(), value.Data())),
112  fVar(b), fVal(value), fBcuts(false), fBins(false), fWithVal(value != ""), fWithExpression(false), fIntegerVariable(false), fFormula(nullptr)
113  {
117  }
118  virtual ~KVEventClassifier() {}
119  ROOT_COPY_CTOR(KVEventClassifier, KVVarGlob1)
120  ROOT_COPY_ASSIGN_OP(KVEventClassifier)
121 
122  void Copy(TObject& other) const override
123  {
125  KVVarGlob1::Copy(other);
126  ((KVEventClassifier&)other).fVar = fVar;
127  ((KVEventClassifier&)other).fVal = fVal;
128  ((KVEventClassifier&)other).fCuts = fCuts;
129  ((KVEventClassifier&)other).fBcuts = fBcuts;
130  ((KVEventClassifier&)other).fBins = fBins;
131  ((KVEventClassifier&)other).fWithVal = fWithVal;
132  ((KVEventClassifier&)other).fWithExpression = fWithExpression;
133  ((KVEventClassifier&)other).fIntegerVariable = fIntegerVariable;
134  ((KVEventClassifier&)other).fFormula.reset(new TFormula(*(fFormula.get())));
135  ((KVEventClassifier&)other).fValues = fValues;
136  }
137  Bool_t IsGlobalVariable() const override
138  {
139  return kFALSE;
140  }
142  {
147 
148  int where = calc_where();
149  if (fBins) {
151  if (where % 2) {
152  return where / 2;
153  }
154  return -1;
155  }
156  return where;
157  }
159  {
164 
165  if (fBins) return fCuts.size() / 2;
166  return fCuts.size();
167  }
168 
169  void AddCut(double x)
170  {
193 
194  if (fBins) {
195  KVError::Error(this, "AddCut", "You cannot mix cuts & bins (and you already defined some bins)");
196  return;
197  }
198  fBcuts = true;
199  fCuts.push_back(x);
200  }
201  void AddBin(double xmin, double xmax)
202  {
220 
221  if (fBcuts) {
222  KVError::Error(this, "AddBin", "You cannot mix cuts & bins (and you already defined some cuts)");
223  return;
224  }
225  fBins = true;
226  fCuts.push_back(xmin);
227  fCuts.push_back(xmax);
228  }
229 
230  void Init() override;
231  void Reset() override {}
232  void Calculate() override
233  {
234  SetValue(GetEventClassification());
235  }
236 
237  ClassDefOverride(KVEventClassifier, 1) //Simple class for sorting events according to global variables
238 };
239 
240 #endif
bool Bool_t
constexpr Bool_t kFALSE
#define ClassDefOverride(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
float xmin
float xmax
char * Form(const char *fmt,...)
Simple class for sorting events according to global variables.
Bool_t IsGlobalVariable() const override
void Copy(TObject &other) const override
void AddBin(double xmin, double xmax)
void Reset() override
virtual ~KVEventClassifier()
void Init() override
int GetMaxEventClassNumber() const
KVEventClassifier(KVVarGlob *b, const TString &value="")
void AddCut(double x)
int GetEventClassification() const
void Calculate() override
Abstract base class for global variables which calculate a single value.
Definition: KVVarGlob1.h:14
void Copy(TObject &obj) const override
Definition: KVVarGlob1.h:51
Base class for all global variable implementations.
Definition: KVVarGlob.h:233
const char * GetName() const override
Double_t x[n]
void Error(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:116