CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

ODWeightsDat Class Reference

#include <ODWeightsDat.h>

Inheritance diagram for ODWeightsDat:
IODConfig IDBObject

List of all members.

Public Member Functions

int getCrystalId () const
int getFedId () const
int getId () const
int getSMId () const
std::string getTable ()
int getTTId () const
std::vector< std::vector< float > > getWeight () const
float getWeight0 () const
float getWeight1 () const
float getWeight2 () const
float getWeight3 () const
float getWeight4 () const
float getWeight5 () const
 ODWeightsDat ()
void setCrystalId (int dac)
void setFedId (int dac)
void setId (int dac)
void setSMId (int dac)
void setTTId (int dac)
void setWeight (int pos, float x)
void setWeight0 (float x)
void setWeight1 (float x)
void setWeight2 (float x)
void setWeight3 (float x)
void setWeight4 (float x)
void setWeight5 (float x)
 ~ODWeightsDat ()

Private Member Functions

void clear ()
void fetchData (std::vector< ODWeightsDat > *fillMap, ODFEWeightsInfo *iov) throw (std::runtime_error)
void fetchData (ODWeightsDat *p) throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeArrayDB (const std::vector< ODWeightsDat > data, ODFEWeightsInfo *iov) throw (std::runtime_error)
void writeDB (const ODWeightsDat *item, ODFEWeightsInfo *iov) throw (std::runtime_error)

Private Attributes

std::vector< std::vector< float > > dccw
int m_fed
int m_ID
int m_sm
int m_tt
float m_wei [6]
float m_wei0
float m_wei1
float m_wei2
float m_wei3
float m_wei4
float m_wei5
int m_xt

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 12 of file ODWeightsDat.h.


Constructor & Destructor Documentation

ODWeightsDat::ODWeightsDat ( )

Definition at line 10 of file ODWeightsDat.cc.

References NULL.

{
  m_env = NULL;
  m_conn = NULL;
  m_writeStmt = NULL;
  m_readStmt = NULL;

  m_sm = 0;
  m_fed = 0;
  m_tt = 0;
  m_xt = 0;

}
ODWeightsDat::~ODWeightsDat ( )

Definition at line 26 of file ODWeightsDat.cc.

{
}

Member Function Documentation

void ODWeightsDat::clear ( void  ) [private]

Definition at line 30 of file ODWeightsDat.cc.

                         {
  m_sm = 0;
  m_fed = 0;
  m_tt = 0;
  m_xt = 0;
  m_wei0 = 0;
  m_wei1 = 0;
  m_wei2 = 0;
  m_wei3 = 0;
  m_wei4 = 0;
  m_wei5 = 0;
}
void ODWeightsDat::fetchData ( std::vector< ODWeightsDat > *  fillMap,
ODFEWeightsInfo iov 
) throw (std::runtime_error) [private]

Definition at line 87 of file ODWeightsDat.cc.

References gather_cfg::cout, alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, setCrystalId(), setFedId(), setSMId(), setTTId(), and setWeight().

{
  this->checkConnection();

  iov->setConnection(m_env, m_conn);
  int iovID = iov->fetchID();
  if (!iovID) { 
    std::cout <<"ID not in the DB"<< endl; 
    return;
  }

  try {
    m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by sm_id, fed_id, tt_id, cry_id");
    m_readStmt->setInt(1, iovID);
    ResultSet* rset = m_readStmt->executeQuery();
    
    //    std::vector< ODWeightsDat > p;
    ODWeightsDat dat;
    while(rset->next()) {
      // dat.setId( rset->getInt(1) );
      dat.setSMId( rset->getInt(2) );
      dat.setFedId( rset->getInt(3) );
      dat.setTTId( rset->getInt(4) );
      dat.setCrystalId( rset->getInt(5) );
      /*
      dat.setWeight0( rset->getFloat(6) );
      dat.setWeight1( rset->getFloat(7) );
      dat.setWeight2( rset->getFloat(8) );
      dat.setWeight3( rset->getFloat(9) );
      dat.setWeight4( rset->getFloat(10) );
      dat.setWeight5( rset->getFloat(11) );
      */
      p->push_back( dat);
      for(int iwei = 0; iwei < 6; iwei++) {
        dat.setWeight(iwei, rset->getFloat(6 + iwei) );
      }
      std::vector<float> dccwei( m_wei,  m_wei+6);
      dccw.push_back(dccwei);  // vector vector

    }


  } catch (SQLException &e) {
    throw(std::runtime_error("ODWeightsDat::fetchData():  "+e.getMessage()));
  }
}
void ODWeightsDat::fetchData ( ODWeightsDat p) throw (std::runtime_error) [private]

