CMS 3D CMS Logo

LMFLaserConfigDat Class Reference

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

Inheritance diagram for LMFLaserConfigDat:

IDataItem IDBObject

List of all members.

Public Member Functions

float getAttenuator () const
float getCurrent () const
float getDelay1 () const
float getDelay2 () const
int getPNGain () const
float getPower () const
std::string getTable ()
int getVFEGain () const
int getWavelength () const
 LMFLaserConfigDat ()
void setAttenuator (float x)
void setCurrent (float x)
void setDelay1 (float x)
void setDelay2 (float x)
void setPNGain (int x)
void setPower (float x)
void setVFEGain (int x)
void setWavelength (int x)
 ~LMFLaserConfigDat ()

Private Member Functions

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

Private Attributes

float m_attenuator
float m_current
float m_delay1
float m_delay2
int m_pn_gain
float m_power
int m_vfe_gain
int m_wl

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file LMFLaserConfigDat.h.


Constructor & Destructor Documentation

LMFLaserConfigDat::LMFLaserConfigDat (  ) 

Definition at line 13 of file LMFLaserConfigDat.cc.

References m_attenuator, IDBObject::m_conn, m_current, m_delay1, m_delay2, IDBObject::m_env, m_pn_gain, m_power, IDataItem::m_readStmt, m_vfe_gain, m_wl, 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_wl=0;
00022    m_vfe_gain=0;
00023    m_pn_gain=0;
00024    m_power=0;
00025    m_attenuator=0;
00026    m_current=0;
00027    m_delay1=0;
00028    m_delay2=0;
00029 }

LMFLaserConfigDat::~LMFLaserConfigDat (  ) 

Definition at line 33 of file LMFLaserConfigDat.cc.

00034 {
00035 }


Member Function Documentation

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

Definition at line 218 of file LMFLaserConfigDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setAttenuator(), setCurrent(), setDelay1(), setDelay2(), setPNGain(), setPower(), setVFEGain(), and setWavelength().

00220 {
00221   this->checkConnection();
00222   fillMap->clear();
00223 
00224   iov->setConnection(m_env, m_conn);
00225   int iovID = iov->fetchID();
00226   if (!iovID) { 
00227     //  throw(runtime_error("LMFLaserConfigDat::writeDB:  IOV not in DB")); 
00228     return;
00229   }
00230 
00231   try {
00232   
00233     m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
00234                        "d.wavelength, d.vfe_gain, d.pn_gain, d.lsr_power, d.lsr_attenuator, d.lsr_current, d.lsr_delay_1, d.lsr_delay_2 "
00235                        "FROM channelview cv JOIN lmf_laser_config_dat d "
00236                        "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
00237                        "WHERE d.lmf_iov_id = :iov_id");
00238  
00239     m_readStmt->setInt(1, iovID);
00240     
00241     ResultSet* rset = m_readStmt->executeQuery();
00242      
00243     std::pair< EcalLogicID, LMFLaserConfigDat > p;
00244     LMFLaserConfigDat dat;
00245     while(rset->next()) {
00246       p.first = EcalLogicID( rset->getString(1),     // name
00247                              rset->getInt(2),        // logic_id
00248                              rset->getInt(3),        // id1
00249                              rset->getInt(4),        // id2
00250                              rset->getInt(5),        // id3
00251                              rset->getString(6));    // maps_to
00252 
00253 
00254       dat.setWavelength( rset->getInt(7) );
00255       dat.setVFEGain( rset->getInt(7) );
00256       dat.setPNGain( rset->getInt(7) );
00257       dat.setPower( rset->getFloat(8) );
00258       dat.setAttenuator( rset->getFloat(8) );
00259       dat.setCurrent( rset->getFloat(8) );
00260       dat.setDelay1( rset->getFloat(8) );
00261       dat.setDelay2( rset->getFloat(8) );
00262 
00263       p.second = dat;
00264       fillMap->insert(p);
00265     }
00266 
00267   } catch (SQLException &e) {
00268     throw(runtime_error("LMFLaserConfigDat::fetchData():  "+e.getMessage()));
00269   }
00270 }

float LMFLaserConfigDat::getAttenuator (  )  const [inline]

Definition at line 29 of file LMFLaserConfigDat.h.

References m_attenuator.

Referenced by writeArrayDB().

00029 { return m_attenuator; }

