BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
BesPolygon2D Class Reference

#include <BesPolygon2D.h>

+ Inheritance diagram for BesPolygon2D:

Public Member Functions

 BesPolygon2D ()
 info box
 
 BesPolygon2D (const char *name, const char *title, Int_t N, Double_t *P)
 
virtual ~BesPolygon2D ()
 
virtual void Draw (Option_t *option="")
 
virtual void Paint (Option_t *option="")
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 
virtual void SetZRSign (Int_t sign)
 
virtual void Resize (Double_t ScaleFactor)
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 
virtual void SetInfoBox ()
 
virtual void GetCenter (Double_t *Center) const
 
virtual void RotatePhi (Double_t phi)
 
virtual void Restore ()
 
virtual void SetSize (Double_t size)
 
Bool_t IsRotatable ()
 
void SetRotatable (Bool_t input)
 
void SetName (const char *name)
 
void SetTitle (const char *name)
 
void Delete (Option_t *option)
 
void DrawClass ()
 
void DrawClone (Option_t *option)
 
void SetDrawOption (Option_t *option)
 
void SetPoints (Double_t *P)
 

Protected Attributes

Double_t * f_xx
 
Double_t * f_yy
 
Int_t fN
 
Double_t * fP
 
Double_t * fPBackUp
 
Double_t fCenter [3]
 
Bool_t fRotatable
 
TPaveText * fInfoBox
 

Detailed Description

Definition at line 27 of file BesPolygon2D.h.

Constructor & Destructor Documentation

◆ BesPolygon2D() [1/2]

BesPolygon2D::BesPolygon2D ( )

info box

◆ BesPolygon2D() [2/2]

BesPolygon2D::BesPolygon2D ( const char *  name,
const char *  title,
Int_t  N,
Double_t *  P 
)

Definition at line 67 of file BesPolygon2D.cxx.

68 :
69 TNamed(name, title), TAttLine(), TAttFill() {
70 //
71 // BesPolygon2D normal constructor
72 //cout << "####################" << endl;
73 //cout << "BesPolygon2D ctor called " << ++num << endl;
74 //cout << "####################" << endl;
75
76 fN = N;
77 fP = new Double_t[fN*3];
78 fPBackUp = new Double_t[fN*3];
79 f_xx = NULL;
80 f_yy = NULL;
81
82 fInfoBox = 0;
83 if (P!=NULL){
84 SetPoints(P);
85 }
86
87 for ( Int_t i = 0; i < fN*3; i++ ) {
88 fPBackUp[i] = fP[i];
89 }
90
91 for (Int_t j = 0; j < 3; j++) {
92 fCenter[j] = 0.0;
93 for ( Int_t i = 0; i < fN; i++) {
94 fCenter[j] += fP[3*i+j];
95 }
96 fCenter[j] /= fN;
97 }
98
99 for ( Int_t i = 0; i < fN; i++ ) {
100 }
101
102 fRotatable = false;
103}
double P(RecMdcKalTrack *trk)
Double_t fCenter[3]
Definition: BesPolygon2D.h:36
TPaveText * fInfoBox
Definition: BesPolygon2D.h:39
Double_t * fP
Definition: BesPolygon2D.h:34
void SetPoints(Double_t *P)
Definition: BesPolygon2D.h:84
Double_t * fPBackUp
Definition: BesPolygon2D.h:35
Bool_t fRotatable
Definition: BesPolygon2D.h:37
Double_t * f_xx
Definition: BesPolygon2D.h:31
Double_t * f_yy
Definition: BesPolygon2D.h:32

◆ ~BesPolygon2D()

BesPolygon2D::~BesPolygon2D ( )
virtual

Definition at line 107 of file BesPolygon2D.cxx.

107 {
108 //
109 // BesPolygon2D default destructor
110 //cout << "####################" << endl;
111 //cout << "BesPolygon2D dtor called " << --num << endl;
112 //cout << "####################" << endl;
113
114 if ( fP) delete [] fP;
115 if ( fPBackUp) delete [] fPBackUp;
116}

Member Function Documentation

◆ Delete()

void BesPolygon2D::Delete ( Option_t *  option)
inline

Definition at line 72 of file BesPolygon2D.h.

72 {
73 TObject::Delete(option);
74 }

◆ DistancetoPrimitive()

Int_t BesPolygon2D::DistancetoPrimitive ( Int_t  px,
Int_t  py 
)
virtual

Definition at line 176 of file BesPolygon2D.cxx.

