BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
Tof2DScin.cxx
Go to the documentation of this file.
1#include <TString.h>
2#include <TColor.h>
3#include <iostream>
4
5#include "math.h"
6#include "TMath.h"
8#include "BesVisLib/BesView.h"
10
11using namespace std;
12
13#ifndef __CINT__
15#endif
16
17//_____________________________________________________
18
20
21}
22
23//_____________________________________________________
24
25Tof2DScin::Tof2DScin(const char* name, const char* title, Int_t N, Double_t *P, Int_t part)
26{
27 SetName(name);
29 fTip = 0;
30 fHighlighted = false;
31 fFired = false;
32 fPart = part;
33
34 fTime = 0.0;
35 fCharge = 0.0;
36
37 fZRSectionTolerance[1] = 0.071; // half of gap between two scin
38 fZRSectionTolerance[2] = fZRSectionTolerance[0] = 0.1647;
39
40 // ------XY------
41
42 Double_t Pxy[3*4]; // N=8
43 for (Int_t i = 0; i < 3*4; i++) {
44 Pxy[i] = (P[i] + P[i+3*4])/2.0;
45 //if (GetName() == TString("EastEcScin0")) cout << Pxy[i] << endl;
46 }
47
48 fScinXY = new BesPolygon2D(name, title, 4, &Pxy[0]);
49 fScinXYFired = new BesPolygon2D(name, title, 4, &Pxy[0]);
50
51 // ------ZR------
52
53 Double_t Pzr[3*4];
54 Int_t iSeq[8] = {0,3,1,2,5,6,4,7}; // center of 0+3, 1+2, 5+6, 4+7
55 for (Int_t i = 0; i < 4; i++) {
56 for (Int_t j = 0; j < 3; j++) {
57 Pzr[3*i+j] = (P[3*iSeq[2*i]+j] + P[3*iSeq[2*i+1]+j])/2.0;
58 }
59 //if (GetName() == TString("EastEcScin0")) cout << Pxy[i] << endl;
60 }
61
62
63 fScinZR = new BesPolygon2D(TString(name)+TString("zr"), title, 4, &Pzr[0]);
64 fScinZRFired = new BesPolygon2D(TString(name)+TString("zr"), title, 4, &Pzr[0]);
65
66 fPhiMin = GetAngle( P[3*3], P[3*3+1] );
67 fPhiMax = GetAngle( P[3*0], P[3*0+1] );
68 //Huang Shuhui's update: Fix ZR view of Mrpc
69 if (fPhiMin > fPhiMax && fPhiMin - fPhiMax < 180.0)
70 { // not cross 0 degree
71 Double_t phiTemp = fPhiMin;
72 fPhiMin = fPhiMax;
73 fPhiMax = phiTemp;
74 }
75 //Long Peixun's update: Consider crossing 0 degree
76 if (fPhiMax > fPhiMin && fPhiMax - fPhiMin > 180.0)
77 {
78 Double_t phiTemp = fPhiMin;
79 fPhiMin = fPhiMax;
80 fPhiMax = phiTemp;
81 }
82 //cout << GetName() << " min "<< fPhiMin << " max " << fPhiMax << endl;
83
84 SetStyle();
85
86 fTip = new BesPaveText(0, 0, 0.1, 0.1);
87 CloseInfo();
88}
89
90//_____________________________________________________
91
93 //Long Peixun's update: remove "if"
94 delete fScinXY;
95 delete fScinZR;
96 delete fScinXYFired;
97 delete fScinZRFired;
98}
99
101{
102 lcScin = 15;
103 lwScin = 1;
104 fcScin = 1003; // lightYellow
105 fsScin = 1001;
106
107 lcScinFired = kRed;
108 lwScinFired = 1;
109 fcScinFired = kRed;
110 fsScinFired = 1001;
111
112 lcScinHL = lcScin;
113 lwScinHL = 1;
114 fcScinHL = kBlue;
115 fsScinHL = 1001;
116
117 lcScinFiredHL = kRed;
118 lwScinFiredHL = 2;
119 fcScinFiredHL = kBlue;
120 fsScinFiredHL = 4000;
121}
122
123
125{
126 fInfoCon.clear();
127 fTip->DeleteText();
128}
129
131{
132 if (fTip) {
133 fTip->Clear();
134
135 if (fInfoCon.size() == 0) fInfoCon.push_back(GetTitle());
136 fTip->SetText(fInfoCon);
137 }
138 else
139 cout << "Tof2DScin::CloseInfo, not initialized" << endl;
140}
141
142//_____________________________________________________
143
144Int_t Tof2DScin::DistancetoPrimitive(Int_t px, Int_t py) {
145
146 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
147 if (view->GetViewType() & kXYView && fScinXY) {
148 return fScinXY->DistancetoPrimitive(px, py);
149 }
150 else if (view->GetViewType() & kZRView && fScinZR) {
151 if (HasZRSection())
152 return fScinZR->DistancetoPrimitive(px, py);
153 }
154
155 return 9999;
156}
157
158//_____________________________________________________
159
160void Tof2DScin::ExecuteEvent(Int_t event, Int_t px, Int_t py) {
161
162 //cout << GetName() << endl;
163
164 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
165
166 if (gBesCursor->GetType() == kBesHand) {
167 if (view) view->ExecuteEvent(event, px, py);
168 }
169 else if (gBesCursor->GetType() == kBesPick){
170
171 if (gPad) gPad->SetCursor(kPointer);
172
173 switch (event) {
174
175 case kMouseEnter :
176 this->SetHighlighted(true);
177
178 //if (this->IsFired() || view->GetVisTofHitsGlobal()) {
179 Draw();
180
181 fTip->SetPos(px, py);
182 view->UpdateView(0);
183
184 //Long Peixun's update: If ShowInfo is not checked, don't show tip text.
185 if (gBesCursor->GetShowInfo()) fTip->Draw("BR,SAME"); // "BR,ARC,SAME"
186 gPad->Modified();
187 gPad->Update();
188 break;
189
190 case kMouseLeave:
191 if (this->IsHighlighted()) {
192 this->SetHighlighted(false);
193 //if (view->GetVisTofHitsGlobal())
194 Draw();
195
196 view->UpdateView(0);
197 gPad->Modified();
198 gPad->Update();
199 break;
200 }
201 }
202 }
203}
204
205//_____________________________________________________
206
207void Tof2DScin::Draw(Option_t *option) {
208 //
209 // Tof2DScin draw function
210 TString opt = option;
211 opt.ToUpper();
212
213 AppendPad(option);
214}
215
216//_____________________________________________________
217
218void Tof2DScin::Paint(Option_t *option) {
219
220 TString opt = option;
221 opt.ToUpper();
222
223 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
224 if (view->GetViewType() & kXYView) {
225
226 if (this->IsFired()) {
227 if (fScinXYFired) {
228 fScinXYFired->SetLineColor(lcScinFired);
229 fScinXYFired->SetLineWidth(lwScinFired);
230 fScinXYFired->SetFillColor(fcScinFired);
231 fScinXYFired->SetFillStyle(fsScinFired);
232 }
233 }
234
235 if (fScinXY) {
236 fScinXY->SetLineColor(lcScin);
237 fScinXY->SetLineWidth(lwScin);
238 fScinXY->SetFillColor(fcScin);
239 fScinXY->SetFillStyle(fsScin);
240 }
241
242 if (this->IsHighlighted()) {
243 if (fScinXY) {
244 fScinXY->SetLineColor(lcScinHL);
245 fScinXY->SetLineWidth(lwScinHL);
246 fScinXY->SetFillColor(fcScinHL);
247 fScinXY->SetFillStyle(fsScinHL);
248 }
249 if (fScinXYFired) {
250 fScinXYFired->SetLineColor(lcScinFiredHL);
251 fScinXYFired->SetLineWidth(lwScinFiredHL);
252 fScinXYFired->SetFillColor(fcScinFiredHL);
253 fScinXYFired->SetFillStyle(fsScinFiredHL);
254 }
255 }
256
257 if (fScinXY) fScinXY->Paint();
258 if (this->IsFired()) {
259 if (view->GetVisTofHitsGlobal() &&
260 ( (fPart == 0 && view->GetVisTofHitsEast()) ||
261 (fPart == 1 && view->GetVisTofHitsBarrel()) ||
262 (fPart == 2 && view->GetVisTofHitsWest()) )) {
263 if (fScinXYFired) {
264 //cout << "Tof fired Scin size " << fCharge/fChargeMax << endl;
265 fScinXYFired->Restore(); // restore default size
266 fScinXYFired->SetSize(fCharge/fChargeMax);
267 fScinXYFired->Paint();
268 }
269 }
270 }
271 }
272
273 if (view->GetViewType() & kZRView) {
274 if (HasZRSection()) {
275 if (this->IsFired()) {
276 if (fScinZRFired) {
277 fScinZRFired->SetLineColor(lcScinFired);
278 fScinZRFired->SetLineWidth(lwScinFired);
279 fScinZRFired->SetFillColor(fcScinFired);
280 fScinZRFired->SetFillStyle(fsScinFired);
281 }
282 }
283
284 if (fScinZR) {
285 fScinZR->SetLineColor(lcScin);
286 fScinZR->SetLineWidth(lwScin);
287 fScinZR->SetFillColor(fcScin);
288 fScinZR->SetFillStyle(fsScin);
289 }
290
291 if (this->IsHighlighted()) {
292 if (fScinZR) {
293 fScinZR->SetLineColor(lcScinHL);
294 fScinZR->SetLineWidth(lwScinHL);
295 fScinZR->SetFillColor(fcScinHL);
296 fScinZR->SetFillStyle(fsScinHL);
297 }
298 if (fScinZRFired) {
299 fScinZRFired->SetLineColor(lcScinFiredHL);
300 fScinZRFired->SetLineWidth(lwScinFiredHL);
301 fScinZRFired->SetFillColor(fcScinFiredHL);
302 fScinZRFired->SetFillStyle(fsScinFiredHL);
303 }
304 }
305
306 if (fScinZR) fScinZR->Paint();
307 if (this->IsFired()) {
308 if (view->GetVisTofHitsGlobal() &&
309 ( (fPart == 0 && view->GetVisTofHitsEast()) ||
310 (fPart == 1 && view->GetVisTofHitsBarrel()) ||
311 (fPart == 2 && view->GetVisTofHitsWest()) )) {
312 if (fScinZRFired) {
313 //cout << "Tof fired Scin size " << fCharge/fChargeMax << endl;
314 fScinZRFired->Restore(); // restore default size
315 fScinZRFired->SetSize(fCharge/fChargeMax);
316 fScinZRFired->Paint();
317 }
318 }
319 }
320 }
321 }
322
323}
324
325//_____________________________________________________
326
327char *Tof2DScin::GetObjectInfo(Int_t px, Int_t py) const {
328
329 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
330 if (view) return view->GetObjectInfo(px, py);
331 else return TObject::GetObjectInfo(px, py);
332}
333
334//_____________________________________________________
335
337{
338 bool flag = false;
339 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
340 Double_t viewPhi = view->GetLongitude();
341 viewPhi = Range360(viewPhi);
342 //if (GetName() == TString("Layer0Wire0")) cout << "view " << viewPhi << endl;
343
344 Double_t zrPhi = viewPhi-90.0;
345 zrPhi = Range360(zrPhi);
346 //if (GetName() == TString("Layer0Wire0")) cout << zrPhi << endl;
347
348 for (Int_t i = 0; i < 2; i++) {
349 if (i==1) {
350 zrPhi += 180.0;
351 zrPhi = Range360(zrPhi);
352 }
353
354 if (zrPhi >= fPhiMin-fZRSectionTolerance[GetPart()] &&
355 zrPhi <= fPhiMax+fZRSectionTolerance[GetPart()]) {
356 flag = true;
357 break;
358 }
359 else if (fPhiMin > fPhiMax) { // cross 0 degree
360 if (zrPhi >= fPhiMin-fZRSectionTolerance[GetPart()] ||
361 zrPhi <= fPhiMax+fZRSectionTolerance[GetPart()]) {
362 flag = true;
363 break;
364 }
365 }
366 }
367
368 return flag;
369}
370
371//_____________________________________________________
372
373Double_t Tof2DScin::GetAngle(Double_t x, Double_t y) //degree
374{
375 Double_t angle = TMath::ACos( x/TMath::Sqrt(x*x+y*y) ) * TMath::RadToDeg();
376 if ( y<0.0 ) angle *= -1;
377 angle = Range360(angle);
378
379 return angle;
380}
381
382//_____________________________________________________
383
384Double_t Tof2DScin::Range360(Double_t input)
385{
386 if (input >= 360.0) {
387 do {
388 input -= 360.0;
389 }
390 while (input >= 360.0);
391 }
392 else if (input < 0.0) {
393 do {
394 input += 360.0;
395 }
396 while (input < 0.0);
397 }
398
399 return input;
400}
@ kBesHand
Definition: BesCursor.h:15
@ kBesPick
Definition: BesCursor.h:14
R__EXTERN BesCursor * gBesCursor
Definition: BesCursor.h:40
@ kXYView
Definition: BesStatus.h:15
@ kZRView
Definition: BesStatus.h:16
double P(RecMdcKalTrack *trk)
cout<<"end eff5"<< endl;TGraph *gr1=new TGraphErrors(15, x, eff_ep, errx, err_ep);TGraph *gr2=new TGraphErrors(15, x, eff_em, errx, err_em);TGraph *gr3=new TGraphErrors(15, x, eff_ep2, errx, err_ep2);TGraph *gr4=new TGraphErrors(15, x, eff_em2, errx, err_em2);TGraph *gr5=new TGraphErrors(15, x, eff_ep3, errx, err_ep3);TGraph *gr6=new TGraphErrors(15, x, eff_em3, errx, err_em3);TGraph *gr7=new TGraphErrors(15, x, eff_ep4, errx, err_ep4);TGraph *gr8=new TGraphErrors(15, x, eff_em4, errx, err_em4);TGraph *gr9=new TGraphErrors(15, x, eff_ep5, errx, err_ep5);TGraph *gr10=new TGraphErrors(15, x, eff_em5, errx, err_em5);TCanvas *c1=new TCanvas("c1","bhabha_eff", 100, 10, 600, 400);TMultiGraph *mg=new TMultiGraph();mg-> SetTitle("bhabha_eff")
legend Draw()
Double_t x[10]
titledef title[20]
ClassImp(Tof2DScin) Tof2DScin
Definition: Tof2DScin.cxx:14
Bool_t GetShowInfo()
Definition: BesCursor.h:35
EBESCursorType GetType()
Definition: BesCursor.h:32
virtual void SetText(std::vector< TString > infoCon)
Definition: BesPaveText.cxx:35
virtual void SetPos(Int_t px, Int_t py)
Definition: BesPaveText.cxx:86
virtual void SetSize(Double_t size)
virtual void Paint(Option_t *option="")
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void Restore()
Double_t GetLongitude()
Definition: BesTView.h:95
virtual void UpdateView(Bool_t resetview=kFALSE)
Definition: BesView.cxx:657
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition: BesView.cxx:869
EBESViewType GetViewType()
Definition: BesView.h:71
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: BesView.cxx:366
Bool_t GetVisTofHitsWest()
Definition: BesView.h:203
Bool_t GetVisTofHitsGlobal()
Definition: BesView.h:200
Bool_t GetVisTofHitsBarrel()
Definition: BesView.h:202
Bool_t GetVisTofHitsEast()
Definition: BesView.h:201
virtual Int_t GetPart()
Definition: Tof2DScin.h:49
virtual void SetHighlighted(bool status=true)
Definition: Tof2DScin.h:30
virtual void Draw(Option_t *option="")
Definition: Tof2DScin.cxx:207
virtual bool IsFired()
Definition: Tof2DScin.h:33
Double_t Range360(Double_t input)
Definition: Tof2DScin.cxx:384
Double_t GetAngle(Double_t x, Double_t y)
Definition: Tof2DScin.cxx:373
virtual void Paint(Option_t *option="")
Definition: Tof2DScin.cxx:218
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition: Tof2DScin.cxx:327
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: Tof2DScin.cxx:160
virtual void CloseInfo()
Definition: Tof2DScin.cxx:130
virtual bool IsHighlighted()
Definition: Tof2DScin.h:32
virtual void SetStyle()
Definition: Tof2DScin.cxx:100
virtual bool HasZRSection()
Definition: Tof2DScin.cxx:336
virtual void ClearInfo()
Definition: Tof2DScin.cxx:124
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Definition: Tof2DScin.cxx:144
double y[1000]