CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoVertex/MultiVertexFit/src/LinTrackCache.cc

Go to the documentation of this file.
00001 #include "RecoVertex/MultiVertexFit/interface/LinTrackCache.h"
00002 #include "RecoVertex/VertexTools/interface/LinearizedTrackStateFactory.h"
00003 
00004 using namespace std;
00005 
00006 namespace
00007 {
00008   int verbose()
00009   {
00010     static const int ret = 0; /* SimpleConfigurable<int>
00011       (0, "LinTrackCache:Debug").value(); */
00012     return ret;
00013   }
00014 
00015   float maxRelinDistance()
00016   {
00017     // maximum distance before relinearizing
00018     static const float ret = 1e-2; /*  SimpleConfigurable<float>
00019       (0.01, "LinTrackCache:RelinearizeAfter").value();
00020       */
00021     return ret;
00022   }
00023 }
00024 
00025 LinTrackCache::RefCountedLinearizedTrackState LinTrackCache::linTrack
00026     ( const GlobalPoint & pos, const reco::TransientTrack & rt )
00027 {
00028   if ( theHasLinTrack[pos][rt] )
00029   {
00030     return theLinTracks[pos][rt];
00031   };
00032 
00033   LinearizedTrackStateFactory lTrackFactory;
00034   RefCountedLinearizedTrackState lTrData =
00035     lTrackFactory.linearizedTrackState( pos, rt );
00036 
00037   theLinTracks[pos][rt]=lTrData;
00038   theHasLinTrack[pos][rt]=true;
00039   return lTrData;
00040 }
00041 
00042 bool LinTrackCache::Comparer::operator() ( const GlobalPoint & left,                                               const GlobalPoint & right )
00043 {
00044   // if theyre closer than 1 micron, they're
00045   // indistinguishable, i.e. the same
00046   // static const double max = 1e-4 * 1e-4;
00047   // if ( ( left - right ).mag2() < max ) return false;
00048 
00049   if ( left.x() != right.x() )
00050   {
00051     return ( left.x() < right.x() );
00052   } else if (left.y() != right.y()) {
00053     return ( left.y() < right.y() );
00054   } else {
00055     return ( left.z() < right.z() );
00056   }
00057 }
00058 
00059 bool LinTrackCache::Vicinity::operator() ( const GlobalPoint & p1,
00060                                            const GlobalPoint & p2 )
00061 {
00062   if ( (p1 - p2).mag() < maxRelinDistance() )
00063   {
00064     return false;
00065   };
00066   return Comparer()(p1,p2);
00067 }
00068 
00069 LinTrackCache::~LinTrackCache()
00070 {
00071   clear();
00072 }
00073 
00074 void LinTrackCache::clear()
00075 {
00076   theLinTracks.clear();
00077   theHasLinTrack.clear();
00078 }