CMS 3D CMS Logo

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