1 #ifndef BASE_PROCESSOR_H
2 #define BASE_PROCESSOR_H
6 #include "base/ProcMgr.h"
8 #define DefFillH1(h1, x, w) { \
9 if (h1 && fIntHistFormat) { \
10 double* arr = (double*) h1; \
11 int nbin = (int) arr[0]; \
12 int bin = (int) (nbin * (x - arr[1]) / (arr[2] - arr[1])); \
13 if (bin<0) arr[3]+=w; else \
14 if (bin>=nbin) arr[4+nbin]+=w; else arr[4+bin]+=w; \
16 if (h1) mgr()->FillH1(h1, x, w); \
20 #define DefFastFillH1(h1,x,weight) { \
23 ((double*) h1)[4+(x)] += weight; \
25 mgr()->FillH1(h1, (x), weight); \
29 #define DefFillH2(h2,x,y,weight) { \
30 if (h2 && fIntHistFormat) { \
31 double* arr = (double*) h2; \
32 int nbin1 = (int) arr[0]; \
33 int nbin2 = (int) arr[3]; \
34 int bin1 = (int) (nbin1 * (x - arr[1]) / (arr[2] - arr[1])); \
35 int bin2 = (int) (nbin2 * (y - arr[4]) / (arr[5] - arr[4])); \
36 if (bin1<0) bin1 = -1; else if (bin1>nbin1) bin1 = nbin1; \
37 if (bin2<0) bin2 = -1; else if (bin2>nbin2) bin2 = nbin2; \
38 arr[6 + (bin1+1) + (bin2+1)*(nbin1+2)]+=weight; \
40 if (h2) mgr()->FillH2(h2, x, y, weight); \
43 #define DefFastFillH2(h2,x,y) { \
44 if (h2 && fIntHistFormat) { \
45 ((double*) h2)[6 + (x+1) + (y+1) * ((int) *((double*)h2) + 2)] += 1.; \
47 if (h2) mgr()->FillH2(h2, x, y, 1.); \
72 enum { DummyBrdId = 0xffffffff };
86 Processor(
const char* name =
"",
unsigned brdid = DummyBrdId);
95 void SetSubPrefix(
const char* subname =
"",
int indx = -1,
const char* subname2 =
"",
int indx2 = -1);
98 void SetSubPrefix2(
const char* subname =
"",
int indx = -1,
const char* subname2 =
"",
int indx2 = -1);
100 H1handle
MakeH1(
const char* name,
const char* title,
int nbins,
double left,
double right,
const char* xtitle = 0);
103 inline void FillH1(H1handle h1,
double x,
double weight = 1.)
104 { DefFillH1(h1,x,weight); }
108 inline void FastFillH1(H1handle h1,
int x,
double weight = 1.)
109 { DefFastFillH1(h1,x, weight); }
128 return isGood ? nbins : 0;
138 inline void CopyH1(H1handle tgt, H1handle src)
149 H2handle
MakeH2(
const char* name,
const char* title,
int nbins1,
double left1,
double right1,
int nbins2,
double left2,
double right2,
const char* options = 0);
152 inline void FillH2(H1handle h2,
double x,
double y,
double weight = 1.)
153 { DefFillH2(h2,x,y,weight); }
158 { DefFastFillH2(h2,x,y); }
161 inline void SetH2Content(H2handle h2,
int nbin1,
int nbin2,
double v = 0.)
173 inline bool GetH2NBins(H2handle h2,
int &nBins1,
int &nBins2)
191 C1handle
MakeC1(
const char* name,
double left,
double right, H1handle h1 = 0);
193 void ChangeC1(C1handle c1,
double left,
double right);
196 inline int TestC1(C1handle c1,
double value,
double* dist = 0)
201 double GetC1Limit(C1handle c1,
bool isleft =
true);
Central data and process manager.
Definition: ProcMgr.h:30
virtual double GetH2Content(H2handle h2, int bin1, int bin2)
Get content for 2D histogram.
Definition: ProcMgr.cxx:304
virtual bool GetH2NBins(H2handle h2, int &nbins1, int &nbins2)
get number of bins for 2D histogram
Definition: ProcMgr.cxx:271
virtual void ClearH2(H2handle h2)
Clear 2D histogram.
Definition: ProcMgr.cxx:338
virtual void SetH1Content(H1handle h1, int bin, double v=0.)
set histogram content
Definition: ProcMgr.cxx:198
virtual void SetH2Title(H2handle h1, const char *title)
Set histogram title.
Definition: ProcMgr.h:149
virtual void SetH1Title(H1handle h1, const char *title)
Set histogram title.
Definition: ProcMgr.h:138
virtual int TestC1(C1handle c1, double value, double *dist=nullptr)
Condition check 0 - inside, -1 left , +1 - right If variable dist specified, will contain distance to...
Definition: ProcMgr.cxx:369
virtual void CopyH1(H1handle tgt, H1handle src)
Copy 1D histogram.
Definition: ProcMgr.cxx:226
virtual double GetH1Content(H1handle h1, int bin)
get histogram context
Definition: ProcMgr.cxx:183
virtual void ClearH1(H1handle h1)
Clear 1D histogram.
Definition: ProcMgr.cxx:213
virtual void SetH2Content(H2handle h2, int bin1, int bin2, double v=0.)
Set content for 2D histogram.
Definition: ProcMgr.cxx:321
virtual bool GetH1NBins(H1handle h1, int &nbins)
get number of histogram bins
Definition: ProcMgr.cxx:157
virtual bool RegisterObject(TObject *tobj, const char *subfolder=nullptr)
method to register ROOT objects, object should be derived from TObject class if returns true,...
Definition: ProcMgr.h:174
Abstract processor.
Definition: base/Processor.h:62
double GetH1Content(H1handle h1, int nbin)
Get bin content of 1-D histogram.
Definition: base/Processor.h:112
int GetH1NBins(H1handle h1)
Get bins numbers for 1-D histogram.
Definition: base/Processor.h:124
bool fIntHistFormat
if true, internal histogram format is used
Definition: base/Processor.h:83
void FastFillH2(H1handle h2, int x, int y)
Fast fill 2-D histogram.
Definition: base/Processor.h:157
void SetSubPrefix2(const char *subname="", int indx=-1, const char *subname2="", int indx2=-1)
Set subprefix for histograms and conditions, index uses 2 symbols.
Definition: base/Processor.cxx:96
void FillH2(H1handle h2, double x, double y, double weight=1.)
Fill 2-D histogram.
Definition: base/Processor.h:152
C1handle MakeC1(const char *name, double left, double right, H1handle h1=0)
Create condition.
Definition: base/Processor.cxx:175
unsigned GetStoreKind() const
Get store kind.
Definition: base/Processor.h:232
int fHistFilling
level of histogram filling
Definition: base/Processor.h:81
ProcMgr * mgr() const
Return manager instance.
Definition: base/Processor.h:217
virtual void UserPostLoop()
post loop
Definition: base/Processor.h:245
virtual bool RegisterObject(TObject *tobj, const char *subfolder=0)
Register object.
Definition: base/Processor.h:207
H2handle MakeH2(const char *name, const char *title, int nbins1, double left1, double right1, int nbins2, double left2, double right2, const char *options=0)
Adds processor prefix to histogram name and calls base::ProcMgr::MakeH2 method.
Definition: base/Processor.cxx:154
void FastFillH1(H1handle h1, int x, double weight=1.)
Fast fill 1-D histogram.
Definition: base/Processor.h:108
bool IsHistFilling() const
Is histogram filling enabled.
Definition: base/Processor.h:227
unsigned GetID() const
Get processor ID.
Definition: base/Processor.h:222
void SetH2Content(H2handle h2, int nbin1, int nbin2, double v=0.)
Set bin content of 2-D histogram.
Definition: base/Processor.h:161
std::string fName
processor name, used for event naming
Definition: base/Processor.h:74
virtual void SetStoreKind(unsigned kind=1)
Set store kind.
Definition: base/Processor.h:237
unsigned fID
identifier, used mostly for debugging
Definition: base/Processor.h:75
void SetH2Title(H2handle h2, const char *title)
Change title of 2-D histogram.
Definition: base/Processor.h:186
void SetPathPrefix(const std::string &prefix)
Set path prefix for histogramsid.
Definition: base/Processor.h:92
bool GetH2NBins(H2handle h2, int &nBins1, int &nBins2)
Get number of bins for 2-D histogram.
Definition: base/Processor.h:173
int TestC1(C1handle c1, double value, double *dist=0)
Test condition.
Definition: base/Processor.h:196
int HistFillLevel() const
Get histogram filling level.
Definition: base/Processor.h:229
H1handle MakeH1(const char *name, const char *title, int nbins, double left, double right, const char *xtitle=0)
Adds processor prefix to histogram name and calls base::ProcMgr::MakeH1 method.
Definition: base/Processor.cxx:132
void ClearH1(H1handle h1)
Clear 1-D histogram.
Definition: base/Processor.h:132
void SetStoreEnabled(bool on=true)
Enable store - set store kind 1.
Definition: base/Processor.h:239
void SetH1Content(H1handle h1, int nbin, double v=0.)
Set bin content of 1-D histogram.
Definition: base/Processor.h:118
unsigned fStoreKind
if >0, store will be enabled for processor
Definition: base/Processor.h:82
double GetC1Limit(C1handle c1, bool isleft=true)
Get condition limit.
Definition: base/Processor.cxx:199
virtual void CreateBranch(TTree *)
Create branch.
Definition: base/Processor.h:204
std::string fSubPrefixD
sub-prefix for histogram directory
Definition: base/Processor.h:79
ProcMgr * fMgr
direct pointer on manager
Definition: base/Processor.h:76
Processor(const char *name="", unsigned brdid=DummyBrdId)
Make constructor protected - no way to create base class instance.
Definition: base/Processor.cxx:12
const char * GetName() const
Get processor name.
Definition: base/Processor.h:220
std::string fPrefix
prefix, used for histogram names
Definition: base/Processor.h:78
void SetH1Title(H1handle h1, const char *title)
Set 1-D histogram title.
Definition: base/Processor.h:144
void ChangeC1(C1handle c1, double left, double right)
Change condition limits.
Definition: base/Processor.cxx:191
void CopyH1(H1handle tgt, H1handle src)
Copy 1-D histogram from src to tgt.
Definition: base/Processor.h:138
bool IsStoreEnabled() const
Is store enabled.
Definition: base/Processor.h:234
void ClearH2(base::H2handle h2)
Clear 2-D histogram.
Definition: base/Processor.h:180
double GetH2Content(H2handle h2, int bin1, int bin2)
Get bin content of 2-D histogram.
Definition: base/Processor.h:167
void FillH1(H1handle h1, double x, double weight=1.)
Fill 1-D histogram.
Definition: base/Processor.h:103
void SetBoardId(unsigned id)
Set board id.
Definition: base/Processor.h:89
void SetSubPrefix(const char *subname="", int indx=-1, const char *subname2="", int indx2=-1)
Set subprefix for histograms and conditions.
Definition: base/Processor.cxx:60
void SetHistFilling(int lvl=99)
Set histogram filling level.
Definition: base/Processor.h:225
virtual ~Processor()
destructor
Definition: base/Processor.cxx:39
virtual void UserPreLoop()
pre loop
Definition: base/Processor.h:242
std::string fSubPrefixN
sub-prefix for histogram names
Definition: base/Processor.h:80
std::string fPathPrefix
histogram path prefix, used for histogram folder name
Definition: base/Processor.h:77