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