File indexing completed on 2024-04-06 11:58:25
0001 #ifndef CalibMuonDTCalibDBUtils_H
0002 #define CalibMuonDTCalibDBUtils_H
0003
0004
0005
0006
0007
0008
0009
0010 #include <iostream>
0011 #include <string>
0012 #include "FWCore/ServiceRegistry/interface/Service.h"
0013 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0014
0015 class DTCalibDBUtils {
0016 public:
0017
0018 DTCalibDBUtils();
0019
0020
0021 virtual ~DTCalibDBUtils();
0022
0023
0024
0025
0026
0027 template <typename T>
0028 static void writeToDB(std::string record, const T& payload) {
0029
0030 edm::Service<cond::service::PoolDBOutputService> dbOutputSvc;
0031 if (dbOutputSvc.isAvailable()) {
0032 try {
0033 if (dbOutputSvc->isNewTagRequest(record)) {
0034
0035 dbOutputSvc->writeOneIOV<T>(payload, dbOutputSvc->beginOfTime(), record);
0036 } else {
0037
0038 dbOutputSvc->writeOneIOV<T>(payload, dbOutputSvc->currentTime(), record);
0039 }
0040 } catch (const cond::Exception& er) {
0041 std::cout << er.what() << std::endl;
0042 } catch (const std::exception& er) {
0043 std::cout << "[DTCalibDBUtils] caught std::exception " << er.what() << std::endl;
0044 } catch (...) {
0045 std::cout << "[DTCalibDBUtils] Funny error" << std::endl;
0046 }
0047 } else {
0048 std::cout << "Service PoolDBOutputService is unavailable" << std::endl;
0049 }
0050 }
0051
0052 protected:
0053 private:
0054 };
0055 #endif