KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVEventClassifier.h
1#ifndef __KVEVENTCLASSIFIER_H
2#define __KVEVENTCLASSIFIER_H
3
4#include "KVVarGlob1.h"
5
95 std::vector<double> fCuts;
96 bool fBcuts;
97 bool fBins;
101 std::unique_ptr<TFormula> fFormula;
102 std::vector<std::string> fValues;
103
104 int calc_where() const;
105
106public:
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 }
119 ROOT_COPY_CTOR(KVEventClassifier, KVVarGlob1)
120 ROOT_COPY_ASSIGN_OP(KVEventClassifier)
121
122 void Copy(TObject& other) const
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 }
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 Error("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 Error("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();
231 void Reset() {}
233 {
235 }
236
237 ClassDef(KVEventClassifier, 1) //Simple class for sorting events according to global variables
238};
239
240#endif
bool Bool_t
constexpr Bool_t kFALSE
#define ClassDef(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 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)
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
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:14
void SetValue(Double_t val)
Definition KVVarGlob1.h:27
void Copy(TObject &obj) const
Definition KVVarGlob1.h:51
Base class for all global variable implementations.
Definition KVVarGlob.h:233
const char * GetName() const override
virtual void Error(const char *method, const char *msgfmt,...) const
Double_t x[n]