CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EventVtxInfoNtupleDumper Class Reference

Inheritance diagram for EventVtxInfoNtupleDumper:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 EventVtxInfoNtupleDumper (const edm::ParameterSet &)

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

edm::InputTag primaryVertices_

Detailed Description

Definition at line 16 of file EventVtxInfoNtupleDumper.cc.


Constructor & Destructor Documentation

EventVtxInfoNtupleDumper::EventVtxInfoNtupleDumper ( const edm::ParameterSet cfg)

Definition at line 26 of file EventVtxInfoNtupleDumper.cc.

                                                                             : 
  primaryVertices_(cfg.getParameter<InputTag>("primaryVertices")) {
  produces<int>( "numPV" ).setBranchAlias( "numPV" );
  produces<int>( "nTrkPV" ).setBranchAlias( "nTrkPV" );
  produces<float>( "chi2PV" ).setBranchAlias( "chi2PV" );
  produces<float>( "ndofPV" ).setBranchAlias( "ndofPV" );
  produces<float>( "zPV" ).setBranchAlias( "zPV" );
  produces<float>( "rhoPV" ).setBranchAlias( "rhoPV" );
  //  produces<std::vector< unsigned int > >( "nTrkPV" ).setBranchAlias( "nTrkPV" );
  //  produces<std::vector< float > >( "chi2PV" ).setBranchAlias( "chi2PV" );
  //  produces<std::vector< float > >( "ndofPV" ).setBranchAlias( "ndofPV" );
}

Member Function Documentation

void EventVtxInfoNtupleDumper::produce ( edm::Event evt,
const edm::EventSetup  
) [private, virtual]

Implements edm::EDProducer.

Definition at line 41 of file EventVtxInfoNtupleDumper.cc.

References reco::Vertex::chi2(), edm::Event::getByLabel(), reco::Vertex::isFake(), reco::Vertex::ndof(), reco::Vertex::position(), primaryVertices_, edm::Event::put(), reco::Vertex::tracksSize(), and reco::Vertex::z().

                                                                        {
  
  Handle<reco::VertexCollection> primaryVertices;  // Collection of primary Vertices
  evt.getByLabel(primaryVertices_, primaryVertices);
  auto_ptr<int> nVtxs( new int );
  auto_ptr<int> nTrkVtx( new int );
  auto_ptr<float> chi2Vtx( new float );
  auto_ptr<float> ndofVtx( new float );
  auto_ptr<float> zVtx( new float );
  auto_ptr<float> rhoVtx( new float );
  //  auto_ptr< vector< unsigned int > > nTrkVtx( new vector< unsigned int > );
  //  auto_ptr< vector< float > > chi2Vtx( new vector< float > );
  //  auto_ptr< vector< float > > ndofVtx( new vector< float > );

  const reco::Vertex &pv = (*primaryVertices)[0];

  *nVtxs = -1;
  *nTrkVtx = -1;
  *chi2Vtx = -1.0;
  *ndofVtx = -1.0;
  *zVtx = -1000;
  *rhoVtx = -1000;
  if( !(pv.isFake()) ) {
    *nVtxs = primaryVertices->size();
    *nTrkVtx = pv.tracksSize();
    *chi2Vtx = pv.chi2();
    *ndofVtx = pv.ndof();
    *zVtx = pv.z();
    *rhoVtx = pv.position().Rho();
  }
  //  nTrkVtx->push_back(pv.tracksSize());
  //  chi2Vtx->push_back(pv.chi2());
  //  ndofVtx->push_back(pv.ndof());
  evt.put( nVtxs, "numPV" );
  evt.put( nTrkVtx, "nTrkPV" );
  evt.put( chi2Vtx, "chi2PV" );
  evt.put( ndofVtx, "ndofPV" );
  evt.put( zVtx, "zPV" );
  evt.put( rhoVtx, "rhoPV" );

}

Member Data Documentation

Definition at line 22 of file EventVtxInfoNtupleDumper.cc.

Referenced by produce().