BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
TTrack Class Reference

A class to represent a track in tracking. More...

#include <TTrack.h>

+ Inheritance diagram for TTrack:

Public Member Functions

 TTrack ()
 Default constructor.
 
 TTrack (const TCircle &)
 Constructor.
 
 TTrack (const TTrack &)
 Copy constructor.
 
 TTrack (const T3DLine &)
 Constructor.
 
 TTrack (const Helix &)
 Constructor.
 
 TTrack (const TRunge &)
 
virtual ~TTrack ()
 Destructor.
 
const std::string & name (void) const
 returns/sets name.
 
const std::string & name (const std::string &newName)
 
TTrackmother (void) const
 sets/returns mother/daughter.
 
TTrackmother (TTrack *)
 
TTrackdaughter (void) const
 
TTrackdaughter (TTrack *)
 
unsigned objectType (void) const
 returns type.
 
unsigned type (void) const
 returns type. Definition is depending on an object type.
 
unsigned finder (void) const
 sets/returns finder.
 
unsigned finder (unsigned finderMask)
 
void setFinderType (unsigned)
 
unsigned getFinderType (void) const
 
unsigned quality (void) const
 sets/returns quality.
 
unsigned quality (unsigned qualityMask)
 
unsigned fitting (void) const
 sets/returns fitting status.
 
unsigned fitting (unsigned fitMask)
 
unsigned state (void) const
 returns/sets internal state.(for bank output)
 
void assign (unsigned maskForWireHit)
 assigns wire hits to this track.
 
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
 
double charge (void) const
 returns charge.
 
const Helixhelix (void) const
 returns helix parameter.
 
Hep3Vector p (void) const
 returns momentum.
 
double ptot (void) const
 returns magnitude of momentum.
 
double pt (void) const
 returns Pt.
 
double pz (void) const
 returns Pz.
 
double impact (void) const
 returns signed impact parameter to the origin.
 
TPoint2D center (void) const
 returns position of helix center.
 
double radius (void) const
 returns signed radius.
 
unsigned ndf (void) const
 returns NDF.
 
double chi2 (void) const
 returns chi2.
 
double confidenceLevel (void) const
 returns confidence level.
 
AList< TSegment > & segments (void)
 returns AList<TSegment>.
 
const AList< TSegment > & segments (void) const
 
int approach (TMLink &) const
 calculates the closest approach to a wire in real space. Results are stored in TMLink. Return value is negative if error happened.
 
int approach (TMLink &, bool sagCorrection) const
 
int approach2D (TMLink &) const
 
int szPosition (TMLink &link) const
 calculates arc length and z for a stereo hit.
 
int szPosition (const TSegment &segment, TMLink &link) const
 calculates arc length and z for a segment. Results are stored in TMLink.
 
int szPosition (const HepPoint3D &p, HepPoint3D &szPosition) const
 calculates arc length for a point.
 
int stereoHitForCurl (TMLink &link, AList< HepPoint3D > &arcZList) const
 
int stereoHitForCurl (TMLink &link, TMLink &link1) const
 
int stereoHitForCurl (TMLink &link, TMLink &link1, TMLink &link2) const
 
void deleteListForCurl (AList< HepPoint3D > &l1, AList< HepPoint3D > &l2) const
 
void deleteListForCurl (AList< HepPoint3D > &l1, AList< HepPoint3D > &l2, AList< HepPoint3D > &l3) const
 
int stereoHitForCurl (AList< TMLink > &) const
 calculates arc length and z for a stereo hit. uses these functions for curl tracks(included svd version).
 
double charge (double)
 sets charge.
 
int fit2D (unsigned=0, double=0.1, double=0.015)
 fits itself. Error was happened if return value is not zero.
 
void refine2D (AList< TMLink > &list, float maxSigma)
 fits itself with cathode hits.
 
void movePivot (void)
 moves pivot to the inner most hit.
 
int HelCyl (double rhole, double rcyl, double zb, double zf, double epsl, double &phi, HepPoint3D &xp) const
 returns a cathode hit list.
 
const AList< TMLink > & finalHits (void) const
 finds cathode hits associated to this track.
 
const AList< TMLink > & finalHits (const AList< TMLink > &hits)
 
const AList< TMLink > & associateHits (void) const
 sets/returns a list of associated TMLink which are used for table output.
 
const AList< TMLink > & associateHits (const AList< TMLink > &hits)
 
- Public Member Functions inherited from TTrackBase
 TTrackBase ()
 Constructor.
 
 TTrackBase (const AList< TMLink > &links)
 Constructor.
 
virtual ~TTrackBase ()
 Destructor.
 
virtual unsigned objectType (void) const
 returns object type.
 
virtual unsigned type (void) const
 returns type. Definition is depending on an object class.
 
virtual void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
 
const AList< TMLink > & links (unsigned mask=0) const
 returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
 
unsigned nLinks (unsigned mask=0) const
 returns # of masked TMLinks assigned to this track object.
 
const AList< TMLink > & cores (unsigned mask=0) const
 returns a list of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
 
unsigned nCores (unsigned mask=0) const
 returns # of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
 
void update (void) const
 update cache.
 
void append (TMLink &)
 appends a TMLink.
 
void append (const AList< TMLink > &)
 appends TMLinks.
 
void appendByApproach (AList< TMLink > &list, double maxSigma)
 appends TMLinks by approach. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.
 
void appendByDistance (AList< TMLink > &list, double maxDistance)
 appends TMLinks by distance. 'list' is an input. Unappended TMLinks will be removed from 'list' when returned.
 
void remove (TMLink &a)
 removes a TMLink.
 
void remove (const AList< TMLink > &)
 removes TMLinks.
 
virtual void refine (AList< TMLink > &list, double maxSigma)
 removes bad points by pull. The bad points are removed from the track, and are returned in 'list'.
 
virtual void refine (double maxSigma)
 removes bad points by pull. The bad points are masked not to be used in fit.
 
virtual int DropWorst ()
 
virtual void removeLinks (void)
 
virtual double distance (const TMLink &) const
 returns distance to a position of TMLink in TMLink space.
 
virtual int approach (TMLink &) const
 calculates the closest approach to a wire in real space. Results are stored in TMLink. Return value is negative if error happened.
 
unsigned testByApproach (const TMLink &list, double sigma) const
 returns # of good hits to be appended.
 
unsigned testByApproach (const AList< TMLink > &list, double sigma) const
 
virtual int fit (void)
 fits itself by a default fitter. Error was happened if return value is not zero.
 
const TMFitter *const fitter (void) const
 returns a pointer to a default fitter.
 
const TMFitter *const fitter (const TMFitter *)
 sets a default fitter.
 
void falseFit ()
 false Fit
 
TMLinkoperator[] (unsigned i) const
 
const TTrackHEP *const hep (void) const
 returns TTrackHEP.
 
unsigned nHeps (void) const
 returns # of contributed TTrackHEP tracks.
 
const TTrackMC *const mc (void) const
 returns a pointer to TTrackMC.
 
bool fitted (void) const
 returns true if fitted.
 
bool fittedWithCathode (void) const
 returns true if fitted with cathode hits(TEMPORARY).
 

Friends

class TTrackManager
 
class TrkReco
 
class THelixFitter
 
class TCosmicFitter
 
class Refit
 
class TBuilder
 
class TBuilder0
 
class TBuilderCosmic
 
class TBuilderCurl
 
class TPMCurlFinder
 
class TCurlFinder
 

Additional Inherited Members

- Protected Attributes inherited from TTrackBase
AList< TMLink_links
 
bool _fitted
 
bool _fittedWithCathode
 
TTrackMC_mc
 

Detailed Description

A class to represent a track in tracking.

Definition at line 129 of file TTrack.h.

Constructor & Destructor Documentation

◆ TTrack() [1/6]

TTrack::TTrack ( )

Default constructor.

Definition at line 207 of file TTrack.cxx.

208: TTrackBase(),
209 _charge(1.),
210 _helix(new Helix(ORIGIN, Vector(5, 0), SymMatrix(5, 0))),
211 _ndf(0),
212 _chi2(0.),
213 _name("empty track"),
214 _state(0),
215 _mother(0),
216 _daughter(0) {
217 //jialk
218 StatusCode scmgn = Gaudi::svcLocator()->service("MagneticFieldSvc",m_pmgnIMF);
219 if(scmgn!=StatusCode::SUCCESS) {
220 std::cout<< __FILE__<<" "<<__LINE__<<" Unable to open Magnetic field service"<<std::endl;
221 }
222}
const HepPoint3D ORIGIN
Constants.
Definition: TMDCUtil.cxx:47
TTrackBase()
Constructor.
Definition: TTrackBase.cxx:40

◆ TTrack() [2/6]

TTrack::TTrack ( const TCircle c)

Constructor.

Definition at line 81 of file TTrack.cxx.

82: TTrackBase(c.links()),
83 _helix(new Helix(ORIGIN, Vector(5, 0), SymMatrix(5, 0))),
84 _charge(c.charge()),
85 _ndf(0),
86 _chi2(0.),
87 _name("none"),
88 _type(0),
89 _state(0),
90 _mother(0),
91 _daughter(0) {
92
93 //jialk
94 StatusCode scmgn = Gaudi::svcLocator()->service("MagneticFieldSvc",m_pmgnIMF);
95 if(scmgn!=StatusCode::SUCCESS) {
96 std::cout<< __FILE__<<" "<<__LINE__<<" Unable to open Magnetic field service"<<std::endl;
97 }
98
99 //_fitter.setMagneticFieldPointer(m_pmgnIMF);//yzhang add 2012-05-04
100 //cout<<"TTrack: "<<m_pmgnIMF->getReferField()<<endl;
101 //...Set a defualt fitter...
102 fitter(& TTrack::_fitter);
103
104 //...Calculate helix parameters...
105 Vector a(5);
106 a[1] = fmod(atan2(_charge * (c.center().y() - ORIGIN.y()),
107 _charge * (c.center().x() - ORIGIN.x()))
108 + 4. * M_PI,
109 2. * M_PI);
110 // a[2] = Helix::ConstantAlpha / c.radius();
111 // a[2] = 333.564095 / c.radius();
112 const double Bz = -1000*m_pmgnIMF->getReferField();
113 a[2] = 333.564095/ (c.radius() * Bz);
114 a[0] = (c.center().x() - ORIGIN.x()) / cos(a[1]) - c.radius();
115 a[3] = 0.;
116 a[4] = 0.;
117 _helix->a(a);
118
119 //...Update links...
120 unsigned n = _links.length();
121 for (unsigned i = 0; i < n; i++)
122 _links[i]->track(this);
123
124 _fitted = false;
125 _fittedWithCathode = false;
126/*
127 //jialk
128 StatusCode scmgn = Gaudi::svcLocator()->service("MagneticFieldSvc",m_pmgnIMF);
129 if(scmgn!=StatusCode::SUCCESS) {
130 std::cout<< __FILE__<<" "<<__LINE__<<" Unable to open Magnetic field service"<<std::endl;
131 }
132*/
133}
double cos(const BesAngle a)
Definition: BesAngle.h:213
const Int_t n
#define M_PI
Definition: TConstant.h:4
const HepVector & a(void) const
returns helix parameters.
virtual double getReferField()=0
double radius(void) const
returns radius.
Definition: TCircle.h:117
const HepPoint3D & center(void) const
returns position of center.
Definition: TCircle.h:108
double charge(void) const
returns charge.
Definition: TCircle.h:147
bool _fittedWithCathode
Definition: TTrackBase.h:163
AList< TMLink > _links
Definition: TTrackBase.h:161
bool _fitted
Definition: TTrackBase.h:162
const AList< TMLink > & links(unsigned mask=0) const
returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
Definition: TTrackBase.cxx:297
const TMFitter *const fitter(void) const
returns a pointer to a default fitter.
Definition: TTrackBase.h:255

◆ TTrack() [3/6]

TTrack::TTrack ( const TTrack a)

Copy constructor.

Definition at line 135 of file TTrack.cxx.

