ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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"
14 #include "TEveProjectionManager.h"
15 #include "TEveTrans.h"
16 
17 /** \class TEveTrackProjected
18 \ingroup TEve
19 Projected copy of a TEveTrack.
20 */
21 
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 /// Default constructor.
26 
28  TEveTrack (),
29  fOrigPnts (0)
30 {
31 }
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// This is virtual method from base-class TEveProjected.
35 
37 {
38  TEveProjected::SetProjection(mng, model);
39  CopyVizParams(dynamic_cast<TEveElement*>(model));
40 
41  TEveTrack* otrack = dynamic_cast<TEveTrack*>(fProjectable);
42  SetTrackParams(*otrack);
43  SetLockPoints(otrack->GetLockPoints());
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  {
88  TEveVector v1, v2;
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.
135  ReduceSegmentLengths(projection->GetMaxTrackStep());
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 = 0;
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
251 Specialization of TEveTrackList for holding TEveTrackProjected objects.
252 */
253 
255 
256 ////////////////////////////////////////////////////////////////////////////////
257 /// Default constructor.
258 
260  TEveTrackList (),
261  TEveProjected ()
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 }
TEveTrackListProjected()
Default constructor.
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:26
Abstract base class for classes that hold results of a non-linear projection transformation.
List_i EndChildren()
Definition: TEveElement.h:165
Int_t fLastPMIdx
Definition: TEveTrack.h:62
virtual void SetDepthLocal(Float_t d)
Set depth (z-coordinate) of the projected points.
virtual void SetTrackParams(const TEveTrack &t)
Copy track parameters from t.
Definition: TEveTrack.cxx:282
const Double_t * v1
Definition: TArcBall.cxx:33
T1 Sign(T1 a, T2 b)
Definition: TMathBase.h:155
void Set(const Float_t *v)
Definition: TEveVector.h:52
float Float_t
Definition: RtypesCore.h:53
UChar_t GetProjTrackBreaking() const
Specialization of TEveTrackList for holding TEveTrackProjected objects.
virtual Int_t Size() const
Definition: TPolyMarker3D.h:81
void ProjectPointdv(Double_t *v, Float_t d)
Project double array.
virtual void SetProjection(TEveProjectionManager *proj, TEveProjectable *model)
This is virtual method from base-class TEveProjected.
List_t::iterator List_i
Definition: TEveElement.h:70
virtual void ClonePoints(const TEvePointSet &e)
Clone points and all point-related information from point-set 'e'.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
ClassImp(TEveTrackProjected)
TEveTrackPropagator * fPropagator
Last path-mark index tried in track-propagation.
Definition: TEveTrack.h:64
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
Sets projection manager and reference in the projectable 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...
Float_t * fBBox
Definition: TAttBBox.h:22
virtual const char * GetName() const
Returns name of object.
Definition: TPolyMarker3D.h:65
virtual void CopyVizParams(const TEveElement *el)
Copy visualization parameters from element el.
Definition: TEveTrack.cxx:1131
Int_t GetBreakPointIdx(Int_t start)
Find index of the last point that lies within the same segment of projected space.
Double_t x[n]
Definition: legend1.C:17
Int_t GetLastPMIdx() const
Definition: TEveTrack.h:85
Projected copy of a TEveTrack.
int d
Definition: tornado.py:11
virtual void MakeTrack(Bool_t recurse=kTRUE)
Calculate track representation based on track data and current settings of the propagator.
Definition: TEveTrack.cxx:338
A list of tracks supporting change of common attributes and selection based on track parameters...
Definition: TEveTrack.h:137
virtual void UpdateProjection()
Virtual method from base-class TEveProjected.
Base-class for non-linear projections.
Float_t z[5]
Definition: Ifit.C:16
virtual Float_t * GetP() const
Definition: TPolyMarker3D.h:67
Manager class for steering of projections and managing projected objects.
virtual void SetDepth(Float_t d)
Set depth coordinate for the element.
Abstract base-class for non-linear projectable objects.
TThread * t[5]
Definition: threadsh1.C:13
Float_t GetMaxTrackStep() const
TEveProjectable * fProjectable
TEveProjectionManager * fManager
virtual void SecSelected(TEveTrack *)
Virtual method from from base-class TEveTrack.
virtual void BisectBreakPoint(TEveVector &vL, TEveVector &vR, Float_t eps_sqr)
Find break-point on both sides of the discontinuity.
Bool_t GetLockPoints() const
Definition: TEveTrack.h:117
virtual void SecSelected(TEveTrack *)
Emits "SecSelected(TEveTrack*)" signal.
Definition: TEveTrack.cxx:548
void ReduceSegmentLengths(Float_t max)
Make sure that no segment is longer than max.
Definition: TEveLine.cxx:183
TEveTrackPropagator * GetPropagator()
Definition: TEveTrack.h:175
TEveTrackProjected()
Default constructor.
Visual representation of a track.
Definition: TEveTrack.h:32
virtual void SetDepthLocal(Float_t d)
This is not needed for functionality as SetDepth(Float_t d) is overriden – but SetDepthLocal() is abs...
void ProjectPointfv(Float_t *v, Float_t d)
Project float array.
TEveProjection * GetProjection()
virtual void SetDepth(Float_t d)
Set depth of all children inheriting from TEveTrackProjected.
Double_t GetDelta() const
virtual Int_t SetNextPoint(Double_t x, Double_t y, Double_t z)
Set point following LastPoint to x, y, z.
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
This is virtual method from base-class TEveProjected.
virtual void SetPathMarks(const TEveTrack &t)
Copy path-marks from t.
Definition: TEveTrack.cxx:299
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual void MakeTrack(Bool_t recurse=kTRUE)
Calculate the points of the track for drawing.
Double_t y[n]
Definition: legend1.C:17
vPathMark_t fPathMarks
Definition: TEveTrack.h:61
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.
TEveVectorT< Float_t > TEveVector
Definition: TEveVector.h:93
void PrintLineSegments()
Print line segments info.
void SetPropagator(TEveTrackPropagator *prop)
Set default propagator for tracks.
Definition: TEveTrack.cxx:625
virtual Bool_t AcceptSegment(TEveVector &, TEveVector &, Float_t) const
void SetDepthCommon(Float_t d, TEveElement *el, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
List_i BeginChildren()
Definition: TEveElement.h:164
virtual void CopyVizParams(const TEveElement *el)
Copy visualization parameters from element el.
Definition: TEveTrack.cxx:475
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
Definition: TEveTrans.cxx:729
void SetLockPoints(Bool_t l)
Definition: TEveTrack.h:116
virtual TEveTrans * PtrMainTrans(Bool_t create=kTRUE)
Return pointer to main transformation.
std::vector< Int_t > fBreakPoints
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Bool_t HasSeveralSubSpaces() const
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
const Int_t n
Definition: legend1.C:16
vPathMark_t::iterator vPathMark_i
Definition: TEveTrack.h:43
Bool_t fRecurse
Definition: TEveTrack.h:150
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904