CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PatVertexAnalyzer Class Reference
Inheritance diagram for PatVertexAnalyzer:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &es)
 
virtual void beginJob ()
 
 PatVertexAnalyzer (const edm::ParameterSet &params)
 constructor and destructor More...
 
 ~PatVertexAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

edm::InputTag genParticles_
 
TH1 * nTracks_
 
TH1 * nVertices_
 
edm::InputTag src_
 
TH1 * x_
 
TH1 * xDelta_
 
TH1 * xErr_
 
TH1 * xPull_
 
TH1 * y_
 
TH1 * yDelta_
 
TH1 * yErr_
 
TH1 * yPull_
 
TH1 * z_
 
TH1 * zDelta_
 
TH1 * zErr_
 
TH1 * zPull_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 26 of file PatVertexAnalyzer.cc.

Constructor & Destructor Documentation

PatVertexAnalyzer::PatVertexAnalyzer ( const edm::ParameterSet params)

constructor and destructor

Definition at line 48 of file PatVertexAnalyzer.cc.

48  :
49  src_(params.getParameter<edm::InputTag>("src")),
51 {
52 }
T getParameter(std::string const &) const
edm::InputTag genParticles_
PatVertexAnalyzer::~PatVertexAnalyzer ( )

Definition at line 54 of file PatVertexAnalyzer.cc.

55 {
56 }

Member Function Documentation

void PatVertexAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup es 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 80 of file PatVertexAnalyzer.cc.

References genParticles_, nTracks_, nVertices_, src_, reco::Vertex::tracksSize(), reco::Vertex::x(), x_, xDelta_, xErr_, reco::Vertex::xError(), xPull_, reco::Vertex::y(), y_, yDelta_, yErr_, reco::Vertex::yError(), yPull_, reco::Vertex::z(), z_, zDelta_, zErr_, reco::Vertex::zError(), and zPull_.

81 {
82  // handle to the primary vertex collection
84  event.getByLabel(src_, pvHandle);
85 
86  // handle to the generator particles (i.e. the MC truth)
88  event.getByLabel(genParticles_, genParticlesHandle);
89 
90  // extract the position of the simulated vertex
91  math::XYZPoint simPV = (*genParticlesHandle)[2].vertex();
92 
93  // the number of reconstructed primary vertices
94  nVertices_->Fill(pvHandle->size());
95 
96  // if we have at least one, use the first (highest pt^2 sum)
97  if (!pvHandle->empty()) {
98  const reco::Vertex &pv = (*pvHandle)[0];
99 
100  nTracks_->Fill(pv.tracksSize());
101 
102  x_->Fill(pv.x());
103  y_->Fill(pv.y());
104  z_->Fill(pv.z());
105 
106  xErr_->Fill(pv.xError());
107  yErr_->Fill(pv.yError());
108  zErr_->Fill(pv.zError());
109 
110  xDelta_->Fill(pv.x() - simPV.X());
111  yDelta_->Fill(pv.y() - simPV.Y());
112  zDelta_->Fill(pv.z() - simPV.Z());
113 
114  xPull_->Fill((pv.x() - simPV.X()) / pv.xError());
115  yPull_->Fill((pv.y() - simPV.Y()) / pv.yError());
116  zPull_->Fill((pv.z() - simPV.Z()) / pv.zError());
117 
118  // we could access the tracks using the
119  // pv.tracks_begin() ... pv.tracks_end() iterators
120  }
121 }
double zError() const
error on z
Definition: Vertex.h:105
double y() const
y coordinate
Definition: Vertex.h:97
edm::InputTag genParticles_
double z() const
y coordinate
Definition: Vertex.h:99
double x() const
x coordinate
Definition: Vertex.h:95
double xError() const
error on x
Definition: Vertex.h:101
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
double yError() const
error on y
Definition: Vertex.h:103
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:35
void PatVertexAnalyzer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 58 of file PatVertexAnalyzer.cc.

References TFileDirectory::make(), nTracks_, nVertices_, x_, xDelta_, xErr_, xPull_, y_, yDelta_, yErr_, yPull_, z_, zDelta_, zErr_, and zPull_.

59 {
60  // retrieve handle to auxiliary service
61  // used for storing histograms into ROOT file
63 
64  nVertices_ = fs->make<TH1F>("nVertices", "number of reconstructed primary vertices", 50, 0, 50);
65  nTracks_ = fs->make<TH1F>("nTracks", "number of tracks at primary vertex", 100, 0, 300);
66  x_ = fs->make<TH1F>("pvX", "primary vertex x", 100, -0.1, 0.1);
67  y_ = fs->make<TH1F>("pvY", "primary vertex y", 100, -0.1, 0.1);
68  z_ = fs->make<TH1F>("pvZ", "primary vertex z", 100, -30, 30);
69  xErr_ = fs->make<TH1F>("pvErrorX", "primary vertex x error", 100, 0, 0.005);
70  yErr_ = fs->make<TH1F>("pvErrorY", "primary vertex y error", 100, 0, 0.005);
71  zErr_ = fs->make<TH1F>("pvErrorZ", "primary vertex z error", 100, 0, 0.01);
72  xDelta_ = fs->make<TH1F>("pvDeltaX", "x shift wrt simulated vertex", 100, -0.01, 0.01);
73  yDelta_ = fs->make<TH1F>("pvDeltaY", "y shift wrt simulated vertex", 100, -0.01, 0.01);
74  zDelta_ = fs->make<TH1F>("pvDeltaZ", "z shift wrt simulated vertex", 100, -0.02, 0.02);
75  xPull_ = fs->make<TH1F>("pvPullX", "primary vertex x pull", 100, -5, 5);
76  yPull_ = fs->make<TH1F>("pvPullY", "primary vertex y pull", 100, -5, 5);
77  zPull_ = fs->make<TH1F>("pvPullZ", "primary vertex z pull", 100, -5, 5);
78 }
T * make() const
make new ROOT object

Member Data Documentation

edm::InputTag PatVertexAnalyzer::genParticles_
private

Definition at line 39 of file PatVertexAnalyzer.cc.

Referenced by analyze().

TH1 * PatVertexAnalyzer::nTracks_
private

Definition at line 41 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1* PatVertexAnalyzer::nVertices_
private

Definition at line 41 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

edm::InputTag PatVertexAnalyzer::src_
private

Definition at line 38 of file PatVertexAnalyzer.cc.

Referenced by analyze().

TH1* PatVertexAnalyzer::x_
private

Definition at line 42 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1* PatVertexAnalyzer::xDelta_
private

Definition at line 44 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1* PatVertexAnalyzer::xErr_
private

Definition at line 43 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1* PatVertexAnalyzer::xPull_
private

Definition at line 45 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1 * PatVertexAnalyzer::y_
private

Definition at line 42 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1 * PatVertexAnalyzer::yDelta_
private

Definition at line 44 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1 * PatVertexAnalyzer::yErr_
private

Definition at line 43 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1 * PatVertexAnalyzer::yPull_
private

Definition at line 45 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1 * PatVertexAnalyzer::z_
private

Definition at line 42 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1 * PatVertexAnalyzer::zDelta_
private

Definition at line 44 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1 * PatVertexAnalyzer::zErr_
private

Definition at line 43 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1 * PatVertexAnalyzer::zPull_
private

Definition at line 45 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().