CGEM BOSS 6.6.5.g
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 //Long Peixun's update: Update fInnerRadius and fOuterRadius initialization for single variables
55 fInnerRadius = innerRadius;
56 fOuterRadius = outerRadius;
57 fNSegment = 40;
58 f_innerCircleX = NULL;
59 f_innerCircleY = NULL;
60 f_outerCircleX = NULL;
61 f_outerCircleY = NULL;
62 f_areaX = NULL;
63 f_areaY = NULL;
64}

◆ ~BesCircle2D()

BesCircle2D::~BesCircle2D ( )
virtual

Definition at line 68 of file BesCircle2D.cxx.

68 {
69 //
70 // BesCircle2D default destructor
71 if ( gDebug ) cout << "BesCircle2D default dtor called" << endl;
72
73 delete[] fCenter; //Long Peixun's update: delete -> delete[]
74}

Member Function Documentation

◆ DistancetoPrimitive()

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

Definition at line 78 of file BesCircle2D.cxx.

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

Referenced by Mdc2DWire::DistancetoPrimitive().

◆ Draw()

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

Definition at line 135 of file BesCircle2D.cxx.

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

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

◆ ExecuteEvent()

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

Definition at line 126 of file BesCircle2D.cxx.

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

◆ 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 = dynamic_cast<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:965

◆ Paint()

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

Definition at line 146 of file BesCircle2D.cxx.

146 {
147 // BesCircle2D paint function
148 TString opt = option;
149 opt.ToUpper();
150
151 // Transform to normalised desktop coordinates
152 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
153 if (view == 0) cout << "no view found" << endl;
154
155 // Draw Painted area between circles as PaintFilledArea
156 Int_t np = fNSegment; //40;
157
158 if (f_innerCircleX){
159 delete [] f_innerCircleX;
160 f_innerCircleX = NULL;
161 }
162 if (f_innerCircleY){
163 delete [] f_innerCircleY;
164 f_innerCircleY = NULL;
165 }
166 if (f_outerCircleX){
167 delete [] f_outerCircleX;
168 f_outerCircleX = NULL;
169 }
170 if (f_outerCircleY){
171 delete [] f_outerCircleY;
172 f_outerCircleY = NULL;
173 }
174 if (f_areaX) {
175 delete [] f_areaX;
176 f_areaX = NULL;
177 }
178 if (f_areaY) {
179 delete [] f_areaY;
180 f_areaY = NULL;
181 }
182
183 f_innerCircleX = new Double_t[np+1];
184 f_innerCircleY = new Double_t[np+1];
185 f_outerCircleX = new Double_t[np+1];
186 f_outerCircleY = new Double_t[np+1];
187 f_areaX = new Double_t[4*np];
188 f_areaY = new Double_t[4*np];
189
190 TAttLine::Modify(); //Change line attributes only if necessary
191 TAttFill::Modify(); //Change fill attributes only if necessary
192
193 Double_t angle;
194 Double_t dphi = 2*TMath::Pi()/(np);
195 Double_t pointWC[3],pointNDC[3];
196
197 for (Int_t i=0; i< np ; i++) {
198 angle = Double_t(i)*dphi;
199
200 // inner circle
201 //Long Peixun's update: fInnerRadius has been changed to single variable
202 pointWC[0] = fCenter[0] + fInnerRadius * TMath::Cos(angle);
203 pointWC[1] = fCenter[1] + fInnerRadius * TMath::Sin(angle);
204 pointWC[2] = fCenter[2];
205 view->WCtoNDC(pointWC,pointNDC);
206 f_innerCircleX[i] = pointNDC[0];
207 f_innerCircleY[i] = pointNDC[1];
208 f_areaX[4*i] = pointNDC[0];
209 f_areaY[4*i] = pointNDC[1];
210 if ( i == 0 ) {
211 f_areaX[4*np - 3] = pointNDC[0];
212 f_areaY[4*np - 3] = pointNDC[1];
213 } else {
214 f_areaX[4*i - 3] = pointNDC[0];
215 f_areaY[4*i - 3] = pointNDC[1];
216 }
217
218 // outer circle
219 //Long Peixun's update: fOuterRadius has been changed to single variable
220 pointWC[0] = fCenter[0] + fOuterRadius * TMath::Cos(angle);
221 pointWC[1] = fCenter[1] + fOuterRadius * 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:824

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 53 of file BesCircle2D.h.

53 {
54 fNSegment = np;
55 }

Referenced by MdcROOTGeo::Init2DGeometry(), and CgemROOTGeo::InitGeometry().


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