KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVPIDIntervalPainter.h
Go to the documentation of this file.
1 
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 
27 class KVPIDIntervalPainter : public TNamed {
28  RQ_OBJECT("KVPIDIntervalPainter")
29 
30  class pid_marker : public TMarker {
33  bool fDrawLabel{false};
34  bool fHighlight{false};
35  Color_t def_color{kBlack};
36  double pid;
37  public:
38  using TMarker::TMarker;
39  pid_marker() = default;
41 
42  void ExecuteEvent(Int_t event, Int_t px, Int_t py);
43  void Paint(Option_t* option = "");
44  void SetDrawLabel(bool yes = true)
45  {
46  fDrawLabel = yes;
47  }
48  bool GetDrawLabel() const
49  {
50  return fDrawLabel;
51  }
52  void HighLight(bool hi = true);
53  void Update(int z, int a, double pid);
54  bool CheckPosition(double x)
55  {
59  return (!parent->active_intervals)
60  || (x >= parent->GetPIDIntervalLowerLimit() && x <= parent->GetPIDIntervalUpperLimit());
61  }
62  };
63  class pid_line : public TLine {
64  public:
65  enum class limit_t {lower, upper};
66  using TLine::TLine;
67  pid_line() = default;
68  pid_line(KVPIDIntervalPainter* p, double _pid, double ymin, double ymax, limit_t limit_type, Color_t itv_col)
69  : parent{p},
70  TLine(_pid, ymin, _pid, ymax),
71  type{limit_type},
72  def_color{itv_col},
73  pid{_pid}
74  {
76  SetLineWidth(2);
77  }
78  void ExecuteEvent(Int_t event, Int_t px, Int_t py);
80  {
81  return type;
82  }
83  bool IsUpperLimit() const
84  {
85  return GetLimitType() == limit_t::upper;
86  }
87  bool IsLowerLimit() const
88  {
89  return GetLimitType() == limit_t::lower;
90  }
91  void HighLight(bool hi = true);
92  void SetX(double X)
93  {
94  SetX1(X);
95  SetX2(X);
96  if (pid != X) {
98  pid = X;
100  if (type == limit_t::lower)
102  else
105  parent->IntMod();
106  }
107  }
108  void Update(double x)
109  {
110  SetX1(x);
111  SetX2(x);
112  pid = x;
113  }
114 
115  double GetX() const
116  {
117  assert(GetX1() == GetX2());
118  return GetX1();
119  }
120  void Paint(Option_t* option = "");
121  bool CheckPosition(double x);
122 
123  private:
126  bool fHighlight{false};
128  double pid;
129  };
130 
131  friend class pid_marker;
132 
133  TH1* fLinearHisto = nullptr;
134  interval* fInterval = nullptr;
135  TAxis* fXaxis{nullptr}, *fYaxis{nullptr};
136 
137  double pid, min, max;
139 
143 
144  KVPIDIntervalPainter* left_interval = nullptr; // interval to the left (i.e. smaller mass) than this one
145  KVPIDIntervalPainter* right_interval = nullptr; // interval to the right (i.e. larger mass) than this one
146 
147  TCanvas* fCanvas = nullptr;
148 
150 
151 public:
153  {
154  right_interval = i;
155  }
157  {
158  left_interval = i;
159  }
161  {
162  return right_interval;
163  }
165  {
166  return left_interval;
167  }
168  KVPIDIntervalPainter(interval* itv, TH1* hh, Color_t itv_color, KVPIDIntervalPainter* last_interval)
169  : TNamed(Form("%d_%d", itv->GetZ(), itv->GetA()), Form("%d_%d", itv->GetZ(), itv->GetA())),
170  fLinearHisto{hh},
171  fInterval{itv},
172  fXaxis{fLinearHisto->GetXaxis()},
173  fYaxis{fLinearHisto->GetYaxis()},
174  pid{fInterval->GetPID()},
175  min{fInterval->GetPIDmin()},
176  max{fInterval->GetPIDmax()},
177  fA{fInterval->GetA()},
178  fZ{fInterval->GetZ()},
179  fMarker{this, itv_color},
180  fLine1{this, min, 0, 200, pid_line::limit_t::lower, itv_color},
181  fLine2{this, max, 0, 200, pid_line::limit_t::upper, itv_color},
182  left_interval{last_interval}
183  {
184  if (last_interval) last_interval->set_right_interval(this);
185  }
186  KVPIDIntervalPainter(const char* name, const char* title)
187  : TNamed(name, title)
188  {}
189  KVPIDIntervalPainter(const TString& name, const TString& title)
190  : TNamed(name, title)
191  {}
192 
194  {
195  active_intervals = false;
196  if (fCanvas) {
199  fCanvas->Modified();
200  fCanvas->Update();
201  }
202  }
204  {
205  active_intervals = true;
206  }
207 
208  void Draw(Option_t* option = "");
209  void HighLight(bool hi = true);
210  void IntMod()
211  {
212  Emit("IntMod()");
213  }
215  {
216  fCanvas = cc;
217  }
218 
219  void Update();
221  {
222  return fZ;
223  }
225  {
226  return fA;
227  }
228 
229  void SetDisplayLabel(bool dis = true)
230  {
231  fMarker.SetDrawLabel(dis);
232  }
233  bool GetDisplayLabel() const
234  {
235  return fMarker.GetDrawLabel();
236  }
238  {
239  return fInterval;
240  }
241  TH1* GetHisto() const
242  {
243  return fLinearHisto;
244  }
245 
247  {
248  return fXaxis->GetBinCenter(fXaxis->GetFirst());
249  }
251  {
252  return fXaxis->GetBinCenter(fXaxis->GetLast());
253  }
255  {
256  return fCanvas;
257  }
258 
260  {
261  return fLine1.GetX();
262  }
264  {
265  return fLine2.GetX();
266  }
267  double GetPIDPosition() const
268  {
269  return fMarker.GetX();
270  }
271 
272  ClassDef(KVPIDIntervalPainter, 1) // Graphical representation of a PID interval in the KVIDZAFromZGrid mass assignation GUI
273 };
274 
275 #endif
int Int_t
#define RQ_OBJECT(sender_class)
bool Bool_t
double Double_t
short Color_t
const char Option_t
#define ClassDef(name, id)
kBlack
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)
KVPIDIntervalPainter * get_right_interval() const
Double_t GetHistoXAxisLowerLimit() const
KVPIDIntervalPainter(const char *name, const char *title)
KVPIDIntervalPainter(const TString &name, const TString &title)
double GetPIDIntervalUpperLimit() const
void Draw(Option_t *option="")
pid_line fLine1
represents lower limit of PID for interval
pid_marker fMarker
represents position of PID for interval
double GetPIDIntervalLowerLimit() const
TCanvas * GetCanvas() const
KVPIDIntervalPainter * right_interval
interval * GetInterval() const
void SetDisplayLabel(bool dis=true)
void HighLight(bool hi=true)
pid_line fLine2
represents upper limit of PID for interval
KVPIDIntervalPainter * get_left_interval() const
void set_right_interval(KVPIDIntervalPainter *i)
Double_t GetHistoXAxisUpperLimit() const
KVPIDIntervalPainter(interval *itv, TH1 *hh, Color_t itv_color, KVPIDIntervalPainter *last_interval)
void set_left_interval(KVPIDIntervalPainter *i)
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="")
void Modified(Bool_t flag=1) override
TList * GetListOfPrimitives() const override
void SetPIDmin(double pidmin)
void SetPIDmax(double pidmax)
Double_t x[n]
const long double cc
volumes
Definition: KVUnits.h:83