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
0009 static const float ret = 1e-2;
0010
0011
0012 return ret;
0013 }
0014 }
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
0032
0033
0034
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 }