KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVPIDIntervalPainter.h
1
3
4#ifndef __KVPIDINTERVALPAINTER_H
5#define __KVPIDINTERVALPAINTER_H
6
7
8#include "RQ_OBJECT.h"
9
10#include "TH1.h"
11#include "TLine.h"
12#include "TMarker.h"
13#include "TLatex.h"
14#include "TCanvas.h"
15#include "KVList.h"
16#include "KVIDZAFromZGrid.h"
17
18#include "TNamed.h"
19
29 RQ_OBJECT("KVPIDIntervalPainter")
30
31 class pid_marker : public TMarker {
34 bool fDrawLabel{false};
35 bool fHighlight{false};
36 Color_t def_color{kBlack};
37 double pid;
38 public:
39 using TMarker::TMarker;
40 pid_marker() = default;
42
43 void ExecuteEvent(Int_t event, Int_t px, Int_t py);
44 void Paint(Option_t* option = "");
45 void SetDrawLabel(bool yes = true)
46 {
47 fDrawLabel = yes;
48 }
49 bool GetDrawLabel() const
50 {
51 return fDrawLabel;
52 }
53 void HighLight(bool hi = true);
54 void Update(int z, int a, double pid);
55 bool CheckPosition(double x)
56 {
60 return (!parent->active_intervals)
61 || (x >= parent->GetPIDIntervalLowerLimit() && x <= parent->GetPIDIntervalUpperLimit());
62 }
63 };
64 class pid_line : public TLine {
65 public:
66 enum class limit_t {lower, upper};
67 using TLine::TLine;
68 pid_line() = default;
69 pid_line(KVPIDIntervalPainter* p, double _pid, double ymin, double ymax, limit_t limit_type, Color_t itv_col)
70 : parent{p},
71 TLine(_pid, ymin, _pid, ymax),
72 type{limit_type},
73 def_color{itv_col},
74 pid{_pid}
75 {
77 SetLineWidth(2);
78 }
79 void ExecuteEvent(Int_t event, Int_t px, Int_t py);
81 {
82 return type;
83 }
84 bool IsUpperLimit() const
85 {
86 return GetLimitType() == limit_t::upper;
87 }
88 bool IsLowerLimit() const
89 {
90 return GetLimitType() == limit_t::lower;
91 }
92 void HighLight(bool hi = true);
93 void SetX(double X)
94 {
95 SetX1(X);
96 SetX2(X);
97 if (pid != X) {
99 pid = X;
101 if (type == limit_t::lower)
103 else
106 parent->IntMod();
107 }
108 }
109 void Update(double x)
110 {
111 SetX1(x);
112 SetX2(x);
113 pid = x;
114 }
115
116 double GetX() const
117 {
118 assert(GetX1() == GetX2());
119 return GetX1();
120 }
121 void Paint(Option_t* option = "");
122 bool CheckPosition(double x);
123
124 private:
127 bool fHighlight{false};
129 double pid;
130 };
131
132 friend class pid_marker;
133
134 TH1* fLinearHisto = nullptr;
135 interval* fInterval = nullptr;
136 TAxis* fXaxis{nullptr}, *fYaxis{nullptr};
137
138 double pid, min, max;
140
144
145 KVPIDIntervalPainter* left_interval = nullptr; // interval to the left (i.e. smaller mass) than this one
146 KVPIDIntervalPainter* right_interval = nullptr; // interval to the right (i.e. larger mass) than this one
147
148 TCanvas* fCanvas = nullptr;
149
151
152public:
166 {
167 return left_interval;
168 }
169 KVPIDIntervalPainter(interval* itv, TH1* hh, Color_t itv_color, KVPIDIntervalPainter* last_interval)
170 : TNamed(Form("%d_%d", itv->GetZ(), itv->GetA()), Form("%d_%d", itv->GetZ(), itv->GetA())),
171 fLinearHisto{hh},
172 fInterval{itv},
173 fXaxis{fLinearHisto->GetXaxis()},
174 fYaxis{fLinearHisto->GetYaxis()},
175 pid{fInterval->GetPID()},
176 min{fInterval->GetPIDmin()},
177 max{fInterval->GetPIDmax()},
178 fA{fInterval->GetA()},
179 fZ{fInterval->GetZ()},
180 fMarker{this, itv_color},
181 fLine1{this, min, 0, 200, pid_line::limit_t::lower, itv_color},
182 fLine2{this, max, 0, 200, pid_line::limit_t::upper, itv_color},
183 left_interval{last_interval}
184 {
185 if (last_interval) last_interval->set_right_interval(this);
186 }
187 KVPIDIntervalPainter(const char* name, const char* title)
188 : TNamed(name, title)
189 {}
190 KVPIDIntervalPainter(const TString& name, const TString& title)
191 : TNamed(name, title)
192 {}
193
195 {
196 active_intervals = false;
197 if (fCanvas) {
200 fCanvas->Modified();
201 fCanvas->Update();
202 }
203 }
205 {
206 active_intervals = true;
207 }
208
209 void Draw(Option_t* option = "");
210 void HighLight(bool hi = true);
211 void IntMod()
212 {
213 Emit("IntMod()");
214 }
216 {
217 fCanvas = cc;
218 }
219
220 void Update();
222 {
223 return fZ;
224 }
226 {
227 return fA;
228 }
229
230 void SetDisplayLabel(bool dis = true)
231 {
233 }
234 bool GetDisplayLabel() const
235 {
236 return fMarker.GetDrawLabel();
237 }
239 {
240 return fInterval;
241 }
242 TH1* GetHisto() const
243 {
244 return fLinearHisto;
245 }
246
252 {
253 return fXaxis->GetBinCenter(fXaxis->GetLast());
254 }
256 {
257 return fCanvas;
258 }
259
261 {
262 return fLine1.GetX();
263 }
265 {
266 return fLine2.GetX();
267 }
268 double GetPIDPosition() const
269 {
270 return fMarker.GetX();
271 }
272
273 ClassDef(KVPIDIntervalPainter, 1) // Graphical representation of a PID interval in the KVIDZAFromZGrid mass assignation GUI
274};
275
276#endif
int Int_t
#define RQ_OBJECT(sender_class)
bool Bool_t
short Color_t
double Double_t
const char Option_t
#define ClassDef(name, id)
kBlack
#define X(type, name)
winID h TVirtualViewer3D TVirtualGLPainter p
char name[80]
float ymin
float ymax
char * Form(const char *fmt,...)
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
pid_line(KVPIDIntervalPainter *p, double _pid, double ymin, double ymax, limit_t limit_type, Color_t itv_col)
Graphical representation of a PID interval in the KVIDZAFromZGrid mass assignation GUI.
KVPIDIntervalPainter * left_interval
void SetCanvas(TCanvas *cc)
Double_t GetHistoXAxisLowerLimit() const
KVPIDIntervalPainter(const char *name, const char *title)
KVPIDIntervalPainter(const TString &name, const TString &title)
double GetPIDIntervalUpperLimit() const
KVPIDIntervalPainter * get_left_interval() const
pid_line fLine1
represents lower limit of PID for interval
pid_marker fMarker
represents position of PID for interval
double GetPIDIntervalLowerLimit() const
KVPIDIntervalPainter * get_right_interval() const
KVPIDIntervalPainter * right_interval
void SetDisplayLabel(bool dis=true)
void HighLight(bool hi=true)
pid_line fLine2
represents upper limit of PID for interval
void set_right_interval(KVPIDIntervalPainter *i)
Double_t GetHistoXAxisUpperLimit() const
KVPIDIntervalPainter(interval *itv, TH1 *hh, Color_t itv_color, KVPIDIntervalPainter *last_interval)
interval * GetInterval() const
void set_left_interval(KVPIDIntervalPainter *i)
TCanvas * GetCanvas() const
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLineColor(Color_t lcolor)
virtual Double_t GetBinCenter(Int_t bin) const
Int_t GetLast() const
Int_t GetFirst() const
void Update() override
virtual void SetX2(Double_t x2)
Double_t GetX2() const
virtual void SetX1(Double_t x1)
Double_t GetX1() const
TObject * Remove(const TObjLinkPtr_t &lnk)
Double_t GetX() const
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual void Paint(Option_t *option="")
TList * GetListOfPrimitives() const override
void Modified(Bool_t flag=1) override
void SetPIDmin(double pidmin)
void SetPIDmax(double pidmax)
Double_t x[n]