BOSS 7.0.1
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"
7#include "BesVisLib/Tof2DScin.h"
8#include "BesVisLib/BesView.h"
9#include "BesVisLib/BesCursor.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);
28 SetTitle(title);
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 if (GetPart() == 2) {
69 Double_t phiTemp = fPhiMin;
70 fPhiMin = fPhiMax;
71 fPhiMax = phiTemp;
72 }
73 //cout << GetName() << " min "<< fPhiMin << " max " << fPhiMax << endl;
74
75 SetStyle();
76
77 fTip = new BesPaveText(0, 0, 0.1, 0.1);
78 CloseInfo();
79}
80
81//_____________________________________________________
82
84
85 if (fScinXY) delete fScinXY;
86 if (fScinZR) delete fScinZR;
87 if (fScinXYFired) delete fScinXYFired;
88 if (fScinZRFired) delete fScinZRFired;
89}
90
92{
93 lcScin = 15;
94 lwScin = 1;
95 fcScin = 1003; // lightYellow
96 fsScin = 1001;
97
98 lcScinFired = kRed;
99 lwScinFired = 1;
100 fcScinFired = kRed;
101 fsScinFired = 1001;
102
103 lcScinHL = lcScin;
104 lwScinHL = 1;
105 fcScinHL = kBlue;
106 fsScinHL = 1001;
107
108 lcScinFiredHL = kRed;
109 lwScinFiredHL = 2;
110 fcScinFiredHL = kBlue;
111 fsScinFiredHL = 4000;
112}
113
114
116{
117 fInfoCon.clear();
118 fTip->DeleteText();
119}
120
122{
123 if (fTip) {
124 fTip->Clear();
125
126 if (fInfoCon.size() == 0) fInfoCon.push_back(GetTitle());
127 fTip->SetText(fInfoCon);
128 }
129 else
130 cout << "Tof2DScin::CloseInfo, not initialized" << endl;
131}
132
133//_____________________________________________________
134
135Int_t Tof2DScin::DistancetoPrimitive(Int_t px, Int_t py) {
136
137 BesView *view = (BesView*)gPad->GetView();
138 if (view->GetViewType() & kXYView && fScinXY) {
139 return fScinXY->DistancetoPrimitive(px, py);
140 }
141 else if (view->GetViewType() & kZRView && fScinZR) {
142 if (HasZRSection())
143 return fScinZR->DistancetoPrimitive(px, py);
144 }
145
146 return 9999;
147}
148
149//_____________________________________________________
150
151void Tof2DScin::ExecuteEvent(Int_t event, Int_t px, Int_t py) {
152
153 //cout << GetName() << endl;
154
155 BesView *view = (BesView*)gPad->GetView();
156
157 if (gBesCursor->GetType() == kBesHand) {
158 if (view) view->ExecuteEvent(event, px, py);
159 }
160 else if (gBesCursor->GetType() == kBesPick){
161
162 if (gPad) gPad->SetCursor(kPointer);
163
164 switch (event) {
165
166 case kMouseEnter :
167 this->SetHighlighted(true);
168
169 //if (this->IsFired() || view->GetVisTofHitsGlobal()) {
170 Draw();
171
172 fTip->SetPos(px, py);
173 view->UpdateView(0);
174
175 fTip->Draw("BR,SAME"); // "BR,ARC,SAME"
176 gPad->Modified();
177 gPad->Update();
178 break;
179
180 case kMouseLeave:
181 if (this->IsHighlighted()) {
182 this->SetHighlighted(false);
183 //if (view->GetVisTofHitsGlobal())
184 Draw();
185
186 view->UpdateView(0);
187 gPad->Modified();
188 gPad->Update();
189 break;
190 }
191 }
192 }
193}
194
195//_____________________________________________________
196
197void Tof2DScin::Draw(Option_t *option) {
198 //
199 // Tof2DScin draw function
200 TString opt = option;
201 opt.ToUpper();
202
203 AppendPad(option);
204}
205
206//_____________________________________________________
207
208void Tof2DScin::Paint(Option_t *option) {
209
210 TString opt = option;
211 opt.ToUpper();
212
213 BesView *view = (BesView*)gPad->GetView();
214 if (view->GetViewType() & kXYView) {
215
216 if (this->IsFired()) {
217 if (fScinXYFired) {
218 fScinXYFired->SetLineColor(lcScinFired);
219 fScinXYFired->SetLineWidth(lwScinFired);
220 fScinXYFired->SetFillColor(fcScinFired);
221 fScinXYFired->SetFillStyle(fsScinFired);
222 }
223 }
224
225 if (fScinXY) {
226 fScinXY->SetLineColor(lcScin);
227 fScinXY->SetLineWidth(lwScin);
228 fScinXY->SetFillColor(fcScin);
229 fScinXY->SetFillStyle(fsScin);
230 }
231
232 if (this->IsHighlighted()) {
233 if (fScinXY) {
234 fScinXY->SetLineColor(lcScinHL);
235 fScinXY->SetLineWidth(lwScinHL);
236 fScinXY->SetFillColor(fcScinHL);
237 fScinXY->SetFillStyle(fsScinHL);
238 }
239 if (fScinXYFired) {
240 fScinXYFired->SetLineColor(lcScinFiredHL);
241 fScinXYFired->SetLineWidth(lwScinFiredHL);
242 fScinXYFired->SetFillColor(fcScinFiredHL);
243 fScinXYFired->SetFillStyle(fsScinFiredHL);
244 }
245 }
246
247 if (fScinXY) fScinXY->Paint();
248 if (this->IsFired()) {
249 if (view->GetVisTofHitsGlobal() &&
250 ( (fPart == 0 && view->GetVisTofHitsEast()) ||
251 (fPart == 1 && view->GetVisTofHitsBarrel()) ||
252 (fPart == 2 && view->GetVisTofHitsWest()) )) {
253 if (fScinXYFired) {
254 //cout << "Tof fired Scin size " << fCharge/fChargeMax << endl;
255 fScinXYFired->Restore(); // restore default size
256 fScinXYFired->SetSize(fCharge/fChargeMax);
257 fScinXYFired->Paint();
258 }
259 }
260 }
261 }
262
263 if (view->GetViewType() & kZRView) {
264 if (HasZRSection()) {
265 if (this->IsFired()) {
266 if (fScinZRFired) {
267 fScinZRFired->SetLineColor(lcScinFired);
268 fScinZRFired->SetLineWidth(lwScinFired);
269 fScinZRFired->SetFillColor(fcScinFired);
270 fScinZRFired->SetFillStyle(fsScinFired);
271 }
272 }
273
274 if (fScinZR) {
275 fScinZR->SetLineColor(lcScin);
276 fScinZR->SetLineWidth(lwScin);
277 fScinZR->SetFillColor(fcScin);
278 fScinZR->SetFillStyle(fsScin);
279 }
280
281 if (this->IsHighlighted()) {
282 if (fScinZR) {
283 fScinZR->SetLineColor(lcScinHL);
284 fScinZR->SetLineWidth(lwScinHL);
285 fScinZR->SetFillColor(fcScinHL);
286 fScinZR->SetFillStyle(fsScinHL);
287 }
288 if (fScinZRFired) {
289 fScinZRFired->SetLineColor(lcScinFiredHL);
290 fScinZRFired->SetLineWidth(lwScinFiredHL);
291 fScinZRFired->SetFillColor(fcScinFiredHL);
292 fScinZRFired->SetFillStyle(fsScinFiredHL);
293 }
294 }
295
296 if (fScinZR) fScinZR->Paint();
297 if (this->IsFired()) {
298 if (view->GetVisTofHitsGlobal() &&
299 ( (fPart == 0 && view->GetVisTofHitsEast()) ||
300 (fPart == 1 && view->GetVisTofHitsBarrel()) ||
301 (fPart == 2 && view->GetVisTofHitsWest()) )) {
302 if (fScinZRFired) {
303 //cout << "Tof fired Scin size " << fCharge/fChargeMax << endl;
304 fScinZRFired->Restore(); // restore default size
305 fScinZRFired->SetSize(fCharge/fChargeMax);
306 fScinZRFired->Paint();
307 }
308 }
309 }
310 }
311 }
312
313}
314
315//_____________________________________________________
316
317char *Tof2DScin::GetObjectInfo(Int_t px, Int_t py) const {
318
319 BesView *view = (BesView*)gPad->GetView();
320 if (view) return view->GetObjectInfo(px, py);
321 else return TObject::GetObjectInfo(px, py);
322}
323
324//_____________________________________________________
325
327{
328 bool flag = false;
329 BesView *view = (BesView*)gPad->GetView();
330 Double_t viewPhi = view->GetLongitude();
331 viewPhi = Range360(viewPhi);
332 //if (GetName() == TString("Layer0Wire0")) cout << "view " << viewPhi << endl;
333
334 Double_t zrPhi = viewPhi-90.0;
335 zrPhi = Range360(zrPhi);
336 //if (GetName() == TString("Layer0Wire0")) cout << zrPhi << endl;
337
338 for (Int_t i = 0; i < 2; i++) {
339 if (i==1) {
340 zrPhi += 180.0;
341 zrPhi = Range360(zrPhi);
342 }
343
344 if (zrPhi >= fPhiMin-fZRSectionTolerance[GetPart()] &&
345 zrPhi <= fPhiMax+fZRSectionTolerance[GetPart()]) {
346 flag = true;
347 break;
348 }
349 else if (fPhiMin > fPhiMax) { // cross 0 degree
350 if (zrPhi >= fPhiMin-fZRSectionTolerance[GetPart()] ||
351 zrPhi <= fPhiMax+fZRSectionTolerance[GetPart()]) {
352 flag = true;
353 break;
354 }
355 }
356 }
357
358 return flag;
359}
360
361//_____________________________________________________
362
363Double_t Tof2DScin::GetAngle(Double_t x, Double_t y) //degree
364{
365 Double_t angle = TMath::ACos( x/TMath::Sqrt(x*x+y*y) ) * TMath::RadToDeg();
366 if ( y<0.0 ) angle *= -1;
367 angle = Range360(angle);
368
369 return angle;
370}
371
372//_____________________________________________________
373
374Double_t Tof2DScin::Range360(Double_t input)
375{
376 if (input >= 360.0) {
377 do {
378 input -= 360.0;
379 }
380 while (input >= 360.0);
381 }
382 else if (input < 0.0) {
383 do {
384 input += 360.0;
385 }
386 while (input < 0.0);
387 }
388
389 return input;
390}
double P(RecMdcKalTrack *trk)
gr SetTitle("BbLum_000XXXX")
Double_t x[10]
ClassImp(Tof2DScin) Tof2DScin
Definition: Tof2DScin.cxx:14
virtual void SetText(std::vector< TString > infoCon)
virtual void SetPos(Int_t px, Int_t py)
Definition: BesPaveText.cxx:76
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()
virtual void UpdateView(Bool_t resetview=kFALSE)
Definition: BesView.cxx:598
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition: BesView.cxx:800
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: BesView.cxx:365
virtual void Draw(Option_t *option="")
Definition: Tof2DScin.cxx:197
Double_t Range360(Double_t input)
Definition: Tof2DScin.cxx:374
Double_t GetAngle(Double_t x, Double_t y)
Definition: Tof2DScin.cxx:363
virtual void Paint(Option_t *option="")
Definition: Tof2DScin.cxx:208
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition: Tof2DScin.cxx:317
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: Tof2DScin.cxx:151
virtual void CloseInfo()
Definition: Tof2DScin.cxx:121
virtual void SetStyle()
Definition: Tof2DScin.cxx:91
virtual bool HasZRSection()
Definition: Tof2DScin.cxx:326
virtual void ClearInfo()
Definition: Tof2DScin.cxx:115
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Definition: Tof2DScin.cxx:135