CMS 3D CMS Logo

JetSignalVertexCompatibilityAlgo.cc
Go to the documentation of this file.
1 #include <functional>
2 #include <cmath>
3 #include <map>
4 
9 
15 
17 
19 
20 using namespace reco;
21 
22 // helper
23 template <typename T>
25  const edm::RefToBase<T> &r2) const {
26  return r1.id() < r2.id() || (r1.id() == r2.id() && r1.key() < r2.key());
27 }
28 
31 
33 
35  GlobalPoint point1 = RecoVertex::convertPos(vtx.position());
37  TrajectoryStateOnSurface tsos = extrap.extrapolate(track.impactPointState(), point1);
38 
39  if (!tsos.isValid())
40  return 1.0e6;
41 
42  GlobalPoint point2 = tsos.globalPosition();
43  ROOT::Math::SVector<double, 3> dir(point1.x() - point2.x(), point1.y() - point2.y(), point1.z() - point2.z());
44  GlobalError cov = RecoVertex::convertError(vtx.covariance()) + tsos.cartesianError().position();
45 
46  return ROOT::Math::Mag2(dir) / std::sqrt(ROOT::Math::Similarity(cov.matrix(), dir));
47 }
48 
50  TransientTrackMap::iterator pos = trackMap.lower_bound(track);
51  if (pos != trackMap.end() && pos->first == track)
52  return pos->second;
53 
54  // the castTo will only work with regular, i.e. no GsfTracks
55  // the interface is not intrinsically polymorph...
56  return trackMap.insert(pos, std::make_pair(track, trackBuilder->build(track.castTo<TrackRef>())))->second;
57 }
58 
59 double JetSignalVertexCompatibilityAlgo::activation(double compat) const {
60  return 1. / (std::exp((compat - cut) / temperature) + 1.);
61 }
62 
64  const reco::TrackRefVector &tracks) const {
65  std::vector<float> result(vertices.size(), 0.);
66  float sum = 0.;
67 
68  for (TrackRefVector::const_iterator track = tracks.begin(); track != tracks.end(); ++track) {
69  const TransientTrack &transientTrack = convert(TrackBaseRef(*track));
70 
71  for (unsigned int i = 0; i < vertices.size(); i++) {
72  double compat = trackVertexCompat(vertices[i], transientTrack);
73  double contribution = activation(compat) * (*track)->pt();
74 
75  result[i] += contribution;
76  sum += contribution;
77  }
78  }
79 
80  if (sum < 1.0e-9) {
81  for (unsigned int i = 0; i < result.size(); i++)
82  result[i] = 1.0 / result.size();
83  } else {
84  for (unsigned int i = 0; i < result.size(); i++)
85  result[i] /= sum;
86  }
87 
88  return result;
89 }
90 
92  trackMap.clear();
93  trackBuilder = builder;
94 }
TrajectoryStateOnSurface.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:355
AnalyticalImpactPointExtrapolator.h
TkAlMuonSelectors_cfi.cut
cut
Definition: TkAlMuonSelectors_cfi.py:5
reco::JetSignalVertexCompatibilityAlgo::temperature
const double temperature
Definition: JetSignalVertexCompatibilityAlgo.h:41
reco::JetSignalVertexCompatibilityAlgo::compatibility
std::vector< float > compatibility(const reco::VertexCollection &vertices, const reco::TrackRefVector &tracks) const
Definition: JetSignalVertexCompatibilityAlgo.cc:63
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
pos
Definition: PixelAliasList.h:18
reco::JetSignalVertexCompatibilityAlgo::activation
double activation(double compat) const
Definition: JetSignalVertexCompatibilityAlgo.cc:59
reco::JetSignalVertexCompatibilityAlgo::~JetSignalVertexCompatibilityAlgo
~JetSignalVertexCompatibilityAlgo()
Definition: JetSignalVertexCompatibilityAlgo.cc:32
ConvertToFromReco.h
reco::TrackBaseRef
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:35
edm::RefVector< TrackCollection >
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
TransientTrack.h
reco::JetSignalVertexCompatibilityAlgo::resetEvent
void resetEvent(const TransientTrackBuilder *trackBuilder)
Definition: JetSignalVertexCompatibilityAlgo.cc:91
edm::Ref< TrackCollection >
reco::JetSignalVertexCompatibilityAlgo::trackBuilder
const TransientTrackBuilder * trackBuilder
Definition: JetSignalVertexCompatibilityAlgo.h:38
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
Track.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::JetSignalVertexCompatibilityAlgo::trackVertexCompat
static double trackVertexCompat(const reco::Vertex &vtx, const TransientTrack &track)
Definition: JetSignalVertexCompatibilityAlgo.cc:34
RefToBase.h
badGlobalMuonTaggersAOD_cff.vtx
vtx
Definition: badGlobalMuonTaggersAOD_cff.py:5
Vertex.h
TransientTrackBuilder.h
AnalyticalImpactPointExtrapolator
Definition: AnalyticalImpactPointExtrapolator.h:26
RecoVertex::convertError
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
reco::JetSignalVertexCompatibilityAlgo::RefToBaseLess::operator()
bool operator()(const edm::RefToBase< T > &r1, const edm::RefToBase< T > &r2) const
Definition: JetSignalVertexCompatibilityAlgo.cc:24
TransientTrackBuilder
Definition: TransientTrackBuilder.h:16
GlobalErrorBase< double, ErrorMatrixTag >
reco::JetSignalVertexCompatibilityAlgo::convert
const TransientTrack & convert(const reco::TrackBaseRef &track) const
Definition: JetSignalVertexCompatibilityAlgo.cc:49
TransientTrackRecord.h
reco::JetSignalVertexCompatibilityAlgo::JetSignalVertexCompatibilityAlgo
JetSignalVertexCompatibilityAlgo(double cut, double temperature)
Definition: JetSignalVertexCompatibilityAlgo.cc:29
jvcParameters_cfi.temperature
temperature
Definition: jvcParameters_cfi.py:7
VertexFwd.h
reco::JetSignalVertexCompatibilityAlgo::cut
const double cut
Definition: JetSignalVertexCompatibilityAlgo.h:40
reco::TransientTrack
Definition: TransientTrack.h:19
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
JetSignalVertexCompatibilityAlgo.h
edm::RefVectorIterator
Definition: EDProductfwd.h:33
edm::RefToBase
Definition: AssociativeIterator.h:54
math::GlobalPoint
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalPoint
point in global coordinate system
Definition: Point3D.h:18
RecoVertex::convertPos
reco::Vertex::Point convertPos(const GlobalPoint &p)
Definition: ConvertToFromReco.h:7
TransientTrackBuilder::build
reco::TransientTrack build(const reco::Track *p) const
Definition: TransientTrackBuilder.cc:20
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
mps_fire.result
result
Definition: mps_fire.py:303
reco::JetSignalVertexCompatibilityAlgo::trackMap
TransientTrackMap trackMap
Definition: JetSignalVertexCompatibilityAlgo.h:37
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
reco::Vertex
Definition: Vertex.h:35
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37