/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/TrkBase/TrkBase-00-01-12/TrkBase/TrkHitOnTrk.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: TrkHitOnTrk.h,v 1.5 2011/02/17 11:53:41 zhangy Exp $
00004 //
00005 // Description:
00006 //  Abstract base class for reconstruction.  Provides common interface 
00007 //   for any tracking hit (e.g. SVT or DCH) for fitters, etc.   
00008 //   Stable and semi-stable quantities are cached: weight, flight and 
00009 //   length.  Residual, deltaChi (normalized resid), and derivs of delChi 
00010 //   w/r/t track params.  The flight and hit lengths
00011 //   are ONLY updated whenever updateMeasurement is called
00012 //
00013 //   Also contains flags that tell whether is (or can be) active (i.e. 
00014 //   actually used in fit).
00015 //
00016 // Environment:
00017 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00018 //
00019 // Author(s): Steve Schaffner
00020 //
00021 // Modified 3-july-97 by Leon Rochester to add '<' & '==' operators for 
00022 // Roguewave Sorted Vector
00023 //------------------------------------------------------------------------
00024 
00025 #ifndef TRKHITONTRK_HH
00026 #define TRKHITONTRK_HH
00027 #include "MdcRecoUtil/PdtPid.h"
00028 #include "TrkBase/TrkEnums.h"
00029 #include <iostream>
00030 #include <functional>
00031 #include "CLHEP/Matrix/Vector.h"
00032 using CLHEP::HepVector;
00033 class TrkFundHit;
00034 class MdcHit;
00035 class MdcHitOnTrack;
00036 class SvtHitOnTrack;
00037 class TrkRep;
00038 class TrkDifTraj;
00039 class Trajectory;
00040 class TrkRecoTrk;
00041 class TrkErrCode;
00042 class TrkDifPoca;
00043 class TrkPoca;
00044 
00045 class TrkHitOnTrkUpdater;
00046 namespace TrkBase { namespace Functors {
00047    class updateMeasurement;
00048    class setActive;
00049    class setParent;
00050 } }
00051 
00052 class TrkHitOnTrk {
00053   friend class TrkHotList;
00054   friend class TrkRecoTrk;
00055 // allow TrkRep to set activity
00056   friend class TrkRep;
00057 public:
00058   typedef std::unary_function<TrkHitOnTrk,bool> predicate_type;
00059   //****************
00060   // Constructors and such
00061   //****************
00062   TrkHitOnTrk(const TrkFundHit*,double tolerance); 
00063   virtual ~TrkHitOnTrk();
00064   virtual TrkHitOnTrk* clone(TrkRep* parentRep, const TrkDifTraj* trkTraj=0) const = 0;
00065 protected:
00066   TrkHitOnTrk(const TrkHitOnTrk& hitToBeCopied, TrkRep* newRep, const TrkDifTraj* trkTraj=0 );
00067 public:
00068 
00069   //****************
00070   // Accessors -- current state of hit
00071   //****************
00072   const TrkRecoTrk* getParentTrack() const;
00073   const TrkRep* getParentRep() const                  {return _parentRep;}
00074   PdtPid::PidType particleType() const;
00075   const TrkFundHit* hit() const                       {return _theHit;}
00076   TrkFundHit* hit()                                   {return _theHit;}
00077   const TrkDifTraj* trkTraj() const { return _trkTraj;}
00078 
00079 
00080   virtual const MdcHitOnTrack* mdcHitOnTrack() const;
00081   virtual const SvtHitOnTrack* svtHitOnTrack() const;
00082 
00083 
00084   inline bool isActive() const;    // false => leave out of current fit calc
00085   inline bool isUsable() const;    // false => cannot be made active
00086   inline bool mustUse() const;     // true => cannot be made inactive
00087   virtual TrkEnums::TrkViewInfo whatView() const = 0;
00088   virtual unsigned layerNumber() const = 0;
00089   double hitRms() const                                    {return _hitRms;}
00090   double weight() const;  
00091   double fltLen() const                                     {return _trkLen;}
00092   double hitLen() const                                     {return _hitLen;}
00093 // ambiguity functions.  These are implemented here as no-ops, and
00094 // are overridden where necessary in MdcHot
00095   virtual int ambig() const;
00096   virtual void setAmbig(int newambig);
00097 
00098   bool operator==(const TrkHitOnTrk&) const;
00099   bool operator< (const TrkHitOnTrk& rhs) const { return fltLen()<rhs.fltLen();}
00100 
00101   virtual const Trajectory* hitTraj() const = 0;
00102 
00103 // test whether residual information is present
00104   bool hasResidual() const { return _poca != 0; }
00105 
00106   //getFitStuff: returns derivs and deltaChi (based on current state of track)
00107   //updateMeasurement: update internal representation, weight/sigma
00108 
00109   TrkErrCode getFitStuff(HepVector& derivs, double& deltaChi) const;
00110   TrkErrCode getFitStuff(double& deltaChi) const;
00111 
00112   // return the *external* residual (this calls the Rep, which may call
00113   // down to the internal residual -- the Rep is responsible for computing
00114   // this quantity. In the case of a KalRep, this could be the unbiased 
00115   // residual (i.e. the one wrt to the track 'without' this hit included in
00116   // the track). This is implemented fully in this baseclass
00117   //   NOTE: this form of 'resid' is here for backwards compatibilty 
00118   //         please use the 'bool resid(double&,double&,bool) const'
00119   //         version for new code...
00120   double resid(bool exclude=false) const;
00121   // This version of 'resid' will also return the 'full' error on the
00122   // residual. 'full' implies that the error due to the uncertainty in the
00123   // track parameters is included. In addition, it is capable of returning
00124   // 'false' if the computation failed (basically because a TrkPoca failed).
00125   // Only trust the answer if 'true' is returned.
00126   bool   resid(double &resid, double &residErr, bool exclude=false) const;
00127 
00128   // return the *internal* residual (used to satisfy getFitStuff)
00129   double residual() const;
00130 
00131   // timing information; note that this returns in units of SECONDS!!!
00132   // First, relative to the track time
00133   virtual bool timeResid(double& resid, double& error) const = 0; 
00134   // then, in 'absolute' units (relative to the trigger time)
00135   virtual bool timeAbsolute(double& time,double& error) const = 0;
00136 
00137   TrkRecoTrk* parentTrack() const; // this requires non-const access to TrkRep
00138   //****************
00139   // Set values
00140   //****************
00141   // 
00142   void setActivity(bool turnOn);   // this is the other function that directly calls
00143                                    // non-const members of TrkRep, and as such the
00144                                    // reason we need a non-const TrkRep *
00145   void setUsability(int usability);         // 0=unusable; 1=usable; 2=must use
00146                                             // setUsability will call setActivity
00147   void setFltLen(double f)                                      {_trkLen = f;}
00148 
00149   //****************
00150   // Set values that shouldn't normally be set
00151   //****************
00152   // Use *only* if you want to circumvent the standard 
00153   //   calculation of the quantity in question and set it by hand
00154   void setHitRms(double newRms)                            {_hitRms = newRms;}
00155 
00156   //****************
00157   // Printing
00158   //****************
00159   virtual void print(std::ostream& ) const;
00160   virtual void printAll(std::ostream& ) const;
00161 
00162 protected:
00163   TrkRep* _parentRep;
00164   TrkFundHit* _theHit;
00165   bool _isActive;
00166   int  _isUsable;
00167   double _hitRms;
00168   double _trkLen;
00169   double _hitLen;
00170   double _resid;
00171   const TrkDifTraj *_trkTraj;
00172   TrkPoca *_poca;
00173   double _tolerance;
00174 
00175 protected:
00176   void setHitResid(double newResid)                        {_resid = newResid;}
00177   TrkRep* parentRep() const { return _parentRep;}
00178   void setHitLen(double h)                               {_hitLen = h;}
00179   void setUsedHit();               // tell underlying hit 
00180   void setUnusedHit(); 
00181   virtual TrkErrCode updateMeasurement(const TrkDifTraj* traj, bool maintainAmbiguity) = 0;
00182   TrkErrCode updatePoca(const TrkDifTraj *trkTraj, bool maintainAmbiguity) ;
00183 private:
00184   TrkHitOnTrk&   operator= (const TrkHitOnTrk&);    // Preempt 
00185   TrkHitOnTrk(const TrkHitOnTrk& hit);  // preempt; use 1st protected ctor
00186   // FIXME: have special 'friend' functors for each operation
00187   //        that requires friendship which are friends, and then
00188   //        arrange it such that only the "allowed" classes can
00189   //        create one of those functors. 
00190   friend class TrkHitOnTrkUpdater;
00191   friend class TrkBase::Functors::updateMeasurement;
00192   friend class TrkBase::Functors::setActive;
00193   friend class TrkBase::Functors::setParent;
00194   // allow friends (essentially reps) to change the activity directly
00195   TrkHitOnTrk *setActive(bool active) { _isActive = active; return this; }
00196   TrkHitOnTrk *setParent(TrkRep* rep) { _parentRep = rep; return this; }
00197 };
00198 
00199 // Inline functions
00200 inline bool TrkHitOnTrk::isActive() const {return _isActive;}
00201 inline bool TrkHitOnTrk::isUsable() const {return (_isUsable > 0);}
00202 inline bool TrkHitOnTrk::mustUse()  const {return (_isUsable > 1);}
00203 
00204 std::ostream& operator<<(std::ostream& o, const TrkHitOnTrk& x) ;
00205 #endif

Generated on Tue Nov 29 23:13:42 2016 for BOSS_7.0.2 by  doxygen 1.4.7