57REveTrackPropagator::Helix_t::Helix_t() :
59 fMaxAng(45), fMaxStep(20.f), fDelta(0.1),
61 fLam(-1), fR(-1), fPhiStep(-1), fSin(-1), fCos(-1),
63 fPtMag(-1), fPlMag(-1), fLStep(-1)
96 if (fCharge > 0) fE3.NegateXYZ();
100 using namespace TMath;
102 if (
a > kAMin && fPtMag*fPtMag > kPtMinSqr)
106 fR =
Abs(fPtMag /
a);
107 fLam = fPlMag / fPtMag;
119 Double_t curr_step = fR * fPhiStep *
Sqrt(1.0f + fLam*fLam);
120 if (curr_step > fMaxStep || enforce_max_step)
121 fPhiStep *= fMaxStep / curr_step;
123 fLStep = fR * fPhiStep * fLam;
124 fSin =
Sin(fPhiStep);
125 fCos =
Cos(fPhiStep);
141 fValid = (fCharge != 0);
154 REveVectorD d = fE2*(fR*fSin) + fE3*(fR*(1-fCos)) + fE1*fLStep;
158 pOut = fPl + fE2*(fPtMag*fCos) + fE3*(fPtMag*fSin);
166 vOut += p * (fMaxStep / p.
Mag());
279 auto track =
dynamic_cast<REveTrack *
>(i.first);
332 if (end_point < 0) end_point =
fPoints.size() - 1;
335 for (
Int_t i = start_point; i < end_point; ++i)
349 if ((
v-
fV).
Mag() < kStepEps)
438 using namespace TMath;
487 vecRKIn[3] = p.
fX*
nm;
488 vecRKIn[4] = p.
fY*
nm;
489 vecRKIn[5] = p.
fZ*
nm;
490 vecRKIn[6] = p.
Mag();
495 vOut.
fX = vecRKOut[0];
496 vOut.
fY = vecRKOut[1];
497 vOut.
fZ = vecRKOut[2];
500 pOut.
fX = vecRKOut[3]*pm;
501 pOut.
fY = vecRKOut[4]*pm;
502 pOut.
fZ = vecRKOut[5]*pm;
523 Step(currV, p, forwV, forwP);
526 if (forwV.
Perp2() > maxRsq)
531 Warning(
"HelixToBounds",
"In MaxR crossing expected t>=0 && t<=1: t=%f, r1=%f, r2=%f, MaxR=%f.",
532 t, currV.
R(), forwV.
R(),
fMaxR);
549 Warning(
"HelixToBounds",
"In MaxZ crossing expected t>=0 && t<=1: t=%f, z1=%f, z2=%f, MaxZ=%f.",
582 Int_t np = first_point;
588 Step(currV, p, forwV, forwP);
607 }
while (np <
fNMax);
610 if (np > first_point)
612 if ((
v - currV).
Mag() > kStepEps)
614 Double_t step_frac = prod0 / (prod0 - prod1);
622 Step(currV, p, forwV, forwP);
633 off *= 1.0f / currV.
fT;
660 Int_t np = first_point;
666 Step(currV, p, forwV, forwP);
676 if (pTPM.
Dot(forwC - forwV) < 0)
692 }
while (np <
fNMax);
699 if (np > first_point)
701 if ((
v - currV).
Mag() > kStepEps)
713 Step(currV, p, forwV, forwP);
724 off *= 1.0f / currV.fT;
748 for (
Int_t i = first_point; i < np; ++i)
758 tt.SetupFromToVec(lpd0, lpd1);
806 tR = (-
b - sqrtD) / (2.0 *
a);
808 tR = (-
b + sqrtD) / (2.0 *
a);
810 tB = tR < tZ ? tR : tZ;
846 Step(pos4, mom, forwV , forwP);
851 Warning(
"HelixIntersectPlane",
"going away from the plane.");
856 delta = forwV - pos4;
857 itsect = pos4 + delta * ((point - pos4).
Dot(
n) / delta.
Dot(
n));
959 Bool_t force = (x < 0 || x > 1);
971 for (
Int_t i = 0; i < size; ++i)
974 ps->SetNextPoint(
v.fX,
v.fY,
v.fZ);
984 auto track =
dynamic_cast<REveTrack *
>(i.first);
987 track->StampObjProps();
1053 Warning(
"SetMinAng",
"This method was mis-named, use SetMaxAng() instead!");
1062 Warning(
"GetMinAng",
"This method was mis-named, use GetMaxAng() instead!");
1231 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1232 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1234 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1245 const Int_t maxit = 500;
1246 const Int_t maxcut = 11;
1255 const Double_t kpisqua = 9.86960440109;
1256 const Int_t kix = 0;
1257 const Int_t kiy = 1;
1258 const Int_t kiz = 2;
1259 const Int_t kipx = 3;
1260 const Int_t kipy = 4;
1261 const Int_t kipz = 5;
1270 for(
Int_t j = 0; j < 7; j++)
1299 secxs[0] = (
b *
f[2] -
c *
f[1]) * ph2;
1300 secys[0] = (
c *
f[0] -
a *
f[2]) * ph2;
1301 seczs[0] = (
a *
f[1] -
b *
f[0]) * ph2;
1302 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1303 if (ang2 > kpisqua)
break;
1305 dxt = h2 *
a + h4 * secxs[0];
1306 dyt = h2 *
b + h4 * secys[0];
1307 dzt = h2 *
c + h4 * seczs[0];
1315 if (ncut++ > maxcut)
break;
1333 secxs[1] = (bt *
f[2] - ct *
f[1]) * ph2;
1334 secys[1] = (ct *
f[0] - at *
f[2]) * ph2;
1335 seczs[1] = (at *
f[1] - bt *
f[0]) * ph2;
1339 secxs[2] = (bt *
f[2] - ct *
f[1]) * ph2;
1340 secys[2] = (ct *
f[0] - at *
f[2]) * ph2;
1341 seczs[2] = (at *
f[1] - bt *
f[0]) * ph2;
1342 dxt =
h * (
a + secxs[2]);
1343 dyt =
h * (
b + secys[2]);
1344 dzt =
h * (
c + seczs[2]);
1348 at =
a + 2.*secxs[2];
1349 bt =
b + 2.*secys[2];
1350 ct =
c + 2.*seczs[2];
1354 if (ncut++ > maxcut)
break;
1368 z = z + (
c + (seczs[0] + seczs[1] + seczs[2]) * kthird) *
h;
1369 y =
y + (
b + (secys[0] + secys[1] + secys[2]) * kthird) *
h;
1370 x =
x + (
a + (secxs[0] + secxs[1] + secxs[2]) * kthird) *
h;
1372 secxs[3] = (bt*
f[2] - ct*
f[1])* ph2;
1373 secys[3] = (ct*
f[0] - at*
f[2])* ph2;
1374 seczs[3] = (at*
f[1] - bt*
f[0])* ph2;
1375 a =
a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1376 b =
b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1377 c =
c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1379 est =
TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1380 +
TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1381 +
TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1384 if (ncut++ > maxcut)
break;
1391 if (iter++ > maxit)
break;
1404 if (step < 0.) rest = -rest;
1407 Float_t dot = (vout[3]*vect[3] + vout[4]*vect[4] + vout[5]*vect[5]);
1428 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1429 hxp[1] = f3*vect[kipx] -
f1*vect[kipz];
1430 hxp[2] =
f1*vect[kipy] - f2*vect[kipx];
1432 hp =
f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1440 g3 = (tet-sint) * hp*rho1;
1445 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*
f1;
1446 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1447 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1449 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*
f1;
1450 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1451 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
void Warning(const char *location, const char *msgfmt,...)
virtual void CheckReferenceCount(const std::string &from="<unknown>")
Check external references to this and eventually auto-destruct the render-element.
REveMagFieldConst Interface to constant magnetic field.
REveMagField Abstract interface to magnetic field.
virtual Double_t GetMaxFieldMag() const =0
virtual void PrintField(Double_t x, Double_t y, Double_t z) const
virtual Bool_t IsConst() const
virtual REveVectorD GetField(Double_t x, Double_t y, Double_t z) const =0
REveRefBackPtr reference-count with back pointers.
REveTrackPropagator Calculates path of a particle taking into account special path-marks and imposed ...
virtual Bool_t GoToVertex(REveVectorD &v, REveVectorD &p)
Propagate particle with momentum p to vertex v.
void Update(const REveVector4D &v, const REveVectorD &p, Bool_t full_update=kFALSE, Bool_t enforce_max_step=kFALSE)
Update helix / B-field projection state.
UChar_t fProjTrackBreaking
void SetRnrPTBMarkers(Bool_t x)
Set projection break-point rendering and rebuild tracks.
static Bool_t IsOutsideBounds(const REveVectorD &point, Double_t maxRsqr, Double_t maxZ)
void SetRnrDaughters(Bool_t x)
Set daughter rendering and rebuild tracks.
Bool_t HelixIntersectPlane(const REveVectorD &p, const REveVectorD &point, const REveVectorD &normal, REveVectorD &itsect)
Intersect helix with a plane.
void SetFitLineSegments(Bool_t x)
Set line segment fitting and rebuild tracks.
virtual ~REveTrackPropagator()
Destructor.
void SetRnrCluster2Ds(Bool_t x)
Set rendering of 2D-clusters and rebuild tracks.
Bool_t LineIntersectPlane(const REveVectorD &p, const REveVectorD &point, const REveVectorD &normal, REveVectorD &itsect)
Intersect line with a plane.
void CheckReferenceCount(const std::string &from="<unknown>") override
Check reference count - virtual from REveElement.
Double_t GetMinAng() const
Get maximum step angle.
void ResetTrack()
Reset cache holding particle trajectory.
void Step(const REveVector4D &v, const REveVectorD &p, REveVector4D &vOut, REveVectorD &pOut)
Wrapper to step helix.
Double_t GetTrackLength(Int_t start_point=0, Int_t end_point=-1) const
Calculate track length from start_point to end_point.
void InitTrack(const REveVectorD &v, Int_t charge)
Initialize internal data-members for given particle parameters.
void LineToBounds(REveVectorD &p)
Propagate neutral particle with momentum p to bounds.
void SetRnrReferences(Bool_t x)
Set track-reference rendering and rebuild tracks.
void ClosestPointFromVertexToLineSegment(const REveVectorD &v, const REveVectorD &s, const REveVectorD &r, Double_t rMagInv, REveVectorD &c)
Get closest point from given vertex v to line segment defined with s and r.
Bool_t IntersectPlane(const REveVectorD &p, const REveVectorD &point, const REveVectorD &normal, REveVectorD &itsect)
Find intersection of currently propagated track with a plane.
void RebuildTracks()
Rebuild all tracks using this render-style.
static const Double_t fgkB2C
void SetMaxAng(Double_t x)
Set maximum step angle and rebuild tracks.
Int_t GetCurrentPoint() const
Get index of current point on track.
static Double_t fgDefMagField
void SetMaxZ(Double_t x)
Set maximum z and rebuild tracks.
void SetMaxStep(Double_t x)
Set maximum step-size and rebuild tracks.
void OnZeroRefCount() override
Virtual from REveRefBackPtr - track reference count has reached zero.
void SetRnrDecay(Bool_t x)
Set decay rendering and rebuild tracks.
std::vector< REveVector4D > fPoints
Bool_t PointOverVertex(const REveVector4D &v0, const REveVector4D &v, Double_t *p=0)
void FillPointSet(REvePointSet *ps) const
Reset ps and populate it with points in propagation cache.
Bool_t LoopToLineSegment(const REveVectorD &s, const REveVectorD &r, REveVectorD &p)
Propagate charged particle with momentum p to line segment with point s and vector r to the second po...
void DistributeOffset(const REveVectorD &off, Int_t first_point, Int_t np, REveVectorD &p)
Distribute offset between first and last point index and rotate momentum.
void SetFitDaughters(Bool_t x)
Set daughter creation point fitting and rebuild tracks.
void SetFitDecay(Bool_t x)
Set decay fitting and rebuild tracks.
void SetFitReferences(Bool_t x)
Set track-reference fitting and rebuild tracks.
void StampAllTracks()
Element-change notification.
REveTrackPropagator(const REveTrackPropagator &)=delete
void SetMaxOrbs(Double_t x)
Set maximum number of orbits and rebuild tracks.
void StepRungeKutta(Double_t step, Double_t *vect, Double_t *vout)
Wrapper to step with method RungeKutta.
void SetProjTrackBreaking(UChar_t x)
Set projection break-point mode and rebuild tracks.
Bool_t ClosestPointBetweenLines(const REveVectorD &, const REveVectorD &, const REveVectorD &, const REveVectorD &, REveVectorD &out)
Get closest point on line defined with vector p0 and u.
void SetMagFieldObj(REveMagField *field, Bool_t own_field=kTRUE)
Set constant magnetic field and rebuild tracks.
void SetRnrFV(Bool_t x)
Set first-vertex rendering and rebuild tracks.
void LoopToBounds(REveVectorD &p)
Propagate charged particle with momentum p to bounds.
void PrintMagField(Double_t x, Double_t y, Double_t z) const
void SetMaxR(Double_t x)
Set maximum radius and rebuild tracks.
virtual Bool_t GoToLineSegment(const REveVectorD &s, const REveVectorD &r, REveVectorD &p)
Propagate particle with momentum p to line with start point s and vector r to the second point.
static REveTrackPropagator fgDefault
void SetDelta(Double_t x)
Set maximum error and rebuild tracks.
void SetMinAng(Double_t x)
Set maximum step angle and rebuild tracks.
virtual void GoToBounds(REveVectorD &p)
Propagate particle to bounds.
Bool_t LoopToVertex(REveVectorD &v, REveVectorD &p)
Propagate charged particle with momentum p to vertex v.
void SetMagField(Double_t bX, Double_t bY, Double_t bZ)
Set constant magnetic field and rebuild tracks.
Bool_t LineToVertex(REveVectorD &v)
Propagate neutral particle to vertex v.
Double_t GetMaxAng() const
void SetFitCluster2Ds(Bool_t x)
Set 2D-cluster fitting and rebuild tracks.
REveMagField * fMagFieldObj
std::vector< REveVector4D > fLastPoints
REveTrack Track with given vertex, momentum and optional referece-points (path-marks) along its path.
virtual void MakeTrack(Bool_t recurse=kTRUE)
Calculate track representation based on track data and current settings of the propagator.
REveVector4T A four-vector template without TObject inheritance and virtual functions.
TT Normalize(TT length=1)
Normalize the vector to length if current length is non-zero.
TT Dot(const REveVectorT &a) const
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
T Mag(const SVector< T, D > &rhs)
Vector magnitude (Euclidian norm) Compute : .
Double_t Sqrt(Double_t x)
static constexpr double nm
static constexpr double s
static constexpr double ps
Short_t Range(Short_t lb, Short_t ub, Short_t x)
constexpr Double_t DegToRad()
Conversion from degree to radian:
Double_t Sqrt(Double_t x)
Short_t Min(Short_t a, Short_t b)
T * Cross(const T v1[3], const T v2[3], T out[3])
Calculate the Cross Product of two vectors: out = [v1 x v2].
constexpr Double_t TwoPi()
void UpdateHelix(const REveVectorD &p, const REveVectorD &b, Bool_t full_update, Bool_t enforce_max_step)
Update helix parameters.
void Step(const REveVector4D &v, const REveVectorD &p, REveVector4D &vOut, REveVectorD &pOut)
Step helix for given momentum p from vertex v.
void UpdateRK(const REveVectorD &p, const REveVectorD &b)
Update helix for stepper RungeKutta.
void UpdateCommon(const REveVectorD &p, const REveVectorD &b)
Common update code for helix and RK propagation.
static long int sum(long int i)