CMS 3D CMS Logo

LMFLaserPNPrimDat Class Reference

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

Inheritance diagram for LMFLaserPNPrimDat:

IDataItem IDBObject

List of all members.

Public Types

enum  laserColorNum { iBlue = 0, iGreen, iRed, iIRed }

Public Member Functions

int getFlag () const
float getMean () const
float getPeak () const
float getPNAOverPNBMean () const
float getPNAOverPNBPeak () const
float getPNAOverPNBRMS () const
float getRMS () const
std::string getTable ()
 LMFLaserPNPrimDat ()
void setFlag (int x)
void setMean (float mean)
void setPeak (float x)
void setPNAOverPNBMean (float mean)
void setPNAOverPNBPeak (float mean)
void setPNAOverPNBRMS (float mean)
void setRMS (float RMS)
 ~LMFLaserPNPrimDat ()

Static Public Member Functions

static void setColor (int color)

Private Member Functions

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

Private Attributes

int m_Flag
float m_Mean
float m_Peak
float m_PNAOverPNBMean
float m_PNAOverPNBPeak
float m_PNAOverPNBRMS
float m_RMS

Static Private Attributes

static int _color = LMFLaserPNPrimDat::iBlue

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file LMFLaserPNPrimDat.h.


Member Enumeration Documentation

enum LMFLaserPNPrimDat::laserColorNum

Enumerator:
iBlue 
iGreen 
iRed 
iIRed 

Definition at line 17 of file LMFLaserPNPrimDat.h.

00017 { iBlue=0, iGreen, iRed, iIRed };


Constructor & Destructor Documentation

LMFLaserPNPrimDat::LMFLaserPNPrimDat (  ) 

Definition at line 16 of file LMFLaserPNPrimDat.cc.

References _color, iBlue, iIRed, IDBObject::m_conn, IDBObject::m_env, m_Flag, m_Mean, m_Peak, m_PNAOverPNBMean, m_PNAOverPNBPeak, m_PNAOverPNBRMS, IDataItem::m_readStmt, m_RMS, IDataItem::m_writeStmt, and NULL.

00017 {
00018   assert( _color>=iBlue && _color<=iIRed ); // GHM
00019 
00020   m_env = NULL;
00021   m_conn = NULL;
00022   m_writeStmt = NULL;
00023   m_readStmt = NULL;
00024 
00025 
00026    m_Mean=0;
00027    m_RMS=0;
00028    m_Peak=0;
00029    m_Flag=0;
00030    m_PNAOverPNBMean=0;
00031    m_PNAOverPNBRMS=0;
00032    m_PNAOverPNBPeak=0;
00033 
00034 }

LMFLaserPNPrimDat::~LMFLaserPNPrimDat (  ) 

Definition at line 38 of file LMFLaserPNPrimDat.cc.

00039 {
00040 }


Member Function Documentation

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

Definition at line 208 of file LMFLaserPNPrimDat.cc.

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

00210 {
00211   this->checkConnection();
00212   fillMap->clear();
00213 
00214   iov->setConnection(m_env, m_conn);
00215   int iovID = iov->fetchID();
00216   if (!iovID) { 
00217     //  throw(runtime_error("LMFLaserPNPrimDat::writeDB:  IOV not in DB")); 
00218     return;
00219   }
00220 
00221   // GHM
00222   std::string command_ = "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, d.flag, d.mean, d.rms, d.peak, d.pna_over_pnb_mean, d.pna_over_pnb_rms, d.pna_over_pnB_peak FROM channelview cv JOIN XXXXXX d ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to WHERE d.lmf_iov_id = :iov_id";
00223   command_.replace( command_.find("XXXXXX",0), 6, getTable() );
00224 
00225   //  cout << "command=" << command_ << endl;
00226 
00227   try {
00228   
00229     m_readStmt->setSQL( command_.c_str() );
00230 
00231     m_readStmt->setInt(1, iovID);
00232 
00233     ResultSet* rset = m_readStmt->executeQuery();
00234 
00235     std::pair< EcalLogicID, LMFLaserPNPrimDat > p;
00236     LMFLaserPNPrimDat dat;
00237     while(rset->next()) {
00238       p.first = EcalLogicID( rset->getString(1),     // name
00239                              rset->getInt(2),        // logic_id
00240                              rset->getInt(3),        // id1
00241                              rset->getInt(4),        // id2
00242                              rset->getInt(5),        // id3
00243                              rset->getString(6));    // maps_to
00244 
00245       dat.setFlag( rset->getInt(7) );
00246       dat.setMean( rset->getFloat(8) );
00247       dat.setRMS( rset->getFloat(9) );
00248       dat.setPeak( rset->getFloat(10) );
00249       dat.setPNAOverPNBMean( rset->getFloat(11) );
00250       dat.setPNAOverPNBRMS( rset->getFloat(12) );
00251       dat.setPNAOverPNBPeak( rset->getFloat(13) );
00252 
00253       p.second = dat;
00254       fillMap->insert(p);
00255     }
00256 
00257   } catch (SQLException &e) {
00258     throw(runtime_error("LMFLaserPNPrimDat::fetchData():  "+e.getMessage()));
00259   }
00260 }