136: TTrackBase((TTrackBase &) a),
137 _charge(a._charge),
138 _segments(a._segments),
139 _helix(new Helix(* a._helix)),
140 _ndf(a._ndf),
141 _chi2(a._chi2),
142 _name("copy of " + a._name),
143 _type(a._type),
144// _catHits(a._catHits),
145 _state(a._state),
146 _mother(a._mother),
147 _daughter(a._daughter) {
148 //jialk
149 StatusCode scmgn = Gaudi::svcLocator()->service("MagneticFieldSvc",m_pmgnIMF);
150 if(scmgn!=StatusCode::SUCCESS) {
151 std::cout<< __FILE__<<" "<<__LINE__<<" Unable to open Magnetic field service"<<std::endl;
152 }
153}
A virtual class for a track class in tracking.
Definition: TTrackBase.h:46

◆ TTrack() [4/6]

TTrack::TTrack ( const T3DLine )

Constructor.

◆ TTrack() [5/6]

TTrack::TTrack ( const Helix h)

Constructor.

Definition at line 181 of file TTrack.cxx.

182: TTrackBase(),
183 _helix(new Helix(h)),
184 _ndf(0),
185 _chi2(0.),
186 _name("none"),
187 _type(0),
188 _state(0),
189 _mother(0),
190 _daughter(0) {
191
192 //...Set a defualt fitter...
193 fitter(& TTrack::_fitter);
194
195 if(_helix->kappa() > 0.)_charge = 1.;
196 else _charge = -1.;
197
198 _fitted = false;
199 _fittedWithCathode = false;
200 //jialk
201 StatusCode scmgn = Gaudi::svcLocator()->service("MagneticFieldSvc",m_pmgnIMF);
202 if(scmgn!=StatusCode::SUCCESS) {
203 std::cout<< __FILE__<<" "<<__LINE__<<" Unable to open Magnetic field service"<<std::endl;
204 }
205}

◆ TTrack() [6/6]

TTrack::TTrack ( const TRunge a)

Definition at line 168 of file TTrack.cxx.

169: TTrackBase((TTrackBase &) a),
170 _helix(new Helix( a.helix())),
171 _ndf(a.ndf()),
172 _chi2(a.chi2()),
173 _name("no"),
174 _type(0),
175 _state(0),
176 _mother(0),
177 _daughter(0) {
178 if(_helix->kappa() > 0.)_charge = 1.;
179 else _charge = -1.;
180}
Helix helix(void) const
returns helix class
Definition: TRunge.cxx:238
unsigned ndf(void) const
returns NDF
Definition: TRunge.cxx:242
double chi2(void) const
returns chi2.
Definition: TRunge.cxx:246

◆ ~TTrack()

TTrack::~TTrack ( )
virtual

Destructor.

Definition at line 224 of file TTrack.cxx.

224 {
225 delete _helix;
226}

Member Function Documentation

◆ approach() [1/2]

int TTrack::approach ( TMLink l) const
virtual

calculates the closest approach to a wire in real space. Results are stored in TMLink. Return value is negative if error happened.

Reimplemented from TTrackBase.

Definition at line 296 of file TTrack.cxx.

296 {
297 return approach(l, false);
298}
int approach(TMLink &) const
calculates the closest approach to a wire in real space. Results are stored in TMLink....
Definition: TTrack.cxx:296

Referenced by approach(), and TTrackManager::closest().

◆ approach() [2/2]

int TTrack::approach ( TMLink link,
bool  sagCorrection 
) const

Definition at line 3059 of file TTrack.cxx.

3059 {
3060 //...Cal. dPhi to rotate...
3061 const TMDCWire & w = * link.wire();
3062 double wp[3]; w.xyPosition(wp);
3063 double wb[3]; w.backwardPosition(wb);
3064 double v[3];
3065 v[0] = w.direction().x();
3066 v[1] = w.direction().y();
3067 v[2] = w.direction().z();
3068 //...Sag correction...
3069 if (doSagCorrection) {
3070 HepVector3D dir = w.direction();
3071 HepPoint3D xw(wp[0], wp[1], wp[2]);
3072 HepPoint3D wireBackwardPosition(wb[0], wb[1], wb[2]);
3073 w.wirePosition(link.positionOnTrack().z(),
3074 xw,
3075 wireBackwardPosition,
3076 dir);
3077 v[0] = dir.x();
3078 v[1] = dir.y();
3079 v[2] = dir.z();
3080 wp[0] = xw.x();
3081 wp[1] = xw.y();
3082 wp[2] = xw.z();
3083 wb[0] = wireBackwardPosition.x();
3084 wb[1] = wireBackwardPosition.y();
3085 wb[2] = wireBackwardPosition.z();
3086 }
3087 //...Cal. dPhi to rotate...
3088 const HepPoint3D & xc = _helix->center();
3089 double xt[3]; _helix->x(0., xt);
3090 double x0 = - xc.x();
3091 double y0 = - xc.y();
3092 double x1 = wp[0] + x0;
3093 double y1 = wp[1] + y0;
3094 x0 += xt[0];
3095 y0 += xt[1];
3096 double dPhi = atan2(x0 * y1 - y0 * x1, x0 * x1 + y0 * y1);
3097 //...Setup...
3098 double kappa = _helix->kappa();
3099 double phi0 = _helix->phi0();
3100//yzhang 2012-08-30
3101 //...Axial case...
3102// if (w.axial()) {
3103// link.positionOnTrack(_helix->x(dPhi));
3104// HepPoint3D x(wp[0], wp[1], wp[2]);
3105// x.setZ(link.positionOnTrack().z());
3106// link.positionOnWire(x);
3107// link.dPhi(dPhi);
3108// return 0;
3109// }
3110#ifdef TRKRECO_DEBUG
3111 double firstdfdphi = 0.;
3112 static bool first = true;
3113 if (first) {
3114// extern BelleTupleManager * BASF_Histogram;
3115// BelleTupleManager * m = BASF_Histogram;
3116// h_nTrial = m->histogram("TTrack::approach nTrial", 100, 0., 100.);
3117 }
3118#endif
3119
3120 //...Stereo case...
3121 // double rho = Helix::ConstantAlpha / kappa;
3122 // double rho = 333.564095 / kappa;
3123 // yzhang 2012-05-03 delete
3124 //double rho = 333.564095/ kappa;
3125 //yzhang add
3126 Gaudi::svcLocator()->service("MagneticFieldSvc",m_pmgnIMF);
3127 if(m_pmgnIMF==NULL) {
3128 std::cout<< __FILE__<<" "<<__LINE__<<" Unable to open Magnetic field service"<<std::endl;
3129 }
3130 const double Bz = -1000*m_pmgnIMF->getReferField();
3131 double rho = 333.564095/(kappa * Bz);
3132 //zhangy
3133 double tanLambda = _helix->tanl();
3134 static Vector x(3);
3135 double t_x[3];
3136 double t_dXdPhi[3];
3137 const double convergence = 1.0e-5;
3138 double l;
3139 unsigned nTrial = 0;
3140 while (nTrial < 100) {
3141
3142 x = link.positionOnTrack(_helix->x(dPhi));
3143 t_x[0] = x[0];
3144 t_x[1] = x[1];
3145 t_x[2] = x[2];
3146
3147 l = v[0] * t_x[0] + v[1] * t_x[1] + v[2] * t_x[2]
3148 - v[0] * wb[0] - v[1] * wb[1] - v[2] * wb[2];
3149
3150 double rcosPhi = rho * cos(phi0 + dPhi);
3151 double rsinPhi = rho * sin(phi0 + dPhi);
3152 t_dXdPhi[0] = rsinPhi;
3153 t_dXdPhi[1] = - rcosPhi;
3154 t_dXdPhi[2] = - rho * tanLambda;
3155
3156 //...f = d(Distance) / d phi...
3157 double t_d2Xd2Phi[2];
3158 t_d2Xd2Phi[0] = rcosPhi;
3159 t_d2Xd2Phi[1] = rsinPhi;
3160
3161 //...iw new...
3162 double n[3];
3163 n[0] = t_x[0] - wb[0];
3164 n[1] = t_x[1] - wb[1];
3165 n[2] = t_x[2] - wb[2];
3166
3167 double a[3];
3168 a[0] = n[0] - l * v[0];
3169 a[1] = n[1] - l * v[1];
3170 a[2] = n[2] - l * v[2];
3171 double dfdphi = a[0] * t_dXdPhi[0]
3172 + a[1] * t_dXdPhi[1]
3173 + a[2] * t_dXdPhi[2];
3174
3175#ifdef TRKRECO_DEBUG
3176 if (nTrial == 0) {
3177// break;
3178 firstdfdphi = dfdphi;
3179 }
3180
3181 //...Check bad case...
3182 if (nTrial > 3) {
3183 std::cout << "TTrack::approach ... " << w.name() << " "
3184 << "dfdphi(0)=" << firstdfdphi
3185 << ",(" << nTrial << ")=" << dfdphi << endl;
3186 }
3187#endif
3188
3189 //...Is it converged?...
3190 if (fabs(dfdphi) < convergence)
3191 break;
3192
3193 double dv = v[0] * t_dXdPhi[0]
3194 + v[1] * t_dXdPhi[1]
3195 + v[2] * t_dXdPhi[2];
3196 double t0 = t_dXdPhi[0] * t_dXdPhi[0]
3197 + t_dXdPhi[1] * t_dXdPhi[1]
3198 + t_dXdPhi[2] * t_dXdPhi[2];
3199 double d2fd2phi = t0 - dv * dv
3200 + a[0] * t_d2Xd2Phi[0]
3201 + a[1] * t_d2Xd2Phi[1];
3202// + a[2] * t_d2Xd2Phi[2];
3203
3204 dPhi -= dfdphi / d2fd2phi;
3205
3206// cout << "nTrial=" << nTrial << endl;
3207// cout << "iw f,df,dphi=" << dfdphi << "," << d2fd2phi << "," << dPhi << endl;
3208
3209 ++nTrial;
3210 }
3211
3212 //...Cal. positions...
3213 link.positionOnWire(HepPoint3D(wb[0] + l * v[0],
3214 wb[1] + l * v[1],
3215 wb[2] + l * v[2]));
3216 link.dPhi(dPhi);
3217
3218#ifdef TRKRECO_DEBUG
3219// h_nTrial->accumulate((float) nTrial + .5);
3220#endif
3221
3222 return nTrial;
3223}
double sin(const BesAngle a)
Definition: BesAngle.h:210
Double_t x[10]
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
HepGeom::Point3D< double > HepPoint3D
Definition: TTrack.h:103
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
A class to represent a wire in MDC.
Definition: TMDCWire.h:55
const HepVector3D & direction(void) const
returns direction vector of the wire.
Definition: TMDCWire.h:342
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
Definition: TMDCWire.h:327
const HepPoint3D & backwardPosition(void) const
returns position in backward endplate.
Definition: TMDCWire.h:306
std::string name(void) const
returns name.
Definition: TMDCWire.h:412
void wirePosition(float zPosition, HepPoint3D &xyPosition, HepPoint3D &backwardPosition, HepVector3D &direction) const
calculates position and direction vector with sag correction.
Definition: TMDCWire.cxx:541
Index first(Pair i)
Definition: EvtCyclic3.cc:195

◆ approach2D()

int TTrack::approach2D ( TMLink l) const

Definition at line 2891 of file TTrack.cxx.

2891 {
2892
2893 const TMDCWire &w = *l.wire();
2894 double kappa = _helix->a()[2];
2895 double phi0 = _helix->a()[1];
2896 HepPoint3D xc(_helix->center());
2897 HepPoint3D xw(w.xyPosition());
2898 HepPoint3D xt(_helix->x());
2899 HepVector3D v0(xt-xc);
2900 HepVector3D v1(xw-xc);
2901
2902 double vCrs = v0.x() * v1.y() - v0.y() * v1.x();
2903 double vDot = v0.x() * v1.x() + v0.y() * v1.y();
2904 double dPhi = atan2(vCrs, vDot);
2905
2906 xt = _helix->x(dPhi);
2907 xt.setZ(0.);
2908 l.positionOnTrack(xt);
2909 xw.setZ(0.);
2910 l.positionOnWire(xw);
2911 l.dPhi(dPhi);
2912 return 0;
2913}

