CMS 3D CMS Logo

DummyCondDBWriter.h
Go to the documentation of this file.
1 #ifndef CalibTracker_SiStripESProducer_DummyCondDBWriter_h
2 #define CalibTracker_SiStripESProducer_DummyCondDBWriter_h
3 
4 // user include files
13 
15 
16 #include <string>
17 
18 template <typename TObject, typename TObjectO, typename TRecord>
20 public:
21  explicit DummyCondDBWriter(const edm::ParameterSet& iConfig);
22  ~DummyCondDBWriter() override;
23  void analyze(const edm::Event& e, const edm::EventSetup& es) override{};
24 
25  void endRun(const edm::Run& run, const edm::EventSetup& es) override;
26 
27 private:
31 };
32 
33 template <typename TObject, typename TObjectO, typename TRecord>
35  : iConfig_(iConfig),
36  token_(esConsumes<edm::Transition::EndRun>(
37  edm::ESInputTag{"", iConfig.getUntrackedParameter<std::string>("label", "")})) {
38  edm::LogInfo("DummyCondDBWriter") << "DummyCondDBWriter constructor for typename " << typeid(TObject).name()
39  << " and record " << typeid(TRecord).name() << std::endl;
40 }
41 
42 template <typename TObject, typename TObjectO, typename TRecord>
44  edm::LogInfo("DummyCondDBWriter") << "DummyCondDBWriter::~DummyCondDBWriter()" << std::endl;
45 }
46 
47 template <typename TObject, typename TObjectO, typename TRecord>
49  std::string rcdName = iConfig_.getParameter<std::string>("record");
50 
51  if (!watcher_.check(es)) {
52  edm::LogInfo("DummyCondDBWriter") << "not needed to store objects with Record " << rcdName << " at run "
53  << run.run() << std::endl;
54  return;
55  }
56 
57  auto obj = std::make_unique<TObjectO>(es.getData(token_));
58  cond::Time_t Time_;
59 
60  //And now write data in DB
62  if (dbservice.isAvailable()) {
63  std::string openIovAt = iConfig_.getUntrackedParameter<std::string>("OpenIovAt", "beginOfTime");
64  if (openIovAt == "beginOfTime")
65  Time_ = dbservice->beginOfTime();
66  else if (openIovAt == "currentTime")
67  Time_ = dbservice->currentTime();
68  else
69  Time_ = iConfig_.getUntrackedParameter<uint32_t>("OpenIovAtTime", 1);
70 
71  dbservice->writeOne(obj.release(), Time_, rcdName);
72  } else {
73  edm::LogError("SiStripFedCablingBuilder") << "Service is unavailable" << std::endl;
74  }
75 }
76 
77 #endif
DummyCondDBWriter
Definition: DummyCondDBWriter.h:19
MessageLogger.h
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
edm::ESWatcher< TRecord >
ESInputTag
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
DummyCondDBWriter::watcher_
edm::ESWatcher< TRecord > watcher_
Definition: DummyCondDBWriter.h:29
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
PoolDBOutputService.h
Service.h
DummyCondDBWriter::DummyCondDBWriter
DummyCondDBWriter(const edm::ParameterSet &iConfig)
Definition: DummyCondDBWriter.h:34
Run.h
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DummyCondDBWriter::token_
edm::ESGetToken< TObject, TRecord > token_
Definition: DummyCondDBWriter.h:30
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
edm::Service< cond::service::PoolDBOutputService >
edm::EventSetup
Definition: EventSetup.h:57
DummyCondDBWriter::iConfig_
edm::ParameterSet iConfig_
Definition: DummyCondDBWriter.h:28
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::ESGetToken< TObject, TRecord >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
DummyCondDBWriter::~DummyCondDBWriter
~DummyCondDBWriter() override
Definition: DummyCondDBWriter.h:43
DummyCondDBWriter::analyze
void analyze(const edm::Event &e, const edm::EventSetup &es) override
Definition: DummyCondDBWriter.h:23
writedatasetfile.run
run
Definition: writedatasetfile.py:27
ESWatcher.h
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
Exception.h
ParameterSet.h
edm::Event
Definition: Event.h:73
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
DummyCondDBWriter::endRun
void endRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: DummyCondDBWriter.h:48