CMS 3D CMS Logo

MonPNPedDat Class Reference

#include <OnlineDB/EcalCondDB/interface/MonPNPedDat.h>

Inheritance diagram for MonPNPedDat:

IDataItem IDBObject

List of all members.

Public Member Functions

float getPedMeanG1 () const
float getPedMeanG16 () const
float getPedRMSG1 () const
float getPedRMSG16 () const
std::string getTable ()
bool getTaskStatus () const
 MonPNPedDat ()
void setPedMeanG1 (float mean)
void setPedMeanG16 (float mean)
void setPedRMSG1 (float mean)
void setPedRMSG16 (float mean)
void setTaskStatus (bool status)
 ~MonPNPedDat ()

Private Member Functions

void fetchData (std::map< EcalLogicID, MonPNPedDat > *fillVec, MonRunIOV *iov) throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeArrayDB (const std::map< EcalLogicID, MonPNPedDat > *data, MonRunIOV *iov) throw (std::runtime_error)
void writeDB (const EcalLogicID *ecid, const MonPNPedDat *item, MonRunIOV *iov) throw (std::runtime_error)

Private Attributes

float m_pedMeanG1
float m_pedMeanG16
float m_pedRMSG1
float m_pedRMSG16
bool m_taskStatus

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file MonPNPedDat.h.


Constructor & Destructor Documentation

MonPNPedDat::MonPNPedDat (  ) 

Definition at line 12 of file MonPNPedDat.cc.

References IDBObject::m_conn, IDBObject::m_env, m_pedMeanG1, m_pedMeanG16, m_pedRMSG1, m_pedRMSG16, IDataItem::m_readStmt, m_taskStatus, 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_pedMeanG1 = 0;
00020   m_pedRMSG1 = 0;
00021   m_pedMeanG16 = 0;
00022   m_pedRMSG16 = 0;
00023   m_taskStatus = 0;
00024 }

MonPNPedDat::~MonPNPedDat (  ) 

Definition at line 28 of file MonPNPedDat.cc.

00029 {
00030 }


Member Function Documentation

void MonPNPedDat::fetchData ( std::map< EcalLogicID, MonPNPedDat > *  fillVec,
MonRunIOV iov 
) throw (std::runtime_error) [private]

Definition at line 82 of file MonPNPedDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setPedMeanG1(), setPedMeanG16(), setPedRMSG1(), setPedRMSG16(), and setTaskStatus().

00084 {
00085   this->checkConnection();
00086   fillMap->clear();
00087 
00088   iov->setConnection(m_env, m_conn);
00089   int iovID = iov->fetchID();
00090   if (!iovID) { 
00091     //  throw(runtime_error("MonPNPedDat::writeDB:  IOV not in DB")); 
00092     return;
00093   }
00094 
00095   try {
00096 
00097     m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
00098                  "d.ped_mean_g1,d.ped_rms_g1, d.ped_mean_g16, d.ped_rms_g16, d.task_status "
00099                  "FROM channelview cv JOIN mon_pn_ped_dat d "
00100                  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
00101                  "WHERE d.iov_id = :iov_id");
00102     m_readStmt->setInt(1, iovID);
00103     ResultSet* rset = m_readStmt->executeQuery();
00104     
00105     std::pair< EcalLogicID, MonPNPedDat > p;
00106     MonPNPedDat dat;
00107     while(rset->next()) {
00108       p.first = EcalLogicID( rset->getString(1),     // name
00109                              rset->getInt(2),        // logic_id
00110                              rset->getInt(3),        // id1
00111                              rset->getInt(4),        // id2
00112                              rset->getInt(5),        // id3
00113                              rset->getString(6));    // maps_to
00114 
00115       dat.setPedMeanG1( rset->getFloat(7) );
00116       dat.setPedRMSG1( rset->getFloat(8) );
00117       dat.setPedMeanG16( rset->getFloat(9) );
00118       dat.setPedRMSG16( rset->getFloat(10) );
00119       dat.setTaskStatus( rset->getInt(11) );
00120       p.second = dat;
00121       fillMap->insert(p);
00122     }
00123   } catch (SQLException &e) {
00124     throw(runtime_error("MonPNPedDat::fetchData():  "+e.getMessage()));
00125   }
00126 }

float MonPNPedDat::getPedMeanG1 (  )  const [inline]

Definition at line 22 of file MonPNPedDat.h.

References m_pedMeanG1.

Referenced by writeArrayDB().

00022 { return m_pedMeanG1; }

float MonPNPedDat::getPedMeanG16 (  )  const [inline]

Definition at line 28 of file MonPNPedDat.h.

References m_pedMeanG16.

Referenced by writeArrayDB().

00028 { return m_pedMeanG16; }

float MonPNPedDat::getPedRMSG1 (  )  const [inline]

Definition at line 25 of file MonPNPedDat.h.

References m_pedRMSG1.

Referenced by writeArrayDB().

