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

#include <BesCircle2D.h>

+ Inheritance diagram for BesCircle2D:

Public Member Functions

 BesCircle2D ()
 
 BesCircle2D (const char *name, const char *title, Double_t innerRadius, Double_t outerRadius, Double_t *center)
 
virtual ~BesCircle2D ()
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 
virtual void Draw (Option_t *option="")
 
virtual void Paint (Option_t *option="")
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 
virtual void SetCenter (Double_t x, Double_t y, Double_t z)
 
virtual void GetCenter (Double_t *center)
 
virtual void SetNSegment (Int_t np)
 

Detailed Description

Definition at line 25 of file BesCircle2D.h.

Constructor & Destructor Documentation

◆ BesCircle2D() [1/2]

BesCircle2D::BesCircle2D ( )

◆ BesCircle2D() [2/2]

BesCircle2D::BesCircle2D ( const char *  name,
const char *  title,
Double_t  innerRadius,
Double_t  outerRadius,
Double_t *  center 
)

Definition at line 46 of file BesCircle2D.cxx.

46 :
47 TNamed(name, title), TAttLine(), TAttFill() {
48 //
49 // BesCircle2D normal constructor
50 if ( gDebug ) cout << "BesCircle2D normal ctor called" << endl;
51
52 fCenter = new Double_t[3];
53 for ( Int_t i = 0; i < 3; i++ ) fCenter[i] = center[i];
54 fInnerRadius = new Double_t[3];
55 fOuterRadius = new Double_t[3];
56 fInnerRadius[0]=innerRadius;
57 fOuterRadius[0]=outerRadius;
58 fNSegment = 40;
59 f_innerCircleX = NULL;
60 f_innerCircleY = NULL;
61 f_outerCircleX = NULL;
62 f_outerCircleY = NULL;
63 f_areaX = NULL;
64 f_areaY = NULL;
65}

◆ ~BesCircle2D()

BesCircle2D::~BesCircle2D ( )
virtual

Definition at line 69 of file BesCircle2D.cxx.

69 {
70 //
71 // BesCircle2D default destructor
72 if ( gDebug ) cout << "BesCircle2D default dtor called" << endl;
73
74 delete fCenter;
75 delete fInnerRadius;
76 delete fOuterRadius;
77}

Member Function Documentation

◆ DistancetoPrimitive()

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

Definition at line 81 of file BesCircle2D.cxx.

81 {
82
83 const Int_t inaxis = 7;
84 Int_t dist = 9999;
85
86 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
87 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
88 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
89 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
90
91 // return if point is not in the user area
92 if (px < puxmin - inaxis) return dist;
93 if (py > puymin + inaxis) return dist;
94 if (px > puxmax + inaxis) return dist;
95 if (py < puymax - inaxis) return dist;
96
97 BesView *view = (BesView*)gPad->GetView();
98 if (!view) return dist;
99
100 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
101 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
102 Double_t xndc[3];
103 //if (view->GetViewType() & kXYView)
104 xndc[0] = x;
105 xndc[1] = y;
106 xndc[2] = 0;
107 //cout << "NDC X:" << xndc[0] << " Y:" << xndc[1] << endl;
108
109 Double_t xwc[3];
110 view->NDCtoWC(xndc, xwc);
111 //cout << "WC X:" << xwc[0] << " Y:" << xwc[1] << endl;
112 //cout << "Center X:" << fCenter[0] << " Y:" << fCenter[1] << endl;
113
114 Double_t distw = 0.0;
115 for (Int_t i = 0; i < 2; i++) {
116 distw += (xwc[i]-fCenter[i]) * (xwc[i]-fCenter[i]);
117 }
118
119 if (distw >= fInnerRadius[0]*fInnerRadius[0] &&
120 distw <= fOuterRadius[0]*fOuterRadius[0])
121 return 0;
122 else
123 return dist;
124}
Double_t x[10]
virtual void NDCtoWC(const Float_t *pn, Float_t *pw)
Definition: BesView.cxx:725

Referenced by Mdc2DWire::DistancetoPrimitive().

◆ Draw()

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

Definition at line 137 of file BesCircle2D.cxx.

137 {
138 //
139 // BesCircle2D draw function
140 TString opt = option;
141 opt.ToUpper();
142
143 AppendPad(option);
144}

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

◆ ExecuteEvent()

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

Definition at line 128 of file BesCircle2D.cxx.

128 {
129 //cout << "I am in " << GetName() << endl;
130
131 BesView *view = (BesView*)gPad->GetView();
132 if (view) view->ExecuteEvent(event, px, py);
133}
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: BesView.cxx:365

◆ GetCenter()

void BesCircle2D::GetCenter ( Double_t *  center)
virtual

Definition at line 275 of file BesCircle2D.cxx.

276{
277 for (Int_t i = 0; i < 3; i++) center[i] = fCenter[i];
278}

Referenced by Mdc2DWire::Paint().

◆ GetObjectInfo()

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

Definition at line 257 of file BesCircle2D.cxx.

257 {
258
259 BesView *view = (BesView*)gPad->GetView();
260 if (view) return view->GetObjectInfo(px, py);
261 else return TObject::GetObjectInfo(px, py);
262}
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition: BesView.cxx:800

