Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:14

0001 #include "RecoVertex/MultiVertexFit/interface/LinTrackCache.h"
0002 #include "RecoVertex/VertexTools/interface/LinearizedTrackStateFactory.h"
0003 
0004 using namespace std;
0005 
0006 namespace {
0007   float maxRelinDistance() {
0008     // maximum distance before relinearizing
0009     static const float ret = 1e-2; /*  SimpleConfigurable<float>
0010       (0.01, "LinTrackCache:RelinearizeAfter").value();
0011       */
0012     return ret;
0013   }
0014 }  // namespace
0015 
0016 LinTrackCache::RefCountedLinearizedTrackState LinTrackCache::linTrack(const GlobalPoint& pos,
0017                                                                       const reco::TransientTrack& rt) {
0018   if (theHasLinTrack[pos][rt]) {
0019     return theLinTracks[pos][rt];
0020   };
0021 
0022   LinearizedTrackStateFactory lTrackFactory;
0023   RefCountedLinearizedTrackState lTrData = lTrackFactory.linearizedTrackState(pos, rt);
0024 
0025   theLinTracks[pos][rt] = lTrData;
0026   theHasLinTrack[pos][rt] = true;
0027   return lTrData;
0028 }
0029 
0030 bool LinTrackCache::Comparer::operator()(const GlobalPoint& left, const GlobalPoint& right) const {
0031   // if theyre closer than 1 micron, they're
0032   // indistinguishable, i.e. the same
0033   // static const double max = 1e-4 * 1e-4;
0034   // if ( ( left - right ).mag2() < max ) return false;
0035 
0036   if (left.x() != right.x()) {
0037     return (left.x() < right.x());
0038   } else if (left.y() != right.y()) {
0039     return (left.y() < right.y());
0040   } else {
0041     return (left.z() < right.z());
0042   }
0043 }
0044 
0045 bool LinTrackCache::Vicinity::operator()(const GlobalPoint& p1, const GlobalPoint& p2) const {
0046   if ((p1 - p2).mag() < maxRelinDistance()) {
0047     return false;
0048   };
0049   return Comparer()(p1, p2);
0050 }
0051 
0052 LinTrackCache::~LinTrackCache() { clear(); }
0053 
0054 void LinTrackCache::clear() {
0055   theLinTracks.clear();
0056   theHasLinTrack.clear();
0057 }