CMS 3D CMS Logo

Public Member Functions | Private Attributes

PatVertexAnalyzer Class Reference

Inheritance diagram for PatVertexAnalyzer:
edm::EDAnalyzer

List of all members.

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
 ~PatVertexAnalyzer ()

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_

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.

                                                                  :
        src_(params.getParameter<edm::InputTag>("src")),
        genParticles_(params.getParameter<edm::InputTag>("mc"))
{
}
PatVertexAnalyzer::~PatVertexAnalyzer ( )

Definition at line 54 of file PatVertexAnalyzer.cc.

{
}

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_.

{  
        // handle to the primary vertex collection
        edm::Handle<reco::VertexCollection> pvHandle;
        event.getByLabel(src_, pvHandle);

        // handle to the generator particles (i.e. the MC truth)
        edm::Handle<reco::GenParticleCollection> genParticlesHandle;
        event.getByLabel(genParticles_, genParticlesHandle);

        // extract the position of the simulated vertex
        math::XYZPoint simPV = (*genParticlesHandle)[2].vertex();

        // the number of reconstructed primary vertices
        nVertices_->Fill(pvHandle->size());

        // if we have at least one, use the first (highest pt^2 sum)
        if (!pvHandle->empty()) {
                const reco::Vertex &pv = (*pvHandle)[0];

                nTracks_->Fill(pv.tracksSize());

                x_->Fill(pv.x());
                y_->Fill(pv.y());
                z_->Fill(pv.z());

                xErr_->Fill(pv.xError());
                yErr_->Fill(pv.yError());
                zErr_->Fill(pv.zError());

                xDelta_->Fill(pv.x() - simPV.X());
                yDelta_->Fill(pv.y() - simPV.Y());
                zDelta_->Fill(pv.z() - simPV.Z());

                xPull_->Fill((pv.x() - simPV.X()) / pv.xError());
                yPull_->Fill((pv.y() - simPV.Y()) / pv.yError());
                zPull_->Fill((pv.z() - simPV.Z()) / pv.zError());

                // we could access the tracks using the
                // pv.tracks_begin() ... pv.tracks_end() iterators
        }
}
void PatVertexAnalyzer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 58 of file PatVertexAnalyzer.cc.

References nTracks_, nVertices_, x_, xDelta_, xErr_, xPull_, y_, yDelta_, yErr_, yPull_, z_, zDelta_, zErr_, and zPull_.

{
        // retrieve handle to auxiliary service
        //  used for storing histograms into ROOT file
        edm::Service<TFileService> fs;

        nVertices_ = fs->make<TH1F>("nVertices", "number of reconstructed primary vertices", 50, 0, 50);
        nTracks_ = fs->make<TH1F>("nTracks", "number of tracks at primary vertex", 100, 0, 300);
        x_ = fs->make<TH1F>("pvX", "primary vertex x", 100, -0.1, 0.1);
        y_ = fs->make<TH1F>("pvY", "primary vertex y", 100, -0.1, 0.1);
        z_ = fs->make<TH1F>("pvZ", "primary vertex z", 100, -30, 30);
        xErr_ = fs->make<TH1F>("pvErrorX", "primary vertex x error", 100, 0, 0.005);
        yErr_ = fs->make<TH1F>("pvErrorY", "primary vertex y error", 100, 0, 0.005);
        zErr_ = fs->make<TH1F>("pvErrorZ", "primary vertex z error", 100, 0, 0.01);
        xDelta_ = fs->make<TH1F>("pvDeltaX", "x shift wrt simulated vertex", 100, -0.01, 0.01);
        yDelta_ = fs->make<TH1F>("pvDeltaY", "y shift wrt simulated vertex", 100, -0.01, 0.01);
        zDelta_ = fs->make<TH1F>("pvDeltaZ", "z shift wrt simulated vertex", 100, -0.02, 0.02);
        xPull_ = fs->make<TH1F>("pvPullX", "primary vertex x pull", 100, -5, 5);
        yPull_ = fs->make<TH1F>("pvPullY", "primary vertex y pull", 100, -5, 5);
        zPull_ = fs->make<TH1F>("pvPullZ", "primary vertex z pull", 100, -5, 5);
}

Member Data Documentation

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().

Definition at line 41 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

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().

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().