float LMFLaserConfigDat::getCurrent (  )  const [inline]

Definition at line 33 of file LMFLaserConfigDat.h.

References m_current.

Referenced by writeArrayDB().

00033 { return m_current; }

float LMFLaserConfigDat::getDelay1 (  )  const [inline]

Definition at line 35 of file LMFLaserConfigDat.h.

References m_delay1.

Referenced by writeArrayDB().

00035 { return m_delay1; }

float LMFLaserConfigDat::getDelay2 (  )  const [inline]

Definition at line 37 of file LMFLaserConfigDat.h.

References m_delay2.

Referenced by writeArrayDB().

00037 { return m_delay2; }

int LMFLaserConfigDat::getPNGain (  )  const [inline]

Definition at line 26 of file LMFLaserConfigDat.h.

References m_pn_gain.

Referenced by writeArrayDB().

00026 { return m_pn_gain; }

float LMFLaserConfigDat::getPower (  )  const [inline]

Definition at line 31 of file LMFLaserConfigDat.h.

References m_power.

Referenced by writeArrayDB().

00031 { return m_power; }

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

Implements IDataItem.

Definition at line 19 of file LMFLaserConfigDat.h.

00019 { return "LMF_LASER_CONFIG_DAT"; }

int LMFLaserConfigDat::getVFEGain (  )  const [inline]

Definition at line 24 of file LMFLaserConfigDat.h.

References m_vfe_gain.

Referenced by writeArrayDB().

00024 { return m_vfe_gain; }

int LMFLaserConfigDat::getWavelength (  )  const [inline]

Definition at line 22 of file LMFLaserConfigDat.h.

References m_wl.

Referenced by writeArrayDB().

00022 { return m_wl; }

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

Implements IDataItem.

Definition at line 39 of file LMFLaserConfigDat.cc.

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

00041 {
00042   this->checkConnection();
00043 
00044   try {
00045     m_writeStmt = m_conn->createStatement();
00046     m_writeStmt->setSQL("INSERT INTO lmf_laser_config_dat (lmf_iov_id, logic_id, "
00047                         "wavelength, vfe_gain, pn_gain, lsr_power, lsr_attenuator, lsr_current, lsr_delay_1, lsr_delay_2) "
00048                         "VALUES (:1, :2, "
00049                         ":3, :4, :5, :6, :7, :8, :9, :10 )");
00050   } catch (SQLException &e) {
00051     throw(runtime_error("LMFLaserConfigDat::prepareWrite():  "+e.getMessage()));
00052   }
00053 }

void LMFLaserConfigDat::setAttenuator ( float  x  )  [inline]

Definition at line 28 of file LMFLaserConfigDat.h.

References m_attenuator.

Referenced by fetchData().

00028 { m_attenuator = x; }

void LMFLaserConfigDat::setCurrent ( float  x  )  [inline]

Definition at line 32 of file LMFLaserConfigDat.h.

References m_current.

Referenced by fetchData().

00032 { m_current = x; }

void LMFLaserConfigDat::setDelay1 ( float  x  )  [inline]

Definition at line 34 of file LMFLaserConfigDat.h.

References m_delay1.

Referenced by fetchData().

00034 { m_delay1 = x; }

void LMFLaserConfigDat::setDelay2 ( float  x  )  [inline]

Definition at line 36 of file LMFLaserConfigDat.h.

References m_delay2.

Referenced by fetchData().

00036 { m_delay2 = x; }

void LMFLaserConfigDat::setPNGain ( int  x  )  [inline]

Definition at line 25 of file LMFLaserConfigDat.h.

References m_pn_gain.

Referenced by fetchData().

00025 { m_pn_gain = x; }

void LMFLaserConfigDat::setPower ( float  x  )  [inline]

Definition at line 30 of file LMFLaserConfigDat.h.

References m_power.

Referenced by fetchData().

00030 { m_power = x; }

void LMFLaserConfigDat::setVFEGain ( int  x  )  [inline]

Definition at line 23 of file LMFLaserConfigDat.h.

References m_vfe_gain.

Referenced by fetchData().

00023 { m_vfe_gain = x; }

void LMFLaserConfigDat::setWavelength ( int  x  )  [inline]

Definition at line 21 of file LMFLaserConfigDat.h.

References m_wl.

Referenced by fetchData().

00021 { m_wl = x; }

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

