Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveTrackProjected.cxx
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
15#include <ROOT/REveTrans.hxx>
17
18using namespace ROOT::Experimental;
19
20/** \class REveTrackProjected
21\ingroup REve
22Projected copy of a REveTrack.
23
24A projection with several sub-spaces, RhoZ, breaks the track where it
25crosses from one to the other: MakeTrack() ends the piece at the bisected
26point on one side and starts the next one at the point on the other side.
27fBreakPoints holds the index of the first point of each piece after the
28first, and the number of points as the end of the last.
29
30The render data is REveLine's entry `pos` with one range per piece, from
31fBreakPoints. The client does not join the last point of a piece to the
32first point of the next.
33*/
34
35REveTrackProjected::~REveTrackProjected()
36{
37 if (fOrigPnts) {
38 delete [] fOrigPnts;
39 fOrigPnts = nullptr;
40 }
41}
42
43
44////////////////////////////////////////////////////////////////////////////////
45/// This is virtual method from base-class REveProjected.
46
48{
50 CopyVizParams(dynamic_cast<REveElement*>(model));
51
52 REveTrack* otrack = dynamic_cast<REveTrack*>(fProjectable);
53 SetTrackParams(*otrack);
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// Set depth (z-coordinate) of the projected points.
59
61{
62 SetDepthCommon(d, this);
63
64 for (Int_t i = 0; i < fSize; ++i)
65 {
66 fPoints[i].fZ = fDepth;
67 }
68
69 for (auto &pm: fPathMarks)
70 {
71 pm.fV.fZ = fDepth;
72 }
73}
74
75////////////////////////////////////////////////////////////////////////////////
76/// Virtual method from base-class REveProjected.
77
79{
80 MakeTrack(kFALSE); // REveProjectionManager makes recursive calls
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Find index of the last point that lies within the same
85/// segment of projected space.
86/// For example, rho-z projection separates upper and lower hemisphere
87/// and tracks break into two lines when crossing the y=0 plane.
88
90{
91 REveProjection *projection = fManager->GetProjection();
92
93 Int_t val = fSize - 1;
94
95 if (projection->HasSeveralSubSpaces())
96 {
98 if (fSize > 1)
99 {
100 Int_t i = start;
101 while (i < fSize - 1)
102 {
103 v1 = RefPoint(i);
104 v2 = RefPoint(i+1);
105 if(projection->AcceptSegment(v1, v2, fPropagator->GetDelta()) == kFALSE)
106 {
107 val = i;
108 break;
109 }
110 i++;
111 }
112 }
113 }
114 return val;
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Calculate the points of the track for drawing.
119/// Call base-class, project, find break-points and insert points
120/// required for full representation.
121
123{
124 REveTrack *otrack = dynamic_cast<REveTrack*>(fProjectable);
125 REveTrans mt;
126 const REveTrans *trans = fManager->GetModelTrans(otrack, mt);
127 REveProjection *projection = fManager->GetProjection();
128
129 fBreakPoints.clear();
130
131 fPathMarks.clear();
132 SetPathMarks(*otrack);
133 if (GetLockPoints() || otrack->GetSize() > 0)
134 {
135 ClonePoints(*otrack);
136 fLastPMIdx = otrack->GetLastPMIdx();
137 }
138 else
139 {
140 REveTrack::MakeTrack(recurse);
141 }
142 if (fSize == 0) return; // All points can be outside of MaxR / MaxZ limits.
143
144 // Break segments additionally if required by the projection.
146 // XXXX This is stoopid. Need some more flaxible way od doing this.
147 // XXXX Make it dependant on projection parameters and on individual
148 // XXXX points (a function of r and z, eg).
149 // XXXX Also, we could represnet track with a bezier curve, trying
150 // XXXX to stretch it as far out as we can so the fewest number of
151 // XXXX points/directions needs to be transferred.
152
153 // Project points, store originals (needed for break-points).
154 Float_t *p = & fPoints[0].fX;
156 for (Int_t i = 0; i < fSize; ++i, p+=3)
157 {
158 if (trans) trans->MultiplyIP(p);
159 fOrigPnts[i].Set(p);
160 projection->ProjectPointfv(p, fDepth);
161 }
162
163 Int_t bL = 0, bR = GetBreakPointIdx(0);
164 std::vector<REveVector> vvec;
165 while (kTRUE)
166 {
167 for (Int_t i = bL; i <= bR; i++)
168 {
169 vvec.push_back( RefPoint(i) );
170 }
171 if (bR == fSize - 1)
172 break;
173
174 REveVector vL = fOrigPnts[bR];
175 REveVector vR = fOrigPnts[bR + 1];
176 projection->BisectBreakPoint(vL, vR, kTRUE, fDepth);
177 vvec.push_back(vL);
178 fBreakPoints.push_back((UInt_t)vvec.size());
179 vvec.push_back(vR);
180
181 bL = bR + 1;
182 bR = GetBreakPointIdx(bL);
183 }
184 fBreakPoints.push_back((UInt_t)vvec.size()); // Mark the track-end for drawing.
185
186 // Decide if points need to be fixed.
187 // This (and the fixing itself) should really be done in REveProjection but
188 // for now we do it here as RhoZ is the only one that needs it.
189 Bool_t fix_y = kFALSE;
190 Float_t sign_y = 0;
191 if (projection->HasSeveralSubSpaces())
192 {
194 {
196 {
197 fix_y = kTRUE;
198 sign_y = vvec.front().fY;
199 break;
200 }
202 {
203 fix_y = kTRUE;
204 sign_y = vvec.back().fY;
205 break;
206 }
207 }
208 }
209
210 Reset((Int_t)vvec.size());
211 for (auto &i: vvec)
212 {
213 if (fix_y)
214 SetNextPoint(i.fX, TMath::Sign(i.fY, sign_y), i.fZ);
215 else
216 SetNextPoint(i.fX, i.fY, i.fZ);
217 }
218 delete [] fOrigPnts;
219 fOrigPnts = nullptr;
220
221 // Project path-marks
222 for (auto &pm: fPathMarks)
223 {
224 projection->ProjectPointdv(trans, pm.fV.Arr(), pm.fV.Arr(), fDepth);
225 }
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Print line segments info.
230
232{
233 printf("%s LineSegments:\n", GetCName());
234
235 Int_t start = 0;
236 Int_t segment = 0;
237
238 for (auto &bpi: fBreakPoints)
239 {
240 Int_t size = bpi - start;
241
242 const REveVector &sVec = RefPoint(start);
243 const REveVector &bPnt = RefPoint(bpi-1);
244 printf("seg %d size %d start %d ::(%f, %f, %f) (%f, %f, %f)\n",
245 segment, size, start, sVec.fX, sVec.fY, sVec.fZ,
246 bPnt.fX, bPnt.fY, bPnt.fZ);
247 start += size;
248 segment++;
249 }
250}
251
252////////////////////////////////////////////////////////////////////////////////
253/// Virtual method from from base-class REveTrack.
254
256{
257 REveTrack* t = dynamic_cast<REveTrack*>(fProjectable);
258 if (t)
259 t->SecSelected(t);
260}
261
262
263/** \class REveTrackListProjected
264\ingroup REve
265Specialization of REveTrackList for holding REveTrackProjected objects.
266*/
267
268////////////////////////////////////////////////////////////////////////////////
269/// Default constructor.
270
276
277////////////////////////////////////////////////////////////////////////////////
278/// This is virtual method from base-class REveProjected.
279
281{
282 REveProjected::SetProjection(proj, model);
283 CopyVizParams(dynamic_cast<REveElement*>(model));
284
285 REveTrackList& tl = * dynamic_cast<REveTrackList*>(model);
287}
288
289////////////////////////////////////////////////////////////////////////////////
290/// This is not needed for functionality as SetDepth(Float_t d)
291/// is overriden -- but SetDepthLocal() is abstract.
292/// Just emits a warning if called.
293
295{
296 Warning("SetDepthLocal", "This function only exists to fulfill an abstract interface.");
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Set depth of all children inheriting from REveTrackProjected.
301
306
307////////////////////////////////////////////////////////////////////////////////
308/// Set depth of all children of el inheriting from REveTrackProjected.
309
311{
312 for (auto &c: el->RefChildren()) {
313 auto ptrack = dynamic_cast<REveTrackProjected *>(c);
314 if (ptrack)
315 ptrack->SetDepth(d);
316 if (fRecurse)
317 SetDepth(d, c);
318 }
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Write REveTrack's render data, the entry `pos`, with one range per piece
323/// between break points, see the class description. A track whose points
324/// were not made by MakeTrack() has no break points and no ranges, and is
325/// drawn as one piece.
326
328{
330
331 // REveLine leaves a previous render data in place when there are no points.
332 auto pos = (fSize > 0 && fRenderData) ? fRenderData->Find("pos") : nullptr;
333 if (!pos)
334 return;
335
336 UInt_t start = 0;
337 for (auto end : fBreakPoints) {
338 pos->Range(start, end - start);
339 start = end;
340 }
341}
#define d(i)
Definition RSha256.hxx:102
#define c(i)
Definition RSha256.hxx:101
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
winID h TVirtualViewer3D TVirtualGLPainter p
const char * GetCName() const
std::unique_ptr< REveRenderData > fRenderData
! Render data entries for the client's maker, see REveRenderData.
void ReduceSegmentLengths(Float_t max)
Make sure that no segment is longer than max.
Definition REveLine.cxx:172
virtual void ClonePoints(const REvePointSet &e)
Clone points and all point-related information from point-set 'e'.
std::vector< REveVector > fPoints
int SetNextPoint(float x, float y, float z)
void Reset(Int_t n_points=0)
Drop all data and set-up the data structures to recive new data.
virtual void SetProjection(REveProjectionManager *mng, REveProjectable *model)
Sets projection manager and reference in the projectable object.
void SetDepthCommon(Float_t d, REveElement *el)
Set the depth and stamp el for a rebuild.
virtual void SetDepth(Float_t d)
Set depth coordinate for the element.
REveProjectionManager Manager class for steering of projections and managing projected objects.
const REveTrans * GetModelTrans(REveElement *model, REveTrans &t)
Return the matrix that takes the coordinates of model into the frame of this manager,...
REveProjection Base for specific classes that implement non-linear projections.
void ProjectPointfv(Float_t *v, Float_t d)
Project float array.
void ProjectPointdv(Double_t *v, Float_t d)
Project double array.
virtual Bool_t HasSeveralSubSpaces() const
virtual Bool_t AcceptSegment(REveVector &, REveVector &, Float_t) const
virtual void BisectBreakPoint(REveVector &vL, REveVector &vR, Float_t eps_sqr)
Find break-point on both sides of the discontinuity.
void SetDepthLocal(Float_t d) override
This is not needed for functionality as SetDepth(Float_t d) is overriden – but SetDepthLocal() is abs...
void SetProjection(REveProjectionManager *proj, REveProjectable *model) override
This is virtual method from base-class REveProjected.
void SetDepth(Float_t d) override
Set depth of all children inheriting from REveTrackProjected.
REveTrackList A list of tracks supporting change of common attributes and selection based on track pa...
void CopyVizParams(const REveElement *el) override
Copy visualization parameters from element el.
void SetPropagator(REveTrackPropagator *prop)
Set default propagator for tracks.
REveTrackPropagator * GetPropagator()
REveTrackProjected Projected copy of a REveTrack.
void SecSelected(REveTrack *) override
Virtual method from from base-class REveTrack.
void SetDepthLocal(Float_t d) override
Set depth (z-coordinate) of the projected points.
void BuildRenderData() override
Write REveTrack's render data, the entry pos, with one range per piece between break points,...
void UpdateProjection() override
Virtual method from base-class REveProjected.
Int_t GetBreakPointIdx(Int_t start)
Find index of the last point that lies within the same segment of projected space.
void MakeTrack(Bool_t recurse=kTRUE) override
Calculate the points of the track for drawing.
void SetProjection(REveProjectionManager *mng, REveProjectable *model) override
This is virtual method from base-class REveProjected.
void PrintLineSegments()
Print line segments info.
REveTrack Track with given vertex, momentum and optional referece-points (path-marks) along its path.
Definition REveTrack.hxx:40
virtual void SecSelected(REveTrack *)
Emits "SecSelected(REveTrack*)" signal.
REveTrackPropagator * fPropagator
Definition REveTrack.hxx:68
Int_t fLastPMIdx
! Last path-mark index tried in track-propagation.
Definition REveTrack.hxx:66
virtual void SetTrackParams(const REveTrack &t)
Copy track parameters from t.
virtual void MakeTrack(Bool_t recurse=kTRUE)
Calculate track representation based on track data and current settings of the propagator.
virtual void SetPathMarks(const REveTrack &t)
Copy path-marks from t.
void BuildRenderData() override
Crates 3D point array for rendering.
void CopyVizParams(const REveElement *el) override
Copy visualization parameters from element el.
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
void Set(const Float_t *v)
Namespace for ROOT features in testing.
Definition TROOT.h:100
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
Definition TMathBase.h:174