CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
Cgem2DStrip.cxx
Go to the documentation of this file.
1#include <TString.h>
2#include <TColor.h>
3#include <iostream>
4#include <cmath>
5#include "TMath.h"
6#include "BesVisLib/BesView.h"
9
10//Author: Long Peixun
11using namespace std;
12
13#ifndef __CINT__
16#endif
17
18//These macros are used to set display condition of strips when debug or test
19//If you want to open conditional display, please remove the annotation of *_TEST_CONDITIONAL_DISPLAY
20//#define CGEM_X_STRIP_TEST_CONDITIONAL_DISPLAY
21//#define CGEM_V_STRIP_TEST_CONDITIONAL_DISPLAY
22#define CGEM_X_STRIP_DISPLAY_CONDITION fLayer == 2 && fSheet == 1
23#define CGEM_V_STRIP_DISPLAY_CONDITION fLayer == 0 && fStrip >= 601 && fStrip <= 602
24
25
26//---------- Cgem 2D Strip base class Begin ----------
27
28Cgem2DStripBase::Cgem2DStripBase(const char* name, const char* title, Int_t layer, Int_t sheet, Int_t strip)
29 : fHighlighted(false), fFired(false), fLayer(layer), fSheet(sheet), fStrip(strip)
30{
31 fTip = new BesPaveText(0, 0, 0.1, 0.1);
32 SetName(name);
33 SetTitle(title);
34}
35
40
42{
43 fInfoCon.clear();
44 fTip->DeleteText();
45}
46
47char *Cgem2DStripBase::GetObjectInfo(Int_t px, Int_t py) const
48{
49 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
50 if (view) return view->GetObjectInfo(px, py);
51 else return TObject::GetObjectInfo(px, py);
52}
53
54//---------- Cgem 2D Strip base class End ----------
55
56
57
58//*************************************************
59//---------- Cgem 2D X-strip class Begin ----------
60
61Cgem2DXStrip::Cgem2DXStrip(const char* name, const char* title,
62 Double_t len, Double_t wid, Double_t phi, Double_t zmin, Double_t r,
63 Double_t size, Double_t thick, Int_t layer, Int_t sheet, Int_t strip,
64 Double_t rUF)
65 : Cgem2DStripBase(name, title, layer, sheet, strip)
66{
67 double cosphi = TMath::Cos(phi);
68 double sinphi = TMath::Sin(phi);
69 double rplust = r + 0.5 * thick;
70 double rsubt = r - 0.5 * thick;
71 Double_t coorStrip[12];
72
73 //Construct XY view projection shape
74 coorStrip[0] = cosphi * rsubt - sinphi * 0.5 * size;
75 coorStrip[1] = sinphi * rsubt + cosphi * 0.5 * size;
76 coorStrip[2] = -zmin;
77 coorStrip[3] = cosphi * rplust - sinphi * 0.5 * size;
78 coorStrip[4] = sinphi * rplust + cosphi * 0.5 * size;
79 coorStrip[5] = -zmin;
80 coorStrip[6] = cosphi * rplust + sinphi * 0.5 * size;
81 coorStrip[7] = sinphi * rplust - cosphi * 0.5 * size;
82 coorStrip[8] = -zmin;
83 coorStrip[9] = cosphi * rsubt + sinphi * 0.5 * size;
84 coorStrip[10] = sinphi * rsubt - cosphi * 0.5 * size;
85 coorStrip[11] = -zmin;
86 fXStripXY = new BesPolygon2D(name, title, 4, coorStrip);
87
88 TString shapename = name;
89 TString shapetitle = title;
90 shapename += " Highlight";
91 shapetitle += " Highlight";
92 fXYHighlight = new BesMarker2D(shapename, shapetitle, r * cosphi, r * sinphi, -zmin);
93 fXYHighlight->SetMarkerStyle(27);
95 fXYHighlight->SetMarkerColor(cHLMarker);
96
97 //Construct ZR view shape
98 coorStrip[0] = coorStrip[3] = cosphi * r;
99 coorStrip[1] = coorStrip[4] = sinphi * r;
100 //coorStrip[2] = -zmin;
101 //coorStrip[5] = zmin;
102 coorStrip[2] = zmin; //New Geom
103 coorStrip[5] = zmin + len; //New Geom
104
105 shapename = name;
106 shapetitle = title;
107 shapename += " ZR";
108 shapetitle += " ZR";
109 fXStripZR = new BesPolygon2D(shapename, shapetitle, 2, coorStrip);
110
111 //Construct UF view shape
112 //while(phi>TMath::Pi()) phi-=2*TMath::Pi();
113 double x = phi * rUF;
114 //if (fLayer == 0) x -= 0.5 * wid;
115 //else x -= wid;
116 coorStrip[0] = x - 0.5 * size;
117 //coorStrip[1] = -zmin;
118 coorStrip[1] = zmin; //New Geom
119 coorStrip[2] = 0;
120 coorStrip[3] = x + 0.5 * size;
121 //coorStrip[4] = -zmin;
122 coorStrip[4] = zmin; //New Geom
123 coorStrip[5] = 0;
124 coorStrip[6] = coorStrip[3];
125 //coorStrip[7] = zmin;
126 coorStrip[7] = zmin + len; //New Geom
127 coorStrip[8] = 0;
128 coorStrip[9] = coorStrip[0];
129 //coorStrip[10] = zmin;
130 coorStrip[10] = zmin + len; //New Geom
131 coorStrip[11] = 0;
132
133 shapename = name;
134 shapetitle = title;
135 shapename += " Unfolded";
136 shapetitle += " Unfolded";
137 fXStripUF = new BesPolygon2D(name, title, 4, coorStrip);
138
139 fFiredSizeFactor = 50;
140 SetStyle();
141 CloseInfo();
142}
143
145{
146 delete fXStripXY;
147 delete fXStripZR;
148 delete fXStripUF;
149 delete fXYHighlight;
150}
151
153{
154 if (fTip)
155 {
156 fTip->Clear();
157 if (fInfoCon.size() == 0) fInfoCon.push_back(GetTitle());
159 }
160 else cout << "Cgem2DXStrip::CloseInfo, not initialized" << endl;
161}
162
164{
165 lcStrip = 41; //line color: khaki
166 lwStrip = 1; //line width
167 fcStrip = 41; //fill color: khaki
168 fsStrip = 1001; //fill style
169
170 lcStripFired = kRed;
171 lwStripFired = 1;
172 fcStripFired = kRed;
173 fsStripFired = 1001;
174
175 lcStripHL = kBlue;
176 lwStripHL = 1;
177 fcStripHL = kBlue;
178 fsStripHL = 1001;
179
180 cHLMarker = 46;
181}
182
183Int_t Cgem2DXStrip::DistancetoPrimitive(Int_t px, Int_t py)
184{
185 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
186
187#ifdef CGEM_X_STRIP_TEST_CONDITIONAL_DISPLAY
188 if (!(CGEM_X_STRIP_DISPLAY_CONDITION)) return 9999;
189#endif
190
191/* if ( view->GetViewType() & kXYView && fStripXY &&
192 ( view->GetVisMucStrips() || (view->GetVisMucHitsGlobal() && this->IsFired()) ) ) {
193 return fStripXY->DistancetoPrimitive(px, py);
194 }
195 else if ( view->GetViewType() & kZRView && fStripZR &&
196 ( (view->GetVisMucStrips() && this->IsZRVisible()) ||
197 (view->GetVisMucHitsGlobal() && this->IsFired() && this->IsZRVisible()) ) ) {
198 return fStripZR->DistancetoPrimitive(px, py);
199 } */
200
201 if ( (view->GetViewType() & kXYView) && fXStripXY &&
202 ( view->GetVisCgemXStrips() || this->IsFired() ))
203 {
204 if (fFired && view->GetVisCgemHitsFiredHL()) return fXYHighlight->DistancetoPrimitive(px, py);
205 else return fXStripXY->DistancetoPrimitive(px, py);
206 }
207
208 if ((view->GetViewType() & kZRView) && fXStripZR &&
209 ( view->GetVisCgemXStrips() || this->IsFired() ))
210 return fXStripZR->DistancetoPrimitive(px, py);
211
212 if ((view->GetViewType() & kCgemUFView0) && fLayer == 0 && fXStripUF &&
213 ( view->GetVisCgemXStrips() || this->IsFired() ))
214 return fXStripUF->DistancetoPrimitive(px, py);
215
216 if ((view->GetViewType() & kCgemUFView1) && fLayer == 1 && fXStripUF &&
217 ( view->GetVisCgemXStrips() || this->IsFired() ))
218 return fXStripUF->DistancetoPrimitive(px, py);
219
220 if ((view->GetViewType() & kCgemUFView2) && fLayer == 2 && fXStripUF &&
221 ( view->GetVisCgemXStrips() || this->IsFired() ))
222 return fXStripUF->DistancetoPrimitive(px, py);
223
224 return 9999;
225}
226
227void Cgem2DXStrip::ExecuteEvent(Int_t event, Int_t px, Int_t py)
228{
229 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
230 //cout << "Cgem2DXStrip::ExecuteEvent()" << endl;
231 if (gBesCursor->GetType() == kBesHand)
232 {
233 if (view) view->ExecuteEvent(event, px, py);
234 }
235
236 else if (gBesCursor->GetType() == kBesPick)
237 {
238 if (gPad) gPad->SetCursor(kPointer);
239
240 switch (event)
241 {
242 case kMouseEnter:
243 SetHighlighted(true);
244 if (view->GetViewType() & kXYView) Draw("XY");
245 if (view->GetViewType() & kZRView) Draw("ZR");
246 if ((view->GetViewType() & kCgemUFView0) || (view->GetViewType() & kCgemUFView1) || (view->GetViewType() & kCgemUFView2))
247 Draw("UF");
248
249 fTip->SetPos(px, py);
250 view->UpdateView(0);
251
252 //Long Peixun's update: If ShowInfo is not checked, don't show tip text.
253 if (gBesCursor->GetShowInfo()) fTip->Draw("BR,SAME");
254 gPad->Modified();
255 gPad->Update();
256 break;
257
258 case kMouseLeave:
259 if (IsHighlighted())
260 {
261 SetHighlighted(false);
262 if (view->GetViewType() & kXYView) Draw("XY");
263 if (view->GetViewType() & kZRView) Draw("ZR");
264 if ((view->GetViewType() & kCgemUFView0) || (view->GetViewType() & kCgemUFView1) || (view->GetViewType() & kCgemUFView2))
265 Draw("UF");
266
267 view->UpdateView(0);
268 gPad->Modified();
269 gPad->Update();
270 }
271 break;
272 }
273 }
274}
275
276void Cgem2DXStrip::Draw(Option_t *option)
277{
278 TString opt = option;
279 opt.ToUpper();
280 AppendPad(option);
281}
282
283void Cgem2DXStrip::Paint(Option_t *option)
284{
285 //TString opt = option;
286 //opt.ToUpper();
287 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
288
289#ifdef CGEM_X_STRIP_TEST_CONDITIONAL_DISPLAY
290 if (!(CGEM_X_STRIP_DISPLAY_CONDITION)) return;
291#endif
292
293 if (view->GetViewType() & kXYView)
294 {
295 if (IsFired())
296 {
297 fXStripXY->SetLineColor(lcStripFired);
298 fXStripXY->SetLineWidth(lwStripFired);
299 fXStripXY->SetFillColor(fcStripFired);
300 fXStripXY->SetFillStyle(fsStripFired);
301
302 //fired X-strip will be drawn larger in XY view
304 Double_t C[3];
306 fXStripXY->Stretch(C[0], C[1], C[2], fFiredSizeFactor);
307 if (view->GetVisCgemHitsFiredHL())
308 {
309 if (IsHighlighted()) fXYHighlight->SetMarkerColor(fcStripHL);
310 else fXYHighlight->SetMarkerColor(cHLMarker);
312 }
313 }
314 else
315 {
316 fXStripXY->SetLineColor(lcStrip);
317 fXStripXY->SetLineWidth(lwStrip);
318 fXStripXY->SetFillColor(fcStrip);
319 fXStripXY->SetFillStyle(fsStrip);
320 fXStripXY->Restore(); //restore normal size
321 }
322
323 if (IsHighlighted())
324 {
325 fXStripXY->SetLineColor(lcStripHL);
326 fXStripXY->SetLineWidth(lwStripHL);
327 fXStripXY->SetFillColor(fcStripHL);
328 fXStripXY->SetFillStyle(fsStripHL);
329 }
330
331 fXStripXY->Paint(); //Cannot use Draw()
332 }
333
334 if (view->GetViewType() & kZRView)
335 {
336 if (IsFired())
337 {
338 fXStripZR->SetLineColor(lcStripFired);
339 fXStripZR->SetLineWidth(lwStripFired);
340 fXStripZR->SetFillColor(fcStripFired);
341 fXStripZR->SetFillStyle(fsStripFired);
342 }
343 else
344 {
345 fXStripZR->SetLineColor(lcStrip);
346 fXStripZR->SetLineWidth(lwStrip);
347 fXStripZR->SetFillColor(fcStrip);
348 fXStripZR->SetFillStyle(fsStrip);
349 }
350
351 if (IsHighlighted())
352 {
353 fXStripZR->SetLineColor(lcStripHL);
354 fXStripZR->SetLineWidth(lwStripHL);
355 fXStripZR->SetFillColor(fcStripHL);
356 fXStripZR->SetFillStyle(fsStripHL);
357 }
358
359 fXStripZR->Paint();
360 }
361
362 if (((view->GetViewType() & kCgemUFView0) && fLayer == 0) ||
363 ((view->GetViewType() & kCgemUFView1) && fLayer == 1) ||
364 ((view->GetViewType() & kCgemUFView2) && fLayer == 2) )
365 {
366 if (IsFired())
367 {
368 fXStripUF->SetLineColor(lcStripFired);
369 fXStripUF->SetLineWidth(lwStripFired);
370 fXStripUF->SetFillColor(fcStripFired);
371 fXStripUF->SetFillStyle(fsStripFired);
372 }
373 else
374 {
375 fXStripUF->SetLineColor(lcStrip);
376 fXStripUF->SetLineWidth(lwStrip);
377 fXStripUF->SetFillColor(fcStrip);
378 fXStripUF->SetFillStyle(fsStrip);
379 }
380
381 if (IsHighlighted())
382 {
383 fXStripUF->SetLineColor(lcStripHL);
384 fXStripUF->SetLineWidth(lwStripHL);
385 fXStripUF->SetFillColor(fcStripHL);
386 fXStripUF->SetFillStyle(fsStripHL);
387 }
388
389 fXStripUF->Paint();
390 }
391}
392
393//---------- Cgem 2D X-strip class End ----------
394
395
396
397//**********************************************************
398//---------- Cgem V-strip calculator class Begin -----------
399
400double CgemVStripCalculator::getPointPhi(double* pos) const
401{
402 return TMath::ATan2(pos[1], pos[0]);
403}
404
405CgemVStripCalculator::CgemVStripCalculator(double r, double len, double wid, double ang, double xmin, double zmin, double pit)
406 : m_RV(r), m_Length(len), m_Width(wid), m_Angle(ang), m_Xmin(xmin), m_Zmin(zmin), m_Pitch(pit)
407{
408 //New Geom
409 //Adjust angle to (-pi/2, pi/2)
410 while (m_Angle > TMath::Pi() / 2) m_Angle -= TMath::Pi();
411 while (m_Angle < -TMath::Pi() / 2) m_Angle += TMath::Pi();
412
413 //Change the value of "delta" to set the precision of V-strip drawing
414 delta = 30.0;
415
416 //Calculate VID offset
417 //vid_offset = getStartVID();
418}
419
420bool CgemVStripCalculator::isPointInSheet(double phi, double z) const
421{
422 if (z < m_Zmin || z > m_Zmin + m_Length) return false;
423 if (phi * m_RV < m_Xmin || phi * m_RV > m_Xmin + m_Width) return false;
424 return true;
425}
426
427// int CgemVStripCalculator::getStartVID() const
428// {
429// if (m_Angle >= 0) return 0;
430// double pitch_in_Z = -m_Pitch / TMath::Sin(m_Angle);
431// int N_in_Z = static_cast<int>(m_Length / pitch_in_Z);
432// return -N_in_Z;
433// }
434
435//Long Peixun's update: VID -> V
436int CgemVStripCalculator::getStartPointFromV(double v, double& phi, double& z) const
437{
438 //int adjVID = VID + vid_offset;
439 //double x_temp = ((adjVID - 1) * m_Pitch + m_V1) / TMath::Cos(m_Angle);
440 double x_temp = v / TMath::Cos(m_Angle);
441 double z_temp;
442
443 //New Geom
444 if (m_Angle < 0)
445 {
446 if (x_temp < 0) return INVALID_VID;
447 if (x_temp <= m_Width)
448 {
449 phi = (x_temp + m_Xmin) / m_RV;
450 z = m_Zmin;
451 return NORMAL;
452 }
453
454 z_temp = (x_temp - m_Width) / TMath::Tan(-m_Angle);
455 if (z_temp <= m_Length)
456 {
457 phi = (m_Xmin + m_Width) / m_RV;
458 z = z_temp + m_Zmin;
459 return NORMAL;
460 }
461 }
462 else
463 {
464 if (x_temp < 0) return INVALID_VID;
465 if (x_temp <= m_Width)
466 {
467 phi = (x_temp + m_Xmin) / m_RV;
468 z = m_Zmin + m_Length;
469 return NORMAL;
470 }
471
472 z_temp = (x_temp - m_Width) / TMath::Tan(m_Angle);
473 if (z_temp <= m_Length)
474 {
475 phi = (m_Xmin + m_Width) / m_RV;
476 z = m_Zmin + m_Length - z_temp;
477 return NORMAL;
478 }
479 }
480 return INVALID_VID;
481}
482
483//Long Peixun's update: VID -> V
484int CgemVStripCalculator::getEndPointFromV(double v, double& phi, double& z) const
485{
486 //int adjVID = VID + vid_offset;
487 //double x_temp = ((adjVID - 1) * m_Pitch + m_V1) / TMath::Cos(m_Angle);
488 double x_temp = v / TMath::Cos(m_Angle);
489 double z_temp;
490
491 //New Geom
492 if (m_Angle < 0)
493 {
494 if (x_temp < 0) return INVALID_VID;
495 z_temp = x_temp / TMath::Tan(-m_Angle);
496 if (z_temp <= m_Length)
497 {
498 phi = m_Xmin / m_RV;
499 z = z_temp + m_Zmin;
500 return NORMAL;
501 }
502 else if (x_temp - m_Length * TMath::Tan(-m_Angle) <= m_Width)
503 {
504 phi = (x_temp - m_Length * TMath::Tan(-m_Angle) + m_Xmin) / m_RV;
505 z = m_Length + m_Zmin;
506 return NORMAL;
507 }
508 }
509 else
510 {
511 if (x_temp < 0) return INVALID_VID;
512 z_temp = x_temp / TMath::Tan(m_Angle);
513 if (z_temp <= m_Length)
514 {
515 phi = m_Xmin / m_RV;
516 z = m_Zmin + m_Length - z_temp;
517 return NORMAL;
518 }
519 else if (x_temp - m_Length * TMath::Tan(m_Angle) <= m_Width)
520 {
521 phi = (x_temp - m_Length * TMath::Tan(m_Angle) + m_Xmin) / m_RV;
522 z = m_Zmin;
523 return NORMAL;
524 }
525 }
526
527 return INVALID_VID;
528}
529
530//Long Peixun's update: VID -> V
532{
533 //New Geom
534 double phi1 = 0, z1 = 0;
535 double phi2 = 0, z2 = 0;
536 double len = 0;
538 getEndPointFromV(v, phi2, z2);
539 len = sqrt(m_RV * m_RV * (phi1 - phi2) * (phi1 - phi2) + (z1 - z2) * (z1 - z2));
540 return len;
541}
542
543//Long Peixun's update: VID -> V
545{
546 double striplen = getStripLengthFromV(v);
547 if (striplen < 0) return INVALID_VID;
548 return static_cast<int>(striplen / delta + 2);
549}
550
551//Long Peixun's update: VID -> V
552int CgemVStripCalculator::getNthPointFromV(double v, int i, double& phi, double& z) const
553{
554 double sphi, sz, res_z, res_phi;
555 int status = getStartPointFromV(v, sphi, sz);
556 if (status != NORMAL) return status;
557 int N = getPointNumberFromV(v) - 1;
558
559 if (i >= 0 && i < N)
560 {
561 //New Geom
562 if (m_Angle <= 0)
563 {
564 res_z = sz + (i * delta) * TMath::Cos(m_Angle);
565 res_phi = sphi + (i * delta) * TMath::Sin(m_Angle) / m_RV;
566 }
567 else
568 {
569 res_z = sz - (i * delta) * TMath::Cos(m_Angle);
570 res_phi = sphi - (i * delta) * TMath::Sin(m_Angle) / m_RV;
571 }
572 }
573 else
574 {
575 //New Geom
576 //if ( (m_Angle <= 0 && res_phi * m_RV < m_Xmin)
577 // || (m_Angle > 0 && res_phi * m_RV > m_Xmin + m_Width)
578 // || res_z > m_Length + m_Zmin )
579 if (i >= N)
580 {
581 status = getEndPointFromV(v, res_phi, res_z);
582 if (status != NORMAL) return status;
583 status = ADJUST_TO_END;
584 }
585 else
586 {
587 status = getStartPointFromV(v, res_phi, res_z);
588 if (status != NORMAL) return status;
589 status = ADJUST_TO_START;
590 }
591 }
592
593 phi = res_phi;
594 z = res_z;
595 return status;
596}
597
598//Long Peixun's update: VID -> V
599double CgemVStripCalculator::getZFromVPhi(double v, double phi) const
600{
601 double x_temp = v / TMath::Cos(m_Angle);
602 double z_temp = (x_temp - phi * m_RV + m_Xmin) / TMath::Tan(m_Angle);
603 return m_Zmin + z_temp;
604}
605
606//---------- Cgem V-strip calculator class End ------------
607
608
609//*************************************************
610//---------- Cgem 2D V-strip class Begin ----------
611
612Cgem2DVStrip::Cgem2DVStrip(const char* name, const char* title, double v,
613 double r, double len, double wid, double ang, double xmin, double zmin, double pit,
614 Double_t size, Double_t thick, Int_t layer, Int_t sheet, Int_t strip,
615 Double_t rUF)
616 : Cgem2DStripBase(name, title, layer, sheet, strip)
617{
618 CgemVStripCalculator calc(rUF, len, wid, ang, xmin, zmin, pit);
619 int N = calc.getPointNumberFromV(v);
620
621 if (N > 0)
622 {
623 //Construct XY and ZR view shape
624 double* pxy = new double[6 * N];
625 double* pzr = new double[6 * N];
626 double tphi = 0, tz = 0;
627 double vuf = v / r * rUF; //vuf is v transformed to unfolded view
628 TString shapename = name;
629 TString shapetitle = title;
630 shapename += " XY";
631 shapetitle += " XY";
632
633 for (int i = 0; i < N; ++i)
634 {
635 calc.getNthPointFromV(v, i, tphi, tz);
636 double cosphi = TMath::Cos(tphi);
637 double sinphi = TMath::Sin(tphi);
638 double rplust = r + 0.5 * thick;
639 double rsubt = r - 0.5 * thick;
640
641 pxy[3 * i] = rsubt * cosphi;
642 pxy[3 * i + 1] = rsubt * sinphi;
643 pxy[3 * i + 2] = tz;
644 pxy[6 * N - 3 * i - 3] = rplust * cosphi;
645 pxy[6 * N - 3 * i - 2] = rplust * sinphi;
646 pxy[6 * N - 3 * i - 1] = tz;
647 pzr[3 * i] = r * cosphi;
648 pzr[3 * i + 1] = r * sinphi;
649 pzr[3 * i + 2] = tz - 0.5 * size;
650 pzr[6 * N - 3 * i - 3] = r * cosphi;
651 pzr[6 * N - 3 * i - 2] = r * sinphi;
652 pzr[6 * N - 3 * i - 1] = tz + 0.5 * size;
653 }
654
655 fVStripXY = new BesPolygon2D(shapename, shapetitle, 2 * N, pxy);
656 fVStripZR = new BesPolygon2D(name, title, 2 * N, pzr);
657
658 //Construct UF view shape
659 Double_t coorStrip[12];
660 calc.getStartPointFromV(vuf, tphi, tz);
661 double size_cosang = 0.5 * size * TMath::Cos(-ang);
662 double size_sinang = 0.5 * size * TMath::Sin(-ang);
663 //double subwid = 0;
664 //if (fLayer == 0) subwid = wid / 2;
665 //else subwid = wid;
666
667 //coorStrip[0] = tphi * r - subwid - size_cosang;
668 coorStrip[0] = tphi * rUF - size_cosang; //New Geom
669 coorStrip[1] = tz - size_sinang;
670 coorStrip[2] = 0;
671 //coorStrip[3] = tphi * r - subwid + size_cosang;
672 coorStrip[3] = tphi * rUF + size_cosang; //New Geom
673 coorStrip[4] = tz + size_sinang;
674 coorStrip[5] = 0;
675 calc.getEndPointFromV(vuf, tphi, tz);
676 //coorStrip[6] = tphi * r - subwid + size_cosang;
677 coorStrip[6] = tphi * rUF + size_cosang; //New Geom
678 coorStrip[7] = tz + size_sinang;
679 coorStrip[8] = 0;
680 //coorStrip[9] = tphi * r - subwid - size_cosang;
681 coorStrip[9] = tphi * rUF - size_cosang; //New Geom
682 coorStrip[10] = tz - size_sinang;
683 coorStrip[11] = 0;
684
685 shapename = name;
686 shapetitle = title;
687 shapename += " Unfolded";
688 shapetitle += " Unfolded";
689 fVStripUF = new BesPolygon2D(name, title, 4, coorStrip);
690
691 delete[] pxy;
692 delete[] pzr;
693 }
694 else
695 {
696 fVStripXY = 0;
697 fVStripZR = 0;
698 fVStripUF = 0;
699 }
700
701 SetStyle();
702 CloseInfo();
703}
704
706{
707 delete fVStripXY;
708 delete fVStripZR;
709 delete fVStripUF;
710}
711
713{
714 if (fTip)
715 {
716 fTip->Clear();
717 if (fInfoCon.size() == 0) fInfoCon.push_back(GetTitle());
719 }
720 else cout << "Cgem2DVStrip::CloseInfo, not initialized" << endl;
721}
722
724{
725 lcStrip = 30; //line color: grey green
726 lwStrip = 1; //line width
727 fcStrip = 30; //fill color: grey green
728 fsStrip = 1001; //fill style
729
730 lcStripFired = kRed;
731 lwStripFired = 1;
732 fcStripFired = kRed;
733 fsStripFired = 1001;
734
735 lcStripHL = kBlue;
736 lwStripHL = 1;
737 fcStripHL = kBlue;
738 fsStripHL = 1001;
739}
740
741Int_t Cgem2DVStrip::DistancetoPrimitive(Int_t px, Int_t py)
742{
743 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
744#ifdef CGEM_V_STRIP_TEST_CONDITIONAL_DISPLAY
745 if (!(CGEM_V_STRIP_DISPLAY_CONDITION)) return 9999;
746#endif
747
748 if ( (view->GetViewType() & kXYView) && fVStripXY &&
749 ( view->GetVisCgemVStrips() || this->IsFired() ))
750 {
751 return fVStripXY->DistancetoPrimitive(px, py);
752 }
753
754 if ((view->GetViewType() & kZRView) && fVStripZR &&
755 ( view->GetVisCgemVStrips() || this->IsFired() ))
756 return fVStripZR->DistancetoPrimitive(px, py);
757
758 if ((view->GetViewType() & kCgemUFView0) && fLayer == 0 && fVStripUF &&
759 ( view->GetVisCgemVStrips() || this->IsFired() ))
760 return fVStripUF->DistancetoPrimitive(px, py);
761
762 if ((view->GetViewType() & kCgemUFView1) && fLayer == 1 && fVStripUF &&
763 ( view->GetVisCgemVStrips() || this->IsFired() ))
764 return fVStripUF->DistancetoPrimitive(px, py);
765
766 if ((view->GetViewType() & kCgemUFView2) && fLayer == 2 && fVStripUF &&
767 ( view->GetVisCgemVStrips() || this->IsFired() ))
768 return fVStripUF->DistancetoPrimitive(px, py);
769
770 return 9999;
771}
772
773void Cgem2DVStrip::ExecuteEvent(Int_t event, Int_t px, Int_t py)
774{
775 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
776 //cout << "Cgem2DXStrip::ExecuteEvent()" << endl;
777 if (gBesCursor->GetType() == kBesHand)
778 {
779 if (view) view->ExecuteEvent(event, px, py);
780 }
781
782 else if (gBesCursor->GetType() == kBesPick)
783 {
784 if (gPad) gPad->SetCursor(kPointer);
785
786 switch (event)
787 {
788 case kMouseEnter:
789 SetHighlighted(true);
790 if (view->GetViewType() & kXYView) Draw("XY");
791 if (view->GetViewType() & kZRView) Draw("ZR");
792 if ((view->GetViewType() & kCgemUFView0) || (view->GetViewType() & kCgemUFView1) || (view->GetViewType() & kCgemUFView2))
793 Draw("UF");
794
795 fTip->SetPos(px, py);
796 view->UpdateView(0);
797
798 //Long Peixun's update: If ShowInfo is not checked, don't show tip text.
799 if (gBesCursor->GetShowInfo()) fTip->Draw("BR,SAME");
800 gPad->Modified();
801 gPad->Update();
802 break;
803
804 case kMouseLeave:
805 if (IsHighlighted())
806 {
807 SetHighlighted(false);
808 if (view->GetViewType() & kXYView) Draw("XY");
809 if (view->GetViewType() & kZRView) Draw("ZR");
810 if ((view->GetViewType() & kCgemUFView0) || (view->GetViewType() & kCgemUFView1) || (view->GetViewType() & kCgemUFView2))
811 Draw("UF");
812
813 view->UpdateView(0);
814 gPad->Modified();
815 gPad->Update();
816 }
817 break;
818 }
819 }
820}
821
822void Cgem2DVStrip::Draw(Option_t *option)
823{
824 TString opt = option;
825 opt.ToUpper();
826 AppendPad(option);
827}
828
829void Cgem2DVStrip::Paint(Option_t *option)
830{
831 //TString opt = option;
832 //opt.ToUpper();
833 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
834
835#ifdef CGEM_V_STRIP_TEST_CONDITIONAL_DISPLAY
836 if (!(CGEM_V_STRIP_DISPLAY_CONDITION)) return;
837#endif
838
839 if ((view->GetViewType() & kXYView) && fVStripXY)
840 {
841 if (IsFired())
842 {
843 fVStripXY->SetLineColor(lcStripFired);
844 fVStripXY->SetLineWidth(lwStripFired);
845 fVStripXY->SetFillColor(fcStripFired);
846 fVStripXY->SetFillStyle(fsStripFired);
847 }
848 else
849 {
850 fVStripXY->SetLineColor(lcStrip);
851 fVStripXY->SetLineWidth(lwStrip);
852 fVStripXY->SetFillColor(fcStrip);
853 fVStripXY->SetFillStyle(fsStrip);
854 }
855
856 if (IsHighlighted())
857 {
858 fVStripXY->SetLineColor(lcStripHL);
859 fVStripXY->SetLineWidth(lwStripHL);
860 fVStripXY->SetFillColor(fcStripHL);
861 fVStripXY->SetFillStyle(fsStripHL);
862 }
863
864 fVStripXY->Paint(); //Cannot use Draw()
865 }
866
867 if ((view->GetViewType() & kZRView) && fVStripZR)
868 {
869 if (IsFired())
870 {
871 fVStripZR->SetLineColor(lcStripFired);
872 fVStripZR->SetLineWidth(lwStripFired);
873 fVStripZR->SetFillColor(fcStripFired);
874 fVStripZR->SetFillStyle(fsStripFired);
875 }
876 else
877 {
878 fVStripZR->SetLineColor(lcStrip);
879 fVStripZR->SetLineWidth(lwStrip);
880 fVStripZR->SetFillColor(fcStrip);
881 fVStripZR->SetFillStyle(fsStrip);
882 }
883
884 if (IsHighlighted())
885 {
886 fVStripZR->SetLineColor(lcStripHL);
887 fVStripZR->SetLineWidth(lwStripHL);
888 fVStripZR->SetFillColor(fcStripHL);
889 fVStripZR->SetFillStyle(fsStripHL);
890 }
891
892 fVStripZR->Paint();
893 }
894
895 if ( fVStripUF && (
896 ((view->GetViewType() & kCgemUFView0) && fLayer == 0) ||
897 ((view->GetViewType() & kCgemUFView1) && fLayer == 1) ||
898 ((view->GetViewType() & kCgemUFView2) && fLayer == 2) )
899 )
900 {
901 if (IsFired())
902 {
903 fVStripUF->SetLineColor(lcStripFired);
904 fVStripUF->SetLineWidth(lwStripFired);
905 fVStripUF->SetFillColor(fcStripFired);
906 fVStripUF->SetFillStyle(fsStripFired);
907 }
908 else
909 {
910 fVStripUF->SetLineColor(lcStrip);
911 fVStripUF->SetLineWidth(lwStrip);
912 fVStripUF->SetFillColor(fcStrip);
913 fVStripUF->SetFillStyle(fsStrip);
914 }
915
916 if (IsHighlighted())
917 {
918 fVStripUF->SetLineColor(lcStripHL);
919 fVStripUF->SetLineWidth(lwStripHL);
920 fVStripUF->SetFillColor(fcStripHL);
921 fVStripUF->SetFillStyle(fsStripHL);
922 }
923
924 fVStripUF->Paint();
925 }
926}
927
928//---------- Cgem 2D V-strip class End ----------
@ kBesHand
Definition BesCursor.h:15
@ kBesPick
Definition BesCursor.h:14
R__EXTERN BesCursor * gBesCursor
Definition BesCursor.h:40
@ kCgemUFView2
Definition BesStatus.h:20
@ kCgemUFView0
Definition BesStatus.h:18
@ kXYView
Definition BesStatus.h:15
@ kCgemUFView1
Definition BesStatus.h:19
@ kZRView
Definition BesStatus.h:16
#define CGEM_X_STRIP_DISPLAY_CONDITION
ClassImp(Cgem2DXStrip) ClassImp(Cgem2DVStrip) Cgem2DStripBase
#define CGEM_V_STRIP_DISPLAY_CONDITION
Double_t phi2
gr SetTitle("BbLum_000XXXX")
Double_t x[10]
Double_t phi1
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35
***************************************************************************************Pseudo Class RRes *****************************************************************************************Parameters and physical constants **Maarten sept ************************************************************************DOUBLE PRECISION xsmu **************************************************************************PARTICLE DATA all others are from PDG *Only resonances with known widths into electron pairs are sept ************************************************************************C Declarations C
Definition RRes.h:29
Bool_t GetShowInfo()
Definition BesCursor.h:35
EBESCursorType GetType()
Definition BesCursor.h:32
virtual void SetMarkerSizeMultiple(Int_t input)
Definition BesMarker2D.h:34
virtual void Paint(Option_t *option="")
virtual void SetText(std::vector< TString > infoCon)
virtual void SetPos(Int_t px, Int_t py)
virtual void Paint(Option_t *option="")
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void Stretch(Double_t sx, Double_t sy, Double_t sz, Double_t factor)
virtual void Restore()
virtual void GetCenter(Double_t *Center) const
Bool_t GetVisCgemXStrips()
Definition BesView.h:122
Bool_t GetVisCgemVStrips()
Definition BesView.h:123
virtual void UpdateView(Bool_t resetview=kFALSE)
Definition BesView.cxx:753
Bool_t GetVisCgemHitsFiredHL()
Definition BesView.h:205
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition BesView.cxx:965
EBESViewType GetViewType()
Definition BesView.h:74
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition BesView.cxx:451
virtual char * GetObjectInfo(Int_t px, Int_t py) const
virtual void ClearInfo()
BesPaveText * fTip
Definition Cgem2DStrip.h:55
Cgem2DStripBase(const char *name, const char *title, Int_t layer, Int_t sheet, Int_t strip)
virtual bool IsFired() const
Definition Cgem2DStrip.h:38
virtual ~Cgem2DStripBase()
std::vector< TString > fInfoCon
Definition Cgem2DStrip.h:54
virtual void SetHighlighted(bool status=true)
Definition Cgem2DStrip.h:35
virtual bool IsHighlighted() const
Definition Cgem2DStrip.h:37
virtual ~Cgem2DVStrip()
virtual void SetStyle()
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void CloseInfo()
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual void Draw(Option_t *option="")
BesPolygon2D * fVStripZR
Cgem2DVStrip(const char *name, const char *title, double v, double r, double len, double wid, double ang, double xmin, double zmin, double pit, Double_t size, Double_t thick, Int_t layer, Int_t sheet, Int_t strip, Double_t rUF)
virtual void Paint(Option_t *option="")
BesPolygon2D * fVStripUF
BesPolygon2D * fVStripXY
virtual void SetStyle()
BesPolygon2D * fXStripXY
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Cgem2DXStrip(const char *name, const char *title, Double_t len, Double_t wid, Double_t phi, Double_t zmin, Double_t r, Double_t size, Double_t thick, Int_t layer, Int_t sheet, Int_t strip, Double_t rUF)
virtual void CloseInfo()
BesPolygon2D * fXStripZR
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual ~Cgem2DXStrip()
BesMarker2D * fXYHighlight
BesPolygon2D * fXStripUF
virtual void Draw(Option_t *option="")
virtual void Paint(Option_t *option="")
Double_t fFiredSizeFactor
static const int ADJUST_TO_END
static const int NORMAL
double getStripLengthFromV(double v) const
double getPointPhi(double *pos) const
int getStartPointFromV(double v, double &phi, double &z) const
int getPointNumberFromV(double v) const
int getNthPointFromV(double v, int i, double &phi, double &z) const
bool isPointInSheet(double phi, double z) const
double getZFromVPhi(double v, double phi) const
static const int ADJUST_TO_START
CgemVStripCalculator(double r, double len, double wid, double ang, double xmin, double zmin, double pit)
static const int INVALID_VID
int getEndPointFromV(double v, double &phi, double &z) const
c1_1 Draw()