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
22
23////////////////////////////////////////////////////////////////////////////////
24/// Default constructor.
25
27 TEveTrack (),
28 fOrigPnts (nullptr)
29{
30}
31
32////////////////////////////////////////////////////////////////////////////////
33/// This is virtual method from base-class TEveProjected.
34
44
45////////////////////////////////////////////////////////////////////////////////
46/// Set depth (z-coordinate) of the projected points.
47
49{
50 SetDepthCommon(d, this, fBBox);
51
52 Int_t n = Size();
53 Float_t *p = GetP() + 2;
54 for (Int_t i = 0; i < n; ++i, p+=3)
55 {
56 *p = fDepth;
57 }
58
59 for (vPathMark_i pm = fPathMarks.begin(); pm != fPathMarks.end(); ++pm)
60 {
61 pm->fV.fZ = fDepth;
62 }
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// Virtual method from base-class TEveProjected.
67
69{
70 MakeTrack(kFALSE); // TEveProjectionManager makes recursive calls
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Find index of the last point that lies within the same
75/// segment of projected space.
76/// For example, rho-z projection separates upper and lower hemisphere
77/// and tracks break into two lines when crossing the y=0 plane.
78
80{
82
83 Int_t val = fLastPoint;
84
85 if (projection->HasSeveralSubSpaces())
86 {
88 if (Size() > 1)
89 {
90 Int_t i = start;
91 while(i < fLastPoint)
92 {
93 GetPoint(i, v1.fX, v1.fY, v1.fZ);
94 GetPoint(i+1, v2.fX, v2.fY, v2.fZ);
95 if(projection->AcceptSegment(v1, v2, fPropagator->GetDelta()) == kFALSE)
96 {
97 val = i;
98 break;
99 }
100 i++;
101 }
102 }
103 }
104 return val;
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Calculate the points of the track for drawing.
109/// Call base-class, project, find break-points and insert points
110/// required for full representation.
111
113{
114 TEveTrack *otrack = dynamic_cast<TEveTrack*>(fProjectable);
115 TEveTrans *trans = otrack->PtrMainTrans(kFALSE);
117
118 fBreakPoints.clear();
119
120 fPathMarks.clear();
122 if (GetLockPoints() || otrack->Size() > 0)
123 {
125 fLastPMIdx = otrack->GetLastPMIdx();
126 }
127 else
128 {
130 }
131 if (Size() == 0) return; // All points can be outside of MaxR / MaxZ limits.
132
133 // Break segments additionally if required by the projection.
134 ReduceSegmentLengths(projection->GetMaxTrackStep());
135
136 // Project points, store originals (needed for break-points).
137 Float_t *p = GetP();
138 fOrigPnts = new TEveVector[Size()];
139 for (Int_t i = 0; i < Size(); ++i, p+=3)
140 {
141 if (trans) trans->MultiplyIP(p);
142 fOrigPnts[i].Set(p);
143 projection->ProjectPointfv(p, fDepth);
144 }
145
146 Float_t x, y, z;
147 Int_t bL = 0, bR = GetBreakPointIdx(0);
148 std::vector<TEveVector> vvec;
149 while (kTRUE)
150 {
151 for (Int_t i=bL; i<=bR; i++)
152 {
153 GetPoint(i, x, y, z);
154 vvec.push_back(TEveVector(x, y, z));
155 }
156 if (bR == fLastPoint)
157 break;
158
160 TEveVector vR = fOrigPnts[bR + 1];
161 projection->BisectBreakPoint(vL, vR, kTRUE, fDepth);
162 vvec.push_back(vL);
163 fBreakPoints.push_back((Int_t)vvec.size());
164 vvec.push_back(vR);
165
166 bL = bR + 1;
168 }
169 fBreakPoints.push_back((Int_t)vvec.size()); // Mark the track-end for drawing.
170
171 // Decide if points need to be fixed.
172 // This (and the fixing itself) should really be done in TEveProjection but
173 // for now we do it here as RhoZ is the only one that needs it.
175 Float_t sign_y = 0;
176 if (projection->HasSeveralSubSpaces())
177 {
179 {
181 {
182 fix_y = kTRUE;
183 sign_y = vvec.front().fY;
184 break;
185 }
187 {
188 fix_y = kTRUE;
189 sign_y = vvec.back().fY;
190 break;
191 }
192 }
193 }
194
195 Reset((Int_t)vvec.size());
196 for (std::vector<TEveVector>::iterator i=vvec.begin(); i!=vvec.end(); ++i)
197 {
198 if (fix_y)
199 SetNextPoint((*i).fX, TMath::Sign((*i).fY, sign_y), (*i).fZ);
200 else
201 SetNextPoint((*i).fX, (*i).fY, (*i).fZ);
202 }
203 delete [] fOrigPnts; fOrigPnts = nullptr;
204
205 // Project path-marks
206 for (vPathMark_i pm = fPathMarks.begin(); pm != fPathMarks.end(); ++pm)
207 {
208 projection->ProjectPointdv(trans, pm->fV.Arr(), pm->fV.Arr(), fDepth);
209 }
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Print line segments info.
214
216{
217 printf("%s LineSegments:\n", GetName());
218 Int_t start = 0;
219 Int_t segment = 0;
222 for (std::vector<Int_t>::iterator bpi = fBreakPoints.begin();
223 bpi != fBreakPoints.end(); ++bpi)
224 {
225 Int_t size = *bpi - start;
226
227 GetPoint(start, sVec.fX, sVec.fY, sVec.fZ);
228 GetPoint((*bpi)-1, bPnt.fX, bPnt.fY, bPnt.fZ);
229 printf("seg %d size %d start %d ::(%f, %f, %f) (%f, %f, %f)\n",
230 segment, size, start, sVec.fX, sVec.fY, sVec.fZ,
231 bPnt.fX, bPnt.fY, bPnt.fZ);
232 start += size;
233 segment ++;
234 }
235}
236
237////////////////////////////////////////////////////////////////////////////////
238/// Virtual method from from base-class TEveTrack.
239
241{
242 TEveTrack* t = dynamic_cast<TEveTrack*>(fProjectable);
243 if (t)
244 t->SecSelected(t);
245}
246
247
248/** \class TEveTrackListProjected
249\ingroup TEve
250Specialization of TEveTrackList for holding TEveTrackProjected objects.
251*/
252
253
254////////////////////////////////////////////////////////////////////////////////
255/// Default constructor.
256
262
263////////////////////////////////////////////////////////////////////////////////
264/// This is virtual method from base-class TEveProjected.
265
267{
269 CopyVizParams(dynamic_cast<TEveElement*>(model));
270
271 TEveTrackList& tl = * dynamic_cast<TEveTrackList*>(model);
272 SetPropagator(tl.GetPropagator());
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// This is not needed for functionality as SetDepth(Float_t d)
277/// is overriden -- but SetDepthLocal() is abstract.
278/// Just emits a warning if called.
279
281{
282 Warning("SetDepthLocal", "This function only exists to fulfill an abstract interface.");
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Set depth of all children inheriting from TEveTrackProjected.
287
292
293////////////////////////////////////////////////////////////////////////////////
294/// Set depth of all children of el inheriting from TEveTrackProjected.
295
297{
299 for (List_i i = el->BeginChildren(); i != el->EndChildren(); ++i)
300 {
301 ptrack = dynamic_cast<TEveTrackProjected*>(*i);
302 if (ptrack)
303 ptrack->SetDepth(d);
304 if (fRecurse)
305 SetDepth(d, *i);
306 }
307}
#define d(i)
Definition RSha256.hxx:102
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
TEveVectorT< Float_t > TEveVector
Definition TEveVector.h:123
winID h TVirtualViewer3D TVirtualGLPainter p
const_iterator begin() const
const_iterator end() const
Float_t * fBBox
Definition TAttBBox.h:20
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
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:182
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.
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.
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.
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.
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:1057
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:176