CMS 3D CMS Logo

LMFCalibPrimDat Class Reference

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

Inheritance diagram for LMFCalibPrimDat:

IDataItem IDBObject

List of all members.

Public Member Functions

int getFlag () const
float getMean () const
float getPeak () const
float getRMS () const
std::string getTable ()
 LMFCalibPrimDat ()
void setFlag (int x)
void setMean (float mean)
void setPeak (float x)
void setRMS (float RMS)
 ~LMFCalibPrimDat ()

Private Member Functions

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

Private Attributes

int m_Flag
float m_Mean
float m_Peak
float m_RMS

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file LMFCalibPrimDat.h.


Constructor & Destructor Documentation

LMFCalibPrimDat::LMFCalibPrimDat (  ) 

Definition at line 13 of file LMFCalibPrimDat.cc.

References IDBObject::m_conn, IDBObject::m_env, m_Flag, m_Mean, m_Peak, IDataItem::m_readStmt, m_RMS, IDataItem::m_writeStmt, and NULL.

00014 {
00015   m_env = NULL;
00016   m_conn = NULL;
00017   m_writeStmt = NULL;
00018   m_readStmt = NULL;
00019 
00020 
00021    m_Mean=0;
00022    m_RMS=0;
00023    m_Peak=0;
00024    m_Flag=0;
00025 
00026 }

LMFCalibPrimDat::~LMFCalibPrimDat (  ) 

Definition at line 30 of file LMFCalibPrimDat.cc.

00031 {
00032 }


Member Function Documentation

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

Definition at line 179 of file LMFCalibPrimDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setFlag(), setMean(), setPeak(), and setRMS().

00181 {
00182   this->checkConnection();
00183   fillMap->clear();
00184 
00185   iov->setConnection(m_env, m_conn);
00186   int iovID = iov->fetchID();
00187   if (!iovID) { 
00188     //  throw(runtime_error("LMFCalibPrimDat::writeDB:  IOV not in DB")); 
00189     return;
00190   }
00191 
00192   try {
00193   
00194     m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
00195                  "d.flag, d.mean, d.rms, d,peak "
00196                  "FROM channelview cv JOIN lmf_calib_PRIM_dat d "
00197                  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
00198                  "WHERE d.lmf_iov_id = :iov_id");
00199  
00200     m_readStmt->setInt(1, iovID);
00201     
00202     ResultSet* rset = m_readStmt->executeQuery();
00203      
00204     std::pair< EcalLogicID, LMFCalibPrimDat > p;
00205     LMFCalibPrimDat dat;
00206     while(rset->next()) {
00207       p.first = EcalLogicID( rset->getString(1),     // name
00208                              rset->getInt(2),        // logic_id
00209                              rset->getInt(3),        // id1
00210                              rset->getInt(4),        // id2
00211                              rset->getInt(5),        // id3
00212                              rset->getString(6));    // maps_to
00213 
00214       dat.setFlag( rset->getInt(7) );
00215       dat.setMean( rset->getFloat(8) );
00216       dat.setRMS( rset->getFloat(9) );
00217       dat.setPeak( rset->getFloat(10) );
00218 
00219       p.second = dat;
00220       fillMap->insert(p);
00221     }
00222 
00223   } catch (SQLException &e) {
00224     throw(runtime_error("LMFCalibPrimDat::fetchData():  "+e.getMessage()));
00225   }
00226 }

int LMFCalibPrimDat::getFlag (  )  const [inline]

Definition at line 31 of file LMFCalibPrimDat.h.

References m_Flag.

Referenced by writeArrayDB().

00031 { return m_Flag; }

float LMFCalibPrimDat::getMean (  )  const [inline]

Definition at line 22 of file LMFCalibPrimDat.h.

References m_Mean.

Referenced by writeArrayDB().

00022 { return m_Mean; }

float LMFCalibPrimDat::getPeak (  )  const [inline]

Definition at line 28 of file LMFCalibPrimDat.h.

References m_Peak.

Referenced by writeArrayDB().

00028 { return m_Peak; }

float LMFCalibPrimDat::getRMS ( void   )  const [inline]

Definition at line 25 of file LMFCalibPrimDat.h.

References m_RMS.

Referenced by writeArrayDB().

00025 { return m_RMS; }

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

Implements IDataItem.

Definition at line 19 of file LMFCalibPrimDat.h.

00019 { return "LMF_CALIB_PRIM_DAT"; }

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

Implements IDataItem.

Definition at line 36 of file LMFCalibPrimDat.cc.

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

00038 {
00039   this->checkConnection();
00040 
00041   try {
00042     m_writeStmt = m_conn->createStatement();
00043     m_writeStmt->setSQL("INSERT INTO lmf_calib_prim_dat (lmf_iov_id, logic_id, "
00044                         "flag, mean, rms, peak ) "
00045                         "VALUES (:1, :2, "
00046                         ":3, :4, :5, :6 )");
00047   } catch (SQLException &e) {
00048     throw(runtime_error("LMFCalibPrimDat::prepareWrite():  "+e.getMessage()));
00049   }
00050 }

void LMFCalibPrimDat::setFlag ( int  x  )  [inline]

Definition at line 30 of file LMFCalibPrimDat.h.

References m_Flag.

Referenced by fetchData().

00030 { m_Flag = x; }

void LMFCalibPrimDat::setMean ( float  mean  )  [inline]

Definition at line 21 of file LMFCalibPrimDat.h.

References m_Mean.

