#ifndef _DCalibrationCCDB_ #define _DCalibrationCCDB_ #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace jana; // Place everything in JANA namespace namespace jana { /** * Descendant of JCalibration class which allow to use CCDB as JANA calibration source */ class DCalibrationCCDB : public JCalibration { public: /** @brief Constructor * * @parameter [in] url - connection string. like mysql://... * @parameter [in] run - run number * @parameter [in] context - variation */ DCalibrationCCDB(ccdb::Calibration* calib, string url, int run, string context="default"): JCalibration(calib->GetConnectionString(), run, context) { mCalibration = calib; pthread_mutex_init(&mutex, NULL); //>oO CCDB debug output #ifdef CCDB_DEBUG_OUTPUT jout<<"CCDB::janaccdb created DCalibrationCCDB with connection string:" << calib->GetConnectionString()<< " run:"< &svals, int event_number=0) { // Lock mutex for exclusive use of underlying Calibration object pthread_mutex_lock(&mutex); // try { //>oO CCDB debug output #ifdef CCDB_DEBUG_OUTPUT cout<<"CCDB::janaccdb"< request = '"<end of CCDB debug output bool result = mCalibration->GetCalib(svals, namepath); //>oO CCDB debug output #ifdef CCDB_DEBUG_OUTPUT cout<<"CCDB::janaccdb result = "<0) { map::const_iterator iter = svals.begin(); first_value.assign(iter->second); } cout<<"CCDB::janaccdb selected name-values count = '"<end of CCDB debug output pthread_mutex_unlock(&mutex); return !result; //JANA has false - if success and true if error } catch (std::exception& ex) { //>oO CCDB debug output #ifdef CCDB_DEBUG_OUTPUT cout <<"CCDB::janaccdb Exception caught at GetCalib(string namepath, map &svals, int event_number=0)"<> request = '"<GetCalib(vsvals, namepath); //>oO CCDB debug output #ifdef CCDB_DEBUG_OUTPUT cout<<"CCDB::janaccdb result = "<0 && vsvals[0].size()>0) { map::const_iterator iter = vsvals[0].begin(); first_value.assign(iter->second); } cout<<"CCDB::janaccdb selected rows = '"<oO CCDB debug output #ifdef CCDB_DEBUG_OUTPUT cout <<"CCDB::janaccdb Exception caught at GetCalib(string namepath, map &svals, int event_number=0)"<GetListOfNamepaths(namepaths); } catch (std::exception& ex) { //some ccdb debug output #ifdef CCDB_DEBUG_OUTPUT cout<<"CCDB::janaccdb Exception cought at GetListOfNamepaths(vector &namepaths). What = "<< ex.what()<