StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiKalmanTrack.h
Go to the documentation of this file.
1 
19 #ifndef StiKalmanTrack_H
20 #define StiKalmanTrack_H 1
21 
22 #include <cassert>
23 //STD
24 #include <vector>
25 //Sti
26 #include "Sti/Base/Factory.h"
27 #include "Sti/StiKTNIterator.h"
28 #include "Sti/StiTrack.h"
29 #include "Sti/StiTrackNodeHelper.h"
30 
31 #include "StThreeVectorD.hh"
32 #include "StMCTruth.h"
33 class StiHit;
34 class StiTrackNode;
35 class StiKalmanTrackNode;
36 
79 enum nodeQA {kKeepHit=1,kGoodHit=2};
80 
81 
82 class StiKalmanTrack : public StiTrack
83 {
84  public:
85 
87  enum { kAppGud =1, kAppRR=2, kAppUpd = 4, kAppUPD = 8 };
88 
98  firstNode(0),
99  lastNode(0),
100  mSeedHitCount(0),
101  mFlag(0),
102  mMass(-1.)
103  { /* nops */ }
104 
110  virtual ~StiKalmanTrack()
111  { }
112 
115  static void setMaxRefiter(int maxRefiter);
116 
117  void reset();
118  void unset();
119 
121  void getMomentum(double p[3], double e[6]) const ;
122 
124  double getP() const;
125 
127  double getPt() const;
128 
130  double getCurvature() const;
131 
133  double getRapidity() const;
134 
136  double getPseudoRapidity() const;
137 
139  double getPhi() const;
140 
142  double getTanL() const;
143 
149  double getDca() const;
150  virtual double getDca(const StiHit * vertex) const;
151 
152  void setDca(double dca);
153 
158  double getDca(StiTrack *t) const;
159 
164  int combUsed() const {return mCombUsed ;}
165  void setCombUsed(int comb) {mCombUsed = comb&7;}
166 
171  int getPointCount(int detectorId=0) const;
173 
175  int getFitPointCount(int detectorId=0) const;
176 
178  void getAllPointCount(int count[1][3],int maxDetId) const;
179 
181  int getGapCount() const;
182 
188  double getTrackLength() const;
196  double getNearBeam(StThreeVectorD *pnt=0,StThreeVectorD *dir=0) const;
197 
204  int getMaxPointCount(int detectorId=0) const;
205 
206  UShort_t getSeedHitCount() const {return mSeedHitCount;}
207  void setSeedHitCount(UShort_t c) {mSeedHitCount=c;}
208 
215  int isPrimary() const {return mVertex;}
216  void setPrimary(int vertex) {mVertex=vertex;}
217 
218  double getTrackRadLength() const;
219 
221  const StiKTNBidirectionalIterator& end() const;
222  StiKTNBidirectionalIterator rbegin() const;
223  const StiKTNBidirectionalIterator& rend() const;
224  void removeLastNode();
225 
230  StiKalmanTrackNode * getInnOutMostNode(int inot,int qua) const;
232  StiKalmanTrackNode * getOuterMostNode(int qua=0) const;
234  StiKalmanTrackNode * getInnerMostNode(int qua=0) const;
235 
237  StiKalmanTrackNode * getOuterMostHitNode(int qua=0) const;
239  StiKalmanTrackNode * getInnerMostHitNode(int qua=0) const;
240  StiKalmanTrackNode * getInnerMostDetHitNode(int detectorId) const;
241  int getNNodes(int qua=0) const;
242  int releaseHits(double rMin=0,double rMax=50);
244  StiKalmanTrackNode * getFirstNode() const { return firstNode; };
246  // Assumes the track has been pruned.
247  StiKalmanTrackNode * getLastNode() const { return lastNode; };
248  void setLastNode (StiKalmanTrackNode *n) { lastNode = n; };
249  void setFirstNode(StiKalmanTrackNode *n) { firstNode = n; };
250  void setFirstLastNode(StiKalmanTrackNode *n);
251  void removeNode(StiKalmanTrackNode *n){ n->remove((StiTreeNode**)&firstNode,(StiTreeNode**)&lastNode);}
252 
253 
256  virtual void add(StiTrackNode * node,int direction,StiTrackNode *near=0);
257 
259  virtual int initialize (const vector<StiHit*> &);
260  virtual int initialize0(const std::vector<StiHit*> &hits, StiNodePars *firstPars=0, StiNodePars *lastPars=0, StiNodeErrs *firstErrs=0, StiNodeErrs *lastErrs=0);
261 
262  virtual vector<StiHit*> getHits();
263  virtual vector<const StMeasuredPoint*> stHits() const;
264  virtual vector<StiKalmanTrackNode*> getNodes(int detectorGroupId) const;
265 
266 
267  double getMass() const; // mass when pid known
268  int getCharge()const; // charge of the particle
269  double getChi2() const; // chi2/ndf of fit
270  double getChi2Max() const; // maximal chi2
271  double getXi2 () const { return mXi2;} // helix chi2
272  double getDca2(StiTrack *t) const; // distance of closest approach to given track - 2D calc
273  double getDca3(StiTrack *t) const; // distance of closest approach to given track - 3D calc
274 
275  int refit();
276  int refitL();
277  void reserveHits(int yes=1);
279  void setFlag(int v);
280  int getFlag() const;
281 
283  StiKalmanTrackNode * extrapolateToRadius(double radius);
284  int approx(int mode = (kAppRR | kAppUPD));
285 
286  void reduce();
287 
288  void print(const char *opt="") const;
289  static void setDebug(int d = 0) {_debug = d;}
290  static int debug() {return _debug;}
291  StiKalmanTrack &operator=(const StiKalmanTrack &tk);
292  int rejectByHitSet() const;
293  int idTruth(int *qu=0) const;
294 
295  void test(const char *txt="") const;
296 
297  typedef enum{ // type of return value for the refit() procedure
298  kNoErrors = 0,
299  kRefitFail,
300  kNotEnoughUsed,
301  kInNodeNotValid,
302  kBadQA,
303  kVertexNodeInvalid,
304  kNodeNotValid,
305  kTooManyDroppedNodes
306  } TRefitStatus;
307 
308 
309 protected:
310  friend ostream& operator<<(ostream& os, const StiKalmanTrack& track);
311 
312  // hidden static variables for refit & refiL
313  static StiTrackNodeHelper sTNH;
314  static double diff(const StiNodePars &p1,const StiNodeErrs &e1
315  ,const StiNodePars &p2,const StiNodeErrs &e2,int &igor);
316  // end of hidden static variables for refit & refiL
317 
325 protected:
326 
327  static int mgMaxRefiter; //max number of refit iteratins allowed
328  static Factory<StiKalmanTrackNode> * trackNodeFactory;
329 
330  StiKalmanTrackNode * firstNode;
331  StiKalmanTrackNode * lastNode;
332 
333  UShort_t mSeedHitCount; //number of points used to seed the track (seed quality)
334  char mCombUsed; // save which combinatoric style was used
335  int mVertex;
336  int mFlag; //A flag to pack w/ topo info
337  double mMass; // mass hypothesis
338  double mXi2;
339  double _dca;
340 
341  public:
342  double _vChi2;//
343  static int _debug; // Debug level
344 
345 };
346 
349 inline double StiKalmanTrack::getMass() const
350 {
351  return mMass;
352 }
353 
354 inline void StiKalmanTrack::setFlag(int v)
355 {
356  mFlag = v;
357 }
358 
359 inline int StiKalmanTrack::getFlag() const
360 {
361  return mFlag;
362 }
363 
380 inline void StiKalmanTrack::getMomentum(double p[3], double e[6]) const
381 {
382  // return the momentum of the track at the inner most node held by this track
383  // which may (or not) be the primary vertex.
384  // this will need to be refined...
385  getInnerMostHitNode()->getMomentum(p,e);
386 }
387 
392 inline double StiKalmanTrack::getP() const
393 {
394  return getInnerMostHitNode()->getP();
395 }
396 
401 inline double StiKalmanTrack::getPt() const
402 {
403  return getInnerMostHitNode()->getPt();
404 }
405 
411 inline double StiKalmanTrack::getCurvature() const
412 {
413  return getInnerMostHitNode()->getCurvature();
414 }
415 
427 inline double StiKalmanTrack::getRapidity() const
428 {
429  // returns the rapidity of the particle at the inner most node held by this track
430  // which may (or not) be the primary vertex.
431  double p[3];
433  inner->getMomentum(p,0);
434  double mass = getMass();
435  assert(mass >= 0);
436  double e = ::sqrt(mass*mass+p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
437  assert(e > p[2]);
438  return 0.5*::log(e+p[2]/e-p[2]);
439 }
440 
451 {
452  // Return pseudo rapidity of the particle at the inner most node held by this track
453  // which may (or not) be the primary vertex.
454  double tanTheta = tan(M_PI/4.- getInnerMostHitNode()->getDipAngle()/2. );
455  assert(tanTheta>0.);
456  return -::log(tanTheta);
457 }
458 
464 inline double StiKalmanTrack::getPhi() const
465 {
466  double p[3];
467  getInnerMostHitNode()->getGlobalMomentum(p,0);
468  return atan2(p[1],p[0]);
469 }
470 
476 inline double StiKalmanTrack::getTanL() const
477 {
478  return getInnerMostHitNode()->getTanL();
479 }
480 
488 inline double StiKalmanTrack::getDca() const
489 {
490  return _dca;
491 }
492 
493 inline void StiKalmanTrack::setDca(double dca)
494 {
495  _dca = dca;
496 }
497 
498 
506 inline double StiKalmanTrack::getDca(StiTrack *t) const
507 {
508  return 0;
509 }
510 
518 inline double StiKalmanTrack::getDca2(StiTrack *t) const
519 {
520  return 0;
521 }
522 
530 inline double StiKalmanTrack::getDca3(StiTrack *t) const
531 {
532  return 0;
533 }
534 
535 
541 {
542  assert(firstNode);
543  return StiKTNBidirectionalIterator::begin(firstNode);
544 }
545 inline StiKTNBidirectionalIterator StiKalmanTrack::rbegin() const
546 {
547  assert(lastNode);
548  return StiKTNBidirectionalIterator::rbegin(lastNode);
549 }
550 
556 {
558 }
559 inline const StiKTNBidirectionalIterator &StiKalmanTrack::rend() const
560 {
561  return StiKTNBidirectionalIterator::rend();
562 }
563 
581 {
582  return getInnOutMostNode(1,qua);
583 }
584 
595 {
596  return getInnOutMostNode(0,qua);
597 }
598 
599 #endif
600 
StiKalmanTrackNode * getInnOutMostNode(int inot, int qua) const
Same for getNNodes(qua)
static const StiKTNIterator & end()
We demarcate the end of the traversal via a singular iterator.
StiKalmanTrackNode * getFirstNode() const
Accessor method returns the first node associated with the track.
StiKalmanTrackNode * getInnerMostHitNode(int qua=0) const
Accessor method returns the inner most hit node associated with the track.
Definition of Kalman Track.
double getP() const
Calculates and returns the momentum of the track at this node.
double getNearBeam(StThreeVectorD *pnt=0, StThreeVectorD *dir=0) const
double getTrackRadLength() const
double getDca2(StiTrack *t) const
StiKalmanTrackNode * getOuterMostHitNode(int qua=0) const
Accessor method returns the outer most hit node associated with the track.
int getMaxPointCount(int detectorId=0) const
Abstract definition of a Track.
Definition: StiTrack.h:59
StiTrackNode * extendToVertex(StiHit *vertex)
int getGapCount() const
Return the number of gaps on this track.
StiKalmanTrackNode * getLastNode() const
Accessor method returns the last node associated with the track.
void getAllPointCount(int count[1][3], int maxDetId) const
Returns all the PointCount far all detectors and types of nodes.
static int mgMaxRefiter
Definition: StiHit.h:51
StiKalmanTrackNode * getOuterMostNode(int qua=0) const
Accessor method returns the outer most node associated with the track.
virtual vector< StiHit * > getHits()
void reserveHits(int yes=1)
virtual ~StiKalmanTrack()
virtual vector< StiKalmanTrackNode * > getNodes(int detectorGroupId) const
return vector of nodes with hits
double getTanL() const
Returns the tangent of the dip angle of the track determined at the inner most point of the track...
double getP() const
Calculates and returns the momentum of the track at the inner most node.
int getFitPointCount(int detectorId=0) const
Returns the number of hits associated and used in the fit of this track.
double getPt() const
Calculates and returns the transverse momentum of the track at this node.
StiKalmanTrackNode * getInnerMostNode(int qua=0) const
Accessor method returns the inner most node associated with the track.
double getMass() const
double getChi2Max() const
Return the maximal node chi2.
int getPointCount(int detectorId=0) const
Return the number of hits associated with this track.
double getCurvature() const
Return the curvature of the track at its inner most point.
double getPseudoRapidity() const
Return the pseudorapidity of the track.
virtual int initialize(const vector< StiHit * > &)
Convenience method to initialize a track based on seed information.
StiKalmanTrackNode * extrapolateToBeam()
int combUsed() const
double getChi2() const
UShort_t getSeedHitCount() const
number of hits used to seed the track
double getDca() const
double getPhi() const
Return azimuthal angle at inner most point of the track.
int isPrimary() const
const StiKTNBidirectionalIterator & end() const
virtual vector< const StMeasuredPoint * > stHits() const
return hits;
double getTrackLength() const
double getRapidity() const
Return the rapidity of the track if the mass is known.
double getCurvature() const
Calculates and returns the tangent of the track pitch angle at this node.
void getMomentum(double p[3], double e[6]) const
Calculates and returns the momentum and error of the track.
virtual void add(StiTrackNode *node, int direction, StiTrackNode *near=0)
StiKTNBidirectionalIterator begin() const
static void setKalmanTrackNodeFactory(Factory< StiKalmanTrackNode > *)
Set the factory used for the creation of kalman track nodes.
void remove(int childIndex)
Definition: StiTreeNode.cxx:28
double getPt() const
Calculates and returns the transverse momentum of the track at the inner most node.
int getCharge() const
double getDca3(StiTrack *t) const