Definition at line 135 of file ODWeightsDat.cc.

References gather_cfg::cout, alignCSCRings::e, and AlCaHLTBitMon_ParallelJobs::p.

{
  this->checkConnection();

  try {
    m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :1 order by sm_id, fed_id, tt_id, cry_id");
    m_readStmt->setInt(1, p->getId());
    ResultSet* rset = m_readStmt->executeQuery();
    
    int row = 0;
    while(rset->next()) {
      row++;
      p->setSMId(      rset->getInt(2) );
      p->setFedId(     rset->getInt(3) );
      p->setTTId(      rset->getInt(4) );
      p->setCrystalId( rset->getInt(5) );
      for(int iwei = 0; iwei < 6; iwei++) {
        p->setWeight(iwei, rset->getFloat(6 + iwei) );
      }
      std::vector<float> dccwei( m_wei,  m_wei+6);
      dccw.push_back(dccwei);  // vector vector
    }  // loop on all rows in the table
    std::cout << " table " << getTable() << " total nb of rows " << row << std::endl;

  } catch (SQLException &e) {
    throw(std::runtime_error("ODWeightsDat::fetchData():  "+e.getMessage()));
  }
}
int ODWeightsDat::getCrystalId ( ) const [inline]

Definition at line 34 of file ODWeightsDat.h.

References m_xt.

Referenced by writeArrayDB().

{ return m_xt; }
int ODWeightsDat::getFedId ( ) const [inline]

Definition at line 28 of file ODWeightsDat.h.

References m_fed.

Referenced by writeArrayDB().

{ return m_fed; }
int ODWeightsDat::getId ( ) const [inline]

Definition at line 22 of file ODWeightsDat.h.

References m_ID.

{ return m_ID; }
int ODWeightsDat::getSMId ( ) const [inline]

Definition at line 25 of file ODWeightsDat.h.

References m_sm.

Referenced by writeArrayDB().

{ return m_sm; }
std::string ODWeightsDat::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 19 of file ODWeightsDat.h.

{ return "DCC_WEIGHTS_DAT"; }
int ODWeightsDat::getTTId ( ) const [inline]

Definition at line 31 of file ODWeightsDat.h.

References m_tt.

Referenced by writeArrayDB().

{ return m_tt; }
std::vector<std::vector<float> > ODWeightsDat::getWeight ( ) const [inline]

Definition at line 52 of file ODWeightsDat.h.

References dccw.

Referenced by popcon::EcalSRPHandler::getNewObjects().

{ return dccw; }
float ODWeightsDat::getWeight0 ( ) const [inline]

Definition at line 45 of file ODWeightsDat.h.

References m_wei0.

Referenced by writeArrayDB().

{ return m_wei0; }
float ODWeightsDat::getWeight1 ( ) const [inline]

Definition at line 46 of file ODWeightsDat.h.

References m_wei1.

Referenced by writeArrayDB().

{ return m_wei1; }
float ODWeightsDat::getWeight2 ( ) const [inline]

Definition at line 47 of file ODWeightsDat.h.

References m_wei2.

Referenced by writeArrayDB().

{ return m_wei2; }
float ODWeightsDat::getWeight3 ( ) const [inline]

