Logo ROOT   6.10/09
Reference Guide
TEveProjections.h
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 #ifndef ROOT_TEveProjections
13 #define ROOT_TEveProjections
14 
15 #include "TEveVector.h"
16 #include "TString.h"
17 
18 #include <vector>
19 
20 class TEveTrans;
21 
22 //==============================================================================
23 // TEveProjection
24 //==============================================================================
25 
27 {
28 public:
29  enum EPType_e { kPT_Unknown, kPT_RPhi, kPT_RhoZ, kPT_3D, kPT_End }; // projection type
30  enum EPProc_e { kPP_Plane, kPP_Distort, kPP_Full }; // projection procedure
31  enum EGeoMode_e { kGM_Unknown, kGM_Polygons, kGM_Segments }; // strategy for geometry projections
32 
34  {
38 
40  fMin(0), fMax(0), fOffset(0), fScale(1) {}
41  PreScaleEntry_t(Float_t min, Float_t max, Float_t off, Float_t scale) :
42  fMin(min), fMax(max), fOffset(off), fScale(scale) {}
43 
44  virtual ~PreScaleEntry_t() {}
45 
47  };
48 
49  typedef std::vector<PreScaleEntry_t> vPreScale_t;
50  typedef std::vector<PreScaleEntry_t>::iterator vPreScale_i;
51 
52 protected:
53  EPType_e fType; // type
54  EGeoMode_e fGeoMode; // strategy of polygon projection (what to try first)
55  TString fName; // name
56 
57  TEveVector fCenter; // center of distortion
58 
59  bool fDisplaceOrigin; // displace point before projection
60 
61  Bool_t fUsePreScale; // use pre-scaling
62  vPreScale_t fPreScales[3]; // scaling before the distortion
63 
64  Float_t fDistortion; // distortion
65  Float_t fFixR; // radius from which scaling remains constant
66  Float_t fFixZ; // z-coordinate from which scaling remains constant
67  Float_t fPastFixRFac; // relative scaling factor beyond fFixR as 10^x
68  Float_t fPastFixZFac; // relative scaling factor beyond fFixZ as 10^x
69  Float_t fScaleR; // scale factor to keep projected radius at fFixR fixed
70  Float_t fScaleZ; // scale factor to keep projected z-coordinate at fFixZ fixed
71  Float_t fPastFixRScale; // relative scaling beyond fFixR
72  Float_t fPastFixZScale; // relative scaling beyond fFixZ
73  Float_t fMaxTrackStep; // maximum distance between two points on a track
74 
75  void PreScaleVariable(Int_t dim, Float_t& v);
76 
77 public:
79  virtual ~TEveProjection() {}
80 
81  virtual Bool_t Is2D() const = 0;
82  virtual Bool_t Is3D() const = 0;
83 
84  virtual void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e p = kPP_Full) = 0;
85 
86  void ProjectPointfv(Float_t* v, Float_t d);
87  void ProjectPointdv(Double_t* v, Float_t d);
88  void ProjectVector(TEveVector& v, Float_t d);
89 
90  void ProjectPointfv(const TEveTrans* t, const Float_t* p, Float_t* v, Float_t d);
91  void ProjectPointdv(const TEveTrans* t, const Double_t* p, Double_t* v, Float_t d);
92  void ProjectVector(const TEveTrans* t, TEveVector& v, Float_t d);
93 
94  const Char_t* GetName() const { return fName.Data(); }
95  void SetName(const Char_t* txt) { fName = txt; }
96 
97  const TEveVector& RefCenter() const { return fCenter; }
98  virtual void SetCenter(TEveVector& v) { fCenter = v; }
99  virtual Float_t* GetProjectedCenter();
100 
101  void SetDisplaceOrigin(bool);
103 
104  void SetType(EPType_e t) { fType = t; }
105  EPType_e GetType() const { return fType; }
106 
107  void SetGeoMode(EGeoMode_e m) { fGeoMode = m; }
108  EGeoMode_e GetGeoMode() const { return fGeoMode; }
109 
110  Bool_t GetUsePreScale() const { return fUsePreScale; }
111  void SetUsePreScale(Bool_t x) { fUsePreScale = x; }
112 
113  void PreScalePoint(Float_t& x, Float_t& y);
114  void PreScalePoint(Float_t& x, Float_t& y, Float_t& z);
115  void AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale);
116  void ChangePreScaleEntry(Int_t coord, Int_t entry, Float_t new_scale);
117  void ClearPreScales();
118 
119  void SetDistortion(Float_t d);
120  Float_t GetDistortion() const { return fDistortion; }
121  Float_t GetFixR() const { return fFixR; }
122  Float_t GetFixZ() const { return fFixZ; }
123  void SetFixR(Float_t x);
124  void SetFixZ(Float_t x);
125  Float_t GetPastFixRFac() const { return fPastFixRFac; }
126  Float_t GetPastFixZFac() const { return fPastFixZFac; }
127  void SetPastFixRFac(Float_t x);
128  void SetPastFixZFac(Float_t x);
130  void SetMaxTrackStep(Float_t x) { fMaxTrackStep = TMath::Max(x, 1.0f); }
131 
132  virtual Bool_t HasSeveralSubSpaces() const { return kFALSE; }
133  virtual Bool_t AcceptSegment(TEveVector&, TEveVector&, Float_t /*tolerance*/) const { return kTRUE; }
134  virtual Int_t SubSpaceId(const TEveVector&) const { return 0; }
135  virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector&) const { return kFALSE; }
136  virtual void BisectBreakPoint(TEveVector& vL, TEveVector& vR, Float_t eps_sqr);
137  virtual void BisectBreakPoint(TEveVector& vL, TEveVector& vR, Bool_t project_result=kFALSE, Float_t depth=0);
138  virtual void SetDirectionalVector(Int_t screenAxis, TEveVector& vec);
139 
140  // utils to draw axis
142  virtual Float_t GetValForScreenPos(Int_t ax, Float_t value);
143  virtual Float_t GetScreenVal(Int_t ax, Float_t value);
144  Float_t GetScreenVal(Int_t i, Float_t x, TEveVector& dirVec, TEveVector& oCenter);
145  Float_t GetLimit(Int_t i, Bool_t pos);
146 
147 
148  static Float_t fgEps; // resolution of projected points
149  static Float_t fgEpsSqr; // square of resolution of projected points
150 
151  ClassDef(TEveProjection, 0); // Base for specific classes that implement non-linear projections.
152 };
153 
154 
155 //==============================================================================
156 // TEveRhoZProjection
157 //==============================================================================
158 
160 {
161 private:
162  TEveVector fProjectedCenter; // projected center of distortion.
163 
164 public:
166  virtual ~TEveRhoZProjection() {}
167 
168  virtual Bool_t Is2D() const { return kTRUE; }
169  virtual Bool_t Is3D() const { return kFALSE; }
170 
171  virtual void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
172 
173  virtual void SetCenter(TEveVector& v);
174  virtual Float_t* GetProjectedCenter() { return fProjectedCenter.Arr(); }
175 
176  virtual Bool_t HasSeveralSubSpaces() const { return kTRUE; }
177  virtual Bool_t AcceptSegment(TEveVector& v1, TEveVector& v2, Float_t tolerance) const;
178  virtual Int_t SubSpaceId(const TEveVector& v) const;
179  virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector& v) const;
180  virtual void SetDirectionalVector(Int_t screenAxis, TEveVector& vec);
181 
182  ClassDef(TEveRhoZProjection, 0); // Rho/Z non-linear projection.
183 };
184 
185 
186 //==============================================================================
187 // TEveRPhiProjection
188 //==============================================================================
189 
191 {
192 public:
194  virtual ~TEveRPhiProjection() {}
195 
196  virtual Bool_t Is2D() const { return kTRUE; }
197  virtual Bool_t Is3D() const { return kFALSE; }
198 
199  virtual void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
200 
201  ClassDef(TEveRPhiProjection, 0); // XY non-linear projection.
202 };
203 
204 
205 //==============================================================================
206 // TEve3DProjection
207 //==============================================================================
208 
210 {
211 public:
213  virtual ~TEve3DProjection() {}
214 
215  virtual Bool_t Is2D() const { return kFALSE; }
216  virtual Bool_t Is3D() const { return kTRUE; }
217 
218  virtual void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
219 
220  ClassDef(TEve3DProjection, 0); // 3D scaling "projection"
221 };
222 
223 // AMT: temporary workaround till root pactches are integrated in CMSSW
224 #define TEVEPROJECTIONS_DISPLACE_ORIGIN_MODE
225 
226 #endif
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:26
EPType_e GetType() const
PreScaleEntry_t(Float_t min, Float_t max, Float_t off, Float_t scale)
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get vector for axis in a projected space.
void SetName(const Char_t *txt)
vPreScale_t fPreScales[3]
float Float_t
Definition: RtypesCore.h:53
void ClearPreScales()
Clear all pre-scaling information.
Float_t GetLimit(Int_t i, Bool_t pos)
Method previously used by TEveProjectionAxesGL. Now obsolete.
virtual Bool_t Is2D() const =0
3D scaling projection.
void ProjectPointdv(Double_t *v, Float_t d)
Project double array.
std::vector< PreScaleEntry_t >::iterator vPreScale_i
Float_t GetFixR() const
Basic string class.
Definition: TString.h:129
Float_t fPastFixZScale
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Float_t GetScreenVal(Int_t ax, Float_t value)
Project point on given axis and return projected value.
virtual Bool_t AcceptSegment(TEveVector &, TEveVector &, Float_t) const
virtual ~TEveRPhiProjection()
void SetUsePreScale(Bool_t x)
virtual ~TEveProjection()
TEveVector fCenter
void SetGeoMode(EGeoMode_e m)
virtual Int_t SubSpaceId(const TEveVector &) const
virtual Bool_t Is3D() const
virtual Bool_t HasSeveralSubSpaces() const
const TEveVector & RefCenter() const
virtual Bool_t HasSeveralSubSpaces() const
Double_t x[n]
Definition: legend1.C:17
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e p=kPP_Full)=0
#define ClassDef(name, id)
Definition: Rtypes.h:297
Float_t GetDistortion() const
Float_t GetFixZ() const
void SetType(EPType_e t)
XY projection with distortion around given center.
void PreScalePoint(Float_t &x, Float_t &y)
Pre-scale point (x, y) in projected coordinates for 2D projections:
void SetMaxTrackStep(Float_t x)
void ProjectVector(TEveVector &v, Float_t d)
Project TEveVector.
Base-class for non-linear projections.
Float_t fMaxTrackStep
std::vector< PreScaleEntry_t > vPreScale_t
TEveVector fProjectedCenter
void SetFixR(Float_t x)
Set fixed radius.
static Float_t fgEps
const TT * Arr() const
Definition: TEveVector.h:40
Float_t GetPastFixZFac() const
virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector &) const
virtual ~TEveRhoZProjection()
void SetFixZ(Float_t x)
Set fixed radius.
TEveProjection()
Constructor.
Float_t GetPastFixRFac() const
const Char_t * GetName() const
SVector< double, 2 > v
Definition: Dict.h:5
virtual Bool_t Is3D() const
void SetPastFixRFac(Float_t x)
Set 2&#39;s-exponent for relative scaling beyond FixR.
EGeoMode_e fGeoMode
virtual Float_t GetValForScreenPos(Int_t ax, Float_t value)
Inverse projection.
TMarker * m
Definition: textangle.C:8
Bool_t GetUsePreScale() const
virtual void BisectBreakPoint(TEveVector &vL, TEveVector &vR, Float_t eps_sqr)
Find break-point on both sides of the discontinuity.
Float_t fPastFixRScale
void ProjectPointfv(Float_t *v, Float_t d)
Project float array.
EGeoMode_e GetGeoMode() const
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual Bool_t Is3D() const =0
void SetDisplaceOrigin(bool)
Set flag to displace for center.
virtual Float_t * GetProjectedCenter()
Get projected center.
virtual Float_t * GetProjectedCenter()
Get projected center.
double f(double x)
double Double_t
Definition: RtypesCore.h:55
virtual void SetCenter(TEveVector &v)
static Float_t fgEpsSqr
Double_t y[n]
Definition: legend1.C:17
void SetDistortion(Float_t d)
Set distortion.
virtual Bool_t Is2D() const
virtual Bool_t Is2D() const
TEveVector GetOrthogonalCenter(int idx, TEveVector &out)
Get center ortogonal to given axis index.
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
virtual Bool_t Is3D() const
char Char_t
Definition: RtypesCore.h:29
Float_t fPastFixZFac
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:200
virtual ~TEve3DProjection()
Bool_t GetDisplaceOrigin() const
Float_t GetMaxTrackStep() const
Float_t fPastFixRFac
void PreScaleVariable(Int_t dim, Float_t &v)
Pre-scale single variable with pre-scale entry dim.
void ChangePreScaleEntry(Int_t coord, Int_t entry, Float_t new_scale)
Change scale for given entry and coordinate.
void SetPastFixZFac(Float_t x)
Set 2&#39;s-exponent for relative scaling beyond FixZ.
const Bool_t kTRUE
Definition: RtypesCore.h:91
Transformation from 3D to 2D.
virtual Bool_t Is2D() const
void AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale)
Add new scaling range for given coordinate.
const char * Data() const
Definition: TString.h:347