00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: TrkExpectedHotSet.cxx,v 1.1.1.1 2005/04/21 06:01:42 zhangy Exp $ 00004 // 00005 // Description: 00006 // Class TrkExpectedHotSet, stores information about projected location 00007 // of Tracks 00008 // 00009 // Environment: 00010 // Software developed for B Factory. 00011 // 00012 // Author List: 00013 // Eric A Charles UW-Madison 00014 // 00015 //------------------------------------------------------------------------ 00016 00017 //---------------- 00018 // BaBar header 00019 //---------------- 00020 //#include "BaBar/BaBar.hh" 00021 00022 //----------------------- 00023 // This Class's Header -- 00024 //----------------------- 00025 #include "TrkBase/TrkExpectedHotSet.h" 00026 00027 //------------- 00028 // C Headers -- 00029 //------------- 00030 extern "C" { 00031 } 00032 00033 //--------------- 00034 // C++ Headers -- 00035 //--------------- 00036 00037 //------------------------------- 00038 // Collaborating Class Headers -- 00039 //------------------------------- 00040 00041 #include "TrkBase/TrkFitTypeKey.h" 00042 #include "TrkBase/TrkExpectedHot.h" 00043 using std::endl; 00044 using std::ostream; 00045 00046 //---------------------------------------------------------------------- 00047 // Local Macros, Typedefs, Structures, Unions and Forward Declarations -- 00048 //----------------------------------------------------------------------- 00049 00050 00051 00052 // ----------------------------------------------- 00053 // -- Static Data & Function Member Definitions -- 00054 // ----------------------------------------------- 00055 00056 // ---------------------------------------- 00057 // -- Public Function Member Definitions -- 00058 // ---------------------------------------- 00059 00060 //---------------- 00061 // Constructors -- 00062 //---------------- 00063 00064 TrkExpectedHotSet::TrkExpectedHotSet( const TrkDetElemId& elemId, 00065 const int& maxFits ) 00066 :_elemId(elemId), 00067 _nFit(-1), 00068 _fitTypeMap(maxFits,-1), 00069 _exTrk(0) 00070 { 00071 } 00072 00073 //-------------- 00074 // Destructor -- 00075 //-------------- 00076 00077 TrkExpectedHotSet::~TrkExpectedHotSet(){ 00078 // owns the exHost 00079 const int iEx = _theHots.size(); 00080 for ( int iKill(0); iKill < iEx; ++iKill ) { 00081 TrkExpectedHot* exHot = _theHots[iKill]; 00082 delete exHot; 00083 } 00084 } 00085 00086 //------------- 00087 // Operators -- 00088 //------------- 00089 00090 //------------- 00091 // Selectors -- 00092 //------------- 00093 00094 const TrkExpectedHot* 00095 TrkExpectedHotSet::exHot( const TrkFitTypeKey& key ) const{ 00096 if ( key.value() < 0 || key.value() >= _fitTypeMap.size() ) return 0; 00097 const int index = _fitTypeMap[key.value()]; 00098 return index < 0 ? 0 : _theHots[index]; 00099 } 00100 00101 const TrkExpectedHot* 00102 TrkExpectedHotSet::exHot( ) const{ 00103 return _nFit < 0 ? 0 : _theHots[0]; 00104 } 00105 00106 void 00107 TrkExpectedHotSet::getHots( std::vector<TrkHitOnTrk*>& hots ) const { 00108 const TrkExpectedHot* anExHot(0); 00109 for ( int i(0); i < _theHots.size(); ++i ) { 00110 anExHot = _theHots[i]; 00111 if ( anExHot->getHots(hots) ) break; 00112 } 00113 } 00114 00115 bool 00116 TrkExpectedHotSet::hasFitType( const TrkFitTypeKey& key ) const{ 00117 return ( exHot(key) != 0 ); 00118 } 00119 00120 00121 void 00122 TrkExpectedHotSet::printFit( const TrkFitTypeKey& key, 00123 ostream& os ) const{ 00124 os << " Intersects element "; 00125 _elemId.printAll(os); 00126 const TrkExpectedHot* theExHot = exHot(key); 00127 if ( theExHot == 0 ) { 00128 os << " _" << endl; 00129 return; 00130 } 00131 theExHot->printAll(os); 00132 os << endl; 00133 } 00134 00135 //------------- 00136 // Modifiers -- 00137 //------------- 00138 00139 bool 00140 TrkExpectedHotSet::addInfo ( TrkExpectedHot* aHot, 00141 const TrkFitTypeKey& key ){ 00142 if ( key.value() < 0 ) return false; 00143 if ( key.value() >= _fitTypeMap.size() ) return false; 00144 if ( aHot == 0 ) return false; 00145 const int test = _fitTypeMap[key.value()]; 00146 if ( test != -1 ) { 00147 TrkExpectedHot* myHot = _theHots[test]; 00148 if ( aHot->hasHot() ) { myHot->setHots(aHot); } 00149 delete aHot; 00150 return true; 00151 } 00152 ++_nFit; 00153 _fitTypeMap[key.value()] = _nFit; 00154 aHot->setExTrk(_exTrk); 00155 _theHots.push_back(aHot); 00156 return true; 00157 } 00158 00159 void 00160 TrkExpectedHotSet::setExTrk( const TrkExpectedTrk* anExTrk ) { 00161 _exTrk = anExTrk; 00162 const int nHot = _theHots.size(); 00163 for ( int iHot(0); iHot < nHot; ++iHot ) { 00164 TrkExpectedHot* aHot = _theHots[iHot]; 00165 aHot->setExTrk(_exTrk); 00166 } 00167 } 00168 00169 bool 00170 TrkExpectedHotSet::isSvt() const { 00171 return _elemId.sysInd() == TrkDetElemId::svt; 00172 } 00173 00174 bool 00175 TrkExpectedHotSet::isMdc() const { 00176 return _elemId.sysInd() == TrkDetElemId::mdc; 00177 } 00178 00179 // ------------------------------------------- 00180 // -- Protected Function Member Definitions -- 00181 // ------------------------------------------- 00182 00183 // ----------------------------------------- 00184 // -- Private Function Member Definitions -- 00185 // ----------------------------------------- 00186 00187 // ----------------------------------- 00188 // -- Internal Function Definitions -- 00189 // ----------------------------------- 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201