Definition at line 48 of file ODWeightsDat.h.

References m_wei3.

Referenced by writeArrayDB().

{ return m_wei3; }
float ODWeightsDat::getWeight4 ( ) const [inline]

Definition at line 49 of file ODWeightsDat.h.

References m_wei4.

Referenced by writeArrayDB().

{ return m_wei4; }
float ODWeightsDat::getWeight5 ( ) const [inline]

Definition at line 50 of file ODWeightsDat.h.

References m_wei5.

Referenced by writeArrayDB().

{ return m_wei5; }
void ODWeightsDat::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 44 of file ODWeightsDat.cc.

References alignCSCRings::e.

{
  this->checkConnection();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO "+getTable()+" (rec_id, sm_id, fed_id, tt_id, cry_id, wei0, wei1, wei2, wei3, wei4, wei5 ) "
                        "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 , :9, :10, :11 )");
  } catch (SQLException &e) {
    throw(std::runtime_error("ODWeightsDat::prepareWrite():  "+e.getMessage()));
  }
}
void ODWeightsDat::setCrystalId ( int  dac) [inline]

Definition at line 33 of file ODWeightsDat.h.

References m_xt.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

{ m_xt = dac; }
void ODWeightsDat::setFedId ( int  dac) [inline]

Definition at line 27 of file ODWeightsDat.h.

References m_fed.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

{ m_fed = dac; }
void ODWeightsDat::setId ( int  dac) [inline]

Definition at line 21 of file ODWeightsDat.h.

References m_ID.

Referenced by popcon::EcalSRPHandler::getNewObjects(), and EcalDccWeightBuilder::writeWeightToDB().

{ m_ID = dac; }
void ODWeightsDat::setSMId ( int  dac) [inline]

Definition at line 24 of file ODWeightsDat.h.

References m_sm.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

{ m_sm = dac; }
void ODWeightsDat::setTTId ( int  dac) [inline]

Definition at line 30 of file ODWeightsDat.h.

References m_tt.

Referenced by fetchData(), and EcalDccWeightBuilder::writeWeightToDB().

{ m_tt = dac; }
void ODWeightsDat::setWeight ( int  pos,
float  x 
) [inline]

Definition at line 43 of file ODWeightsDat.h.

References m_wei, pos, and x.

Referenced by fetchData().

{ m_wei[pos] = x; }
void ODWeightsDat::setWeight0 ( float  x) [inline]

Definition at line 36 of file ODWeightsDat.h.

References m_wei0, and x.

Referenced by EcalDccWeightBuilder::writeWeightToDB().

{ m_wei0 = x; }
void ODWeightsDat::setWeight1 ( float  x) [inline]

Definition at line 37 of file ODWeightsDat.h.

References m_wei1, and x.

Referenced by EcalDccWeightBuilder::writeWeightToDB().

{ m_wei1 = x; }
void ODWeightsDat::setWeight2 ( float  x) [inline]

Definition at line 38 of file ODWeightsDat.h.

References m_wei2, and x.

Referenced by EcalDccWeightBuilder::writeWeightToDB().

{ m_wei2 = x; }
void ODWeightsDat::setWeight3 ( float  x) [inline]

Definition at line 39 of file ODWeightsDat.h.

References m_wei3, and x.

Referenced by EcalDccWeightBuilder::writeWeightToDB().

{ m_wei3 = x; }
void ODWeightsDat::setWeight4 ( float  x) [inline]

Definition at line 40 of file ODWeightsDat.h.

References m_wei4, and x.

Referenced by EcalDccWeightBuilder::writeWeightToDB().

{ m_wei4 = x; }
void ODWeightsDat::setWeight5 ( float  x) [inline]

Definition at line 41 of file ODWeightsDat.h.

References m_wei5, and x.

Referenced by EcalDccWeightBuilder::writeWeightToDB().

{ m_wei5 = x; }
void ODWeightsDat::writeArrayDB ( const std::vector< ODWeightsDat data,
ODFEWeightsInfo iov 
) throw (std::runtime_error) [private]