◆ Paint()

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

Definition at line 148 of file BesCircle2D.cxx.

148 {
149 // BesCircle2D paint function
150 TString opt = option;
151 opt.ToUpper();
152
153 // Transform to normalised desktop coordinates
154 BesView *view = (BesView*)gPad->GetView();
155 if (view == 0) cout << "no view found" << endl;
156
157 // Draw Painted area between circles as PaintFilledArea
158 Int_t np = fNSegment; //40;
159
160 if (f_innerCircleX){
161 delete [] f_innerCircleX;
162 f_innerCircleX = NULL;
163 }
164 if (f_innerCircleY){
165 delete [] f_innerCircleY;
166 f_innerCircleY = NULL;
167 }
168 if (f_outerCircleX){
169 delete [] f_outerCircleX;
170 f_outerCircleX = NULL;
171 }
172 if (f_outerCircleY){
173 delete [] f_outerCircleY;
174 f_outerCircleY = NULL;
175 }
176 if (f_areaX) {
177 delete [] f_areaX;
178 f_areaX = NULL;
179 }
180 if (f_areaY) {
181 delete [] f_areaY;
182 f_areaY = NULL;
183 }
184
185 f_innerCircleX = new Double_t[np+1];
186 f_innerCircleY = new Double_t[np+1];
187 f_outerCircleX = new Double_t[np+1];
188 f_outerCircleY = new Double_t[np+1];
189 f_areaX = new Double_t[4*np];
190 f_areaY = new Double_t[4*np];
191
192 TAttLine::Modify(); //Change line attributes only if necessary
193 TAttFill::Modify(); //Change fill attributes only if necessary
194
195 Double_t angle;
196 Double_t dphi = 2*TMath::Pi()/(np);
197 Double_t pointWC[3],pointNDC[3];
198
199 for (Int_t i=0; i< np ; i++) {
200 angle = Double_t(i)*dphi;
201
202 // inner circle
203 pointWC[0] = fCenter[0] + fInnerRadius[0]*TMath::Cos(angle);
204 pointWC[1] = fCenter[1] + fInnerRadius[0]*TMath::Sin(angle);
205 pointWC[2] = fCenter[2];
206 view->WCtoNDC(pointWC,pointNDC);
207 f_innerCircleX[i] = pointNDC[0];
208 f_innerCircleY[i] = pointNDC[1];
209 f_areaX[4*i] = pointNDC[0];
210 f_areaY[4*i] = pointNDC[1];
211 if ( i == 0 ) {
212 f_areaX[4*np - 3] = pointNDC[0];
213 f_areaY[4*np - 3] = pointNDC[1];
214 } else {
215 f_areaX[4*i - 3] = pointNDC[0];
216 f_areaY[4*i - 3] = pointNDC[1];
217 }
218
219 // outer circle
220 pointWC[0] = fCenter[0] + fOuterRadius[0]*TMath::Cos(angle);
221 pointWC[1] = fCenter[1] + fOuterRadius[0]*TMath::Sin(angle);
222 pointWC[2] = fCenter[2];
223 view->WCtoNDC(pointWC,pointNDC);
224 f_outerCircleX[i] = pointNDC[0];
225 f_outerCircleY[i] = pointNDC[1];
226 f_areaX[4*i + 3] = pointNDC[0];
227 f_areaY[4*i + 3] = pointNDC[1];
228 if ( i == 0 ) {
229 f_areaX[4*np - 2] = pointNDC[0];
230 f_areaY[4*np - 2] = pointNDC[1];
231 } else {
232 f_areaX[4*i - 2] = pointNDC[0];
233 f_areaY[4*i - 2] = pointNDC[1];
234 }
235
236 }
237
238 // last point for circles
239 f_innerCircleX[np] = f_innerCircleX[0];
240 f_innerCircleY[np] = f_innerCircleY[0];
241 f_outerCircleX[np] = f_outerCircleX[0];
242 f_outerCircleY[np] = f_outerCircleY[0];
243
244 // paint filled areas
245 for (Int_t i = 0; i < np; i++ ) {
246 gPad->PaintFillArea(4,&f_areaX[4*i],&f_areaY[4*i]);
247 }
248
249 // paint circles
250 // yzhang
251 gPad->PaintPolyLine(np+1,f_innerCircleX,f_innerCircleY);
252 gPad->PaintPolyLine(np+1,f_outerCircleX,f_outerCircleY);
253
254}
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)
Definition: BesView.cxx:659

Referenced by Mdc2DWire::Paint().

◆ SetCenter()

void BesCircle2D::SetCenter ( Double_t  x,
Double_t  y,
Double_t  z 
)
virtual

Definition at line 266 of file BesCircle2D.cxx.

267{
268 fCenter[0] = x;
269 fCenter[1] = y;
270 fCenter[2] = z;
271}

◆ SetNSegment()

virtual void BesCircle2D::SetNSegment ( Int_t  np)
inlinevirtual

Definition at line 52 of file BesCircle2D.h.

52 {
53 fNSegment = np;
54 }

Referenced by MdcROOTGeo::Init2DGeometry().


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