176 {
177 //
178 // Compute the closest distance of approach from point px,py to the
179 // center of this polygon
180 // The distance is computed in pixels units.
181
182 const Int_t inaxis = 7;
183 Int_t dist = 9999;
184
185 if (this->IsRotatable()) return dist;
186
187 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
188 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
189 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
190 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
191
192 // return if point is not in the user area
193 if (px < puxmin - inaxis) return dist;
194 if (py > puymin + inaxis) return dist;
195 if (px > puxmax + inaxis) return dist;
196 if (py < puymax - inaxis) return dist;
197
198 // judge the mouse point and center are always on the same side of any line of ploygon
199 // Transform to normalised desktop coordinates
200
201 BesView *view = (BesView*)gPad->GetView();
202 if (!view) return dist;
203
204 Bool_t inPolygon = true;
205 Int_t x1, y1, x2, y2, cx, cy;
206 Double_t Pndc[3], k, b, pb, cb;
207
208 view->WCtoNDC(&fCenter[0], Pndc);
209 cx = gPad->XtoAbsPixel(Pndc[0]);
210 cy = gPad->YtoAbsPixel(Pndc[1]);
211
212 //cout << "px " << px << " py " << py << endl;
213 //cout << "center " << cx << " " << cy << endl;
214
215 for (Int_t i = 0; i < fN; i++) {
216 view->WCtoNDC(&fP[3*i], Pndc);
217 x1 = gPad->XtoAbsPixel(Pndc[0]);
218 y1 = gPad->YtoAbsPixel(Pndc[1]);
219
220 if (i != fN-1) {
221 view->WCtoNDC(&fP[3*(i+1)], Pndc);
222 }
223 else
224 view->WCtoNDC(&fP[0], Pndc);
225
226 x2 = gPad->XtoAbsPixel(Pndc[0]);
227 y2 = gPad->YtoAbsPixel(Pndc[1]);
228
229 //cout << "x1 " << x1 << " y1 " << y1 << endl;
230 //cout << "x2 " << x2 << " y2 " << y2 << endl;
231 if (x1 == x2) {
232 if ((px-x1)*(cx-x1) <= 0) {
233 inPolygon = false;
234 break;
235 }
236 }
237 else {
238 k = Double_t(y2-y1)/(x2-x1);
239 b = y1-k*x1;
240 pb = py-k*px;
241 cb = cy-k*cx;
242 if ((pb-b)*(cb-b) <= 0) {
243 inPolygon = false;
244 break;
245 }
246 }
247 }
248
249 if (inPolygon == true) {
250 //gPad->SetSelected(this);
251 //gPad->SetCursor(kHand);
252 return 0;
253 }
254 else return 9999;
255
256 //cout << GetName() << dist << endl;
257 //if (dist < 100) dist = 0;
258}
Bool_t IsRotatable()
Definition: BesPolygon2D.h:60
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)
Definition: BesView.cxx:659

Referenced by Emc2DCrystal::DistancetoPrimitive(), Muc2DStrip::DistancetoPrimitive(), and Tof2DScin::DistancetoPrimitive().

◆ Draw()

void BesPolygon2D::Draw ( Option_t *  option = "")
virtual

Definition at line 120 of file BesPolygon2D.cxx.

120 {
121 //
122 // BesPolygon2D draw function
123 TString opt = option;
124 opt.ToUpper();
125
126 AppendPad(option);
127}

Referenced by MdcROOTGeo::Draw(), MucROOTGeo::Draw(), BesGeometry::Draw2DXY(), and BesGeometry::Draw2DZR().

◆ DrawClass()

void BesPolygon2D::DrawClass ( )
inline

Definition at line 75 of file BesPolygon2D.h.

75 {
76 TObject::DrawClass();
77 }

◆ DrawClone()

void BesPolygon2D::DrawClone ( Option_t *  option)
inline

Definition at line 78 of file BesPolygon2D.h.

78 {
79 TObject::DrawClone(option);
80 }

◆ ExecuteEvent()

void BesPolygon2D::ExecuteEvent ( Int_t  event,
Int_t  px,
Int_t  py 
)
virtual

Definition at line 262 of file BesPolygon2D.cxx.

262 {
263 //cout << "I am in " << GetName() << endl;
264
265 BesView *view = (BesView*)gPad->GetView();
266 if (view) view->ExecuteEvent(event, px, py);
267}
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: BesView.cxx:365

◆ GetCenter()

void BesPolygon2D::GetCenter ( Double_t *  Center) const
virtual

Definition at line 336 of file BesPolygon2D.cxx.

336 {
337 //
338 // Compute geometric center of this polygon
339 for ( Int_t i = 0; i < 3; i++ ) {
340 Center[i] = 0;
341 for ( Int_t j = 0; j < fN; j++ ) Center[i] += fP[3*j+i];
342 Center[i] /= fN;
343 }
344}

