CMS 3D CMS Logo

MonDelaysTTDat Class Reference

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

Inheritance diagram for MonDelaysTTDat:

IDataItem IDBObject

List of all members.

Public Member Functions

float getDelayMean () const
float getDelayRMS () const
std::string getTable ()
bool getTaskStatus () const
 MonDelaysTTDat ()
void setDelayMean (float mean)
void setDelayRMS (float rms)
void setTaskStatus (bool status)
 ~MonDelaysTTDat ()

Private Member Functions

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

Private Attributes

float m_delayMean
float m_delayRMS
bool m_taskStatus

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file MonDelaysTTDat.h.


Constructor & Destructor Documentation

MonDelaysTTDat::MonDelaysTTDat (  ) 

Definition at line 12 of file MonDelaysTTDat.cc.

References IDBObject::m_conn, m_delayMean, m_delayRMS, IDBObject::m_env, 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_delayMean = 0;
00020   m_delayRMS = 0;
00021   m_taskStatus = 0;
00022 }

MonDelaysTTDat::~MonDelaysTTDat (  ) 

Definition at line 26 of file MonDelaysTTDat.cc.

00027 {
00028 }


Member Function Documentation

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

Definition at line 78 of file MonDelaysTTDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setDelayMean(), setDelayRMS(), and setTaskStatus().

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

float MonDelaysTTDat::getDelayMean (  )  const [inline]

Definition at line 22 of file MonDelaysTTDat.h.

References m_delayMean.

Referenced by writeArrayDB().

00022 { return m_delayMean; }

float MonDelaysTTDat::getDelayRMS (  )  const [inline]

Definition at line 25 of file MonDelaysTTDat.h.

References m_delayRMS.

Referenced by writeArrayDB().

00025 { return m_delayRMS; }

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

Implements IDataItem.

Definition at line 19 of file MonDelaysTTDat.h.

00019 { return "MON_DELAYS_TT_DAT"; }

bool MonDelaysTTDat::getTaskStatus (  )  const [inline]

Definition at line 28 of file MonDelaysTTDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

00028 { return m_taskStatus; }

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

Implements IDataItem.

Definition at line 32 of file MonDelaysTTDat.cc.

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

00034 {
00035   this->checkConnection();
00036 
00037   try {
00038     m_writeStmt = m_conn->createStatement();
00039     m_writeStmt->setSQL("INSERT INTO mon_delays_tt_dat (iov_id, logic_id, "
00040                         "delay_mean, delay_rms, task_status) "
00041                         "VALUES (:iov_id, :logic_id, "
00042                         ":delay_mean, :delay_rms, :task_status)");
00043   } catch (SQLException &e) {
00044     throw(runtime_error("MonDelaysTTDat::prepareWrite():  "+e.getMessage()));
00045   }
00046 }

void MonDelaysTTDat::setDelayMean ( float  mean  )  [inline]

Definition at line 21 of file MonDelaysTTDat.h.

References m_delayMean.

Referenced by fetchData().

00021 { m_delayMean = mean; }

void MonDelaysTTDat::setDelayRMS ( float  rms  )  [inline]

Definition at line 24 of file MonDelaysTTDat.h.

References m_delayRMS.

Referenced by fetchData().

00024 { m_delayRMS = rms; }

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

Definition at line 27 of file MonDelaysTTDat.h.

References m_taskStatus.

Referenced by fetchData().

00027 { m_taskStatus = status; }

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

Definition at line 124 of file MonDelaysTTDat.cc.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, getDelayMean(), getDelayRMS(), EcalLogicID::getLogicID(), getTaskStatus(), IDataItem::m_writeStmt, p, st, x, and y.

00126 {
00127   this->checkConnection();
00128   this->checkPrepare();
00129 
00130   int iovID = iov->fetchID();
00131   if (!iovID) { throw(runtime_error("MonDelaysTTDat::writeArrayDB:  IOV not in DB")); }
00132 
00133 
00134   int nrows=data->size(); 
00135   int* ids= new int[nrows];
00136   int* iovid_vec= new int[nrows];
00137   float* xx= new float[nrows];
00138   float* yy= new float[nrows];
00139   int* st= new int[nrows];
00140 
00141   ub2* ids_len= new ub2[nrows];
00142   ub2* iov_len= new ub2[nrows];
00143   ub2* x_len= new ub2[nrows];
00144   ub2* y_len= new ub2[nrows];
00145   ub2* st_len= new ub2[nrows];
00146 
00147   const EcalLogicID* channel;
00148   const MonDelaysTTDat* dataitem;
00149   int count=0;
00150   typedef map< EcalLogicID, MonDelaysTTDat >::const_iterator CI;
00151   for (CI p = data->begin(); p != data->end(); ++p) {
00152         channel = &(p->first);
00153         int logicID = channel->getLogicID();
00154         if (!logicID) { throw(runtime_error("MonDelaysTTDat::writeArrayDB:  Bad EcalLogicID")); }
00155         ids[count]=logicID;
00156         iovid_vec[count]=iovID;
00157 
00158         dataitem = &(p->second);
00159         // dataIface.writeDB( channel, dataitem, iov);
00160         float x=dataitem->getDelayMean();
00161         float y=dataitem->getDelayRMS();
00162         int statu=dataitem->getTaskStatus();
00163 
00164 
00165 
00166         xx[count]=x;
00167         yy[count]=y;
00168         st[count]=statu;
00169 
00170 
00171         ids_len[count]=sizeof(ids[count]);
00172         iov_len[count]=sizeof(iovid_vec[count]);
00173         
00174         x_len[count]=sizeof(xx[count]);
00175         y_len[count]=sizeof(yy[count]);
00176         st_len[count]=sizeof(st[count]);
00177 
00178         count++;
00179      }
00180 
00181 
00182   try {
00183     m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
00184     m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
00185     m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
00186     m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
00187     m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT , sizeof(st[0]), st_len );
00188    
00189 
00190     m_writeStmt->executeArrayUpdate(nrows);
00191 
00192     delete [] ids;
00193     delete [] iovid_vec;
00194     delete [] xx;
00195     delete [] yy;
00196     delete [] st;
00197 
00198     delete [] ids_len;
00199     delete [] iov_len;
00200     delete [] x_len;
00201     delete [] y_len;
00202     delete [] st_len;
00203 
00204 
00205 
00206   } catch (SQLException &e) {
00207     throw(runtime_error("MonDelaysTTDat::writeArrayDB():  "+e.getMessage()));
00208   }
00209 }

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

Definition at line 50 of file MonDelaysTTDat.cc.

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

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


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file MonDelaysTTDat.h.


Member Data Documentation

float MonDelaysTTDat::m_delayMean [private]

Definition at line 46 of file MonDelaysTTDat.h.

Referenced by getDelayMean(), MonDelaysTTDat(), and setDelayMean().

float MonDelaysTTDat::m_delayRMS [private]

Definition at line 47 of file MonDelaysTTDat.h.

Referenced by getDelayRMS(), MonDelaysTTDat(), and setDelayRMS().

bool MonDelaysTTDat::m_taskStatus [private]

Definition at line 48 of file MonDelaysTTDat.h.

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


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