int LMFLaserPNPrimDat::getFlag (  )  const [inline]

Definition at line 47 of file LMFLaserPNPrimDat.h.

References m_Flag.

Referenced by writeArrayDB().

00047 { return m_Flag; }

float LMFLaserPNPrimDat::getMean (  )  const [inline]

Definition at line 38 of file LMFLaserPNPrimDat.h.

References m_Mean.

Referenced by writeArrayDB().

00038 { return m_Mean; }

float LMFLaserPNPrimDat::getPeak (  )  const [inline]

Definition at line 44 of file LMFLaserPNPrimDat.h.

References m_Peak.

Referenced by writeArrayDB().

00044 { return m_Peak; }

float LMFLaserPNPrimDat::getPNAOverPNBMean (  )  const [inline]

Definition at line 50 of file LMFLaserPNPrimDat.h.

References m_PNAOverPNBMean.

Referenced by writeArrayDB().

00050 { return m_PNAOverPNBMean; }

float LMFLaserPNPrimDat::getPNAOverPNBPeak (  )  const [inline]

Definition at line 54 of file LMFLaserPNPrimDat.h.

References m_PNAOverPNBPeak.

Referenced by writeArrayDB().

00054 { return m_PNAOverPNBPeak; }

float LMFLaserPNPrimDat::getPNAOverPNBRMS (  )  const [inline]

Definition at line 52 of file LMFLaserPNPrimDat.h.

References m_PNAOverPNBRMS.

Referenced by writeArrayDB().

00052 { return m_PNAOverPNBRMS; }

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

Definition at line 41 of file LMFLaserPNPrimDat.h.

References m_RMS.

Referenced by writeArrayDB().

00041 { return m_RMS; }

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

Implements IDataItem.

Definition at line 24 of file LMFLaserPNPrimDat.h.

References _color, iBlue, iGreen, iIRed, and iRed.

Referenced by fetchData(), and prepareWrite().

00025   {
00026     switch( _color )
00027       {
00028       case iBlue:  return "LMF_LASER_BLUE_PN_PRIM_DAT"; 
00029       case iGreen: return "LMF_LASER_GREEN_PN_PRIM_DAT"; 
00030       case iRed:   return "LMF_LASER_RED_PN_PRIM_DAT"; 
00031       case iIRed:  return "LMF_LASER_IRED_PN_PRIM_DAT"; 
00032       }
00033   // default
00034     return "LMF_LASER_BLUE_PN_PRIM_DAT"; 
00035   }

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

Implements IDataItem.

Definition at line 44 of file LMFLaserPNPrimDat.cc.

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

00046 {
00047   this->checkConnection();
00048 
00049   // GHM
00050   std::string command_ = "INSERT INTO XXXXXX (lmf_iov_id, logic_id, flag, mean, rms, peak,  pna_over_pnB_mean, pna_over_pnB_rms, pna_over_pnB_peak ) VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9 )";
00051   command_.replace( command_.find("XXXXXX",0), 6, getTable() );
00052   //   cout << "In prepareWrite: command_" << command_ << endl;
00053 
00054   try {
00055     m_writeStmt = m_conn->createStatement();
00056     m_writeStmt->setSQL( command_.c_str() );
00057   } catch (SQLException &e) {
00058     throw(runtime_error("LMFLaserPNPrimDat::prepareWrite():  "+e.getMessage()));
00059   }
00060 }

void LMFLaserPNPrimDat::setColor ( int  color  )  [static]

Definition at line 263 of file LMFLaserPNPrimDat.cc.

References _color.

00263 { _color = color; }

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

Definition at line 46 of file LMFLaserPNPrimDat.h.

References m_Flag.

Referenced by fetchData().

00046 { m_Flag = x; }

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

Definition at line 37 of file LMFLaserPNPrimDat.h.

References m_Mean.

Referenced by fetchData().

00037 { m_Mean = mean; }

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

Definition at line 43 of file LMFLaserPNPrimDat.h.

References m_Peak.

Referenced by fetchData().

00043 { m_Peak = x; }

void LMFLaserPNPrimDat::setPNAOverPNBMean ( float  mean  )  [inline]

Definition at line 49 of file LMFLaserPNPrimDat.h.

References m_PNAOverPNBMean.

Referenced by fetchData().

00049 { m_PNAOverPNBMean = mean; }

void LMFLaserPNPrimDat::setPNAOverPNBPeak ( float  mean  )  [inline]

Definition at line 53 of file LMFLaserPNPrimDat.h.

References m_PNAOverPNBPeak.

Referenced by fetchData().

00053 { m_PNAOverPNBPeak = mean; }

void LMFLaserPNPrimDat::setPNAOverPNBRMS ( float  mean  )  [inline]

Definition at line 51 of file LMFLaserPNPrimDat.h.

References m_PNAOverPNBRMS.

Referenced by fetchData().

00051 { m_PNAOverPNBRMS = mean; }

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

Definition at line 40 of file LMFLaserPNPrimDat.h.

References m_RMS.

Referenced by fetchData().

00040 { m_RMS = RMS; }

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

Definition at line 95 of file LMFLaserPNPrimDat.cc.

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

00097 {
00098   this->checkConnection();
00099   this->checkPrepare();
00100 
00101   int iovID = iov->fetchID();
00102   if (!iovID) { throw(runtime_error("LMFLaserPNPrimDat::writeArrayDB:  IOV not in DB")); }
00103 
00104 
00105   int nrows=data->size(); 
00106   int* ids= new int[nrows];
00107   int* iovid_vec= new int[nrows];
00108   int* aa= new int[nrows];
00109   float* xx= new float[nrows];
00110   float* yy= new float[nrows];
00111   float* zz= new float[nrows];
00112   float* wwa= new float[nrows];
00113   float* uua= new float[nrows];
00114   float* tta= new float[nrows];
00115 
00116   ub2* ids_len= new ub2[nrows];
00117   ub2* iov_len= new ub2[nrows];
00118   ub2* a_len= new ub2[nrows];
00119   ub2* x_len= new ub2[nrows];
00120   ub2* y_len= new ub2[nrows];
00121   ub2* z_len= new ub2[nrows];
00122   ub2* wa_len= new ub2[nrows];
00123   ub2* ua_len= new ub2[nrows];
00124   ub2* ta_len= new ub2[nrows];
00125 
00126   const EcalLogicID* channel;
00127   const LMFLaserPNPrimDat* dataitem;
00128   int count=0;
00129   typedef map< EcalLogicID, LMFLaserPNPrimDat >::const_iterator CI;
00130   for (CI p = data->begin(); p != data->end(); ++p) {
00131         channel = &(p->first);
00132         int logicID = channel->getLogicID();
00133         if (!logicID) { throw(runtime_error("LMFLaserPNPrimDat::writeArrayDB:  Bad EcalLogicID")); }
00134         ids[count]=logicID;
00135         iovid_vec[count]=iovID;
00136 
00137         dataitem = &(p->second);
00138         // dataIface.writeDB( channel, dataitem, iov);
00139         int a=dataitem->getFlag();
00140         float x=dataitem->getMean();
00141         float y=dataitem->getRMS();
00142         float z=dataitem->getPeak();
00143         float wa=dataitem->getPNAOverPNBMean();
00144         float ua=dataitem->getPNAOverPNBRMS();
00145         float ta=dataitem->getPNAOverPNBPeak();
00146 
00147         aa[count]=a;
00148         xx[count]=x;
00149         yy[count]=y;
00150         zz[count]=z;
00151         wwa[count]=wa;
00152         uua[count]=ua;
00153         tta[count]=ta;
00154 
00155         ids_len[count]=sizeof(ids[count]);
00156         iov_len[count]=sizeof(iovid_vec[count]);
00157         
00158         a_len[count]=sizeof(aa[count]);
00159         x_len[count]=sizeof(xx[count]);
00160         y_len[count]=sizeof(yy[count]);
00161         z_len[count]=sizeof(zz[count]);
00162         wa_len[count]=sizeof(wwa[count]);
00163         ua_len[count]=sizeof(uua[count]);
00164         ta_len[count]=sizeof(tta[count]);
00165 
00166         count++;
00167      }
00168 
00169 
00170   try {
00171     m_writeStmt->setDataBuffer(1,  (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
00172     m_writeStmt->setDataBuffer(2,  (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
00173     m_writeStmt->setDataBuffer(3,  (dvoid*)aa,  OCCIINT , sizeof(aa[0]), a_len );
00174     m_writeStmt->setDataBuffer(4,  (dvoid*)xx,  OCCIFLOAT , sizeof(xx[0]), x_len );
00175     m_writeStmt->setDataBuffer(5,  (dvoid*)yy,  OCCIFLOAT , sizeof(yy[0]), y_len );
00176     m_writeStmt->setDataBuffer(6,  (dvoid*)zz,  OCCIFLOAT , sizeof(zz[0]), z_len );
00177     m_writeStmt->setDataBuffer(7,  (dvoid*)wwa, OCCIFLOAT , sizeof(wwa[0]), wa_len );
00178     m_writeStmt->setDataBuffer(8,  (dvoid*)uua, OCCIFLOAT , sizeof(uua[0]), ua_len );
00179     m_writeStmt->setDataBuffer(9,  (dvoid*)tta, OCCIFLOAT , sizeof(tta[0]), ta_len );
00180 
00181     m_writeStmt->executeArrayUpdate(nrows);
00182 
00183     delete [] ids;
00184     delete [] iovid_vec;
00185     delete [] aa;
00186     delete [] xx;
00187     delete [] yy;
00188     delete [] zz;
00189     delete [] wwa;
00190     delete [] uua;
00191     delete [] tta;
00192 
00193     delete [] ids_len;
00194     delete [] iov_len;
00195     delete [] a_len;
00196     delete [] x_len;
00197     delete [] y_len;
00198     delete [] z_len;
00199     delete [] wa_len;
00200     delete [] ua_len;
00201     delete [] ta_len;
00202 
00203   } catch (SQLException &e) {
00204     throw(runtime_error("LMFLaserPNPrimDat::writeArrayDB():  "+e.getMessage()));
00205   }
00206 }

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

Definition at line 64 of file LMFLaserPNPrimDat.cc.

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

00066 {
00067   this->checkConnection();
00068   this->checkPrepare();
00069 
00070   int iovID = iov->fetchID();
00071   if (!iovID) { throw(runtime_error("LMFLaserPNPrimDat::writeDB:  IOV not in DB")); }
00072 
00073   int logicID = ecid->getLogicID();
00074   if (!logicID) { throw(runtime_error("LMFLaserPNPrimDat::writeDB:  Bad EcalLogicID")); }
00075   
00076   try {
00077     m_writeStmt->setInt(1, iovID);
00078     m_writeStmt->setInt(2, logicID);
00079 
00080     m_writeStmt->setInt(3, item->getFlag() );
00081     m_writeStmt->setFloat(4, item->getMean() );
00082     m_writeStmt->setFloat(5, item->getRMS() );
00083     m_writeStmt->setFloat(6, item->getPeak() );
00084     m_writeStmt->setFloat(7, item->getPNAOverPNBMean() );
00085     m_writeStmt->setFloat(8, item->getPNAOverPNBRMS() );
00086     m_writeStmt->setFloat(9, item->getPNAOverPNBPeak() );
00087   
00088     m_writeStmt->executeUpdate();
00089   } catch (SQLException &e) {
00090     throw(runtime_error("LMFLaserPNPrimDat::writeDB():  "+e.getMessage()));
00091   }
00092 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 19 of file LMFLaserPNPrimDat.h.


Member Data Documentation

int LMFLaserPNPrimDat::_color = LMFLaserPNPrimDat::iBlue [static, private]

Definition at line 71 of file LMFLaserPNPrimDat.h.

Referenced by getTable(), LMFLaserPNPrimDat(), and setColor().

int LMFLaserPNPrimDat::m_Flag [private]

Definition at line 74 of file LMFLaserPNPrimDat.h.

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

float LMFLaserPNPrimDat::m_Mean [private]

Definition at line 76 of file LMFLaserPNPrimDat.h.

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

float LMFLaserPNPrimDat::m_Peak [private]

Definition at line 77 of file LMFLaserPNPrimDat.h.

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

float LMFLaserPNPrimDat::m_PNAOverPNBMean [private]

Definition at line 78 of file LMFLaserPNPrimDat.h.

Referenced by getPNAOverPNBMean(), LMFLaserPNPrimDat(), and setPNAOverPNBMean().

float LMFLaserPNPrimDat::m_PNAOverPNBPeak [private]

Definition at line 80 of file LMFLaserPNPrimDat.h.

Referenced by getPNAOverPNBPeak(), LMFLaserPNPrimDat(), and setPNAOverPNBPeak().

float LMFLaserPNPrimDat::m_PNAOverPNBRMS [private]

Definition at line 79 of file LMFLaserPNPrimDat.h.

Referenced by getPNAOverPNBRMS(), LMFLaserPNPrimDat(), and setPNAOverPNBRMS().

float LMFLaserPNPrimDat::m_RMS [private]

Definition at line 75 of file LMFLaserPNPrimDat.h.

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


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