/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/TrkBase/TrkBase-00-01-12/src/TrkHotListFull.cxx

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: TrkHotListFull.cxx,v 1.1.1.1 2005/04/21 06:01:42 zhangy Exp $
00004 //
00005 // Description:
00006 //
00007 //
00008 // Environment:
00009 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00010 //
00011 // Author(s): Steve Schaffner
00012 //
00013 //------------------------------------------------------------------------
00014 
00015 //#include "BaBar/BaBar.h"
00016 #include "TrkBase/TrkHotListFull.h"
00017 #include "TrkBase/TrkPredicates.h"
00018 #include "TrkBase/TrkHitOnTrk.h"
00019 #include "TrkBase/TrkView.h"
00020 //#include "ErrLogger/ErrLog.h"
00021 #include "MdcRecoUtil/BesCollectionUtils.h"
00022 #include <assert.h>
00023 #include <algorithm>
00024 #include <functional>
00025 
00026 // Default ctor
00027 // Special case of ctor below:
00028 
00029 TrkHotListFull::TrkHotListFull()
00030 {
00031 }
00032 
00033 
00034 TrkHotListFull::TrkHotListFull(const TrkHotList& inHots,TrkBase::Functors::cloneHot f)
00035 {
00036         //TrkHotListFull::clone come here
00037     _hotlist.reserve(dfltCapac());
00038 //Clones Hots, and makes each point at the new track.
00039     for (TrkHotList::hot_iterator i = inHots.begin();i!=inHots.end();++i) {
00040 //          i->printAll(std::cout);//yzhang debug
00041          _hotlist.push_back(f(*i));
00042     }
00043 }
00044 
00045 
00046 TrkHotListFull::TrkHotListFull(TrkHotList& inHots, TrkBase::Functors::setParent f)
00047 {
00048     _hotlist.reserve(dfltCapac());
00049 // shallow copy the hots and remove from input hotList
00050   for (TrkHotList::nc_hot_iterator i = inHots.begin();i!=inHots.end();++i) {
00051       _hotlist.push_back(f(*i));
00052   }
00053   inHots.hotlist().clear();
00054 }
00055 
00056 
00057 TrkHotList*
00058 TrkHotListFull::clone(TrkBase::Functors::cloneHot f) const
00059 {
00060   return new TrkHotListFull(*this, f);
00061 }
00062 
00063 TrkHotListFull::~TrkHotListFull()
00064 {
00065 //      std::cout << " ~TrkHotListFull" << std::endl;//yzhang debug
00066 // turn the parents off before deleting hots.  This avoids a cyclic delete error
00067 // when deleting a track
00068 //   std::for_each(begin(),end(),setParent(0));
00069   std::for_each(_hotlist.begin(),_hotlist.end(),bes::Collection::DeleteObject());
00070 }
00071 
00072 size_t
00073 TrkHotListFull::dfltCapac()
00074 {
00075   static size_t _dfltCapac = 75;
00076   return _dfltCapac;
00077 }
00078 
00079 void
00080 TrkHotListFull::updateHots()
00081 {
00082   std::for_each(begin(),end(),updateMeasurement(0,false));
00083   sort();
00084 }
00085 
00086 void
00087 TrkHotListFull::append(TrkHitOnTrk* newHot)
00088 {
00089   _hotlist.push_back(newHot);
00090 }
00091 
00092 void
00093 TrkHotListFull::remove(TrkHitOnTrk* deadHot)
00094 {
00095   typedef std::vector<TrkHitOnTrk*>::iterator iter_t;
00096   iter_t i = std::find(_hotlist.begin(),_hotlist.end(),deadHot);
00097   if (i!=_hotlist.end()) {
00098     delete *i;
00099     _hotlist.erase(i);
00100   } else
00101     std::cout<<"ErrMsg(error) "<< " you asked to remove a hit which I don't have! " << std::endl;
00102 }
00103 
00104 TrkHitOnTrk*
00105 TrkHotListFull::findHot(const TrkFundHit* theHit) const
00106 {
00107   TrkBase::Predicates::hotMatchesFundHit match(theHit);
00108   TrkHotList::hot_iterator i = std::find_if(begin(),end(),match);
00109   return i==end()?0:const_cast<TrkHitOnTrk*>( i.get() );  // FIXME: return (non)const TrkHitOnTrk from (non)const
00110 }
00111 
00112 int
00113 TrkHotListFull::nActive(TrkEnums::TrkViewInfo view) const
00114 {
00115   int nAct = 0;
00116   for (TrkHotList::hot_iterator i = begin();i!=end();++i) {
00117     if (i->isActive())
00118       if(view == TrkEnums::bothView || i->whatView() == view)++nAct;
00119   }
00120   return nAct;
00121 }
00122 
00123 int
00124 TrkHotListFull::nHit(TrkEnums::TrkViewInfo view) const
00125 {
00126   if(view == TrkEnums::bothView)
00127     return end()-begin();
00128   else {
00129     int nAct = 0;
00130     for (TrkHotList::hot_iterator i = begin();i!=end();++i) {
00131       if(i->whatView() == view)++nAct;
00132     }
00133     return nAct;
00134   }
00135 }
00136 
00137 bool
00138 TrkHotListFull::hitCapable() const
00139 {
00140   return true;
00141 }
00142 
00143 int
00144 TrkHotListFull::nMdc(TrkEnums::TrkViewInfo view) const
00145 {
00146   bool activeOnly(true);
00147   TrkBase::Predicates::isMdcHitOnTrack mdc(activeOnly);
00148   TrkBase::Predicates::hasView v(view);
00149 // FIXME: W6U1 doesn't have std::count (at least, not in the config used by BaBar!)
00150 // FIXME: std::compose2 is an SGI extension...
00151 //  return std::count(begin(),end(),std::compose2(std::logical_and<bool>(),mdc,v);
00152   int n = 0;
00153   for (TrkHotList::hot_iterator i = begin();i!=end();++i)
00154       if(mdc(*i)&&v(*i)) ++n;
00155   return n;
00156 }
00157 
00158 int
00159 TrkHotListFull::nSvt(TrkEnums::TrkViewInfo view) const
00160 {
00161   bool activeOnly(true);
00162   TrkBase::Predicates::isSvtHitOnTrack svt(activeOnly);
00163   TrkBase::Predicates::hasView v(view);
00164 // FIXME: W6U1 doesn't have std::count (at least, not in the config used by BaBar!)
00165 // FIXME: std::compose2 is an SGI extension...
00166 //  return std::count(begin(),end(),std::compose2(std::logical_and<bool>(),svt,v);
00167   int n = 0;
00168   for (TrkHotList::hot_iterator i = begin();i!=end();++i)
00169           if (svt(*i)&&v(*i)) ++n;
00170   return n;
00171 }
00172 
00173 double
00174 TrkHotListFull::startFoundRange() const
00175 {
00176   TrkBase::Predicates::isHotActive active;
00177   TrkHotList::hot_iterator i = std::find_if(begin(),end(),active);
00178   return i == end() ? 9999 : i->fltLen();
00179 }
00180 
00181 double
00182 TrkHotListFull::endFoundRange() const
00183 {
00184   double maxFlt = -9999;
00185   TrkBase::Predicates::isHotActive predicate;
00186   TrkHotList::hot_iterator i = end();
00187   TrkHotList::hot_iterator b = begin();
00188   while (i-- != b) {
00189     if (predicate(*i)) {
00190       maxFlt = i->fltLen();
00191       break;
00192     }
00193   }
00194   return maxFlt;
00195 }
00196 
00197 
00198 TrkView
00199 TrkHotListFull::svtView(int layer) const
00200 {
00201   TrkView retval;
00202   bool activeOnly(true);
00203   TrkBase::Predicates::isSvtHitOnTrack svt(activeOnly);
00204   TrkBase::Predicates::isLayer l(layer);
00205   // FIXME: std::compose2 is an SGI extension...
00206   for(TrkHotList::hot_iterator i=begin();i!=end();++i)
00207         if (svt(*i)&&l(*i)) retval.addView(i->whatView());
00208   return retval;
00209 }
00210 
00211 unsigned
00212 TrkHotListFull::firstMdcLayer() const
00213 {
00214   unsigned firstlay(50);
00215   bool activeOnly(true);
00216   TrkBase::Predicates::isMdcHitOnTrack mdc(activeOnly);
00217   for (TrkHotList::hot_iterator i = begin();i!=end();++i) {
00218     if (mdc(*i)) firstlay = std::min(firstlay,i->layerNumber());
00219   }
00220   return firstlay<50?firstlay:0;
00221 }
00222 
00223 unsigned
00224 TrkHotListFull::lastMdcLayer() const
00225 {
00226   unsigned lastlay(0);
00227   bool activeOnly(true);
00228   TrkBase::Predicates::isMdcHitOnTrack mdc(activeOnly);
00229   for (TrkHotList::hot_iterator i = begin();i!=end();++i) {
00230     if (mdc(*i)) lastlay = std::max(lastlay,i->layerNumber());
00231   }
00232   return lastlay;
00233 }
00234 
00235 const std::vector<TrkHitOnTrk*>&
00236 TrkHotListFull::hotlist() const
00237 {
00238   return _hotlist;
00239 }
00240 
00241 std::vector<TrkHitOnTrk*>&
00242 TrkHotListFull::hotlist()
00243 {
00244   return _hotlist;
00245 }
00246 
00247 bool
00248 TrkHotListFull::isActive(unsigned ihot) const {
00249   if(ihot<_hotlist.size())
00250     return _hotlist[ihot]->isActive();
00251   else
00252     return false;
00253 }
00254             

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