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.
1 //
2 // $Id: LeptonVertexSignificance.cc,v 1.3 2010/10/15 22:44:33 wmtan Exp $
3 //
4 
21 
22 using namespace pat;
23 
24 // constructor
26  // instantiate the transient-track builder
28  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
30 }
31 
32 // destructor
34  delete theTrackBuilder_;
35 }
36 
37 // calculate the TrackIsoPt for the lepton object
38 float LeptonVertexSignificance::calculate(const Electron & theElectron, const edm::Event & iEvent) {
39  return this->calculate(*theElectron.gsfTrack(), iEvent);
40 }
41 
42 float LeptonVertexSignificance::calculate(const Muon & theMuon, const edm::Event & iEvent) {
43  return this->calculate(*theMuon.track(), iEvent);
44 }
45 
46 // calculate the TrackIsoPt for the lepton's track
48  // FIXME: think more about how to handle events without vertices
49  // lepton LR calculation should have nothing to do with event selection
51  iEvent.getByLabel("offlinePrimaryVerticesFromCTFTracks", vertexHandle);
52  if (vertexHandle.product()->size() == 0) return 0;
53  reco::Vertex theVertex = vertexHandle.product()->front();
54  // calculate the track-vertex association significance
55  reco::TransientTrack theTrTrack = theTrackBuilder_->build(&theTrack);
56  GlobalPoint theVertexPoint(theVertex.position().x(), theVertex.position().y(), theVertex.position().z());
57  FreeTrajectoryState theLeptonNearVertex = theTrTrack.trajectoryStateClosestToPoint(theVertexPoint).theState();
58  return fabs(theVertex.position().z() - theLeptonNearVertex.position().z())
59  / sqrt(std::pow(theVertex.zError(), 2) + theLeptonNearVertex.cartesianError().position().czz());
60 }
61 
double zError() const
error on z
Definition: Vertex.h:105
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:131
const Point & position() const
position
Definition: Vertex.h:93
TransientTrackBuilder * theTrackBuilder_
int iEvent
Definition: GenABIO.cc:243
T sqrt(T t)
Definition: SSEVec.h:48
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
Analysis-level electron class.
Definition: Electron.h:52
T const * product() const
Definition: Handle.h:74
float calculate(const Electron &anElectron, const edm::Event &iEvent)
Analysis-level muon class.
Definition: Muon.h:51
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:142