Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
29 class REveProjection {
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};
37  Float_t fOffset{0};
38  Float_t fScale{1};
39 
40  PreScaleEntry_t() = default;
41 
42  PreScaleEntry_t(Float_t min, Float_t max, Float_t off, Float_t scale)
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:
76  REveProjection();
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 
84  void ProjectPointfv(Float_t *v, Float_t d);
85  void ProjectPointdv(Double_t *v, Float_t d);
86  void ProjectVector(REveVector &v, Float_t d);
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);
100  Bool_t GetDisplaceOrigin() const { return fDisplaceOrigin; }
101 
102  void SetType(EPType_e t) { fType = t; }
103  EPType_e GetType() const { return fType; }
104 
105  void SetGeoMode(EGeoMode_e m) { fGeoMode = m; }
106  EGeoMode_e GetGeoMode() const { return fGeoMode; }
107 
108  Bool_t GetUsePreScale() const { return fUsePreScale; }
109  void SetUsePreScale(Bool_t x) { fUsePreScale = x; }
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);
127  Float_t GetMaxTrackStep() const { return fMaxTrackStep; }
128  void SetMaxTrackStep(Float_t x) { fMaxTrackStep = TMath::Max(x, 1.0f); }
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
139  REveVector GetOrthogonalCenter(int idx, REveVector &out);
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 
154 class REveRhoZProjection : public REveProjection {
155 private:
156  REveVector fProjectedCenter; // projected center of distortion.
157 
158 public:
159  REveRhoZProjection();
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 
182 class REveRPhiProjection : public REveProjection {
183 public:
184  REveRPhiProjection();
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 
198 class REve3DProjection : public REveProjection {
199 public:
200  REve3DProjection();
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