#include <HIBestVertexProducer.h>
Public Member Functions | |
HIBestVertexProducer (const edm::ParameterSet &ps) | |
virtual void | produce (edm::Event &ev, const edm::EventSetup &es) |
~HIBestVertexProducer () | |
Private Member Functions | |
void | beginJob () |
Private Attributes | |
edm::InputTag | theAdaptiveVertexCollection |
edm::ParameterSet | theConfig |
edm::InputTag | theMedianVertexCollection |
Definition at line 9 of file HIBestVertexProducer.h.
HIBestVertexProducer::HIBestVertexProducer | ( | const edm::ParameterSet & | ps | ) | [explicit] |
Definition at line 20 of file HIBestVertexProducer.cc.
: theConfig(ps), theMedianVertexCollection(ps.getParameter<edm::InputTag>("medianVertexCollection")), theAdaptiveVertexCollection(ps.getParameter<edm::InputTag>("adaptiveVertexCollection")) { produces<reco::VertexCollection>(); }
HIBestVertexProducer::~HIBestVertexProducer | ( | ) |
Definition at line 29 of file HIBestVertexProducer.cc.
{ }
void HIBestVertexProducer::beginJob | ( | void | ) | [private, virtual] |
void HIBestVertexProducer::produce | ( | edm::Event & | ev, |
const edm::EventSetup & | es | ||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 40 of file HIBestVertexProducer.cc.
References ExpressReco_HICollisions_FallBack::beamSpot, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), edm::Event::getByLabel(), edm::HandleBase::isValid(), reco::BeamSpot::position(), funct::pow(), edm::Handle< T >::product(), edm::Event::put(), reco::BeamSpot::sigmaZ(), reco::BeamSpot::x0(), and reco::BeamSpot::y0().
{ // 1. use best adaptive vertex preferentially // 2. use median vertex in case where adaptive algorithm failed // 3. use beamspot if netither vertexing method succeeds // New vertex collection std::auto_ptr<reco::VertexCollection> newVertexCollection(new reco::VertexCollection); //** Get precise adaptive vertex **/ edm::Handle<reco::VertexCollection> vc1; ev.getByLabel(theAdaptiveVertexCollection, vc1); const reco::VertexCollection *vertices1 = vc1.product(); if(vertices1->size()==0) LogError("HeavyIonVertexing") << "adaptive vertex collection is empty!" << endl; if(vertices1->begin()->zError()<3) { reco::VertexCollection::const_iterator vertex1 = vertices1->begin(); newVertexCollection->push_back(*vertex1); LogInfo("HeavyIonVertexing") << "adaptive vertex:\n vz = (" << vertex1->x() << ", " << vertex1->y() << ", " << vertex1->z() << ")" << "\n error = (" << vertex1->xError() << ", " << vertex1->yError() << ", " << vertex1->zError() << ")" << endl; } else { //** Get fast median vertex **/ edm::Handle<reco::VertexCollection> vc2; ev.getByLabel(theMedianVertexCollection, vc2); const reco::VertexCollection * vertices2 = vc2.product(); //** Get beam spot position and error **/ reco::BeamSpot beamSpot; edm::Handle<reco::BeamSpot> beamSpotHandle; ev.getByLabel("offlineBeamSpot", beamSpotHandle); if( beamSpotHandle.isValid() ) beamSpot = *beamSpotHandle; else LogError("HeavyIonVertexing") << "no beamspot with name: 'offlineBeamSpot'" << endl; if(vertices2->size() > 0) { reco::VertexCollection::const_iterator vertex2 = vertices2->begin(); reco::Vertex::Error err; err(0,0)=pow(beamSpot.BeamWidthX(),2); err(1,1)=pow(beamSpot.BeamWidthY(),2); err(2,2)=pow(vertex2->zError(),2); reco::Vertex newVertex(reco::Vertex::Point(beamSpot.x0(),beamSpot.y0(),vertex2->z()), err, 0, 1, 1); newVertexCollection->push_back(newVertex); LogInfo("HeavyIonVertexing") << "median vertex + beamspot: \n position = (" << newVertex.x() << ", " << newVertex.y() << ", " << newVertex.z() << ")" << "\n error = (" << newVertex.xError() << ", " << newVertex.yError() << ", " << newVertex.zError() << ")" << endl; } else { reco::Vertex::Error err; err(0,0)=pow(beamSpot.BeamWidthX(),2); err(1,1)=pow(beamSpot.BeamWidthY(),2); err(2,2)=pow(beamSpot.sigmaZ(),2); reco::Vertex newVertex(beamSpot.position(), err, 0, 0, 1); newVertexCollection->push_back(newVertex); LogInfo("HeavyIonVertexing") << "beam spot: \n position = (" << newVertex.x() << ", " << newVertex.y() << ", " << newVertex.z() << ")" << "\n error = (" << newVertex.xError() << ", " << newVertex.yError() << ", " << newVertex.zError() << ")" << endl; } } // put new vertex collection into event ev.put(newVertexCollection); }
Definition at line 20 of file HIBestVertexProducer.h.
Definition at line 18 of file HIBestVertexProducer.h.
Definition at line 19 of file HIBestVertexProducer.h.