CMS 3D CMS Logo

HcalParametersDBBuilder.cc
Go to the documentation of this file.
14 
15 //#define EDM_ML_DEBUG
16 
17 class HcalParametersDBBuilder : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
18 public:
20 
22 
23  void beginRun(edm::Run const& iEvent, edm::EventSetup const&) override;
24  void analyze(edm::Event const& iEvent, edm::EventSetup const&) override {}
25  void endRun(edm::Run const& iEvent, edm::EventSetup const&) override {}
26 
27 private:
31 };
32 
34  : fromDD4hep_(ps.getParameter<bool>("fromDD4hep")) {
35 #ifdef EDM_ML_DEBUG
36  edm::LogVerbatim("HCalGeom") << "HcalParametersDBBuilder::HcalParametersDBBuilder called with dd4hep: "
37  << fromDD4hep_;
38 #endif
39  dd4HepCompactViewToken_ = esConsumes<edm::Transition::BeginRun>();
40  compactViewToken_ = esConsumes<edm::Transition::BeginRun>();
41 }
42 
45  desc.add<bool>("fromDD4hep", false);
46  descriptions.add("HcalParametersWriter", desc);
47 }
48 
50  HcalParameters php;
52  if (!mydbservice.isAvailable()) {
53  edm::LogError("HcalParametersDBBuilder") << "PoolDBOutputService unavailable";
54  return;
55  }
56 
57  HcalParametersFromDD builder;
58 
59  if (fromDD4hep_) {
60 #ifdef EDM_ML_DEBUG
61  edm::LogVerbatim("HCalGeom") << "HcalParametersDBBuilder::Try to access cms::DDCompactView";
62 #endif
64  builder.build((*cpv), php);
65  } else {
66 #ifdef EDM_ML_DEBUG
67  edm::LogVerbatim("HCalGeom") << "HcalParametersDBBuilder::Try to access DDCompactView";
68 #endif
70  builder.build(&(*cpv), php);
71  }
72 
73  if (mydbservice->isNewTagRequest("HcalParametersRcd")) {
74  mydbservice->createOneIOV(php, mydbservice->beginOfTime(), "HcalParametersRcd");
75  } else {
76  edm::LogError("HcalParametersDBBuilder") << "HcalParameters and HcalParametersRcd Tag already present";
77  }
78 }
79 
Log< level::Info, true > LogVerbatim
bool build(const DDCompactView *, HcalParameters &)
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4HepCompactViewToken_
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
HcalParametersDBBuilder(const edm::ParameterSet &)
Log< level::Error, false > LogError
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
int iEvent
Definition: GenABIO.cc:224
bool isNewTagRequest(const std::string &recordName)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(edm::Event const &iEvent, edm::EventSetup const &) override
void endRun(edm::Run const &iEvent, edm::EventSetup const &) override
edm::ESGetToken< DDCompactView, IdealGeometryRecord > compactViewToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &)
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:141
bool isAvailable() const
Definition: Service.h:40
Definition: Run.h:45