Referenced by fit2D().

◆ assign()

void TTrack::assign ( unsigned  maskForWireHit)

assigns wire hits to this track.

Definition at line 3635 of file TTrack.cxx.

3635 {
3636 hitMask |= WireHitUsed;
3637
3638 unsigned n = _links.length();
3639 for (unsigned i = 0; i < n; i++) {
3640 TMLink * l = _links[i];
3641 const TMDCWireHit * h = l->hit();
3642#ifdef TRKRECO_DEBUG
3643 if (h->track()) {
3644 std::cout << "TTrack::assign !!! hit(" << h->wire()->name();
3645 std::cout << ") already assigned" << std::endl;
3646 }
3647#endif
3648
3649 //...This function will be moved to TTrackManager...
3650 h->track((TTrack *) this);
3651 h->state(h->state() | hitMask);
3652 }
3653}
#define WireHitUsed
Definition: TMDCWireHit.h:47
unsigned state(void) const
returns state.
Definition: TMDCWireHit.h:230
const TTrack *const track(void) const
assigns a pointer to a TTrack.
Definition: TMDCWireHit.h:280
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
Definition: TMDCWireHit.h:218
A class to represent a track in tracking.
Definition: TTrack.h:129

◆ associateHits() [1/2]

const AList< TMLink > & TTrack::associateHits ( const AList< TMLink > &  hits)
inline

Definition at line 717 of file TTrack.h.

717 {
718 _associateHits = list;
719 return _associateHits;
720}

◆ associateHits() [2/2]

const AList< TMLink > & TTrack::associateHits ( void  ) const
inline

sets/returns a list of associated TMLink which are used for table output.

Definition at line 724 of file TTrack.h.

724 {
725 return _associateHits;
726}

◆ center()

TPoint2D TTrack::center ( void  ) const
inline

returns position of helix center.

Definition at line 595 of file TTrack.h.

595 {
596 return TPoint2D(_helix->center());
597}
A class to represent a point in 2D.
Definition: TPoint2D.h:37

Referenced by stereoHitForCurl(), and szPosition().

◆ charge() [1/2]

double TTrack::charge ( double  a)
inline

sets charge.

Definition at line 510 of file TTrack.h.

510 {
511 return _charge = a;
512}

◆ charge() [2/2]

double TTrack::charge ( void  ) const
inline

◆ chi2()

double TTrack::chi2 ( void  ) const
inline

returns chi2.

Definition at line 495 of file TTrack.h.

495 {
496#ifdef TRKRECO_DEBUG
497 if (! _fitted) std::cout << "TTrack::chi2 !!! chi2 not updated" << std::endl;
498#endif
499 return _chi2;
500}

Referenced by fit2D(), and TTrackManager::sortTracksByQuality().

◆ confidenceLevel()

double TTrack::confidenceLevel ( void  ) const
inline

returns confidence level.

Definition at line 547 of file TTrack.h.

547 {
548 return chisq2confLevel((int) _ndf, _chi2);
549}
double chisq2confLevel(int n, double chi2)
ALPHA = 10000. / 2.99792458 / 15.
Definition: TMDCUtil.cxx:156

◆ daughter() [1/2]

TTrack * TTrack::daughter ( TTrack a)
inline

Definition at line 663 of file TTrack.h.

663 {
664 if (a) _state |= (TrackHasDaughter << TrackRelationShift);
665 else _state &= (~(TrackHasDaughter << TrackRelationShift));
666 return _daughter = a;
667}
#define TrackHasDaughter
Definition: TTrack.h:61
#define TrackRelationShift
Definition: TTrack.h:62

◆ daughter() [2/2]

TTrack * TTrack::daughter ( void  ) const
inline

Definition at line 657 of file TTrack.h.

657 {
658 return _daughter;
659}

Referenced by TTrackManager::setCurlerFlags().

◆ deleteListForCurl() [1/2]

void TTrack::deleteListForCurl ( AList< HepPoint3D > &  l1,
AList< HepPoint3D > &  l2 
) const

◆ deleteListForCurl() [2/2]

void TTrack::deleteListForCurl ( AList< HepPoint3D > &  l1,
AList< HepPoint3D > &  l2,
AList< HepPoint3D > &  l3 
) const

◆ dump()

void TTrack::dump ( const std::string &  message = std::string(""),
const std::string &  prefix = std::string("") 
) const
virtual

dumps debug information.

Reimplemented from TTrackBase.

Definition at line 229 of file TTrack.cxx.

229 {
230 bool def = false;
231 if (msg == "") def = true;
232 std::string pre = pre0;
233 std::string tab;
234 for (unsigned i = 0; i < pre.length(); i++)
235 tab += " ";
236 if (def || msg.find("track") != std::string::npos || msg.find("detail") != std::string::npos) {
237 std::cout << pre
238 << p() << "(pt=" << pt() << ")" << std::endl
239 << tab
240 << "links=" << _links.length()
241 << "(cores=" << nCores()
242 << "),chrg=" << _charge
243 << ",ndf=" << _ndf
244 << ",chi2=" << _chi2
245 << std::endl;
246 pre = tab;
247 }
248 if (msg.find("helix") != std::string::npos || msg.find("detail") != std::string::npos) {
249 std::cout << pre
250 << "pivot=" << _helix->pivot()
251 << ",center=" << _helix->center() << std::endl
252 << pre
253 << "helix=(" << _helix->a()[0] << "," << _helix->a()[1]<< ","
254 << _helix->a()[2] << "," << _helix->a()[3] << ","
255 << _helix->a()[4] << ")" << std::endl;
256 pre = tab;
257 }
258 if (! def) TTrackBase::dump(msg, pre);
259}
const HepPoint3D & pivot(void) const
returns pivot position.
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TTrackBase.cxx:58
unsigned nCores(unsigned mask=0) const
returns # of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
Definition: TTrackBase.cxx:325
double pt(void) const
returns Pt.
Definition: TTrack.h:528
Hep3Vector p(void) const
returns momentum.
Definition: TTrack.h:553

◆ finalHits() [1/2]

const AList< TMLink > & TTrack::finalHits ( const AList< TMLink > &  hits)
inline

Definition at line 704 of file TTrack.h.

704 {
705 _finalHits = list;
706 return _finalHits;
707}

◆ finalHits() [2/2]

const AList< TMLink > & TTrack::finalHits ( void  ) const
inline

finds cathode hits associated to this track.

relation between cluster and wire relation between cluster and layer appends Svd Hits(TSvdHit) returns Svd Hits List sets/returns a list of TMLink which are used for table output.

Definition at line 711 of file TTrack.h.

711 {
712 return _finalHits;
713}

◆ finder() [1/2]

unsigned TTrack::finder ( unsigned  finderMask)
inline

Definition at line 607 of file TTrack.h.

607 {
608 _state |= (a & TrackFinderMask);
609 return finder();
610}
#define TrackFinderMask
Definition: TTrack.h:30
unsigned finder(void) const
sets/returns finder.
Definition: TTrack.h:601

◆ finder() [2/2]

unsigned TTrack::finder ( void  ) const
inline

sets/returns finder.

Definition at line 601 of file TTrack.h.

601 {
602 return _state & TrackFinderMask;
603}

Referenced by finder(), and TTrackManager::salvage().

◆ fit2D()

int TTrack::fit2D ( unsigned  ipFlag = 0,
double  ipDistance = 0.1,
double  ipError = 0.015 
)

fits itself. Error was happened if return value is not zero.

fits itself with r-phi view. Error was happened if return value is not zero.

Definition at line 2542 of file TTrack.cxx.

