CMS 3D CMS Logo

MonShapeQualityDat Class Reference

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

Inheritance diagram for MonShapeQualityDat:

IDataItem IDBObject

List of all members.

Public Member Functions

float getAvgChi2 () const
std::string getTable ()
 MonShapeQualityDat ()
void setAvgChi2 (float chi2)
 ~MonShapeQualityDat ()

Private Member Functions

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

Private Attributes

float m_avgChi2

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file MonShapeQualityDat.h.


Constructor & Destructor Documentation

MonShapeQualityDat::MonShapeQualityDat (  ) 

Definition at line 12 of file MonShapeQualityDat.cc.

References m_avgChi2, 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_avgChi2 = 0;
00020 }

MonShapeQualityDat::~MonShapeQualityDat (  ) 

Definition at line 24 of file MonShapeQualityDat.cc.

00025 {
00026 }


Member Function Documentation

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

Definition at line 74 of file MonShapeQualityDat.cc.

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

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("MonShapeQualityDat::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.avg_chi2 "
00091                  "FROM channelview cv JOIN mon_shape_quality_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, MonShapeQualityDat > p;
00098     MonShapeQualityDat 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.setAvgChi2( rset->getFloat(7) );
00108 
00109       p.second = dat;
00110       fillMap->insert(p);
00111     }
00112   } catch (SQLException &e) {
00113     throw(runtime_error("MonShapeQualityDat::fetchData():  "+e.getMessage()));
00114   }
00115 }

float MonShapeQualityDat::getAvgChi2 (  )  const [inline]

Definition at line 22 of file MonShapeQualityDat.h.

References m_avgChi2.

Referenced by writeArrayDB().

00022 { return m_avgChi2; }

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

Implements IDataItem.

Definition at line 19 of file MonShapeQualityDat.h.

00019 { return "MON_SHAPE_QUALITY_DAT"; }

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

Implements IDataItem.

Definition at line 30 of file MonShapeQualityDat.cc.

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

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

void MonShapeQualityDat::setAvgChi2 ( float  chi2  )  [inline]

Definition at line 21 of file MonShapeQualityDat.h.

References m_avgChi2.

Referenced by fetchData().

00021 { m_avgChi2 = chi2; }

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

Definition at line 117 of file MonShapeQualityDat.cc.

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

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

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

Definition at line 48 of file MonShapeQualityDat.cc.

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

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


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file MonShapeQualityDat.h.


Member Data Documentation

float MonShapeQualityDat::m_avgChi2 [private]

Definition at line 38 of file MonShapeQualityDat.h.

Referenced by getAvgChi2(), MonShapeQualityDat(), and setAvgChi2().


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