CMS 3D CMS Logo

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

ODWeightsSamplesDat Class Reference

#include <ODWeightsSamplesDat.h>

Inheritance diagram for ODWeightsSamplesDat:
IODConfig IDBObject

List of all members.

Public Member Functions

int getFedId () const
int getId () const
int getSampleId () const
std::string getTable ()
int getWeightNumber () const
 ODWeightsSamplesDat ()
void setFedId (int dac)
void setId (int dac)
void setSampleId (int dac)
void setWeightNumber (int dac)
 ~ODWeightsSamplesDat ()

Private Member Functions

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

Private Attributes

int m_fed
int m_ID
int m_sn
int m_ss

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 12 of file ODWeightsSamplesDat.h.


Constructor & Destructor Documentation

ODWeightsSamplesDat::ODWeightsSamplesDat ( )

Definition at line 10 of file ODWeightsSamplesDat.cc.

References NULL.

ODWeightsSamplesDat::~ODWeightsSamplesDat ( )

Definition at line 23 of file ODWeightsSamplesDat.cc.

{
}

Member Function Documentation

void ODWeightsSamplesDat::clear ( void  ) [private]

Definition at line 27 of file ODWeightsSamplesDat.cc.

                                {
  m_fed = 0;
  m_ss = 0;
  m_sn = 0;
}
void ODWeightsSamplesDat::fetchData ( std::vector< ODWeightsSamplesDat > *  fillMap,
ODFEWeightsInfo iov 
) throw (std::runtime_error) [private]

Definition at line 68 of file ODWeightsSamplesDat.cc.

References gather_cfg::cout, alignCSCRings::e, o2o::iov, AlCaHLTBitMon_ParallelJobs::p, setFedId(), setSampleId(), and setWeightNumber().

{
  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 fed_id, sample_id");
    m_readStmt->setInt(1, iovID);
    ResultSet* rset = m_readStmt->executeQuery();
    
    //    std::vector< ODWeightsSamplesDat > p;
    ODWeightsSamplesDat dat;
    while(rset->next()) {
      // dat.setId( rset->getInt(1) );
      dat.setFedId( rset->getInt(2) );
      dat.setSampleId( rset->getInt(3) );
      dat.setWeightNumber( rset->getInt(4) );

      p->push_back( dat);

    }

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

Definition at line 103 of file ODWeightsSamplesDat.cc.

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

{
  this->checkConnection();

  try {
    m_readStmt->setSQL("SELECT * FROM " + getTable() + " WHERE rec_id = :1 order by fed_id, sample_id");
    m_readStmt->setInt(1, p->getId());
    ResultSet* rset = m_readStmt->executeQuery();
    
    while(rset->next()) {
      p->setFedId(        rset->getInt(2) );
      p->setSampleId(     rset->getInt(3) );
      p->setWeightNumber( rset->getInt(4) );
    }

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

Definition at line 25 of file ODWeightsSamplesDat.h.

References m_fed.

Referenced by writeArrayDB().

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

Definition at line 22 of file ODWeightsSamplesDat.h.

References m_ID.

{ return m_ID; }
int ODWeightsSamplesDat::getSampleId ( ) const [inline]

Definition at line 28 of file ODWeightsSamplesDat.h.

References m_ss.

Referenced by popcon::EcalSRPHandler::getNewObjects(), and writeArrayDB().

{ return m_ss; }
std::string ODWeightsSamplesDat::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 19 of file ODWeightsSamplesDat.h.

{ return "DCC_WEIGHTSAMPLE_DAT"; }
int ODWeightsSamplesDat::getWeightNumber ( ) const [inline]

Definition at line 31 of file ODWeightsSamplesDat.h.

References m_sn.

Referenced by writeArrayDB().

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

Implements IODConfig.

Definition at line 33 of file ODWeightsSamplesDat.cc.

References alignCSCRings::e.

{
  this->checkConnection();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO "+getTable()+" (rec_id, fed_id, sample_id, weight_number ) "
                        "VALUES (:1, :2, :3, :4 )");
  } catch (SQLException &e) {
    throw(std::runtime_error("ODWeightsSamplesDat::prepareWrite():  "+e.getMessage()));
  }
}
void ODWeightsSamplesDat::setFedId ( int  dac) [inline]

Definition at line 24 of file ODWeightsSamplesDat.h.

References m_fed.

Referenced by fetchData().

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

Definition at line 21 of file ODWeightsSamplesDat.h.

References m_ID.

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

{ m_ID = dac; }
void ODWeightsSamplesDat::setSampleId ( int  dac) [inline]

Definition at line 27 of file ODWeightsSamplesDat.h.

References m_ss.

Referenced by fetchData().

{ m_ss = dac; }
void ODWeightsSamplesDat::setWeightNumber ( int  dac) [inline]

Definition at line 30 of file ODWeightsSamplesDat.h.

References m_sn.

Referenced by fetchData().

{ m_sn = dac; }
void ODWeightsSamplesDat::writeArrayDB ( const std::vector< ODWeightsSamplesDat data,
ODFEWeightsInfo iov 
) throw (std::runtime_error) [private]

Definition at line 126 of file ODWeightsSamplesDat.cc.

References prof2calltree::count, AlCaHLTBitMon_QueryRunRegistry::data, alignCSCRings::e, getFedId(), getSampleId(), getWeightNumber(), 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];

  ub2* ids_len= new ub2[nrows];
  ub2* x_len= new ub2[nrows];
  ub2* y_len= new ub2[nrows];
  ub2* z_len= new ub2[nrows];

  ODWeightsSamplesDat dataitem;
  
  int n_data= (int) data.size();
  for (int count = 0; count <n_data ; count++) {
    dataitem=data[count];
    ids[count]=iovID;
    xx[count]=dataitem.getFedId();
    yy[count]=dataitem.getSampleId();
    zz[count]=dataitem.getWeightNumber();


        ids_len[count]=sizeof(ids[count]);
        x_len[count]=sizeof(xx[count]);
        y_len[count]=sizeof(yy[count]);
        z_len[count]=sizeof(zz[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->executeArrayUpdate(nrows);

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

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

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

Definition at line 49 of file ODWeightsSamplesDat.cc.

References alignCSCRings::e.

{
  this->checkConnection();

  try {
    m_writeStmt->setInt(1, item->getId());
    m_writeStmt->setInt(2, item->getFedId() );
    m_writeStmt->setInt(3, item->getSampleId() );
    m_writeStmt->setInt(4, item->getWeightNumber() );
    
    m_writeStmt->executeUpdate();
  } catch (SQLException &e) {
    throw(std::runtime_error("ODWeightsSamplesDat::writeDB():  "+e.getMessage()));
  }
}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file ODWeightsSamplesDat.h.


Member Data Documentation

Definition at line 54 of file ODWeightsSamplesDat.h.

Referenced by getFedId(), and setFedId().

Definition at line 57 of file ODWeightsSamplesDat.h.

Referenced by getId(), and setId().

Definition at line 56 of file ODWeightsSamplesDat.h.

Referenced by getWeightNumber(), and setWeightNumber().

Definition at line 55 of file ODWeightsSamplesDat.h.

Referenced by getSampleId(), and setSampleId().