2542 {
2543#ifdef TRKRECO_DEBUG_DETAIL
2544 std::cout << " TTrack::fit2D(r-phi) ..." << std::endl;
2545#endif
2546 //if(_fitted)return 0;
2547
2548 //...Check # of hits...
2549
2550 //std::cout << "# = " << _links.length() << std::endl;
2551 //...Setup...
2552 unsigned nTrial(0);
2553 Vector a(_helix->a());
2554 double chi2;
2555 double chi2Old = 1.0e+99;
2556 Vector dchi2da(3);
2557 SymMatrix d2chi2d2a(3,0);
2558 Vector da(5), dxda(3), dyda(3);
2559 Vector dDda(3);
2560 const double convergence = 1.0e-5;
2561 Vector f(3);
2562 int err = 0;
2563 double factor = 1.0;
2564 unsigned usedWireNumber = 0;
2565
2566 //...Fitting loop...
2567 while(nTrial < 100){
2568 //...Set up...
2569 chi2 = 0.;
2570 for (unsigned j=0;j<3;++j) dchi2da[j] = 0.;
2571 d2chi2d2a = SymMatrix(3, 0);
2572 usedWireNumber = 0;
2573
2574 //...Loop with hits...
2575 unsigned i = 0;
2576 while (TMLink * l = _links[i++]) {
2577 if(l->fit2D() == 0)continue;
2578 const TMDCWireHit &h = *l->hit();
2579
2580 //...Cal. closest points...
2581 if(approach2D(*l) != 0)continue;
2582 double dPhi = l->dPhi();
2583 const HepPoint3D & onTrack = l->positionOnTrack();
2584 const HepPoint3D & onWire = l->positionOnWire();
2585 HepPoint3D onTrack2(onTrack.x(),onTrack.y(),0.);
2586 HepPoint3D onWire2(onWire.x(),onWire.y(),0.);
2587
2588 //...Obtain drift distance and its error...
2589 unsigned leftRight = WireHitRight;
2590 if (onWire2.cross(onTrack2).z() < 0.) leftRight = WireHitLeft;
2591 double distance = h.drift(leftRight);
2592 double eDistance = h.dDrift(leftRight);
2593 double eDistance2 = eDistance * eDistance;
2594 if(eDistance == 0.){
2595 std::cout << "Error(?) : Drift Distance Error = 0 in fit2D of TrkReco." << std::endl;
2596 continue;
2597 }
2598
2599 //...Residual...
2600 HepVector3D v = onTrack2 - onWire2;
2601 double vmag = v.mag();
2602 double dDistance = vmag - distance;
2603
2604 //...dxda...
2605 if(this->dxda2D(*l, dPhi, dxda, dyda) != 0)continue;
2606
2607 //...Chi2 related...
2608 //Vector3 vw(0.,0.,1.);
2609 dDda = (vmag > 0.)
2610 ? (v.x()*dxda+v.y()*dyda)/vmag
2611 : Vector(3,0);
2612 if(vmag<=0.0){
2613 std::cout << " in fit2D " << onTrack << ", " << onWire;
2614 h.dump();
2615 continue;
2616 }
2617 dchi2da += (dDistance/eDistance2)*dDda;
2618 d2chi2d2a += vT_times_v(dDda)/eDistance2;
2619 double pChi2 = dDistance*dDistance/eDistance2;
2620 chi2 += pChi2;
2621
2622 //...Store results...
2623 l->update(onTrack2, onWire2, leftRight, pChi2);
2624 ++usedWireNumber;
2625 }
2626 if(ipFlag != 0){
2627 double kappa = _helix->a()[2];
2628 double phi0 = _helix->a()[1];
2629 HepPoint3D xc(_helix->center());
2630 HepPoint3D onWire(0.,0.,0.);
2631 HepPoint3D xt(_helix->x());
2632 HepVector3D v0(xt-xc);
2633 HepVector3D v1(onWire-xc);
2634 double vCrs = v0.x() * v1.y() - v0.y() * v1.x();
2635 double vDot = v0.x() * v1.x() + v0.y() * v1.y();
2636 double dPhi = atan2(vCrs, vDot);
2637 HepPoint3D onTrack(_helix->x(dPhi).x(),_helix->x(dPhi).y(),0.);
2638 double distance = ipDistance;
2639 double eDistance = ipError;
2640 double eDistance2 = eDistance * eDistance;
2641
2642 HepVector3D v = onTrack - onWire;
2643 double vmag = v.mag();
2644 double dDistance = vmag - distance;
2645
2646 if(this->dxda2D(dPhi, dxda, dyda) != 0)goto ipOff;
2647
2648 dDda = (vmag > 0.)
2649 ? (v.x()*dxda+v.y()*dyda)/vmag
2650 : Vector(3,0);
2651 if(vmag<=0.0){
2652 goto ipOff;
2653 }
2654 dchi2da += (dDistance/eDistance2)*dDda;
2655 d2chi2d2a += vT_times_v(dDda)/eDistance2;
2656 double pChi2 = dDistance*dDistance/eDistance2;
2657 chi2 += pChi2;
2658
2659 ++usedWireNumber;
2660 }
2661 ipOff:
2662 if(usedWireNumber < 4){
2663 err = -2;
2664 break;
2665 }
2666
2667 //...Check condition...
2668 double change = chi2Old - chi2;
2669 if(fabs(change) < convergence)break;
2670 if(change < 0.){
2671#ifdef TRKRECO_DEBUG_DETAIL
2672 std::cout << "chi2Old, chi2=" << chi2Old <<" "<< chi2 << std::endl;
2673#endif
2674 //change to the old value.
2675 a += factor*da;
2676 _helix->a(a);
2677
2678 chi2 = 0.;
2679 for (unsigned j=0;j<3;++j) dchi2da[j] = 0.;
2680 d2chi2d2a = SymMatrix(3,0);
2681 usedWireNumber = 0;
2682
2683 //...Loop with hits...
2684 unsigned i = 0;
2685 while (TMLink *l = _links[i++]) {
2686 if(l->fit2D() == 0)continue;
2687 const TMDCWireHit & h = * l->hit();
2688
2689 //...Cal. closest points...
2690 if(approach2D(*l) != 0)continue;
2691 double dPhi = l->dPhi();
2692 const HepPoint3D & onTrack = l->positionOnTrack();
2693 const HepPoint3D & onWire = l->positionOnWire();
2694 HepPoint3D onTrack2(onTrack.x(),onTrack.y(),0.);
2695 HepPoint3D onWire2(onWire.x(),onWire.y(),0.);
2696
2697 //...Obtain drift distance and its error...
2698 unsigned leftRight = WireHitRight;
2699 if (onWire2.cross(onTrack2).z() < 0.) leftRight = WireHitLeft;
2700 double distance = h.drift(leftRight);
2701 double eDistance = h.dDrift(leftRight);
2702 double eDistance2 = eDistance * eDistance;
2703
2704 //...Residual...
2705 HepVector3D v = onTrack2 - onWire2;
2706 double vmag = v.mag();
2707 double dDistance = vmag - distance;
2708
2709 //...dxda...
2710 if(this->dxda2D(*l, dPhi, dxda, dyda) != 0)continue;
2711
2712 //...Chi2 related...
2713 dDda = (vmag>0.)
2714 ? (v.x()*dxda + v.y()*dyda)/vmag
2715 : Vector(3,0);
2716 if(vmag<=0.0) {
2717 std::cout << " in fit2D " << onTrack << ", " << onWire;
2718 h.dump();
2719 continue;
2720 }
2721 dchi2da += (dDistance/eDistance2)*dDda;
2722 d2chi2d2a += vT_times_v(dDda)/eDistance2;
2723 double pChi2 = dDistance*dDistance/eDistance2;
2724 chi2 += pChi2;
2725
2726 //...Store results...
2727 l->update(onTrack2, onWire2, leftRight, pChi2);
2728 ++usedWireNumber;
2729 }
2730 if(ipFlag != 0){
2731 double kappa = _helix->a()[2];
2732 double phi0 = _helix->a()[1];
2733 HepPoint3D xc(_helix->center());
2734 HepPoint3D onWire(0.,0.,0.);
2735 HepPoint3D xt(_helix->x());
2736 HepVector3D v0(xt-xc);
2737 HepVector3D v1(onWire-xc);
2738 double vCrs = v0.x() * v1.y() - v0.y() * v1.x();
2739 double vDot = v0.x() * v1.x() + v0.y() * v1.y();
2740 double dPhi = atan2(vCrs, vDot);
2741 HepPoint3D onTrack(_helix->x(dPhi).x(),_helix->x(dPhi).y(),0.);
2742 double distance = ipDistance;
2743 double eDistance = ipError;
2744 double eDistance2 = eDistance * eDistance;
2745
2746 HepVector3D v = onTrack - onWire;
2747 double vmag = v.mag();
2748 double dDistance = vmag - distance;
2749
2750 if(this->dxda2D(dPhi, dxda, dyda) != 0)goto ipOff2;
2751
2752 dDda = (vmag > 0.)
2753 ? (v.x()*dxda+v.y()*dyda)/vmag
2754 : Vector(3,0);
2755 if(vmag<=0.0){
2756 goto ipOff2;
2757 }
2758 dchi2da += (dDistance/eDistance2)*dDda;
2759 d2chi2d2a += vT_times_v(dDda)/eDistance2;
2760 double pChi2 = dDistance*dDistance/eDistance2;
2761 chi2 += pChi2;
2762
2763 ++usedWireNumber;
2764 }
2765 ipOff2:
2766 if(usedWireNumber < 4){
2767 err = -2;
2768 break;
2769 }
2770 //break;
2771 factor *= 0.75;
2772#ifdef TRKRECO_DEBUG_DETAIL
2773 std::cout << "factor = " << factor << std::endl;
2774 std::cout << "chi2 = " << chi2 << std::endl;
2775#endif
2776 if(factor < 0.01)break;
2777 }
2778
2779 chi2Old = chi2;
2780
2781 //...Cal. helix parameters for next loop...
2782 f = solve(d2chi2d2a, dchi2da);
2783 da[0] = f[0];
2784 da[1] = f[1];
2785 da[2] = f[2];
2786 da[3] = 0.;
2787 da[4] = 0.;
2788
2789 a -= factor*da;
2790 _helix->a(a);
2791 ++nTrial;
2792 }
2793 if(err){
2794 return err;
2795 }
2796
2797 //...Cal. error matrix...
2798 SymMatrix Ea(5,0);
2799 unsigned dim = 3;
2800 SymMatrix Eb = d2chi2d2a;
2801 SymMatrix Ec = Eb.inverse(err);
2802 Ea[0][0] = Ec[0][0];
2803 Ea[0][1] = Ec[0][1];
2804 Ea[0][2] = Ec[0][2];
2805 Ea[1][1] = Ec[1][1];
2806 Ea[1][2] = Ec[1][2];
2807 Ea[2][2] = Ec[2][2];
2808
2809 //...Store information...
2810 if(!err){
2811 _helix->a(a);
2812 _helix->Ea(Ea);
2813 }else{
2814 err = -2;
2815 }
2816
2817 _ndf = usedWireNumber-dim;
2818 _chi2 = chi2;
2819
2820 //_fitted = true;
2821
2822#define JJJTEST 0
2823#if JJJTEST
2824 double gmaxX = -9999. ,gminX = 9999.;
2825 double gmaxY = -9999. ,gminY = 9999.;
2826 FILE *gnuplot, *data;
2827 double step = 200.;
2828 double dStep = 2.*M_PI/step;
2829 for(int i=0,size = _links.length();i<size;++i){
2830 TMLink * l = _links[i];
2831 double drift = l->hit()->distance(0);
2832 char name[100] = "dat";
2833 char counter[10] = "";
2834 sprintf(counter,"%02d",i);
2835 strcat(name,counter);
2836 if((data = fopen(name,"w")) != NULL){
2837 for(int ii=0;ii<step;++ii){
2838 double X = l->wire()->xyPosition().x() + drift*cos(dStep*static_cast<double>(ii));
2839 double Y = l->wire()->xyPosition().y() + drift*sin(dStep*static_cast<double>(ii));
2840 fprintf(data,"%lf, %lf\n",X,Y);
2841 if(gmaxX < X)gmaxX = X;
2842 if(gminX > X)gminX = X;
2843 if(gmaxY < Y)gmaxY = Y;
2844 if(gminY > Y)gminY = Y;
2845 }
2846 fclose(data);
2847 }
2848 }
2849 step = 300.;
2850 dStep = 2.*M_PI/step;
2851 if((data = fopen("datc","w")) != NULL){
2852 for(int ii=0;ii<step;++ii){
2853 double X = _helix->center().x() + _helix->radius()*cos(dStep*static_cast<double>(ii));
2854 double Y = _helix->center().y() + _helix->radius()*sin(dStep*static_cast<double>(ii));
2855 fprintf(data,"%lf, %lf\n",X,Y);
2856 }
2857 fclose(data);
2858 }
2859 if((gnuplot = popen("gnuplot","w")) != NULL){
2860 fprintf(gnuplot,"set size 0.721,1.0 \n");
2861 fprintf(gnuplot,"set xrange [%f:%f] \n",gminX,gmaxX);
2862 fprintf(gnuplot,"set yrange [%f:%f] \n",gminY,gmaxY);
2863 if(_links.length() == 4){
2864 fprintf(gnuplot,"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, \"dat02\" with line, \"dat03\" with line \n");
2865 }else if(_links.length() == 5){
2866 fprintf(gnuplot,"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, \"dat02\" with line, \"dat03\" with line, \"dat04\" with line \n");
2867 }else if(_links.length() == 6){
2868 fprintf(gnuplot,"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, \"dat02\" with line, \"dat03\" with line, \"dat04\" with line, \"dat05\" with line \n");
2869 }else if(_links.length() == 7){
2870 fprintf(gnuplot,"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, \"dat02\" with line, \"dat03\" with line, \"dat04\" with line, \"dat05\" with line, \"dat06\" with line \n");
2871 }else if(_links.length() == 8){
2872 fprintf(gnuplot,"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, \"dat02\" with line, \"dat03\" with line, \"dat04\" with line, \"dat05\" with line, \"dat06\" with line, \"dat07\" with line \n");
2873 }else if(_links.length() == 9){
2874 fprintf(gnuplot,"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, \"dat02\" with line, \"dat03\" with line, \"dat04\" with line, \"dat05\" with line, \"dat06\" with line, \"dat07\" with line, \"dat08\" with line \n");
2875 }else if(_links.length() == 10){
2876 fprintf(gnuplot,"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, \"dat02\" with line, \"dat03\" with line, \"dat04\" with line, \"dat05\" with line, \"dat06\" with line, \"dat07\" with line, \"dat08\" with line, \"dat09\" with line \n");
2877 }else if(_links.length() >= 11){
2878 fprintf(gnuplot,"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, \"dat02\" with line, \"dat03\" with line, \"dat04\" with line, \"dat05\" with line, \"dat06\" with line, \"dat07\" with line, \"dat08\" with line, \"dat09\" with line, \"dat10\" with line \n");
2879 }
2880 fflush(gnuplot);
2881 char tmp[8];
2882 gets(tmp);
2883 pclose(gnuplot);
2884 }
2885#endif //JJJTEST
2886
2887 return err;
2888}
TTree * data
#define WireHitLeft
Definition: TMDCWireHit.h:21
#define WireHitRight
Definition: TMDCWireHit.h:22
const HepSymMatrix & Ea(void) const
returns error matrix.
double radius(void) const
returns radious of helix.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TMDCWireHit.cxx:64
float dDrift(unsigned) const
returns drift distance error.
Definition: TMDCWireHit.h:243
float drift(unsigned) const
returns drift distance.
Definition: TMDCWireHit.h:236
virtual double distance(const TMLink &) const
returns distance to a position of TMLink in TMLink space.
Definition: TTrackBase.cxx:89
const std::string & name(void) const
returns/sets name.
Definition: TTrack.h:516
int approach2D(TMLink &) const
Definition: TTrack.cxx:2891
double chi2(void) const
returns chi2.
Definition: TTrack.h:495

Referenced by refine2D().

◆ fitting() [1/2]

unsigned TTrack::fitting ( unsigned  fitMask)
inline

Definition at line 636 of file TTrack.h.

636 {
637 _state |= ((a << TrackFitShift) & TrackFitMask);
638 return fitting();
639}
#define TrackFitShift
Definition: TTrack.h:56
#define TrackFitMask
Definition: TTrack.h:57
unsigned fitting(void) const
sets/returns fitting status.
Definition: TTrack.h:630

