Logo ROOT   6.19/01
Reference Guide
REveProjections.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, 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 ROOT7_REveProjections
13 #define ROOT7_REveProjections
14 
15 #include <ROOT/REveVector.hxx>
16 
17 #include <vector>
18 
19 namespace ROOT {
20 namespace Experimental {
21 
22 class REveTrans;
23 
24 ///////////////////////////////////////////////////////////////////////////////
25 /// REveProjection
26 /// Base for specific classes that implement non-linear projections.
27 ///////////////////////////////////////////////////////////////////////////////
28 
30 public:
31  enum EPType_e { kPT_Unknown, kPT_RPhi, kPT_RhoZ, kPT_3D, kPT_End }; // projection type
32  enum EPProc_e { kPP_Plane, kPP_Distort, kPP_Full }; // projection procedure
33  enum EGeoMode_e { kGM_Unknown, kGM_Polygons, kGM_Segments }; // strategy for geometry projections
34 
35  struct PreScaleEntry_t {
36  Float_t fMin{0}, fMax{0};
39 
40  PreScaleEntry_t() = default;
41 
43  : fMin(min), fMax(max), fOffset(off), fScale(scale)
44  {
45  }
46  };
47 
48  typedef std::vector<PreScaleEntry_t> vPreScale_t;
49 
50 protected:
51  EPType_e fType; // type
52  EGeoMode_e fGeoMode; // strategy of polygon projection (what to try first)
53  std::string fName; // name
54 
55  REveVector fCenter; // center of distortion
56 
57  bool fDisplaceOrigin; // displace point before projection
58 
59  Bool_t fUsePreScale; // use pre-scaling
60  vPreScale_t fPreScales[3]; // scaling before the distortion
61 
62  Float_t fDistortion; // distortion
63  Float_t fFixR; // radius from which scaling remains constant
64  Float_t fFixZ; // z-coordinate from which scaling remains constant
65  Float_t fPastFixRFac; // relative scaling factor beyond fFixR as 10^x
66  Float_t fPastFixZFac; // relative scaling factor beyond fFixZ as 10^x
67  Float_t fScaleR; // scale factor to keep projected radius at fFixR fixed
68  Float_t fScaleZ; // scale factor to keep projected z-coordinate at fFixZ fixed
69  Float_t fPastFixRScale; // relative scaling beyond fFixR
70  Float_t fPastFixZScale; // relative scaling beyond fFixZ
71  Float_t fMaxTrackStep; // maximum distance between two points on a track
72 
73  void PreScaleVariable(Int_t dim, Float_t &v);
74 
75 public:
77  virtual ~REveProjection() {}
78 
79  virtual Bool_t Is2D() const = 0;
80  virtual Bool_t Is3D() const = 0;
81 
82  virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e p = kPP_Full) = 0;
83 
87 
88  void ProjectPointfv(const REveTrans *t, const Float_t *p, Float_t *v, Float_t d);
89  void ProjectPointdv(const REveTrans *t, const Double_t *p, Double_t *v, Float_t d);
90  void ProjectVector(const REveTrans *t, REveVector &v, Float_t d);
91 
92  const char *GetName() const { return fName.c_str(); }
93  void SetName(const char *txt) { fName = txt; }
94 
95  const REveVector &RefCenter() const { return fCenter; }
96  virtual void SetCenter(REveVector &v) { fCenter = v; }
97  virtual Float_t *GetProjectedCenter();
98 
99  void SetDisplaceOrigin(bool);
101 
102  void SetType(EPType_e t) { fType = t; }
103  EPType_e GetType() const { return fType; }
104 
106  EGeoMode_e GetGeoMode() const { return fGeoMode; }
107 
108  Bool_t GetUsePreScale() const { return fUsePreScale; }
110 
111  void PreScalePoint(Float_t &x, Float_t &y);
112  void PreScalePoint(Float_t &x, Float_t &y, Float_t &z);
113  void AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale);
114  void ChangePreScaleEntry(Int_t coord, Int_t entry, Float_t new_scale);
115  void ClearPreScales();
116 
117  void SetDistortion(Float_t d);
118  Float_t GetDistortion() const { return fDistortion; }
119  Float_t GetFixR() const { return fFixR; }
120  Float_t GetFixZ() const { return fFixZ; }
121  void SetFixR(Float_t x);
122  void SetFixZ(Float_t x);
123  Float_t GetPastFixRFac() const { return fPastFixRFac; }
124  Float_t GetPastFixZFac() const { return fPastFixZFac; }
125  void SetPastFixRFac(Float_t x);
126  void SetPastFixZFac(Float_t x);
129 
130  virtual Bool_t HasSeveralSubSpaces() const { return kFALSE; }
131  virtual Bool_t AcceptSegment(REveVector &, REveVector &, Float_t /*tolerance*/) const { return kTRUE; }
132  virtual Int_t SubSpaceId(const REveVector &) const { return 0; }
133  virtual Bool_t IsOnSubSpaceBoundrary(const REveVector &) const { return kFALSE; }
134  virtual void BisectBreakPoint(REveVector &vL, REveVector &vR, Float_t eps_sqr);
135  virtual void BisectBreakPoint(REveVector &vL, REveVector &vR, Bool_t project_result = kFALSE, Float_t depth = 0);
136  virtual void SetDirectionalVector(Int_t screenAxis, REveVector &vec);
137 
138  // utils to draw axis
140  virtual Float_t GetValForScreenPos(Int_t ax, Float_t value);
141  virtual Float_t GetScreenVal(Int_t ax, Float_t value);
142  Float_t GetScreenVal(Int_t i, Float_t x, REveVector &dirVec, REveVector &oCenter);
143  Float_t GetLimit(Int_t i, Bool_t pos);
144 
145  static Float_t fgEps; // resolution of projected points
146  static Float_t fgEpsSqr; // square of resolution of projected points
147 };
148 
149 //==============================================================================
150 // REveRhoZProjection
151 // Rho/Z non-linear projection.
152 //==============================================================================
153 
155 private:
156  REveVector fProjectedCenter; // projected center of distortion.
157 
158 public:
160  virtual ~REveRhoZProjection() {}
161 
162  Bool_t Is2D() const override { return kTRUE; }
163  Bool_t Is3D() const override { return kFALSE; }
164 
165  void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc = kPP_Full) override;
166 
167  void SetCenter(REveVector &v) override;
168  Float_t *GetProjectedCenter() override { return fProjectedCenter.Arr(); }
169 
170  Bool_t HasSeveralSubSpaces() const override { return kTRUE; }
171  Bool_t AcceptSegment(REveVector &v1, REveVector &v2, Float_t tolerance) const override;
172  Int_t SubSpaceId(const REveVector &v) const override;
173  Bool_t IsOnSubSpaceBoundrary(const REveVector &v) const override;
174  void SetDirectionalVector(Int_t screenAxis, REveVector &vec) override;
175 };
176 
177 //==============================================================================
178 // REveRPhiProjection
179 // XY non-linear projection.
180 //==============================================================================
181 
183 public:
185  virtual ~REveRPhiProjection() {}
186 
187  Bool_t Is2D() const override { return kTRUE; }
188  Bool_t Is3D() const override { return kFALSE; }
189 
190  void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc = kPP_Full) override;
191 };
192 
193 //==============================================================================
194 // REve3DProjection
195 // 3D scaling "projection"
196 //==============================================================================
197 
199 public:
201  virtual ~REve3DProjection() {}
202 
203  Bool_t Is2D() const override { return kFALSE; }
204  Bool_t Is3D() const override { return kTRUE; }
205 
206  void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc = kPP_Full) override;
207 };
208 
209 } // namespace Experimental
210 } // namespace ROOT
211 
212 #endif
Float_t GetLimit(Int_t i, Bool_t pos)
virtual Bool_t AcceptSegment(REveVector &, REveVector &, Float_t) const
void ClearPreScales()
Clear all pre-scaling information.
void SetDisplaceOrigin(bool)
Set flag to displace for center.
virtual Int_t SubSpaceId(const REveVector &) const
auto * m
Definition: textangle.C:8
VSD Structures.
Definition: StringConv.hxx:21
Bool_t HasSeveralSubSpaces() const override
virtual Bool_t IsOnSubSpaceBoundrary(const REveVector &) const
float Float_t
Definition: RtypesCore.h:53
void AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale)
Add new scaling range for given coordinate.
virtual Float_t GetScreenVal(Int_t ax, Float_t value)
Project point on given axis and return projected value.
void SetDistortion(Float_t d)
Set distortion.
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
Project point.
Bool_t AcceptSegment(REveVector &v1, REveVector &v2, Float_t tolerance) const override
Check if segment of two projected points is valid.
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t HasSeveralSubSpaces() const
virtual void SetDirectionalVector(Int_t screenAxis, REveVector &vec)
Get vector for axis in a projected space.
Double_t x[n]
Definition: legend1.C:17
virtual Bool_t Is3D() const =0
void SetFixZ(Float_t x)
Set fixed radius.
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
Project point.
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e p=kPP_Full)=0
REveProjection Base for specific classes that implement non-linear projections.
REveVector GetOrthogonalCenter(int idx, REveVector &out)
Get center ortogonal to given axis index.
const REveVector & RefCenter() const
Int_t SubSpaceId(const REveVector &v) const override
Return sub-space id for the point.
virtual Float_t GetValForScreenPos(Int_t ax, Float_t value)
Inverse projection.
void ChangePreScaleEntry(Int_t coord, Int_t entry, Float_t new_scale)
Change scale for given entry and coordinate.
const Bool_t kFALSE
Definition: RtypesCore.h:88
void ProjectVector(REveVector &v, Float_t d)
Project REveVector.
#define d(i)
Definition: RSha256.hxx:102
virtual void SetCenter(REveVector &v)
void PreScaleVariable(Int_t dim, Float_t &v)
Pre-scale single variable with pre-scale entry dim.
void SetDirectionalVector(Int_t screenAxis, REveVector &vec) override
Get direction in the unprojected space for axis index in the projected space.
void ProjectPointdv(Double_t *v, Float_t d)
Project double array.
double Double_t
Definition: RtypesCore.h:55
void PreScalePoint(Float_t &x, Float_t &y)
Pre-scale point (x, y) in projected coordinates for 2D projections:
std::vector< PreScaleEntry_t > vPreScale_t
Double_t y[n]
Definition: legend1.C:17
Float_t * GetProjectedCenter() override
Get projected center.
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
PreScaleEntry_t(Float_t min, Float_t max, Float_t off, Float_t scale)
virtual Bool_t Is2D() const =0
void SetCenter(REveVector &v) override
Set center of distortion (virtual method).
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
Project point.
void SetPastFixRFac(Float_t x)
Set 2&#39;s-exponent for relative scaling beyond FixR.
virtual Float_t * GetProjectedCenter()
Get projected center.
Bool_t IsOnSubSpaceBoundrary(const REveVector &v) const override
Checks if point is on sub-space boundary.
virtual void BisectBreakPoint(REveVector &vL, REveVector &vR, Float_t eps_sqr)
Find break-point on both sides of the discontinuity.
const Bool_t kTRUE
Definition: RtypesCore.h:87
void ProjectPointfv(Float_t *v, Float_t d)
Project float array.
void SetPastFixZFac(Float_t x)
Set 2&#39;s-exponent for relative scaling beyond FixZ.
void SetFixR(Float_t x)
Set fixed radius.