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
18
19using namespace ROOT::Experimental;
20
21/** \class REveTrackProjected
22\ingroup REve
23Projected copy of a REveTrack.
24*/
25
26
27REveTrackProjected::~REveTrackProjected()
28{
29 if (fOrigPnts) {
30 delete [] fOrigPnts;
31 fOrigPnts = nullptr;
32 }
33}
34
35
36////////////////////////////////////////////////////////////////////////////////
37/// This is virtual method from base-class REveProjected.
38
40{
42 CopyVizParams(dynamic_cast<REveElement*>(model));
43
44 REveTrack* otrack = dynamic_cast<REveTrack*>(fProjectable);
45 SetTrackParams(*otrack);
47}
48
49////////////////////////////////////////////////////////////////////////////////
50/// Set depth (z-coordinate) of the projected points.
51
53{
54 SetDepthCommon(d, this, fBBox);
55
56 for (Int_t i = 0; i < fSize; ++i)
57 {
58 fPoints[i].fZ = fDepth;
59 }
60
61 for (auto &pm: fPathMarks)
62 {
63 pm.fV.fZ = fDepth;
64 }
65}
66
67////////////////////////////////////////////////////////////////////////////////
68/// Virtual method from base-class REveProjected.
69
71{
72 MakeTrack(kFALSE); // REveProjectionManager makes recursive calls
73}
74
75////////////////////////////////////////////////////////////////////////////////
76/// Find index of the last point that lies within the same
77/// segment of projected space.
78/// For example, rho-z projection separates upper and lower hemisphere
79/// and tracks break into two lines when crossing the y=0 plane.
80
82{
83 REveProjection *projection = fManager->GetProjection();
84
85 Int_t val = fSize - 1;
86
87 if (projection->HasSeveralSubSpaces())
88 {
90 if (fSize > 1)
91 {
92 Int_t i = start;
93 while (i < fSize - 1)
94 {
95 v1 = RefPoint(i);
96 v2 = RefPoint(i+1);
97 if(projection->AcceptSegment(v1, v2, fPropagator->GetDelta()) == kFALSE)
98 {
99 val = i;
100 break;
101 }
102 i++;
103 }
104 }
105 }
106 return val;
107}
108
109////////////////////////////////////////////////////////////////////////////////
110/// Calculate the points of the track for drawing.
111/// Call base-class, project, find break-points and insert points
112/// required for full representation.
113
115{
116 REveTrack *otrack = dynamic_cast<REveTrack*>(fProjectable);
117 REveTrans *trans = otrack->PtrMainTrans(kFALSE);
118 REveProjection *projection = fManager->GetProjection();
119
120 fBreakPoints.clear();
121
122 fPathMarks.clear();
123 SetPathMarks(*otrack);
124 if (GetLockPoints() || otrack->GetSize() > 0)
125 {
126 ClonePoints(*otrack);
127 fLastPMIdx = otrack->GetLastPMIdx();
128 }
129 else
130 {
131 REveTrack::MakeTrack(recurse);
132 }
133 if (fSize == 0) return; // All points can be outside of MaxR / MaxZ limits.
134
135 // Break segments additionally if required by the projection.
137 // XXXX This is stoopid. Need some more flaxible way od doing this.
138 // XXXX Make it dependant on projection parameters and on individual
139 // XXXX points (a function of r and z, eg).
140 // XXXX Also, we could represnet track with a bezier curve, trying
141 // XXXX to stretch it as far out as we can so the fewest number of
142 // XXXX points/directions needs to be transferred.
143
144 // Project points, store originals (needed for break-points).
145 Float_t *p = & fPoints[0].fX;
147 for (Int_t i = 0; i < fSize; ++i, p+=3)
148 {
149 if (trans) trans->MultiplyIP(p);
150 fOrigPnts[i].Set(p);
151 projection->ProjectPointfv(p, fDepth);
152 }
153
154 Int_t bL = 0, bR = GetBreakPointIdx(0);
155 std::vector<REveVector> vvec;
156 while (kTRUE)
157 {
158 for (Int_t i = bL; i <= bR; i++)
159 {
160 vvec.push_back( RefPoint(i) );
161 }
162 if (bR == fSize - 1)
163 break;
164
165 REveVector vL = fOrigPnts[bR];
166 REveVector vR = fOrigPnts[bR + 1];
167 projection->BisectBreakPoint(vL, vR, kTRUE, fDepth);
168 vvec.push_back(vL);
169 fBreakPoints.push_back((UInt_t)vvec.size());
170 vvec.push_back(vR);
171
172 bL = bR + 1;
173 bR = GetBreakPointIdx(bL);
174 }
175 fBreakPoints.push_back((UInt_t)vvec.size()); // Mark the track-end for drawing.
176
177 // Decide if points need to be fixed.
178 // This (and the fixing itself) should really be done in REveProjection but
179 // for now we do it here as RhoZ is the only one that needs it.
180 Bool_t fix_y = kFALSE;
181 Float_t sign_y = 0;
182 if (projection->HasSeveralSubSpaces())
183 {
185 {
187 {
188 fix_y = kTRUE;
189 sign_y = vvec.front().fY;
190 break;
191 }
193 {
194 fix_y = kTRUE;
195 sign_y = vvec.back().fY;
196 break;
197 }
198 }
199 }
200
201 Reset((Int_t)vvec.size());
202 for (auto &i: vvec)
203 {
204 if (fix_y)
205 SetNextPoint(i.fX, TMath::Sign(i.fY, sign_y), i.fZ);
206 else
207 SetNextPoint(i.fX, i.fY, i.fZ);
208 }
209 delete [] fOrigPnts;
210 fOrigPnts = nullptr;
211
212 // Project path-marks
213 for (auto &pm: fPathMarks)
214 {
215 projection->ProjectPointdv(trans, pm.fV.Arr(), pm.fV.Arr(), fDepth);
216 }
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Print line segments info.
221
223{
224 printf("%s LineSegments:\n", GetCName());
225
226 Int_t start = 0;
227 Int_t segment = 0;
228
229 for (auto &bpi: fBreakPoints)
230 {
231 Int_t size = bpi - start;
232
233 const REveVector &sVec = RefPoint(start);
234 const REveVector &bPnt = RefPoint(bpi-1);
235 printf("seg %d size %d start %d ::(%f, %f, %f) (%f, %f, %f)\n",
236 segment, size, start, sVec.fX, sVec.fY, sVec.fZ,
237 bPnt.fX, bPnt.fY, bPnt.fZ);
238 start += size;
239 segment++;
240 }
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Virtual method from from base-class REveTrack.
245
247{
248 REveTrack* t = dynamic_cast<REveTrack*>(fProjectable);
249 if (t)
250 t->SecSelected(t);
251}
252
253
254/** \class REveTrackListProjected
255\ingroup REve
256Specialization of REveTrackList for holding REveTrackProjected objects.
257*/
258
259////////////////////////////////////////////////////////////////////////////////
260/// Default constructor.
261
263 REveTrackList (),
265{
266}
267
268////////////////////////////////////////////////////////////////////////////////
269/// This is virtual method from base-class REveProjected.
270
272{
273 REveProjected::SetProjection(proj, model);
274 CopyVizParams(dynamic_cast<REveElement*>(model));
275
276 REveTrackList& tl = * dynamic_cast<REveTrackList*>(model);
278}
279
280////////////////////////////////////////////////////////////////////////////////
281/// This is not needed for functionality as SetDepth(Float_t d)
282/// is overriden -- but SetDepthLocal() is abstract.
283/// Just emits a warning if called.
284
286{
287 Warning("SetDepthLocal", "This function only exists to fulfill an abstract interface.");
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Set depth of all children inheriting from REveTrackProjected.
292
294{
295 SetDepth(d, this);
296}
297
298////////////////////////////////////////////////////////////////////////////////
299/// Set depth of all children of el inheriting from REveTrackProjected.
300
302{
303 for (auto &c: el->RefChildren()) {
304 auto ptrack = dynamic_cast<REveTrackProjected *>(c);
305 if (ptrack)
306 ptrack->SetDepth(d);
307 if (fRecurse)
308 SetDepth(d, c);
309 }
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Creates client representation.
314
315Int_t REveTrackProjected::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
316{
317 Int_t ret = REveTrack::WriteCoreJson(j, rnr_offset);
318
319 j["render_data"]["break_point_size"] = fBreakPoints.size();
320
321 return ret;
322}
323
324////////////////////////////////////////////////////////////////////////////////
325/// Creates client rendering info.
326
328{
330
331 if (fRenderData && !fBreakPoints.empty()) {
332 fRenderData->Reserve(0, 0, fBreakPoints.size());
334 }
335}
#define d(i)
Definition RSha256.hxx:102
#define c(i)
Definition RSha256.hxx:101
const Bool_t kFALSE
Definition RtypesCore.h:92
const Bool_t kTRUE
Definition RtypesCore.h:91
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:231
const char * GetCName() const
std::unique_ptr< REveRenderData > fRenderData
Externally assigned and controlled user data.
virtual REveTrans * PtrMainTrans(Bool_t create=kTRUE)
Return pointer to main transformation.
void ReduceSegmentLengths(Float_t max)
Make sure that no segment is longer than max.
Definition REveLine.cxx:165
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, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
virtual void SetDepth(Float_t d)
Set depth coordinate for the element.
REveProjectionManager Manager class for steering of projections and managing projected objects.
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
Creates client rendering info.
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Creates client representation.
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
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Fill core part of JSON representation.
virtual void SecSelected(REveTrack *)
Emits "SecSelected(REveTrack*)" signal.
REveTrackPropagator * fPropagator
Last path-mark index tried in track-propagation.
Definition REveTrack.hxx:68
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)
Float_t * fBBox
Definition TAttBBox.h:20
T1 Sign(T1 a, T2 b)
Definition TMathBase.h:165