CMS 3D CMS Logo

MonH4TablePositionDat Class Reference

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

Inheritance diagram for MonH4TablePositionDat:

IDataItem IDBObject

List of all members.

Public Member Functions

std::string getTable ()
float getTableX () const
float getTableY () const
 MonH4TablePositionDat ()
void setTableX (float x)
void setTableY (float y)
 ~MonH4TablePositionDat ()

Private Member Functions

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

Private Attributes

float m_tableX
float m_tableY

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 11 of file MonH4TablePositionDat.h.


Constructor & Destructor Documentation

MonH4TablePositionDat::MonH4TablePositionDat (  ) 

Definition at line 10 of file MonH4TablePositionDat.cc.

References IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, m_tableX, m_tableY, 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_tableX = 0;
00018   m_tableY = 0;
00019 }

MonH4TablePositionDat::~MonH4TablePositionDat (  ) 

Definition at line 23 of file MonH4TablePositionDat.cc.

00024 {
00025 }


Member Function Documentation

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

Definition at line 74 of file MonH4TablePositionDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setTableX(), and setTableY().

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

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

Implements IDataItem.

Definition at line 18 of file MonH4TablePositionDat.h.

00018 { return "MON_H4_TABLE_POSITION_DAT"; }

float MonH4TablePositionDat::getTableX (  )  const [inline]

Definition at line 21 of file MonH4TablePositionDat.h.

References m_tableX.

Referenced by writeArrayDB().

00021 { return m_tableX; }

float MonH4TablePositionDat::getTableY (  )  const [inline]

Definition at line 24 of file MonH4TablePositionDat.h.

References m_tableY.

Referenced by writeArrayDB().

00024 { return m_tableY; }

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

Implements IDataItem.

Definition at line 29 of file MonH4TablePositionDat.cc.

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

00031 {
00032   this->checkConnection();
00033 
00034   try {
00035     m_writeStmt = m_conn->createStatement();
00036     m_writeStmt->setSQL("INSERT INTO mon_h4_table_position_dat (iov_id, logic_id, "
00037                         "table_x, table_y) "
00038                         "VALUES (:iov_id, :logic_id, "
00039                         ":3, :4)");
00040   } catch (SQLException &e) {
00041     throw(runtime_error("MonH4TablePositionDat::prepareWrite():  "+e.getMessage()));
00042   }
00043 }

void MonH4TablePositionDat::setTableX ( float  x  )  [inline]

Definition at line 20 of file MonH4TablePositionDat.h.

References m_tableX.

Referenced by fetchData().

00020 { m_tableX = x; }

void MonH4TablePositionDat::setTableY ( float  y  )  [inline]

Definition at line 23 of file MonH4TablePositionDat.h.

References m_tableY.

Referenced by fetchData().

00023 { m_tableY = y; }

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

Definition at line 118 of file MonH4TablePositionDat.cc.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, EcalLogicID::getLogicID(), getTableX(), getTableY(), IDataItem::m_writeStmt, p, x, and y.

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

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

Definition at line 47 of file MonH4TablePositionDat.cc.

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

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


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 13 of file MonH4TablePositionDat.h.


Member Data Documentation

float MonH4TablePositionDat::m_tableX [private]

Definition at line 40 of file MonH4TablePositionDat.h.

Referenced by getTableX(), MonH4TablePositionDat(), and setTableX().

float MonH4TablePositionDat::m_tableY [private]

Definition at line 41 of file MonH4TablePositionDat.h.

Referenced by getTableY(), MonH4TablePositionDat(), and setTableY().


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