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 {
22  // instantiate the transient-track builder
24  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
26 }
27 
28 // destructor
30  delete theTrackBuilder_;
31 }
32 
33 // calculate the TrackIsoPt for the lepton object
34 float LeptonVertexSignificance::calculate(const Electron & theElectron, const edm::Event & iEvent) {
35  return this->calculate(*theElectron.gsfTrack(), iEvent);
36 }
37 
38 float LeptonVertexSignificance::calculate(const Muon & theMuon, const edm::Event & iEvent) {
39  return this->calculate(*theMuon.track(), iEvent);
40 }
41 
42 // calculate the TrackIsoPt for the lepton's track
44  // FIXME: think more about how to handle events without vertices
45  // lepton LR calculation should have nothing to do with event selection
47  iEvent.getByToken(vertexToken_, vertexHandle);
48  if (vertexHandle.product()->empty()) return 0;
49  reco::Vertex theVertex = vertexHandle.product()->front();
50  // calculate the track-vertex association significance
51  reco::TransientTrack theTrTrack = theTrackBuilder_->build(&theTrack);
52  GlobalPoint theVertexPoint(theVertex.position().x(), theVertex.position().y(), theVertex.position().z());
53  FreeTrajectoryState theLeptonNearVertex = theTrTrack.trajectoryStateClosestToPoint(theVertexPoint).theState();
54  return fabs(theVertex.position().z() - theLeptonNearVertex.position().z())
55  / sqrt(std::pow(theVertex.zError(), 2) + theLeptonNearVertex.cartesianError().position().czz());
56 }
57 
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
double zError() const
error on z
Definition: Vertex.h:123
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:109
Definition: HeavyIon.h:7
TransientTrackBuilder * theTrackBuilder_
int iEvent
Definition: GenABIO.cc:224
Definition: Muon.py:1
T sqrt(T t)
Definition: SSEVec.h:18
T const * product() const
Definition: Handle.h:74
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:71
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:40