◆ fitting() [2/2]

unsigned TTrack::fitting ( void  ) const
inline

sets/returns fitting status.

Definition at line 630 of file TTrack.h.

630 {
631 return (_state >> TrackFitShift) & TrackFitMask;
632}

Referenced by fitting().

◆ getFinderType()

unsigned TTrack::getFinderType ( void  ) const
inline

Definition at line 680 of file TTrack.h.

680 {
681 return _findertype;
682}

◆ HelCyl()

int TTrack::HelCyl ( double  rhole,
double  rcyl,
double  zb,
double  zf,
double  epsl,
double &  phi,
HepPoint3D xp 
) const

returns a cathode hit list.

calculates an intersection of this track and a cylinder.

Definition at line 316 of file TTrack.cxx.

322 {
323
324
325 int status(0); // return value
326 //---------------------------------------------------------------------
327 // value | ext | status
328 //---------------------------------------------------------------------
329 // 1. | OK |
330 // -1. | NO | charge = 0
331 // 0. | NO | | tanl | < 0.1 ( neglect | lamda | < 5.7 deg. )
332 // | | or | dPhi | > 2 pi ( neglect curly track )
333 // | | or cannot reach to r=rhole at z = zb or zf.
334 // 2. | OK | backward , ext point set on z = zb
335 // 3. | OK | forward , ext point set on z = zf
336 //---------------------------------------------------------------------
337 // * when value = 0,2,3 , ext(z) <= zb or ext(z) >= zf
338
339 //--- debug
340 // std::cout << " " << std::endl;
341 // std::cout << "HelCyl called .. rhole=" << rhole << " rCyl=" << rCyl ;
342 // std::cout << " zb=" << zb << " zf=" << zf << " epsl=" << epsl << std::endl;
343 //--- debug end
344
345 // Check of Charge
346
347 if ( int(_charge) == 0 ) {
348 std::cout << "HelCyl gets a straight line !!" << std::endl;
349 return -1 ;
350 }
351
352 // parameters
353
354 HepPoint3D CenterCyl( 0., 0., 0. );
355 HepPoint3D CenterTrk = _helix->center();
356 double rTrk = fabs( _helix->radius() );
357
358 double rPivot = fabs( _helix->pivot().perp() );
359
360 double phi0 = _helix->a()[1];
361 double tanl = _helix->a()[4];
362 // double zdz = _helix->pivot().z() + _helix->a()[3];
363 double dPhi;
364 double zee;
365
366
367 // Calculate intersections between cylinder and track
368 // if return value = 2 track hitting barrel part
369
370 HepPoint3D Cross1, Cross2;
371
372 if (intersection( CenterTrk,_charge * rTrk ,CenterCyl,rCyl,
373 epsl,
374 Cross1,Cross2)
375 == 2 ) {
376
377 double phiCyl = atan2( _charge * ( CenterTrk.y() - Cross1.y() ),
378 _charge * ( CenterTrk.x() - Cross1.x() ) );
379 phiCyl = ( phiCyl > 0. ) ? phiCyl : phiCyl + 2. * M_PI;
380
381 dPhi = phiCyl - phi0;
382
383 // dPhi region ( at cylinder )
384 // -pi <= dPhi < pi
385
386
387 double PhiYobun = 1./ fabs( _helix->radius() );
388 double zero = 0.00001;
389
390 if( _charge >=0. ){
391 if( dPhi > PhiYobun ) dPhi -= 2. * M_PI;
392 if( -2. * M_PI - zero <= dPhi <= ( -2.* M_PI + PhiYobun ) )
393 dPhi += 2. * M_PI;
394 }
395
396 if( _charge < 0. ){
397 if( dPhi < -PhiYobun ) dPhi += 2. * M_PI;
398 if( 2. * M_PI + zero >= dPhi >= ( 2. * M_PI - PhiYobun ) )
399 dPhi -= 2. * M_PI;
400 }
401
402 if( dPhi < - M_PI ) dPhi += 2. * M_PI;
403 if( dPhi >= M_PI ) dPhi -= 2. * M_PI;
404
405 //--debug
406 // std::cout << "dPhi = " << dPhi << std::endl;
407 //--debug end
408
409 xp.setX( Cross1.x() );
410 xp.setY( Cross1.y() );
411 xp.setZ( _helix->x(dPhi).z() );
412 // xp.setZ( zdz - _charge * rTrk * tanl * dPhi );
413
414 if ( xp.z() > zb && xp.z() < zf ) {
415 phi = dPhi;
416 //--- debug ---
417 // std::cout << "return1 ( ext success )" << std::endl;
418 // std::cout << " xp:= " << xp.x() << ", " << xp.y() << ", " << xp.z() << std::endl;
419 //--- debug ----
420 return 1 ;
421 }
422 }
423
424
425 // tracks hitting endcaps
426
427 if ( fabs(tanl) < 0.1 ) {
428 //--- debug ---
429 // std::cout << "return0 ( ext failed , |tanl| < 0.1 )" << std::endl;
430 // std::cout << " xp:= " << xp.x() << ", " << xp.y() << ", " << xp.z() << std::endl;
431 //--- debug ---
432 return 0;
433 }
434
435 if ( tanl > 0. ) {
436 zee = zf ;
437 status = 3 ;
438 }
439 else {
440 zee = zb ;
441 status = 2 ;
442 }
443
444 dPhi = _charge * ( _helix->x(0.).z() - zee )/rTrk/tanl;
445 // dPhi = _charge * ( zdz - zee )/rTrk/tanl;
446
447 // Requre dPhi < 2*pi
448
449 if ( fabs(dPhi) > 2. * M_PI ) {
450 //--- debug ---
451 // std::cout << " return0 ( ext failed , dPhi > 2pi )" << std::endl;
452 // std::cout << " xp:= " << xp.x() << ", " << xp.y() << ", " << xp.z() << std::endl;
453 //--- debug ---
454 return 0 ;
455 }
456
457 xp.setX( _helix->x(dPhi).x() );
458 xp.setY( _helix->x(dPhi).y() );
459 xp.setZ( zee );
460
461 double test = xp.perp2() - rhole*rhole ;
462 if ( test < 0. ) {
463 //--- debug ---
464 // std::cout << "return0 ( cannot reach to rhole at z=edge )" << std::endl;
465 // std::cout << " xp:= " << xp.x() << ", " << xp.y() << ", " << xp.z() << std::endl;
466 //--- debug ---
467 return 0 ;
468 }
469
470 phi = dPhi ;
471 //--- debug ---
472 // std::cout << "return" << status << std::endl;
473 // std::cout << " xp:= " << xp.x() << ", " << xp.y() << ", " << xp.z() << std::endl;
474 //--- debug ---
475
476 return status ;
477
478}
std::string test
Definition: CalibModel.cxx:43
const DifNumber zero
int intersection(const HepPoint3D &c1, double r1, const HepPoint3D &c2, double r2, double eps, HepPoint3D &x1, HepPoint3D &x2)
Circle utilities.
Definition: TMDCUtil.cxx:99

◆ helix()

const Helix & TTrack::helix ( void  ) const
inline

returns helix parameter.

Definition at line 477 of file TTrack.h.

477 {
478#ifdef TRKRECO_DEBUG
479 // if (! _fitted) std::cout << "TTrack::helix !!! helix not updated" << std::endl;
480#endif
481 return * _helix;
482}

Referenced by TBuilder::buildStereo(), TBuilder0::buildStereo(), TBuilderCosmic::buildStereo(), TBuilderCurl::buildStereo(), TBuilder0::buildStereo0(), TBuilderCurl::buildStereoMC(), calVirtualCircle(), and TTrackManager::merge().

◆ impact()

double TTrack::impact ( void  ) const
inline

returns signed impact parameter to the origin.

Definition at line 571 of file TTrack.h.

571 {
572 return fabs(_helix->radius()) - _helix->center().mag();
573}

Referenced by TBuilderCurl::buildStereo(), TBuilderCurl::buildStereoMC(), and TMSelector::select().

◆ mother() [1/2]

TTrack * TTrack::mother ( TTrack a)
inline

Definition at line 649 of file TTrack.h.

649 {
650 if (a) _state |= (TrackHasMother << TrackRelationShift);
651 else _state &= (~(TrackHasMother << TrackRelationShift));
652 return _mother = a;
653}
#define TrackHasMother
Definition: TTrack.h:60

◆ mother() [2/2]

TTrack * TTrack::mother ( void  ) const
inline

sets/returns mother/daughter.

Definition at line 643 of file TTrack.h.

643 {
644 return _mother;
645}

◆ movePivot()

void TTrack::movePivot ( void  )

moves pivot to the inner most hit.

Definition at line 262 of file TTrack.cxx.

262 {
263 unsigned n = _links.length();
264 if (! n) {
265 std::cout << "TTrack::movePivot !!! can't move a pivot"
266 << " because of no link";
267 std::cout << std::endl;
268 return;
269 }
270
271 //...Check cores...
273 const AList<TMLink> * links = & cores;
274 if (cores.length() == 0) links = & _links;
275
276 //...Hit loop...
277 unsigned innerMost = 0;
278 unsigned innerMostLayer = (* links)[0]->wire()->layerId();
279 n = links->length();
280 for (unsigned i = 1; i < n; i++) {
281 TMLink * l = (* links)[i];
282 if (l->wire()->layerId() < innerMostLayer) {
283 innerMost = i;
284 innerMostLayer = l->wire()->layerId();
285 }
286 }
287
288 //...Move pivot...
289 HepPoint3D newPivot = (* links)[innerMost]->positionOnWire();
290 if (quality() & TrackQuality2D)
291 newPivot.setZ(0.);
292 _helix->pivot(newPivot);
293}
#define TrackQuality2D
Definition: TTrack.h:47
unsigned layerId(void) const
returns layer id.
Definition: TMDCWire.h:219
const AList< TMLink > & cores(unsigned mask=0) const
returns a list of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
Definition: TTrackBase.cxx:317
unsigned quality(void) const
sets/returns quality.
Definition: TTrack.h:614

◆ name() [1/2]

const std::string & TTrack::name ( const std::string &  newName)
inline

Definition at line 522 of file TTrack.h.

522 {
523 return _name = a;
524}

◆ name() [2/2]

const std::string & TTrack::name ( void  ) const
inline

returns/sets name.

Definition at line 516 of file TTrack.h.

516 {
517 return _name;
518}

Referenced by TTrackMC::dump(), fit2D(), and TTrackManager::salvageAssociateHits().

◆ ndf()

unsigned TTrack::ndf ( void  ) const
inline

returns NDF.

Definition at line 486 of file TTrack.h.

486 {
487#ifdef TRKRECO_DEBUG
488 if (! _fitted) std::cout << "TTrack::ndf !!! ndf not updated" << std::endl;
489#endif
490 return _ndf;
491}

Referenced by TTrackManager::sortTracksByQuality().

◆ objectType()

unsigned TTrack::objectType ( void  ) const
inlinevirtual

returns type.

Reimplemented from TTrackBase.

Definition at line 559 of file TTrack.h.

559 {
560 return Track;
561}
#define Track
Definition: TTrackBase.h:30

◆ p()

Hep3Vector TTrack::p ( void  ) const
inline

returns momentum.

Definition at line 553 of file TTrack.h.

553 {
554 return _helix->momentum(0.);
555}
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.

Referenced by dump(), stereoHitForCurl(), and szPosition().

◆ pt()

double TTrack::pt ( void  ) const
inline

returns Pt.

Definition at line 528 of file TTrack.h.

528 {
529 return 1. / fabs(_helix->a()[2]);
530}

Referenced by TBuilderCurl::buildStereo(), TBuilderCurl::buildStereoMC(), dump(), TTrackManager::maskNormal(), TTrackManager::merge(), TMSelector::select(), and TTrackManager::sortTracksByPt().

◆ ptot()

double TTrack::ptot ( void  ) const
inline

returns magnitude of momentum.

Definition at line 540 of file TTrack.h.

