BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/TrkBase/include/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 "CLHEP/Matrix/Vector.h"
28#include "MdcRecoUtil/PdtPid.h"
29#include "TrkBase/TrkEnums.h"
30#include <functional>
31#include <iostream>
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 {
47 namespace Functors {
49 class setActive;
50 class setParent;
51 } // namespace Functors
52} // namespace TrkBase
53
54class TrkHitOnTrk {
55 friend class TrkHotList;
56 friend class TrkRecoTrk;
57 // allow TrkRep to set activity
58 friend class TrkRep;
59
60public:
61 typedef std::unary_function<TrkHitOnTrk, bool> predicate_type;
62 //****************
63 // Constructors and such
64 //****************
65 TrkHitOnTrk( const TrkFundHit*, double tolerance );
66 virtual ~TrkHitOnTrk();
67 virtual TrkHitOnTrk* clone( TrkRep* parentRep, const TrkDifTraj* trkTraj = 0 ) const = 0;
68
69protected:
70 TrkHitOnTrk( const TrkHitOnTrk& hitToBeCopied, TrkRep* newRep,
71 const TrkDifTraj* trkTraj = 0 );
72
73public:
74 //****************
75 // Accessors -- current state of hit
76 //****************
77 const TrkRecoTrk* getParentTrack() const;
78 const TrkRep* getParentRep() const { return _parentRep; }
80 const TrkFundHit* hit() const { return _theHit; }
81 TrkFundHit* hit() { return _theHit; }
82 const TrkDifTraj* trkTraj() const { return _trkTraj; }
83
84 virtual const MdcHitOnTrack* mdcHitOnTrack() const;
85 virtual const SvtHitOnTrack* svtHitOnTrack() const;
86
87 inline bool isActive() const; // false => leave out of current fit calc
88 inline bool isUsable() const; // false => cannot be made active
89 inline bool mustUse() const; // true => cannot be made inactive
90 virtual TrkEnums::TrkViewInfo whatView() const = 0;
91 virtual unsigned layerNumber() const = 0;
92 double hitRms() const { return _hitRms; }
93 double weight() const;
94 double fltLen() const { return _trkLen; }
95 double hitLen() const { return _hitLen; }
96 // ambiguity functions. These are implemented here as no-ops, and
97 // are overridden where necessary in MdcHot
98 virtual int ambig() const;
99 virtual void setAmbig( int newambig );
100
101 bool operator==( const TrkHitOnTrk& ) const;
102 bool operator<( const TrkHitOnTrk& rhs ) const { return fltLen() < rhs.fltLen(); }
103
104 virtual const Trajectory* hitTraj() const = 0;
105
106 // test whether residual information is present
107 bool hasResidual() const { return _poca != 0; }
108
109 // getFitStuff: returns derivs and deltaChi (based on current state of track)
110 // updateMeasurement: update internal representation, weight/sigma
111
112 TrkErrCode getFitStuff( HepVector& derivs, double& deltaChi ) const;
113 TrkErrCode getFitStuff( double& deltaChi ) const;
114
115 // return the *external* residual (this calls the Rep, which may call
116 // down to the internal residual -- the Rep is responsible for computing
117 // this quantity. In the case of a KalRep, this could be the unbiased
118 // residual (i.e. the one wrt to the track 'without' this hit included in
119 // the track). This is implemented fully in this baseclass
120 // NOTE: this form of 'resid' is here for backwards compatibilty
121 // please use the 'bool resid(double&,double&,bool) const'
122 // version for new code...
123 double resid( bool exclude = false ) const;
124 // This version of 'resid' will also return the 'full' error on the
125 // residual. 'full' implies that the error due to the uncertainty in the
126 // track parameters is included. In addition, it is capable of returning
127 // 'false' if the computation failed (basically because a TrkPoca failed).
128 // Only trust the answer if 'true' is returned.
129 bool resid( double& resid, double& residErr, bool exclude = false ) const;
130
131 // return the *internal* residual (used to satisfy getFitStuff)
132 double residual() const;
133
134 // timing information; note that this returns in units of SECONDS!!!
135 // First, relative to the track time
136 virtual bool timeResid( double& resid, double& error ) const = 0;
137 // then, in 'absolute' units (relative to the trigger time)
138 virtual bool timeAbsolute( double& time, double& error ) const = 0;
139
140 TrkRecoTrk* parentTrack() const; // this requires non-const access to TrkRep
141 //****************
142 // Set values
143 //****************
144 //
145 void setActivity( bool turnOn ); // this is the other function that directly calls
146 // non-const members of TrkRep, and as such the
147 // reason we need a non-const TrkRep *
148 void setUsability( int usability ); // 0=unusable; 1=usable; 2=must use
149 // setUsability will call setActivity
150 void setFltLen( double f ) { _trkLen = f; }
151
152 //****************
153 // Set values that shouldn't normally be set
154 //****************
155 // Use *only* if you want to circumvent the standard
156 // calculation of the quantity in question and set it by hand
157 void setHitRms( double newRms ) { _hitRms = newRms; }
158
159 //****************
160 // Printing
161 //****************
162 virtual void print( std::ostream& ) const;
163 virtual void printAll( std::ostream& ) const;
164
165protected:
168 bool _isActive;
169 int _isUsable;
170 double _hitRms;
171 double _trkLen;
172 double _hitLen;
173 double _resid;
174 const TrkDifTraj* _trkTraj;
175 TrkPoca* _poca;
176 double _tolerance;
177
178protected:
179 void setHitResid( double newResid ) { _resid = newResid; }
180 TrkRep* parentRep() const { return _parentRep; }
181 void setHitLen( double h ) { _hitLen = h; }
182 void setUsedHit(); // tell underlying hit
184 virtual TrkErrCode updateMeasurement( const TrkDifTraj* traj, bool maintainAmbiguity ) = 0;
185 TrkErrCode updatePoca( const TrkDifTraj* trkTraj, bool maintainAmbiguity );
186
187private:
188 TrkHitOnTrk& operator=( const TrkHitOnTrk& ); // Preempt
189 TrkHitOnTrk( const TrkHitOnTrk& hit ); // preempt; use 1st protected ctor
190 // FIXME: have special 'friend' functors for each operation
191 // that requires friendship which are friends, and then
192 // arrange it such that only the "allowed" classes can
193 // create one of those functors.
194 friend class TrkHitOnTrkUpdater;
196 friend class TrkBase::Functors::setActive;
197 friend class TrkBase::Functors::setParent;
198 // allow friends (essentially reps) to change the activity directly
199 TrkHitOnTrk* setActive( bool active ) {
200 _isActive = active;
201 return this;
202 }
203 TrkHitOnTrk* setParent( TrkRep* rep ) {
204 _parentRep = rep;
205 return this;
206 }
207};
208
209// Inline functions
210inline bool TrkHitOnTrk::isActive() const { return _isActive; }
211inline bool TrkHitOnTrk::isUsable() const { return ( _isUsable > 0 ); }
212inline bool TrkHitOnTrk::mustUse() const { return ( _isUsable > 1 ); }
213
214std::ostream& operator<<( std::ostream& o, const TrkHitOnTrk& x );
215#endif
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
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
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
std::unary_function< TrkHitOnTrk, bool > predicate_type
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