Definition at line 167 of file ODWeightsDat.cc.

References prof2calltree::count, data, alignCSCRings::e, getCrystalId(), getFedId(), getSMId(), getTTId(), getWeight0(), getWeight1(), getWeight2(), getWeight3(), getWeight4(), getWeight5(), and o2o::iov.

{
  this->checkConnection();

  int iovID = iov->fetchID();
  if (!iovID) { throw(std::runtime_error("ODDelays::writeArrayDB:  ODFEDelaysInfo not in DB")); }


  int nrows=data.size(); 
  int* ids= new int[nrows];
  int* xx= new int[nrows];
  int* yy= new int[nrows];
  int* zz= new int[nrows];
  int* st= new int[nrows];
  float* xx1= new float[nrows];
  float* yy1= new float[nrows];
  float* zz1= new float[nrows];
  float* xx2= new float[nrows];
  float* yy2= new float[nrows];
  float* zz2= new float[nrows];


  ub2* ids_len= new ub2[nrows];
  ub2* x_len= new ub2[nrows];
  ub2* y_len= new ub2[nrows];
  ub2* z_len= new ub2[nrows];
  ub2* st_len= new ub2[nrows];
  ub2* x1_len= new ub2[nrows];
  ub2* y1_len= new ub2[nrows];
  ub2* z1_len= new ub2[nrows];
  ub2* x2_len= new ub2[nrows];
  ub2* y2_len= new ub2[nrows];
  ub2* z2_len= new ub2[nrows];

  ODWeightsDat dataitem;
  
  int n_data= (int) data.size();
  for (int count = 0; count <n_data ; count++) {
    dataitem=data[count];
    ids[count]=iovID;
    xx[count]=dataitem.getSMId();
    yy[count]=dataitem.getFedId();
    zz[count]=dataitem.getTTId();
    st[count]=dataitem.getCrystalId();
    xx1[count]=dataitem.getWeight0();
    yy1[count]=dataitem.getWeight1();
    zz1[count]=dataitem.getWeight2();
    xx2[count]=dataitem.getWeight3();
    yy2[count]=dataitem.getWeight4();
    zz2[count]=dataitem.getWeight5();


        ids_len[count]=sizeof(ids[count]);
        x_len[count]=sizeof(xx[count]);
        y_len[count]=sizeof(yy[count]);
        z_len[count]=sizeof(zz[count]);
        st_len[count]=sizeof(st[count]);
        x1_len[count]=sizeof(xx1[count]);
        y1_len[count]=sizeof(yy1[count]);
        z1_len[count]=sizeof(zz1[count]);
        x2_len[count]=sizeof(xx2[count]);
        y2_len[count]=sizeof(yy2[count]);
        z2_len[count]=sizeof(zz2[count]);

     }


  try {
    m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT, sizeof(ids[0]),ids_len);
    m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT , sizeof(xx[0]), x_len );
    m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
    m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );
    m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT , sizeof(st[0]), st_len );
    m_writeStmt->setDataBuffer(6, (dvoid*)xx1, OCCIFLOAT , sizeof(xx1[0]), x1_len );
    m_writeStmt->setDataBuffer(7, (dvoid*)yy1, OCCIFLOAT , sizeof(yy1[0]), y1_len );
    m_writeStmt->setDataBuffer(8, (dvoid*)zz1, OCCIFLOAT , sizeof(zz1[0]), z1_len );
    m_writeStmt->setDataBuffer(9, (dvoid*)xx2, OCCIFLOAT , sizeof(xx2[0]), x2_len );
    m_writeStmt->setDataBuffer(10, (dvoid*)yy2, OCCIFLOAT , sizeof(yy2[0]), y2_len );
    m_writeStmt->setDataBuffer(11, (dvoid*)zz2, OCCIFLOAT , sizeof(zz2[0]), z2_len );
   

    m_writeStmt->executeArrayUpdate(nrows);

    delete [] ids;
    delete [] xx;
    delete [] yy;
    delete [] zz;
    delete [] st;
    delete [] xx1;
    delete [] yy1;
    delete [] zz1;
    delete [] xx2;
    delete [] yy2;
    delete [] zz2;

    delete [] ids_len;
    delete [] x_len;
    delete [] y_len;
    delete [] z_len;
    delete [] st_len;
    delete [] x1_len;
    delete [] y1_len;
    delete [] z1_len;
    delete [] x2_len;
    delete [] y2_len;
    delete [] z2_len;

  } catch (SQLException &e) {
    throw(std::runtime_error("ODWeightsDat::writeArrayDB():  "+e.getMessage()));
  }
}
void ODWeightsDat::writeDB ( const ODWeightsDat item,
ODFEWeightsInfo iov 
) throw (std::runtime_error) [private]

