KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVPIDIntervalPainter.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Mon Jan 23 14:29:32 2017
2 //Author: Diego Gruyer
3 
4 #include "KVPIDIntervalPainter.h"
5 #include "TCanvas.h"
6 #include "TFrame.h"
7 
9 
10 
11 
12 
14 KVPIDIntervalPainter::KVPIDIntervalPainter(interval* itv, TH1* hh): TNamed(Form("%d_%d", itv->GetZ(), itv->GetA()), Form("%d_%d", itv->GetZ(), itv->GetA()))
15 {
16 
17  fDisplayLabel = false;
18  fInterval = itv;
19  fLinearHisto = hh;
20  pid = fInterval->GetPID();
21  min = fInterval->GetPIDmin();
22  max = fInterval->GetPIDmax();
23  fHighlight = false;
24 
25  fZ = fInterval->GetZ();
26  fA = fInterval->GetA();
27 
28  fCanvas = 0;
29 
30  fMarker = new TMarker(pid, fLinearHisto->GetBinContent(fLinearHisto->FindBin(pid)), 23);
31  fLabel = new TLatex(fMarker->GetX(), fMarker->GetY(), Form(" (%d,%d)", fZ, fA));
32  fLabel->SetTextAlign(12);
33  fLabel->SetTextFont(42);
34  fLabel->SetTextSize(0.0421941);
35 
36  fLine1 = new TLine(min, 0, min, 200); //,fLinearHisto->GetBinContent(fLinearHisto->FindBin(min)));
37  fLine2 = new TLine(max, 0, max, 200); //,fLinearHisto->GetBinContent(fLinearHisto->FindBin(max)));
38 
39 // fMarker->SetMarkerColor(kGray+1);
40  fLine1->SetLineColor(kGray + 1);
41  fLine2->SetLineColor(kGray + 1);
42 
43  fXaxis = fLinearHisto->GetXaxis();
44  fYaxis = fLinearHisto->GetYaxis();
45 }
46 
47 
48 
49 
52 
53 KVPIDIntervalPainter::KVPIDIntervalPainter(const char* name, const char* title)
54  : TNamed(name, title)
55 {
56  // Constructor inherited from TNamed
57 }
58 
59 
60 
61 
64 
66  : TNamed(name, title)
67 {
68  // Constructor inherited from TNamed
69 }
70 
71 
72 
73 
76 
78 {
79  // Destructor
80 
86 
87  delete fMarker;
88  delete fLine1;
89  delete fLine2;
90 }
91 
92 
93 
94 
95 
97 
99 {
100  if (fMarker) fMarker->Draw();
101  if (fLine1) fLine1->Draw();
102  if (fLine2) fLine2->Draw();
103 }
104 
105 
106 
108 
110 {
111  fHighlight = hi;
112  if (hi) {
115  fLabel->SetTextColor(kRed + 1);
116  fLine1->SetLineWidth(2);
117  fLine1->SetLineColor(kRed + 1);
118  fLine2->SetLineWidth(2);
119  fLine2->SetLineColor(kRed + 1);
120  }
121  else {
125  fLine1->SetLineWidth(1);
126  fLine1->SetLineColor(kGray + 1);
127  fLine2->SetLineWidth(1);
128  fLine2->SetLineColor(kGray + 1);
129  }
130 }
131 
132 
133 
135 
137 {
138  SetName(Form("%d_%d", fInterval->GetZ(), fInterval->GetA()));
139  SetTitle(Form("%d_%d", fInterval->GetZ(), fInterval->GetA()));
140  fZ = fInterval->GetZ();
141  fA = fInterval->GetA();
142  fLabel->SetText(fLabel->GetX(), fLabel->GetY(), Form(" (%d,%d)", fZ, fA));
143 }
144 
145 
146 
148 
150 {
151  if (fDisplayLabel == dis) return;
152  fDisplayLabel = dis;
153  if (fDisplayLabel) fLabel->Draw();
155 }
156 
157 
158 
160 
162 {
163  double ym = fCanvas->GetFrame()->GetY2();
164  if (fCanvas->GetLogy()) ym = TMath::Exp(ym * TMath::Log(10));
165 
166  Color_t col = kBlack;
167  if (!(fInterval->GetA() % 2)) col = kBlue;
168 
169  if (!fHighlight) {
170  fLine1->SetLineColor(col);
171  fLine2->SetLineColor(col);
172  fMarker->SetMarkerColor(col);
173  fLabel->SetTextColor(col);
174  }
175 
176  double mi = fXaxis->GetBinCenter(fXaxis->GetFirst());
177  double ma = fXaxis->GetBinCenter(fXaxis->GetLast());
178 
179  fLine1->SetY1(0);
180  fLine2->SetY1(0);
181  if (pid > mi && pid < ma) {
182  fLine1->SetY2(ym);
183  fLine2->SetY2(ym);
185  if (fMarker->GetX() != pid) {
188  pid = fMarker->GetX();
189  if (fDisplayLabel) {
190  fLabel->SetX(fMarker->GetX());
191  fLabel->SetY(fMarker->GetY());
192  }
193  IntMod();
194  }
195  if (fLine1->GetX1() != min) {
197  min = fLine1->GetX1();
198  IntMod();
199  }
200  if (fLine2->GetX1() != max) {
202  max = fLine2->GetX1();
203  IntMod();
204  }
205  }
206  else {
207  fLine1->SetY2(0);
208  fLine2->SetY2(0);
210  }
211 }
212 
213 
214 
215 
216 
217 
218 
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
short Color_t
const char Option_t
kGray
kRed
kBlack
kBlue
float type_of_call hi(const int &, const int &)
char * Form(const char *fmt,...)
Used for mass identification GUI.
virtual void Draw(Option_t *option="")
KVPIDIntervalPainter(interval *itv, TH1 *hh)
void SetDisplayLabel(bool dis=true)
void HighLight(bool hi=true)
virtual void Paint(Option_t *chopt="")
virtual ~KVPIDIntervalPainter()
Destructor.
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerSize(Size_t msize=1)
virtual void SetTextColor(Color_t tcolor=1)
virtual Double_t GetBinCenter(Int_t bin) const
Int_t GetLast() const
Int_t GetFirst() const
Double_t GetY2() const
virtual Double_t GetBinContent(Int_t bin) const
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
virtual void SetY2(Double_t y2)
virtual void SetY1(Double_t y1)
Double_t GetX1() const
TObject * Remove(const TObjLinkPtr_t &lnk)
virtual void SetY(Double_t y)
virtual void Draw(Option_t *option="")
Double_t GetX() const
Double_t GetY() const
virtual void SetTitle(const char *title="")
virtual void SetName(const char *name)
virtual void Draw(Option_t *option="")
Int_t GetLogy() const override
TFrame * GetFrame() override
TList * GetListOfPrimitives() const override
virtual void SetText(Double_t x, Double_t y, const char *text)
Double_t GetX() const
virtual void SetY(Double_t y)
virtual void SetX(Double_t x)
Double_t GetY() const
void SetPID(double pid)
void SetPIDmin(double pidmin)
void SetPIDmax(double pidmax)
Double_t Exp(Double_t x)
Double_t Log(Double_t x)