00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: TrkRecoTrk.h,v 1.4 2008/04/01 03:13:19 zhangy Exp $ 00004 // 00005 // Description: 00006 // This is the standard reconstructed charged track class. Only a few 00007 // functions, describing the track as a whole, are in this interface. 00008 // The remainder of the information can be obtained through one of the 00009 // four interfaces available here (TrkFit, TrkFitStatus, TrkHitList, 00010 // TrkExtInterface -- see comments below for details). 00011 // The interface you get will be for a particular mass hypothesis (if 00012 // leave out the particle-type argument, you will get the interface for 00013 // the default type for that track). Some interfaces may not be available 00014 // for some tracks: some kinds of tracks don't have hit lists, for example, 00015 // and sometimes fits fail for some hypotheses. In such cases, you get 00016 // a null pointer returned to you -- so test it. 00017 // All hypotheses should have the same kind of internal representation 00018 // A single fit may represent more than one particle 00019 // type; whichFit(hypo) tells you which fit is actually being used when 00020 // you ask about "hypo". 00021 // 00022 // Track creation: 00023 // Only FitMaker objects are allowed to create tracks, and only they can 00024 // change the TrkRep inside an existing track. The RecoTrk ctor permits 00025 // tracks to be created without Reps, but FitMakers are required (by 00026 // fiat, not by syntax) to install a Rep in a track before finishing 00027 // with it. 00028 // 00029 // Environment: 00030 // Software developed for the BaBar Detector at the SLAC B-Factory. 00031 // 00032 // Author List: 00033 // Steve Schaffner 00034 //------------------------------------------------------------------------ 00035 #ifndef TRKRECOTRK_HH 00036 #define TRKRECOTRK_HH 00037 00038 #include <map> 00039 #include <set> 00040 #include <iosfwd> 00041 #include <functional> 00042 #include "TrkBase/TrkId.h" 00043 //#include "GaudiKernel/ObjectVector.h" 00044 //#include "GaudiKernel/ContainedObject.h" 00045 #include "MdcRecoUtil/PdtPid.h" 00046 #include "TrkBase/TrkDirection.h" 00047 #include "TrkBase/TrkHitList.h" 00048 #include "TrkBase/TrkStoreHypo.h" 00049 #include "TrkBase/TrkFit.h" 00050 #include "TrkBase/TrkFitStatus.h" 00051 //yzhang for store to TDS 00052 #include "MdcRecEvent/RecMdcTrack.h" 00053 #include "MdcRecEvent/RecMdcHit.h" 00054 //zhangy 00055 00056 class TrkRep; 00057 class TrkRepIter; 00058 class TrkContext; 00059 class TrkFundHit; 00060 class TrkExchangePar; 00061 class TrkVolume; 00062 class TrkFit; 00063 class TrkExtInterface; 00064 class TrkFitStatus; 00065 class TrkErrCode; 00066 class BField; 00067 class TrkIdManager; 00068 class TrkRecoTrkImpl; 00069 00070 //class TrkRecoTrk : public ContainedObject {//yzhang 00071 class TrkRecoTrk { 00072 public: 00073 typedef std::unary_function<TrkRecoTrk,bool> predicate_type; 00074 //********************************* 00075 //Global track quantities: 00076 //********************************* 00077 const TrkId& id() const; 00078 PdtPid::PidType defaultType() const {return _defaultType;} 00079 PdtPid::PidType whichFit(PdtPid::PidType hypo) const; 00080 int fitNumber(PdtPid::PidType hypo) const; 00081 double trackT0() const; 00082 const BField& bField() const {return *_bField;} 00083 00084 TrkErrCode addFit(PdtPid::PidType hypo,bool fit=true); // also fits if requested 00085 // Note: resetT0() requires refit to make fit current 00086 void resetT0(double time); // also updates hits 00087 00088 //********************************************************** 00089 // To get information about the track as fitted to a particular mass 00090 // hypothesis, use one of the following interfaces. In each case, 00091 // you can either specify a hypothesis, or omit the argument and get the 00092 // default hypothesis for this track. 00093 //********************************************************** 00094 00095 //********************************************************** 00096 // (1) Standard information about the fitted track (momentum, position, 00097 // charge, chisq etc). 00098 //********************************************************** 00099 const TrkFit* fitResult() const; 00100 const TrkFit* fitResult(PdtPid::PidType hypo) const; 00101 00102 00103 //********************************************************** 00104 // (2) Interface for accessing and manipulating the track's list of hits, 00105 // and for fitting the track. 00106 //********************************************************** 00107 TrkHitList* hits() {return hits(defaultType());} 00108 const TrkHitList* hits() const {return hits(defaultType());} 00109 TrkHitList* hits(PdtPid::PidType hypo); 00110 const TrkHitList* hits(PdtPid::PidType hypo) const; 00111 00112 // same for hots. This is more direct 00113 TrkHotList* hots() {return hots(defaultType());} 00114 const TrkHotList* hots() const {return hots(defaultType());} 00115 TrkHotList* hots(PdtPid::PidType hypo); 00116 const TrkHotList* hots(PdtPid::PidType hypo) const; 00117 00118 00119 00120 //********************************************************** 00121 // (3) Specialized information about the fit; of interest mostly to experts 00122 //********************************************************** 00123 const TrkFitStatus* status() const; 00124 const TrkFitStatus* status(PdtPid::PidType hypo) const; 00125 TrkFitStatus* status(); 00126 TrkFitStatus* status(PdtPid::PidType hypo); 00127 00128 00129 //******************************************************** 00130 // Attach an extended interface for a specific track representation; returns 00131 // false if this track doesn't have the right kind of TrkRep in it. 00132 //******************************************************** 00133 bool attach(TrkExtInterface&, PdtPid::PidType hypo); 00134 bool attach(TrkExtInterface&, PdtPid::PidType hypo) const; 00135 00136 00137 //************************************************** 00138 // Constructors and such (normal ctor is protected) 00139 //************************************************** 00140 // Copy constructor (leaves original unchanged): 00141 TrkRecoTrk(const TrkRecoTrk& right); 00142 // Destructor 00143 virtual ~TrkRecoTrk(); 00144 const TrkRecoTrk& operator=(const TrkRecoTrk& right); 00145 bool operator==(const TrkRecoTrk &other) const; 00146 bool operator<(const TrkRecoTrk &other) const; 00147 00148 //********************************************************** 00149 // Printing 00150 //********************************************************** 00151 virtual void print(std::ostream& ) const; 00152 virtual void printAll(std::ostream& ) const; 00153 //********************************************************** 00154 // Persistence 00155 //********************************************************** 00156 // Mark a particular hypo at a particular flight length for storage. 00157 // This only works for the mini. Several 'lists' of storage requests 00158 // may be associated with each track 00159 void markForStore(PdtPid::PidType hypo,double fltlen,const char* listname="Default"); 00160 const std::set<TrkStoreHypo>& storageRequests(const char* listname="Default") const; 00161 // clear out all marked stores 00162 void clearStorageRequests(const char* listname="Default"); 00163 // return the set of fit storage lists known to this track 00164 void storageLists(std::set<std::string>& storage) const; 00165 //protected: //yzhang debug 00166 // TrkRep* getRep(PdtPid::PidType hypo); 00167 // const TrkRep* getRep(PdtPid::PidType hypo) const; 00168 00169 private: 00170 //*** Data members *** 00171 TrkRecoTrkImpl* _impl; // the reps live here; owned by trk; 00172 // the reason they're stashed away in this class 00173 // is because (for #($*)( reasons) ooddlx must 00174 // parse code which needs to know that TrkRecoTrk 00175 // inherits from AbsEvtObj -- but ooddlx cannot 00176 // deal with somewhat complex ANSI C++ constructions 00177 // (e.g. namespaces). Stashing the reps into 00178 // TrkRecoTrkImpl, which can be fwd declared as we 00179 // only use a pointer to it insures that ooddlx 00180 // doesn't get 'confused' by real ANSI C++... 00181 TrkId _id; // unique id # in event 00182 std::vector<int> _fitNumber; //number of times fit has been altered 00183 // keep track of the storage requests, by list. This is sorted first by hypo, then 00184 // by flightlength. 00185 std::map<std::string,std::set<TrkStoreHypo> > _storage; 00186 PdtPid::PidType _defaultType; 00187 double _trackT0; 00188 const BField* _bField; 00189 protected: 00190 TrkRep* getRep(PdtPid::PidType hypo); 00191 const TrkRep* getRep(PdtPid::PidType hypo) const; 00192 // protected functio 00193 void copyReps(const TrkRecoTrk& rhs); 00194 // The following takes ownership of the argument; it replaces the default Rep 00195 // and zeroes others. 00196 void setRep(TrkRep*); 00197 // Make hypothesis <hypo> use fit currently used for hypo <fit>: 00198 void repointHypo(PdtPid::PidType hypo, PdtPid::PidType fit); 00199 void changeDefault(PdtPid::PidType newHypo); 00200 00201 // return the list of unique distinct Reps attached to this track 00202 std::pair<TrkRepIter,TrkRepIter> uniqueReps() const; 00203 // return the list of the 5 reps this track is pointing at 00204 std::pair<TrkRepIter,TrkRepIter> allReps() const; 00205 void setFitNumber(PdtPid::PidType hypo, int newNumber); 00206 void updateReps(); 00207 // addHypoTo takes ownership of newRep! 00208 void addHypoTo(TrkRep* newRep, PdtPid::PidType hypo); 00209 // a couple of lame functions to limp past inconsistencies between the persistent 00210 // design and the tracking design. Ugh 00211 void setIdManager(TrkIdManager* idMan); 00212 void setBField(const BField* field); 00213 // Constructors are protected (construct through FitMaker) 00214 TrkRecoTrk(PdtPid::PidType defaultPart, const TrkContext&, double t0); 00215 // persistence constructor. BField and IdManager must be set later 00216 TrkRecoTrk(PdtPid::PidType defaultPart,long idnum,double t0); 00217 public: 00218 // Access to TrkRep, for testing only; use it at your peril 00219 const TrkRep* testRep( PdtPid::PidType hypo ) const { return getRep(hypo);} 00220 friend class TrkFitMaker; 00221 friend class TrkHitOnTrk; 00222 friend class TrkHitList; 00223 friend class KalMiniTrkK; 00224 friend class TrkKalMiniCompositeK; 00225 }; 00226 00227 std::ostream& operator<<(std::ostream& os, const TrkRecoTrk& tk); 00228 00229 //typedef ObjectVector<TrkRecoTrk> TrkRecoTrkCol; 00230 00231 #endif