CMS 3D CMS Logo

LeptonVertexSignificance.cc
Go to the documentation of this file.
15 
16 using namespace pat;
17 
18 // constructor
20  : vertexToken_(iC.consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVerticesFromCTFTracks"))) {
21  // instantiate the transient-track builder
23  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
25 }
26 
27 // destructor
29 
30 // calculate the TrackIsoPt for the lepton object
32  return this->calculate(*theElectron.gsfTrack(), iEvent);
33 }
34 
36  return this->calculate(*theMuon.track(), iEvent);
37 }
38 
39 // calculate the TrackIsoPt for the lepton's track
41  // FIXME: think more about how to handle events without vertices
42  // lepton LR calculation should have nothing to do with event selection
44  iEvent.getByToken(vertexToken_, vertexHandle);
45  if (vertexHandle.product()->empty())
46  return 0;
47  reco::Vertex theVertex = vertexHandle.product()->front();
48  // calculate the track-vertex association significance
49  reco::TransientTrack theTrTrack = theTrackBuilder_->build(&theTrack);
50  GlobalPoint theVertexPoint(theVertex.position().x(), theVertex.position().y(), theVertex.position().z());
51  FreeTrajectoryState theLeptonNearVertex = theTrTrack.trajectoryStateClosestToPoint(theVertexPoint).theState();
52  return fabs(theVertex.position().z() - theLeptonNearVertex.position().z()) /
53  sqrt(std::pow(theVertex.zError(), 2) + theLeptonNearVertex.cartesianError().position().czz());
54 }
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
double zError() const
error on z
Definition: Vertex.h:127
const FreeTrajectoryState & theState() const
reco::TransientTrack build(const reco::Track *p) const
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
reco::TrackRef track() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
const Point & position() const
position
Definition: Vertex.h:113
Definition: HeavyIon.h:7
TransientTrackBuilder * theTrackBuilder_
int iEvent
Definition: GenABIO.cc:224
Definition: Muon.py:1
T sqrt(T t)
Definition: SSEVec.h:19
T const * product() const
Definition: Handle.h:69
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:73
float calculate(const Electron &anElectron, const edm::Event &iEvent)
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
T const * product() const
Definition: ESHandle.h:86
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30