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:
29  unsigned long long cacheID;
30 };
31 
32 template <typename TObject, typename TObjectO, typename TRecord>
34  : iConfig_(iConfig), cacheID(0) {
35  edm::LogInfo("DummyCondDBWriter") << "DummyCondDBWriter constructor for typename " << typeid(TObject).name()
36  << " and record " << typeid(TRecord).name() << std::endl;
37 }
38 
39 template <typename TObject, typename TObjectO, typename TRecord>
41  edm::LogInfo("DummyCondDBWriter") << "DummyCondDBWriter::~DummyCondDBWriter()" << std::endl;
42 }
43 
44 template <typename TObject, typename TObjectO, typename TRecord>
46  std::string rcdName = iConfig_.getParameter<std::string>("record");
47  std::string labelName = iConfig_.getUntrackedParameter<std::string>("label", "");
48 
49  if (cacheID == es.get<TRecord>().cacheIdentifier()) {
50  edm::LogInfo("DummyCondDBWriter") << "not needed to store objects with Record " << rcdName << " at run "
51  << run.run() << std::endl;
52  return;
53  }
54  cacheID = es.get<TRecord>().cacheIdentifier();
55 
57  es.get<TRecord>().get(labelName, esobj);
58  TObjectO* obj = new TObjectO(*(esobj.product()));
59  cond::Time_t Time_;
60 
61  //And now write data in DB
63  if (dbservice.isAvailable()) {
64  std::string openIovAt = iConfig_.getUntrackedParameter<std::string>("OpenIovAt", "beginOfTime");
65  if (openIovAt == "beginOfTime")
66  Time_ = dbservice->beginOfTime();
67  else if (openIovAt == "currentTime")
68  Time_ = dbservice->currentTime();
69  else
70  Time_ = iConfig_.getUntrackedParameter<uint32_t>("OpenIovAtTime", 1);
71 
72  dbservice->writeOne(obj, Time_, rcdName);
73  } else {
74  edm::LogError("SiStripFedCablingBuilder") << "Service is unavailable" << std::endl;
75  }
76 }
77 
78 #endif
DummyCondDBWriter
Definition: DummyCondDBWriter.h:19
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
MessageLogger.h
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:177
ESHandle.h
edm::Run
Definition: Run.h:45
edm::LogInfo
Definition: MessageLogger.h:254
EDAnalyzer.h
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
PoolDBOutputService.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
Service.h
DummyCondDBWriter::DummyCondDBWriter
DummyCondDBWriter(const edm::ParameterSet &iConfig)
Definition: DummyCondDBWriter.h:33
Run.h
edm::ESHandle
Definition: DTSurvey.h:22
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
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
get
#define get
DummyCondDBWriter::~DummyCondDBWriter
~DummyCondDBWriter() override
Definition: DummyCondDBWriter.h:40
DummyCondDBWriter::analyze
void analyze(const edm::Event &e, const edm::EventSetup &es) override
Definition: DummyCondDBWriter.h:23
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DummyCondDBWriter::cacheID
unsigned long long cacheID
Definition: DummyCondDBWriter.h:29
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:56
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:179
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:45