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 
19 
20 template< typename TObject , typename TObjectO , typename TRecord>
22 
23 public:
24 
25  explicit DummyCondDBWriter(const edm::ParameterSet& iConfig);
26  ~DummyCondDBWriter() override;
27  void analyze(const edm::Event& e, const edm::EventSetup&es) override{};
28 
29  void endRun(const edm::Run & run, const edm::EventSetup & es) override;
30 
31  private:
33  unsigned long long cacheID;
34 };
35 
36 template< typename TObject , typename TObjectO ,typename TRecord>
38  edm::LogInfo("DummyCondDBWriter") << "DummyCondDBWriter constructor for typename " << typeid(TObject).name() << " and record " << typeid(TRecord).name() << std::endl;
39 }
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 
50  std::string rcdName=iConfig_.getParameter<std::string>("record");
52 
53  if( cacheID == es.get<TRecord>().cacheIdentifier()){
54  edm::LogInfo("DummyCondDBWriter") << "not needed to store objects with Record "<< rcdName << " at run " << run.run() << std::endl; return;
55  }
56  cacheID = es.get<TRecord>().cacheIdentifier();
57 
59  es.get<TRecord>().get( labelName, esobj );
60  TObjectO *obj= new TObjectO(*(esobj.product()));
61  cond::Time_t Time_;
62 
63  //And now write data in DB
65  if( dbservice.isAvailable() ){
66 
67  std::string openIovAt=iConfig_.getUntrackedParameter<std::string>("OpenIovAt","beginOfTime");
68  if(openIovAt=="beginOfTime")
69  Time_=dbservice->beginOfTime();
70  else if (openIovAt=="currentTime")
71  Time_=dbservice->currentTime();
72  else
73  Time_=iConfig_.getUntrackedParameter<uint32_t>("OpenIovAtTime",1);
74 
75  dbservice->writeOne(obj, Time_, rcdName);
76  } else{
77  edm::LogError("SiStripFedCablingBuilder")<<"Service is unavailable"<<std::endl;
78  }
79 }
80 
81 #endif
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
RunNumber_t run() const
Definition: RunBase.h:40
DummyCondDBWriter(const edm::ParameterSet &iConfig)
unsigned long long Time_t
Definition: Time.h:16
bool isAvailable() const
Definition: Service.h:40
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
unsigned long long cacheID
edm::ParameterSet iConfig_
T get() const
Definition: EventSetup.h:71
void endRun(const edm::Run &run, const edm::EventSetup &es) override
~DummyCondDBWriter() override
void analyze(const edm::Event &e, const edm::EventSetup &es) override
T const * product() const
Definition: ESHandle.h:86
Definition: Run.h:45