CMS 3D CMS Logo

CaliCrystalIntercalDat Class Reference

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

Inheritance diagram for CaliCrystalIntercalDat:

IDataItem IDBObject

List of all members.

Public Member Functions

 CaliCrystalIntercalDat ()
float getCali () const
float getCaliRMS () const
int getNumEvents () const
std::string getTable ()
bool getTaskStatus () const
void setCali (float c)
void setCaliRMS (float c)
void setNumEvents (int n)
void setTaskStatus (bool s)
 ~CaliCrystalIntercalDat ()

Private Member Functions

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

Private Attributes

float m_cali
float m_caliRMS
int m_numEvents
bool m_taskStatus

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file CaliCrystalIntercalDat.h.


Constructor & Destructor Documentation

CaliCrystalIntercalDat::CaliCrystalIntercalDat (  ) 

Definition at line 12 of file CaliCrystalIntercalDat.cc.

References m_cali, m_caliRMS, IDBObject::m_conn, IDBObject::m_env, m_numEvents, m_taskStatus, IDataItem::m_writeStmt, and NULL.

00013 {
00014   m_env = NULL;
00015   m_conn = NULL;
00016   m_writeStmt = NULL;
00017 
00018   m_cali = 0;
00019   m_caliRMS = 0;
00020   m_numEvents = 0;
00021   m_taskStatus = false;
00022 }

CaliCrystalIntercalDat::~CaliCrystalIntercalDat (  ) 

Definition at line 26 of file CaliCrystalIntercalDat.cc.

00027 {
00028 }


Member Function Documentation

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

Definition at line 79 of file CaliCrystalIntercalDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setCali(), setCaliRMS(), setNumEvents(), and setTaskStatus().

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

float CaliCrystalIntercalDat::getCali (  )  const [inline]

Definition at line 22 of file CaliCrystalIntercalDat.h.

References m_cali.

Referenced by writeArrayDB().

00022 { return m_cali; }

float CaliCrystalIntercalDat::getCaliRMS (  )  const [inline]

Definition at line 25 of file CaliCrystalIntercalDat.h.

References m_caliRMS.

Referenced by writeArrayDB().

00025 { return m_caliRMS; }

int CaliCrystalIntercalDat::getNumEvents (  )  const [inline]

Definition at line 28 of file CaliCrystalIntercalDat.h.

References m_numEvents.

Referenced by writeArrayDB().

00028 { return m_numEvents; }

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

Implements IDataItem.

Definition at line 19 of file CaliCrystalIntercalDat.h.

00019 { return "CALI_CRYSTAL_INTERCAL_DAT"; }

bool CaliCrystalIntercalDat::getTaskStatus (  )  const [inline]

Definition at line 31 of file CaliCrystalIntercalDat.h.

References m_taskStatus.

Referenced by writeArrayDB().

00031 { return m_taskStatus; }

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

Implements IDataItem.

Definition at line 32 of file CaliCrystalIntercalDat.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 cali_crystal_intercal_dat (iov_id, logic_id, "
00040                         "cali, cali_rms, num_events, task_status) "
00041                         "VALUES (:iov_id, :logic_id, "
00042                         ":3, :4, :5, :6)");
00043   } catch (SQLException &e) {
00044     throw(runtime_error("CaliCrystalIntercalDat::prepareWrite():  "+e.getMessage()));
00045   }
00046 }

void CaliCrystalIntercalDat::setCali ( float  c  )  [inline]

Definition at line 21 of file CaliCrystalIntercalDat.h.

References m_cali.

Referenced by fetchData().

00021 { m_cali = c; }

void CaliCrystalIntercalDat::setCaliRMS ( float  c  )  [inline]

Definition at line 24 of file CaliCrystalIntercalDat.h.

References m_caliRMS.

Referenced by fetchData().

00024 { m_caliRMS = c; }

void CaliCrystalIntercalDat::setNumEvents ( int  n  )  [inline]

Definition at line 27 of file CaliCrystalIntercalDat.h.

References m_numEvents.

Referenced by fetchData().

00027 { m_numEvents = n; }

void CaliCrystalIntercalDat::setTaskStatus ( bool  s  )  [inline]

Definition at line 30 of file CaliCrystalIntercalDat.h.

References m_taskStatus.

Referenced by fetchData().

00030 { m_taskStatus = s; }

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

Definition at line 125 of file CaliCrystalIntercalDat.cc.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, getCali(), getCaliRMS(), EcalLogicID::getLogicID(), getNumEvents(), getTaskStatus(), IDataItem::m_writeStmt, p, st, tt, x, and y.

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

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

Definition at line 50 of file CaliCrystalIntercalDat.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("CaliCrystalIntercalDat::writeDB:  IOV not in DB")); }
00058   
00059   int logicID = ecid->getLogicID();
00060   if (!logicID) { throw(runtime_error("CaliCrystalIntercalDat::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->getCali() );
00067     m_writeStmt->setFloat(4, item->getCaliRMS() );
00068     m_writeStmt->setInt(5, item->getNumEvents() );
00069     m_writeStmt->setInt(6, item->getTaskStatus() );
00070     
00071     m_writeStmt->executeUpdate();
00072   } catch (SQLException &e) {
00073     throw(runtime_error("CaliCrystalIntercalDat::writeDB():  "+e.getMessage()));
00074   }
00075 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file CaliCrystalIntercalDat.h.


Member Data Documentation

float CaliCrystalIntercalDat::m_cali [private]

Definition at line 49 of file CaliCrystalIntercalDat.h.

Referenced by CaliCrystalIntercalDat(), getCali(), and setCali().

float CaliCrystalIntercalDat::m_caliRMS [private]

Definition at line 50 of file CaliCrystalIntercalDat.h.

Referenced by CaliCrystalIntercalDat(), getCaliRMS(), and setCaliRMS().

int CaliCrystalIntercalDat::m_numEvents [private]

Definition at line 51 of file CaliCrystalIntercalDat.h.

Referenced by CaliCrystalIntercalDat(), getNumEvents(), and setNumEvents().

bool CaliCrystalIntercalDat::m_taskStatus [private]

Definition at line 52 of file CaliCrystalIntercalDat.h.

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


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