diff --git a/CondCore/ESSources/test/SiStripTest/noiseanalyzer.cc b/CondCore/ESSources/test/SiStripTest/noiseanalyzer.cc index 236a0ed9379ff..1f757a5b0ecf8 100644 --- a/CondCore/ESSources/test/SiStripTest/noiseanalyzer.cc +++ b/CondCore/ESSources/test/SiStripTest/noiseanalyzer.cc @@ -2,50 +2,49 @@ #include #include #include -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "CondFormats/Calibration/interface/mySiStripNoises.h" #include "CondFormats/DataRecord/interface/mySiStripNoisesRcd.h" +#include "FWCore/Framework/interface/global/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" + using namespace std; namespace edmtest { - class NoisesAnalyzer : public edm::EDAnalyzer { + class NoisesAnalyzer : public edm::global::EDAnalyzer<> { public: - explicit NoisesAnalyzer(edm::ParameterSet const& p) { std::cout << "NoisesAnalyzer" << std::endl; } - explicit NoisesAnalyzer(int i) { std::cout << "NoisesAnalyzer " << i << std::endl; } - virtual ~NoisesAnalyzer() { std::cout << "~NoisesAnalyzer " << std::endl; } - virtual void analyze(const edm::Event& e, const edm::EventSetup& c); + explicit NoisesAnalyzer(edm::ParameterSet const& p) : theNoisesToken_(esConsumes()) { + edm::LogPrint("NoisesAnalyzer") << "NoisesAnalyzer"; + } + explicit NoisesAnalyzer(int i) { edm::LogPrint("NoisesAnalyzer") << "NoisesAnalyzer " << i; } + virtual ~NoisesAnalyzer() { edm::LogPrint("NoisesAnalyzer") << "~NoisesAnalyzer "; } + void analyze(edm::StreamID, const edm::Event& e, const edm::EventSetup& c) const override; private: + const edm::ESGetToken theNoisesToken_; }; - void NoisesAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) { + void NoisesAnalyzer::analyze(edm::StreamID, const edm::Event& e, const edm::EventSetup& context) const { using namespace edm::eventsetup; // Context is not used. - std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl; - std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl; + edm::LogPrint("NoisesAnalyzer") << " I AM IN RUN NUMBER " << e.id().run(); + edm::LogPrint("NoisesAnalyzer") << " ---EVENT NUMBER " << e.id().event(); edm::eventsetup::EventSetupRecordKey recordKey( edm::eventsetup::EventSetupRecordKey::TypeTag::findType("mySiStripNoisesRcd")); if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) { //record not found - std::cout << "Record \"mySiStripNoisesRcd" - << "\" does not exist " << std::endl; + edm::LogPrint("NoisesAnalyzer") << "Record \"mySiStripNoisesRcd\" does not exist"; } - edm::ESHandle pNoises; - std::cout << "got eshandle" << std::endl; - context.get().get(pNoises); - std::cout << "got context" << std::endl; - const mySiStripNoises* mynoise = pNoises.product(); - std::cout << "Noises* " << mynoise << std::endl; + edm::LogPrint("NoisesAnalyzer") << "got context"; + auto const& mynoise = &context.getData(theNoisesToken_); + edm::LogPrint("NoisesAnalyzer") << "Noises* " << mynoise; unsigned int a = mynoise->v_noises.size(); - std::cout << "size a " << a << std::endl; + edm::LogPrint("NoisesAnalyzer") << "size a " << a; unsigned int b = mynoise->indexes.size(); - std::cout << "size b " << b << std::endl; + edm::LogPrint("NoisesAnalyzer") << "size b " << b; /*for(std::vector::const_iterator it=mynoise->indexes.begin(); it!=mynoise->indexes.end(); ++it){ std::cout << " detid " <detid<< std::endl; }*/ diff --git a/CondCore/ESSources/test/TestConcurrentIOVsCondCore.sh b/CondCore/ESSources/test/TestConcurrentIOVsCondCore.sh index 0189cad84136b..93bdf58bdcf79 100755 --- a/CondCore/ESSources/test/TestConcurrentIOVsCondCore.sh +++ b/CondCore/ESSources/test/TestConcurrentIOVsCondCore.sh @@ -5,8 +5,8 @@ function die { echo $1: status $2 ; exit $2; } pushd ${LOCAL_TMP_DIR} echo cmsRun TestConcurrentIOVsCondCore_cfg.py -cmsRun --parameter-set ${LOCAL_TEST_DIR}/TestConcurrentIOVsCondCore_cfg.py > TestConcurrentIOVsCondCoreCout.log || die 'Failed in TestConcurrentIOVsCondCore_cfg.py' $? -grep TestConcurrentIOVsCondCore TestConcurrentIOVsCondCoreCout.log > TestConcurrentIOVsCondCore.log +cmsRun --parameter-set ${LOCAL_TEST_DIR}/TestConcurrentIOVsCondCore_cfg.py || die 'Failed in TestConcurrentIOVsCondCore_cfg.py' $? +grep "TestConcurrentIOVsCondCore: " TestConcurrentIOVsCondCoreCout.log > TestConcurrentIOVsCondCore.log diff ${LOCAL_TEST_DIR}/unit_test_outputs/TestConcurrentIOVsCondCore.log TestConcurrentIOVsCondCore.log || die "comparing TestConcurrentIOVsCondCore.log" $? popd diff --git a/CondCore/ESSources/test/TestConcurrentIOVsCondCore_cfg.py b/CondCore/ESSources/test/TestConcurrentIOVsCondCore_cfg.py index cc42123051106..bc403080ca168 100644 --- a/CondCore/ESSources/test/TestConcurrentIOVsCondCore_cfg.py +++ b/CondCore/ESSources/test/TestConcurrentIOVsCondCore_cfg.py @@ -38,8 +38,12 @@ ) process.load("FWCore.MessageService.MessageLogger_cfi") -#process.MessageLogger.cerr.threshold = 'INFO' -#process.MessageLogger.cerr.INFO.limit = 1000000 +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('TestConcurrentIOVsCondCoreCout','cout'), + TestConcurrentIOVsCondCoreCout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) process.source = cms.Source("EmptySource", firstRun = cms.untracked.uint32(132598), diff --git a/CondCore/ESSources/test/stubs/EfficiencyByLabelAnalyzer.cc b/CondCore/ESSources/test/stubs/EfficiencyByLabelAnalyzer.cc index 03d619274c3b8..384eb7bbc9993 100644 --- a/CondCore/ESSources/test/stubs/EfficiencyByLabelAnalyzer.cc +++ b/CondCore/ESSources/test/stubs/EfficiencyByLabelAnalyzer.cc @@ -9,61 +9,61 @@ Toy EDProducers and EDProducts for testing purposes only. #include #include #include -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/Framework/interface/EventSetup.h" #include "CondFormats/Calibration/interface/Efficiency.h" #include "CondFormats/DataRecord/interface/ExEfficiency.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" + using namespace std; namespace edmtest { - class EfficiencyByLabelAnalyzer : public edm::EDAnalyzer { + class EfficiencyByLabelAnalyzer : public edm::one::EDAnalyzer<> { public: - explicit EfficiencyByLabelAnalyzer(edm::ParameterSet const& p) { - std::cout << "EfficiencyByLabelAnalyzer" << std::endl; + explicit EfficiencyByLabelAnalyzer(edm::ParameterSet const& p) + : theEffToken1_(esConsumes()), theEffToken2_(esConsumes()) { + edm::LogPrint("EfficiencyByLabelAnalyzer") << "EfficiencyByLabelAnalyzer"; + } + explicit EfficiencyByLabelAnalyzer(int i) { + edm::LogPrint("EfficiencyByLabelAnalyzer") << "EfficiencyByLabelAnalyzer " << i; + } + virtual ~EfficiencyByLabelAnalyzer() { + edm::LogPrint("EfficiencyByLabelAnalyzer") << "~EfficiencyByLabelAnalyzer "; } - explicit EfficiencyByLabelAnalyzer(int i) { std::cout << "EfficiencyByLabelAnalyzer " << i << std::endl; } - virtual ~EfficiencyByLabelAnalyzer() { std::cout << "~EfficiencyByLabelAnalyzer " << std::endl; } virtual void analyze(const edm::Event& e, const edm::EventSetup& c); private: + const edm::ESGetToken theEffToken1_, theEffToken2_; }; void EfficiencyByLabelAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) { using namespace edm::eventsetup; // Context is not used. - std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl; - std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl; + edm::LogPrint("EfficiencyByLabelAnalyzer") << " I AM IN RUN NUMBER " << e.id().run(); + edm::LogPrint("EfficiencyByLabelAnalyzer") << " ---EVENT NUMBER " << e.id().event(); edm::eventsetup::EventSetupRecordKey recordKey( edm::eventsetup::EventSetupRecordKey::TypeTag::findType("ExEfficiencyRcd")); if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) { //record not found - std::cout << "Record \"ExEfficiencyRcd" - << "\" does not exist " << std::endl; + edm::LogPrint("EfficiencyByLabelAnalyzer") << "Record \"ExEfficiencyRcd\" does not exist"; } - edm::ESHandle hEff1; - edm::ESHandle hEff2; - std::cout << "got eshandle" << std::endl; - context.get().get("vinEff1", hEff1); - context.get().get("vinEff2", hEff2); - std::cout << "got context" << std::endl; + edm::LogPrint("EfficiencyByLabelAnalyzer") << "got context"; { - condex::Efficiency const& eff = *hEff2.product(); - std::cout << "Efficiency*, type (2) " << (void*)(&eff) << " " << typeid(eff).name() << std::endl; + condex::Efficiency const& eff = context.getData(theEffToken2_); + edm::LogPrint("EfficiencyByLabelAnalyzer") + << "Efficiency*, type (2) " << (void*)(&eff) << " " << typeid(eff).name(); } - condex::Efficiency const& eff = *hEff1.product(); - std::cout << "Efficiency*, type " << (void*)(&eff) << " " << typeid(eff).name() << std::endl; + condex::Efficiency const& eff = context.getData(theEffToken1_); + edm::LogPrint("EfficiencyByLabelAnalyzer") << "Efficiency*, type " << (void*)(&eff) << " " << typeid(eff).name(); for (float pt = 0; pt < 10; pt += 2) { - std::cout << "\npt=" << pt << " :"; + edm::LogPrint("EfficiencyByLabelAnalyzer") << "\npt=" << pt << " :"; for (float eta = -3; eta < 3; eta += 1) - std::cout << eff(pt, eta) << " "; + edm::LogPrint("EfficiencyByLabelAnalyzer") << eff(pt, eta) << " "; } - std::cout << std::endl; + edm::LogPrint("EfficiencyByLabelAnalyzer"); } DEFINE_FWK_MODULE(EfficiencyByLabelAnalyzer); diff --git a/CondCore/ESSources/test/stubs/KeyListAnalyzer.cc b/CondCore/ESSources/test/stubs/KeyListAnalyzer.cc index a99a000315b92..2636d7440a04a 100644 --- a/CondCore/ESSources/test/stubs/KeyListAnalyzer.cc +++ b/CondCore/ESSources/test/stubs/KeyListAnalyzer.cc @@ -3,77 +3,66 @@ #include #include #include -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/Framework/interface/EventSetup.h" -#include "CondFormats/DataRecord/interface/ExEfficiency.h" #include "CondCore/IOVService/interface/KeyList.h" + #include "CondFormats/Calibration/interface/Conf.h" +#include "CondFormats/DataRecord/interface/ExEfficiency.h" + +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" using namespace std; namespace { - template - void print(Conf const & c) { - std::cout << c.v << " " << c.key << " ; "; + template + void print(Conf const& c) { + edm::LogPrint("KeyListAnalyzer") << c.v << " " << c.key << " ; "; } -} - +} // namespace -namespace edmtest -{ - class KeyListAnalyzer : public edm::EDAnalyzer - { +namespace edmtest { + class KeyListAnalyzer : public edm::one::EDAnalyzer<> { public: - explicit KeyListAnalyzer(edm::ParameterSet const& p) - { - std::cout<<"KeyListAnalyzer"< theKeyListToken_; }; - - void - KeyListAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context){ + + void KeyListAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) { using namespace edm::eventsetup; // Context is not used. - std::cout <<" I AM IN RUN NUMBER "< klh; - std::cout<<"got eshandle"<().get(klh); - std::cout<<"got context"<(i)); - else - print(*kl.get(i)); + edm::LogPrint("KeyListAnalyzer") << "got context"; + cond::KeyList const& kl = context.getData(theKeyListToken_); + int n = 0; + for (int i = 0; i < kl.size(); i++) + if (kl.elem(i)) { + n++; + if (0 == i % 2) + print(*kl.get(i)); + else + print(*kl.get(i)); } - std::cout << "found " << n << " valid keyed confs" << std::endl; - - std::cout << std::endl; + edm::LogPrint("KeyListAnalyzer") << "found " << n << " valid keyed confs" << std::endl; } DEFINE_FWK_MODULE(KeyListAnalyzer); -} +} // namespace edmtest diff --git a/CondCore/ESSources/test/stubs/LumiTestReadAnalyzer.cc b/CondCore/ESSources/test/stubs/LumiTestReadAnalyzer.cc index 98253597e40c0..fcd8022a775c1 100644 --- a/CondCore/ESSources/test/stubs/LumiTestReadAnalyzer.cc +++ b/CondCore/ESSources/test/stubs/LumiTestReadAnalyzer.cc @@ -8,46 +8,43 @@ Toy EDProducers and EDProducts for testing purposes only. #include #include #include -//#include -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" +#include + +#include "CondCore/CondDB/interface/Time.h" + +#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h" +#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h" -#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h" -//#include "CondFormats/DataRecord/interface/LumiTestPayloadRcd.h" -//#include "CondFormats/Common/interface/LumiTestPayload.h" -#include "CondCore/CondDB/interface/Time.h" -#include using namespace std; namespace edmtest { - class LumiTestReadAnalyzer : public edm::EDAnalyzer { + class LumiTestReadAnalyzer : public edm::one::EDAnalyzer<> { public: explicit LumiTestReadAnalyzer(edm::ParameterSet const& p) - : m_processId(p.getUntrackedParameter("processId")), + : theBSToken_(esConsumes()), + m_processId(p.getUntrackedParameter("processId")), m_pathForLastLumiFile(p.getUntrackedParameter("lastLumiFile", "")), m_pathForErrorFile("") { std::string pathForErrorFolder = p.getUntrackedParameter("pathForErrorFile"); m_pathForErrorFile = pathForErrorFolder + "/lumi_read_" + m_processId + ".txt"; } explicit LumiTestReadAnalyzer(int i) {} - virtual ~LumiTestReadAnalyzer() {} - virtual void beginJob(); - virtual void beginRun(const edm::Run&, const edm::EventSetup& context); + virtual ~LumiTestReadAnalyzer() = default; virtual void analyze(const edm::Event& e, const edm::EventSetup& c); private: + const edm::ESGetToken theBSToken_; std::string m_processId; std::string m_pathForLastLumiFile; std::string m_pathForErrorFile; }; - void LumiTestReadAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& context) {} - void LumiTestReadAnalyzer::beginJob() {} + void LumiTestReadAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) { static constexpr const char* const MSGSOURCE = "LumiTestReadAnalyzer:"; edm::eventsetup::EventSetupRecordKey recordKey( @@ -56,9 +53,7 @@ namespace edmtest { //record not found edm::LogError(MSGSOURCE) << "Record \"BeamSpotObjectsRcd\" does not exist "; } - edm::ESHandle ps; - context.get().get(ps); - const BeamSpotObjects* payload = ps.product(); + auto const& payload = &context.getData(theBSToken_); edm::LogInfo(MSGSOURCE) << "Event " << e.id().event() << " Run " << e.id().run() << " Lumi " << e.id().luminosityBlock() << " Time " << e.time().value() << " LumiTestPayload id " << payload->GetBeamType() << std::endl; @@ -71,15 +66,15 @@ namespace edmtest { msg << "On time " << boost::posix_time::to_iso_extended_string(now) << " Target " << target << "; found " << found; edm::LogWarning(MSGSOURCE) << msg.str(); - std::cout << "ERROR ( process " << m_processId << " ) : " << msg.str() << std::endl; - std::cout << "### dumping in file " << m_pathForErrorFile << std::endl; + edm::LogPrint("LumiTestReadAnalyzer") << "ERROR ( process " << m_processId << " ) : " << msg.str(); + edm::LogPrint("LumiTestReadAnalyzer") << "### dumping in file " << m_pathForErrorFile; { std::ofstream errorFile(m_pathForErrorFile, std::ios_base::app); errorFile << msg.str() << std::endl; } //throw std::runtime_error( msg.str() ); } else { - std::cout << "Info: read was ok." << std::endl; + edm::LogPrint("LumiTestReadAnalyzer") << "Info: read was ok."; } } DEFINE_FWK_MODULE(LumiTestReadAnalyzer); diff --git a/CondCore/ESSources/test/stubs/PedestalsAnalyzer.cc b/CondCore/ESSources/test/stubs/PedestalsAnalyzer.cc index d1d61ff968933..01a65d1f8e891 100644 --- a/CondCore/ESSources/test/stubs/PedestalsAnalyzer.cc +++ b/CondCore/ESSources/test/stubs/PedestalsAnalyzer.cc @@ -9,71 +9,66 @@ Toy EDProducers and EDProducts for testing purposes only. #include #include #include -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/Framework/interface/EventSetup.h" #include "CondFormats/Calibration/interface/Pedestals.h" #include "CondFormats/DataRecord/interface/PedestalsRcd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" + #include "TFile.h" using namespace std; namespace edmtest { - class PedestalsAnalyzer : public edm::EDAnalyzer { + class PedestalsAnalyzer : public edm::one::EDAnalyzer { public: - explicit PedestalsAnalyzer(edm::ParameterSet const& p) { std::cout << "PedestalsAnalyzer" << std::endl; } - explicit PedestalsAnalyzer(int i) { std::cout << "PedestalsAnalyzer " << i << std::endl; } - virtual ~PedestalsAnalyzer() { std::cout << "~PedestalsAnalyzer " << std::endl; } - virtual void beginJob(); - virtual void beginRun(const edm::Run&, const edm::EventSetup& context); - virtual void analyze(const edm::Event& e, const edm::EventSetup& c); + explicit PedestalsAnalyzer(edm::ParameterSet const& p) + : thePedestalToken_(esConsumes()), theBeginRunPedestalToken_(esConsumes()) { + edm::LogPrint("PedestalsAnalyzer") << "PedestalsAnalyzer"; + } + explicit PedestalsAnalyzer(int i) { edm::LogPrint("PedestalsAnalyzer") << "PedestalsAnalyzer " << i; } + virtual ~PedestalsAnalyzer() { edm::LogPrint("PedestalsAnalyzer") << "~PedestalsAnalyzer "; } + virtual void beginJob() override; + virtual void beginRun(const edm::Run&, const edm::EventSetup& context) override; + virtual void analyze(const edm::Event& e, const edm::EventSetup& c) override; + virtual void endRun(const edm::Run&, const edm::EventSetup&) override; private: + const edm::ESGetToken thePedestalToken_, theBeginRunPedestalToken_; }; void PedestalsAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& context) { - std::cout << "###PedestalsAnalyzer::beginRun" << std::endl; - edm::ESHandle pPeds; - std::cout << "got eshandle" << std::endl; - context.get().get(pPeds); - } - void PedestalsAnalyzer::beginJob() { - std::cout << "###PedestalsAnalyzer::beginJob" << std::endl; - /*edm::ESHandle pPeds; - std::cout<<"got eshandle"<().get(pPeds); - */ + edm::LogPrint("PedestalsAnalyzer") << "###PedestalsAnalyzer::beginRun"; + edm::LogPrint("PedestalsAnalyzer") << "got context"; + auto const& myBeginRunPed = &context.getData(theBeginRunPedestalToken_); + edm::LogPrint("PedestalsAnalyzer") << "Pedestals* " << myBeginRunPed; } + void PedestalsAnalyzer::beginJob() { edm::LogPrint("PedestalsAnalyzer") << "###PedestalsAnalyzer::beginJob"; } void PedestalsAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) { using namespace edm::eventsetup; // Context is not used. - std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl; - std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl; + edm::LogPrint("PedestalsAnalyzer") << " I AM IN RUN NUMBER " << e.id().run(); + edm::LogPrint("PedestalsAnalyzer") << " ---EVENT NUMBER " << e.id().event(); edm::eventsetup::EventSetupRecordKey recordKey( edm::eventsetup::EventSetupRecordKey::TypeTag::findType("PedestalsRcd")); if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) { //record not found - std::cout << "Record \"PedestalsRcd" - << "\" does not exist " << std::endl; + edm::LogPrint("PedestalsAnalyzer") << "Record \"PedestalsRcd\" does not exist"; } - edm::ESHandle pPeds; - std::cout << "got eshandle" << std::endl; - context.get().get(pPeds); - std::cout << "got context" << std::endl; - const Pedestals* myped = pPeds.product(); - std::cout << "Pedestals* " << myped << std::endl; + edm::LogPrint("PedestalsAnalyzer") << "got context"; + auto const& myped = &context.getData(thePedestalToken_); + edm::LogPrint("PedestalsAnalyzer") << "Pedestals* " << myped; for (std::vector::const_iterator it = myped->m_pedestals.begin(); it != myped->m_pedestals.end(); ++it) - std::cout << " mean: " << it->m_mean << " variance: " << it->m_variance; - std::cout << std::endl; + edm::LogPrint("PedestalsAnalyzer") << " mean: " << it->m_mean << " variance: " << it->m_variance; + edm::LogPrint("PedestalsAnalyzer") << std::endl; TFile* f = TFile::Open("MyPedestal.xml", "recreate"); f->WriteObjectAny(myped, "Pedestals", "Pedestals"); f->Close(); } + void PedestalsAnalyzer::endRun(const edm::Run&, const edm::EventSetup&) {} DEFINE_FWK_MODULE(PedestalsAnalyzer); } // namespace edmtest diff --git a/CondCore/ESSources/test/stubs/PedestalsByLabelAnalyzer.cc b/CondCore/ESSources/test/stubs/PedestalsByLabelAnalyzer.cc index 2432fbbbfa2eb..84a0a786498ac 100644 --- a/CondCore/ESSources/test/stubs/PedestalsByLabelAnalyzer.cc +++ b/CondCore/ESSources/test/stubs/PedestalsByLabelAnalyzer.cc @@ -8,53 +8,52 @@ Toy EDProducers and EDProducts for testing purposes only. #include #include #include -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/Framework/interface/EventSetup.h" #include "CondFormats/Calibration/interface/Pedestals.h" #include "CondFormats/DataRecord/interface/PedestalsRcd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" + using namespace std; namespace edmtest { - class PedestalsByLabelAnalyzer : public edm::EDAnalyzer { + class PedestalsByLabelAnalyzer : public edm::one::EDAnalyzer<> { public: - explicit PedestalsByLabelAnalyzer(edm::ParameterSet const& p) { - std::cout << "PedestalsByLabelAnalyzer" << std::endl; + explicit PedestalsByLabelAnalyzer(edm::ParameterSet const& p) + : thePedestalToken_(esConsumes(edm::ESInputTag("", "lab3d"))) { + edm::LogPrint("PedestalsByLabelAnalyzer") << "PedestalsByLabelAnalyzer"; + } + explicit PedestalsByLabelAnalyzer(int i) { + edm::LogPrint("PedestalsByLabelAnalyzer") << "PedestalsByLabelAnalyzer " << i; } - explicit PedestalsByLabelAnalyzer(int i) { std::cout << "PedestalsByLabelAnalyzer " << i << std::endl; } - virtual ~PedestalsByLabelAnalyzer() { std::cout << "~PedestalsByLabelAnalyzer " << std::endl; } + virtual ~PedestalsByLabelAnalyzer() { edm::LogPrint("PedestalsByLabelAnalyzer") << "~PedestalsByLabelAnalyzer "; } virtual void analyze(const edm::Event& e, const edm::EventSetup& c); private: + const edm::ESGetToken thePedestalToken_; }; void PedestalsByLabelAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) { using namespace edm::eventsetup; // Context is not used. - std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl; - std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl; + edm::LogPrint("PedestalsByLabelAnalyzer") << " I AM IN RUN NUMBER " << e.id().run(); + edm::LogPrint("PedestalsByLabelAnalyzer") << " ---EVENT NUMBER " << e.id().event(); edm::eventsetup::EventSetupRecordKey recordKey( edm::eventsetup::EventSetupRecordKey::TypeTag::findType("PedestalsRcd")); if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) { //record not found - std::cout << "Record \"PedestalsRcd" - << "\" does not exist " << std::endl; + edm::LogPrint("PedestalsByLabelAnalyzer") << "Record \"PedestalsRcd\" does not exist"; } - edm::ESHandle pPeds; - std::cout << "got eshandle" << std::endl; - context.get().get("lab3d", pPeds); - std::cout << "got context" << std::endl; - const Pedestals* myped = pPeds.product(); - std::cout << "Pedestals* " << myped << std::endl; + edm::LogPrint("PedestalsByLabelAnalyzer") << "got context"; + auto const& myped = &context.getData(thePedestalToken_); + edm::LogPrint("PedestalsByLabelAnalyzer") << "Pedestals* " << myped; for (std::vector::const_iterator it = myped->m_pedestals.begin(); it != myped->m_pedestals.end(); ++it) - std::cout << " mean: " << it->m_mean << " variance: " << it->m_variance; - std::cout << std::endl; + edm::LogPrint("PedestalsByLabelAnalyzer") << " mean: " << it->m_mean << " variance: " << it->m_variance; + edm::LogPrint("PedestalsByLabelAnalyzer") << std::endl; } DEFINE_FWK_MODULE(PedestalsByLabelAnalyzer); } // namespace edmtest diff --git a/CondCore/ESSources/test/stubs/TestConcurrentIOVsCondCore.cc b/CondCore/ESSources/test/stubs/TestConcurrentIOVsCondCore.cc index bb739c2969d5d..4b942df262875 100644 --- a/CondCore/ESSources/test/stubs/TestConcurrentIOVsCondCore.cc +++ b/CondCore/ESSources/test/stubs/TestConcurrentIOVsCondCore.cc @@ -174,8 +174,9 @@ namespace edmtest { // The original reference file was created using a version // of the code before concurrent IOVs were implemented. for (auto const& object : testObjects_) { - std::cout << "TestConcurrentIOVsCondCore: lumi = " << object.lumi_ << " position: (" << object.x_ << ", " - << object.y_ << ", " << object.z_ << ") iov = " << object.start_ << ":" << object.end_ << std::endl; + edm::LogPrint("TestConcurrentIOVsCondCore") + << "TestConcurrentIOVsCondCore: lumi = " << object.lumi_ << " position: (" << object.x_ << ", " << object.y_ + << ", " << object.z_ << ") iov = " << object.start_ << ":" << object.end_; } } diff --git a/CondCore/ESSources/test/stubs/TestUpdater.cc b/CondCore/ESSources/test/stubs/TestUpdater.cc index bdc33483275ef..4ffcfcf5a10ed 100644 --- a/CondCore/ESSources/test/stubs/TestUpdater.cc +++ b/CondCore/ESSources/test/stubs/TestUpdater.cc @@ -1,14 +1,14 @@ #include #include #include -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" #include #include #include +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" + typedef std::vector Payload; #include "FWCore/Framework/interface/EventSetupRecordImplementation.h" @@ -21,39 +21,42 @@ EVENTSETUP_RECORD_REG(OneIntRcd); namespace condtest { - class TestUpdater : public edm::EDAnalyzer { + class TestUpdater : public edm::one::EDAnalyzer { public: explicit TestUpdater(edm::ParameterSet const&); - virtual void analyze(const edm::Event& e, const edm::EventSetup& c); - virtual void beginRun(const edm::Run&, const edm::EventSetup&); - virtual void endRun(const edm::Run& r, const edm::EventSetup&) {} + virtual void analyze(const edm::Event& e, const edm::EventSetup& c) override; + virtual void beginRun(const edm::Run&, const edm::EventSetup&) override; + virtual void endRun(const edm::Run&, const edm::EventSetup&) override; static void update(int run); int evCount; + + private: + const edm::ESGetToken, OneIntRcd> theIntToken_; }; - TestUpdater::TestUpdater(edm::ParameterSet const&) : evCount(0) {} + TestUpdater::TestUpdater(edm::ParameterSet const&) : evCount(0), theIntToken_(esConsumes()) {} void TestUpdater::beginRun(const edm::Run&, const edm::EventSetup&) { evCount = 0; } + void TestUpdater::endRun(const edm::Run&, const edm::EventSetup&) {} + void TestUpdater::analyze(const edm::Event& e, const edm::EventSetup& c) { ++evCount; if (0 == e.id().run() % 2 && evCount == 3) update(e.id().run() + 1); - edm::ESHandle > h; - c.get().get(h); - size_t number = (*h.product()).front(); + size_t number = (c.getData(theIntToken_)).front(); if (1 == e.id().run() % 2 && number != e.id().run()) - std::cout << "it was not updated!" << std::endl; + edm::LogPrint("TestUpdater") << "it was not updated!"; } void TestUpdater::update(int run) { std::ostringstream ss; ss << "touch cfg.py; rm cfg.py; sed 's?_CurrentRun_?" << run << "?g' writeInt_cfg.py > cfg.py; cmsRun cfg.py"; - std::cout << ss.str() << std::endl; + edm::LogPrint("TestUpdater") << ss.str(); // write run in db ::system(ss.str().c_str()); }