Definition at line 89 of file LMFLaserConfigDat.cc.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, getAttenuator(), getCurrent(), getDelay1(), getDelay2(), EcalLogicID::getLogicID(), getPNGain(), getPower(), getVFEGain(), getWavelength(), IDataItem::m_writeStmt, p, x, y, and z.

00091 {
00092   this->checkConnection();
00093   this->checkPrepare();
00094 
00095   int iovID = iov->fetchID();
00096   if (!iovID) { throw(runtime_error("LMFLaserConfigDat::writeArrayDB:  IOV not in DB")); }
00097 
00098 
00099   int nrows=data->size(); 
00100   int* ids= new int[nrows];
00101   int* iovid_vec= new int[nrows];
00102   
00103   int* xx= new int[nrows];
00104   int* yy= new int[nrows];
00105   int* zz= new int[nrows];
00106   float* wwa= new float[nrows];
00107   float* uua= new float[nrows];
00108   float* tta= new float[nrows];
00109   float* wwb= new float[nrows];
00110   float* uub= new float[nrows];
00111 
00112   ub2* ids_len= new ub2[nrows];
00113   ub2* iov_len= new ub2[nrows];
00114   ub2* x_len= new ub2[nrows];
00115   ub2* y_len= new ub2[nrows];
00116   ub2* z_len= new ub2[nrows];
00117   ub2* wa_len= new ub2[nrows];
00118   ub2* ua_len= new ub2[nrows];
00119   ub2* ta_len= new ub2[nrows];
00120   ub2* wb_len= new ub2[nrows];
00121   ub2* ub_len= new ub2[nrows];
00122 
00123   const EcalLogicID* channel;
00124   const LMFLaserConfigDat* dataitem;
00125   int count=0;
00126   typedef map< EcalLogicID, LMFLaserConfigDat >::const_iterator CI;
00127   for (CI p = data->begin(); p != data->end(); ++p) {
00128         channel = &(p->first);
00129         int logicID = channel->getLogicID();
00130         if (!logicID) { throw(runtime_error("LMFLaserConfigDat::writeArrayDB:  Bad EcalLogicID")); }
00131         ids[count]=logicID;
00132         iovid_vec[count]=iovID;
00133 
00134         dataitem = &(p->second);
00135         // dataIface.writeDB( channel, dataitem, iov);
00136 
00137         int x=dataitem->getWavelength();
00138         int y=dataitem->getVFEGain();
00139         int z=dataitem->getPNGain();
00140         float wa=dataitem->getPower();
00141         float ua=dataitem->getAttenuator();
00142         float ta=dataitem->getCurrent();
00143         float wb=dataitem->getDelay1();
00144         float ub=dataitem->getDelay2();
00145 
00146 
00147         xx[count]=x;
00148         yy[count]=y;
00149         zz[count]=z;
00150         wwa[count]=wa;
00151         uua[count]=ua;
00152         tta[count]=ta;
00153         wwb[count]=wb;
00154         uub[count]=ub;
00155 
00156         ids_len[count]=sizeof(ids[count]);
00157         iov_len[count]=sizeof(iovid_vec[count]);
00158         
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         wb_len[count]=sizeof(wwb[count]);
00166         ub_len[count]=sizeof(uub[count]);
00167 
00168         count++;
00169      }
00170 
00171 
00172   try {
00173     m_writeStmt->setDataBuffer(1,  (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
00174     m_writeStmt->setDataBuffer(2,  (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
00175     m_writeStmt->setDataBuffer(3,  (dvoid*)xx,  OCCIINT , sizeof(xx[0]), x_len );
00176     m_writeStmt->setDataBuffer(4,  (dvoid*)yy,  OCCIINT , sizeof(yy[0]), y_len );
00177     m_writeStmt->setDataBuffer(5,  (dvoid*)zz,  OCCIINT , sizeof(zz[0]), z_len );
00178     m_writeStmt->setDataBuffer(6,  (dvoid*)wwa, OCCIFLOAT , sizeof(wwa[0]), wa_len );
00179     m_writeStmt->setDataBuffer(7,  (dvoid*)uua, OCCIFLOAT , sizeof(uua[0]), ua_len );
00180     m_writeStmt->setDataBuffer(8,  (dvoid*)tta, OCCIFLOAT , sizeof(tta[0]), ta_len );
00181     m_writeStmt->setDataBuffer(9, (dvoid*)wwb, OCCIFLOAT , sizeof(wwb[0]), wb_len );
00182     m_writeStmt->setDataBuffer(10, (dvoid*)uub, OCCIFLOAT , sizeof(uub[0]), ub_len );
00183    
00184     m_writeStmt->executeArrayUpdate(nrows);
00185 
00186     delete [] ids;
00187     delete [] iovid_vec;
00188    
00189     delete [] xx;
00190     delete [] yy;
00191     delete [] zz;
00192  
00193     delete [] wwa;
00194     delete [] uua;
00195     delete [] tta;
00196     delete [] wwb;
00197     delete [] uub;
00198 
00199 
00200     delete [] ids_len;
00201     delete [] iov_len;
00202 
00203     delete [] x_len;
00204     delete [] y_len;
00205     delete [] z_len;
00206  
00207     delete [] wa_len;
00208     delete [] ua_len;
00209     delete [] ta_len;
00210     delete [] wb_len;
00211     delete [] ub_len;
00212 
00213   } catch (SQLException &e) {
00214     throw(runtime_error("LMFLaserConfigDat::writeArrayDB():  "+e.getMessage()));
00215   }
00216 }

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

Definition at line 57 of file LMFLaserConfigDat.cc.

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

00059 {
00060   this->checkConnection();
00061   this->checkPrepare();
00062 
00063   int iovID = iov->fetchID();
00064   if (!iovID) { throw(runtime_error("LMFLaserConfigDat::writeDB:  IOV not in DB")); }
00065 
00066   int logicID = ecid->getLogicID();
00067   if (!logicID) { throw(runtime_error("LMFLaserConfigDat::writeDB:  Bad EcalLogicID")); }
00068   
00069   try {
00070     m_writeStmt->setInt(1, iovID);
00071     m_writeStmt->setInt(2, logicID);
00072 
00073     m_writeStmt->setInt(3, item->getWavelength() );
00074     m_writeStmt->setInt(4, item->getVFEGain() );
00075     m_writeStmt->setInt(5, item->getPNGain() );
00076     m_writeStmt->setFloat(6, item->getPower() );
00077     m_writeStmt->setFloat(7, item->getAttenuator() );
00078     m_writeStmt->setFloat(8, item->getCurrent() );
00079     m_writeStmt->setFloat(9, item->getDelay1() );
00080     m_writeStmt->setFloat(10, item->getDelay2() );
00081   
00082     m_writeStmt->executeUpdate();
00083   } catch (SQLException &e) {
00084     throw(runtime_error("LMFLaserConfigDat::writeDB():  "+e.getMessage()));
00085   }
00086 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file LMFLaserConfigDat.h.


Member Data Documentation

float LMFLaserConfigDat::m_attenuator [private]

Definition at line 58 of file LMFLaserConfigDat.h.

Referenced by getAttenuator(), LMFLaserConfigDat(), and setAttenuator().

float LMFLaserConfigDat::m_current [private]

Definition at line 59 of file LMFLaserConfigDat.h.

Referenced by getCurrent(), LMFLaserConfigDat(), and setCurrent().

float LMFLaserConfigDat::m_delay1 [private]

Definition at line 60 of file LMFLaserConfigDat.h.

Referenced by getDelay1(), LMFLaserConfigDat(), and setDelay1().

float LMFLaserConfigDat::m_delay2 [private]

Definition at line 61 of file LMFLaserConfigDat.h.

Referenced by getDelay2(), LMFLaserConfigDat(), and setDelay2().

int LMFLaserConfigDat::m_pn_gain [private]

Definition at line 56 of file LMFLaserConfigDat.h.

Referenced by getPNGain(), LMFLaserConfigDat(), and setPNGain().

float LMFLaserConfigDat::m_power [private]

Definition at line 57 of file LMFLaserConfigDat.h.

Referenced by getPower(), LMFLaserConfigDat(), and setPower().

int LMFLaserConfigDat::m_vfe_gain [private]

Definition at line 55 of file LMFLaserConfigDat.h.

Referenced by getVFEGain(), LMFLaserConfigDat(), and setVFEGain().

int LMFLaserConfigDat::m_wl [private]

Definition at line 54 of file LMFLaserConfigDat.h.

Referenced by getWavelength(), LMFLaserConfigDat(), and setWavelength().


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