#ifndef ROOT_TEveTrackPropagator
#define ROOT_TEveTrackPropagator
#include "TEveVector.h"
#include "TEvePathMark.h"
#include "TEveUtil.h"
#include "TEveElement.h"
#include "TMarker.h"
#include <vector>
class TEvePointSet;
class TEveMagField
{
protected:
Bool_t fFieldConstant;
public:
TEveMagField(): fFieldConstant(kFALSE){}
virtual ~TEveMagField(){}
virtual Bool_t IsConst() const {return fFieldConstant;};
virtual void PrintField(Double_t x, Double_t y, Double_t z) const
{
TEveVector b = GetField(x, y, z);
printf("v(%f, %f, %f) B(%f, %f, %f) \n", x, y, z, b.fX, b.fY, b.fZ);
}
TEveVectorD GetFieldD(const TEveVectorD &v) const { return GetFieldD(v.fX, v.fY, v.fZ); }
virtual TEveVectorD GetFieldD(Double_t x, Double_t y, Double_t z) const { return GetField(x, y, z); }
virtual Double_t GetMaxFieldMagD() const { return GetMaxFieldMag(); }
virtual TEveVector GetField(Float_t, Float_t, Float_t) const { return TEveVector(); }
virtual Float_t GetMaxFieldMag() const { return 4; }
ClassDef(TEveMagField, 0);
};
class TEveMagFieldConst : public TEveMagField
{
protected:
TEveVectorD fB;
public:
TEveMagFieldConst(Double_t x, Double_t y, Double_t z) : TEveMagField(), fB(x, y, z)
{ fFieldConstant = kTRUE; }
virtual ~TEveMagFieldConst() {}
using TEveMagField::GetField;
virtual TEveVectorD GetFieldD(Double_t , Double_t , Double_t ) const { return fB; }
virtual Double_t GetMaxFieldMagD() const { return fB.Mag(); };
ClassDef(TEveMagFieldConst, 0);
};
class TEveMagFieldDuo : public TEveMagField
{
protected:
TEveVectorD fBIn;
TEveVectorD fBOut;
Double_t fR2;
public:
TEveMagFieldDuo(Double_t r, Double_t bIn, Double_t bOut) : TEveMagField(),
fBIn(0,0,bIn), fBOut(0,0,bOut), fR2(r*r)
{
fFieldConstant = kFALSE;
}
virtual ~TEveMagFieldDuo() {}
using TEveMagField::GetField;
virtual TEveVectorD GetFieldD(Double_t x, Double_t y, Double_t ) const
{ return ((x*x+y*y)<fR2) ? fBIn : fBOut; }
virtual Double_t GetMaxFieldMagD() const
{ Double_t b1 = fBIn.Mag(), b2 = fBOut.Mag(); return b1 > b2 ? b1 : b2; }
ClassDef(TEveMagFieldDuo, 0);
};
class TEveTrackPropagator : public TEveElementList,
public TEveRefBackPtr
{
friend class TEveTrackPropagatorSubEditor;
public:
enum EStepper_e { kHelix, kRungeKutta };
enum EProjTrackBreaking_e { kPTB_Break, kPTB_UseFirstPointPos, kPTB_UseLastPointPos };
protected:
struct Helix_t
{
Int_t fCharge;
Double_t fMaxAng;
Double_t fMaxStep;
Double_t fDelta;
Double_t fPhi;
Bool_t fValid;
Double_t fLam;
Double_t fR;
Double_t fPhiStep;
Double_t fSin, fCos;
Double_t fRKStep;
TEveVectorD fB;
TEveVectorD fE1, fE2, fE3;
TEveVectorD fPt, fPl;
Double_t fPtMag;
Double_t fPlMag;
Double_t fLStep;
Helix_t();
void UpdateCommon(const TEveVectorD & p, const TEveVectorD& b);
void UpdateHelix (const TEveVectorD & p, const TEveVectorD& b, Bool_t full_update, Bool_t enforce_max_step);
void UpdateRK (const TEveVectorD & p, const TEveVectorD& b);
void Step(const TEveVector4D& v, const TEveVectorD& p, TEveVector4D& vOut, TEveVectorD& pOut);
Double_t GetStep() { return fLStep * TMath::Sqrt(1 + fLam*fLam); }
Double_t GetStep2() { return fLStep * fLStep * (1 + fLam*fLam); }
};
private:
TEveTrackPropagator(const TEveTrackPropagator&);
TEveTrackPropagator& operator=(const TEveTrackPropagator&);
protected:
EStepper_e fStepper;
TEveMagField* fMagFieldObj;
Bool_t fOwnMagFiledObj;
Double_t fMaxR;
Double_t fMaxZ;
Int_t fNMax;
Double_t fMaxOrbs;
Bool_t fEditPathMarks;
Bool_t fFitDaughters;
Bool_t fFitReferences;
Bool_t fFitDecay;
Bool_t fFitCluster2Ds;
Bool_t fRnrDaughters;
Bool_t fRnrReferences;
Bool_t fRnrDecay;
Bool_t fRnrCluster2Ds;
Bool_t fRnrFV;
TMarker fPMAtt;
TMarker fFVAtt;
UChar_t fProjTrackBreaking;
Bool_t fRnrPTBMarkers;
TMarker fPTBAtt;
std::vector<TEveVector4D> fPoints;
TEveVectorD fV;
Helix_t fH;
void RebuildTracks();
void Update(const TEveVector4D& v, const TEveVectorD& p, Bool_t full_update=kFALSE, Bool_t enforce_max_step=kFALSE);
void Step(const TEveVector4D &v, const TEveVectorD &p, TEveVector4D &vOut, TEveVectorD &pOut);
Bool_t LoopToVertex(TEveVectorD& v, TEveVectorD& p);
void LoopToBounds(TEveVectorD& p);
Bool_t LineToVertex (TEveVectorD& v);
void LineToBounds (TEveVectorD& p);
void StepRungeKutta(Double_t step, Double_t* vect, Double_t* vout);
Bool_t HelixIntersectPlane(const TEveVectorD& p, const TEveVectorD& point, const TEveVectorD& normal,
TEveVectorD&itsect);
Bool_t LineIntersectPlane(const TEveVectorD& p, const TEveVectorD& point, const TEveVectorD& normal,
TEveVectorD& itsect);
Bool_t PointOverVertex(const TEveVector4D& v0, const TEveVector4D& v, Double_t* p=0);
public:
TEveTrackPropagator(const char* n="TEveTrackPropagator", const char* t="",
TEveMagField* field=0, Bool_t own_field=kTRUE);
virtual ~TEveTrackPropagator();
virtual void OnZeroRefCount();
virtual void CheckReferenceCount(const TEveException& eh="TEveElement::CheckReferenceCount ");
virtual void ElementChanged(Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE);
void InitTrack(const TEveVectorD& v, Int_t charge);
void ResetTrack();
void GoToBounds(TEveVectorD& p);
Bool_t GoToVertex(TEveVectorD& v, TEveVectorD& p);
void InitTrack(const TEveVectorF& v, Int_t charge);
void GoToBounds(TEveVectorF& p);
Bool_t GoToVertex(TEveVectorF& v, TEveVectorF&p);
Bool_t IntersectPlane(const TEveVectorD& p, const TEveVectorD& point, const TEveVectorD& normal,
TEveVectorD& itsect);
void FillPointSet(TEvePointSet* ps) const;
void SetStepper(EStepper_e s) { fStepper = s; }
void SetMagField(Double_t bX, Double_t bY, Double_t bZ);
void SetMagField(Double_t b) { SetMagField(0, 0, b); }
void SetMagFieldObj(TEveMagField* field, Bool_t own_field=kTRUE);
void SetMaxR(Double_t x);
void SetMaxZ(Double_t x);
void SetMaxOrbs(Double_t x);
void SetMinAng(Double_t x);
void SetMaxAng(Double_t x);
void SetMaxStep(Double_t x);
void SetDelta(Double_t x);
void SetEditPathMarks(Bool_t x) { fEditPathMarks = x; }
void SetRnrDaughters(Bool_t x);
void SetRnrReferences(Bool_t x);
void SetRnrDecay(Bool_t x);
void SetRnrCluster2Ds(Bool_t x);
void SetFitDaughters(Bool_t x);
void SetFitReferences(Bool_t x);
void SetFitDecay(Bool_t x);
void SetFitCluster2Ds(Bool_t x);
void SetRnrFV(Bool_t x);
void SetProjTrackBreaking(UChar_t x);
void SetRnrPTBMarkers(Bool_t x);
TEveVectorD GetMagField(Double_t x, Double_t y, Double_t z) { return fMagFieldObj->GetField(x, y, z); }
void PrintMagField(Double_t x, Double_t y, Double_t z) const;
EStepper_e GetStepper() const { return fStepper;}
Double_t GetMaxR() const { return fMaxR; }
Double_t GetMaxZ() const { return fMaxZ; }
Double_t GetMaxOrbs() const { return fMaxOrbs; }
Double_t GetMinAng() const;
Double_t GetMaxAng() const { return fH.fMaxAng; }
Double_t GetMaxStep() const { return fH.fMaxStep; }
Double_t GetDelta() const { return fH.fDelta; }
Bool_t GetEditPathMarks() const { return fEditPathMarks; }
Bool_t GetRnrDaughters() const { return fRnrDaughters; }
Bool_t GetRnrReferences() const { return fRnrReferences; }
Bool_t GetRnrDecay() const { return fRnrDecay; }
Bool_t GetRnrCluster2Ds() const { return fRnrCluster2Ds; }
Bool_t GetFitDaughters() const { return fFitDaughters; }
Bool_t GetFitReferences() const { return fFitReferences; }
Bool_t GetFitDecay() const { return fFitDecay; }
Bool_t GetFitCluster2Ds() const { return fFitCluster2Ds; }
Bool_t GetRnrFV() const { return fRnrFV; }
UChar_t GetProjTrackBreaking() const { return fProjTrackBreaking; }
Bool_t GetRnrPTBMarkers() const { return fRnrPTBMarkers; }
TMarker& RefPMAtt() { return fPMAtt; }
TMarker& RefFVAtt() { return fFVAtt; }
TMarker& RefPTBAtt() { return fPTBAtt; }
static Bool_t IsOutsideBounds(const TEveVectorD& point, Double_t maxRsqr, Double_t maxZ);
static Double_t fgDefMagField;
static const Double_t fgkB2C;
static TEveTrackPropagator fgDefault;
static Double_t fgEditorMaxR;
static Double_t fgEditorMaxZ;
ClassDef(TEveTrackPropagator, 0);
};
inline Bool_t TEveTrackPropagator::IsOutsideBounds(const TEveVectorD& point,
Double_t maxRsqr,
Double_t maxZ)
{
return TMath::Abs(point.fZ) > maxZ ||
point.fX*point.fX + point.fY*point.fY > maxRsqr;
}
inline Bool_t TEveTrackPropagator::PointOverVertex(const TEveVector4D &v0,
const TEveVector4D &v,
Double_t *p)
{
static const Double_t kMinPl = 1e-5;
TEveVectorD dv; dv.Sub(v0, v);
Double_t dotV;
if (TMath::Abs(fH.fPlMag) > kMinPl)
{
dotV = fH.fE1.Dot(dv);
if (fH.fPlMag < 0)
dotV = -dotV;
}
else
{
dotV = fH.fE2.Dot(dv);
}
if (p)
*p = dotV;
return dotV < 0;
}
#endif
TEveTrackPropagator.h:100 TEveTrackPropagator.h:101 TEveTrackPropagator.h:102 TEveTrackPropagator.h:103 TEveTrackPropagator.h:104 TEveTrackPropagator.h:105 TEveTrackPropagator.h:106 TEveTrackPropagator.h:107 TEveTrackPropagator.h:108 TEveTrackPropagator.h:109 TEveTrackPropagator.h:110 TEveTrackPropagator.h:111 TEveTrackPropagator.h:112 TEveTrackPropagator.h:113 TEveTrackPropagator.h:114 TEveTrackPropagator.h:115 TEveTrackPropagator.h:116 TEveTrackPropagator.h:117 TEveTrackPropagator.h:118 TEveTrackPropagator.h:119 TEveTrackPropagator.h:120 TEveTrackPropagator.h:121 TEveTrackPropagator.h:122 TEveTrackPropagator.h:123 TEveTrackPropagator.h:124 TEveTrackPropagator.h:125 TEveTrackPropagator.h:126 TEveTrackPropagator.h:127 TEveTrackPropagator.h:128 TEveTrackPropagator.h:129 TEveTrackPropagator.h:130 TEveTrackPropagator.h:131 TEveTrackPropagator.h:132 TEveTrackPropagator.h:133 TEveTrackPropagator.h:134 TEveTrackPropagator.h:135 TEveTrackPropagator.h:136 TEveTrackPropagator.h:137 TEveTrackPropagator.h:138 TEveTrackPropagator.h:139 TEveTrackPropagator.h:140 TEveTrackPropagator.h:141 TEveTrackPropagator.h:142 TEveTrackPropagator.h:143 TEveTrackPropagator.h:144 TEveTrackPropagator.h:145 TEveTrackPropagator.h:146 TEveTrackPropagator.h:147 TEveTrackPropagator.h:148 TEveTrackPropagator.h:149 TEveTrackPropagator.h:150 TEveTrackPropagator.h:151 TEveTrackPropagator.h:152 TEveTrackPropagator.h:153 TEveTrackPropagator.h:154 TEveTrackPropagator.h:155 TEveTrackPropagator.h:156 TEveTrackPropagator.h:157 TEveTrackPropagator.h:158 TEveTrackPropagator.h:159 TEveTrackPropagator.h:160 TEveTrackPropagator.h:161 TEveTrackPropagator.h:162 TEveTrackPropagator.h:163 TEveTrackPropagator.h:164 TEveTrackPropagator.h:165 TEveTrackPropagator.h:166 TEveTrackPropagator.h:167 TEveTrackPropagator.h:168 TEveTrackPropagator.h:169 TEveTrackPropagator.h:170 TEveTrackPropagator.h:171 TEveTrackPropagator.h:172 TEveTrackPropagator.h:173 TEveTrackPropagator.h:174 TEveTrackPropagator.h:175 TEveTrackPropagator.h:176 TEveTrackPropagator.h:177 TEveTrackPropagator.h:178 TEveTrackPropagator.h:179 TEveTrackPropagator.h:180 TEveTrackPropagator.h:181 TEveTrackPropagator.h:182 TEveTrackPropagator.h:183 TEveTrackPropagator.h:184 TEveTrackPropagator.h:185 TEveTrackPropagator.h:186 TEveTrackPropagator.h:187 TEveTrackPropagator.h:188 TEveTrackPropagator.h:189 TEveTrackPropagator.h:190 TEveTrackPropagator.h:191 TEveTrackPropagator.h:192 TEveTrackPropagator.h:193 TEveTrackPropagator.h:194 TEveTrackPropagator.h:195 TEveTrackPropagator.h:196 TEveTrackPropagator.h:197 TEveTrackPropagator.h:198 TEveTrackPropagator.h:199 TEveTrackPropagator.h:200 TEveTrackPropagator.h:201 TEveTrackPropagator.h:202 TEveTrackPropagator.h:203 TEveTrackPropagator.h:204 TEveTrackPropagator.h:205 TEveTrackPropagator.h:206 TEveTrackPropagator.h:207 TEveTrackPropagator.h:208 TEveTrackPropagator.h:209 TEveTrackPropagator.h:210 TEveTrackPropagator.h:211 TEveTrackPropagator.h:212 TEveTrackPropagator.h:213 TEveTrackPropagator.h:214 TEveTrackPropagator.h:215 TEveTrackPropagator.h:216 TEveTrackPropagator.h:217 TEveTrackPropagator.h:218 TEveTrackPropagator.h:219 TEveTrackPropagator.h:220 TEveTrackPropagator.h:221 TEveTrackPropagator.h:222 TEveTrackPropagator.h:223 TEveTrackPropagator.h:224 TEveTrackPropagator.h:225 TEveTrackPropagator.h:226 TEveTrackPropagator.h:227 TEveTrackPropagator.h:228 TEveTrackPropagator.h:229 TEveTrackPropagator.h:230 TEveTrackPropagator.h:231 TEveTrackPropagator.h:232 TEveTrackPropagator.h:233 TEveTrackPropagator.h:234 TEveTrackPropagator.h:235 TEveTrackPropagator.h:236 TEveTrackPropagator.h:237 TEveTrackPropagator.h:238 TEveTrackPropagator.h:239 TEveTrackPropagator.h:240 TEveTrackPropagator.h:241 TEveTrackPropagator.h:242 TEveTrackPropagator.h:243 TEveTrackPropagator.h:244 TEveTrackPropagator.h:245 TEveTrackPropagator.h:246 TEveTrackPropagator.h:247 TEveTrackPropagator.h:248 TEveTrackPropagator.h:249 TEveTrackPropagator.h:250 TEveTrackPropagator.h:251 TEveTrackPropagator.h:252 TEveTrackPropagator.h:253 TEveTrackPropagator.h:254 TEveTrackPropagator.h:255 TEveTrackPropagator.h:256 TEveTrackPropagator.h:257 TEveTrackPropagator.h:258 TEveTrackPropagator.h:259 TEveTrackPropagator.h:260 TEveTrackPropagator.h:261 TEveTrackPropagator.h:262 TEveTrackPropagator.h:263 TEveTrackPropagator.h:264 TEveTrackPropagator.h:265 TEveTrackPropagator.h:266 TEveTrackPropagator.h:267 TEveTrackPropagator.h:268 TEveTrackPropagator.h:269 TEveTrackPropagator.h:270 TEveTrackPropagator.h:271 TEveTrackPropagator.h:272 TEveTrackPropagator.h:273 TEveTrackPropagator.h:274 TEveTrackPropagator.h:275 TEveTrackPropagator.h:276 TEveTrackPropagator.h:277 TEveTrackPropagator.h:278 TEveTrackPropagator.h:279 TEveTrackPropagator.h:280 TEveTrackPropagator.h:281 TEveTrackPropagator.h:282 TEveTrackPropagator.h:283 TEveTrackPropagator.h:284 TEveTrackPropagator.h:285 TEveTrackPropagator.h:286 TEveTrackPropagator.h:287 TEveTrackPropagator.h:288 TEveTrackPropagator.h:289 TEveTrackPropagator.h:290 TEveTrackPropagator.h:291 TEveTrackPropagator.h:292 TEveTrackPropagator.h:293 TEveTrackPropagator.h:294 TEveTrackPropagator.h:295 TEveTrackPropagator.h:296 TEveTrackPropagator.h:297 TEveTrackPropagator.h:298 TEveTrackPropagator.h:299 TEveTrackPropagator.h:300 TEveTrackPropagator.h:301 TEveTrackPropagator.h:302 TEveTrackPropagator.h:303 TEveTrackPropagator.h:304 TEveTrackPropagator.h:305 TEveTrackPropagator.h:306 TEveTrackPropagator.h:307 TEveTrackPropagator.h:308 TEveTrackPropagator.h:309 TEveTrackPropagator.h:310 TEveTrackPropagator.h:311 TEveTrackPropagator.h:312 TEveTrackPropagator.h:313 TEveTrackPropagator.h:314 TEveTrackPropagator.h:315 TEveTrackPropagator.h:316 TEveTrackPropagator.h:317 TEveTrackPropagator.h:318 TEveTrackPropagator.h:319 TEveTrackPropagator.h:320 TEveTrackPropagator.h:321 TEveTrackPropagator.h:322 TEveTrackPropagator.h:323 TEveTrackPropagator.h:324 TEveTrackPropagator.h:325 TEveTrackPropagator.h:326 TEveTrackPropagator.h:327 TEveTrackPropagator.h:328 TEveTrackPropagator.h:329 TEveTrackPropagator.h:330 TEveTrackPropagator.h:331 TEveTrackPropagator.h:332 TEveTrackPropagator.h:333 TEveTrackPropagator.h:334 TEveTrackPropagator.h:335 TEveTrackPropagator.h:336 TEveTrackPropagator.h:337 TEveTrackPropagator.h:338 TEveTrackPropagator.h:339 TEveTrackPropagator.h:340 TEveTrackPropagator.h:341 TEveTrackPropagator.h:342 TEveTrackPropagator.h:343 TEveTrackPropagator.h:344 TEveTrackPropagator.h:345 TEveTrackPropagator.h:346 TEveTrackPropagator.h:347 TEveTrackPropagator.h:348 TEveTrackPropagator.h:349 TEveTrackPropagator.h:350 TEveTrackPropagator.h:351 TEveTrackPropagator.h:352 TEveTrackPropagator.h:353 TEveTrackPropagator.h:354 TEveTrackPropagator.h:355 TEveTrackPropagator.h:356 TEveTrackPropagator.h:357 TEveTrackPropagator.h:358 TEveTrackPropagator.h:359 TEveTrackPropagator.h:360 TEveTrackPropagator.h:361 TEveTrackPropagator.h:362 TEveTrackPropagator.h:363 TEveTrackPropagator.h:364 TEveTrackPropagator.h:365 TEveTrackPropagator.h:366 TEveTrackPropagator.h:367 TEveTrackPropagator.h:368 TEveTrackPropagator.h:369 TEveTrackPropagator.h:370 TEveTrackPropagator.h:371 TEveTrackPropagator.h:372 TEveTrackPropagator.h:373 TEveTrackPropagator.h:374 TEveTrackPropagator.h:375 TEveTrackPropagator.h:376 TEveTrackPropagator.h:377