#include <OnlineDB/EcalCondDB/interface/FEConfigPedDat.h>
Public Member Functions | |
FEConfigPedDat () | |
int | getId () const |
float | getPedMeanG1 () const |
float | getPedMeanG12 () const |
float | getPedMeanG6 () const |
std::string | getTable () |
void | setId (int x) |
void | setPedMeanG1 (float mean) |
void | setPedMeanG12 (float mean) |
void | setPedMeanG6 (float mean) |
~FEConfigPedDat () | |
Private Member Functions | |
void | fetchData (map< EcalLogicID, FEConfigPedDat > *fillMap, FEConfigPedInfo *iconf) throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | writeArrayDB (const std::map< EcalLogicID, FEConfigPedDat > *data, FEConfigPedInfo *iconf) throw (std::runtime_error) |
void | writeDB (const EcalLogicID *ecid, const FEConfigPedDat *item, FEConfigPedInfo *iconf) throw (std::runtime_error) |
Private Attributes | |
int | m_ID |
float | m_pedMeanG1 |
float | m_pedMeanG12 |
float | m_pedMeanG6 |
Friends | |
class | EcalCondDBInterface |
Definition at line 11 of file FEConfigPedDat.h.
FEConfigPedDat::FEConfigPedDat | ( | ) |
Definition at line 11 of file FEConfigPedDat.cc.
References IDBObject::m_conn, IDBObject::m_env, m_ID, m_pedMeanG1, m_pedMeanG12, m_pedMeanG6, IDataItem::m_readStmt, IDataItem::m_writeStmt, and NULL.
00012 { 00013 m_env = NULL; 00014 m_conn = NULL; 00015 m_writeStmt = NULL; 00016 m_readStmt = NULL; 00017 m_ID=0; 00018 m_pedMeanG1 = 0; 00019 m_pedMeanG6 = 0; 00020 m_pedMeanG12 = 0; 00021 00022 }
FEConfigPedDat::~FEConfigPedDat | ( | ) |
void FEConfigPedDat::fetchData | ( | map< EcalLogicID, FEConfigPedDat > * | fillMap, | |
FEConfigPedInfo * | iconf | |||
) | throw (std::runtime_error) [private] |
Definition at line 75 of file FEConfigPedDat.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setPedMeanG1(), setPedMeanG12(), and setPedMeanG6().
00077 { 00078 this->checkConnection(); 00079 fillMap->clear(); 00080 00081 iconf->setConnection(m_env, m_conn); 00082 int iconfID = iconf->fetchID(); 00083 if (!iconfID) { 00084 // throw(runtime_error("FEConfigPedDat::writeDB: ICONF not in DB")); 00085 return; 00086 } 00087 00088 try { 00089 00090 m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 00091 "d.mean_12, d.mean_6, d.mean_1 " 00092 "FROM channelview cv JOIN fe_config_ped_dat d " 00093 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 00094 "WHERE ped_conf_id = :ped_conf_id"); 00095 m_readStmt->setInt(1, iconfID); 00096 ResultSet* rset = m_readStmt->executeQuery(); 00097 00098 std::pair< EcalLogicID, FEConfigPedDat > p; 00099 FEConfigPedDat dat; 00100 while(rset->next()) { 00101 p.first = EcalLogicID( rset->getString(1), // name 00102 rset->getInt(2), // logic_id 00103 rset->getInt(3), // id1 00104 rset->getInt(4), // id2 00105 rset->getInt(5), // id3 00106 rset->getString(6)); // maps_to 00107 00108 dat.setPedMeanG12( rset->getFloat(7) ); 00109 dat.setPedMeanG6( rset->getFloat(8) ); 00110 dat.setPedMeanG1( rset->getFloat(9) ); 00111 00112 p.second = dat; 00113 fillMap->insert(p); 00114 } 00115 } catch (SQLException &e) { 00116 throw(runtime_error("FEConfigPedDat::fetchData: "+e.getMessage())); 00117 } 00118 }
int FEConfigPedDat::getId | ( | ) | const [inline] |
float FEConfigPedDat::getPedMeanG1 | ( | ) | const [inline] |
Definition at line 24 of file FEConfigPedDat.h.
References m_pedMeanG1.
Referenced by EcalTPGDBApp::readFromConfDB_TPGPedestals(), and writeArrayDB().
00024 { return m_pedMeanG1; }
float FEConfigPedDat::getPedMeanG12 | ( | ) | const [inline] |
Definition at line 30 of file FEConfigPedDat.h.
References m_pedMeanG12.
Referenced by EcalTPGDBApp::readFromConfDB_TPGPedestals(), and writeArrayDB().
00030 { return m_pedMeanG12; }
float FEConfigPedDat::getPedMeanG6 | ( | ) | const [inline] |
Definition at line 27 of file FEConfigPedDat.h.
References m_pedMeanG6.
Referenced by EcalTPGDBApp::readFromConfDB_TPGPedestals(), and writeArrayDB().
00027 { return m_pedMeanG6; }
std::string FEConfigPedDat::getTable | ( | ) | [inline, virtual] |
void FEConfigPedDat::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IDataItem.
Definition at line 31 of file FEConfigPedDat.cc.
References IDBObject::checkConnection(), e, getTable(), IDBObject::m_conn, and IDataItem::m_writeStmt.
00033 { 00034 this->checkConnection(); 00035 00036 try { 00037 m_writeStmt = m_conn->createStatement(); 00038 00039 m_writeStmt->setSQL("INSERT INTO "+getTable()+" (ped_conf_id, logic_id, " 00040 "mean_12, mean_6, mean_1 ) " 00041 "VALUES (:ped_conf_id, :logic_id, " 00042 ":ped_mean_g12, :ped_mean_g6, :ped_mean_g1 )" ); 00043 } catch (SQLException &e) { 00044 throw(runtime_error("FEConfigPedDat::prepareWrite(): "+e.getMessage())); 00045 } 00046 }
void FEConfigPedDat::setPedMeanG1 | ( | float | mean | ) | [inline] |
Definition at line 23 of file FEConfigPedDat.h.
References m_pedMeanG1.
Referenced by EcalTPGParamBuilder::analyze(), and fetchData().
00023 { m_pedMeanG1 = mean; }
void FEConfigPedDat::setPedMeanG12 | ( | float | mean | ) | [inline] |
Definition at line 29 of file FEConfigPedDat.h.
References m_pedMeanG12.
Referenced by EcalTPGParamBuilder::analyze(), and fetchData().
00029 { m_pedMeanG12 = mean; }
void FEConfigPedDat::setPedMeanG6 | ( | float | mean | ) | [inline] |
Definition at line 26 of file FEConfigPedDat.h.
References m_pedMeanG6.
Referenced by EcalTPGParamBuilder::analyze(), and fetchData().
00026 { m_pedMeanG6 = mean; }
void FEConfigPedDat::writeArrayDB | ( | const std::map< EcalLogicID, FEConfigPedDat > * | data, | |
FEConfigPedInfo * | iconf | |||
) | throw (std::runtime_error) [private] |
Definition at line 120 of file FEConfigPedDat.cc.
References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, EcalLogicID::getLogicID(), getPedMeanG1(), getPedMeanG12(), getPedMeanG6(), IDataItem::m_writeStmt, p, x, y, and z.
00122 { 00123 this->checkConnection(); 00124 this->checkPrepare(); 00125 00126 int iconfID = iconf->fetchID(); 00127 if (!iconfID) { throw(runtime_error("FEConfigPedDat::writeArrayDB: ICONF not in DB")); } 00128 00129 00130 int nrows=data->size(); 00131 int* ids= new int[nrows]; 00132 int* iconfid_vec= new int[nrows]; 00133 float* xx= new float[nrows]; 00134 float* yy= new float[nrows]; 00135 float* zz= new float[nrows]; 00136 00137 00138 ub2* ids_len= new ub2[nrows]; 00139 ub2* iconf_len= new ub2[nrows]; 00140 ub2* x_len= new ub2[nrows]; 00141 ub2* y_len= new ub2[nrows]; 00142 ub2* z_len= new ub2[nrows]; 00143 00144 00145 const EcalLogicID* channel; 00146 const FEConfigPedDat* dataitem; 00147 int count=0; 00148 typedef map< EcalLogicID, FEConfigPedDat >::const_iterator CI; 00149 for (CI p = data->begin(); p != data->end(); ++p) { 00150 channel = &(p->first); 00151 int logicID = channel->getLogicID(); 00152 if (!logicID) { throw(runtime_error("FEConfigPedDat::writeArrayDB: Bad EcalLogicID")); } 00153 ids[count]=logicID; 00154 iconfid_vec[count]=iconfID; 00155 00156 dataitem = &(p->second); 00157 // dataIface.writeDB( channel, dataitem, iconf); 00158 float x=dataitem->getPedMeanG12(); 00159 float y=dataitem->getPedMeanG6(); 00160 float z=dataitem->getPedMeanG1(); 00161 00162 xx[count]=x; 00163 yy[count]=y; 00164 zz[count]=z; 00165 00166 ids_len[count]=sizeof(ids[count]); 00167 iconf_len[count]=sizeof(iconfid_vec[count]); 00168 00169 x_len[count]=sizeof(xx[count]); 00170 y_len[count]=sizeof(yy[count]); 00171 z_len[count]=sizeof(zz[count]); 00172 00173 count++; 00174 } 00175 00176 00177 try { 00178 m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]),iconf_len); 00179 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len ); 00180 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len ); 00181 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len ); 00182 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT , sizeof(zz[0]), z_len ); 00183 00184 m_writeStmt->executeArrayUpdate(nrows); 00185 00186 delete [] ids; 00187 delete [] iconfid_vec; 00188 delete [] xx; 00189 delete [] yy; 00190 delete [] zz; 00191 00192 delete [] ids_len; 00193 delete [] iconf_len; 00194 delete [] x_len; 00195 delete [] y_len; 00196 delete [] z_len; 00197 00198 } catch (SQLException &e) { 00199 throw(runtime_error("FEConfigPedDat::writeArrayDB(): "+e.getMessage())); 00200 } 00201 }
void FEConfigPedDat::writeDB | ( | const EcalLogicID * | ecid, | |
const FEConfigPedDat * | item, | |||
FEConfigPedInfo * | iconf | |||
) | throw (std::runtime_error) [private] |
Definition at line 50 of file FEConfigPedDat.cc.
References IDBObject::checkConnection(), e, and IDataItem::m_writeStmt.
00052 { 00053 this->checkConnection(); 00054 00055 int iconfID = iconf->fetchID(); 00056 if (!iconfID) { throw(runtime_error("FEConfigPedDat::writeDB: ICONF not in DB")); } 00057 00058 int logicID = ecid->getLogicID(); 00059 if (!logicID) { throw(runtime_error("FEConfigPedDat::writeDB: Bad EcalLogicID")); } 00060 00061 try { 00062 m_writeStmt->setInt(1, iconfID); 00063 m_writeStmt->setInt(2, logicID); 00064 m_writeStmt->setFloat(3, item->getPedMeanG12()); 00065 m_writeStmt->setFloat(4, item->getPedMeanG6()); 00066 m_writeStmt->setFloat(5, item->getPedMeanG1()); 00067 00068 m_writeStmt->executeUpdate(); 00069 } catch (SQLException &e) { 00070 throw(runtime_error("FEConfigPedDat::writeDB(): "+e.getMessage())); 00071 } 00072 }
friend class EcalCondDBInterface [friend] |
int FEConfigPedDat::m_ID [private] |
Definition at line 50 of file FEConfigPedDat.h.
Referenced by FEConfigPedDat(), getId(), and setId().
float FEConfigPedDat::m_pedMeanG1 [private] |
Definition at line 47 of file FEConfigPedDat.h.
Referenced by FEConfigPedDat(), getPedMeanG1(), and setPedMeanG1().
float FEConfigPedDat::m_pedMeanG12 [private] |
Definition at line 49 of file FEConfigPedDat.h.
Referenced by FEConfigPedDat(), getPedMeanG12(), and setPedMeanG12().
float FEConfigPedDat::m_pedMeanG6 [private] |
Definition at line 48 of file FEConfigPedDat.h.
Referenced by FEConfigPedDat(), getPedMeanG6(), and setPedMeanG6().