BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
Mdc2DWire.cxx
Go to the documentation of this file.
1#include <TString.h>
2#include <TColor.h>
3#include <iostream>
4#include "math.h"
5#include "TMath.h"
7#include "BesVisLib/BesView.h"
9
10using namespace std;
11
12#ifndef __CINT__
14#endif
15
16//_____________________________________________________
17
19
20}
21
22//_____________________________________________________
23
24Mdc2DWire::Mdc2DWire(const char* name,
25 const char* title,
26 Double_t rmin,
27 Double_t rmax,
28 Double_t dz,
29 Double_t phi,
30 Double_t *center )
31{
32
33 SetName(name);
35 fTip = 0;
36 fTube = 0; //Long Peixun's update: Add fTube initialization
37 fHighlighted = false;
38 fFired = false;
39 fColorfulWire = false;
40 fWireType = 1; // axial wire
41 evTime = 0;
42
43 Double_t r = 0.25*(rmax-rmin);
44 fWireCircle = new BesCircle2D(name, title, 0.0, r, &center[0]);
45
46 Double_t dx = fabs(r*cos(phi));
47 Double_t dy = fabs(r*sin(phi));
48 Double_t P[12] = { center[0] - dx, center[1] - dy, center[2] - dz,
49 center[0] + dx, center[1] + dy, center[2] - dz,
50 center[0] - dx, center[1] - dy, center[2] + dz,
51 center[0] + dx, center[1] + dy, center[2] + dz
52 };
53
54 fWireCone = new BesPolygon2D(name, title, 4, P);
55
56 Init();
57}
58
59//_____________________________________________________
60
61Mdc2DWire::Mdc2DWire(const char* name, const char* title, Int_t N, Double_t *P)
62{
63 SetName(name);
65 fTip = 0;
66 fHighlighted = false;
67 fFired = false;
68 fColorfulWire = false;
69 fWireType = 2; // stereo wire
70
71 Double_t *tubeP = &P[3*N/2]; // east four points, P4~P7
72 fTube = new BesPolygon2D(name, title, N/2, tubeP);
73 fWireCircle = 0;
74 fWireCone = 0;
75
76 for (Int_t i = 0; i < 3; i++) {
77 fWestHole[i] = (P[i] + P[3+i] + P[6+i] + P[9+i] )/4.0; // (P0+P1+P2+P3)/4
78 fEastHole[i] = (P[12+i] + P[15+i] + P[18+i] + P[21+i])/4.0; // (P4+P5+P6+P7)/4
79 }
80 TVector3 westVec(fWestHole[0], fWestHole[1], fWestHole[2]);
81 TVector3 eastVec(fEastHole[0], fEastHole[1], fEastHole[2]);
82 fWestPhi = westVec.Phi() * TMath::RadToDeg();
83 fEastPhi = eastVec.Phi() * TMath::RadToDeg();
84 if (fWestPhi < 0.0) fWestPhi += 360.0;
85 if (fEastPhi < 0.0) fEastPhi += 360.0;
86
87 // ------XY------
88 Double_t rMax = sqrt( (P[4*3] -P[7*3]) * (P[4*3]-P[7*3]) +
89 (P[4*3+1]-P[7*3+1]) * (P[4*3+1]-P[7*3+1]) +
90 (P[4*3+2]-P[7*3+2]) * (P[4*3+2]-P[7*3+2]) ) / 2.0;
91
92 Double_t rMinRatio = 0.0001; // min bubble radius = rMinRatio * rMax;
93 Double_t rMaxRatio = 0.8;//0.6; // 0.4//yzhang
94
95 Double_t newP[12];
96 Double_t edge = rMaxRatio*0.0001; //*0.85
97 for (Int_t i = 0; i < 3; i++) {
98 newP[i] = (0.5+edge*rMinRatio)*(P[i]+P[3+i])*0.5
99 + (0.5-edge*rMinRatio)*(P[6+i]+P[9+i])*0.5; // near center of P0+P1
100 newP[3+i] = (0.5-edge*rMinRatio)*(P[i]+P[3+i])*0.5
101 + (0.5+edge*rMinRatio)*(P[6+i]+P[9+i])*0.5; // near center of P2+P3
102 newP[6+i] = (0.5+edge*rMaxRatio)*(P[12+i]+P[15+i])*0.5
103 + (0.5-edge*rMaxRatio)*(P[18+i]+P[21+i])*0.5; // near center of P4+P5
104 newP[9+i] = (0.5-edge*rMaxRatio)*(P[12+i]+P[15+i])*0.5
105 + (0.5+edge*rMaxRatio)*(P[18+i]+P[21+i])*0.5; // near center of P6+P7
106 }
107 fWireCone = new BesPolygon2D("WireCone", "WireCone", 4, &newP[0]);
108
109 fWireCircle =
110 new BesCircle2D("WireBubble", "WireBubble", 0.0, rMaxRatio*rMax, &fEastHole[0]);
111
112 // ------ZR------
113 fZRPosMarker2D =
114 new BesMarker2D("MdcZRPos", "MdcZRPos", fEastHole[0], fEastHole[1], fEastHole[2]);
115
116 Init();
117}
118
119//_____________________________________________________
120
122
123 //Long Peixun's update: remove "if"
124 delete fTube;
125 delete fWireCircle;
126 delete fWireCone;
127 delete fZRPosMarker2D;
128 delete fTip;
129}
130
131//_____________________________________________________
132
134
135 SetStyle();
136
137 fTip = new BesPaveText(0, 0, 0.1, 0.1);
138 CloseInfo();
139}
140
141//_____________________________________________________
142
144{
145 lcTube = kBlack; // grey;
146 lwTube = 1;
147 fcTube = kBlack; // grey 15;
148 fsTube = 4000;
149
150 lcWire = 15;
151 if (fWireType == 1) lcWire = kGreen;
152 if (fWireType == 2) lcWire = kBlue;
153 lwCircle = 1;
154 lwCone = 1;
155 fcCircle = kWhite;
156 fcCone = 0;
157 fsCircle = 1001;
158 fsCone = 0;
159
160 lcWireFired = kRed;
161 lwCircleFired = 2;//yzhang 2;
162 lwConeFired = 2;
163 fcCircleFired = 9004; //kBlack;
164 fcConeFired = kBlack;
165 fsCircleFired = 1001;//solid
166 fsConeFired = 3001;
167
168 lcWireHL = kMagenta;//yzhang lcWire;
169 lwCircleHL = 2;
170 lwConeHL = 2;
171 fcCircleHL = kMagenta;//yzhang kBlack;
172 fcConeHL = kRed;
173 fsCircleHL = 1001;
174 fsConeHL = 4000;
175
176 sizeMarker = 4;
177 cMarker = kBlue;
178 cMarkerFired = kRed; // color of fired marker
179 cMarkerHL = cMarker; // cMarkerFired;
180 sMarker = 24;
181 sMarkerFired = 20; // style of fired marker
182 sMarkerHL = 25; // style of highlighted marker
183}
184
186{
187 fInfoCon.clear();
188 fTip->DeleteText();
189}
190
192{
193 if (fTip) {
194 fTip->Clear();
195
196 if (fInfoCon.size() == 0) fInfoCon.push_back(GetTitle());
197 fTip->SetText(fInfoCon);
198 }
199 else
200 cout << "Mdc2DWire::CloseInfo, not initialized" << endl;
201}
202
203//_____________________________________________________
204
205Int_t Mdc2DWire::DistancetoPrimitive(Int_t px, Int_t py) {
206 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
207 if (view->GetViewType() & kXYView) {
208 return fWireCircle->DistancetoPrimitive(px, py);
209 }
210 else if (view->GetViewType() & kZRView) {
211 if (fZRPosMarker2D) {
212 //Long Peixun's update: Remove duplicate code
213
214 //We need to research what damage fZRPoseMarker2D pointers
215 //This bug can be avoid by changing the initialize order of subdetectors
216 // if ((unsigned long long)(fZRPosMarker2D) & 0xFFFFFFFF00000000)
217 // {
218 // cout << this << " " << fZRPosMarker2D << endl;
219 // }
220
221 return fZRPosMarker2D->DistancetoPrimitive(px, py);
222 }
223 }
224
225 return 999;
226}
227
228//_____________________________________________________
229
230void Mdc2DWire::ExecuteEvent(Int_t event, Int_t px, Int_t py) {
231
232 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
233
234 if (gBesCursor->GetType() == kBesHand) {
235 if (view) view->ExecuteEvent(event, px, py);
236 }
237 else if (gBesCursor->GetType() == kBesPick){
238
239 if (gPad) gPad->SetCursor(kPointer);
240
241 Int_t origColor = 1;
242
243 switch (event) {
244
245 case kMouseEnter :
246
247 if ( fWireCircle ) origColor = fWireCircle->GetFillColor();
248 if ( fZRPosMarker2D ) origColor = fZRPosMarker2D->GetMarkerColor();
249 this->SetHighlighted(true);
250
251 if (this->IsFired() || view->GetVisMdcWires()) {
252 Draw("WIRE,SAME");
253
254 fTip->SetPos(px, py);
255 view->UpdateView(0);
256
257 //Long Peixun's update: If ShowInfo is not checked, don't show tip text.
258 if (gBesCursor->GetShowInfo()) fTip->Draw("BR,SAME"); // "BR,ARC,SAME"
259 gPad->Modified();
260 gPad->Update();
261 }
262 break;
263
264 case kMouseLeave:
265
266 if (this->IsHighlighted()) {
267 this->SetHighlighted(false);
268 if (view->GetVisMdcWires()) Draw("WIRE,SAME");
269
270 view->UpdateView(0);
271 gPad->Modified();
272 gPad->Update();
273 }
274 break;
275 }
276
277 }
278}
279
280//_____________________________________________________
281
282void Mdc2DWire::Draw(Option_t *option) {
283 //
284 // Mdc2DWire draw function
285 TString opt = option;
286 opt.ToUpper();
287
288 AppendPad(option);
289}
290
291//_____________________________________________________
292
293void Mdc2DWire::Paint(Option_t *option) {
294
295 TString opt = option;
296 opt.ToUpper();
297
298 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
299
300 //gStyle->SetPalette(1);
301 if (view->GetViewType() & kXYView) {
302
303 Double_t wcCenter[3], ncCenter[3];
304 fWireCircle->GetCenter(&wcCenter[0]);
305 view->WCtoNDC(wcCenter, &ncCenter[0]);
306 Double_t x1, y1, x2, y2;
307 Double_t d = 0.05;
308 gPad->GetRange(x1, y1, x2, y2);
309
310 // Only draw wire in pad range
311 if (ncCenter[0] > x1-d && ncCenter[0] < x2+d &&
312 ncCenter[1] > y1-d && ncCenter[1] < y2+d) {
313 if (opt.Contains("TUBE") && fTube ) {
314 fTube->SetLineColor(lcTube);
315 fTube->SetLineWidth(lwTube);
316 fTube->SetFillColor(fcTube);
317 fTube->SetFillStyle(fsTube);
318
319 fTube->Paint();
320 }
321
322 if (this->IsFired()) {
323 if (fWireCircle) {
324 fWireCircle->SetLineColor(lcWireFired);
325 fWireCircle->SetLineWidth(lwCircleFired);
326 fWireCircle->SetFillColor(fcCircleFired);
327 fWireCircle->SetFillStyle(fsCircleFired);
328 }
329 if (fWireCone) {
330 fWireCone->SetLineColor(lcWireFired);
331 fWireCone->SetLineWidth(lwConeFired);
332 fWireCone->SetFillColor(fcConeFired);
333 fWireCone->SetFillStyle(fsConeFired);
334 }
335 }
336 else {
337 if (fWireCone) {
338 fWireCone->SetLineColor(lcWire);
339 fWireCone->SetLineWidth(lwCone);
340 fWireCone->SetFillColor(fcCone);
341 fWireCone->SetFillStyle(fsCone);
342 }
343 if (fWireCircle) {
344 fWireCircle->SetLineColor(lcWire);
345 fWireCircle->SetLineWidth(lwCircle);
346 fWireCircle->SetFillColor(fcCircle);
347 fWireCircle->SetFillStyle(fsCircle);
348 }
349 }
350
351 if (this->IsHighlighted()) {
352 if (fWireCircle) {
353 fWireCircle->SetLineColor(lcWireHL);
354 fWireCircle->SetLineWidth(lwCircleHL);
355 fWireCircle->SetFillColor(fcCircleHL);
356 fWireCircle->SetFillStyle(fsCircleHL);
357 }
358 if (fWireCone) {
359 fWireCone->SetLineColor(lcWireHL);
360 fWireCone->SetLineWidth(lwConeHL);
361 fWireCone->SetFillColor(fcConeHL);
362 fWireCone->SetFillStyle(fsConeHL);
363 }
364 }
365 if (opt.Contains("WIRE")) {
366 //Long Peixun's update: Only draw fired wires' cone
367 if (IsFired()) fWireCone->Paint(); //Long Peixun's update: Draw colorful wires' cone
368 if (fWireCircle) fWireCircle->Paint();
369 }
370 }
371 }
372
373 if (view->GetViewType() & kZRView) {
374 if (HasZRSection()) {
375 fZRPosMarker2D->SetWCX(fZRSectionPos[0]);
376 fZRPosMarker2D->SetWCY(fZRSectionPos[1]);
377 fZRPosMarker2D->SetWCZ(fZRSectionPos[2]);
378 fZRPosMarker2D->SetMarkerColor(cMarker);
379 fZRPosMarker2D->SetMarkerStyle(sMarker);
380 fZRPosMarker2D->SetMarkerSizeMultiple(sizeMarker);
381
382 if (this->IsFired()) {
383 if (fZRPosMarker2D) {
384 fZRPosMarker2D->SetMarkerColor(cMarkerFired);
385 fZRPosMarker2D->SetMarkerStyle(sMarkerFired);
386 }
387 }
388 else {
389 if (fZRPosMarker2D) {
390 fZRPosMarker2D->SetMarkerColor(cMarker);
391 fZRPosMarker2D->SetMarkerStyle(sMarker);
392 }
393 }
394
395 if (this->IsHighlighted()) {
396 if (fZRPosMarker2D) {
397 fZRPosMarker2D->SetMarkerColor(cMarkerHL);
398 fZRPosMarker2D->SetMarkerStyle(sMarkerHL);
399 }
400 }
401
402 if (opt.Contains("WIRE")) {
403 if (fZRPosMarker2D) fZRPosMarker2D->Paint();
404 }
405 }
406 }
407}
408
409//_____________________________________________________
410
411char *Mdc2DWire::GetObjectInfo(Int_t px, Int_t py) const {
412
413 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
414 if (view) return view->GetObjectInfo(px, py);
415 else return TObject::GetObjectInfo(px, py);
416}
417
418//_____________________________________________________
419
421{
422 if (fWireType != 2) return false;
423
424 bool flag = false;
425 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
426 Double_t viewPhi = view->GetLongitude();
427 viewPhi = Range360(viewPhi);
428 //if (GetName() == TString("Layer0Wire0")) cout << "view " << viewPhi << endl;
429
430 Double_t zrPhi = viewPhi-90.0;
431 zrPhi = Range360(zrPhi);
432 //if (GetName() == TString("Layer0Wire0")) cout << zrPhi << endl;
433
434 for (Int_t i = 0; i < 2; i++) {
435 if (i==1) {
436 zrPhi += 180.0;
437 zrPhi = Range360(zrPhi);
438 }
439
440 if ( fabs(fEastPhi-fWestPhi) < 180.0 ) { // no cross phi=0.0
441 if ( (fEastPhi-zrPhi)*(fWestPhi-zrPhi) > 0.0 ) flag = false;
442 else {
443 Double_t factor = fabs( (fEastPhi-zrPhi)/(fEastPhi-fWestPhi) );
444 for (Int_t i = 0; i < 3; i++) {
445 fZRSectionPos[i] = factor*fWestHole[i] + (1.0-factor)*fEastHole[i];
446 }
447 flag = true;
448 break;
449 }
450 }
451 else { // cross phi=0.0
452 if ( (fEastPhi-zrPhi)*(fWestPhi-zrPhi) < 0.0 ) flag = false;
453 else { // range 0~360 -> -180~180
454 Double_t tempEastPhi = fEastPhi;
455 if (tempEastPhi >= 180.0) tempEastPhi -= 360.0;
456 Double_t tempWestPhi = fWestPhi;
457 if (tempWestPhi >= 180.0) tempWestPhi -= 360.0;
458 Double_t tempZRPhi = zrPhi;
459 if (tempZRPhi >= 180.0) tempZRPhi -= 360.0;
460
461 Double_t factor = fabs( (tempEastPhi-tempZRPhi)/(tempEastPhi-tempWestPhi) );
462 for (Int_t i = 0; i < 3; i++) {
463 fZRSectionPos[i] = factor*fWestHole[i] + (1.0-factor)*fEastHole[i];
464 }
465 flag = true;
466 break;
467 }
468 }
469 }
470
471 return flag;
472}
473
474//_____________________________________________________
475
476Double_t Mdc2DWire::Range360(Double_t input)
477{
478 if (input >= 360.0) {
479 do {
480 input -= 360.0;
481 }
482 while (input >= 360.0);
483 }
484 else if (input < 0.0) {
485 do {
486 input += 360.0;
487 }
488 while (input < 0.0);
489 }
490
491 return input;
492}
493
494//_____________________________________________________
495
497{
498 mdcTime = time;
499}
500
501//_____________________________________________________
502
504{
505 mdcCharge = charge;
506}
507
508//_____________________________________________________
509
510void Mdc2DWire::SetQOverflow(Bool_t qOvfl)
511{
512 qOverflow = qOvfl;
513}
514
515//_____________________________________________________
516
518{
519 evTime = time;
520}
521
522//_____________________________________________________
523//Long Peixun's update: raw channel data for mdc hits display
525{
526 timeChannel = tc;
527}
529{
530 chargeChannel = cc;
531}
532
533//_____________________________________________________
534
535void Mdc2DWire::SetColorfulWire(Bool_t colorfulWire, Bool_t subEvTime)
536{
537 fColorfulWire = colorfulWire;
538 if(fColorfulWire){
539 //yzhang change LINE COLOR of fired mdc wires
540 //n color bin = 50, time of max bin is 2000
541 //time max value = 1943.8125 ~ 2000 ns
542 //no time info color is kGray
543 //time > 2000 && time <=10000, color is kBlack
544 int tempColor;
545 if(subEvTime){
546 // raw time - event start time
547 double tempMdcTime = mdcTime - evTime;
548 if(fabs(evTime)>0.0001) tempMdcTime += 230;
549 if(tempMdcTime>10000) {
550 tempColor = kGray;
551 }else if(tempMdcTime>2000&&tempMdcTime<=10000){
552 tempColor = kRed;
553 }else if(tempMdcTime<-10){
554 tempColor = kWhite;
555 }else{
556 tempColor = 51 + (int) (tempMdcTime/40);
557 }
558 }else{
559 //raw time
560 if(mdcTime>10000) {
561 tempColor= kGray;
562 }else if(mdcTime>2000&&mdcTime<=10000){
563 tempColor = kRed;
564 }else{
565 tempColor = 51 + (int) (mdcTime/40);
566 }
567 }
568 lcWireFired = tempColor;
569 //std::cout<< " mdcTime "<<mdcTime <<" evTime "<< evTime << " t-t0 "<< mdcTime - evTime +230<< " lcWireFired " << lcWireFired <<std::endl;
570
571 //yzhang change FILL COLOR of fired mdc wires
572 //n color bin = 50, charge of max bin is 2000
573 //charge max value = 29783 ~ 30000
574 //adc> 2000&&<=30000 color is kBlack
575 //no adc color is kGray
576 if(mdcCharge>30000){
577 tempColor = kGray;
578 }else if(mdcCharge>2000&&mdcCharge<=30000){
579 tempColor = kRed;
580 }else {
581 tempColor = 51 + (int) (mdcCharge/40);
582 }
583 if(qOverflow) { tempColor = kBlack; }
584 fcCircleFired = tempColor;
585 //std::cout<< " mdcCharge "<<mdcCharge<<" ovfl "<<qOverflow<<" fcCircleFired " << fcCircleFired<< std::endl;
586 }else{
587 lcWireFired = kRed;
588 fcCircleFired = 9004;
589 }
590}
double sin(const BesAngle a)
Definition BesAngle.h:210
double cos(const BesAngle a)
Definition BesAngle.h:213
@ kBesHand
Definition BesCursor.h:15
@ kBesPick
Definition BesCursor.h:14
R__EXTERN BesCursor * gBesCursor
Definition BesCursor.h:40
@ kXYView
Definition BesStatus.h:18
@ kZRView
Definition BesStatus.h:19
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 time
titledef title[20]
ClassImp(Mdc2DWire) Mdc2DWire
Definition Mdc2DWire.cxx:13
virtual void Paint(Option_t *option="")
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void GetCenter(Double_t *center)
Bool_t GetShowInfo()
Definition BesCursor.h:35
EBESCursorType GetType()
Definition BesCursor.h:32
virtual void SetWCY(Float_t input)
Definition BesMarker2D.h:45
virtual void SetMarkerSizeMultiple(Int_t input)
Definition BesMarker2D.h:34
virtual void Paint(Option_t *option="")
virtual void SetWCZ(Float_t input)
Definition BesMarker2D.h:46
virtual void SetWCX(Float_t input)
Definition BesMarker2D.h:44
virtual void SetText(std::vector< TString > infoCon)
virtual void SetPos(Int_t px, Int_t py)
virtual void Paint(Option_t *option="")
Double_t GetLongitude()
Definition BesTView.h:95
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)
Definition BesView.cxx:728
virtual void UpdateView(Bool_t resetview=kFALSE)
Definition BesView.cxx:657
Bool_t GetVisMdcWires()
Definition BesView.h:114
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
void SetChargeChannel(UInt_t cc)
virtual void ClearInfo()
void SetQOverflow(Bool_t qOvfl)
virtual void CloseInfo()
virtual void SetHighlighted(bool status=true)
Definition Mdc2DWire.h:32
virtual bool IsFired()
Definition Mdc2DWire.h:35
virtual char * GetObjectInfo(Int_t px, Int_t py) const
virtual bool IsHighlighted()
Definition Mdc2DWire.h:34
virtual bool HasZRSection()
void SetTime(Double_t time)
void SetColorfulWire(Bool_t colorfulWire, Bool_t subEvTime)
Double_t Range360(Double_t input)
void SetEvTime(Double_t time)
virtual void Paint(Option_t *option="")
virtual void Init()
virtual void SetStyle()
void SetTimeChannel(UInt_t tc)
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void Draw(Option_t *option="")
void SetCharge(Double_t charge)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
float charge