BOSS 6.6.4.p03
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
93 if (fStripXY) delete fStripXY;
94 if (fStripZR) 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 = (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 = (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 fTip->Draw("BR,SAME"); // "BR,ARC,SAME"
180 gPad->Modified();
181 gPad->Update();
182
183 break;
184
185 case kMouseLeave:
186 if (this->IsHighlighted()) {
187 this->SetHighlighted(false);
188 //if (view->GetVisMucHitsGlobal())
189 Draw();
190
191 view->UpdateView(0);
192 gPad->Modified();
193 gPad->Update();
194 break;
195 }
196 }
197
198 //if (view) view->ExecuteEvent(event, px, py);
199 }
200}
201
202//_____________________________________________________
203
204void Muc2DStrip::Draw(Option_t *option) {
205 //
206 // Muc2DStrip draw function
207 TString opt = option;
208 opt.ToUpper();
209
210 AppendPad(option);
211}
212
213//_____________________________________________________
214
215void Muc2DStrip::Paint(Option_t *option) {
216
217 TString opt = option;
218 opt.ToUpper();
219
220 BesView *view = (BesView*)gPad->GetView();
221 Double_t min[3], max[3];
222 view->GetRange(&min[0], &max[0]);
223 Double_t maxRange = 0.0;
224 Double_t range[3];
225 for (Int_t i = 0; i < 3; i++) {
226 range[i] = fabs(max[i] - min[i]);
227 if (range[i] > maxRange) maxRange = range[i];
228 }
229
230 if (view->GetViewType() & kXYView) {
231
232 if (fStripXY) {
233 fStripXY->SetLineColor(lcStrip);
234 fStripXY->SetLineWidth(lwStrip);
235 fStripXY->SetLineStyle(lsStrip);
236 fStripXY->SetFillColor(fcStrip);
237 fStripXY->SetFillStyle(fsStrip);
238 }
239
240 if (this->IsFired()) {
241 if (fStripXY) {
242 fStripXY->SetLineColor(lcStripFired);
243 if (maxRange > m_kDrawLineRange && fPart == 1)
244 fStripXY->SetLineColor(fcStripFired); // too small makes it hard to see
245 fStripXY->SetLineWidth(lwStripFired);
246 fStripXY->SetLineStyle(lsStripFired);
247 fStripXY->SetFillColor(fcStripFired);
248 fStripXY->SetFillStyle(fsStripFired);
249 }
250 }
251
252 if (this->IsHighlighted()) {
253 if (fStripXY) {
254 fStripXY->SetLineColor(lcStripHL);
255 if (maxRange > m_kDrawLineRange && fPart == 1)
256 fStripXY->SetLineColor(fcStripHL); // too small makes it hard to see
257 fStripXY->SetLineWidth(lwStripHL);
258 fStripXY->SetLineStyle(lsStripHL);
259 fStripXY->SetFillColor(fcStripHL);
260 fStripXY->SetFillStyle(fsStripHL);
261 }
262 }
263
264 if ( fStripXY && view->GetVisMucStrips() ) fStripXY->Paint();
265 if (this->IsFired()) {
266 if (view->GetVisMucHitsGlobal() &&
267 ( (fPart == 0 && view->GetVisMucHitsEast()) ||
268 (fPart == 1 && view->GetVisMucHitsBarrel()) ||
269 (fPart == 2 && view->GetVisMucHitsWest()) )) {
270 fStripXY->Paint();
271 }
272 }
273 }
274
275 if (view->GetViewType() & kZRView) {
276
277 if (fStripZR) {
278 fStripZR->SetLineColor(lcStrip);
279 fStripZR->SetLineWidth(lwStrip);
280 fStripZR->SetLineStyle(lsStrip);
281 fStripZR->SetFillColor(fcStrip);
282 fStripZR->SetFillStyle(fsStrip);
283 }
284
285 if (this->IsFired()) {
286 if (fStripZR) {
287 fStripZR->SetLineColor(lcStripFired);
288 if (maxRange > m_kDrawLineRange)
289 fStripZR->SetLineColor(fcStripFired); // too small makes it hard to see
290 fStripZR->SetLineWidth(lwStripFired);
291 fStripZR->SetLineStyle(lsStripFired);
292 fStripZR->SetFillColor(fcStripFired);
293 fStripZR->SetFillStyle(fsStripFired);
294 }
295 }
296
297 if (this->IsHighlighted()) {
298 if (fStripZR) {
299 fStripZR->SetLineColor(lcStripHL);
300 if (maxRange > m_kDrawLineRange)
301 fStripZR->SetLineColor(fcStripHL); // too small makes it hard to see
302 fStripZR->SetLineWidth(lwStripHL);
303 fStripZR->SetLineStyle(lsStripHL);
304 fStripZR->SetFillColor(fcStripHL);
305 fStripZR->SetFillStyle(fsStripHL);
306 }
307 }
308
309 if ( fStripZR && view->GetVisMucStrips() && IsZRVisible() ) fStripZR->Paint();
310 if (this->IsFired() && IsZRVisible() ) {
311 if (view->GetVisMucHitsGlobal() &&
312 ( (fPart == 0 && view->GetVisMucHitsEast()) ||
313 (fPart == 1 && view->GetVisMucHitsBarrel()) ||
314 (fPart == 2 && view->GetVisMucHitsWest()) )) {
315 fStripZR->Paint();
316 }
317 }
318 }
319}
320
321//_____________________________________________________
322
323char *Muc2DStrip::GetObjectInfo(Int_t px, Int_t py) const {
324
325 BesView *view = (BesView*)gPad->GetView();
326 if (view) return view->GetObjectInfo(px, py);
327 else return TObject::GetObjectInfo(px, py);
328}
329
330//_____________________________________________________
331
333{
334 BesView *view = (BesView*)gPad->GetView();
335 Double_t viewPhi = view->GetLongitude();
336 viewPhi = Range360(viewPhi);
337
338 if (fPart != 1) {
339 if ( (Int_t)viewPhi % 90 == 0 ) return true;
340 else return false;
341 }
342 else {
343 Int_t viewSeg = Int_t(viewPhi/45.0+0.5);
344 //cout << "viewSeg " << viewSeg << endl;
345 Int_t upSeg = viewSeg-2;
346 Int_t downSeg = viewSeg+2;
347 if (upSeg < 0) upSeg += 8;
348 else if (upSeg >= 8) upSeg -= 8;
349 if (downSeg < 0) downSeg += 8;
350 else if (downSeg >= 8) downSeg -= 8;
351 //if (fStrip == 0) cout << GetName() << " upSeg " << upSeg << " downSeg " << downSeg << endl;
352
353 if ( (Int_t)viewPhi % 45 == 0 && (fSeg == upSeg || fSeg == downSeg) ) return true;
354 else return false;
355 }
356
357 return false;
358}
359
360//_____________________________________________________
361
362Double_t Muc2DStrip::GetAngle(Double_t x, Double_t y) //degree
363{
364 Double_t angle = TMath::ACos( x/TMath::Sqrt(x*x+y*y) ) * TMath::RadToDeg();
365 if ( y<0.0 ) angle *= -1;
366 angle = Range360(angle);
367
368 return angle;
369}
370
371//_____________________________________________________
372
373Double_t Muc2DStrip::Range360(Double_t input)
374{
375 if (input >= 360.0) {
376 do {
377 input -= 360.0;
378 }
379 while (input >= 360.0);
380 }
381 else if (input < 0.0) {
382 do {
383 input += 360.0;
384 }
385 while (input < 0.0);
386 }
387
388 return input;
389}
@ 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
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:76
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:1137
Bool_t GetVisMucHitsWest()
Definition: BesView.h:196
Bool_t GetVisMucHitsGlobal()
Definition: BesView.h:193
Bool_t GetVisMucHitsEast()
Definition: BesView.h:194
virtual void UpdateView(Bool_t resetview=kFALSE)
Definition: BesView.cxx:598
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition: BesView.cxx:800
Bool_t GetVisMucHitsBarrel()
Definition: BesView.h:195
EBESViewType GetViewType()
Definition: BesView.h:65
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: BesView.cxx:365
Bool_t GetVisMucStrips()
Definition: BesView.h:133
Double_t GetAngle(Double_t x, Double_t y)
Definition: Muc2DStrip.cxx:362
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:204
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:323
virtual void ClearInfo()
Definition: Muc2DStrip.cxx:119
virtual bool IsZRVisible()
Definition: Muc2DStrip.cxx:332
virtual void Paint(Option_t *option="")
Definition: Muc2DStrip.cxx:215
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:373
c1_1 Draw()