Referenced by fetchData().

00021 { m_Mean = mean; }

void LMFCalibPrimDat::setPeak ( float  x  )  [inline]

Definition at line 27 of file LMFCalibPrimDat.h.

References m_Peak.

Referenced by fetchData().

00027 { m_Peak = x; }

void LMFCalibPrimDat::setRMS ( float  RMS  )  [inline]

Definition at line 24 of file LMFCalibPrimDat.h.

References m_RMS.

Referenced by fetchData().

00024 { m_RMS = RMS; }

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

Definition at line 82 of file LMFCalibPrimDat.cc.

References a, aa, IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, getFlag(), EcalLogicID::getLogicID(), getMean(), getPeak(), getRMS(), IDataItem::m_writeStmt, p, x, y, and z.

00084 {
00085   this->checkConnection();
00086   this->checkPrepare();
00087 
00088   int iovID = iov->fetchID();
00089   if (!iovID) { throw(runtime_error("LMFCalibPrimDat::writeArrayDB:  IOV not in DB")); }
00090 
00091 
00092   int nrows=data->size(); 
00093   int* ids= new int[nrows];
00094   int* iovid_vec= new int[nrows];
00095   int* aa= new int[nrows];
00096   float* xx= new float[nrows];
00097   float* yy= new float[nrows];
00098   float* zz= new float[nrows];
00099 
00100 
00101   ub2* ids_len= new ub2[nrows];
00102   ub2* iov_len= new ub2[nrows];
00103   ub2* a_len= new ub2[nrows];
00104   ub2* x_len= new ub2[nrows];
00105   ub2* y_len= new ub2[nrows];
00106   ub2* z_len= new ub2[nrows];
00107 
00108 
00109   const EcalLogicID* channel;
00110   const LMFCalibPrimDat* dataitem;
00111   int count=0;
00112   typedef map< EcalLogicID, LMFCalibPrimDat >::const_iterator CI;
00113   for (CI p = data->begin(); p != data->end(); ++p) {
00114         channel = &(p->first);
00115         int logicID = channel->getLogicID();
00116         if (!logicID) { throw(runtime_error("LMFCalibPrimDat::writeArrayDB:  Bad EcalLogicID")); }
00117         ids[count]=logicID;
00118         iovid_vec[count]=iovID;
00119 
00120         dataitem = &(p->second);
00121         // dataIface.writeDB( channel, dataitem, iov);
00122         int a=dataitem->getFlag();
00123         float x=dataitem->getMean();
00124         float y=dataitem->getRMS();
00125         float z=dataitem->getPeak();
00126 
00127 
00128         aa[count]=a;
00129         xx[count]=x;
00130         yy[count]=y;
00131         zz[count]=z;
00132 
00133 
00134         ids_len[count]=sizeof(ids[count]);
00135         iov_len[count]=sizeof(iovid_vec[count]);
00136         
00137         a_len[count]=sizeof(aa[count]);
00138         x_len[count]=sizeof(xx[count]);
00139         y_len[count]=sizeof(yy[count]);
00140         z_len[count]=sizeof(zz[count]);
00141 
00142 
00143         count++;
00144      }
00145 
00146 
00147   try {
00148     m_writeStmt->setDataBuffer(1,  (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
00149     m_writeStmt->setDataBuffer(2,  (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
00150     m_writeStmt->setDataBuffer(3,  (dvoid*)aa,  OCCIINT , sizeof(aa[0]), a_len );
00151     m_writeStmt->setDataBuffer(4,  (dvoid*)xx,  OCCIFLOAT , sizeof(xx[0]), x_len );
00152     m_writeStmt->setDataBuffer(5,  (dvoid*)yy,  OCCIFLOAT , sizeof(yy[0]), y_len );
00153     m_writeStmt->setDataBuffer(6,  (dvoid*)zz,  OCCIFLOAT , sizeof(zz[0]), z_len );
00154 
00155 
00156     m_writeStmt->executeArrayUpdate(nrows);
00157 
00158     delete [] ids;
00159     delete [] iovid_vec;
00160     delete [] aa;
00161     delete [] xx;
00162     delete [] yy;
00163     delete [] zz;
00164 
00165 
00166     delete [] ids_len;
00167     delete [] iov_len;
00168     delete [] a_len;
00169     delete [] x_len;
00170     delete [] y_len;
00171     delete [] z_len;
00172 
00173 
00174   } catch (SQLException &e) {
00175     throw(runtime_error("LMFCalibPrimDat::writeArrayDB():  "+e.getMessage()));
00176   }
00177 }

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

Definition at line 54 of file LMFCalibPrimDat.cc.

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

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


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file LMFCalibPrimDat.h.


Member Data Documentation

int LMFCalibPrimDat::m_Flag [private]

Definition at line 47 of file LMFCalibPrimDat.h.

Referenced by getFlag(), LMFCalibPrimDat(), and setFlag().

float LMFCalibPrimDat::m_Mean [private]

Definition at line 49 of file LMFCalibPrimDat.h.

Referenced by getMean(), LMFCalibPrimDat(), and setMean().

float LMFCalibPrimDat::m_Peak [private]

Definition at line 50 of file LMFCalibPrimDat.h.

Referenced by getPeak(), LMFCalibPrimDat(), and setPeak().

float LMFCalibPrimDat::m_RMS [private]

Definition at line 48 of file LMFCalibPrimDat.h.

Referenced by getRMS(), LMFCalibPrimDat(), and setRMS().


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