Referenced by Resize().

◆ GetObjectInfo()

char * BesPolygon2D::GetObjectInfo ( Int_t  px,
Int_t  py 
) const
virtual

Definition at line 293 of file BesPolygon2D.cxx.

293 {
294
295 BesView *view = (BesView*)gPad->GetView();
296 if (view) return view->GetObjectInfo(px, py);
297 else return TObject::GetObjectInfo(px, py);
298}
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition: BesView.cxx:800

Referenced by SetInfoBox().

◆ IsRotatable()

Bool_t BesPolygon2D::IsRotatable ( )
inline

Definition at line 60 of file BesPolygon2D.h.

60 {
61 return fRotatable;
62 }

Referenced by DistancetoPrimitive(), and Paint().

◆ Paint()

void BesPolygon2D::Paint ( Option_t *  option = "")
virtual

Definition at line 131 of file BesPolygon2D.cxx.

131 {
132 //
133 // BesPolygon2D paint function
134 TString opt = option;
135 opt.ToUpper();
136
137 // Transform to normalised desktop coordinates
138 BesView *view = (BesView*)gPad->GetView();
139 if (view == 0) cout << "no view found" << endl;
140 Double_t viewPhi = view->GetLongitude();
141 if (IsRotatable()) RotatePhi(viewPhi-180.0);
142
143 if (f_xx) {
144 delete [] f_xx;
145 f_xx = NULL;
146 }
147 if (f_yy) {
148 delete [] f_yy;
149 f_yy = NULL;
150 }
151
152 f_xx = new Double_t[fN+1];
153 f_yy = new Double_t[fN+1];
154 Double_t Pndc[3];
155
156 for ( Int_t i = 0; i < fN; i++ ) {
157 view->WCtoNDC(&fP[i*3], Pndc);
158 f_xx[i] = Pndc[0];
159 f_yy[i] = Pndc[1];
160 }
161
162 // Close surface
163 f_xx[fN] = f_xx[0];
164 f_yy[fN] = f_yy[0];
165
166 TAttLine::Modify(); //Change line attributes only if necessary
167 TAttFill::Modify(); //Change fill attributes only if necessary
168
169 gPad->PaintFillArea(fN, f_xx, f_yy);
170 gPad->PaintPolyLine(fN+1, f_xx, f_yy);
171 if (IsRotatable()) Restore();
172}
virtual void Restore()
virtual void RotatePhi(Double_t phi)
Double_t GetLongitude()
Definition: BesTView.h:95

Referenced by Emc2DCrystal::Paint(), Mdc2DWire::Paint(), Muc2DStrip::Paint(), and Tof2DScin::Paint().

◆ Resize()

void BesPolygon2D::Resize ( Double_t  ScaleFactor)
virtual

Definition at line 318 of file BesPolygon2D.cxx.

318 {
319 //
320 // Resize the polygon by ScaleFactor
321
322 // Compute geometric center of the polygon
323 Double_t C[3];
324 GetCenter(C);
325
326 // Rescale distances from the center
327 for ( Int_t i = 0; i < 3; i++ ) {
328 for ( Int_t j = 0; j < fN; j++ ) {
329 fP[3*j+i] = C[i] + ScaleFactor*(fP[3*j+i]-C[i]);
330 }
331 }
332}
***************************************************************************************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 GetCenter(Double_t *Center) const

◆ Restore()

void BesPolygon2D::Restore ( )
virtual

Definition at line 362 of file BesPolygon2D.cxx.

362 {
363
364 for (Int_t i = 0; i < fN*3; i++) {
365 fP[i] = fPBackUp[i];
366 }
367}

Referenced by Paint(), Emc2DCrystal::Paint(), and Tof2DScin::Paint().

◆ RotatePhi()

void BesPolygon2D::RotatePhi ( Double_t  phi)
virtual

Definition at line 348 of file BesPolygon2D.cxx.

348 {
349
350 //cout << "phi " << phi << endl;
351 for (Int_t i = 0; i < fN; i++) {
352 TVector3 vec(fP[i*3], fP[i*3+1], fP[i*3+2]);
353 Double_t r = vec.Pt();
354 Double_t newPhi = vec.Phi() + phi*TMath::DegToRad();
355 fP[i*3] = r * cos(newPhi);
356 fP[i*3+1] = r * sin(newPhi);
357 }
358}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
dble_vec_t vec[12]
Definition: ranlxd.c:372

Referenced by Paint().

◆ SetDrawOption()

void BesPolygon2D::SetDrawOption ( Option_t *  option)
inline

Definition at line 81 of file BesPolygon2D.h.

81 {
82 TObject::SetDrawOption(option);
83 }

