#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: /// DEPRECATED: /// This file will be removed from here and the functionality /// replaced with JCalibrationCCDB.h which resides in the JANA /// library. That has been updated with mutex locks to match /// this file as of JANA version 0.7.3. However, JANA 0.7.3 also /// changes the signature of the GetCalib virtual methods to /// use uint64_t and int32_t. The following methods are wrappers /// that allow this file to be used with JANA 0.7.3 (as well as /// previous versions) until 0.7.3 becomes commonplace and this /// file can be removed. /// /// June 10, 2015 David Lawrence virtual bool GetCalib(string namepath, map &svals, uint64_t event_number=0){return GetCalib(namepath,svals,(int)event_number);} virtual bool GetCalib(string namepath, vector &svals, uint64_t event_number=0){return GetCalib(namepath,svals,(int)event_number);} virtual bool GetCalib(string namepath, vector< map > &svals, uint64_t event_number=0){return GetCalib(namepath,svals,(int)event_number);} virtual bool GetCalib(string namepath, vector< vector > &svals, uint64_t event_number=0){return GetCalib(namepath,svals,(int)event_number);} /** @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 = '"<end of CCDB debug output bool result = mCalibration->GetCalib(svals, namepath); //>oO CCDB debug output #ifdef CCDB_DEBUG_OUTPUT cout<<"CCDB::janaccdb result = "<0) { vector::const_iterator iter = svals.begin(); first_value.assign(*iter); } 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, vector &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, vector > &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) { vector::const_iterator iter = vsvals[0].begin(); first_value.assign(*iter); } cout<<"CCDB::janaccdb selected rows = '"<oO CCDB debug output #ifdef CCDB_DEBUG_OUTPUT cout <<"CCDB::janaccdb Exception caught at GetCalib(string namepath, vector > &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()<