00025 { return m_pedRMSG1; }

float MonPNPedDat::getPedRMSG16 (  )  const [inline]

Definition at line 31 of file MonPNPedDat.h.

References m_pedRMSG16.

Referenced by writeArrayDB().

00031 { return m_pedRMSG16; }

std::string MonPNPedDat::getTable (  )  [inline, virtual]

Implements IDataItem.

Definition at line 19 of file MonPNPedDat.h.

00019 { return "MON_PN_PED_DAT"; }

bool MonPNPedDat::getTaskStatus (  )  const [inline]

Definition at line 34 of file MonPNPedDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

00034 { return m_taskStatus; }

void MonPNPedDat::prepareWrite (  )  throw (std::runtime_error) [private, virtual]

Implements IDataItem.

Definition at line 34 of file MonPNPedDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, and IDataItem::m_writeStmt.

00036 {
00037   this->checkConnection();
00038 
00039   try {
00040     m_writeStmt = m_conn->createStatement();
00041     m_writeStmt->setSQL("INSERT INTO mon_pn_ped_dat (iov_id, logic_id, "
00042                         "ped_mean_g1, ped_rms_g1, ped_mean_g16, ped_rms_g16, task_status) "
00043                         "VALUES (:iov_id, :logic_id, "
00044                         ":3, :4, :5, :6, :7)");
00045   } catch (SQLException &e) {
00046     throw(runtime_error("MonPNPedDat::prepareWrite():  "+e.getMessage()));
00047   }
00048 }

void MonPNPedDat::setPedMeanG1 ( float  mean  )  [inline]

Definition at line 21 of file MonPNPedDat.h.

References m_pedMeanG1.

Referenced by fetchData(), EBPedestalClient::writeDb(), and EEPedestalClient::writeDb().

00021 { m_pedMeanG1 = mean; }

void MonPNPedDat::setPedMeanG16 ( float  mean  )  [inline]

Definition at line 27 of file MonPNPedDat.h.

References m_pedMeanG16.

Referenced by fetchData(), EBPedestalClient::writeDb(), and EEPedestalClient::writeDb().

00027 { m_pedMeanG16 = mean; }

void MonPNPedDat::setPedRMSG1 ( float  mean  )  [inline]

Definition at line 24 of file MonPNPedDat.h.

References m_pedRMSG1.

Referenced by fetchData(), EBPedestalClient::writeDb(), and EEPedestalClient::writeDb().

00024 { m_pedRMSG1 = mean; }

void MonPNPedDat::setPedRMSG16 ( float  mean  )  [inline]

Definition at line 30 of file MonPNPedDat.h.

References m_pedRMSG16.

Referenced by fetchData(), EBPedestalClient::writeDb(), and EEPedestalClient::writeDb().

00030 { m_pedRMSG16 = mean; }

void MonPNPedDat::setTaskStatus ( bool  status  )  [inline]

Definition at line 33 of file MonPNPedDat.h.

References m_taskStatus.

Referenced by fetchData(), EBPedestalClient::writeDb(), and EEPedestalClient::writeDb().

00033 { m_taskStatus = status; }

void MonPNPedDat::writeArrayDB ( const std::map< EcalLogicID, MonPNPedDat > *  data,
MonRunIOV iov 
) throw (std::runtime_error) [private]

Definition at line 128 of file MonPNPedDat.cc.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, EcalLogicID::getLogicID(), getPedMeanG1(), getPedMeanG16(), getPedRMSG1(), getPedRMSG16(), getTaskStatus(), IDataItem::m_writeStmt, p, st, w, ww, x, y, and z.

