#include <OnlineDB/EcalCondDB/interface/MonOccupancyDat.h>
Public Member Functions | |
float | getAvgEnergy () const |
int | getEventsOverHighThreshold () const |
int | getEventsOverLowThreshold () const |
std::string | getTable () |
MonOccupancyDat () | |
void | setAvgEnergy (float energy) |
void | setEventsOverHighThreshold (int events) |
void | setEventsOverLowThreshold (int events) |
~MonOccupancyDat () | |
Private Member Functions | |
void | fetchData (std::map< EcalLogicID, MonOccupancyDat > *fillVec, MonRunIOV *iov) throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | writeArrayDB (const std::map< EcalLogicID, MonOccupancyDat > *data, MonRunIOV *iov) throw (std::runtime_error) |
void | writeDB (const EcalLogicID *ecid, const MonOccupancyDat *item, MonRunIOV *iov) throw (std::runtime_error) |
Private Attributes | |
float | m_avgEnergy |
int | m_eventsOverHighThreshold |
int | m_eventsOverLowThreshold |
Friends | |
class | EcalCondDBInterface |
Definition at line 12 of file MonOccupancyDat.h.
MonOccupancyDat::MonOccupancyDat | ( | ) |
Definition at line 10 of file MonOccupancyDat.cc.
References m_avgEnergy, IDBObject::m_conn, IDBObject::m_env, m_eventsOverHighThreshold, m_eventsOverLowThreshold, IDataItem::m_readStmt, IDataItem::m_writeStmt, and NULL.
00011 { 00012 m_env = NULL; 00013 m_conn = NULL; 00014 m_writeStmt = NULL; 00015 m_readStmt = NULL; 00016 00017 m_eventsOverLowThreshold = 0; 00018 m_eventsOverHighThreshold = 0; 00019 m_avgEnergy = 0; 00020 }
MonOccupancyDat::~MonOccupancyDat | ( | ) |
void MonOccupancyDat::fetchData | ( | std::map< EcalLogicID, MonOccupancyDat > * | fillVec, | |
MonRunIOV * | iov | |||
) | throw (std::runtime_error) [private] |
Definition at line 76 of file MonOccupancyDat.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setAvgEnergy(), setEventsOverHighThreshold(), and setEventsOverLowThreshold().
00078 { 00079 this->checkConnection(); 00080 fillMap->clear(); 00081 00082 iov->setConnection(m_env, m_conn); 00083 int iovID = iov->fetchID(); 00084 if (!iovID) { 00085 // throw(runtime_error("MonOccupancyDat::writeDB: IOV not in DB")); 00086 return; 00087 } 00088 00089 try { 00090 00091 m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 00092 "d.events_over_low_threshold, d.events_over_high_threshold, d.avg_energy " 00093 "FROM channelview cv JOIN mon_occupancy_dat d " 00094 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 00095 "WHERE d.iov_id = :iov_id"); 00096 m_readStmt->setInt(1, iovID); 00097 ResultSet* rset = m_readStmt->executeQuery(); 00098 00099 std::pair< EcalLogicID, MonOccupancyDat > p; 00100 MonOccupancyDat dat; 00101 while(rset->next()) { 00102 p.first = EcalLogicID( rset->getString(1), // name 00103 rset->getInt(2), // logic_id 00104 rset->getInt(3), // id1 00105 rset->getInt(4), // id2 00106 rset->getInt(5), // id3 00107 rset->getString(6)); // maps_to 00108 00109 dat.setEventsOverLowThreshold( rset->getInt(7) ); 00110 dat.setEventsOverHighThreshold( rset->getInt(8) ); 00111 dat.setAvgEnergy( rset->getFloat(9) ); 00112 00113 p.second = dat; 00114 fillMap->insert(p); 00115 } 00116 } catch (SQLException &e) { 00117 throw(runtime_error("MonOccupancyDat::fetchData(): "+e.getMessage())); 00118 } 00119 }
float MonOccupancyDat::getAvgEnergy | ( | ) | const [inline] |
Definition at line 28 of file MonOccupancyDat.h.
References m_avgEnergy.
Referenced by writeArrayDB().
00028 { return m_avgEnergy; }
int MonOccupancyDat::getEventsOverHighThreshold | ( | ) | const [inline] |
Definition at line 25 of file MonOccupancyDat.h.
References m_eventsOverHighThreshold.
Referenced by writeArrayDB().
00025 { return m_eventsOverHighThreshold; }
int MonOccupancyDat::getEventsOverLowThreshold | ( | ) | const [inline] |
Definition at line 22 of file MonOccupancyDat.h.
References m_eventsOverLowThreshold.
Referenced by writeArrayDB().
00022 { return m_eventsOverLowThreshold; }
std::string MonOccupancyDat::getTable | ( | ) | [inline, virtual] |
void MonOccupancyDat::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IDataItem.
Definition at line 30 of file MonOccupancyDat.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, and IDataItem::m_writeStmt.
00032 { 00033 this->checkConnection(); 00034 00035 try { 00036 m_writeStmt = m_conn->createStatement(); 00037 m_writeStmt->setSQL("INSERT INTO mon_occupancy_dat (iov_id, logic_id, " 00038 "events_over_low_threshold, events_over_high_threshold, avg_energy) " 00039 "VALUES (:iov_id, :logic_id, " 00040 ":3, :4, :5)"); 00041 } catch (SQLException &e) { 00042 throw(runtime_error("MonOccupancyDat::prepareWrite(): "+e.getMessage())); 00043 } 00044 }
void MonOccupancyDat::setAvgEnergy | ( | float | energy | ) | [inline] |
Definition at line 27 of file MonOccupancyDat.h.
References m_avgEnergy.
Referenced by fetchData(), EECosmicClient::writeDb(), EEBeamCaloClient::writeDb(), EBCosmicClient::writeDb(), and EBBeamCaloClient::writeDb().
00027 { m_avgEnergy = energy; }
Definition at line 24 of file MonOccupancyDat.h.
References m_eventsOverHighThreshold.
Referenced by fetchData(), EECosmicClient::writeDb(), EEBeamCaloClient::writeDb(), EBCosmicClient::writeDb(), and EBBeamCaloClient::writeDb().
00024 { m_eventsOverHighThreshold = events; }
Definition at line 21 of file MonOccupancyDat.h.
References m_eventsOverLowThreshold.
Referenced by fetchData(), EECosmicClient::writeDb(), EEBeamCaloClient::writeDb(), EBCosmicClient::writeDb(), and EBBeamCaloClient::writeDb().
00021 { m_eventsOverLowThreshold = events; }
void MonOccupancyDat::writeArrayDB | ( | const std::map< EcalLogicID, MonOccupancyDat > * | data, | |
MonRunIOV * | iov | |||
) | throw (std::runtime_error) [private] |
Definition at line 121 of file MonOccupancyDat.cc.
References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, getAvgEnergy(), getEventsOverHighThreshold(), getEventsOverLowThreshold(), EcalLogicID::getLogicID(), IDataItem::m_writeStmt, p, x, y, and z.
00123 { 00124 this->checkConnection(); 00125 this->checkPrepare(); 00126 00127 int iovID = iov->fetchID(); 00128 if (!iovID) { throw(runtime_error("MonOccupancyDat::writeArrayDB: IOV not in DB")); } 00129 00130 00131 int nrows=data->size(); 00132 int* ids= new int[nrows]; 00133 int* iovid_vec= new int[nrows]; 00134 int* xx= new int[nrows]; 00135 int* yy= new int[nrows]; 00136 float* zz= new float[nrows]; 00137 00138 ub2* ids_len= new ub2[nrows]; 00139 ub2* iov_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 MonOccupancyDat* dataitem; 00147 int count=0; 00148 typedef map< EcalLogicID, MonOccupancyDat >::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("MonOccupancyDat::writeArrayDB: Bad EcalLogicID")); } 00153 ids[count]=logicID; 00154 iovid_vec[count]=iovID; 00155 00156 dataitem = &(p->second); 00157 // dataIface.writeDB( channel, dataitem, iov); 00158 int x=dataitem->getEventsOverLowThreshold(); 00159 int y=dataitem->getEventsOverHighThreshold(); 00160 float z=dataitem->getAvgEnergy(); 00161 00162 00163 00164 xx[count]=x; 00165 yy[count]=y; 00166 zz[count]=z; 00167 00168 ids_len[count]=sizeof(ids[count]); 00169 iov_len[count]=sizeof(iovid_vec[count]); 00170 00171 x_len[count]=sizeof(xx[count]); 00172 y_len[count]=sizeof(yy[count]); 00173 z_len[count]=sizeof(zz[count]); 00174 00175 count++; 00176 } 00177 00178 00179 try { 00180 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len); 00181 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len ); 00182 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len ); 00183 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len ); 00184 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT , sizeof(zz[0]), z_len ); 00185 00186 m_writeStmt->executeArrayUpdate(nrows); 00187 00188 delete [] ids; 00189 delete [] iovid_vec; 00190 delete [] xx; 00191 delete [] yy; 00192 delete [] zz; 00193 00194 delete [] ids_len; 00195 delete [] iov_len; 00196 delete [] x_len; 00197 delete [] y_len; 00198 delete [] z_len; 00199 00200 00201 } catch (SQLException &e) { 00202 throw(runtime_error("MonOccupancyDat::writeArrayDB(): "+e.getMessage())); 00203 } 00204 }
void MonOccupancyDat::writeDB | ( | const EcalLogicID * | ecid, | |
const MonOccupancyDat * | item, | |||
MonRunIOV * | iov | |||
) | throw (std::runtime_error) [private] |
Definition at line 48 of file MonOccupancyDat.cc.
References IDBObject::checkConnection(), IDataItem::checkPrepare(), e, and IDataItem::m_writeStmt.
00050 { 00051 this->checkConnection(); 00052 this->checkPrepare(); 00053 00054 int iovID = iov->fetchID(); 00055 if (!iovID) { throw(runtime_error("MonOccupancyDat::writeDB: IOV not in DB")); } 00056 00057 int logicID = ecid->getLogicID(); 00058 if (!logicID) { throw(runtime_error("MonOccupancyDat::writeDB: Bad EcalLogicID")); } 00059 00060 try { 00061 m_writeStmt->setInt(1, iovID); 00062 m_writeStmt->setInt(2, logicID); 00063 00064 m_writeStmt->setInt(3, item->getEventsOverLowThreshold() ); 00065 m_writeStmt->setInt(4, item->getEventsOverHighThreshold() ); 00066 m_writeStmt->setFloat(5, item->getAvgEnergy() ); 00067 00068 m_writeStmt->executeUpdate(); 00069 } catch (SQLException &e) { 00070 throw(runtime_error("MonOccupancyDat::writeDB(): "+e.getMessage())); 00071 } 00072 }
friend class EcalCondDBInterface [friend] |
float MonOccupancyDat::m_avgEnergy [private] |
Definition at line 47 of file MonOccupancyDat.h.
Referenced by getAvgEnergy(), MonOccupancyDat(), and setAvgEnergy().
Definition at line 46 of file MonOccupancyDat.h.
Referenced by getEventsOverHighThreshold(), MonOccupancyDat(), and setEventsOverHighThreshold().
int MonOccupancyDat::m_eventsOverLowThreshold [private] |
Definition at line 45 of file MonOccupancyDat.h.
Referenced by getEventsOverLowThreshold(), MonOccupancyDat(), and setEventsOverLowThreshold().