CMS 3D CMS Logo

DTCalibDBUtils.h
Go to the documentation of this file.
1 #ifndef CalibMuonDTCalibDBUtils_H
2 #define CalibMuonDTCalibDBUtils_H
3 
10 #include <iostream>
11 #include <string>
14 
16 public:
19 
21  virtual ~DTCalibDBUtils();
22 
23  // Operations
24 
27  template <typename T>
28  static void writeToDB(std::string record, const T& payload) {
29  // Write the ttrig object to DB
31  if (dbOutputSvc.isAvailable()) {
32  try {
33  if (dbOutputSvc->isNewTagRequest(record)) {
34  //create mode
35  dbOutputSvc->writeOneIOV<T>(payload, dbOutputSvc->beginOfTime(), record);
36  } else {
37  //append mode. Note: correct PoolDBESSource must be loaded
38  dbOutputSvc->writeOneIOV<T>(payload, dbOutputSvc->currentTime(), record);
39  }
40  } catch (const cond::Exception& er) {
41  std::cout << er.what() << std::endl;
42  } catch (const std::exception& er) {
43  std::cout << "[DTCalibDBUtils] caught std::exception " << er.what() << std::endl;
44  } catch (...) {
45  std::cout << "[DTCalibDBUtils] Funny error" << std::endl;
46  }
47  } else {
48  std::cout << "Service PoolDBOutputService is unavailable" << std::endl;
49  }
50  }
51 
52 protected:
53 private:
54 };
55 #endif
static void writeToDB(std::string record, const T &payload)
Base exception class for the object to relational access.
Definition: Exception.h:11
virtual ~DTCalibDBUtils()
Destructor.
bool isNewTagRequest(const std::string &recordName)
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
DTCalibDBUtils()
Constructor.
bool isAvailable() const
Definition: Service.h:40
char const * what() const noexcept override
Definition: Exception.cc:107
long double T