Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapted Primary vertex producer to use new consumes API #40

Merged
merged 1 commit into from Jul 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -29,7 +29,6 @@
#include "FWCore/Framework/interface/EventSetup.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"

//#include "RecoVertex/PrimaryVertexProducer/interface/PrimaryVertexProducerAlgorithm.h"
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
Expand Down Expand Up @@ -62,8 +61,6 @@ class PrimaryVertexProducer : public edm::EDProducer {

// access to config
edm::ParameterSet config() const { return theConfig; }
edm::InputTag trackLabel;
edm::InputTag beamSpotLabel;

private:
// ----------member data ---------------------------
Expand All @@ -83,4 +80,6 @@ class PrimaryVertexProducer : public edm::EDProducer {

edm::ParameterSet theConfig;
bool fVerbose;
edm::EDGetTokenT<reco::BeamSpot> bsToken;
edm::EDGetTokenT<reco::TrackCollection> trkToken;
};
Expand Up @@ -5,6 +5,7 @@
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
Expand All @@ -21,9 +22,8 @@ PrimaryVertexProducer::PrimaryVertexProducer(const edm::ParameterSet& conf)
{

fVerbose = conf.getUntrackedParameter<bool>("verbose", false);
trackLabel = conf.getParameter<edm::InputTag>("TrackLabel");
beamSpotLabel = conf.getParameter<edm::InputTag>("beamSpotLabel");

trkToken = consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("TrackLabel"));
bsToken = consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("beamSpotLabel"));

// select and configure the track selection
std::string trackSelectionAlgorithm=conf.getParameter<edm::ParameterSet>("TkFilterParameters").getParameter<std::string>("algorithm");
Expand Down Expand Up @@ -122,7 +122,7 @@ PrimaryVertexProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup
// get the BeamSpot, it will alwys be needed, even when not used as a constraint
reco::BeamSpot beamSpot;
edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
iEvent.getByLabel(beamSpotLabel,recoBeamSpotHandle);
iEvent.getByToken(bsToken,recoBeamSpotHandle);
if (recoBeamSpotHandle.isValid()){
beamSpot = *recoBeamSpotHandle;
}else{
Expand All @@ -142,7 +142,7 @@ PrimaryVertexProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup
// get RECO tracks from the event
// `tks` can be used as a ptr to a reco::TrackCollection
edm::Handle<reco::TrackCollection> tks;
iEvent.getByLabel(trackLabel, tks);
iEvent.getByToken(trkToken, tks);


// interface RECO tracks to vertex reconstruction
Expand Down