CMS 3D CMS Logo

DCUCapsuleTempRawDat Class Reference

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

Inheritance diagram for DCUCapsuleTempRawDat:

IDataItem IDBObject

List of all members.

Public Member Functions

 DCUCapsuleTempRawDat ()
float getCapsuleTempADC () const
float getCapsuleTempRMS () const
std::string getTable ()
void setCapsuleTempADC (float adc)
void setCapsuleTempRMS (float rms)
 ~DCUCapsuleTempRawDat ()

Private Member Functions

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

Private Attributes

float m_capsuleTempADC
float m_capsuleTempRMS

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file DCUCapsuleTempRawDat.h.


Constructor & Destructor Documentation

DCUCapsuleTempRawDat::DCUCapsuleTempRawDat (  ) 

Definition at line 12 of file DCUCapsuleTempRawDat.cc.

References m_capsuleTempADC, m_capsuleTempRMS, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, 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_capsuleTempADC = 0;
00020   m_capsuleTempRMS = 0;
00021 }

DCUCapsuleTempRawDat::~DCUCapsuleTempRawDat (  ) 

Definition at line 25 of file DCUCapsuleTempRawDat.cc.

00026 {
00027 }


Member Function Documentation

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

Definition at line 76 of file DCUCapsuleTempRawDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setCapsuleTempADC(), and setCapsuleTempRMS().

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("DCUCapsuleTempRawDat::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.capsule_temp_adc, d.capsule_temp_rms "
00093                  "FROM channelview cv JOIN dcu_capsule_temp_raw_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, DCUCapsuleTempRawDat > p;
00100     DCUCapsuleTempRawDat 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.setCapsuleTempADC( rset->getFloat(7) );
00110       dat.setCapsuleTempRMS( rset->getFloat(8) );
00111 
00112       p.second = dat;
00113       fillMap->insert(p);
00114     }
00115   } catch (SQLException &e) {
00116     throw(runtime_error("DCUCapsuleTempRawDat::fetchData():  "+e.getMessage()));
00117   }
00118 }

float DCUCapsuleTempRawDat::getCapsuleTempADC (  )  const [inline]

Definition at line 22 of file DCUCapsuleTempRawDat.h.

References m_capsuleTempADC.

Referenced by writeArrayDB().

00022 { return m_capsuleTempADC; }

float DCUCapsuleTempRawDat::getCapsuleTempRMS (  )  const [inline]

Definition at line 25 of file DCUCapsuleTempRawDat.h.

References m_capsuleTempRMS.

Referenced by writeArrayDB().

00025 { return m_capsuleTempRMS; }

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

Implements IDataItem.

Definition at line 19 of file DCUCapsuleTempRawDat.h.

00019 { return "DCU_CAPSULE_TEMP_RAW_DAT"; }

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

Implements IDataItem.

Definition at line 31 of file DCUCapsuleTempRawDat.cc.

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

00033 {
00034   this->checkConnection();
00035 
00036   try {
00037     m_writeStmt = m_conn->createStatement();
00038     m_writeStmt->setSQL("INSERT INTO dcu_capsule_temp_raw_dat (iov_id, logic_id, "
00039                         "capsule_temp_adc, capsule_temp_rms) "
00040                         "VALUES (:iov_id, :logic_id, "
00041                         ":3, :4)");
00042   } catch (SQLException &e) {
00043     throw(runtime_error("DCUCapsuleTempRawDat::prepareWrite():  "+e.getMessage()));
00044   }
00045 }

void DCUCapsuleTempRawDat::setCapsuleTempADC ( float  adc  )  [inline]

Definition at line 21 of file DCUCapsuleTempRawDat.h.

References m_capsuleTempADC.

Referenced by fetchData().

00021 { m_capsuleTempADC = adc; }

void DCUCapsuleTempRawDat::setCapsuleTempRMS ( float  rms  )  [inline]

Definition at line 24 of file DCUCapsuleTempRawDat.h.

References m_capsuleTempRMS.

Referenced by fetchData().

00024 { m_capsuleTempRMS = rms; }

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

Definition at line 120 of file DCUCapsuleTempRawDat.cc.

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

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

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

Definition at line 49 of file DCUCapsuleTempRawDat.cc.

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

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


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file DCUCapsuleTempRawDat.h.


Member Data Documentation

float DCUCapsuleTempRawDat::m_capsuleTempADC [private]

Definition at line 41 of file DCUCapsuleTempRawDat.h.

Referenced by DCUCapsuleTempRawDat(), getCapsuleTempADC(), and setCapsuleTempADC().

float DCUCapsuleTempRawDat::m_capsuleTempRMS [private]

Definition at line 42 of file DCUCapsuleTempRawDat.h.

Referenced by DCUCapsuleTempRawDat(), getCapsuleTempRMS(), and setCapsuleTempRMS().


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