540 {
541 return (1. / fabs(_helix->a()[2])) *
542 sqrt(1. + _helix->a()[4] * _helix->a()[4]);
543}

◆ pz()

double TTrack::pz ( void  ) const
inline

returns Pz.

Definition at line 534 of file TTrack.h.

534 {
535 return (1. / fabs(_helix->a()[2])) * _helix->a()[4];
536}

Referenced by TBuilderCurl::buildStereo().

◆ quality() [1/2]

unsigned TTrack::quality ( unsigned  qualityMask)
inline

Definition at line 620 of file TTrack.h.

620 {
621// _state = ((a << TrackQualityShift) & TrackQualityMask) |
622// (_state & (~ (TrackQualityMask << TrackQualityShift)));
623 _state = ((a & TrackQualityMask) << TrackQualityShift) |
624 (_state & (~ (TrackQualityMask << TrackQualityShift)));
625 return quality();
626}
#define TrackQualityMask
Definition: TTrack.h:49
#define TrackQualityShift
Definition: TTrack.h:48

◆ quality() [2/2]

unsigned TTrack::quality ( void  ) const
inline

sets/returns quality.

Definition at line 614 of file TTrack.h.

614 {
615 return (_state >> TrackQualityShift) & TrackQualityMask;
616}

Referenced by movePivot(), and quality().

◆ radius()

double TTrack::radius ( void  ) const
inline

returns signed radius.

Definition at line 577 of file TTrack.h.

577 {
578 return _helix->radius();
579}

Referenced by calVirtualCircle().

◆ refine2D()

void TTrack::refine2D ( AList< TMLink > &  list,
float  maxSigma 
)

fits itself with cathode hits.

remove bad points by chi2. Bad points are returned in a 'list'. fit() should be called before calling this function. (using stereo wire as axial wire(z=0))

Definition at line 301 of file TTrack.cxx.

301 {
302 unsigned n = _links.length();
303 AList<TMLink> bad;
304 for (unsigned i = 0; i < n; ++i) {
305 if (_links[i]->pull() > maxSigma) bad.append(_links[i]);
306 }
307 _links.remove(bad);
308 if (bad.length()){
309 _fitted = false;
310 fit2D();
311 }
312 list.append(bad);
313}
int fit2D(unsigned=0, double=0.1, double=0.015)
fits itself. Error was happened if return value is not zero.
Definition: TTrack.cxx:2542

◆ segments() [1/2]

AList< TSegment > & TTrack::segments ( void  )
inline

returns AList<TSegment>.

Definition at line 583 of file TTrack.h.

583 {
584 return _segments;
585}

Referenced by TBuilder::buildStereoNew().

◆ segments() [2/2]

const AList< TSegment > & TTrack::segments ( void  ) const
inline

Definition at line 589 of file TTrack.h.

589 {
590 return _segments;
591}

◆ setFinderType()

void TTrack::setFinderType ( unsigned  type)
inline

Definition at line 676 of file TTrack.h.

676 {
677 _findertype=type;
678}
unsigned type(void) const
returns type. Definition is depending on an object type.
Definition: TTrack.h:565

◆ state()

unsigned TTrack::state ( void  ) const
inline

returns/sets internal state.(for bank output)

Definition at line 671 of file TTrack.h.

671 {
672 return _state;
673}

◆ stereoHitForCurl() [1/4]

int TTrack::stereoHitForCurl ( AList< TMLink > &  list) const

calculates arc length and z for a stereo hit. uses these functions for curl tracks(included svd version).

Definition at line 2009 of file TTrack.cxx.

