CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
Muc2DStrip.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"
8#include "BesVisLib/BesView.h"
10
11using namespace std;
12
13#ifndef __CINT__
15#endif
16
17//_____________________________________________________
18
20
21}
22
23//_____________________________________________________
24
25Muc2DStrip::Muc2DStrip(const char* name, const char* title, Int_t N, Double_t *P, Int_t part, Int_t seg, Int_t gap, Int_t strip)
26{
27 SetName(name);
28 SetTitle(title);
29 fTip = 0;
30 fHighlighted = false;
31 fFired = false;
32 fPart = part;
33 fSeg = seg;
34 fGap = gap;
35 fStrip = strip;
36
37 // ------XY------
38
39 Double_t Pxy[3*4];
40 for (Int_t i = 0; i < 4; i++) {
41 if (part == 1) {
42 Int_t iXYSeq[8] = {1,0,4,5, 2,3,7,6}; // center of 1+2, 0+3, 4+7, 5+6
43 for (Int_t j = 0; j < 3; j++) {
44 Pxy[3*i+j] = ( P[3*iXYSeq[i]+j] + P[3*(iXYSeq[i+4])+j] )/2.0;
45 }
46 }
47 else {
48 Int_t iXYSeq[8] = {0,1,2,3, 4,5,6,7}; // center of 0+4, 1+5, 2+6, 3+7
49 for (Int_t j = 0; j < 3; j++) {
50 Pxy[3*i+j] = ( P[3*iXYSeq[i]+j] + P[3*(iXYSeq[i+4])+j] )/2.0;
51 }
52 }
53 }
54
55 fStripXY = new BesPolygon2D(name, title, 4, &Pxy[0]);
56
57 // ------ZR------
58
59 Double_t Pzr[3*6];
60 Int_t nzrPoints = 6;
61 if (part == 1) {
62 Int_t iZRSeq[6] = {4,5,1,2,6,7}; //{1,2,6,5, 0,3,7,4}; // center of 0+4, 1+5, 2+6, 3+7
63 for (Int_t i = 0; i < nzrPoints; i++) {
64 for (Int_t j = 0; j < 3; j++) {
65 Pzr[3*i+j] = P[3*iZRSeq[i]+j]; // ( P[3*iZRSeq[i]+j] + P[3*(iZRSeq[i+4])+j] )/2.0;
66 }
67 }
68 }
69 else {
70 nzrPoints = 6;
71 Int_t iZRSeq[6] = {1,2,3,7,6,5};
72 for (Int_t i = 0; i < nzrPoints; i++) {
73 for (Int_t j = 0; j < 3; j++) {
74 Pzr[3*i+j] = P[3*iZRSeq[i]+j];
75 }
76 }
77 }
78
79 fStripZR = new BesPolygon2D(name, title, nzrPoints, &Pzr[0]);
80
81 // Init
82
83 SetStyle();
84
85 fTip = new BesPaveText(0, 0, 0.1, 0.1);
86 CloseInfo();
87}
88
89//_____________________________________________________
90
92 //Long Peixun's update: remove "if"
93 delete fStripXY;
94 delete fStripZR;
95}
96
98{
99 lcStrip = 15;
100 lwStrip = 1;
101 lsStrip = 1;
102 fcStrip = 1007; // lightBrown // 1005; // lightBlue
103 fsStrip = 1001;
104
105 lcStripFired = 15; //kRed; //15
106 lwStripFired = 1;
107 lsStripFired = 1;
108 fcStripFired = kRed;
109 fsStripFired = 1001;
110
111 lcStripHL = lcStrip;
112 lwStripHL = 1;
113 lsStripHL = 1;
114 fcStripHL = kBlue;
115 fsStripHL = 1001;
116
117}
118
120{
121 fInfoCon.clear();
122 fTip->DeleteText();
123}
124
126{
127 if (fTip) {
128 fTip->Clear();
129
130 if (fInfoCon.size() == 0) fInfoCon.push_back(GetTitle());
131 fTip->SetText(fInfoCon);
132 }
133 else
134 cout << "Muc2DStrip::CloseInfo, not initialized" << endl;
135}
136
137//_____________________________________________________
138
139Int_t Muc2DStrip::DistancetoPrimitive(Int_t px, Int_t py) {
140
141 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
142 if ( view->GetViewType() & kXYView && fStripXY &&
143 ( view->GetVisMucStrips() || (view->GetVisMucHitsGlobal() && this->IsFired()) ) ) {
144 return fStripXY->DistancetoPrimitive(px, py);
145 }
146 else if ( view->GetViewType() & kZRView && fStripZR &&
147 ( (view->GetVisMucStrips() && this->IsZRVisible()) ||
148 (view->GetVisMucHitsGlobal() && this->IsFired() && this->IsZRVisible()) ) ) {
149 return fStripZR->DistancetoPrimitive(px, py);
150 }
151
152 return 9999;
153}
154
155//_____________________________________________________
156
157void Muc2DStrip::ExecuteEvent(Int_t event, Int_t px, Int_t py) {
158
159 //cout << GetName() << endl;
160 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
161
162 if (gBesCursor->GetType() == kBesHand) {
163 if (view) view->ExecuteEvent(event, px, py);
164 }
165 else if (gBesCursor->GetType() == kBesPick){
166
167 if (gPad) gPad->SetCursor(kPointer);
168
169 switch (event) {
170
171 case kMouseEnter :
172 this->SetHighlighted(true);
173
174 Draw();
175
176 fTip->SetPos(px, py);
177 view->UpdateView(0);
178
179 //Long Peixun's update: If ShowInfo is not checked, don't show tip text.
180 if (gBesCursor->GetShowInfo()) fTip->Draw("BR,SAME"); // "BR,ARC,SAME"
181 gPad->Modified();
182 gPad->Update();
183
184 break;
185
186 case kMouseLeave:
187 if (this->IsHighlighted()) {
188 this->SetHighlighted(false);
189 //if (view->GetVisMucHitsGlobal())
190 Draw();
191
192 view->UpdateView(0);
193 gPad->Modified();
194 gPad->Update();
195 break;
196 }
197 }
198
199 //if (view) view->ExecuteEvent(event, px, py);
200 }
201}
202
203//_____________________________________________________
204
205void Muc2DStrip::Draw(Option_t *option) {
206 //
207 // Muc2DStrip draw function
208 TString opt = option;
209 opt.ToUpper();
210
211 AppendPad(option);
212}
213
214//_____________________________________________________
215
216void Muc2DStrip::Paint(Option_t *option) {
217
218 TString opt = option;
219 opt.ToUpper();
220
221 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
222 Double_t min[3], max[3];
223 view->GetRange(&min[0], &max[0]);
224 Double_t maxRange = 0.0;
225 Double_t range[3];
226 for (Int_t i = 0; i < 3; i++) {
227 range[i] = fabs(max[i] - min[i]);
228 if (range[i] > maxRange) maxRange = range[i];
229 }
230
231 if (view->GetViewType() & kXYView) {
232
233 if (fStripXY) {
234 fStripXY->SetLineColor(lcStrip);
235 fStripXY->SetLineWidth(lwStrip);
236 fStripXY->SetLineStyle(lsStrip);
237 fStripXY->SetFillColor(fcStrip);
238 fStripXY->SetFillStyle(fsStrip);
239 }
240
241 if (this->IsFired()) {
242 if (fStripXY) {
243 fStripXY->SetLineColor(lcStripFired);
244 if (maxRange > m_kDrawLineRange && fPart == 1)
245 fStripXY->SetLineColor(fcStripFired); // too small makes it hard to see
246 fStripXY->SetLineWidth(lwStripFired);
247 fStripXY->SetLineStyle(lsStripFired);
248 fStripXY->SetFillColor(fcStripFired);
249 fStripXY->SetFillStyle(fsStripFired);
250 }
251 }
252
253 if (this->IsHighlighted()) {
254 if (fStripXY) {
255 fStripXY->SetLineColor(lcStripHL);
256 if (maxRange > m_kDrawLineRange && fPart == 1)
257 fStripXY->SetLineColor(fcStripHL); // too small makes it hard to see
258 fStripXY->SetLineWidth(lwStripHL);
259 fStripXY->SetLineStyle(lsStripHL);
260 fStripXY->SetFillColor(fcStripHL);
261 fStripXY->SetFillStyle(fsStripHL);
262 }
263 }
264
265 if ( fStripXY && view->GetVisMucStrips() ) fStripXY->Paint();
266 if (this->IsFired()) {
267 if (view->GetVisMucHitsGlobal() &&
268 ( (fPart == 0 && view->GetVisMucHitsEast()) ||
269 (fPart == 1 && view->GetVisMucHitsBarrel()) ||
270 (fPart == 2 && view->GetVisMucHitsWest()) )) {
271 fStripXY->Paint();
272 }
273 }
274 }
275
276 if (view->GetViewType() & kZRView) {
277
278 if (fStripZR) {
279 fStripZR->SetLineColor(lcStrip);
280 fStripZR->SetLineWidth(lwStrip);
281 fStripZR->SetLineStyle(lsStrip);
282 fStripZR->SetFillColor(fcStrip);
283 fStripZR->SetFillStyle(fsStrip);
284 }
285
286 if (this->IsFired()) {
287 if (fStripZR) {
288 fStripZR->SetLineColor(lcStripFired);
289 if (maxRange > m_kDrawLineRange)
290 fStripZR->SetLineColor(fcStripFired); // too small makes it hard to see
291 fStripZR->SetLineWidth(lwStripFired);
292 fStripZR->SetLineStyle(lsStripFired);
293 fStripZR->SetFillColor(fcStripFired);
294 fStripZR->SetFillStyle(fsStripFired);
295 }
296 }
297
298 if (this->IsHighlighted()) {
299 if (fStripZR) {
300 fStripZR->SetLineColor(lcStripHL);
301 if (maxRange > m_kDrawLineRange)
302 fStripZR->SetLineColor(fcStripHL); // too small makes it hard to see
303 fStripZR->SetLineWidth(lwStripHL);
304 fStripZR->SetLineStyle(lsStripHL);
305 fStripZR->SetFillColor(fcStripHL);
306 fStripZR->SetFillStyle(fsStripHL);
307 }
308 }
309
310 if ( fStripZR && view->GetVisMucStrips() && IsZRVisible() ) fStripZR->Paint();
311 if (this->IsFired() && IsZRVisible() ) {
312 if (view->GetVisMucHitsGlobal() &&
313 ( (fPart == 0 && view->GetVisMucHitsEast()) ||
314 (fPart == 1 && view->GetVisMucHitsBarrel()) ||
315 (fPart == 2 && view->GetVisMucHitsWest()) )) {
316 fStripZR->Paint();
317 }
318 }
319 }
320}
321
322//_____________________________________________________
323
324char *Muc2DStrip::GetObjectInfo(Int_t px, Int_t py) const {
325
326 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
327 if (view) return view->GetObjectInfo(px, py);
328 else return TObject::GetObjectInfo(px, py);
329}
330
331//_____________________________________________________
332
334{
335 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
336 Double_t viewPhi = view->GetLongitude();
337 viewPhi = Range360(viewPhi);
338
339 if (fPart != 1) {
340 if ( (Int_t)viewPhi % 90 == 0 ) return true;
341 else return false;
342 }
343 else {
344 Int_t viewSeg = Int_t(viewPhi/45.0+0.5);
345 //cout << "viewSeg " << viewSeg << endl;
346 Int_t upSeg = viewSeg-2;
347 Int_t downSeg = viewSeg+2;
348 if (upSeg < 0) upSeg += 8;
349 else if (upSeg >= 8) upSeg -= 8;
350 if (downSeg < 0) downSeg += 8;
351 else if (downSeg >= 8) downSeg -= 8;
352 //if (fStrip == 0) cout << GetName() << " upSeg " << upSeg << " downSeg " << downSeg << endl;
353
354 if ( (Int_t)viewPhi % 45 == 0 && (fSeg == upSeg || fSeg == downSeg) ) return true;
355 else return false;
356 }
357
358 return false;
359}
360
361//_____________________________________________________
362
363Double_t Muc2DStrip::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 Muc2DStrip::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}
@ kBesHand
Definition: BesCursor.h:15
@ kBesPick
Definition: BesCursor.h:14
R__EXTERN BesCursor * gBesCursor
Definition: BesCursor.h:40
@ kXYView
Definition: BesStatus.h:15
@ kZRView
Definition: BesStatus.h:16
double P(RecMdcKalTrack *trk)
gr SetTitle("BbLum_000XXXX")
Double_t x[10]
ClassImp(Muc2DStrip) Muc2DStrip
Definition: Muc2DStrip.cxx:14
Bool_t GetShowInfo()
Definition: BesCursor.h:35
EBESCursorType GetType()
Definition: BesCursor.h:32
virtual void SetText(std::vector< TString > infoCon)
Definition: BesPaveText.cxx:35
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)
Double_t GetLongitude()
Definition: BesTView.h:95
virtual void GetRange(Float_t *min, Float_t *max)
Definition: BesTView.cxx:1138
Bool_t GetVisMucHitsWest()
Definition: BesView.h:248
Bool_t GetVisMucHitsGlobal()
Definition: BesView.h:245
Bool_t GetVisMucHitsEast()
Definition: BesView.h:246
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
Bool_t GetVisMucHitsBarrel()
Definition: BesView.h:247
EBESViewType GetViewType()
Definition: BesView.h:74
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: BesView.cxx:451
Bool_t GetVisMucStrips()
Definition: BesView.h:170
Double_t GetAngle(Double_t x, Double_t y)
Definition: Muc2DStrip.cxx:363
virtual void SetHighlighted(bool status=true)
Definition: Muc2DStrip.h:30
virtual bool IsHighlighted()
Definition: Muc2DStrip.h:32
virtual void Draw(Option_t *option="")
Definition: Muc2DStrip.cxx:205
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Definition: Muc2DStrip.cxx:139
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition: Muc2DStrip.cxx:324
virtual void ClearInfo()
Definition: Muc2DStrip.cxx:119
virtual bool IsZRVisible()
Definition: Muc2DStrip.cxx:333
virtual void Paint(Option_t *option="")
Definition: Muc2DStrip.cxx:216
virtual bool IsFired()
Definition: Muc2DStrip.h:33
virtual void SetStyle()
Definition: Muc2DStrip.cxx:97
virtual void CloseInfo()
Definition: Muc2DStrip.cxx:125
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: Muc2DStrip.cxx:157
Double_t Range360(Double_t input)
Definition: Muc2DStrip.cxx:374
c1_1 Draw()