GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
GH1D.h
Go to the documentation of this file.
1#ifndef GH1D_H
2#define GH1D_H
3
4#include "TH1.h"
5#include "TRef.h"
6#include "TPad.h"
7#include "GuiTypes.h"
8#include "TList.h"
9#include "TBox.h"
10
11#include "Globals.h"
12#include "GH2I.h"
13
14class TF1;
15class TRegion;
16
17class GH1D : public TH1D {
18public:
19 GH1D() : fParent(nullptr), fProjectionAxis(-1) {}
20 explicit GH1D(const TVectorD& vec) : TH1D(vec), fParent(nullptr), fProjectionAxis(-1) {}
21 GH1D(const char* name, const char* title, Int_t nbinsx, const Float_t* xbins)
22 : TH1D(name, title, nbinsx, xbins), fParent(nullptr), fProjectionAxis(-1)
23 {
24 }
25 GH1D(const char* name, const char* title, Int_t nbinsx, const Double_t* xbins)
26 : TH1D(name, title, nbinsx, xbins), fParent(nullptr), fProjectionAxis(-1)
27 {
28 }
29 GH1D(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup)
30 : TH1D(name, title, nbinsx, xlow, xup), fParent(nullptr), fProjectionAxis(-1)
31 {
32 }
33
34 GH1D(const TF1& function, Int_t nbinsx, Double_t xlow, Double_t xup);
35
36 explicit GH1D(const TH1& source);
37 explicit GH1D(const TH1* source);
38 // virtual void SetOption(Option_t* option=" ");
39
40 TObject* GetParent() const { return fParent.GetObject(); }
41 void SetParent(TObject* obj) { fParent = obj; }
42
43 TVirtualPad* GetPad() const { return fPad; }
44 void SetPad(TVirtualPad* pad);
45
46 int GetProjectionAxis() const { return fProjectionAxis; }
47 void SetProjectionAxis(int axis) { fProjectionAxis = axis; }
48
49 void Clear(Option_t* opt = "") override;
50 void Print(Option_t* opt = "") const override;
51 void Copy(TObject& obj) const override;
52 void Draw(Option_t* opt = "") override;
53 TH1* DrawCopy(Option_t* opt = "", const char* name_postfix = "copy") const override;
54 TH1* DrawNormalized(Option_t* opt = "", Double_t norm = 1) const override;
55
56 bool WriteDatFile(const char* outFile);
57
58 GH1D* Project(int bins = -1);
59
60 GH1D* GetPrevious(bool DrawEmpty = false) const;
61 GH1D* GetNext(bool DrawEmpty = false) const;
62
63 GH1D* Project(double value_low, double value_high) const;
64 GH1D* Project_Background(double value_low, double value_high, double bg_value_low, double bg_value_high,
66
67 TVirtualPad* Pad() const { return fPad; }
68 TList* ListOfRegions() { return &fRegions; }
69
70 void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* selected);
71 void HandleEvent(Event_t* event, Window_t window);
72
73 void RemoveRegion(TRegion* region);
74
75 void UpdatePad()
76 {
77 fPad->Modified();
78 fPad->Update();
79 }
80 void UpdateRegions();
81 void PrintRegions();
82 void DrawRegions(Option_t* opt = "");
83
84 static void VerboseLevel(EVerbosity level) { fVerboseLevel = level; }
86
87private:
89
90 TRef fParent;
92 TVirtualPad* fPad{nullptr}; //!<!
93 // variables for regions
94 double fStartX{0.}; //!<! initial x-position of new region
95 double fStartY{0.}; //!<! initial y-position of new region
96 bool fGate{false}; //< flag to indicate that next region will be a gate region
97 bool fBackground{false}; //< flag to indicate that next region will be a background region
98 bool fRegion{false}; //< flag to indicate that next region will be a default region
99 TBox* fCurrentRegion{nullptr}; //!<! box for the current region
100 std::array<int, 3> fRegionColor{kOrange + 2, kGreen + 2, kCyan + 2}; // could be made static?
101 size_t fNofRegions{0}; //!<! counts number of regions in this histogram, only used to set the color of the region
102 TList fRegions;
103
104 static EVerbosity fVerboseLevel; //!<! level of verbosity
105
106 /// /cond CLASSIMP
107 ClassDefOverride(GH1D, 1) // NOLINT(readability-else-after-return)
108 /// /endcond
109};
110
112 kGate,
114 kRegion };
115
116class TRegion : public TBox {
117public:
118 TRegion() = default;
119 TRegion(TBox* box, ERegionType type, GH1D* parent);
120 TRegion(const TRegion&) = default;
121 TRegion(TRegion&&) = default;
122 TRegion& operator=(const TRegion&) = default;
123 TRegion& operator=(TRegion&&) = default;
124 ~TRegion() = default;
125
126 bool Update();
127 void Hide();
128 void Draw(Option_t* opt = "") override;
129
130 void Update(double startX, double stopX);
131
132private:
133 GH1D* fParent{nullptr};
135 double fLowX{0.};
136 double fHighX{0.};
137
138 /// /cond CLASSIMP
139 ClassDefOverride(TRegion, 1) // NOLINT(readability-else-after-return)
140 /// /endcond
141};
142
143#endif /* GH1D_H */
ERegionType
Definition GH1D.h:111
EBackgroundSubtraction
Definition GH2Base.h:14
EVerbosity
Definition Globals.h:143
Definition GH1D.h:17
double fStartX
! initial x-position of new region
Definition GH1D.h:94
GH1D * Project_Background(double value_low, double value_high, double bg_value_low, double bg_value_high, EBackgroundSubtraction mode=EBackgroundSubtraction::kRegionBackground) const
Definition GH1D.cxx:190
TVirtualPad * Pad() const
Definition GH1D.h:67
void SetPad(TVirtualPad *pad)
Definition GH1D.cxx:241
GH1D(const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup)
Definition GH1D.h:29
void DrawRegions(Option_t *opt="")
Definition GH1D.cxx:527
std::array< int, 3 > fRegionColor
Definition GH1D.h:100
TH1 * DrawNormalized(Option_t *opt="", Double_t norm=1) const override
Definition GH1D.cxx:134
void UpdatePad()
Definition GH1D.h:75
TList * ListOfRegions()
Definition GH1D.h:68
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject *selected)
Definition GH1D.cxx:248
void PrintRegions()
Definition GH1D.cxx:534
void RemoveCurrentRegion()
Definition GH1D.cxx:547
GH1D(const TVectorD &vec)
Definition GH1D.h:20
bool fGate
Definition GH1D.h:96
double fStartY
! initial y-position of new region
Definition GH1D.h:95
GH1D * GetNext(bool DrawEmpty=false) const
Definition GH1D.cxx:157
TRef fParent
Definition GH1D.h:90
static EVerbosity fVerboseLevel
! level of verbosity
Definition GH1D.h:104
void Copy(TObject &obj) const override
Definition GH1D.cxx:101
size_t fNofRegions
! counts number of regions in this histogram, only used to set the color of the region
Definition GH1D.h:101
void Print(Option_t *opt="") const override
Definition GH1D.cxx:95
bool WriteDatFile(const char *outFile)
Definition GH1D.cxx:43
void Clear(Option_t *opt="") override
Definition GH1D.cxx:89
GH1D(const char *name, const char *title, Int_t nbinsx, const Double_t *xbins)
Definition GH1D.h:25
TBox * fCurrentRegion
! box for the current region
Definition GH1D.h:99
static void VerboseLevel(EVerbosity level)
Definition GH1D.h:84
GH1D * GetPrevious(bool DrawEmpty=false) const
Definition GH1D.cxx:144
static EVerbosity VerboseLevel()
Definition GH1D.h:85
TVirtualPad * GetPad() const
Definition GH1D.h:43
void HandleEvent(Event_t *event, Window_t window)
Definition GH1D.cxx:278
void UpdateRegions()
Definition GH1D.cxx:520
GH1D * Project(int bins=-1)
Definition GH1D.cxx:220
int fProjectionAxis
Definition GH1D.h:91
bool fRegion
Definition GH1D.h:98
TH1 * DrawCopy(Option_t *opt="", const char *name_postfix="copy") const override
Definition GH1D.cxx:124
TList fRegions
Definition GH1D.h:102
int GetProjectionAxis() const
Definition GH1D.h:46
void SetProjectionAxis(int axis)
Definition GH1D.h:47
void SetParent(TObject *obj)
Definition GH1D.h:41
GH1D(const char *name, const char *title, Int_t nbinsx, const Float_t *xbins)
Definition GH1D.h:21
TVirtualPad * fPad
!
Definition GH1D.h:92
GH1D()
Definition GH1D.h:19
void RemoveRegion(TRegion *region)
Definition GH1D.cxx:557
bool fBackground
Definition GH1D.h:97
void Draw(Option_t *opt="") override
Definition GH1D.cxx:108
TObject * GetParent() const
Definition GH1D.h:40
~TRegion()=default
TRegion(const TRegion &)=default
TRegion & operator=(TRegion &&)=default
void Draw(Option_t *opt="") override
Definition GH1D.cxx:653
void Hide()
Definition GH1D.cxx:674
TRegion()=default
GH1D * fParent
Definition GH1D.h:133
ERegionType fType
Definition GH1D.h:134
double fHighX
Definition GH1D.h:136
TRegion(TRegion &&)=default
TRegion & operator=(const TRegion &)=default
bool Update()
Definition GH1D.cxx:579
double fLowX
Definition GH1D.h:135