2010{
2011 if(list.length() == 0)return -1;
2012
2013 HepPoint3D center = _helix->center();
2014 HepPoint3D tmp(-999., -999., 0.);
2015 double r = fabs(_helix->curv());
2016 for(unsigned i = 0, size = list.length(); i < size; ++i){
2017 TMDCWireHit &h = *const_cast<TMDCWireHit*>(list[i]->hit());
2018 HepVector3D X = 0.5*(h.wire()->forwardPosition() +
2019 h.wire()->backwardPosition());
2020 HepVector3D x = HepVector3D(X.x(), X.y(), 0.);
2021 HepVector3D w = x - center;
2022 HepVector3D V = h.wire()->direction();
2023 HepVector3D v = HepVector3D(V.x(), V.y(), 0.);
2024 double vmag2 = v.mag2();
2025 double vmag = sqrt(vmag2);
2026 //...temporary
2027 for(unsigned j = 0; j < 4; ++j)
2028 list[i]->arcZ(tmp,j);
2029
2030 //...stereo?
2031 if (vmag == 0.) continue;
2032
2033 double drift = h.drift(WireHitLeft);
2034 double R[2] = {r + drift, r - drift};
2035 double wv = w.dot(v);
2036 double d2[2];
2037 d2[0] = vmag2*R[0]*R[0] + (wv*wv - vmag2*w.mag2()); //...= v^2*(r^2 - w^2*sin()^2)...outer
2038 d2[1] = vmag2*R[1]*R[1] + (wv*wv - vmag2*w.mag2()); //...= v^2*(r^2 - w^2*sin()^2)...inner
2039
2040 //...No crossing in R/Phi plane...
2041 if (d2[0] < 0. && d2[1] < 0.) continue;
2042
2043 bool ok_inner(true);
2044 bool ok_outer(true);
2045 double d[2] = {-1., -1.};
2046 //...outer
2047 if(d2[0] >= 0.){
2048 d[0] = sqrt(d2[0]);
2049 }else{
2050 ok_outer = false;
2051 }
2052 if(d2[1] >= 0.){
2053 d[1] = sqrt(d2[1]);
2054 }else{
2055 ok_inner = false;
2056 }
2057
2058 //...Cal. length and z to crossing points...
2059 double l[2][2];
2060 double z[2][2];
2061 //...outer
2062 if(ok_outer){
2063 l[0][0] = (- wv + d[0]) / vmag2; //...= (-wvcos()+d)/v/v = (-wcos() + (r^2 - w^2*sin()^2)^0.5)/v
2064 l[1][0] = (- wv - d[0]) / vmag2; //...= (-wvcos()+d)/v/v = (-wcos() - (r^2 - w^2*sin()^2)^0.5)/v
2065 z[0][0] = X.z() + l[0][0]*V.z();
2066 z[1][0] = X.z() + l[1][0]*V.z();
2067 }
2068 //...inner
2069 if(ok_inner){
2070 l[0][1] = (- wv + d[1]) / vmag2; //...= (-wvcos()+d)/v/v = (-wcos() + (r^2 - w^2*sin()^2)^0.5)/v
2071 l[1][1] = (- wv - d[1]) / vmag2; //...= (-wvcos()+d)/v/v = (-wcos() - (r^2 - w^2*sin()^2)^0.5)/v
2072 z[0][1] = X.z() + l[0][1]*V.z();
2073 z[1][1] = X.z() + l[1][1]*V.z();
2074 }
2075
2076 //...Cal. xy position of crossing points...
2077 HepVector3D p[2][2];
2078#if 1
2079 HepVector3D tp[2][2];
2080#endif
2081 if(ok_outer){
2082 p[0][0] = x + l[0][0] * v;
2083 p[1][0] = x + l[1][0] * v;
2084#if 1
2085 tp[0][0] = p[0][0];
2086 tp[1][0] = p[1][0];
2087#endif
2088 HepVector3D tmp_pc = p[0][0] - center;
2089 HepVector3D pc0 = HepVector3D(tmp_pc.x(), tmp_pc.y(), 0.);
2090 p[0][0] -= drift/pc0.mag()*pc0;
2091 tmp_pc = p[1][0] - center;
2092 HepVector3D pc1 = HepVector3D(tmp_pc.x(), tmp_pc.y(), 0.);
2093 p[1][0] -= drift/pc1.mag()*pc1;
2094 }
2095#define JJTEST 0
2096 if(ok_inner){
2097 p[0][1] = x + l[0][1] * v;
2098 p[1][1] = x + l[1][1] * v;
2099#if JJTEST
2100 tp[0][1] = p[0][1];
2101 tp[1][1] = p[1][1];
2102#endif
2103 HepVector3D tmp_pc = p[0][1] - center;
2104 HepVector3D pc0 = HepVector3D(tmp_pc.x(), tmp_pc.y(), 0.);
2105 p[0][1] += drift/pc0.mag()*pc0;
2106 tmp_pc = p[1][1] - center;
2107 HepVector3D pc1 = HepVector3D(tmp_pc.x(), tmp_pc.y(), 0.);
2108 p[1][1] += drift/pc1.mag()*pc1;
2109 }
2110
2111 //...boolean
2112 bool ok_xy[2][2];
2113 if(ok_outer){
2114 ok_xy[0][0] = true;
2115 ok_xy[1][0] = true;
2116 }else{
2117 ok_xy[0][0] = false;
2118 ok_xy[1][0] = false;
2119 }
2120 if(ok_inner){
2121 ok_xy[0][1] = true;
2122 ok_xy[1][1] = true;
2123 }else{
2124 ok_xy[0][1] = false;
2125 ok_xy[1][1] = false;
2126 }
2127 if(ok_outer){
2128 if (_charge * (center.x() * p[0][0].y() - center.y() * p[0][0].x()) < 0.)
2129 ok_xy[0][0] = false;
2130 if (_charge * (center.x() * p[1][0].y() - center.y() * p[1][0].x()) < 0.)
2131 ok_xy[1][0] = false;
2132 }
2133 if(ok_inner){
2134 if (_charge * (center.x() * p[0][1].y() - center.y() * p[0][1].x()) < 0.)
2135 ok_xy[0][1] = false;
2136 if (_charge * (center.x() * p[1][1].y() - center.y() * p[1][1].x()) < 0.)
2137 ok_xy[1][1] = false;
2138 }
2139 if(!ok_inner && ok_outer && (!ok_xy[0][0]) && (!ok_xy[1][0])){
2140 continue;
2141 }
2142 if(ok_inner && !ok_outer && (!ok_xy[0][1]) && (!ok_xy[1][1])){
2143 continue;
2144 }
2145
2146 //...Check z position...
2147 if(ok_xy[0][0]){
2148 if (z[0][0] < h.wire()->backwardPosition().z() ||
2149 z[0][0] > h.wire()->forwardPosition().z()) ok_xy[0][0] = false;
2150 }
2151 if(ok_xy[1][0]){
2152 if (z[1][0] < h.wire()->backwardPosition().z() ||
2153 z[1][0] > h.wire()->forwardPosition().z()) ok_xy[1][0] = false;
2154 }
2155 if(ok_xy[0][1]){
2156 if (z[0][1] < h.wire()->backwardPosition().z() ||
2157 z[0][1] > h.wire()->forwardPosition().z()) ok_xy[0][1] = false;
2158 }
2159 if(ok_xy[1][1]){
2160 if (z[1][1] < h.wire()->backwardPosition().z() ||
2161 z[1][1] > h.wire()->forwardPosition().z()) ok_xy[1][1] = false;
2162 }
2163 if ((!ok_xy[0][0]) && (!ok_xy[1][0]) &&
2164 (!ok_xy[0][1]) && (!ok_xy[1][1])){
2165 continue;
2166 }
2167 double cosdPhi, dPhi;
2168 unsigned index;
2169 index = 0;
2170 if(ok_xy[0][0]){
2171 //...cal. arc length...
2172 cosdPhi = - center.dot((p[0][0] - center).unit()) / center.mag();
2173 if(fabs(cosdPhi) < 1.0){
2174 dPhi = acos(cosdPhi);
2175 }else if(cosdPhi >= 1.0){
2176 dPhi = 0.;
2177 }else{
2178 dPhi = M_PI;
2179 }
2180 list[i]->arcZ(HepPoint3D(r*dPhi, z[0][0], 0.), index);
2181 //std::cout << r*dPhi << ", " << z[0][0] << std::endl;
2182 ++index;
2183 }
2184 if(ok_xy[1][0]){
2185 //...cal. arc length...
2186 cosdPhi = - center.dot((p[1][0] - center).unit()) / center.mag();
2187 if(fabs(cosdPhi) < 1.0){
2188 dPhi = acos(cosdPhi);
2189 }else if(cosdPhi >= 1.0){
2190 dPhi = 0.;
2191 }else{
2192 dPhi = M_PI;
2193 }
2194 list[i]->arcZ(HepPoint3D(r*dPhi, z[1][0], 0.), index);
2195 //std::cout << r*dPhi << ", " << z[1][0] << std::endl;
2196 ++index;
2197 }
2198 if(ok_xy[0][1]){
2199 //...cal. arc length...
2200 cosdPhi = - center.dot((p[0][1] - center).unit()) / center.mag();
2201 if(fabs(cosdPhi) < 1.0){
2202 dPhi = acos(cosdPhi);
2203 }else if(cosdPhi >= 1.0){
2204 dPhi = 0.;
2205 }else{
2206 dPhi = M_PI;
2207 }
2208 list[i]->arcZ(HepPoint3D(r*dPhi, z[0][1], 0.), index);
2209 //std::cout << r*dPhi << ", " << z[0][1] << std::endl;
2210 ++index;
2211 }
2212 if(ok_xy[1][1]){
2213 //...cal. arc length...
2214 cosdPhi = - center.dot((p[1][1] - center).unit()) / center.mag();
2215 if(fabs(cosdPhi) < 1.0){
2216 dPhi = acos(cosdPhi);
2217 }else if(cosdPhi >= 1.0){
2218 dPhi = 0.;
2219 }else{
2220 dPhi = M_PI;
2221 }
2222 list[i]->arcZ(HepPoint3D(r*dPhi, z[1][1], 0.), index);
2223 //std::cout << r*dPhi << ", " << z[1][1] << std::endl;
2224 ++index;
2225 }
2226
2227#if JJTEST
2228 double gmaxX = -9999. ,gminX = 9999.;
2229 double gmaxY = -9999. ,gminY = 9999.;
2230 FILE *gnuplot, *data;
2231 double step = 100.;
2232 double dStep = 2.*M_PI/step;
2233 if((data = fopen("dat1","w")) != NULL){
2234 if(ok_xy[0][0]){
2235 for(int ii=0;ii<step;++ii){
2236 double X = tp[0][0].x() + drift*cos(dStep*static_cast<double>(ii));
2237 double Y = tp[0][0].y() + drift*sin(dStep*static_cast<double>(ii));
2238 fprintf(data,"%lf, %lf\n",X,Y);
2239 if(gmaxX < X)gmaxX = X;
2240 if(gminX > X)gminX = X;
2241 if(gmaxY < Y)gmaxY = Y;
2242 if(gminY > Y)gminY = Y;
2243 }
2244 }
2245 fclose(data);
2246 }
2247 if((data = fopen("dat2","w")) != NULL){
2248 if(ok_xy[1][0]){
2249 for(int ii=0;ii<step;++ii){
2250 double X = tp[1][0].x() + drift*cos(dStep*static_cast<double>(ii));
2251 double Y = tp[1][0].y() + drift*sin(dStep*static_cast<double>(ii));
2252 fprintf(data,"%lf, %lf\n",X,Y);
2253 if(gmaxX < X)gmaxX = X;
2254 if(gminX > X)gminX = X;
2255 if(gmaxY < Y)gmaxY = Y;
2256 if(gminY > Y)gminY = Y;
2257 }
2258 }
2259 fclose(data);
2260 }
2261 if((data = fopen("dat3","w")) != NULL){
2262 if(ok_xy[0][1]){
2263 for(int ii=0;ii<step;++ii){
2264 double X = tp[0][1].x() + drift*cos(dStep*static_cast<double>(ii));
2265 double Y = tp[0][1].y() + drift*sin(dStep*static_cast<double>(ii));
2266 fprintf(data,"%lf, %lf\n",X,Y);
2267 if(gmaxX < X)gmaxX = X;
2268 if(gminX > X)gminX = X;
2269 if(gmaxY < Y)gmaxY = Y;
2270 if(gminY > Y)gminY = Y;
2271 }
2272 }
2273 fclose(data);
2274 }
2275 if((data = fopen("dat4","w")) != NULL){
2276 if(ok_xy[1][1]){
2277 for(int ii=0;ii<step;++ii){
2278 double X = tp[1][1].x() + drift*cos(dStep*static_cast<double>(ii));
2279 double Y = tp[1][1].y() + drift*sin(dStep*static_cast<double>(ii));
2280 fprintf(data,"%lf, %lf\n",X,Y);
2281 if(gmaxX < X)gmaxX = X;
2282 if(gminX > X)gminX = X;
2283 if(gmaxY < Y)gmaxY = Y;
2284 if(gminY > Y)gminY = Y;
2285 }
2286 }
2287 fclose(data);
2288 }
2290 HepVector3D tDist(tX.x(), tX.y(), 0.);
2291 double tD = tDist.mag();
2292 double vvvM = 1./ v.mag();
2293 HepVector3D tDire = vvvM*v;
2294 step = 2.;
2295 dStep = tD/step;
2296 if((data = fopen("dat5","w")) != NULL){
2297 for(int ii=0;ii<step+1;++ii){
2298 double X = h.wire()->backwardPosition().x()+dStep*static_cast<double>(ii)*tDire.x();
2299 double Y = h.wire()->backwardPosition().y()+dStep*static_cast<double>(ii)*tDire.y();
2300 fprintf(data,"%lf, %lf\n",X,Y);
2301 if(gmaxX < X)gmaxX = X;
2302 if(gminX > X)gminX = X;
2303 if(gmaxY < Y)gmaxY = Y;
2304 if(gminY > Y)gminY = Y;
2305 }
2306 fclose(data);
2307 }
2308 if((data = fopen("dat6","w")) != NULL){
2309 double X = h.wire()->backwardPosition().x();
2310 double Y = h.wire()->backwardPosition().y();
2311 fprintf(data,"%lf, %lf\n",X,Y);
2312 if(gmaxX < X)gmaxX = X;
2313 if(gminX > X)gminX = X;
2314 if(gmaxY < Y)gmaxY = Y;
2315 if(gminY > Y)gminY = Y;
2316 fclose(data);
2317 }
2318 if((data = fopen("dat7","w")) != NULL){
2319 double X = h.wire()->forwardPosition().x();
2320 double Y = h.wire()->forwardPosition().y();
2321 fprintf(data,"%lf, %lf\n",X,Y);
2322 if(gmaxX < X)gmaxX = X;
2323 if(gminX > X)gminX = X;
2324 if(gmaxY < Y)gmaxY = Y;
2325 if(gminY > Y)gminY = Y;
2326 fclose(data);
2327 }
2328 step = 300.;
2329 dStep = 2.*M_PI/step;
2330 if((data = fopen("dat8","w")) != NULL){
2331 for(int ii=0;ii<step;++ii){
2332 double X = center.x() + r*cos(dStep*static_cast<double>(ii));
2333 double Y = center.y() + r*sin(dStep*static_cast<double>(ii));
2334 fprintf(data,"%lf, %lf\n",X,Y);
2335 }
2336 fclose(data);
2337 }
2338 if((data = fopen("dat9","w")) != NULL){
2339 if(ok_xy[0][0]){
2340 double X = p[0][0].x();
2341 double Y = p[0][0].y();
2342 fprintf(data,"%lf, %lf\n",X,Y);
2343 }
2344 fclose(data);
2345 }
2346 if((data = fopen("dat10","w")) != NULL){
2347 if(ok_xy[1][0]){
2348 double X = p[1][0].x();
2349 double Y = p[1][0].y();
2350 fprintf(data,"%lf, %lf\n",X,Y);
2351 }
2352 fclose(data);
2353 }
2354 if((data = fopen("dat11","w")) != NULL){
2355 if(ok_xy[0][1]){
2356 double X = p[0][1].x();
2357 double Y = p[0][1].y();
2358 fprintf(data,"%lf, %lf\n",X,Y);
2359 }
2360 fclose(data);
2361 }
2362 if((data = fopen("dat12","w")) != NULL){
2363 if(ok_xy[1][1]){
2364 double X = p[1][1].x();
2365 double Y = p[1][1].y();
2366 fprintf(data,"%lf, %lf\n",X,Y);
2367 }
2368 fclose(data);
2369 }
2370 std::cout << "Drift Distance = " << drift << ", xy1cm -> z" << V.z()/v.mag() << "cm, xyDist(cm) = " << tD << std::endl;
2371 if(tX.z()<0.)std::cout << "ERROR : F < B" << std::endl;
2372 if((gnuplot = popen("gnuplot","w")) != NULL){
2373 fprintf(gnuplot,"set size 0.721,1.0 \n");
2374 fprintf(gnuplot,"set xrange [%f:%f] \n",gminX,gmaxX);
2375 fprintf(gnuplot,"set yrange [%f:%f] \n",gminY,gmaxY);
2376 fprintf(gnuplot,"plot \"dat1\" with line, \"dat2\" with line, \"dat3\" with line, \"dat4\" with line, \"dat5\" with line, \"dat6\", \"dat7\", \"dat8\" with line, \"dat9\", \"dat10\", \"dat11\", \"dat12\" \n");
2377 fflush(gnuplot);
2378 char tmp[8];
2379 gets(tmp);
2380 pclose(gnuplot);
2381 }
2382#endif
2383 }
2384 return 0;
2385}
HepGeom::Vector3D< double > HepVector3D
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in !Latex Output unit
Definition: FoamA.h:90
const HepPoint3D & forwardPosition(void) const
returns position in forward endplate.
Definition: TMDCWire.h:300
double dot(const TPoint2D &) const
Definition: TPoint2D.h:133
double y(void) const
Definition: TPoint2D.h:94
double mag(void) const
Definition: TPoint2D.h:112
double x(void) const
Definition: TPoint2D.h:88
TPoint2D center(void) const
returns position of helix center.
Definition: TTrack.h:595
complex_t R(double Q2, double M2, double G, double Mp2, double Mm2)
Definition: TUtil.h:27

◆ stereoHitForCurl() [2/4]

int TTrack::stereoHitForCurl ( TMLink link,
AList< HepPoint3D > &  arcZList 
) const

◆ stereoHitForCurl() [3/4]

int TTrack::stereoHitForCurl ( TMLink link,
TMLink link1 
) const

◆ stereoHitForCurl() [4/4]

int TTrack::stereoHitForCurl ( TMLink link,
TMLink link1,
TMLink link2 
) const

◆ szPosition() [1/3]

int TTrack::szPosition ( const HepPoint3D p,
HepPoint3D szPosition 
) const

calculates arc length for a point.

Definition at line 3608 of file TTrack.cxx.

3608 {
3609
3610 //...Cal. arc length...
3611 HepPoint3D center = _helix->center();
3612 HepPoint3D xy = p;
3613 xy.setZ(0.);
3614 double cosdPhi = - center.dot((xy - center).unit()) / center.mag();
3615 double dPhi;
3616 if (fabs(cosdPhi) <= 1.0) {
3617 dPhi = acos(cosdPhi);
3618 }
3619 else if (cosdPhi > 1.0) {
3620 dPhi = 0.0;
3621 }
3622 else {
3623 dPhi = M_PI;
3624 }
3625
3626 //...Finish...
3627 sz.setX(_helix->curv() * dPhi);
3628 sz.setY(p.z());
3629 sz.setZ(0.);
3630
3631 return 0;
3632}

◆ szPosition() [2/3]

int TTrack::szPosition ( const TSegment segment,
TMLink link 
) const

calculates arc length and z for a segment. Results are stored in TMLink.

Definition at line 3570 of file TTrack.cxx.

