Logo ROOT   6.08/07
Reference Guide
TEveJetCone.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel, Jochen Thaeder 2009
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TEveJetCone.h"
13 #include "TEveTrans.h"
14 #include "TEveProjectionManager.h"
15 
16 #include "TMath.h"
17 
18 /** \class TEveJetCone
19 \ingroup TEve
20 Draws a jet cone with leading particle is specified in (eta,phi) and
21 cone radius is given.
22 
23 If Apex is not set, default is (0.,0.,0.)
24 In case of cylinder was set, cone is cut at the cylinder edges.
25 
26 Example :
27 ~~~ {.cpp}
28  Float_t coneEta = r.Uniform(-0.9, 0.9);
29  Float_t conePhi = r.Uniform(0.0, TwoPi() );
30  Float_t coneRadius = 0.4;
31 
32  TEveJetCone* jetCone = new TEveJetCone("JetCone");
33  jetCone->SetCylinder(250, 250);
34  if (jetCone->AddCone(coneEta, conePhi, coneRadius) != -1)
35  gEve->AddElement(jetCone);
36 ~~~
37 
38 #### Implementation notes
39 
40 TEveVector fLimits encodes the following information:
41  - fY, fZ: barrel radius and endcap z-position;
42  if both are 0, fX encodes the spherical radius
43  - fX : scaling for length of the cone
44 */
45 
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 /// Constructor.
50 
52  TEveShape(n, t),
53  fApex(),
54  fLimits(), fThetaC(10),
55  fEta(0), fPhi(0), fDEta(0), fDPhi(0), fNDiv(72)
56 {
57  fColor = kGreen;
58 }
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// Compute bounding-box of the data.
62 
64 {
65  BBoxInit();
71 }
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// Virtual from TEveProjectable, returns TEveJetConeProjected class.
75 
77 {
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Add jet cone.
83 /// parameters are :
84 /// - (eta,phi) : of the center/leading particle
85 /// - cone_r : cone radius in eta-phi space
86 /// - length : length of the cone
87 /// - if cylinder is set and length is adapted to cylinder.
88 /// - if length is given, it will be used as scalar factor
89 /// - if cylinder is not set, length is used as length of the cone
90 /// Return 0 on success.
91 
93 {
94  return AddEllipticCone(eta, phi, cone_r, cone_r, length);
95 }
96 
97 ////////////////////////////////////////////////////////////////////////////////
98 /// Add jet cone.
99 /// parameters are :
100 /// - (eta,phi) : of the center/leading particle
101 /// - (reta, rphi) : radius of cone in eta-phi space
102 /// - length : length of the cone
103 /// - if cylinder is set and length is adapted to cylinder.
104 /// - if length is given, it will be used as scalar factor
105 /// - if cylinder is not set, length is used as length of the cone
106 /// Returns 0 on success.
107 
109 {
110  using namespace TMath;
111 
112  if (length != 0) fLimits.fX = length;
113 
114  if (fLimits.IsZero())
115  return -1;
116 
117  fEta = eta; fPhi = phi; fDEta = reta; fDPhi = rphi;
118 
119  return 0;
120 }
121 
122 ////////////////////////////////////////////////////////////////////////////////
123 /// Fill TEveVector with eta and phi, magnitude 1.
124 
126 {
127  using namespace TMath;
128 
129  return TEveVector(Cos(phi) / CosH(eta), Sin(phi) / CosH(eta), TanH(eta));
130 }
131 
132 ////////////////////////////////////////////////////////////////////////////////
133 /// Returns point on the base of the cone with given eta and phi.
134 
136 {
137  using namespace TMath;
138 
139  TEveVector vec = CalcEtaPhiVec(eta, phi);
140 
141  // -- Set length of the contourPoint
142  if (fLimits.fY != 0 && fLimits.fZ != 0)
143  {
144  Float_t theta = vec.Theta();
145  if (theta < fThetaC)
146  vec *= fLimits.fZ / Cos(theta);
147  else if (theta > Pi() - fThetaC)
148  vec *= fLimits.fZ / Cos(theta - Pi());
149  else
150  vec *= fLimits.fY / Sin(theta);
151 
152  if (fLimits.fX != 0) vec *= fLimits.fX;
153  }
154  else
155  {
156  vec *= fLimits.fX;
157  }
158 
159  return vec;
160 }
161 
162 ////////////////////////////////////////////////////////////////////////////////
163 /// Returns point on the base of the cone with internal angle alpha:
164 /// alpha = 0 -> max eta, alpha = pi/2 -> max phi, ...
165 
167 {
168  using namespace TMath;
169 
170  return CalcBaseVec(fEta + fDEta * Cos(alpha), fPhi + fDPhi * Sin(alpha));
171 }
172 
173 ////////////////////////////////////////////////////////////////////////////////
174 /// Returns true if the cone is in barrel / endcap transition region.
175 
177 {
178  using namespace TMath;
179 
180  Float_t tm = CalcBaseVec(0).Theta();
181  Float_t tM = CalcBaseVec(Pi()).Theta();
182 
183  return (tM > fThetaC && tm < fThetaC) ||
184  (tM > Pi() - fThetaC && tm < Pi() - fThetaC);
185 }
186 
187 /** \class TEveJetConeProjected
188 \ingroup TEve
189 Projection of TEveJetCone.
190 */
191 
192 ////////////////////////////////////////////////////////////////////////////////
193 /// Constructor.
194 
195 TEveJetConeProjected::TEveJetConeProjected(const char* n, const char* t) :
196  TEveShape(n, t)
197 {
198 }
199 
200 ////////////////////////////////////////////////////////////////////////////////
201 /// Destructor.
202 
204 {
205 }
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 /// Compute bounding-box, virtual from TAttBBox.
209 
211 {
212  BBoxInit();
213 
214  TEveJetCone *cone = dynamic_cast<TEveJetCone*>(fProjectable);
215 ////////////////////////////////////////////////////////////////////////////////
216 
218  TEveVector v;
219  v = cone->fApex; proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
220  v = cone->CalcBaseVec(0); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
221  v = cone->CalcBaseVec(TMath::PiOver2()); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
222  v = cone->CalcBaseVec(TMath::Pi()); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
223  v = cone->CalcBaseVec(TMath::Pi() + TMath::PiOver2()); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
224 }
225 
226 ////////////////////////////////////////////////////////////////////////////////
227 /// This is virtual method from base-class TEveProjected.
228 
230 {
231  SetDepthCommon(d, this, fBBox);
232 }
233 
234 ////////////////////////////////////////////////////////////////////////////////
235 /// This is virtual method from base-class TEveProjected.
236 
238 {
239  TEveProjected::SetProjection(mng, model);
240  CopyVizParams(dynamic_cast<TEveElement*>(model));
241 }
242 
243 ////////////////////////////////////////////////////////////////////////////////
244 /// Re-project the jet-cone.
245 
247 {
248 }
Abstract base-class for 2D/3D shapes.
Definition: TEveShape.h:22
virtual void ComputeBBox()
Compute bounding-box of the data.
Definition: TEveJetCone.cxx:63
TT Theta() const
Definition: TEveVector.h:106
Double_t TanH(Double_t)
Definition: TMath.h:436
float Float_t
Definition: RtypesCore.h:53
TEveVector fApex
Definition: TEveJetCone.h:34
TEveVector CalcBaseVec(Float_t eta, Float_t phi) const
Returns point on the base of the cone with given eta and phi.
Draws a jet cone with leading particle is specified in (eta,phi) and cone radius is given...
Definition: TEveJetCone.h:23
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
Sets projection manager and reference in the projectable object.
Bool_t IsZero() const
Definition: TEveVector.h:88
Definition: Rtypes.h:61
const char * Class
Definition: TXMLSetup.cxx:64
virtual TClass * ProjectedClass(const TEveProjection *p) const
Virtual from TEveProjectable, returns TEveJetConeProjected class.
Definition: TEveJetCone.cxx:76
Float_t * fBBox
Definition: TAttBBox.h:22
Int_t AddEllipticCone(Float_t eta, Float_t phi, Float_t reta, Float_t rphi, Float_t length=0)
Add jet cone.
virtual void SetDepthLocal(Float_t d)
This is virtual method from base-class TEveProjected.
void BBoxCheckPoint(Float_t x, Float_t y, Float_t z)
Definition: TAttBBox.h:60
TEveJetCone(const TEveJetCone &)
TEveProjectionManager * GetManager() const
void ProjectVector(TEveVector &v, Float_t d)
Project TEveVector.
Base-class for non-linear projections.
Float_t fPhi
Definition: TEveJetCone.h:38
Bool_t IsInTransitionRegion() const
Returns true if the cone is in barrel / endcap transition region.
Manager class for steering of projections and managing projected objects.
Int_t AddCone(Float_t eta, Float_t phi, Float_t cone_r, Float_t length=0)
Add jet cone.
Definition: TEveJetCone.cxx:92
Abstract base-class for non-linear projectable objects.
SVector< double, 2 > v
Definition: Dict.h:5
double Pi()
Mathematical constants.
Definition: Math.h:68
TEveJetConeProjected(const TEveJetConeProjected &)
TEveProjectable * fProjectable
Float_t fThetaC
Definition: TEveJetCone.h:37
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
Double_t Cos(Double_t)
Definition: TMath.h:424
Double_t Pi()
Definition: TMath.h:44
TEveProjection * GetProjection()
virtual void ComputeBBox()
Compute bounding-box, virtual from TAttBBox.
#define ClassImp(name)
Definition: Rtypes.h:279
virtual void CopyVizParams(const TEveElement *el)
Copy visualization parameters from element el.
Definition: TEveShape.cxx:70
TEveVector CalcEtaPhiVec(Float_t eta, Float_t phi) const
Fill TEveVector with eta and phi, magnitude 1.
TEveVectorT< Float_t > TEveVector
Definition: TEveVector.h:93
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
This is virtual method from base-class TEveProjected.
TEveVector fLimits
Definition: TEveJetCone.h:36
Double_t PiOver2()
Definition: TMath.h:46
void SetDepthCommon(Float_t d, TEveElement *el, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
Double_t Sin(Double_t)
Definition: TMath.h:421
virtual void UpdateProjection()
Re-project the jet-cone.
Float_t fDPhi
Definition: TEveJetCone.h:39
char Text_t
Definition: RtypesCore.h:58
virtual ~TEveJetConeProjected()
Destructor.
Float_t fDEta
Definition: TEveJetCone.h:39
Float_t fEta
Definition: TEveJetCone.h:38
const Int_t n
Definition: legend1.C:16
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
Definition: TAttBBox.cxx:29
Double_t CosH(Double_t)
Definition: TMath.h:433