forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveProjections.h
226 lines (167 loc) · 9.12 KB
/
TEveProjections.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TEveProjections
#define ROOT_TEveProjections
#include "TEveVector.h"
#include "TString.h"
#include <vector>
class TEveTrans;
//==============================================================================
// TEveProjection
//==============================================================================
class TEveProjection
{
public:
enum EPType_e { kPT_Unknown, kPT_RPhi, kPT_RhoZ, kPT_3D, kPT_End }; // projection type
enum EPProc_e { kPP_Plane, kPP_Distort, kPP_Full }; // projection procedure
enum EGeoMode_e { kGM_Unknown, kGM_Polygons, kGM_Segments }; // strategy for geometry projections
struct PreScaleEntry_t
{
Float_t fMin, fMax;
Float_t fOffset;
Float_t fScale;
PreScaleEntry_t() :
fMin(0), fMax(0), fOffset(0), fScale(1) {}
PreScaleEntry_t(Float_t min, Float_t max, Float_t off, Float_t scale) :
fMin(min), fMax(max), fOffset(off), fScale(scale) {}
virtual ~PreScaleEntry_t() {}
ClassDef(PreScaleEntry_t, 0);
};
typedef std::vector<PreScaleEntry_t> vPreScale_t;
typedef std::vector<PreScaleEntry_t>::iterator vPreScale_i;
protected:
EPType_e fType; // type
EGeoMode_e fGeoMode; // strategy of polygon projection (what to try first)
TString fName; // name
TEveVector fCenter; // center of distortion
bool fDisplaceOrigin; // displace point before projection
Bool_t fUsePreScale; // use pre-scaling
vPreScale_t fPreScales[3]; // scaling before the distortion
Float_t fDistortion; // distortion
Float_t fFixR; // radius from which scaling remains constant
Float_t fFixZ; // z-coordinate from which scaling remains constant
Float_t fPastFixRFac; // relative scaling factor beyond fFixR as 10^x
Float_t fPastFixZFac; // relative scaling factor beyond fFixZ as 10^x
Float_t fScaleR; // scale factor to keep projected radius at fFixR fixed
Float_t fScaleZ; // scale factor to keep projected z-coordinate at fFixZ fixed
Float_t fPastFixRScale; // relative scaling beyond fFixR
Float_t fPastFixZScale; // relative scaling beyond fFixZ
Float_t fMaxTrackStep; // maximum distance between two points on a track
void PreScaleVariable(Int_t dim, Float_t& v);
public:
TEveProjection();
virtual ~TEveProjection() {}
virtual Bool_t Is2D() const = 0;
virtual Bool_t Is3D() const = 0;
virtual void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e p = kPP_Full) = 0;
void ProjectPointfv(Float_t* v, Float_t d);
void ProjectPointdv(Double_t* v, Float_t d);
void ProjectVector(TEveVector& v, Float_t d);
void ProjectPointfv(const TEveTrans* t, const Float_t* p, Float_t* v, Float_t d);
void ProjectPointdv(const TEveTrans* t, const Double_t* p, Double_t* v, Float_t d);
void ProjectVector(const TEveTrans* t, TEveVector& v, Float_t d);
const Char_t* GetName() const { return fName.Data(); }
void SetName(const Char_t* txt) { fName = txt; }
const TEveVector& RefCenter() const { return fCenter; }
virtual void SetCenter(TEveVector& v) { fCenter = v; }
virtual Float_t* GetProjectedCenter();
void SetDisplaceOrigin(bool);
Bool_t GetDisplaceOrigin() const { return fDisplaceOrigin; }
void SetType(EPType_e t) { fType = t; }
EPType_e GetType() const { return fType; }
void SetGeoMode(EGeoMode_e m) { fGeoMode = m; }
EGeoMode_e GetGeoMode() const { return fGeoMode; }
Bool_t GetUsePreScale() const { return fUsePreScale; }
void SetUsePreScale(Bool_t x) { fUsePreScale = x; }
void PreScalePoint(Float_t& x, Float_t& y);
void PreScalePoint(Float_t& x, Float_t& y, Float_t& z);
void AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale);
void ChangePreScaleEntry(Int_t coord, Int_t entry, Float_t new_scale);
void ClearPreScales();
void SetDistortion(Float_t d);
Float_t GetDistortion() const { return fDistortion; }
Float_t GetFixR() const { return fFixR; }
Float_t GetFixZ() const { return fFixZ; }
void SetFixR(Float_t x);
void SetFixZ(Float_t x);
Float_t GetPastFixRFac() const { return fPastFixRFac; }
Float_t GetPastFixZFac() const { return fPastFixZFac; }
void SetPastFixRFac(Float_t x);
void SetPastFixZFac(Float_t x);
Float_t GetMaxTrackStep() const { return fMaxTrackStep; }
void SetMaxTrackStep(Float_t x) { fMaxTrackStep = TMath::Max(x, 1.0f); }
virtual Bool_t HasSeveralSubSpaces() const { return kFALSE; }
virtual Bool_t AcceptSegment(TEveVector&, TEveVector&, Float_t /*tolerance*/) const { return kTRUE; }
virtual Int_t SubSpaceId(const TEveVector&) const { return 0; }
virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector&) const { return kFALSE; }
virtual void BisectBreakPoint(TEveVector& vL, TEveVector& vR, Float_t eps_sqr);
virtual void BisectBreakPoint(TEveVector& vL, TEveVector& vR, Bool_t project_result=kFALSE, Float_t depth=0);
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector& vec);
// utils to draw axis
TEveVector GetOrthogonalCenter(int idx, TEveVector& out);
virtual Float_t GetValForScreenPos(Int_t ax, Float_t value);
virtual Float_t GetScreenVal(Int_t ax, Float_t value);
Float_t GetScreenVal(Int_t i, Float_t x, TEveVector& dirVec, TEveVector& oCenter);
Float_t GetLimit(Int_t i, Bool_t pos);
static Float_t fgEps; // resolution of projected points
static Float_t fgEpsSqr; // square of resolution of projected points
ClassDef(TEveProjection, 0); // Base for specific classes that implement non-linear projections.
};
//==============================================================================
// TEveRhoZProjection
//==============================================================================
class TEveRhoZProjection: public TEveProjection
{
private:
TEveVector fProjectedCenter; // projected center of distortion.
public:
TEveRhoZProjection();
virtual ~TEveRhoZProjection() {}
virtual Bool_t Is2D() const { return kTRUE; }
virtual Bool_t Is3D() const { return kFALSE; }
virtual void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
virtual void SetCenter(TEveVector& v);
virtual Float_t* GetProjectedCenter() { return fProjectedCenter.Arr(); }
virtual Bool_t HasSeveralSubSpaces() const { return kTRUE; }
virtual Bool_t AcceptSegment(TEveVector& v1, TEveVector& v2, Float_t tolerance) const;
virtual Int_t SubSpaceId(const TEveVector& v) const;
virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector& v) const;
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector& vec);
ClassDef(TEveRhoZProjection, 0); // Rho/Z non-linear projection.
};
//==============================================================================
// TEveRPhiProjection
//==============================================================================
class TEveRPhiProjection : public TEveProjection
{
public:
TEveRPhiProjection();
virtual ~TEveRPhiProjection() {}
virtual Bool_t Is2D() const { return kTRUE; }
virtual Bool_t Is3D() const { return kFALSE; }
virtual void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
ClassDef(TEveRPhiProjection, 0); // XY non-linear projection.
};
//==============================================================================
// TEve3DProjection
//==============================================================================
class TEve3DProjection : public TEveProjection
{
public:
TEve3DProjection();
virtual ~TEve3DProjection() {}
virtual Bool_t Is2D() const { return kFALSE; }
virtual Bool_t Is3D() const { return kTRUE; }
virtual void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
ClassDef(TEve3DProjection, 0); // 3D scaling "projection"
};
// AMT: temporary workaround till root pactches are integrated in CMSSW
#define TEVEPROJECTIONS_DISPLACE_ORIGIN_MODE
#endif