◆ SetInfoBox()

void BesPolygon2D::SetInfoBox ( )
virtual

Definition at line 271 of file BesPolygon2D.cxx.

271 {
272 //
273 // Set tooltip textbox with some information
274 TView *view = (TView*)gPad->GetView();
275 Double_t Pndc[3];
276 view->WCtoNDC(&fP[0], Pndc);
277
278 if (fInfoBox){
279 delete fInfoBox;
280 fInfoBox = 0;
281 }
282 fInfoBox = new TPaveText(Pndc[0], Pndc[1],
283 Pndc[0]+0.4, Pndc[1]+0.1);
284 fInfoBox->SetBorderSize(1);
285 fInfoBox->SetFillColor(191);
286 fInfoBox->AddText(GetTitle());
287 fInfoBox->AddText(GetObjectInfo(0,0));
288 fInfoBox->Draw();
289}
virtual char * GetObjectInfo(Int_t px, Int_t py) const

◆ SetName()

void BesPolygon2D::SetName ( const char *  name)
inline

Definition at line 66 of file BesPolygon2D.h.

66 {
67 TNamed::SetName(name);
68 }

◆ SetPoints()

void BesPolygon2D::SetPoints ( Double_t *  P)
inline

Definition at line 84 of file BesPolygon2D.h.

84 {
85 for ( Int_t i = 0; i < fN*3; i++ ) fP[i] = P[i];
86 }

Referenced by BesPolygon2D().

◆ SetRotatable()

void BesPolygon2D::SetRotatable ( Bool_t  input)
inline

Definition at line 63 of file BesPolygon2D.h.

63 {
64 fRotatable = input;
65 }

Referenced by MdcROOTGeo::Draw(), MucROOTGeo::Draw(), and BesGeometry::InitGeometry().

◆ SetSize()

void BesPolygon2D::SetSize ( Double_t  size)
virtual

Definition at line 371 of file BesPolygon2D.cxx.

371 {
372
373 if (size > 0.95) size = 0.98; // too big could not see border
374 if (size < 0.15) size = 0.2; // too small could not be seen
375
376 for (Int_t i = 0; i < 3; i++) {
377 for (Int_t j = 0; j < fN; j++) {
378 fP[3*j+i] = size * fP[3*j+i] + (1.0-size) * fCenter[i];
379 }
380 }
381}

Referenced by Emc2DCrystal::Paint(), and Tof2DScin::Paint().

◆ SetTitle()

void BesPolygon2D::SetTitle ( const char *  name)
inline

Definition at line 69 of file BesPolygon2D.h.

69 {
70 TNamed::SetTitle(name);
71 }

◆ SetZRSign()

void BesPolygon2D::SetZRSign ( Int_t  sign)
virtual

Definition at line 302 of file BesPolygon2D.cxx.

302 {
303 //
304 // set sign of points for ZR view
305
306 for ( Int_t i = 0; i < fN; i++ ) {
307 // clear sign
308 fP[(i*3)+1] = TMath::Sign(1.,Double_t(fP[(i*3)+1])) * fP[(i*3)+1];
309
310 // set sign
311 fP[(i*3)+1] = TMath::Sign(1,sign) * fP[(i*3)+1];
312 }
313
314}

Member Data Documentation

◆ f_xx

Double_t* BesPolygon2D::f_xx
protected

Definition at line 31 of file BesPolygon2D.h.

Referenced by BesPolygon2D(), and Paint().

◆ f_yy

Double_t* BesPolygon2D::f_yy
protected

Definition at line 32 of file BesPolygon2D.h.

Referenced by BesPolygon2D(), and Paint().

◆ fCenter

Double_t BesPolygon2D::fCenter[3]
protected

Definition at line 36 of file BesPolygon2D.h.

Referenced by BesPolygon2D(), DistancetoPrimitive(), and SetSize().

◆ fInfoBox

TPaveText* BesPolygon2D::fInfoBox
protected

Definition at line 39 of file BesPolygon2D.h.

Referenced by BesPolygon2D(), and SetInfoBox().

◆ fN

Int_t BesPolygon2D::fN
protected

◆ fP

Double_t* BesPolygon2D::fP
protected

◆ fPBackUp

Double_t* BesPolygon2D::fPBackUp
protected

Definition at line 35 of file BesPolygon2D.h.

Referenced by BesPolygon2D(), Restore(), and ~BesPolygon2D().

◆ fRotatable

Bool_t BesPolygon2D::fRotatable
protected

Definition at line 37 of file BesPolygon2D.h.

Referenced by BesPolygon2D(), IsRotatable(), and SetRotatable().


The documentation for this class was generated from the following files: