CMS 3D CMS Logo

LMFPNBlueDat Class Reference

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

Inheritance diagram for LMFPNBlueDat:

IDataItem IDBObject

List of all members.

Public Member Functions

float getPNErr () const
float getPNPeak () const
std::string getTable ()
 LMFPNBlueDat ()
void setPNErr (float err)
void setPNPeak (float peak)
 ~LMFPNBlueDat ()

Private Member Functions

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

Private Attributes

float m_pnErr
float m_pnPeak

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file LMFPNBlueDat.h.


Constructor & Destructor Documentation

LMFPNBlueDat::LMFPNBlueDat (  ) 

Definition at line 12 of file LMFPNBlueDat.cc.

References IDBObject::m_conn, IDBObject::m_env, m_pnErr, m_pnPeak, 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_pnPeak = 0;
00020   m_pnErr = 0;
00021 }

LMFPNBlueDat::~LMFPNBlueDat (  ) 

Definition at line 25 of file LMFPNBlueDat.cc.

00026 {
00027 }


Member Function Documentation

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

Definition at line 152 of file LMFPNBlueDat.cc.

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

00154 {
00155   this->checkConnection();
00156   fillMap->clear();
00157 
00158   iov->setConnection(m_env, m_conn);
00159   int iovID = iov->fetchID();
00160   if (!iovID) { 
00161     //  throw(runtime_error("LMFPNBlueDat::writeDB:  IOV not in DB")); 
00162     return;
00163   }
00164 
00165   try {
00166 
00167     m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
00168                  "d.pn_peak, d.pn_err "
00169                  "FROM channelview cv JOIN lmf_pn_blue_dat d "
00170                  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
00171                  "WHERE d.iov_id = :iov_id");
00172     m_readStmt->setInt(1, iovID);
00173     ResultSet* rset = m_readStmt->executeQuery();
00174     
00175     std::pair< EcalLogicID, LMFPNBlueDat > p;
00176     LMFPNBlueDat dat;
00177     while(rset->next()) {
00178       p.first = EcalLogicID( rset->getString(1),     // name
00179                              rset->getInt(2),        // logic_id
00180                              rset->getInt(3),        // id1
00181                              rset->getInt(4),        // id2
00182                              rset->getInt(5),        // id3
00183                              rset->getString(6));    // maps_to
00184 
00185       dat.setPNPeak( rset->getFloat(7) );
00186       dat.setPNErr( rset->getFloat(8) );
00187 
00188       p.second = dat;
00189       fillMap->insert(p);
00190     }
00191 
00192 
00193   } catch (SQLException &e) {
00194     throw(runtime_error("LMFPNBlueDat::fetchData():  "+e.getMessage()));
00195   }
00196 }

float LMFPNBlueDat::getPNErr (  )  const [inline]

Definition at line 25 of file LMFPNBlueDat.h.

References m_pnErr.

Referenced by writeArrayDB().

00025 { return m_pnErr; }

float LMFPNBlueDat::getPNPeak (  )  const [inline]

Definition at line 22 of file LMFPNBlueDat.h.

References m_pnPeak.

Referenced by writeArrayDB().

00022 { return m_pnPeak; }

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

Implements IDataItem.

Definition at line 19 of file LMFPNBlueDat.h.

00019 { return "LMF_PN_BLUE_DAT"; }

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

Implements IDataItem.

Definition at line 31 of file LMFPNBlueDat.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 lmf_pn_blue_dat (iov_id, logic_id, "
00039                         "pn_peak, pn_err) "
00040                         "VALUES (:iov_id, :logic_id, "
00041                         ":3, :4)");
00042   } catch (SQLException &e) {
00043     throw(runtime_error("LMFPNBlueDat::prepareWrite():  "+e.getMessage()));
00044   }
00045 }

void LMFPNBlueDat::setPNErr ( float  err  )  [inline]

Definition at line 24 of file LMFPNBlueDat.h.

References m_pnErr.

Referenced by fetchData().

00024 { m_pnErr = err; }

void LMFPNBlueDat::setPNPeak ( float  peak  )  [inline]

Definition at line 21 of file LMFPNBlueDat.h.

References m_pnPeak.

Referenced by fetchData().

00021 { m_pnPeak = peak; }

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

Definition at line 75 of file LMFPNBlueDat.cc.

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

00077 {
00078   this->checkConnection();
00079   this->checkPrepare();
00080 
00081   int iovID = iov->fetchID();
00082   if (!iovID) { throw(runtime_error("LMFPNBlueDat::writeArrayDB:  IOV not in DB")); }
00083 
00084 
00085   int nrows= data->size(); // to be checked 
00086   int* ids= new int[nrows];
00087   int* iovid_vec= new int[nrows];
00088   float* xx= new float[nrows];
00089   float* yy= new float[nrows];
00090 
00091   ub2* ids_len= new ub2[nrows];
00092   ub2* iov_len= new ub2[nrows];
00093   ub2* x_len= new ub2[nrows];
00094   ub2* y_len= new ub2[nrows];
00095 
00096   const EcalLogicID* channel;
00097   const LMFPNBlueDat* dataitem;
00098   int count=0;
00099   typedef map< EcalLogicID, LMFPNBlueDat >::const_iterator CI;
00100   for (CI p = data->begin(); p != data->end(); ++p) {
00101         channel = &(p->first);
00102         int logicID = channel->getLogicID();
00103         if (!logicID) { throw(runtime_error("LMFPNBlueDat::writeArrayDB:  Bad EcalLogicID")); }
00104         ids[count]=logicID;
00105         iovid_vec[count]=iovID;
00106 
00107         dataitem = &(p->second);
00108         // dataIface.writeDB( channel, dataitem, iov);
00109         float x=dataitem->getPNPeak();
00110         float y=dataitem->getPNErr();
00111 
00112         xx[count]=x;
00113         yy[count]=y;
00114         ids_len[count]=sizeof(ids[count]);
00115         iov_len[count]=sizeof(iovid_vec[count]);
00116         
00117         x_len[count]=sizeof(xx[count]);
00118         y_len[count]=sizeof(yy[count]);
00119 
00120         count++;
00121      }
00122 
00123 
00124   try {
00125     m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
00126     m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
00127     m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len );
00128     m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len );
00129     //m_writeStmt->setFloat(3, item->getAPDPeak() );
00130     // m_writeStmt->setFloat(4, item->getAPDErr() );
00131 
00132     m_writeStmt->executeArrayUpdate(nrows);
00133 
00134     delete [] ids;
00135     delete [] iovid_vec;
00136     delete [] xx;
00137     delete [] yy;
00138 
00139     delete [] ids_len;
00140     delete [] iov_len;
00141     delete [] x_len;
00142     delete [] y_len;
00143     
00144 
00145 
00146   } catch (SQLException &e) {
00147     throw(runtime_error("LMFPNBlueDat::writeArrayDB():  "+e.getMessage()));
00148   }
00149 }

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

Definition at line 49 of file LMFPNBlueDat.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("LMFPNBlueDat::writeDB:  IOV not in DB")); }
00057 
00058   int logicID = ecid->getLogicID();
00059   if (!logicID) { throw(runtime_error("LMFPNBlueDat::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->getPNPeak() );
00066     m_writeStmt->setFloat(4, item->getPNErr() );
00067 
00068     m_writeStmt->executeUpdate();
00069   } catch (SQLException &e) {
00070     throw(runtime_error("LMFPNBlueDat::writeDB():  "+e.getMessage()));
00071   }
00072 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file LMFPNBlueDat.h.


Member Data Documentation

float LMFPNBlueDat::m_pnErr [private]

Definition at line 43 of file LMFPNBlueDat.h.

Referenced by getPNErr(), LMFPNBlueDat(), and setPNErr().

float LMFPNBlueDat::m_pnPeak [private]

Definition at line 42 of file LMFPNBlueDat.h.

Referenced by getPNPeak(), LMFPNBlueDat(), and setPNPeak().


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