File indexing completed on 2024-04-06 12:13:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0016 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
0017 #include "FWCore/ServiceRegistry/interface/GlobalContext.h"
0018 #include "FWCore/ServiceRegistry/interface/ServiceMaker.h"
0019
0020 namespace edm {
0021 namespace service {
0022
0023 class TestService {
0024 public:
0025 TestService(const ParameterSet&, ActivityRegistry&);
0026
0027 static void fillDescriptions(edm::ConfigurationDescriptions&);
0028
0029 void preBeginProcessBlock(GlobalContext const&);
0030
0031 void preEndProcessBlock(GlobalContext const&);
0032
0033 void preGlobalBeginRun(GlobalContext const&);
0034
0035 void preGlobalEndRun(GlobalContext const&);
0036
0037 void preGlobalBeginLumi(GlobalContext const&);
0038
0039 void preGlobalEndLumi(GlobalContext const&);
0040
0041 private:
0042 bool printTestMessageLoggerErrors_;
0043 };
0044 }
0045 }
0046
0047 using namespace edm::service;
0048
0049 TestService::TestService(ParameterSet const& iPS, ActivityRegistry& iRegistry)
0050 : printTestMessageLoggerErrors_(iPS.getUntrackedParameter<bool>("printTestMessageLoggerErrors")) {
0051 iRegistry.watchPreBeginProcessBlock(this, &TestService::preBeginProcessBlock);
0052
0053 iRegistry.watchPreEndProcessBlock(this, &TestService::preEndProcessBlock);
0054
0055 iRegistry.watchPreGlobalBeginRun(this, &TestService::preGlobalBeginRun);
0056
0057 iRegistry.watchPreGlobalEndRun(this, &TestService::preGlobalEndRun);
0058
0059 iRegistry.watchPreGlobalBeginLumi(this, &TestService::preGlobalBeginLumi);
0060
0061 iRegistry.watchPreGlobalEndLumi(this, &TestService::preGlobalEndLumi);
0062 }
0063
0064 void TestService::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0065 edm::ParameterSetDescription desc;
0066 desc.addUntracked<bool>("printTestMessageLoggerErrors", false)
0067 ->setComment("Prints MessageLogger errors to test formatting of such messages when printed from Services");
0068 descriptions.add("TestService", desc);
0069 }
0070
0071 void TestService::preBeginProcessBlock(GlobalContext const&) {
0072 if (printTestMessageLoggerErrors_) {
0073 edm::LogError("TestMessageLogger") << "test message from TestService::preBeginProcessBlock";
0074 }
0075 }
0076
0077 void TestService::preEndProcessBlock(GlobalContext const&) {
0078 if (printTestMessageLoggerErrors_) {
0079 edm::LogError("TestMessageLogger") << "test message from TestService::preEndProcessBlock";
0080 }
0081 }
0082
0083 void TestService::preGlobalBeginRun(GlobalContext const&) {
0084 if (printTestMessageLoggerErrors_) {
0085 edm::LogError("TestMessageLogger") << "test message from TestService::preGlobalBeginRun";
0086 }
0087 }
0088
0089 void TestService::preGlobalEndRun(GlobalContext const&) {
0090 if (printTestMessageLoggerErrors_) {
0091 edm::LogError("TestMessageLogger") << "test message from TestService::preGlobalEndRun";
0092 }
0093 }
0094
0095 void TestService::preGlobalBeginLumi(GlobalContext const& gc) {
0096 if (printTestMessageLoggerErrors_) {
0097 edm::LogError("TestMessageLogger") << "test message from TestService::preGlobalBeginLumi";
0098 }
0099 }
0100
0101 void TestService::preGlobalEndLumi(GlobalContext const& gc) {
0102 if (printTestMessageLoggerErrors_) {
0103 edm::LogError("TestMessageLogger") << "test message from TestService::preGlobalEndLumi";
0104 }
0105 }
0106
0107 using edm::service::TestService;
0108 DEFINE_FWK_SERVICE(TestService);