#include <OnlineDB/EcalCondDB/interface/LMFLaserBlueRawDat.h>
Public Member Functions | |
float | getAPDErr () const |
float | getAPDPeak () const |
std::string | getTable () |
LMFLaserBlueRawDat () | |
void | setAPDErr (float err) |
void | setAPDPeak (float peak) |
~LMFLaserBlueRawDat () | |
Private Member Functions | |
void | fetchData (std::map< EcalLogicID, LMFLaserBlueRawDat > *fillVec, LMFRunIOV *iov) throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | writeArrayDB (const std::map< EcalLogicID, LMFLaserBlueRawDat > *data, LMFRunIOV *iov) throw (std::runtime_error) |
void | writeDB (const EcalLogicID *ecid, const LMFLaserBlueRawDat *item, LMFRunIOV *iov) throw (std::runtime_error) |
Private Attributes | |
float | m_apdErr |
float | m_apdPeak |
Friends | |
class | EcalCondDBInterface |
Definition at line 12 of file LMFLaserBlueRawDat.h.
LMFLaserBlueRawDat::LMFLaserBlueRawDat | ( | ) |
Definition at line 12 of file LMFLaserBlueRawDat.cc.
References m_apdErr, m_apdPeak, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, IDataItem::m_writeStmt, and NULL.
00013 { 00014 m_env = NULL; 00015 m_conn = NULL; 00016 m_writeStmt = NULL; 00017 m_readStmt = NULL; 00018 00019 m_apdPeak = 0; 00020 m_apdErr = 0; 00021 }
LMFLaserBlueRawDat::~LMFLaserBlueRawDat | ( | ) |
void LMFLaserBlueRawDat::fetchData | ( | std::map< EcalLogicID, LMFLaserBlueRawDat > * | fillVec, | |
LMFRunIOV * | iov | |||
) | throw (std::runtime_error) [private] |
Definition at line 150 of file LMFLaserBlueRawDat.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setAPDErr(), and setAPDPeak().
00152 { 00153 this->checkConnection(); 00154 fillMap->clear(); 00155 00156 iov->setConnection(m_env, m_conn); 00157 int iovID = iov->fetchID(); 00158 if (!iovID) { 00159 // throw(runtime_error("LMFLaserBlueRawDat::writeDB: IOV not in DB")); 00160 return; 00161 } 00162 00163 try { 00164 00165 m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 00166 "d.apd_peak, d.apd_err " 00167 "FROM channelview cv JOIN lmf_laser_blue_raw_dat d " 00168 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 00169 "WHERE d.iov_id = :iov_id"); 00170 m_readStmt->setInt(1, iovID); 00171 ResultSet* rset = m_readStmt->executeQuery(); 00172 00173 std::pair< EcalLogicID, LMFLaserBlueRawDat > p; 00174 LMFLaserBlueRawDat dat; 00175 while(rset->next()) { 00176 p.first = EcalLogicID( rset->getString(1), // name 00177 rset->getInt(2), // logic_id 00178 rset->getInt(3), // id1 00179 rset->getInt(4), // id2 00180 rset->getInt(5), // id3 00181 rset->getString(6)); // maps_to 00182 00183 dat.setAPDPeak( rset->getFloat(7) ); 00184 dat.setAPDErr( rset->getFloat(8) ); 00185 00186 p.second = dat; 00187 fillMap->insert(p); 00188 } 00189 m_conn->terminateStatement(m_readStmt); 00190 } catch (SQLException &e) { 00191 throw(runtime_error("LMFLaserBlueRawDat::fetchData(): "+e.getMessage())); 00192 } 00193 }
float LMFLaserBlueRawDat::getAPDErr | ( | ) | const [inline] |
Definition at line 25 of file LMFLaserBlueRawDat.h.
References m_apdErr.
Referenced by writeArrayDB().
00025 { return m_apdErr; }
float LMFLaserBlueRawDat::getAPDPeak | ( | ) | const [inline] |
Definition at line 22 of file LMFLaserBlueRawDat.h.
References m_apdPeak.
Referenced by writeArrayDB().
00022 { return m_apdPeak; }
std::string LMFLaserBlueRawDat::getTable | ( | ) | [inline, virtual] |
void LMFLaserBlueRawDat::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IDataItem.
Definition at line 31 of file LMFLaserBlueRawDat.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, and IDataItem::m_writeStmt.
00033 { 00034 this->checkConnection(); 00035 00036 try { 00037 m_writeStmt = m_conn->createStatement(); 00038 m_writeStmt->setSQL("INSERT INTO lmf_laser_blue_raw_dat (iov_id, logic_id, " 00039 "apd_peak, apd_err) " 00040 "VALUES (:iov_id, :logic_id, " 00041 ":3, :4)"); 00042 } catch (SQLException &e) { 00043 throw(runtime_error("LMFLaserBlueRawDat::prepareWrite(): "+e.getMessage())); 00044 } 00045 }
void LMFLaserBlueRawDat::setAPDErr | ( | float | err | ) | [inline] |
void LMFLaserBlueRawDat::setAPDPeak | ( | float | peak | ) | [inline] |
Definition at line 21 of file LMFLaserBlueRawDat.h.
References m_apdPeak.
Referenced by fetchData().
00021 { m_apdPeak = peak; }
void LMFLaserBlueRawDat::writeArrayDB | ( | const std::map< EcalLogicID, LMFLaserBlueRawDat > * | data, | |
LMFRunIOV * | iov | |||
) | throw (std::runtime_error) [private] |
Definition at line 74 of file LMFLaserBlueRawDat.cc.
References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, getAPDErr(), getAPDPeak(), EcalLogicID::getLogicID(), IDataItem::m_writeStmt, p, x, and y.
00076 { 00077 this->checkConnection(); 00078 this->checkPrepare(); 00079 00080 int iovID = iov->fetchID(); 00081 if (!iovID) { throw(runtime_error("LMFLaserBlueRawDat::writeArrayDB: IOV not in DB")); } 00082 00083 00084 int nrows= data->size(); // to be checked 00085 int* ids= new int[nrows]; 00086 int* iovid_vec= new int[nrows]; 00087 float* xx= new float[nrows]; 00088 float* yy= new float[nrows]; 00089 00090 ub2* ids_len= new ub2[nrows]; 00091 ub2* iov_len= new ub2[nrows]; 00092 ub2* x_len= new ub2[nrows]; 00093 ub2* y_len= new ub2[nrows]; 00094 00095 const EcalLogicID* channel; 00096 const LMFLaserBlueRawDat* dataitem; 00097 int count=0; 00098 typedef map< EcalLogicID, LMFLaserBlueRawDat >::const_iterator CI; 00099 for (CI p = data->begin(); p != data->end(); ++p) { 00100 channel = &(p->first); 00101 int logicID = channel->getLogicID(); 00102 if (!logicID) { throw(runtime_error("LMFLaserBlueRawDat::writeArrayDB: Bad EcalLogicID")); } 00103 ids[count]=logicID; 00104 iovid_vec[count]=iovID; 00105 00106 dataitem = &(p->second); 00107 // dataIface.writeDB( channel, dataitem, iov); 00108 float x=dataitem->getAPDPeak(); 00109 float y=dataitem->getAPDErr(); 00110 00111 xx[count]=x; 00112 yy[count]=y; 00113 ids_len[count]=sizeof(ids[count]); 00114 iov_len[count]=sizeof(iovid_vec[count]); 00115 00116 x_len[count]=sizeof(xx[count]); 00117 y_len[count]=sizeof(yy[count]); 00118 00119 count++; 00120 } 00121 00122 00123 try { 00124 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len); 00125 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len ); 00126 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len ); 00127 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len ); 00128 //m_writeStmt->setFloat(3, item->getAPDPeak() ); 00129 // m_writeStmt->setFloat(4, item->getAPDErr() ); 00130 00131 m_writeStmt->executeArrayUpdate(nrows); 00132 00133 delete [] ids; 00134 delete [] iovid_vec; 00135 delete [] xx; 00136 delete [] yy; 00137 00138 delete [] ids_len; 00139 delete [] iov_len; 00140 delete [] x_len; 00141 delete [] y_len; 00142 00143 00144 00145 } catch (SQLException &e) { 00146 throw(runtime_error("LMFLaserBlueRawDat::writeArryaDB(): "+e.getMessage())); 00147 } 00148 }
void LMFLaserBlueRawDat::writeDB | ( | const EcalLogicID * | ecid, | |
const LMFLaserBlueRawDat * | item, | |||
LMFRunIOV * | iov | |||
) | throw (std::runtime_error) [private] |
Definition at line 49 of file LMFLaserBlueRawDat.cc.
References IDBObject::checkConnection(), IDataItem::checkPrepare(), e, and IDataItem::m_writeStmt.
00051 { 00052 this->checkConnection(); 00053 this->checkPrepare(); 00054 00055 int iovID = iov->fetchID(); 00056 if (!iovID) { throw(runtime_error("LMFLaserBlueRawDat::writeDB: IOV not in DB")); } 00057 00058 int logicID = ecid->getLogicID(); 00059 if (!logicID) { throw(runtime_error("LMFLaserBlueRawDat::writeDB: Bad EcalLogicID")); } 00060 00061 try { 00062 m_writeStmt->setInt(1, iovID); 00063 m_writeStmt->setInt(2, logicID); 00064 00065 m_writeStmt->setFloat(3, item->getAPDPeak() ); 00066 m_writeStmt->setFloat(4, item->getAPDErr() ); 00067 00068 m_writeStmt->executeUpdate(); 00069 } catch (SQLException &e) { 00070 throw(runtime_error("LMFLaserBlueRawDat::writeDB(): "+e.getMessage())); 00071 } 00072 }
friend class EcalCondDBInterface [friend] |
float LMFLaserBlueRawDat::m_apdErr [private] |
Definition at line 43 of file LMFLaserBlueRawDat.h.
Referenced by getAPDErr(), LMFLaserBlueRawDat(), and setAPDErr().
float LMFLaserBlueRawDat::m_apdPeak [private] |
Definition at line 42 of file LMFLaserBlueRawDat.h.
Referenced by getAPDPeak(), LMFLaserBlueRawDat(), and setAPDPeak().