Skip to content

Commit

Permalink
Merge pull request #10661 from wddgit/enableConsumesException
Browse files Browse the repository at this point in the history
Make missing consumes calls an exception
  • Loading branch information
davidlange6 committed Aug 13, 2015
2 parents 936e2be + f5fe00b commit 30ebfb9
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
5 changes: 3 additions & 2 deletions CalibMuon/DTCalibration/interface/DTCalibMuonSelection.h
Expand Up @@ -6,8 +6,9 @@
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/EDGetToken.h"

#include "DataFormats/MuonReco/interface/MuonFwd.h"

#include <vector>
#include <string>
Expand All @@ -26,7 +27,7 @@ class DTCalibMuonSelection : public edm::EDFilter {

virtual void endJob() ;

edm::InputTag muonList;
edm::EDGetTokenT<reco::MuonCollection> muonList;

double etaMin;
double etaMax;
Expand Down
6 changes: 3 additions & 3 deletions CalibMuon/DTCalibration/src/DTCalibMuonSelection.cc
Expand Up @@ -9,9 +9,9 @@

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

#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"

#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
Expand All @@ -21,7 +21,7 @@ using namespace reco;

DTCalibMuonSelection::DTCalibMuonSelection(const edm::ParameterSet& iConfig)
{
muonList = iConfig.getParameter<edm::InputTag>("src");
muonList = consumes<MuonCollection>(iConfig.getParameter<edm::InputTag>("src"));
etaMin = iConfig.getParameter<double>("etaMin");
etaMax = iConfig.getParameter<double>("etaMax");
ptMin = iConfig.getParameter<double>("ptMin");
Expand All @@ -37,7 +37,7 @@ bool DTCalibMuonSelection::filter(edm::Event& iEvent, const edm::EventSetup& iSe

//Retrieve the muons list
Handle<MuonCollection> MuHandle;
iEvent.getByLabel(muonList,MuHandle);
iEvent.getByToken(muonList,MuHandle);

for (MuonCollection::const_iterator nmuon = MuHandle->begin(); nmuon != MuHandle->end(); ++nmuon) {

Expand Down
17 changes: 11 additions & 6 deletions FWCore/Framework/src/Principal.cc
Expand Up @@ -110,19 +110,24 @@ namespace edm {

namespace {
void failedToRegisterConsumesMany(edm::TypeID const& iType) {
LogError("GetManyWithoutRegistration")<<"::getManyByType called for "<<iType<<" without a corresponding consumesMany being called for this module. \n";
cms::Exception exception("GetManyWithoutRegistration");
exception << "::getManyByType called for " << iType
<< " without a corresponding consumesMany being called for this module. \n";
throw exception;
}

void failedToRegisterConsumes(KindOfType kindOfType,
TypeID const& productType,
std::string const& moduleLabel,
std::string const& productInstanceName,
std::string const& processName) {
LogError("GetByLabelWithoutRegistration")<<"::getByLabel without corresponding call to consumes or mayConsumes for this module.\n"
<< (kindOfType == PRODUCT_TYPE ? " type: " : " type: edm::View<")<<productType
<< (kindOfType == PRODUCT_TYPE ? "\n module label: " : ">\n module label: ")<<moduleLabel
<<"\n product instance name: '"<<productInstanceName
<<"'\n process name: '"<<processName<<"'\n";
cms::Exception exception("GetByLabelWithoutRegistration");
exception << "::getByLabel without corresponding call to consumes or mayConsumes for this module.\n"
<< (kindOfType == PRODUCT_TYPE ? " type: " : " type: edm::View<") << productType
<< (kindOfType == PRODUCT_TYPE ? "\n module label: " : ">\n module label: ") << moduleLabel
<<"\n product instance name: '" << productInstanceName
<<"'\n process name: '" << processName << "'\n";
throw exception;
}
}

Expand Down
4 changes: 2 additions & 2 deletions FWCore/Framework/test/stubs/RunLumiEventAnalyzer.cc
Expand Up @@ -40,7 +40,7 @@ namespace edmtest {
} else {
expectedRunLumisEvents1_ = pset.getUntrackedParameter<std::vector<unsigned long long> >("expectedRunLumiEvents1", std::vector<unsigned long long>());
}

triggerResultsToken_ = consumes<edm::TriggerResults>(edm::InputTag("TriggerResults"));
}

void RunLumiEventAnalyzer::analyze(edm::Event const& event, edm::EventSetup const&) {
Expand All @@ -54,7 +54,7 @@ namespace edmtest {

if(dumpTriggerResults_) {
edm::Handle<edm::TriggerResults> triggerResults;
event.getByLabel("TriggerResults", triggerResults);
event.getByToken(triggerResultsToken_, triggerResults);
if(triggerResults.isValid()) {
edm::LogAbsolute("RunLumiEvent") << "TestFailuresAnalyzer dumping TriggerResults";
edm::LogAbsolute("RunLumiEvent") << *triggerResults;
Expand Down
6 changes: 6 additions & 0 deletions FWCore/Framework/test/stubs/RunLumiEventAnalyzer.h
Expand Up @@ -3,9 +3,14 @@

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Utilities/interface/EDGetToken.h"

#include <vector>

namespace edm {
class TriggerResults;
}

namespace edmtest {

class RunLumiEventAnalyzer : public edm::EDAnalyzer {
Expand Down Expand Up @@ -34,6 +39,7 @@ namespace edmtest {
int expectedEndingIndex0_;
int expectedEndingIndex1_;
int expectedEndingIndex_;
edm::EDGetTokenT<edm::TriggerResults> triggerResultsToken_;
};
}

Expand Down
2 changes: 1 addition & 1 deletion FWCore/Integration/test/ViewAnalyzer.cc
Expand Up @@ -77,7 +77,7 @@ namespace edmtest
consumes<OVSimpleProduct>(edm::InputTag{"ovsimple"});
consumes<edm::View<OVSimpleProduct::value_type>>(edm::InputTag{"ovsimple"});
consumes<AVSimpleProduct>(edm::InputTag{"avsimple"});
consumes<edm::View<AVSimpleProduct>::value_type>(edm::InputTag{"avsimple"});
consumes<edm::View<AVSimpleProduct::value_type>>(edm::InputTag{"avsimple"});
consumes<edmtest::DSVSimpleProduct>(edm::InputTag{"dsvsimple"});
consumes<edm::View<edmtest::DSVSimpleProduct::value_type>>(edm::InputTag{"dsvsimple"});

Expand Down
3 changes: 3 additions & 0 deletions Validation/HcalDigis/interface/HcalDigisValidation.h
Expand Up @@ -14,6 +14,7 @@
#include "DQMServices/Core/interface/MonitorElement.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/EDGetToken.h"

#include "Geometry/CaloGeometry/interface/CaloGeometry.h"

Expand Down Expand Up @@ -112,6 +113,8 @@ class HcalDigisValidation : public DQMEDAnalyzer {
edm::EDGetTokenT<edm::SortedCollection<HBHEDataFrame> > tok_hbhe_;
edm::EDGetTokenT<edm::SortedCollection<HODataFrame> > tok_ho_;
edm::EDGetTokenT<edm::SortedCollection<HFDataFrame> > tok_hf_;
edm::EDGetTokenT<HcalTrigPrimDigiCollection> tok_emulTPs_;
edm::EDGetTokenT<HcalTrigPrimDigiCollection> tok_dataTPs_;

edm::ESHandle<CaloGeometry> geometry;
edm::ESHandle<HcalDbService> conditions;
Expand Down
8 changes: 5 additions & 3 deletions Validation/HcalDigis/src/HcalDigisValidation.cc
Expand Up @@ -35,6 +35,8 @@ HcalDigisValidation::HcalDigisValidation(const edm::ParameterSet& iConfig) {
tok_hbhe_ = consumes<edm::SortedCollection<HBHEDataFrame> >(inputTag_);
tok_ho_ = consumes<edm::SortedCollection<HODataFrame> >(inputTag_);
tok_hf_ = consumes<edm::SortedCollection<HFDataFrame> >(inputTag_);
tok_emulTPs_ = consumes<HcalTrigPrimDigiCollection>(edm::InputTag("emulDigis"));
tok_dataTPs_ = consumes<HcalTrigPrimDigiCollection>(edm::InputTag("simHcalTriggerPrimitiveDigis"));

nevent1 = 0;
nevent2 = 0;
Expand Down Expand Up @@ -467,12 +469,12 @@ void HcalDigisValidation::analyze(const edm::Event& iEvent, const edm::EventSetu

//Get all handles
edm::Handle<HcalTrigPrimDigiCollection> emulTPs;
iEvent.getByLabel("emulDigis", emulTPs);
iEvent.getByToken(tok_emulTPs_, emulTPs);

edm::Handle<HcalTrigPrimDigiCollection> dataTPs;
iEvent.getByLabel("simHcalTriggerPrimitiveDigis", dataTPs);
iEvent.getByToken(tok_dataTPs_, dataTPs);
//iEvent.getByLabel("hcalDigis", dataTPs);

//~TP Code

// std::cout << " >>>>> HcalDigiTester::analyze hcalselector = "
Expand Down

0 comments on commit 30ebfb9

Please sign in to comment.