5 #include "FWCore/Framework/interface/Event.h"
6 #include "FWCore/Framework/interface/EventSetup.h"
7 #include "FWCore/Framework/interface/MakerMacros.h"
8 #include "FWCore/ParameterSet/interface/ParameterSet.h"
9 #include "FWCore/Utilities/interface/InputTag.h"
10 #include "DataFormats/Common/interface/Handle.h"
11 #include "DataFormats/Common/interface/View.h"
12 #include "DataFormats/VertexReco/interface/Vertex.h"
13 #include "DataFormats/VertexReco/interface/VertexFwd.h"
14 #include "DataFormats/TrackReco/interface/Track.h"
15 #include "DataFormats/TrackReco/interface/TrackFwd.h"
23 : input_(config.getParameter<
edm::InputTag>(
"input")),
24 branch_(config.getParameter<
std::string>(
"branch")),
25 first_only_(config.getParameter<bool>(
"firstVertexOnly")),
26 track_pt_threshold_(config.getParameter<double>(
"trackPtThreshold")),
27 request_trks_(config.getParameter<bool>(
"requestTracks")) {
28 consumes<edm::View<reco::Vertex>>(input_);
29 vertices_ =
new std::vector<ic::Vertex>();
31 produces<reco::TrackRefVector>(
"requestedTracks");
40 void ICVertexProducer::produce(edm::Event& event,
41 const edm::EventSetup& setup) {
42 edm::Handle<edm::View<reco::Vertex> > vtxs_handle;
43 event.getByLabel(input_, vtxs_handle);
45 std::auto_ptr<reco::TrackRefVector> trk_requests(
new reco::TrackRefVector());
49 vertices_->resize(vtxs_handle->size());
51 vertices_->resize(vtxs_handle->size() > 0 ? 1 : 0);
54 for (
unsigned i = 0; i < vtxs_handle->size(); ++i) {
55 reco::Vertex
const& src = vtxs_handle->at(i);
57 dest.
set_id(vertex_hasher_(&src));
64 for (reco::Vertex::trackRef_iterator trk_iter = src.tracks_begin();
65 trk_iter != src.tracks_end(); ++trk_iter) {
66 float weight = src.trackWeight(*trk_iter);
67 reco::TrackRef trk_ref = trk_iter->castTo<reco::TrackRef>();
68 if (trk_ref->pt() < track_pt_threshold_)
continue;
69 dest.
AddTrack(track_hasher_(&(*trk_ref)), weight);
70 trk_requests->push_back(trk_ref);
73 if (first_only_)
break;
75 if (request_trks_)
event.put(trk_requests,
"requestedTracks");
78 void ICVertexProducer::beginJob() {
82 void ICVertexProducer::endJob() {}
void set_vz(float const &z)
Vertex z-coordinate.
void set_vx(float const &x)
Vertex x-coordinate.
ICVertexProducer(const edm::ParameterSet &)
void set_ndof(float const &ndof)
The number-of-degrees-of-freedom in the vertex fit.
void set_id(std::size_t const &id)
Unique identifier.
void set_chi2(float const &chi2)
The of the vertex fit.
void AddTrack(std::size_t id, float weight)
Add an ic::Track::id with a vertex fit weight.
void set_vy(float const &y)
Vertex y-coordinate.
DEFINE_FWK_MODULE(ICVertexProducer)
Stores information about the position of an event vertex and the quality of the track fit...