CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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()->size() == 0) 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:446
double zError() const
error on z
Definition: Vertex.h:118
const FreeTrajectoryState & theState() const
reco::TransientTrack build(const reco::Track *p) const
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
Definition: Electron.cc:133
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const Point & position() const
position
Definition: Vertex.h:106
TransientTrackBuilder * theTrackBuilder_
int iEvent
Definition: GenABIO.cc:230
T sqrt(T t)
Definition: SSEVec.h:48
T const * product() const
Definition: Handle.h:81
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
Analysis-level electron class.
Definition: Electron.h:52
float calculate(const Electron &anElectron, const edm::Event &iEvent)
Analysis-level muon class.
Definition: Muon.h:50
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
reco::TrackRef track() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:149