CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions
DTCalibDBUtils Class Reference

#include <DTCalibDBUtils.h>

Public Member Functions

 DTCalibDBUtils ()
 Constructor. More...
 
virtual ~DTCalibDBUtils ()
 Destructor. More...
 

Static Public Member Functions

template<typename T >
static void writeToDB (std::string record, const T &payload)
 

Detailed Description

Simple interface to PoolDBOutputService to write objects to DB.

Author
G. Cerminara - INFN Torino

Definition at line 15 of file DTCalibDBUtils.h.

Constructor & Destructor Documentation

◆ DTCalibDBUtils()

DTCalibDBUtils::DTCalibDBUtils ( )

Constructor.

◆ ~DTCalibDBUtils()

virtual DTCalibDBUtils::~DTCalibDBUtils ( )
virtual

Destructor.

Member Function Documentation

◆ writeToDB()

template<typename T >
static void DTCalibDBUtils::writeToDB ( std::string  record,
const T payload 
)
inlinestatic

Write the payload to the DB using PoolDBOutputService. New payload are created in the DB, existing payload are appended.

Definition at line 28 of file DTCalibDBUtils.h.

References cond::service::PoolDBOutputService::beginOfTime(), gather_cfg::cout, cond::service::PoolDBOutputService::currentTime(), cppFunctionSkipper::exception, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), jetsAK4_Puppi_cff::payload, Hcal_FrontierConditions_cff::record, cms::Exception::what(), and cond::service::PoolDBOutputService::writeOneIOV().

Referenced by DTLocalTriggerSynchTest::dqmEndJob(), DTTPGParamsWriter::endJob(), DTTTrigOffsetCalibration::endJob(), DTT0CalibrationRMS::endJob(), DTTTrigWriter::endJob(), DTTPDeadWriter::endJob(), DTTTrigCalibration::endJob(), and DTT0Calibration::endJob().

28  {
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  }
Base exception class for the object to relational access.
Definition: Exception.h:11
bool isNewTagRequest(const std::string &recordName)
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
bool isAvailable() const
Definition: Service.h:40
char const * what() const noexcept override
Definition: Exception.cc:107
long double T