CMS 3D CMS Logo

MonLed2Dat Class Reference

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

Inheritance diagram for MonLed2Dat:

IDataItem IDBObject

List of all members.

Public Member Functions

std::string getTable ()
bool getTaskStatus () const
float getVPTMean () const
float getVPTOverPNMean () const
float getVPTOverPNRMS () const
float getVPTRMS () const
 MonLed2Dat ()
void setTaskStatus (bool status)
void setVPTMean (float mean)
void setVPTOverPNMean (float mean)
void setVPTOverPNRMS (float rms)
void setVPTRMS (float rms)
 ~MonLed2Dat ()

Private Member Functions

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

Private Attributes

bool m_taskStatus
float m_vptMean
float m_vptOverPNMean
float m_vptOverPNRMS
float m_vptRMS

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file MonLed2Dat.h.


Constructor & Destructor Documentation

MonLed2Dat::MonLed2Dat (  ) 

Definition at line 10 of file MonLed2Dat.cc.

References IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, m_taskStatus, m_vptMean, m_vptOverPNMean, m_vptOverPNRMS, m_vptRMS, 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_vptMean = 0;
00018   m_vptRMS = 0;
00019   m_vptOverPNMean = 0;
00020   m_vptOverPNRMS = 0;
00021   m_taskStatus = 0;
00022   
00023 }

MonLed2Dat::~MonLed2Dat (  ) 

Definition at line 27 of file MonLed2Dat.cc.

00028 {
00029 }


Member Function Documentation

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

Definition at line 81 of file MonLed2Dat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setTaskStatus(), setVPTMean(), setVPTOverPNMean(), setVPTOverPNRMS(), and setVPTRMS().

00083 {
00084   this->checkConnection();
00085 
00086   fillMap->clear();
00087 
00088   iov->setConnection(m_env, m_conn);
00089   int iovID = iov->fetchID();
00090   if (!iovID) { 
00091     //  throw(runtime_error("MonLed2Dat::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.vpt_mean, d.vpt_rms, d.vpt_over_pn_mean, d.vpt_over_pn_rms, d.task_status "
00099                  "FROM channelview cv JOIN mon_led2_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, MonLed2Dat > p;
00106     MonLed2Dat 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.setVPTMean( rset->getFloat(7) );
00116       dat.setVPTRMS( rset->getFloat(8) );
00117       dat.setVPTOverPNMean( rset->getFloat(9) );
00118       dat.setVPTOverPNRMS( rset->getFloat(10) );
00119       dat.setTaskStatus( rset->getInt(11) );
00120                         
00121 
00122       p.second = dat;
00123       fillMap->insert(p);
00124     }
00125   } catch (SQLException &e) {
00126     throw(runtime_error("MonLed2Dat::fetchData():  "+e.getMessage()));
00127   }
00128 }

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

Implements IDataItem.

Definition at line 19 of file MonLed2Dat.h.

00019 { return "MON_LED2_DAT"; }

bool MonLed2Dat::getTaskStatus (  )  const [inline]

Definition at line 34 of file MonLed2Dat.h.

References m_taskStatus.

Referenced by writeArrayDB().

00034 { return m_taskStatus; }

float MonLed2Dat::getVPTMean (  )  const [inline]

Definition at line 22 of file MonLed2Dat.h.

References m_vptMean.

Referenced by writeArrayDB().

00022 { return m_vptMean; }

float MonLed2Dat::getVPTOverPNMean (  )  const [inline]

Definition at line 28 of file MonLed2Dat.h.

References m_vptOverPNMean.

Referenced by writeArrayDB().

00028 { return m_vptOverPNMean; }

float MonLed2Dat::getVPTOverPNRMS (  )  const [inline]

Definition at line 31 of file MonLed2Dat.h.

References m_vptOverPNRMS.

Referenced by writeArrayDB().

00031 { return m_vptOverPNRMS; }

float MonLed2Dat::getVPTRMS (  )  const [inline]

Definition at line 25 of file MonLed2Dat.h.

References m_vptRMS.

Referenced by writeArrayDB().

00025 { return m_vptRMS; }

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

Implements IDataItem.

Definition at line 33 of file MonLed2Dat.cc.

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

00035 {
00036   this->checkConnection();
00037 
00038   try {
00039     m_writeStmt = m_conn->createStatement();
00040     m_writeStmt->setSQL("INSERT INTO mon_led2_dat (iov_id, logic_id, "
00041                         "vpt_mean, vpt_rms, vpt_over_pn_mean, vpt_over_pn_rms, task_status) "
00042                         "VALUES (:iov_id, :logic_id, "
00043                         ":vpt_mean, :vpt_rms, :vpt_over_pn_mean, :vpt_over_pn_rms, :task_status)");
00044   } catch (SQLException &e) {
00045     throw(runtime_error("MonLed2Dat::prepareWrite():  "+e.getMessage()));
00046   }
00047 }

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

Definition at line 33 of file MonLed2Dat.h.

References m_taskStatus.

Referenced by fetchData(), and EELedClient::writeDb().

00033 { m_taskStatus = status; }

void MonLed2Dat::setVPTMean ( float  mean  )  [inline]

Definition at line 21 of file MonLed2Dat.h.

References m_vptMean.

Referenced by fetchData(), and EELedClient::writeDb().

00021 { m_vptMean = mean; }

void MonLed2Dat::setVPTOverPNMean ( float  mean  )  [inline]

Definition at line 27 of file MonLed2Dat.h.

References m_vptOverPNMean.

Referenced by fetchData(), and EELedClient::writeDb().

00027 { m_vptOverPNMean = mean; }

void MonLed2Dat::setVPTOverPNRMS ( float  rms  )  [inline]

Definition at line 30 of file MonLed2Dat.h.

References m_vptOverPNRMS.

Referenced by fetchData(), and EELedClient::writeDb().

00030 { m_vptOverPNRMS = rms; }

void MonLed2Dat::setVPTRMS ( float  rms  )  [inline]

Definition at line 24 of file MonLed2Dat.h.

References m_vptRMS.

Referenced by fetchData(), and EELedClient::writeDb().

00024 { m_vptRMS = rms; }

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

Definition at line 130 of file MonLed2Dat.cc.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, EcalLogicID::getLogicID(), getTaskStatus(), getVPTMean(), getVPTOverPNMean(), getVPTOverPNRMS(), getVPTRMS(), IDataItem::m_writeStmt, p, st, w, ww, x, y, and z.

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

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

Definition at line 51 of file MonLed2Dat.cc.

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

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


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file MonLed2Dat.h.


Member Data Documentation

bool MonLed2Dat::m_taskStatus [private]

Definition at line 55 of file MonLed2Dat.h.

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

float MonLed2Dat::m_vptMean [private]

Definition at line 51 of file MonLed2Dat.h.

Referenced by getVPTMean(), MonLed2Dat(), and setVPTMean().

float MonLed2Dat::m_vptOverPNMean [private]

Definition at line 53 of file MonLed2Dat.h.

Referenced by getVPTOverPNMean(), MonLed2Dat(), and setVPTOverPNMean().

float MonLed2Dat::m_vptOverPNRMS [private]

Definition at line 54 of file MonLed2Dat.h.

Referenced by getVPTOverPNRMS(), MonLed2Dat(), and setVPTOverPNRMS().

float MonLed2Dat::m_vptRMS [private]

Definition at line 52 of file MonLed2Dat.h.

Referenced by getVPTRMS(), MonLed2Dat(), and setVPTRMS().


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