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

consumes migration for several packages #2037

Merged
merged 13 commits into from Jan 27, 2014
11 changes: 9 additions & 2 deletions DQM/SiStripCommon/test/plugins/Test_SiStrip_HistId.cc
Expand Up @@ -27,13 +27,20 @@ class Test_SiStrip_HistId : public edm::EDAnalyzer {

virtual void analyze(const edm::Event&, const edm::EventSetup&);
private:

#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
EDGetTokenT<ExampleData> example_;
#endif

// ----------member data ---------------------------
};

Test_SiStrip_HistId::Test_SiStrip_HistId(const edm::ParameterSet& iConfig)
{
//now do what ever initialization is needed

#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
example_ = consumes<ExampleData>(edm::InputTag("data"));
#endif
}


Expand All @@ -46,7 +53,7 @@ void Test_SiStrip_HistId::analyze(const edm::Event& iEvent, const edm::EventSetu
{
#ifdef THIS_IS_AN_EVENT_EXAMPLE
edm::Handle<ExampleData> pIn;
iEvent.getByLabel("example",pIn);
iEvent.getByToken(example_,pIn);
#endif

#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
Expand Down
8 changes: 5 additions & 3 deletions DQMOffline/Alignment/interface/MuonAlignment.h
Expand Up @@ -122,10 +122,12 @@ class MuonAlignment : public edm::EDAnalyzer {
RecHitVector doMatching(const reco::Track &, edm::Handle<DTRecSegment4DCollection> &, edm::Handle<CSCSegmentCollection> &, intDVector *, intDVector *, edm::ESHandle<GlobalTrackingGeometry> &);

// Muon Track Label
edm::InputTag theMuonCollectionLabel;
edm::EDGetTokenT<reco::TrackCollection> theMuonCollectionLabel;

edm::EDGetTokenT<DTRecSegment4DCollection> theRecHits4DTagDT;

edm::EDGetTokenT<CSCSegmentCollection> theRecHits4DTagCSC;

edm::InputTag theRecHits4DTagDT;
edm::InputTag theRecHits4DTagCSC;
std::string trackRefitterType;

// residual histos residual range
Expand Down
9 changes: 7 additions & 2 deletions DQMOffline/Alignment/interface/TkAlCaRecoMonitor.h
Expand Up @@ -22,6 +22,10 @@ Monitoring special quantities related to Tracker Alignment AlCaReco Production.
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "DQMServices/Core/interface/MonitorElement.h"

//DataFormats
#include <DataFormats/JetReco/interface/CaloJet.h>


class TrackerGeometry;
class DQMStore;

Expand Down Expand Up @@ -65,8 +69,9 @@ class TkAlCaRecoMonitor : public edm::EDAnalyzer {
bool runsOnReco_;
bool useSignedR_;

edm::InputTag trackProducer_;
edm::InputTag referenceTrackProducer_;
edm::EDGetTokenT<reco::TrackCollection> trackProducer_;
edm::EDGetTokenT<reco::TrackCollection> referenceTrackProducer_;
edm::EDGetTokenT<reco::CaloJetCollection> jetCollection_;
double daughterMass_;
std::map<int,int> binByRawId_;
};
Expand Down
12 changes: 6 additions & 6 deletions DQMOffline/Alignment/src/MuonAlignment.cc
Expand Up @@ -16,10 +16,10 @@ MuonAlignment::MuonAlignment(const edm::ParameterSet& pSet) {

parameters = pSet;

theMuonCollectionLabel = parameters.getParameter<edm::InputTag>("MuonCollection");
theMuonCollectionLabel = consumes<reco::TrackCollection>(parameters.getParameter<edm::InputTag>("MuonCollection"));

theRecHits4DTagDT = parameters.getParameter<edm::InputTag>("RecHits4DDTCollectionTag");
theRecHits4DTagCSC = parameters.getParameter<edm::InputTag>("RecHits4DCSCCollectionTag");
theRecHits4DTagDT = consumes<DTRecSegment4DCollection>(parameters.getParameter<edm::InputTag>("RecHits4DDTCollectionTag"));
theRecHits4DTagCSC = consumes<CSCSegmentCollection>(parameters.getParameter<edm::InputTag>("RecHits4DCSCCollectionTag"));

resLocalXRangeStation1 = parameters.getUntrackedParameter<double>("resLocalXRangeStation1");
resLocalXRangeStation2 = parameters.getUntrackedParameter<double>("resLocalXRangeStation2");
Expand Down Expand Up @@ -238,16 +238,16 @@ void MuonAlignment::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe

// Get the RecoMuons collection from the event
edm::Handle<reco::TrackCollection> muons;
iEvent.getByLabel(theMuonCollectionLabel, muons);
iEvent.getByToken(theMuonCollectionLabel, muons);

// Get the 4D DTSegments
edm::Handle<DTRecSegment4DCollection> all4DSegmentsDT;
iEvent.getByLabel(theRecHits4DTagDT, all4DSegmentsDT);
iEvent.getByToken(theRecHits4DTagDT, all4DSegmentsDT);
DTRecSegment4DCollection::const_iterator segmentDT;

// Get the 4D CSCSegments
edm::Handle<CSCSegmentCollection> all4DSegmentsCSC;
iEvent.getByLabel(theRecHits4DTagCSC, all4DSegmentsCSC);
iEvent.getByToken(theRecHits4DTagCSC, all4DSegmentsCSC);
CSCSegmentCollection::const_iterator segmentCSC;

//Vectors used to perform the matching between Segments and hits from Track
Expand Down
22 changes: 12 additions & 10 deletions DQMOffline/Alignment/src/TkAlCaRecoMonitor.cc
Expand Up @@ -18,16 +18,19 @@
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMOffline/Alignment/interface/TkAlCaRecoMonitor.h"

#include <DataFormats/JetReco/interface/CaloJet.h>
#include <DataFormats/Math/interface/deltaR.h>

#include <string>
//#include <sstream>
#include "TLorentzVector.h"

TkAlCaRecoMonitor::TkAlCaRecoMonitor(const edm::ParameterSet& iConfig) {
dqmStore_ = edm::Service<DQMStore>().operator->();
conf_ = iConfig;
trackProducer_ = consumes<reco::TrackCollection>(conf_.getParameter<edm::InputTag>("TrackProducer"));
referenceTrackProducer_ = consumes<reco::TrackCollection>(conf_.getParameter<edm::InputTag>("ReferenceTrackProducer"));
jetCollection_ = mayConsume<reco::CaloJetCollection>(conf_.getParameter<edm::InputTag>("CaloJetCollection"));

dqmStore_ = edm::Service<DQMStore>().operator->();
}

TkAlCaRecoMonitor::~TkAlCaRecoMonitor() { }
Expand All @@ -36,9 +39,6 @@ void TkAlCaRecoMonitor::beginJob() {

std::string histname; //for naming the histograms according to algorithm used

trackProducer_ = conf_.getParameter<edm::InputTag>("TrackProducer");
referenceTrackProducer_ = conf_.getParameter<edm::InputTag>("ReferenceTrackProducer");

std::string AlgoName = conf_.getParameter<std::string>("AlgoName");
std::string MEFolderName = conf_.getParameter<std::string>("FolderName");

Expand Down Expand Up @@ -142,7 +142,10 @@ void TkAlCaRecoMonitor::beginJob() {

histname = "AlCaRecoTrackEfficiency_";
AlCaRecoTrackEfficiency_ = dqmStore_->book1D(histname+AlgoName, histname+AlgoName, TrackEfficiencyBin, TrackEfficiencyMin, TrackEfficiencyMax);
AlCaRecoTrackEfficiency_->setAxisTitle("n("+trackProducer_.label()+") / n("+referenceTrackProducer_.label()+")");
Labels l_tp, l_rtp;
labelsForToken(referenceTrackProducer_, l_rtp);
labelsForToken(trackProducer_, l_tp);
AlCaRecoTrackEfficiency_->setAxisTitle("n("+std::string(l_tp.module)+") / n("+std::string(l_rtp.module)+")");

int zBin = conf_.getParameter<unsigned int>("HitMapsZBin"); //300
double zMax = conf_.getParameter<double>("HitMapZMax"); //300.0; //cm
Expand Down Expand Up @@ -184,14 +187,14 @@ void TkAlCaRecoMonitor::beginJob() {
void TkAlCaRecoMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {

edm::Handle<reco::TrackCollection> trackCollection;
iEvent.getByLabel(trackProducer_, trackCollection);
iEvent.getByToken(trackProducer_, trackCollection);
if (!trackCollection.isValid()){
edm::LogError("Alignment")<<"invalid trackcollection encountered!";
return;
}

edm::Handle<reco::TrackCollection> referenceTrackCollection;
iEvent.getByLabel(referenceTrackProducer_, referenceTrackCollection);
iEvent.getByToken(referenceTrackProducer_, referenceTrackCollection);
if (!trackCollection.isValid()){
edm::LogError("Alignment")<<"invalid reference track-collection encountered!";
return;
Expand All @@ -212,8 +215,7 @@ void TkAlCaRecoMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup&

edm::Handle<reco::CaloJetCollection> jets;
if(runsOnReco_){
edm::InputTag jetCollection = conf_.getParameter<edm::InputTag>("CaloJetCollection");
iEvent.getByLabel(jetCollection, jets);
iEvent.getByToken(jetCollection_, jets);
if(! jets.isValid()){
edm::LogError("Alignment")<<"no jet collection found in event!";
}
Expand Down
47 changes: 18 additions & 29 deletions DQMOffline/EGamma/plugins/ElectronAnalyzer.cc
Expand Up @@ -5,8 +5,6 @@
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/Common/interface/TriggerResults.h"
Expand All @@ -32,12 +30,12 @@ ElectronAnalyzer::ElectronAnalyzer( const edm::ParameterSet & conf )
{
// general, collections
Selection_ = conf.getParameter<int>("Selection");
electronCollection_ = conf.getParameter<edm::InputTag>("ElectronCollection");
matchingObjectCollection_ = conf.getParameter<edm::InputTag>("MatchingObjectCollection");
trackCollection_ = conf.getParameter<edm::InputTag>("TrackCollection");
vertexCollection_ = conf.getParameter<edm::InputTag>("VertexCollection");
gsftrackCollection_ = conf.getParameter<edm::InputTag>("GsfTrackCollection");
beamSpotTag_ = conf.getParameter<edm::InputTag>("BeamSpot");
electronCollection_ = consumes<GsfElectronCollection>(conf.getParameter<edm::InputTag>("ElectronCollection"));
matchingObjectCollection_ = consumes<SuperClusterCollection>(conf.getParameter<edm::InputTag>("MatchingObjectCollection"));
trackCollection_ = consumes<TrackCollection>(conf.getParameter<edm::InputTag>("TrackCollection"));
vertexCollection_ = consumes<VertexCollection>(conf.getParameter<edm::InputTag>("VertexCollection"));
gsftrackCollection_ = consumes<GsfTrackCollection>(conf.getParameter<edm::InputTag>("GsfTrackCollection"));
beamSpotTag_ = consumes<BeamSpot>(conf.getParameter<edm::InputTag>("BeamSpot"));
readAOD_ = conf.getParameter<bool>("ReadAOD");

// matching
Expand Down Expand Up @@ -282,10 +280,12 @@ void ElectronAnalyzer::book()

// matching object
std::string matchingObjectType ;
if (std::string::npos!=matchingObjectCollection_.label().find("SuperCluster",0))
{ matchingObjectType = "SC" ; }
Labels l;
labelsForToken(matchingObjectCollection_,l);
if (std::string::npos != std::string(l.module).find("SuperCluster",0))
{ matchingObjectType = "SC" ; }
if (matchingObjectType=="")
{ edm::LogError("ElectronMcFakeValidator::beginJob")<<"Unknown matching object type !" ; }
{ edm::LogError("ElectronMcFakeValidator::beginJob")<<"Unknown matching object type !" ; }
else
{ edm::LogInfo("ElectronMcFakeValidator::beginJob")<<"Matching object type: "<<matchingObjectType ; }
// std::string htitle = "# "+matchingObjectType+"s", xtitle = "N_{"+matchingObjectType+"}" ;
Expand Down Expand Up @@ -317,30 +317,19 @@ void ElectronAnalyzer::book()
void ElectronAnalyzer::analyze( const edm::Event& iEvent, const edm::EventSetup & iSetup )
{
nEvents_++ ;
// if (!trigger(iEvent)) return ;
// nAfterTrigger_++ ;

// edm::Handle<SuperClusterCollection> barrelSCs ;
// iEvent.getByLabel("correctedHybridSuperClusters",barrelSCs) ;
// edm::Handle<SuperClusterCollection> endcapsSCs ;
// iEvent.getByLabel("correctedMulti5x5SuperClustersWithPreshower",endcapsSCs) ;
// std::cout<<"[ElectronMcSignalValidator::analyze]"
// <<"Event "<<iEvent.id()
// <<" has "<<barrelSCs.product()->size()<<" barrel superclusters"
// <<" and "<<endcapsSCs.product()->size()<<" endcaps superclusters" ;
//

edm::Handle<GsfElectronCollection> gsfElectrons ;
iEvent.getByLabel(electronCollection_,gsfElectrons) ;
iEvent.getByToken(electronCollection_,gsfElectrons) ;
edm::Handle<reco::SuperClusterCollection> recoClusters ;
iEvent.getByLabel(matchingObjectCollection_,recoClusters) ;
iEvent.getByToken(matchingObjectCollection_,recoClusters) ;
edm::Handle<reco::TrackCollection> tracks;
iEvent.getByLabel(trackCollection_,tracks);
iEvent.getByToken(trackCollection_,tracks);
edm::Handle<reco::GsfTrackCollection> gsfTracks;
iEvent.getByLabel(gsftrackCollection_,gsfTracks);
iEvent.getByToken(gsftrackCollection_,gsfTracks);
edm::Handle<reco::VertexCollection> vertices;
iEvent.getByLabel(vertexCollection_,vertices);
iEvent.getByToken(vertexCollection_,vertices);
edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
iEvent.getByLabel(beamSpotTag_,recoBeamSpotHandle) ;
iEvent.getByToken(beamSpotTag_,recoBeamSpotHandle) ;
const BeamSpot bs = *recoBeamSpotHandle ;

int ievt = iEvent.id().event();
Expand Down
16 changes: 10 additions & 6 deletions DQMOffline/EGamma/plugins/ElectronAnalyzer.h
Expand Up @@ -10,6 +10,10 @@
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"

#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/VertexReco/interface/Vertex.h"


class MagneticField ;

#include "FWCore/Framework/interface/Event.h"
Expand All @@ -34,12 +38,12 @@ class ElectronAnalyzer : public ElectronDqmAnalyzerBase

// general, collections
int Selection_;
edm::InputTag electronCollection_;
edm::InputTag matchingObjectCollection_;
edm::InputTag gsftrackCollection_;
edm::InputTag trackCollection_;
edm::InputTag vertexCollection_;
edm::InputTag beamSpotTag_;
edm::EDGetTokenT<reco::GsfElectronCollection> electronCollection_;
edm::EDGetTokenT<reco::SuperClusterCollection> matchingObjectCollection_;
edm::EDGetTokenT<reco::GsfTrackCollection> gsftrackCollection_;
edm::EDGetTokenT<reco::TrackCollection> trackCollection_;
edm::EDGetTokenT<reco::VertexCollection> vertexCollection_;
edm::EDGetTokenT<reco::BeamSpot> beamSpotTag_;
bool readAOD_; //NEW

// matching
Expand Down
30 changes: 14 additions & 16 deletions DQMOffline/EGamma/plugins/ElectronGeneralAnalyzer.cc
Expand Up @@ -6,8 +6,6 @@
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/Common/interface/TriggerResults.h"
Expand All @@ -30,13 +28,13 @@ ElectronGeneralAnalyzer::ElectronGeneralAnalyzer( const edm::ParameterSet & conf
: ElectronDqmAnalyzerBase(conf)
{
// collection input tags
electronCollection_ = conf.getParameter<edm::InputTag>("ElectronCollection");
matchingObjectCollection_ = conf.getParameter<edm::InputTag>("MatchingObjectCollection");
trackCollection_ = conf.getParameter<edm::InputTag>("TrackCollection");
vertexCollection_ = conf.getParameter<edm::InputTag>("VertexCollection");
gsftrackCollection_ = conf.getParameter<edm::InputTag>("GsfTrackCollection");
beamSpotTag_ = conf.getParameter<edm::InputTag>("BeamSpot");
triggerResults_ = conf.getParameter<edm::InputTag>("TriggerResults");
electronCollection_ = consumes<GsfElectronCollection>(conf.getParameter<edm::InputTag>("ElectronCollection"));
matchingObjectCollection_ = consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("MatchingObjectCollection"));
trackCollection_ = consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("TrackCollection"));
vertexCollection_ = consumes<reco::VertexCollection>(conf.getParameter<edm::InputTag>("VertexCollection"));
gsftrackCollection_ = consumes<reco::GsfTrackCollection>(conf.getParameter<edm::InputTag>("GsfTrackCollection"));
beamSpotTag_ = consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("BeamSpot"));
triggerResults_ = consumes<edm::TriggerResults>(conf.getParameter<edm::InputTag>("TriggerResults"));

// // for trigger
// HLTPathsByName_= conf.getParameter<std::vector<std::string > >("HltPaths");
Expand All @@ -60,17 +58,17 @@ void ElectronGeneralAnalyzer::book()
void ElectronGeneralAnalyzer::analyze( const edm::Event& iEvent, const edm::EventSetup & iSetup )
{
edm::Handle<GsfElectronCollection> gsfElectrons ;
iEvent.getByLabel(electronCollection_,gsfElectrons) ;
iEvent.getByToken(electronCollection_,gsfElectrons) ;
edm::Handle<reco::SuperClusterCollection> recoClusters ;
iEvent.getByLabel(matchingObjectCollection_,recoClusters) ;
iEvent.getByToken(matchingObjectCollection_,recoClusters) ;
edm::Handle<reco::TrackCollection> tracks;
iEvent.getByLabel(trackCollection_,tracks);
iEvent.getByToken(trackCollection_,tracks);
edm::Handle<reco::GsfTrackCollection> gsfTracks;
iEvent.getByLabel(gsftrackCollection_,gsfTracks);
iEvent.getByToken(gsftrackCollection_,gsfTracks);
edm::Handle<reco::VertexCollection> vertices;
iEvent.getByLabel(vertexCollection_,vertices);
iEvent.getByToken(vertexCollection_,vertices);
edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
iEvent.getByLabel(beamSpotTag_,recoBeamSpotHandle) ;
iEvent.getByToken(beamSpotTag_,recoBeamSpotHandle) ;
const BeamSpot bs = *recoBeamSpotHandle ;

int ievt = iEvent.id().event();
Expand All @@ -90,7 +88,7 @@ void ElectronGeneralAnalyzer::analyze( const edm::Event& iEvent, const edm::Even

// trigger
edm::Handle<edm::TriggerResults> triggerResults ;
iEvent.getByLabel(triggerResults_,triggerResults) ;
iEvent.getByToken(triggerResults_,triggerResults) ;
if (triggerResults.isValid())
{
unsigned int i, n = triggerResults->size() ;
Expand Down
18 changes: 11 additions & 7 deletions DQMOffline/EGamma/plugins/ElectronGeneralAnalyzer.h
Expand Up @@ -16,6 +16,10 @@ class MagneticField ;
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/VertexReco/interface/Vertex.h"


class ElectronGeneralAnalyzer : public ElectronDqmAnalyzerBase
{
public:
Expand All @@ -33,15 +37,15 @@ class ElectronGeneralAnalyzer : public ElectronDqmAnalyzerBase
//=========================================

// collection input tags
edm::InputTag electronCollection_;
edm::InputTag matchingObjectCollection_;
edm::InputTag gsftrackCollection_;
edm::InputTag trackCollection_;
edm::InputTag vertexCollection_;
edm::InputTag beamSpotTag_;
edm::EDGetTokenT<reco::GsfElectronCollection> electronCollection_;
edm::EDGetTokenT<reco::SuperClusterCollection> matchingObjectCollection_;
edm::EDGetTokenT<reco::GsfTrackCollection> gsftrackCollection_;
edm::EDGetTokenT<reco::TrackCollection> trackCollection_;
edm::EDGetTokenT<reco::VertexCollection> vertexCollection_;
edm::EDGetTokenT<reco::BeamSpot> beamSpotTag_;

// for trigger
edm::InputTag triggerResults_;
edm::EDGetTokenT<edm::TriggerResults> triggerResults_;
//std::vector<std::string > HLTPathsByName_;
//
// //=========================================
Expand Down