BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/TrkBase/TrkBase-00-01-12/TrkBase/TrkHitOnTrk.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkHitOnTrk.h,v 1.5 2011/02/17 11:53:41 zhangy Exp $
4//
5// Description:
6// Abstract base class for reconstruction. Provides common interface
7// for any tracking hit (e.g. SVT or DCH) for fitters, etc.
8// Stable and semi-stable quantities are cached: weight, flight and
9// length. Residual, deltaChi (normalized resid), and derivs of delChi
10// w/r/t track params. The flight and hit lengths
11// are ONLY updated whenever updateMeasurement is called
12//
13// Also contains flags that tell whether is (or can be) active (i.e.
14// actually used in fit).
15//
16// Environment:
17// Software developed for the BaBar Detector at the SLAC B-Factory.
18//
19// Author(s): Steve Schaffner
20//
21// Modified 3-july-97 by Leon Rochester to add '<' & '==' operators for
22// Roguewave Sorted Vector
23//------------------------------------------------------------------------
24
25#ifndef TRKHITONTRK_HH
26#define TRKHITONTRK_HH
27#include "MdcRecoUtil/PdtPid.h"
28#include "TrkBase/TrkEnums.h"
29#include <iostream>
30#include <functional>
31#include "CLHEP/Matrix/Vector.h"
32using CLHEP::HepVector;
33class TrkFundHit;
34class MdcHit;
35class MdcHitOnTrack;
36class SvtHitOnTrack;
37class TrkRep;
38class TrkDifTraj;
39class Trajectory;
40class TrkRecoTrk;
41class TrkErrCode;
42class TrkDifPoca;
43class TrkPoca;
44
46namespace TrkBase { namespace Functors {
47 class updateMeasurement;
48 class setActive;
49 class setParent;
50} }
51
52class TrkHitOnTrk {
53 friend class TrkHotList;
54 friend class TrkRecoTrk;
55// allow TrkRep to set activity
56 friend class TrkRep;
57public:
58 typedef std::unary_function<TrkHitOnTrk,bool> predicate_type;
59 //****************
60 // Constructors and such
61 //****************
62 TrkHitOnTrk(const TrkFundHit*,double tolerance);
63 virtual ~TrkHitOnTrk();
64 virtual TrkHitOnTrk* clone(TrkRep* parentRep, const TrkDifTraj* trkTraj=0) const = 0;
65protected:
66 TrkHitOnTrk(const TrkHitOnTrk& hitToBeCopied, TrkRep* newRep, const TrkDifTraj* trkTraj=0 );
67public:
68
69 //****************
70 // Accessors -- current state of hit
71 //****************
72 const TrkRecoTrk* getParentTrack() const;
73 const TrkRep* getParentRep() const {return _parentRep;}
75 const TrkFundHit* hit() const {return _theHit;}
76 TrkFundHit* hit() {return _theHit;}
77 const TrkDifTraj* trkTraj() const { return _trkTraj;}
78
79
80 virtual const MdcHitOnTrack* mdcHitOnTrack() const;
81 virtual const SvtHitOnTrack* svtHitOnTrack() const;
82
83
84 inline bool isActive() const; // false => leave out of current fit calc
85 inline bool isUsable() const; // false => cannot be made active
86 inline bool mustUse() const; // true => cannot be made inactive
87 virtual TrkEnums::TrkViewInfo whatView() const = 0;
88 virtual unsigned layerNumber() const = 0;
89 double hitRms() const {return _hitRms;}
90 double weight() const;
91 double fltLen() const {return _trkLen;}
92 double hitLen() const {return _hitLen;}
93// ambiguity functions. These are implemented here as no-ops, and
94// are overridden where necessary in MdcHot
95 virtual int ambig() const;
96 virtual void setAmbig(int newambig);
97
98 bool operator==(const TrkHitOnTrk&) const;
99 bool operator< (const TrkHitOnTrk& rhs) const { return fltLen()<rhs.fltLen();}
100
101 virtual const Trajectory* hitTraj() const = 0;
102
103// test whether residual information is present
104 bool hasResidual() const { return _poca != 0; }
105
106 //getFitStuff: returns derivs and deltaChi (based on current state of track)
107 //updateMeasurement: update internal representation, weight/sigma
108
109 TrkErrCode getFitStuff(HepVector& derivs, double& deltaChi) const;
110 TrkErrCode getFitStuff(double& deltaChi) const;
111
112 // return the *external* residual (this calls the Rep, which may call
113 // down to the internal residual -- the Rep is responsible for computing
114 // this quantity. In the case of a KalRep, this could be the unbiased
115 // residual (i.e. the one wrt to the track 'without' this hit included in
116 // the track). This is implemented fully in this baseclass
117 // NOTE: this form of 'resid' is here for backwards compatibilty
118 // please use the 'bool resid(double&,double&,bool) const'
119 // version for new code...
120 double resid(bool exclude=false) const;
121 // This version of 'resid' will also return the 'full' error on the
122 // residual. 'full' implies that the error due to the uncertainty in the
123 // track parameters is included. In addition, it is capable of returning
124 // 'false' if the computation failed (basically because a TrkPoca failed).
125 // Only trust the answer if 'true' is returned.
126 bool resid(double &resid, double &residErr, bool exclude=false) const;
127
128 // return the *internal* residual (used to satisfy getFitStuff)
129 double residual() const;
130
131 // timing information; note that this returns in units of SECONDS!!!
132 // First, relative to the track time
133 virtual bool timeResid(double& resid, double& error) const = 0;
134 // then, in 'absolute' units (relative to the trigger time)
135 virtual bool timeAbsolute(double& time,double& error) const = 0;
136
137 TrkRecoTrk* parentTrack() const; // this requires non-const access to TrkRep
138 //****************
139 // Set values
140 //****************
141 //
142 void setActivity(bool turnOn); // this is the other function that directly calls
143 // non-const members of TrkRep, and as such the
144 // reason we need a non-const TrkRep *
145 void setUsability(int usability); // 0=unusable; 1=usable; 2=must use
146 // setUsability will call setActivity
147 void setFltLen(double f) {_trkLen = f;}
148
149 //****************
150 // Set values that shouldn't normally be set
151 //****************
152 // Use *only* if you want to circumvent the standard
153 // calculation of the quantity in question and set it by hand
154 void setHitRms(double newRms) {_hitRms = newRms;}
155
156 //****************
157 // Printing
158 //****************
159 virtual void print(std::ostream& ) const;
160 virtual void printAll(std::ostream& ) const;
161
162protected:
165 bool _isActive;
166 int _isUsable;
167 double _hitRms;
168 double _trkLen;
169 double _hitLen;
170 double _resid;
171 const TrkDifTraj *_trkTraj;
172 TrkPoca *_poca;
173 double _tolerance;
174
175protected:
176 void setHitResid(double newResid) {_resid = newResid;}
177 TrkRep* parentRep() const { return _parentRep;}
178 void setHitLen(double h) {_hitLen = h;}
179 void setUsedHit(); // tell underlying hit
181 virtual TrkErrCode updateMeasurement(const TrkDifTraj* traj, bool maintainAmbiguity) = 0;
182 TrkErrCode updatePoca(const TrkDifTraj *trkTraj, bool maintainAmbiguity) ;
183private:
184 TrkHitOnTrk& operator= (const TrkHitOnTrk&); // Preempt
185 TrkHitOnTrk(const TrkHitOnTrk& hit); // preempt; use 1st protected ctor
186 // FIXME: have special 'friend' functors for each operation
187 // that requires friendship which are friends, and then
188 // arrange it such that only the "allowed" classes can
189 // create one of those functors.
190 friend class TrkHitOnTrkUpdater;
192 friend class TrkBase::Functors::setActive;
193 friend class TrkBase::Functors::setParent;
194 // allow friends (essentially reps) to change the activity directly
195 TrkHitOnTrk *setActive(bool active) { _isActive = active; return this; }
196 TrkHitOnTrk *setParent(TrkRep* rep) { _parentRep = rep; return this; }
197};
198
199// Inline functions
200inline bool TrkHitOnTrk::isActive() const {return _isActive;}
201inline bool TrkHitOnTrk::isUsable() const {return (_isUsable > 0);}
202inline bool TrkHitOnTrk::mustUse() const {return (_isUsable > 1);}
203
204std::ostream& operator<<(std::ostream& o, const TrkHitOnTrk& x) ;
205#endif
Double_t time
std::ostream & operator<<(std::ostream &o, const TrkHitOnTrk &x)
void setActivity(bool turnOn)
virtual bool timeAbsolute(double &time, double &error) const =0
TrkErrCode getFitStuff(double &deltaChi) const
virtual const SvtHitOnTrack * svtHitOnTrack() const
virtual void setAmbig(int newambig)
TrkErrCode updatePoca(const TrkDifTraj *trkTraj, bool maintainAmbiguity)
double residual() const
friend class TrkBase::Functors::setParent
void setUsability(int usability)
double resid(bool exclude=false) const
virtual TrkErrCode updateMeasurement(const TrkDifTraj *traj, bool maintainAmbiguity)=0
virtual ~TrkHitOnTrk()
virtual TrkHitOnTrk * clone(TrkRep *parentRep, const TrkDifTraj *trkTraj=0) const =0
TrkHitOnTrk(const TrkFundHit *, double tolerance)
bool isUsable() const
virtual const Trajectory * hitTraj() const =0
const TrkRecoTrk * getParentTrack() const
bool mustUse() const
friend class TrkBase::Functors::setActive
bool operator<(const TrkHitOnTrk &rhs) const
double weight() const
TrkHitOnTrk(const TrkHitOnTrk &hitToBeCopied, TrkRep *newRep, const TrkDifTraj *trkTraj=0)
PdtPid::PidType particleType() const
virtual TrkEnums::TrkViewInfo whatView() const =0
virtual const MdcHitOnTrack * mdcHitOnTrack() const
TrkRecoTrk * parentTrack() const
virtual int ambig() const
bool operator==(const TrkHitOnTrk &) const
bool isActive() const
void setUnusedHit()
void setUsedHit()
TrkErrCode getFitStuff(HepVector &derivs, double &deltaChi) const
virtual bool timeResid(double &resid, double &error) const =0
bool resid(double &resid, double &residErr, bool exclude=false) const
virtual unsigned layerNumber() const =0
virtual void print(std::ostream &) const
virtual void printAll(std::ostream &) const
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")