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