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