Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveTrackPropagator.h
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#ifndef ROOT_TEveTrackPropagator
13#define ROOT_TEveTrackPropagator
14
15#include "TEveVector.h"
16#include "TEvePathMark.h"
17#include "TEveUtil.h"
18#include "TEveElement.h"
19#include "TMarker.h"
20
21#include <vector>
22
23class TEvePointSet;
24
25
26//==============================================================================
27// TEveMagField
28//==============================================================================
29
31{
32protected:
34
35public:
37 virtual ~TEveMagField() {}
38
39 virtual Bool_t IsConst() const { return fFieldConstant; }
40
41 virtual void PrintField(Double_t x, Double_t y, Double_t z) const
42 {
43 TEveVector b = GetField(x, y, z);
44 printf("v(%f, %f, %f) B(%f, %f, %f) \n", x, y, z, b.fX, b.fY, b.fZ);
45 }
46
47 // Track propagator uses only GetFieldD() and GetMaxFieldMagD().
48 //
49 // Here, in this base-class, we have to keep float versions GetField() and GetMaxFieldMag() as
50 // primary sources of field data (for backward compatibility in ALICE and CMS).
51 //
52 // One only needs to redefine the double versions in subclasses.
53
54 virtual Double_t GetMaxFieldMagD() const { return GetMaxFieldMag(); }
55 virtual TEveVectorD GetFieldD(Double_t x, Double_t y, Double_t z) const { return GetField(x, y, z); }
56
57 TEveVectorD GetFieldD(const TEveVectorD &v) const { return GetFieldD(v.fX, v.fY, v.fZ); }
58
59 virtual Float_t GetMaxFieldMag() const { return 4; }
60 virtual TEveVector GetField(Float_t, Float_t, Float_t) const { return TEveVector(); }
61
62 ClassDef(TEveMagField, 0); // Abstract interface to magnetic field
63};
64
65
66//==============================================================================
67// TEveMagFieldConst
68//==============================================================================
69
71{
72protected:
74
75public:
77 TEveMagField(), fB(x, y, z)
79 virtual ~TEveMagFieldConst() {}
80
81 virtual Double_t GetMaxFieldMagD() const { return fB.Mag(); };
82 virtual TEveVectorD GetFieldD(Double_t /*x*/, Double_t /*y*/, Double_t /*z*/) const { return fB; }
83
84 ClassDef(TEveMagFieldConst, 0); // Interface to constant magnetic field.
85};
86
87
88//==============================================================================
89// TEveMagFieldDuo
90//==============================================================================
91
93{
94protected:
98
99public:
101 TEveMagField(),
102 fBIn(0,0,bIn), fBOut(0,0,bOut), fR2(r*r)
103 {
105 }
106 virtual ~TEveMagFieldDuo() {}
107
108 virtual Double_t GetMaxFieldMagD() const { return std::max(fBIn.Mag(), fBOut.Mag()); }
109
111 { return ((x*x+y*y)<fR2) ? fBIn : fBOut; }
112
113 ClassDef(TEveMagFieldDuo, 0); // Interface to magnetic field with two different values depending on radius.
114};
115
116
117//==============================================================================
118// TEveTrackPropagator
119//==============================================================================
120
122 public TEveRefBackPtr
123{
125
126public:
128
130
131protected:
132 struct Helix_t
133 {
134 Int_t fCharge; // Charge of tracked particle.
135 Double_t fMaxAng; // Maximum step angle.
136 Double_t fMaxStep; // Maximum allowed step size.
137 Double_t fDelta; // Maximum error in the middle of the step.
138
139 Double_t fPhi; // Accumulated angle to check fMaxOrbs by propagator.
140 Bool_t fValid; // Corner case pT~0 or B~0, possible in variable mag field.
141
142 // ----------------------------------------------------------------
143
144 // helix parameters
145 Double_t fLam; // Momentum ratio pT/pZ.
146 Double_t fR; // Helix radius in cm.
147 Double_t fPhiStep; // Caluclated from fMinAng and fDelta.
148 Double_t fSin, fCos; // Current sin/cos(phistep).
149
150 // Runge-Kutta parameters
151 Double_t fRKStep; // Step for Runge-Kutta.
152
153 // cached
154 TEveVectorD fB; // Current magnetic field, cached.
155 TEveVectorD fE1, fE2, fE3; // Base vectors: E1 -> B dir, E2->pT dir, E3 = E1xE2.
156 TEveVectorD fPt, fPl; // Transverse and longitudinal momentum.
157 Double_t fPtMag; // Magnitude of pT.
158 Double_t fPlMag; // Momentum parallel to mag field.
159 Double_t fLStep; // Transverse step arc-length in cm.
160
161 // ----------------------------------------------------------------
162
163 Helix_t();
164
165 void UpdateCommon(const TEveVectorD & p, const TEveVectorD& b);
166 void UpdateHelix (const TEveVectorD & p, const TEveVectorD& b, Bool_t full_update, Bool_t enforce_max_step);
167 void UpdateRK (const TEveVectorD & p, const TEveVectorD& b);
168
169 void Step(const TEveVector4D& v, const TEveVectorD& p, TEveVector4D& vOut, TEveVectorD& pOut);
170
172 Double_t GetStep2() { return fLStep * fLStep * (1 + fLam*fLam); }
173 };
174
175
176private:
177 TEveTrackPropagator(const TEveTrackPropagator&); // Not implemented
179
180 void DistributeOffset(const TEveVectorD& off, Int_t first_point, Int_t np, TEveVectorD& p);
181
182protected:
184
187
188 // Track extrapolation limits
189 Double_t fMaxR; // Max radius for track extrapolation
190 Double_t fMaxZ; // Max z-coordinate for track extrapolation.
191 Int_t fNMax; // Max steps
192 // Helix limits
193 Double_t fMaxOrbs; // Maximal angular path of tracks' orbits (1 ~ 2Pi).
194
195 // Path-mark / first-vertex control
196 Bool_t fEditPathMarks; // Show widgets for path-mark control in GUI editor.
197 Bool_t fFitDaughters; // Pass through daughter creation points when extrapolating a track.
198 Bool_t fFitReferences; // Pass through given track-references when extrapolating a track.
199 Bool_t fFitDecay; // Pass through decay point when extrapolating a track.
200 Bool_t fFitCluster2Ds; // Pass through 2D-clusters when extrapolating a track.
201 Bool_t fFitLineSegments; // Pass through line when extrapolating a track.
202 Bool_t fRnrDaughters; // Render daughter path-marks.
203 Bool_t fRnrReferences; // Render track-reference path-marks.
204 Bool_t fRnrDecay; // Render decay path-marks.
205 Bool_t fRnrCluster2Ds; // Render 2D-clusters.
206 Bool_t fRnrFV; // Render first vertex.
207 TMarker fPMAtt; // Marker attributes for rendering of path-marks.
208 TMarker fFVAtt; // Marker attributes for fits vertex.
209
210 // Handling of discontinuities in projections
211 UChar_t fProjTrackBreaking; // Handling of projected-track breaking.
212 Bool_t fRnrPTBMarkers; // Render break-points on tracks.
213 TMarker fPTBAtt; // Marker attributes for track break-points.
214
215 // ----------------------------------------------------------------
216
217 // Propagation, state of current track
218 std::vector<TEveVector4D> fPoints; // Calculated point.
219 std::vector<TEveVector4D> fLastPoints; // Copy of the latest calculated points.
220 TEveVectorD fV; // Start vertex.
221 Helix_t fH; // Helix.
222
223 void RebuildTracks();
224 void Update(const TEveVector4D& v, const TEveVectorD& p, Bool_t full_update=kFALSE, Bool_t enforce_max_step=kFALSE);
225 void Step(const TEveVector4D &v, const TEveVectorD &p, TEveVector4D &vOut, TEveVectorD &pOut);
226
229 void LoopToBounds(TEveVectorD& p);
230
232 void LineToBounds (TEveVectorD& p);
233
234 void StepRungeKutta(Double_t step, Double_t* vect, Double_t* vout);
235
236 Bool_t HelixIntersectPlane(const TEveVectorD& p, const TEveVectorD& point, const TEveVectorD& normal,
237 TEveVectorD&itsect);
238 Bool_t LineIntersectPlane(const TEveVectorD& p, const TEveVectorD& point, const TEveVectorD& normal,
239 TEveVectorD& itsect);
241
244
245public:
246 TEveTrackPropagator(const char* n="TEveTrackPropagator", const char* t="",
247 TEveMagField* field=0, Bool_t own_field=kTRUE);
248 virtual ~TEveTrackPropagator();
249
250 virtual void OnZeroRefCount();
251
252 virtual void CheckReferenceCount(const TEveException& eh="TEveElement::CheckReferenceCount ");
253
254 virtual void ElementChanged(Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE);
255
256 // propagation
257 void InitTrack(const TEveVectorD& v, Int_t charge);
258 void ResetTrack();
259
260 Int_t GetCurrentPoint() const;
261 Double_t GetTrackLength(Int_t start_point=0, Int_t end_point=-1) const;
262
263 virtual void GoToBounds(TEveVectorD& p);
265 virtual Bool_t GoToLineSegment(const TEveVectorD& s, const TEveVectorD& r, TEveVectorD& p);
266
267 // TEveVectorF wrappers
268 void InitTrack(const TEveVectorF& v, Int_t charge);
269 void GoToBounds(TEveVectorF& p);
272
273 Bool_t IntersectPlane(const TEveVectorD& p, const TEveVectorD& point, const TEveVectorD& normal,
274 TEveVectorD& itsect);
275
276 void FillPointSet(TEvePointSet* ps) const;
277
279
280 void SetMagField(Double_t bX, Double_t bY, Double_t bZ);
282 void SetMagFieldObj(TEveMagField* field, Bool_t own_field=kTRUE);
283
284 void SetMaxR(Double_t x);
285 void SetMaxZ(Double_t x);
286 void SetMaxOrbs(Double_t x);
287 void SetMinAng(Double_t x);
288 void SetMaxAng(Double_t x);
289 void SetMaxStep(Double_t x);
290 void SetDelta(Double_t x);
291
295 void SetRnrDecay(Bool_t x);
299 void SetFitDecay(Bool_t x);
302 void SetRnrFV(Bool_t x);
305
307 void PrintMagField(Double_t x, Double_t y, Double_t z) const;
308
309 EStepper_e GetStepper() const { return fStepper;}
310
311 Double_t GetMaxR() const { return fMaxR; }
312 Double_t GetMaxZ() const { return fMaxZ; }
313 Double_t GetMaxOrbs() const { return fMaxOrbs; }
314 Double_t GetMinAng() const;
315 Double_t GetMaxAng() const { return fH.fMaxAng; }
316 Double_t GetMaxStep() const { return fH.fMaxStep; }
317 Double_t GetDelta() const { return fH.fDelta; }
318
322 Bool_t GetRnrDecay() const { return fRnrDecay; }
326 Bool_t GetFitDecay() const { return fFitDecay; }
329 Bool_t GetRnrFV() const { return fRnrFV; }
332
333 TMarker& RefPMAtt() { return fPMAtt; }
334 TMarker& RefFVAtt() { return fFVAtt; }
335 TMarker& RefPTBAtt() { return fPTBAtt; }
336
337 const std::vector<TEveVector4D>& GetLastPoints() const { return fLastPoints; }
338
339 static Bool_t IsOutsideBounds(const TEveVectorD& point, Double_t maxRsqr, Double_t maxZ);
340
341 static Double_t fgDefMagField; // Default value for constant solenoid magnetic field.
342 static const Double_t fgkB2C; // Constant for conversion of momentum to curvature.
343 static TEveTrackPropagator fgDefault; // Default track propagator.
344
345 static Double_t fgEditorMaxR; // Max R that can be set in GUI editor.
346 static Double_t fgEditorMaxZ; // Max Z that can be set in GUI editor.
347
348 ClassDef(TEveTrackPropagator, 0); // Calculates path of a particle taking into account special path-marks and imposed boundaries.
349};
350
351//______________________________________________________________________________
353 Double_t maxRsqr,
354 Double_t maxZ)
355{
356 // Return true if point% is outside of cylindrical bounds detrmined by
357 // square radius and z.
358
359 return TMath::Abs(point.fZ) > maxZ ||
360 point.fX*point.fX + point.fY*point.fY > maxRsqr;
361}
362
363//______________________________________________________________________________
365 const TEveVector4D &v,
366 Double_t *p)
367{
368 static const Double_t kMinPl = 1e-5;
369
370 TEveVectorD dv; dv.Sub(v0, v);
371
372 Double_t dotV;
373
374 if (TMath::Abs(fH.fPlMag) > kMinPl)
375 {
376 // Use longitudinal momentum to determine crossing point.
377 // Works ok for spiraling helices, also for loopers.
378
379 dotV = fH.fE1.Dot(dv);
380 if (fH.fPlMag < 0)
381 dotV = -dotV;
382 }
383 else
384 {
385 // Use full momentum, which is pT, under this conditions.
386
387 dotV = fH.fE2.Dot(dv);
388 }
389
390 if (p)
391 *p = dotV;
392
393 return dotV < 0;
394}
395
396#endif
ROOT::R::TRInterface & r
Definition Object.C:4
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define e(i)
Definition RSha256.hxx:103
unsigned char UChar_t
Definition RtypesCore.h:38
const Bool_t kFALSE
Definition RtypesCore.h:92
bool Bool_t
Definition RtypesCore.h:63
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassDef(name, id)
Definition Rtypes.h:325
TEveVectorT< Float_t > TEveVector
Definition TEveVector.h:123
A list of TEveElements.
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
Implements constant magnetic field, given by a vector fB.
virtual TEveVectorD GetFieldD(Double_t, Double_t, Double_t) const
virtual Double_t GetMaxFieldMagD() const
TEveMagFieldConst(Double_t x, Double_t y, Double_t z)
Implements constant magnetic filed that switches on given axial radius fR2 from vector fBIn to fBOut.
virtual Double_t GetMaxFieldMagD() const
TEveMagFieldDuo(Double_t r, Double_t bIn, Double_t bOut)
virtual TEveVectorD GetFieldD(Double_t x, Double_t y, Double_t) const
Abstract base-class for interfacing to magnetic field needed by the TEveTrackPropagator.
virtual TEveVector GetField(Float_t, Float_t, Float_t) const
virtual Bool_t IsConst() const
virtual ~TEveMagField()
virtual Float_t GetMaxFieldMag() const
virtual void PrintField(Double_t x, Double_t y, Double_t z) const
virtual TEveVectorD GetFieldD(Double_t x, Double_t y, Double_t z) const
TEveVectorD GetFieldD(const TEveVectorD &v) const
virtual Double_t GetMaxFieldMagD() const
TEvePointSet is a render-element holding a collection of 3D points with optional per-point TRef and a...
Base-class for reference-counted objects with reverse references to TEveElement objects.
Definition TEveUtil.h:187
Sub-editor for TEveTrackPropagator class.
Holding structure for a number of track rendering parameters.
Bool_t GetFitCluster2Ds() const
Double_t GetMaxAng() const
virtual void GoToBounds(TEveVectorD &p)
Propagate particle to bounds.
void SetFitReferences(Bool_t x)
Set track-reference fitting and rebuild tracks.
void SetRnrDecay(Bool_t x)
Set decay rendering and rebuild tracks.
void SetRnrDaughters(Bool_t x)
Set daughter rendering and rebuild tracks.
void SetFitLineSegments(Bool_t x)
Set line segment fitting and rebuild tracks.
void ResetTrack()
Reset cache holding particle trajectory.
Bool_t GetFitDaughters() const
void SetMagFieldObj(TEveMagField *field, Bool_t own_field=kTRUE)
Set constant magnetic field and rebuild tracks.
Double_t GetDelta() const
EStepper_e GetStepper() const
Bool_t HelixIntersectPlane(const TEveVectorD &p, const TEveVectorD &point, const TEveVectorD &normal, TEveVectorD &itsect)
Intersect helix with a plane.
void StepRungeKutta(Double_t step, Double_t *vect, Double_t *vout)
Wrapper to step with method RungeKutta.
void SetDelta(Double_t x)
Set maximum error and rebuild tracks.
Bool_t IntersectPlane(const TEveVectorD &p, const TEveVectorD &point, const TEveVectorD &normal, TEveVectorD &itsect)
Find intersection of currently propagated track with a plane.
Bool_t GetRnrDaughters() const
void DistributeOffset(const TEveVectorD &off, Int_t first_point, Int_t np, TEveVectorD &p)
Distribute offset between first and last point index and rotate momentum.
Bool_t GetFitLineSegments() const
static Bool_t IsOutsideBounds(const TEveVectorD &point, Double_t maxRsqr, Double_t maxZ)
void ClosestPointFromVertexToLineSegment(const TEveVectorD &v, const TEveVectorD &s, const TEveVectorD &r, Double_t rMagInv, TEveVectorD &c)
Get closest point from given vertex v to line segment defined with s and r.
void Step(const TEveVector4D &v, const TEveVectorD &p, TEveVector4D &vOut, TEveVectorD &pOut)
Wrapper to step helix.
void SetMaxR(Double_t x)
Set maximum radius and rebuild tracks.
Double_t GetTrackLength(Int_t start_point=0, Int_t end_point=-1) const
Calculate track length from start_point to end_point.
void SetFitDaughters(Bool_t x)
Set daughter creation point fitting and rebuild tracks.
TEveTrackPropagator(const TEveTrackPropagator &)
virtual Bool_t GoToVertex(TEveVectorD &v, TEveVectorD &p)
Propagate particle with momentum p to vertex v.
static Double_t fgEditorMaxZ
Bool_t PointOverVertex(const TEveVector4D &v0, const TEveVector4D &v, Double_t *p=0)
void LineToBounds(TEveVectorD &p)
Propagate neutral particle with momentum p to bounds.
Bool_t GetRnrCluster2Ds() const
Int_t GetCurrentPoint() const
Get index of current point on track.
virtual ~TEveTrackPropagator()
Destructor.
TEveVectorD GetMagField(Double_t x, Double_t y, Double_t z)
static Double_t fgDefMagField
TEveTrackPropagator & operator=(const TEveTrackPropagator &)
Bool_t GetFitReferences() const
UChar_t GetProjTrackBreaking() const
void SetStepper(EStepper_e s)
void Update(const TEveVector4D &v, const TEveVectorD &p, Bool_t full_update=kFALSE, Bool_t enforce_max_step=kFALSE)
Update helix / B-field projection state.
void FillPointSet(TEvePointSet *ps) const
Reset ps and populate it with points in propagation cache.
virtual void OnZeroRefCount()
Virtual from TEveRefBackPtr - track reference count has reached zero.
void SetRnrFV(Bool_t x)
Set first-vertex rendering and rebuild tracks.
void SetProjTrackBreaking(UChar_t x)
Set projection break-point mode and rebuild tracks.
Bool_t ClosestPointBetweenLines(const TEveVectorD &, const TEveVectorD &, const TEveVectorD &, const TEveVectorD &, TEveVectorD &out)
Get closest point on line defined with vector p0 and u.
void SetMinAng(Double_t x)
Set maximum step angle and rebuild tracks.
void LoopToBounds(TEveVectorD &p)
Propagate charged particle with momentum p to bounds.
void SetEditPathMarks(Bool_t x)
static TEveTrackPropagator fgDefault
Bool_t LineIntersectPlane(const TEveVectorD &p, const TEveVectorD &point, const TEveVectorD &normal, TEveVectorD &itsect)
Intersect line with a plane.
void SetRnrCluster2Ds(Bool_t x)
Set rendering of 2D-clusters and rebuild tracks.
std::vector< TEveVector4D > fPoints
Double_t GetMaxStep() const
virtual Bool_t GoToLineSegment(const TEveVectorD &s, const TEveVectorD &r, TEveVectorD &p)
Propagate particle with momentum p to line with start point s and vector r to the second point.
void SetRnrReferences(Bool_t x)
Set track-reference rendering and rebuild tracks.
Bool_t GetRnrPTBMarkers() const
static Double_t fgEditorMaxR
Bool_t GetEditPathMarks() const
void SetMaxAng(Double_t x)
Set maximum step angle and rebuild tracks.
Bool_t LineToVertex(TEveVectorD &v)
Propagate neutral particle to vertex v.
void InitTrack(const TEveVectorD &v, Int_t charge)
Initialize internal data-members for given particle parameters.
virtual void ElementChanged(Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE)
Element-change notification.
static const Double_t fgkB2C
void SetMaxStep(Double_t x)
Set maximum step-size and rebuild tracks.
void SetFitCluster2Ds(Bool_t x)
Set 2D-cluster fitting and rebuild tracks.
void SetMagField(Double_t b)
std::vector< TEveVector4D > fLastPoints
Bool_t LoopToLineSegment(const TEveVectorD &s, const TEveVectorD &r, TEveVectorD &p)
Propagate charged particle with momentum p to line segment with point s and vector r to the second po...
Double_t GetMaxOrbs() const
Double_t GetMinAng() const
Get maximum step angle.
void PrintMagField(Double_t x, Double_t y, Double_t z) const
void RebuildTracks()
Rebuild all tracks using this render-style.
void SetRnrPTBMarkers(Bool_t x)
Set projection break-point rendering and rebuild tracks.
virtual void CheckReferenceCount(const TEveException &eh="TEveElement::CheckReferenceCount ")
Check reference count - virtual from TEveElement.
Bool_t LoopToVertex(TEveVectorD &v, TEveVectorD &p)
Propagate charged particle with momentum p to vertex v.
void SetMaxZ(Double_t x)
Set maximum z and rebuild tracks.
void SetFitDecay(Bool_t x)
Set decay fitting and rebuild tracks.
const std::vector< TEveVector4D > & GetLastPoints() const
Bool_t GetRnrReferences() const
void SetMaxOrbs(Double_t x)
Set maximum number of orbits and rebuild tracks.
void SetMagField(Double_t bX, Double_t bY, Double_t bZ)
Set constant magnetic field and rebuild tracks.
Minimal, templated four-vector.
Definition TEveVector.h:243
TT Dot(const TEveVectorT &a) const
Definition TEveVector.h:168
TT Mag() const
Definition TEveVector.h:99
TEveVectorT & Sub(const TEveVectorT &a, const TEveVectorT &b)
Definition TEveVector.h:186
Manages Markers.
Definition TMarker.h:22
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Double_t Sqrt(Double_t x)
Definition TMath.h:691
Short_t Abs(Short_t d)
Definition TMathBase.h:120
void UpdateRK(const TEveVectorD &p, const TEveVectorD &b)
Update helix for stepper RungeKutta.
void UpdateHelix(const TEveVectorD &p, const TEveVectorD &b, Bool_t full_update, Bool_t enforce_max_step)
Update helix parameters.
void Step(const TEveVector4D &v, const TEveVectorD &p, TEveVector4D &vOut, TEveVectorD &pOut)
Step helix for given momentum p from vertex v.
void UpdateCommon(const TEveVectorD &p, const TEveVectorD &b)
Common update code for helix and RK propagation.