3570 {
3571
3572 //...Pick up a wire which represents segment position...
3573 AList<TMLink> links = segment.cores();
3574 unsigned n = links.length();
3575// std::cout<<" szPosition TTrack:: segment.cores().length():"<<n<<endl;
3576// for (unsigned i = 1; i < n; i++) {
3577// std::cout<<"drift distance"<<links[i]->hit()->drift()<<endl;
3578// }
3579 if (! n) return -1;
3580 TMLink * minL = links[0];
3581 float minDist = links[0]->drift();
3582#ifdef TRKRECO_DEBUG_DETAIL
3583 std::cout<<"minDist szPosition TTrack:"<<minDist<<endl;
3584#endif
3585 for (unsigned i = 1; i < n; i++) {
3586 if (links[i]->hit()->drift() < minDist) {
3587 minDist = links[i]->drift();
3588#ifdef TRKRECO_DEBUG_DETAIL
3589 std::cout<<"minDist szPosition TTrack:"<<minDist<<endl;
3590#endif
3591 minL = links[i];
3592 }
3593 }
3594
3595 //...sz calculation...
3596 a.position(minL->position());
3597 a.leftRight(2);
3598 a.hit(minL->hit());
3599 int err = szPosition(a);
3600#ifdef TRKRECO_DEBUG_DETAIL
3601 std::cout<<"err of szPosition TTrack:"<<err<<endl;
3602#endif
3603 if (err) return -2;
3604 return 0;
3605}
int szPosition(TMLink &link) const
calculates arc length and z for a stereo hit.
Definition: TTrack.cxx:3372

◆ szPosition() [3/3]

int TTrack::szPosition ( TMLink link) const

calculates arc length and z for a stereo hit.

Definition at line 3372 of file TTrack.cxx.

3372 {
3373 const TMDCWireHit & h = * link.hit();
3374 HepVector3D X = 0.5 * (h.wire()->forwardPosition()
3375 + h.wire()->backwardPosition());
3376 // double theta = atan2(X.y(), X.x());
3377 // HepVector3D lr(h.distance(WireHitLeft) * sin(theta),
3378 // - h.distance(WireHitLeft) * cos(theta),
3379 // 0.);
3380
3381 HepVector3D xx = HepVector3D(X.x(), X.y(), 0.);
3382 HepPoint3D center = _helix->center();
3383 HepVector3D yy = center - xx;
3384 HepVector3D ww = HepVector3D(yy.x(), yy.y(), 0.);
3385 double wwmag2 = ww.mag2();
3386 double wwmag = sqrt(wwmag2);
3387 HepVector3D lr(h.drift(WireHitLeft)/wwmag * ww.x(),
3388 h.drift(WireHitLeft)/wwmag * ww.y(),
3389 0.);
3390
3391#ifdef TRKRECO_DEBUG_DETAIL
3392 std::cout<<"old lr "<<lr<<endl;
3393 std::cout<<"old X "<<X<<endl;
3394 std::cout<<"link.leftRight "<<link.leftRight()<<endl;
3395#endif
3396 //...Check left or right...
3397 // // change to bes3 .. test..
3398 //if (link.leftRight() == WireHitRight) {
3399 //lr = - lr;
3400 //}
3401 //if (link.leftRight() == WireHitLeft) lr = - lr;
3402 //else if (link.leftRight() == 2) lr = ORIGIN;
3403
3404 //yzhang 2012-05-07
3405 const double Bz = -1000*m_pmgnIMF->getReferField();
3406#ifdef TRKRECO_DEBUG_DETAIL
3407 std::cout<<"charge "<<_charge<<" Bz "<<Bz<<endl;
3408#endif
3409 if (_charge*Bz > 0){ //yzhang 2012-05-07
3410 if (link.leftRight() == WireHitRight){
3411 lr = - lr;//right
3412 }
3413 }else{
3414 if (link.leftRight() == WireHitLeft){
3415 lr = - lr;//left
3416 }
3417 }
3418 if (link.leftRight() == 2) lr = ORIGIN;
3419 //zhangy
3420
3421 X += lr;
3422
3423 //...Prepare vectors...
3424 // HepPoint3D center = _helix->center();
3425 HepPoint3D tmp(-9999., -9999., 0.);
3426 HepVector3D x = HepVector3D(X.x(), X.y(), 0.);
3427 HepVector3D w = x - center;
3428 // //modified the next sentence because the direction are different from belle.
3429 HepVector3D V = h.wire()->direction();
3430 // // to bes3
3431 // // HepVector3D V = - h.wire()->direction();
3432
3433 HepVector3D v = HepVector3D(V.x(), V.y(), 0.);
3434 double vmag2 = v.mag2();
3435 double vmag = sqrt(vmag2);
3436
3437 double r = _helix->curv();
3438 double wv = w.dot(v);
3439 // //zsl for bes3
3440 // wv = abs(wv);
3441 double d2 = wv * wv - vmag2 * (w.mag2() - r * r);
3442#ifdef TRKRECO_DEBUG_DETAIL
3443 std::cout<<"lr "<<lr<<endl;
3444 std::cout<<"forwardPosition "<<h.wire()->forwardPosition()<<endl;
3445 std::cout<<"backwardPosition "<<h.wire()->backwardPosition()<<endl;
3446 std::cout<<"X "<<X<<endl;
3447 std::cout<<"center "<<center<<endl;
3448 std::cout<<"xx "<<xx<<endl;
3449 std::cout<<"ww "<<ww<<endl;
3450 std::cout<<"TTrack::wire direction:"<<h.wire()->direction()<<endl;
3451 std::cout<<"x "<<x<<endl;
3452 std::cout<<"w "<<w<<endl;
3453 std::cout<<"sz,Track::vmag:"<<vmag<<", helix_r:"<<r<<", wv:"<<wv<<", d:"<<sqrt(d2)<<endl;
3454#endif
3455
3456 //...No crossing in R/Phi plane... This is too tight...
3457
3458 if (d2 < 0.) {
3459 link.position(tmp);
3460
3461#ifdef TRKRECO_DEBUG
3462 std::cout << "TTrack !!! stereo: 0. > d2 = " << d2 << " "
3463 << link.leftRight() << std::endl;
3464#endif
3465 return -1;
3466 }
3467 double d = sqrt(d2);
3468
3469 //...Cal. length to crossing points...
3470 double l[2];
3471 l[0] = (- wv + d) / vmag2;
3472 l[1] = (- wv - d) / vmag2;
3473
3474 //...Cal. z of crossing points...
3475 bool ok[2];
3476 ok[0] = true;
3477 ok[1] = true;
3478 double z[2];
3479 z[0] = X.z() + l[0] * V.z();
3480 z[1] = X.z() + l[1] * V.z();
3481#ifdef TRKRECO_DEBUG_DETAIL
3482 std::cout<<"X.z():"<<X.z()<<endl;
3483 std::cout<<"szPosition::z(0) "<<z[0]<<" z(1)"<<z[1]<<" leftRight "<<link.leftRight()<<endl;
3484 std::cout<<"szPosition::wire backwardPosition and forwardPosition:"<< h.wire()->backwardPosition().z()<<","<<h.wire()->forwardPosition().z()<<endl;
3485 std::cout << " l0, l1 = " << l[0] << ", " << l[1] << std::endl;
3486 std::cout << " z0, z1 = " << z[0] << ", " << z[1] << std::endl;
3487 std::cout << " backward = " << h.wire()->backwardPosition().z() << std::endl;
3488 std::cout << " forward = " << h.wire()->forwardPosition().z() << std::endl;
3489#endif
3490
3491 //...Check z position... //yzhang change 2012-05-03
3492 //modified because Belle backward and forward are different from BESIII
3493
3494 /*
3495 if (link.leftRight() == 2) {
3496 if (z[0] > h.wire()->backwardPosition().z()+20.
3497 || z[0] < h.wire()->forwardPosition().z()-20.) ok[0] = false;
3498 if (z[1] > h.wire()->backwardPosition().z()+20.
3499 || z[1] < h.wire()->forwardPosition().z()-20.) ok[1] = false;
3500 }
3501 else {
3502 if (z[0] > h.wire()->backwardPosition().z()
3503 || z[0] < h.wire()->forwardPosition().z() ) ok[0] = false;
3504 if (z[1] > h.wire()->backwardPosition().z()
3505 || z[1] < h.wire()->forwardPosition().z() ) ok[1] = false;
3506 }
3507 if ((! ok[0]) && (! ok[1])) {
3508 link.position(tmp);
3509 return -2;
3510 }*/
3511 //belle...
3512 if (link.leftRight() == 2) {
3513 if (z[0] < h.wire()->backwardPosition().z() - 20.
3514 || z[0] > h.wire()->forwardPosition().z() + 20.) ok[0] = false;
3515 if (z[1] < h.wire()->backwardPosition().z()-20.
3516 || z[1] > h.wire()->forwardPosition().z()+20.) ok[1] = false;
3517 }
3518 else {
3519 if (z[0] < h.wire()->backwardPosition().z()
3520 || z[0] > h.wire()->forwardPosition().z()) ok[0] = false;
3521 if (z[1] < h.wire()->backwardPosition().z()
3522 || z[1] > h.wire()->forwardPosition().z()) ok[1] = false;
3523 }
3524 if ((! ok[0]) && (! ok[1])) {
3525 link.position(tmp);
3526 return -2;
3527 }
3528
3529
3530 //...Cal. xy position of crossing points...
3531 HepVector3D p[2];
3532 p[0] = x + l[0] * v;
3533 p[1] = x + l[1] * v;
3534/* if (_charge * (center.x() * p[0].y() - center.y() * p[0].x()) < 0.) //liuqg, cosmic...
3535 ok[0] = false;
3536 if (_charge * (center.x() * p[1].y() - center.y() * p[1].x()) < 0.)
3537 ok[1] = false;
3538 if ((! ok[0]) && (! ok[1])){
3539 // double tmp1 = _charge * (center.x() * p[0].y() - center.y() * p[0].x());
3540 // double tmp2 = _charge * (center.x() * p[1].y() - center.y() * p[1].x()) ;
3541 // if (link.leftRight() == 2) std::cout<<tmp1<<" "<<tmp2<<std::endl;
3542 link.position(tmp);
3543 return -3;
3544 }
3545*/
3546 //...Which one is the best?... Study needed...
3547 unsigned best = 0;
3548 if (ok[1]) best = 1;
3549
3550 //...Cal. arc length...
3551 double cosdPhi = - center.dot((p[best] - center).unit()) / center.mag();
3552 double dPhi;
3553 if(fabs(cosdPhi)<=1.0) {
3554 dPhi = acos(cosdPhi);
3555 } else if (cosdPhi>1.0) {
3556 dPhi = 0.0;
3557 } else {
3558 dPhi = M_PI;
3559 }
3560
3561 //...Finish...
3562 tmp.setX(r * dPhi);
3563 tmp.setY(z[best]);
3564 link.position(tmp);
3565
3566 return 0;
3567}

Referenced by TBuilder::buildStereo(), TBuilder0::buildStereo(), TBuilderCosmic::buildStereo(), TBuilder0::buildStereo0(), and szPosition().

◆ type()

unsigned TTrack::type ( void  ) const
inlinevirtual

returns type. Definition is depending on an object type.

Reimplemented from TTrackBase.

Definition at line 565 of file TTrack.h.

565 {
566 return defineType();
567}

Referenced by TTrackManager::setCurlerFlags(), and setFinderType().

Friends And Related Function Documentation

◆ Refit

friend class Refit
friend

Definition at line 373 of file TTrack.h.

◆ TBuilder

friend class TBuilder
friend

Definition at line 374 of file TTrack.h.

◆ TBuilder0

friend class TBuilder0
friend

Definition at line 375 of file TTrack.h.

◆ TBuilderCosmic

friend class TBuilderCosmic
friend

Definition at line 376 of file TTrack.h.

◆ TBuilderCurl

friend class TBuilderCurl
friend

Definition at line 377 of file TTrack.h.

◆ TCosmicFitter

friend class TCosmicFitter
friend

Definition at line 372 of file TTrack.h.

◆ TCurlFinder

friend class TCurlFinder
friend

Definition at line 379 of file TTrack.h.

◆ THelixFitter

friend class THelixFitter
friend

Definition at line 371 of file TTrack.h.

◆ TPMCurlFinder

friend class TPMCurlFinder
friend

Definition at line 378 of file TTrack.h.

◆ TrkReco

friend class TrkReco
friend

Definition at line 370 of file TTrack.h.

◆ TTrackManager

friend class TTrackManager
friend

Definition at line 369 of file TTrack.h.


The documentation for this class was generated from the following files: