CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Private Member Functions
TEveEllipsoidProjectedGL Class Reference

#include <TEveEllipsoidGL.h>

Inheritance diagram for TEveEllipsoidProjectedGL:
TEveEllipsoidGL

Public Member Functions

 ClassDefOverride (TEveEllipsoidProjectedGL, 0)
 
void DirectDraw (TGLRnrCtx &rnrCtx) const override
 
void SetBBox () override
 
Bool_t SetModel (TObject *obj, const Option_t *opt=nullptr) override
 
 TEveEllipsoidProjectedGL ()
 
 ~TEveEllipsoidProjectedGL () override
 
- Public Member Functions inherited from TEveEllipsoidGL
 ClassDefOverride (TEveEllipsoidGL, 0)
 
void DirectDraw (TGLRnrCtx &rnrCtx) const override
 
Bool_t IgnoreSizeForOfInterest () const override
 
void SetBBox () override
 
Bool_t SetModel (TObject *obj, const Option_t *opt=nullptr) override
 
 TEveEllipsoidGL ()
 
 ~TEveEllipsoidGL () override
 

Protected Attributes

TEveEllipsoidProjectedfM
 
- Protected Attributes inherited from TEveEllipsoidGL
TEveEllipsoidfE
 

Private Member Functions

void drawArch (float pStart, float pEnd, float phiStep, TEveVector &v0, TEveVector &v1, TEveVector &v2) const
 
void DrawRhoPhi () const
 
void DrawRhoZ () const
 
void drawRhoZAxis (TEveVector &v, TEveVector &) const
 
TEveEllipsoidProjectedGLoperator= (const TEveEllipsoidProjectedGL &)
 
 TEveEllipsoidProjectedGL (const TEveEllipsoidProjectedGL &)
 

Detailed Description

Definition at line 45 of file TEveEllipsoidGL.h.

Constructor & Destructor Documentation

TEveEllipsoidProjectedGL::TEveEllipsoidProjectedGL ( const TEveEllipsoidProjectedGL )
private
TEveEllipsoidProjectedGL::TEveEllipsoidProjectedGL ( )

Definition at line 118 of file TEveEllipsoidGL.cc.

118  :
119  fM(nullptr)
120 {
121  // Constructor.
122 
123  // fDLCache = kFALSE; // Disable display list.
124  fMultiColor = kTRUE;
125 }
TEveEllipsoidProjected * fM
TEveEllipsoidProjectedGL::~TEveEllipsoidProjectedGL ( )
inlineoverride

Member Function Documentation

TEveEllipsoidProjectedGL::ClassDefOverride ( TEveEllipsoidProjectedGL  ,
 
)
void TEveEllipsoidProjectedGL::DirectDraw ( TGLRnrCtx &  rnrCtx) const
override

Definition at line 146 of file TEveEllipsoidGL.cc.

References DrawRhoPhi(), DrawRhoZ(), and fM.

147 {
148  // Render with OpenGL.
149 
150  TEveProjection *proj = fM->GetManager()->GetProjection();
151 
152 
153  glPushAttrib(GL_ENABLE_BIT| GL_POLYGON_BIT | GL_LINE_BIT | GL_POINT_BIT);
154  glDisable(GL_LIGHTING);
155  glDisable(GL_CULL_FACE);
156 
157  glPushMatrix();
158  if ( proj->GetType() == TEveProjection::kPT_RPhi)
159  DrawRhoPhi();
160  else
161  DrawRhoZ();
162 
163  glPopMatrix();
164  glPopAttrib();
165 }
TEveEllipsoidProjected * fM
void TEveEllipsoidProjectedGL::drawArch ( float  pStart,
float  pEnd,
float  phiStep,
TEveVector &  v0,
TEveVector &  v1,
TEveVector &  v2 
) const
private

Definition at line 168 of file TEveEllipsoidGL.cc.

References funct::cos(), objects.autophobj::float, fM, phi, funct::sin(), and findQualityFiles::v.

Referenced by DrawRhoPhi(), and DrawRhoZ().

169 {
170  TEveProjection *proj = fM->GetManager()->GetProjection();
171  float phi = phiStart;
172  while (phi < phiEnd ) {
173  TEveVector v = v0 + v1*((float)cos(phi)) + v2*((float)sin(phi));
174  proj->ProjectVector(v, fM->fDepth);
175  glVertex3fv(v.Arr());
176 
177  phi += phiStep;
178  }
179  TEveVector v = v0 + v1*((float)cos(phiEnd)) + v2*((float)sin(phiEnd));
180  proj->ProjectVector(v, fM->fDepth);
181  glVertex3fv(v.Arr());
182 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TEveEllipsoidProjected * fM
void TEveEllipsoidProjectedGL::DrawRhoPhi ( ) const
private

Definition at line 185 of file TEveEllipsoidGL.cc.

References Abs(), drawArch(), TEveEllipsoidGL::fE, TEveEllipsoid::fEScale, fM, mps_fire::i, p1, p2, TEveEllipsoid::RefEMtx(), TEveEllipsoid::RefPos(), mathSSE::sqrt(), and TwoPi.

Referenced by DirectDraw().

186 {
187  // printf("TEveEllipsoidProjectedGL::DirectDraw [%s ]\n", fE->GetName() );
188 
189  TMatrixDSym xxx(3);
190  for(int i=0;i<2;i++)
191  for(int j=0;j<2;j++)
192  {
193  xxx(i,j) = fE->RefEMtx()(i+1,j+1);
194  }
195 
196  TMatrixDEigen eig(xxx);
197  TVectorD xxxEig ( eig.GetEigenValuesRe());
198 
199 
200  // Projection supports only floats :(
201  TEveVector v0(fE->RefPos()[0], fE->RefPos()[1], 0);
202  TEveVector v1(eig.GetEigenVectors()(0, 0) , eig.GetEigenVectors()(0, 1), 0 );
203  v1 *= fE->fEScale * sqrt(TMath::Abs(xxxEig[0]));
204  TEveVector v2(eig.GetEigenVectors()(1, 0) , eig.GetEigenVectors()(1, 1), 0 );
205  v2 *= fE->fEScale * sqrt(TMath::Abs(xxxEig[1]));
206 
207  TEveProjection *proj = fM->GetManager()->GetProjection();
208 
209  // fill
210  glBegin(GL_POLYGON);
211  drawArch(0, TMath::TwoPi(), TMath::TwoPi()/20, v0, v1, v2);
212  glEnd();
213 
214  // frame
215  TGLUtil::LineWidth(fE->fLineWidth);
216  TGLUtil::Color(fE->fLineColor);
217 
218  glBegin(GL_LINE_LOOP);
219  drawArch(0, TMath::TwoPi(), TMath::TwoPi()/20, v0, v1, v2);
220  glEnd();
221 
222  glBegin(GL_LINES);
223  {
224  // glColor3f(1, 0, 0);
225  TEveVector p1 = v0 - v1;
226  TEveVector p2 = v0 + v1;
227  proj->ProjectVector(p1, fM->fDepth);
228  proj->ProjectVector(p2, fM->fDepth);
229  glVertex3fv(p1.Arr());
230  glVertex3fv(p2.Arr());
231  }
232  {
233  // glColor3f(0, 1, 0);
234  TEveVector p1 = v0 - v2;
235  TEveVector p2 = v0 + v2;
236  proj->ProjectVector(p1, fM->fDepth);
237  proj->ProjectVector(p2, fM->fDepth);
238  glVertex3fv(p1.Arr());
239  glVertex3fv(p2.Arr());
240  }
241  glEnd();
242 
243 
244 
245 }
const double TwoPi
TEveVector & RefPos()
Definition: TEveEllipsoid.h:38
void drawArch(float pStart, float pEnd, float phiStep, TEveVector &v0, TEveVector &v1, TEveVector &v2) const
TEveEllipsoid * fE
T sqrt(T t)
Definition: SSEVec.h:18
TEveTrans & RefEMtx()
Definition: TEveEllipsoid.h:40
T Abs(T a)
Definition: MathUtil.h:49
double p2[4]
Definition: TauolaWrapper.h:90
TEveEllipsoidProjected * fM
double p1[4]
Definition: TauolaWrapper.h:89
void TEveEllipsoidProjectedGL::DrawRhoZ ( ) const
private

Definition at line 248 of file TEveEllipsoidGL.cc.

References Abs(), funct::cos(), pyrootRender::da, TtSemiLepEvtBuilder_cfi::disc, drawArch(), drawRhoZAxis(), MillePedeFileConverter_cfg::e, TEveEllipsoidGL::fE, TEveEllipsoid::fEScale, objects.autophobj::float, fM, mps_fire::i, Max(), Min(), N, AlignmentTrackSelector_cfi::phiMax, AlignmentTrackSelector_cfi::phiMin, TEveEllipsoid::RefEMtx(), TEveEllipsoid::RefPos(), funct::sin(), mathSSE::sqrt(), and TwoPi.

Referenced by DirectDraw().

249 {
250  // printf("TEveEllipsoidProjectedGL::DirectDraw [%s ]\n", fE->GetTitle() );
251 
252  TEveVector v0(fE->RefPos()[0], fE->RefPos()[1], fE->RefPos()[2]);
253 
254  TMatrixDSym xxx(3);
255  xxx(0, 0) = 1;
256  for(int i=1;i<3;i++)
257  for(int j=1;j<3;j++)
258  {
259  xxx(i,j) = fE->RefEMtx()(i+1,j+1);
260  }
261  TMatrixDEigen eig(xxx);
262  TVectorD xxxEig ( eig.GetEigenValuesRe());
263 
264 
265  TEveVector v1(0, eig.GetEigenVectors()(1, 2), eig.GetEigenVectors()(2, 2));
266  v1 *= fE->fEScale * sqrt(TMath::Abs(xxxEig[2]));
267 
268  TEveVector v2(0, eig.GetEigenVectors()(1, 1), eig.GetEigenVectors()(2, 1));
269  v2 *= fE->fEScale * sqrt(TMath::Abs(xxxEig[1]));
270  if (v1[1]*v2[2] > v1[2]*v2[1])
271  v2 *= -1;
272 
273 
274  TEveProjection *proj = fM->GetManager()->GetProjection();
275 
276  // ellipse intersection with projection center
277  bool splitted = false;
278  int N = 20;
279  double phiStep = TMath::TwoPi()/N;
280 
281  // projection center can be moved in beam-spot
282  float bs = 0;
283  if (proj->GetDisplaceOrigin())
284  bs = proj->RefCenter()[1];
285 
286  float da = v2[1]*v2[1] + v1[1]*v1[1];
287  float db = 2 * v1[1] * (v0[1]-bs);
288  float dc = (v0[1]-bs)*(v0[1]-bs) - v2[1]*v2[1];
289  float disc = (db*db -4*da*dc);
290 
291  if ( disc > 0) {
292  disc = sqrt(disc);
293  float cosS1 = ( -db + disc)/(2 * da);
294  float cosS2 = ( -db - disc)/(2 * da);
295  if (TMath::Abs(cosS1) < 1) {
296  splitted = true;
297  // printf("splitted \n");
298 
299  double phi1 = acos(cosS1);
300  double phi2 = acos(cosS2);
301  TEveVector ps1 = v0 + v1*((float)cos(phi1)) + v2*((float)sin(phi1));
302  TEveVector ps2 = v0 + v1*((float)cos(phi2)) + v2*((float)sin(phi2));
303 
304 
305 
306  // acos has values [0, Pi] , check the symetry over x axis (mirroring)
307  if (TMath::Abs(ps1[1] - bs) > 1e-5)
308  phi1 = TMath::TwoPi() -phi1;
309 
310  if (TMath::Abs(ps2[1] - bs) > 1e-5)
311  phi2 = TMath::TwoPi() -phi2;
312 
313  int N = 20;
314  double phiStep = TMath::TwoPi()/N;
315  double phiOffset = phiStep*0.1;
316  double phiMin = TMath::Min(phi1, phi2);
317  double phiMax = TMath::Max(phi1, phi2);
318  // printf(" %f %f \n",phi1*TMath::RadToDeg(), phi2*TMath::RadToDeg() );
319 
320  // fill
321  // upper clothing
322  glBegin(GL_POLYGON);
323  drawArch(phiMin + phiOffset, phiMax - phiOffset, phiStep, v0, v1, v2);
324  glEnd();
325  // bottom clothing
326  glBegin(GL_POLYGON);
327  drawArch(phiMax + phiOffset, phiMax + TMath::TwoPi() - (phiMax -phiMin) - phiOffset, phiStep, v0, v1, v2);
328  glEnd();
329 
330  // frame
331  TGLUtil::LineWidth(fE->fLineWidth);
332  TGLUtil::Color(fE->fLineColor);
333  // upper clothing
334  glBegin(GL_LINE_LOOP);
335  drawArch(phiMin + phiOffset, phiMax - phiOffset, phiStep, v0, v1, v2);
336  glEnd();
337  // bottom clothing
338  glBegin(GL_LINE_LOOP);
339  drawArch(phiMax + phiOffset, phiMax + TMath::TwoPi() - (phiMax -phiMin) - phiOffset, phiStep, v0, v1, v2);
340  glEnd();
341 
342  }
343  }
344 
345 
346  if (!splitted) {
347  glBegin(GL_POLYGON);
348  drawArch(0, TMath::TwoPi(), phiStep, v0, v1, v2);
349  glEnd();
350  TGLUtil::LineWidth(fE->fLineWidth);
351  TGLUtil::Color(fE->fLineColor);
352  glBegin(GL_LINE_LOOP);
353  drawArch(0, TMath::TwoPi(), phiStep, v0, v1, v2);
354  glEnd();
355  }
356 
357  drawRhoZAxis(v0, v2);
358  drawRhoZAxis(v0, v1);
359 }
const double TwoPi
TEveVector & RefPos()
Definition: TEveEllipsoid.h:38
void drawArch(float pStart, float pEnd, float phiStep, TEveVector &v0, TEveVector &v1, TEveVector &v2) const
TEveEllipsoid * fE
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T Min(T a, T b)
Definition: MathUtil.h:39
void drawRhoZAxis(TEveVector &v, TEveVector &) const
T sqrt(T t)
Definition: SSEVec.h:18
TEveTrans & RefEMtx()
Definition: TEveEllipsoid.h:40
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T Abs(T a)
Definition: MathUtil.h:49
T Max(T a, T b)
Definition: MathUtil.h:44
#define N
Definition: blowfish.cc:9
TEveEllipsoidProjected * fM
void TEveEllipsoidProjectedGL::drawRhoZAxis ( TEveVector &  v,
TEveVector &  v2 
) const
private

Definition at line 362 of file TEveEllipsoidGL.cc.

References Abs(), objects.autophobj::float, and fM.

Referenced by DrawRhoZ().

363 {
364  glBegin(GL_LINES);
365  TEveProjection* proj = fM->GetManager()->GetProjection();
366 
367  float bs = 0;
368  if (proj->GetDisplaceOrigin())
369  bs = proj->RefCenter()[1];
370 
371  float off = (v2[1] > v0[1] ) ? 0.01 : -0.01;
372  TEveVector alu = v0 + v2;
373  proj->ProjectVector(alu, fM->fDepth);
374  glVertex3fv(alu.Arr());
375 
376  if (TMath::Abs(v0[1]/v2[1]) < 1 )
377  {
378  alu = v0 - ((float) ((1-off) *(v0[1]-bs)/v2[1])) * v2;
379  proj->ProjectVector(alu, fM->fDepth);
380  glVertex3fv(alu.Arr());
381 
382  //============================
383 
384  alu = v0 - ((float) ((1+off) * (v0[1]-bs)/v2[1])) * v2;
385  proj->ProjectVector(alu, fM->fDepth);
386  glVertex3fv(alu.Arr());
387  }
388 
389  alu = v0 - v2;
390  proj->ProjectVector(alu, fM->fDepth);
391  glVertex3fv(alu.Arr());
392 
393  glEnd();
394 }
T Abs(T a)
Definition: MathUtil.h:49
TEveEllipsoidProjected * fM
TEveEllipsoidProjectedGL& TEveEllipsoidProjectedGL::operator= ( const TEveEllipsoidProjectedGL )
private
void TEveEllipsoidProjectedGL::SetBBox ( )
override

Definition at line 138 of file TEveEllipsoidGL.cc.

139 {
140  // Set bounding box.
141 
142  SetAxisAlignedBBox(((TEveEllipsoidProjected*)fExternalObj)->AssertBBox());
143 }
Bool_t TEveEllipsoidProjectedGL::SetModel ( TObject *  obj,
const Option_t *  opt = nullptr 
)
override

Definition at line 128 of file TEveEllipsoidGL.cc.

References TEveEllipsoidGL::fE, fM, and GetRecoTauVFromDQM_MC_cff::obj.

129 {
130  // Set model object.
131 
132  fM = SetModelDynCast<TEveEllipsoidProjected>(obj);
133  fE = dynamic_cast<TEveEllipsoid*>(fM->GetProjectable());
134  return fE != nullptr;
135 }
TEveEllipsoid * fE
TEveEllipsoidProjected * fM

Member Data Documentation

TEveEllipsoidProjected* TEveEllipsoidProjectedGL::fM
protected

Definition at line 57 of file TEveEllipsoidGL.h.

Referenced by DirectDraw(), drawArch(), DrawRhoPhi(), DrawRhoZ(), drawRhoZAxis(), and SetModel().