Definition at line 60 of file ODWeightsDat.cc.

References alignCSCRings::e.

{
  this->checkConnection();

  try {
    m_writeStmt->setInt(1, item->getId());
    m_writeStmt->setInt(2, item->getSMId());
    m_writeStmt->setInt(3, item->getFedId() );
    m_writeStmt->setInt(4, item->getTTId() );
    m_writeStmt->setInt(5, item->getCrystalId() );
    
    m_writeStmt->setFloat(6, item->getWeight0() );
    m_writeStmt->setFloat(7, item->getWeight1() );
    m_writeStmt->setFloat(8, item->getWeight2() );
    m_writeStmt->setFloat(9, item->getWeight3() );
    m_writeStmt->setFloat(10, item->getWeight4() );
    m_writeStmt->setFloat(11, item->getWeight5() );

    m_writeStmt->executeUpdate();
  } catch (SQLException &e) {
    throw(std::runtime_error("ODWeightsDat::writeDB():  "+e.getMessage()));
  }
}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file ODWeightsDat.h.


Member Data Documentation

std::vector<std::vector<float> > ODWeightsDat::dccw [private]

Definition at line 86 of file ODWeightsDat.h.

Referenced by getWeight().

int ODWeightsDat::m_fed [private]

Definition at line 73 of file ODWeightsDat.h.

Referenced by getFedId(), and setFedId().

int ODWeightsDat::m_ID [private]

Definition at line 76 of file ODWeightsDat.h.

Referenced by getId(), and setId().

int ODWeightsDat::m_sm [private]

Definition at line 72 of file ODWeightsDat.h.

Referenced by getSMId(), and setSMId().

int ODWeightsDat::m_tt [private]

Definition at line 74 of file ODWeightsDat.h.

Referenced by getTTId(), and setTTId().

float ODWeightsDat::m_wei[6] [private]

Definition at line 85 of file ODWeightsDat.h.

Referenced by setWeight().

float ODWeightsDat::m_wei0 [private]

Definition at line 78 of file ODWeightsDat.h.

Referenced by getWeight0(), and setWeight0().

float ODWeightsDat::m_wei1 [private]

Definition at line 79 of file ODWeightsDat.h.

Referenced by getWeight1(), and setWeight1().

float ODWeightsDat::m_wei2 [private]

Definition at line 80 of file ODWeightsDat.h.

Referenced by getWeight2(), and setWeight2().

float ODWeightsDat::m_wei3 [private]

Definition at line 81 of file ODWeightsDat.h.

Referenced by getWeight3(), and setWeight3().

float ODWeightsDat::m_wei4 [private]

Definition at line 82 of file ODWeightsDat.h.

Referenced by getWeight4(), and setWeight4().

float ODWeightsDat::m_wei5 [private]

Definition at line 83 of file ODWeightsDat.h.

Referenced by getWeight5(), and setWeight5().

int ODWeightsDat::m_xt [private]

Definition at line 75 of file ODWeightsDat.h.

Referenced by getCrystalId(), and setCrystalId().