CMS 3D CMS Logo

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

ODDelaysDat Class Reference

#include <ODDelaysDat.h>

Inheritance diagram for ODDelaysDat:
IODConfig IDBObject

List of all members.

Public Member Functions

int getFedId () const
int getId () const
int getSMId () const
std::string getTable ()
int getTimeOffset () const
int getTTId () const
 ODDelaysDat ()
void setFedId (int dac)
void setId (int dac)
void setSMId (int dac)
void setTimeOffset (int dac)
void setTTId (int dac)
 ~ODDelaysDat ()

Private Member Functions

void fetchData (std::vector< ODDelaysDat > *fillMap, int id) throw (std::runtime_error)
void fetchData (std::vector< ODDelaysDat > *fillMap, ODFEDelaysInfo *iov) throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeArrayDB (const std::vector< ODDelaysDat > data, ODFEDelaysInfo *iov) throw (std::runtime_error)
void writeDB (const ODDelaysDat *item, ODFEDelaysInfo *iov) throw (std::runtime_error)

Private Attributes

int m_fed
int m_ID
int m_sm
int m_t1
int m_tt

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 10 of file ODDelaysDat.h.


Constructor & Destructor Documentation

ODDelaysDat::ODDelaysDat ( )

Definition at line 10 of file ODDelaysDat.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_t1 = 0;

}
ODDelaysDat::~ODDelaysDat ( )

Definition at line 26 of file ODDelaysDat.cc.

{
}

Member Function Documentation

void ODDelaysDat::fetchData ( std::vector< ODDelaysDat > *  fillMap,
int  id 
) throw (std::runtime_error) [private]

Definition at line 73 of file ODDelaysDat.cc.

References alignCSCRings::e, AlCaHLTBitMon_ParallelJobs::p, setFedId(), setSMId(), setTimeOffset(), and setTTId().

Referenced by EcalCondDBInterface::fetchFEDelaysForRun().

{
  this->checkConnection();

  if (!iovID) { 
    //  throw(std::runtime_error("ODDelaysDat::writeDB:  IOV not in DB")); 
    return;
  }

  try {
    m_readStmt = m_conn->createStatement();
    m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :rec_id order by sm_id, fed_id, tt_id");
    m_readStmt->setInt(1, iovID);
    ResultSet* rset = m_readStmt->executeQuery();
    
    //    std::vector< ODDelaysDat > p;
    ODDelaysDat 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.setTimeOffset( rset->getInt(5) );

      p->push_back( dat);

    }
  } catch (SQLException &e) {
    throw(std::runtime_error("ODDelaysDat::fetchData():  "+e.getMessage()));
  }
}
void ODDelaysDat::fetchData ( std::vector< ODDelaysDat > *  fillMap,
ODFEDelaysInfo iov 
) throw (std::runtime_error) [private]

Definition at line 66 of file ODDelaysDat.cc.

References o2o::iov, and AlCaHLTBitMon_ParallelJobs::p.

                          {
  iov->setConnection(m_env, m_conn);
  int iovID = iov->fetchID();
  fetchData(p, iovID);
}
int ODDelaysDat::getFedId ( ) const [inline]

Definition at line 26 of file ODDelaysDat.h.

References m_fed.

Referenced by writeArrayDB().

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

Definition at line 20 of file ODDelaysDat.h.

References m_ID.

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

Definition at line 23 of file ODDelaysDat.h.

References m_sm.

Referenced by writeArrayDB().

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

Implements IODConfig.

Definition at line 17 of file ODDelaysDat.h.

{ return "DELAYS_DAT"; }
int ODDelaysDat::getTimeOffset ( ) const [inline]

Definition at line 33 of file ODDelaysDat.h.

References m_t1.

Referenced by writeArrayDB().

{ return m_t1; }
int ODDelaysDat::getTTId ( ) const [inline]

Definition at line 29 of file ODDelaysDat.h.

References m_tt.

Referenced by writeArrayDB().

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

Implements IODConfig.

Definition at line 32 of file ODDelaysDat.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, time_offset ) "
                        "VALUES (:1, :2, :3, :4, :5 )");
  } catch (SQLException &e) {
    throw(std::runtime_error("ODDelaysDat::prepareWrite():  "+e.getMessage()));
  }
}
void ODDelaysDat::setFedId ( int  dac) [inline]

Definition at line 25 of file ODDelaysDat.h.

References m_fed.

Referenced by fetchData().

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

Definition at line 19 of file ODDelaysDat.h.

References m_ID.

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

Definition at line 22 of file ODDelaysDat.h.

References m_sm.

Referenced by fetchData().

{ m_sm = dac; }
void ODDelaysDat::setTimeOffset ( int  dac) [inline]

Definition at line 32 of file ODDelaysDat.h.

References m_t1.

Referenced by fetchData().

{ m_t1 = dac; }
void ODDelaysDat::setTTId ( int  dac) [inline]

Definition at line 28 of file ODDelaysDat.h.

References m_tt.

Referenced by fetchData().

{ m_tt = dac; }
void ODDelaysDat::writeArrayDB ( const std::vector< ODDelaysDat data,
ODFEDelaysInfo iov 
) throw (std::runtime_error) [private]

Definition at line 108 of file ODDelaysDat.cc.

References prof2calltree::count, data, alignCSCRings::e, getFedId(), getSMId(), getTimeOffset(), getTTId(), 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];



  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];


  ODDelaysDat 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.getTimeOffset();


        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]);

     }


  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->executeArrayUpdate(nrows);

    delete [] ids;
    delete [] xx;
    delete [] yy;
    delete [] zz;
    delete [] st;

    delete [] ids_len;
    delete [] x_len;
    delete [] y_len;
    delete [] z_len;
    delete [] st_len;

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

Definition at line 48 of file ODDelaysDat.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->getTimeOffset() );

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

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 12 of file ODDelaysDat.h.


Member Data Documentation

int ODDelaysDat::m_fed [private]

Definition at line 53 of file ODDelaysDat.h.

Referenced by getFedId(), and setFedId().

int ODDelaysDat::m_ID [private]

Definition at line 56 of file ODDelaysDat.h.

Referenced by getId(), and setId().

int ODDelaysDat::m_sm [private]

Definition at line 52 of file ODDelaysDat.h.

Referenced by getSMId(), and setSMId().

int ODDelaysDat::m_t1 [private]

Definition at line 55 of file ODDelaysDat.h.

Referenced by getTimeOffset(), and setTimeOffset().

int ODDelaysDat::m_tt [private]

Definition at line 54 of file ODDelaysDat.h.

Referenced by getTTId(), and setTTId().