00130 {
00131   this->checkConnection();
00132   this->checkPrepare();
00133 
00134   int iovID = iov->fetchID();
00135   if (!iovID) { throw(runtime_error("MonPNPedDat::writeArrayDB:  IOV not in DB")); }
00136 
00137 
00138   int nrows=data->size(); 
00139   int* ids= new int[nrows];
00140   int* iovid_vec= new int[nrows];
00141   float* xx= new float[nrows];
00142   float* yy= new float[nrows];
00143   float* zz= new float[nrows];
00144   float* ww= new float[nrows];
00145   int* st= new int[nrows];
00146 
00147   ub2* ids_len= new ub2[nrows];
00148   ub2* iov_len= new ub2[nrows];
00149   ub2* x_len= new ub2[nrows];
00150   ub2* y_len= new ub2[nrows];
00151   ub2* z_len= new ub2[nrows];
00152   ub2* w_len= new ub2[nrows];
00153 
00154   ub2* st_len= new ub2[nrows];
00155 
00156   const EcalLogicID* channel;
00157   const MonPNPedDat* dataitem;
00158   int count=0;
00159   typedef map< EcalLogicID, MonPNPedDat >::const_iterator CI;
00160   for (CI p = data->begin(); p != data->end(); ++p) {
00161         channel = &(p->first);
00162         int logicID = channel->getLogicID();
00163         if (!logicID) { throw(runtime_error("MonPNPedDat::writeArrayDB:  Bad EcalLogicID")); }
00164         ids[count]=logicID;
00165         iovid_vec[count]=iovID;
00166 
00167         dataitem = &(p->second);
00168         // dataIface.writeDB( channel, dataitem, iov);
00169         float x=dataitem->getPedMeanG1();
00170         float y=dataitem->getPedRMSG1();
00171         float z=dataitem->getPedMeanG16();
00172         float w=dataitem->getPedRMSG16();
00173         int statu=dataitem->getTaskStatus();
00174 
00175 
00176 
00177         xx[count]=x;
00178         yy[count]=y;
00179         zz[count]=z;
00180         ww[count]=w;
00181 
00182         st[count]=statu;
00183 
00184 
00185         ids_len[count]=sizeof(ids[count]);
00186         iov_len[count]=sizeof(iovid_vec[count]);
00187         
00188         x_len[count]=sizeof(xx[count]);
00189         y_len[count]=sizeof(yy[count]);
00190         z_len[count]=sizeof(zz[count]);
00191         w_len[count]=sizeof(ww[count]);
00192 
00193         st_len[count]=sizeof(st[count]);
00194 
00195         count++;
00196      }
00197 
00198 
00199   try {
00200     m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
00201     m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
00202     m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
00203     m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
00204     m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT , sizeof(zz[0]), z_len );
00205     m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIFLOAT , sizeof(ww[0]), w_len );
00206     m_writeStmt->setDataBuffer(7, (dvoid*)st, OCCIINT , sizeof(st[0]), st_len );
00207    
00208 
00209     m_writeStmt->executeArrayUpdate(nrows);
00210 
00211     delete [] ids;
00212     delete [] iovid_vec;
00213     delete [] xx;
00214     delete [] yy;
00215     delete [] zz;
00216     delete [] ww;
00217 
00218     delete [] st;
00219 
00220     delete [] ids_len;
00221     delete [] iov_len;
00222     delete [] x_len;
00223     delete [] y_len;
00224     delete [] z_len;
00225     delete [] w_len;
00226 
00227     delete [] st_len;
00228 
00229 
00230 
00231   } catch (SQLException &e) {
00232     throw(runtime_error("MonPNPedDat::writeArrayDB():  "+e.getMessage()));
00233   }
00234 }

void MonPNPedDat::writeDB ( const EcalLogicID ecid,
const MonPNPedDat item,
MonRunIOV iov 
) throw (std::runtime_error) [private]

Definition at line 52 of file MonPNPedDat.cc.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), e, and IDataItem::m_writeStmt.

00054 {
00055   this->checkConnection();
00056   this->checkPrepare();
00057 
00058   int iovID = iov->fetchID();
00059   if (!iovID) { throw(runtime_error("MonPNPedDat::writeDB:  IOV not in DB")); }
00060 
00061   int logicID = ecid->getLogicID();
00062   if (!logicID) { throw(runtime_error("MonPNPedDat::writeDB:  Bad EcalLogicID")); }
00063   
00064   try {
00065     m_writeStmt->setInt(1, iovID);
00066     m_writeStmt->setInt(2, logicID);
00067 
00068     m_writeStmt->setFloat(3, item->getPedMeanG1() );
00069     m_writeStmt->setFloat(4, item->getPedRMSG1() );
00070     m_writeStmt->setFloat(5, item->getPedMeanG16() );
00071     m_writeStmt->setFloat(6, item->getPedRMSG16() );
00072     m_writeStmt->setInt(7, item->getTaskStatus() );
00073 
00074     m_writeStmt->executeUpdate();
00075   } catch (SQLException &e) {
00076     throw(runtime_error("MonPNPedDat::writeDB():  "+e.getMessage()));
00077   }
00078 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file MonPNPedDat.h.


Member Data Documentation

float MonPNPedDat::m_pedMeanG1 [private]

Definition at line 52 of file MonPNPedDat.h.

Referenced by getPedMeanG1(), MonPNPedDat(), and setPedMeanG1().

float MonPNPedDat::m_pedMeanG16 [private]

Definition at line 54 of file MonPNPedDat.h.

Referenced by getPedMeanG16(), MonPNPedDat(), and setPedMeanG16().

float MonPNPedDat::m_pedRMSG1 [private]

Definition at line 53 of file MonPNPedDat.h.

Referenced by getPedRMSG1(), MonPNPedDat(), and setPedRMSG1().

float MonPNPedDat::m_pedRMSG16 [private]

Definition at line 55 of file MonPNPedDat.h.

Referenced by getPedRMSG16(), MonPNPedDat(), and setPedRMSG16().

bool MonPNPedDat::m_taskStatus [private]

Definition at line 56 of file MonPNPedDat.h.

Referenced by getTaskStatus(), MonPNPedDat(), and setTaskStatus().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:28:24 2009 for CMSSW by  doxygen 1.5.4