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
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);
27  void analyze(const edm::Event& e, const edm::EventSetup&es){};
28 
29  void endRun(const edm::Run & run, const edm::EventSetup & es);
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");
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( 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:42
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:47
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:55
T const * product() const
Definition: ESHandle.h:62
Definition: Run.h:36