Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveTrackProjected.cxx
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#include "TEveTrackProjected.h"
13#include "TEveTrackPropagator.h"
15#include "TEveTrans.h"
16
17/** \class TEveTrackProjected
18\ingroup TEve
19Projected copy of a TEveTrack.
20*/
21
23
24////////////////////////////////////////////////////////////////////////////////
25/// Default constructor.
26
28 TEveTrack (),
29 fOrigPnts (nullptr)
30{
31}
32
33////////////////////////////////////////////////////////////////////////////////
34/// This is virtual method from base-class TEveProjected.
35
37{
39 CopyVizParams(dynamic_cast<TEveElement*>(model));
40
41 TEveTrack* otrack = dynamic_cast<TEveTrack*>(fProjectable);
42 SetTrackParams(*otrack);
44}
45
46////////////////////////////////////////////////////////////////////////////////
47/// Set depth (z-coordinate) of the projected points.
48
50{
51 SetDepthCommon(d, this, fBBox);
52
53 Int_t n = Size();
54 Float_t *p = GetP() + 2;
55 for (Int_t i = 0; i < n; ++i, p+=3)
56 {
57 *p = fDepth;
58 }
59
60 for (vPathMark_i pm = fPathMarks.begin(); pm != fPathMarks.end(); ++pm)
61 {
62 pm->fV.fZ = fDepth;
63 }
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// Virtual method from base-class TEveProjected.
68
70{
71 MakeTrack(kFALSE); // TEveProjectionManager makes recursive calls
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// Find index of the last point that lies within the same
76/// segment of projected space.
77/// For example, rho-z projection separates upper and lower hemisphere
78/// and tracks break into two lines when crossing the y=0 plane.
79
81{
82 TEveProjection *projection = fManager->GetProjection();
83
84 Int_t val = fLastPoint;
85
86 if (projection->HasSeveralSubSpaces())
87 {
89 if (Size() > 1)
90 {
91 Int_t i = start;
92 while(i < fLastPoint)
93 {
94 GetPoint(i, v1.fX, v1.fY, v1.fZ);
95 GetPoint(i+1, v2.fX, v2.fY, v2.fZ);
96 if(projection->AcceptSegment(v1, v2, fPropagator->GetDelta()) == kFALSE)
97 {
98 val = i;
99 break;
100 }
101 i++;
102 }
103 }
104 }
105 return val;
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Calculate the points of the track for drawing.
110/// Call base-class, project, find break-points and insert points
111/// required for full representation.
112
114{
115 TEveTrack *otrack = dynamic_cast<TEveTrack*>(fProjectable);
116 TEveTrans *trans = otrack->PtrMainTrans(kFALSE);
117 TEveProjection *projection = fManager->GetProjection();
118
119 fBreakPoints.clear();
120
121 fPathMarks.clear();
122 SetPathMarks(*otrack);
123 if (GetLockPoints() || otrack->Size() > 0)
124 {
125 ClonePoints(*otrack);
126 fLastPMIdx = otrack->GetLastPMIdx();
127 }
128 else
129 {
130 TEveTrack::MakeTrack(recurse);
131 }
132 if (Size() == 0) return; // All points can be outside of MaxR / MaxZ limits.
133
134 // Break segments additionally if required by the projection.
136
137 // Project points, store originals (needed for break-points).
138 Float_t *p = GetP();
139 fOrigPnts = new TEveVector[Size()];
140 for (Int_t i = 0; i < Size(); ++i, p+=3)
141 {
142 if (trans) trans->MultiplyIP(p);
143 fOrigPnts[i].Set(p);
144 projection->ProjectPointfv(p, fDepth);
145 }
146
147 Float_t x, y, z;
148 Int_t bL = 0, bR = GetBreakPointIdx(0);
149 std::vector<TEveVector> vvec;
150 while (kTRUE)
151 {
152 for (Int_t i=bL; i<=bR; i++)
153 {
154 GetPoint(i, x, y, z);
155 vvec.push_back(TEveVector(x, y, z));
156 }
157 if (bR == fLastPoint)
158 break;
159
160 TEveVector vL = fOrigPnts[bR];
161 TEveVector vR = fOrigPnts[bR + 1];
162 projection->BisectBreakPoint(vL, vR, kTRUE, fDepth);
163 vvec.push_back(vL);
164 fBreakPoints.push_back((Int_t)vvec.size());
165 vvec.push_back(vR);
166
167 bL = bR + 1;
168 bR = GetBreakPointIdx(bL);
169 }
170 fBreakPoints.push_back((Int_t)vvec.size()); // Mark the track-end for drawing.
171
172 // Decide if points need to be fixed.
173 // This (and the fixing itself) should really be done in TEveProjection but
174 // for now we do it here as RhoZ is the only one that needs it.
175 Bool_t fix_y = kFALSE;
176 Float_t sign_y = 0;
177 if (projection->HasSeveralSubSpaces())
178 {
180 {
182 {
183 fix_y = kTRUE;
184 sign_y = vvec.front().fY;
185 break;
186 }
188 {
189 fix_y = kTRUE;
190 sign_y = vvec.back().fY;
191 break;
192 }
193 }
194 }
195
196 Reset((Int_t)vvec.size());
197 for (std::vector<TEveVector>::iterator i=vvec.begin(); i!=vvec.end(); ++i)
198 {
199 if (fix_y)
200 SetNextPoint((*i).fX, TMath::Sign((*i).fY, sign_y), (*i).fZ);
201 else
202 SetNextPoint((*i).fX, (*i).fY, (*i).fZ);
203 }
204 delete [] fOrigPnts; fOrigPnts = nullptr;
205
206 // Project path-marks
207 for (vPathMark_i pm = fPathMarks.begin(); pm != fPathMarks.end(); ++pm)
208 {
209 projection->ProjectPointdv(trans, pm->fV.Arr(), pm->fV.Arr(), fDepth);
210 }
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Print line segments info.
215
217{
218 printf("%s LineSegments:\n", GetName());
219 Int_t start = 0;
220 Int_t segment = 0;
221 TEveVector sVec;
222 TEveVector bPnt;
223 for (std::vector<Int_t>::iterator bpi = fBreakPoints.begin();
224 bpi != fBreakPoints.end(); ++bpi)
225 {
226 Int_t size = *bpi - start;
227
228 GetPoint(start, sVec.fX, sVec.fY, sVec.fZ);
229 GetPoint((*bpi)-1, bPnt.fX, bPnt.fY, bPnt.fZ);
230 printf("seg %d size %d start %d ::(%f, %f, %f) (%f, %f, %f)\n",
231 segment, size, start, sVec.fX, sVec.fY, sVec.fZ,
232 bPnt.fX, bPnt.fY, bPnt.fZ);
233 start += size;
234 segment ++;
235 }
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Virtual method from from base-class TEveTrack.
240
242{
243 TEveTrack* t = dynamic_cast<TEveTrack*>(fProjectable);
244 if (t)
245 t->SecSelected(t);
246}
247
248
249/** \class TEveTrackListProjected
250\ingroup TEve
251Specialization of TEveTrackList for holding TEveTrackProjected objects.
252*/
253
255
256////////////////////////////////////////////////////////////////////////////////
257/// Default constructor.
258
260 TEveTrackList (),
262{
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// This is virtual method from base-class TEveProjected.
267
269{
270 TEveProjected::SetProjection(proj, model);
271 CopyVizParams(dynamic_cast<TEveElement*>(model));
272
273 TEveTrackList& tl = * dynamic_cast<TEveTrackList*>(model);
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// This is not needed for functionality as SetDepth(Float_t d)
279/// is overriden -- but SetDepthLocal() is abstract.
280/// Just emits a warning if called.
281
283{
284 Warning("SetDepthLocal", "This function only exists to fulfill an abstract interface.");
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Set depth of all children inheriting from TEveTrackProjected.
289
291{
292 SetDepth(d, this);
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Set depth of all children of el inheriting from TEveTrackProjected.
297
299{
300 TEveTrackProjected* ptrack;
301 for (List_i i = el->BeginChildren(); i != el->EndChildren(); ++i)
302 {
303 ptrack = dynamic_cast<TEveTrackProjected*>(*i);
304 if (ptrack)
305 ptrack->SetDepth(d);
306 if (fRecurse)
307 SetDepth(d, *i);
308 }
309}
#define d(i)
Definition RSha256.hxx:102
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassImp(name)
Definition Rtypes.h:382
TEveVectorT< Float_t > TEveVector
Definition TEveVector.h:123
winID h TVirtualViewer3D TVirtualGLPainter p
Float_t * fBBox
Definition TAttBBox.h:20
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
virtual TEveTrans * PtrMainTrans(Bool_t create=kTRUE)
Return pointer to main transformation.
List_i EndChildren()
List_i BeginChildren()
List_t::iterator List_i
Definition TEveElement.h:72
void ReduceSegmentLengths(Float_t max)
Make sure that no segment is longer than max.
Definition TEveLine.cxx:183
virtual void ClonePoints(const TEvePointSet &e)
Clone points and all point-related information from point-set 'e'.
void Reset(Int_t n_points=0, Int_t n_int_ids=0)
Drop all data and set-up the data structures to recive new data.
Abstract base-class for non-linear projectable objects.
Abstract base class for classes that hold results of a non-linear projection transformation.
virtual void SetDepth(Float_t d)
Set depth coordinate for the element.
TEveProjectable * fProjectable
TEveProjectionManager * fManager
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
Sets projection manager and reference in the projectable object.
void SetDepthCommon(Float_t d, TEveElement *el, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
Manager class for steering of projections and managing projected objects.
TEveProjection * GetProjection()
Base-class for non-linear projections.
virtual void BisectBreakPoint(TEveVector &vL, TEveVector &vR, Float_t eps_sqr)
Find break-point on both sides of the discontinuity.
void ProjectPointfv(Float_t *v, Float_t d)
Project float array.
virtual Bool_t HasSeveralSubSpaces() const
void ProjectPointdv(Double_t *v, Float_t d)
Project double array.
Float_t GetMaxTrackStep() const
virtual Bool_t AcceptSegment(TEveVector &, TEveVector &, Float_t) const
Specialization of TEveTrackList for holding TEveTrackProjected objects.
void SetProjection(TEveProjectionManager *proj, TEveProjectable *model) override
This is virtual method from base-class TEveProjected.
TEveTrackListProjected()
Default constructor.
void SetDepthLocal(Float_t d) override
This is not needed for functionality as SetDepth(Float_t d) is overriden – but SetDepthLocal() is abs...
void SetDepth(Float_t d) override
Set depth of all children inheriting from TEveTrackProjected.
A list of tracks supporting change of common attributes and selection based on track parameters.
Definition TEveTrack.h:140
void SetPropagator(TEveTrackPropagator *prop)
Set default propagator for tracks.
Bool_t fRecurse
Definition TEveTrack.h:150
void CopyVizParams(const TEveElement *el) override
Copy visualization parameters from element el.
TEveTrackPropagator * GetPropagator()
Definition TEveTrack.h:175
Projected copy of a TEveTrack.
std::vector< Int_t > fBreakPoints
TEveTrackProjected()
Default constructor.
void MakeTrack(Bool_t recurse=kTRUE) override
Calculate the points of the track for drawing.
void SecSelected(TEveTrack *) override
Virtual method from from base-class TEveTrack.
void SetProjection(TEveProjectionManager *mng, TEveProjectable *model) override
This is virtual method from base-class TEveProjected.
void UpdateProjection() override
Virtual method from base-class TEveProjected.
void PrintLineSegments()
Print line segments info.
Int_t GetBreakPointIdx(Int_t start)
Find index of the last point that lies within the same segment of projected space.
void SetDepthLocal(Float_t d) override
Set depth (z-coordinate) of the projected points.
Double_t GetDelta() const
UChar_t GetProjTrackBreaking() const
Visual representation of a track.
Definition TEveTrack.h:33
vPathMark_t::iterator vPathMark_i
Definition TEveTrack.h:43
virtual void SecSelected(TEveTrack *)
Emits "SecSelected(TEveTrack*)" signal.
Bool_t GetLockPoints() const
Definition TEveTrack.h:117
virtual void MakeTrack(Bool_t recurse=kTRUE)
Calculate track representation based on track data and current settings of the propagator.
TEveTrackPropagator * fPropagator
Last path-mark index tried in track-propagation.
Definition TEveTrack.h:64
virtual void SetPathMarks(const TEveTrack &t)
Copy path-marks from t.
Int_t GetLastPMIdx() const
Definition TEveTrack.h:85
void CopyVizParams(const TEveElement *el) override
Copy visualization parameters from element el.
virtual void SetTrackParams(const TEveTrack &t)
Copy track parameters from t.
void SetLockPoints(Bool_t l)
Definition TEveTrack.h:116
vPathMark_t fPathMarks
Definition TEveTrack.h:61
Int_t fLastPMIdx
Definition TEveTrack.h:62
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition TEveTrans.h:27
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
void Set(const Float_t *v)
Definition TEveVector.h:82
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:979
const char * GetName() const override
Returns name of object.
virtual void GetPoint(Int_t n, Float_t &x, Float_t &y, Float_t &z) const
Fills the parameters x, y, z with the coordinate of the n-th point n must be between 0 and Size() - 1...
virtual Int_t Size() const
virtual Float_t * GetP() const
virtual Int_t SetNextPoint(Double_t x, Double_t y, Double_t z)
Set point following LastPoint to x, y, z.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
Definition TMathBase.h:175