ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ForwardAnalysis/Utilities/src/TrackAssociatedWithPVSelector.cc
Revision: 1.1
Committed: Fri Aug 26 10:19:59 2011 UTC (13 years, 8 months ago) by antoniov
Content type: text/plain
Branch: MAIN
CVS Tags: V01-01-01, V01-01-00, antoniov-forwardAnalysis-09Jul2012-v1, antoniov-forwardAnalysis-29Jun2012-v1, V01-00-00, antoniov-utilities-11Jun2012-v1, antoniov-forwardAnalysis-Oct072011-v1, sfonseca_10_04_2011, antoniov-forwardAnalysis-Sep182011-v1, antoniov-forwardAnalysis-Sep102011-v1, sfonseca_08_26_2011, HEAD
Log Message:
update

File Contents

# Content
1 #include "ForwardAnalysis/Utilities/interface/TrackAssociatedWithPVSelector.h"
2
3 #include "DataFormats/Common/interface/Handle.h"
4 #include "FWCore/Framework/interface/Event.h"
5 #include "FWCore/ParameterSet/interface/ParameterSet.h"
6
7 #include "DataFormats/TrackReco/interface/Track.h"
8 #include "DataFormats/VertexReco/interface/Vertex.h"
9
10 using namespace reco;
11 using forwardAnalysis::TrackAssociatedWithPVSelector;
12
13 TrackAssociatedWithPVSelector::TrackAssociatedWithPVSelector(const edm::ParameterSet& pset):
14 vertexTag_(pset.getParameter<edm::InputTag>("vertexTag")),
15 deltaZVtxMin_(pset.getParameter<double>("minDistanceFromVertex")),
16 deltaZVtxMax_(pset.getParameter<double>("maxDistanceFromVertex")){}
17
18 TrackAssociatedWithPVSelector::~TrackAssociatedWithPVSelector() {}
19
20 bool TrackAssociatedWithPVSelector::operator()(const reco::Track& track, const edm::Event& event) const {
21 edm::Handle<edm::View<Vertex> > vertexCollectionH;
22 event.getByLabel(vertexTag_,vertexCollectionH);
23 const edm::View<Vertex>& vtxColl = *(vertexCollectionH.product());
24
25 // Access primary vertex
26 const Vertex& primaryVertex = vtxColl.front();
27 bool goodPrimaryVertex = ((primaryVertex.isValid())&&(!primaryVertex.isFake()));
28
29 if(!goodPrimaryVertex) return false;
30
31 const math::XYZPoint& trackVtxPos = track.vertex();
32 const math::XYZPoint& primVtxPos = primaryVertex.position();
33
34 math::XYZVector dist = trackVtxPos - primVtxPos;
35 bool accept = (fabs(dist.z()) >= deltaZVtxMin_)&&(fabs(dist.z()) <= deltaZVtxMax_);
36
37 return accept;
38 }