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