CMS 3D CMS Logo

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

ODFEDAQConfig Class Reference

#include <ODFEDAQConfig.h>

Inheritance diagram for ODFEDAQConfig:
IODConfig IDBObject

List of all members.

Public Member Functions

int fetchNextId () throw (std::runtime_error)
int getBadTTId () const
int getBadXtId () const
std::string getComment () const
int getDelayId () const
int getId () const
int getPedestalId () const
std::string getTable ()
int getTriggerBadTTId () const
int getTriggerBadXtId () const
int getVersion () const
int getWeightId () const
 ODFEDAQConfig ()
void setBadTTId (int x)
void setBadXtId (int x)
void setComment (std::string x)
void setDelayId (int x)
void setId (int id)
void setParameters (std::map< std::string, std::string > my_keys_map)
void setPedestalId (int x)
void setTriggerBadTTId (int x)
void setTriggerBadXtId (int x)
void setVersion (int id)
void setWeightId (int x)
 ~ODFEDAQConfig ()

Private Member Functions

void clear ()
void fetchData (ODFEDAQConfig *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeDB () throw (std::runtime_error)

Private Attributes

int m_btt
int m_bxt
std::string m_com
int m_del
int m_ID
int m_ped
int m_tbtt
int m_tbxt
int m_version
int m_wei

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 9 of file ODFEDAQConfig.h.


Constructor & Destructor Documentation

ODFEDAQConfig::ODFEDAQConfig ( )

Definition at line 21 of file ODFEDAQConfig.cc.

References hitfit::clear(), and NULL.

ODFEDAQConfig::~ODFEDAQConfig ( )

Definition at line 49 of file ODFEDAQConfig.cc.

{
}

Member Function Documentation

void ODFEDAQConfig::clear ( void  ) [private]
void ODFEDAQConfig::fetchData ( ODFEDAQConfig result) throw (std::runtime_error) [private]

Definition at line 157 of file ODFEDAQConfig.cc.

References gather_cfg::cout, alignCSCRings::e, getInt(), and query::result.

Referenced by EcalCondDBInterface::fetchFEDelaysForRun().

{
  this->checkConnection();
  result->clear();
  if(result->getId()==0 && (result->getConfigTag()=="") ){
    throw(std::runtime_error("ODFEDAQConfig::fetchData(): no Id defined for this ODFEDAQConfig "));
  }

  m_readStmt = m_conn->createStatement(); 
  if(result->getConfigTag()!="" && result->getVersion() ==0  ){
    int new_version=0;
    std::cout<< "using new method : retrieving last version for this tag "<<endl;
    try {
      this->checkConnection();

      m_readStmt->setSQL("select max(version) from "+getTable()+" where tag=:tag " );
      m_readStmt->setString(1, result->getConfigTag());
      std::cout << "Getting last ver" << std::endl << std::flush; 
     ResultSet* rset = m_readStmt->executeQuery();
      while (rset->next ()){
        new_version= rset->getInt(1);
      }
      m_conn->terminateStatement(m_readStmt);

      //      m_readStmt = m_conn->createStatement(); 
      
      result->setVersion(new_version);
      
    } catch (SQLException &e) {
      throw(std::runtime_error("ODFEDAQConfig::fetchData():  "+e.getMessage()));
    }
    
    
    
  }

  try {

    m_readStmt->setSQL("SELECT * FROM " + getTable() +   
                       " where ( config_id = :1 or (tag=:2 AND version=:3 ) )" );
    m_readStmt->setInt(1, result->getId());
    m_readStmt->setString(2, result->getConfigTag());
    m_readStmt->setInt(3, result->getVersion());
    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();

    // 1 is the id and 2 is the config tag and 3 is the version

    result->setId(rset->getInt(1));
    result->setConfigTag(rset->getString(2));
    result->setVersion(rset->getInt(3));

    result->setPedestalId(       getInt(rset,4) );
    result->setDelayId(          getInt(rset,5) );
    result->setWeightId(         getInt(rset,6) );
    result->setBadXtId(          getInt(rset,7) );
    result->setBadTTId(          getInt(rset,8) );
    result->setTriggerBadXtId(   getInt(rset,9) );
    result->setTriggerBadTTId(   getInt(rset,10) );
    result->setComment(          rset->getString(11) );

  } catch (SQLException &e) {
    throw(std::runtime_error("ODFEDAQConfig::fetchData():  "+e.getMessage()));
  }
}
int ODFEDAQConfig::fetchID ( ) throw (std::runtime_error) [private]

Definition at line 225 of file ODFEDAQConfig.cc.

References alignCSCRings::e.

{
  // Return from memory if available
  if (m_ID!=0) {
    return m_ID;
  }

  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT config_id FROM "+ getTable()+
                 "WHERE  tag=:1 and version=:2 " );

    stmt->setString(1, getConfigTag() );
    stmt->setInt(2, getVersion() );

    ResultSet* rset = stmt->executeQuery();

    if (rset->next()) {
      m_ID = rset->getInt(1);
    } else {
      m_ID = 0;
    }
    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("ODFEDAQConfig::fetchID:  "+e.getMessage()));
  }

  return m_ID;
}
int ODFEDAQConfig::fetchNextId ( ) throw (std::runtime_error)

Definition at line 55 of file ODFEDAQConfig.cc.

References alignCSCRings::e, and query::result.

                                                        {

  int result=0;
  try {
    this->checkConnection();

    m_readStmt = m_conn->createStatement(); 
    m_readStmt->setSQL("select fe_daq_conDfig_sq.nextVal from dual");
    ResultSet* rset = m_readStmt->executeQuery();
    while (rset->next ()){
      result= rset->getInt(1);
    }
    m_conn->terminateStatement(m_readStmt);
    return result; 

  } catch (SQLException &e) {
    throw(std::runtime_error("ODFEDAQConfig::fetchNextId():  "+e.getMessage()));
  }

}
int ODFEDAQConfig::getBadTTId ( ) const [inline]

Definition at line 36 of file ODFEDAQConfig.h.

References m_btt.

Referenced by popcon::EcalChannelStatusHandler::daqOut(), and popcon::EcalDAQHandler::getNewObjects().

{ return m_btt; }
int ODFEDAQConfig::getBadXtId ( ) const [inline]

Definition at line 34 of file ODFEDAQConfig.h.

References m_bxt.

{ return m_bxt; }
std::string ODFEDAQConfig::getComment ( ) const [inline]

Definition at line 43 of file ODFEDAQConfig.h.

References m_com.

{ return m_com; }
int ODFEDAQConfig::getDelayId ( ) const [inline]

Definition at line 29 of file ODFEDAQConfig.h.

References m_del.

Referenced by EcalCondDBInterface::fetchFEDelaysForRun().

{ return m_del; }
int ODFEDAQConfig::getId ( ) const [inline]

Definition at line 19 of file ODFEDAQConfig.h.

References m_ID.

{ return m_ID; }
int ODFEDAQConfig::getPedestalId ( ) const [inline]

Definition at line 27 of file ODFEDAQConfig.h.

References m_ped.

{ return m_ped; }
std::string ODFEDAQConfig::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 16 of file ODFEDAQConfig.h.

{ return "FE_DAQ_CONFIG"; }
int ODFEDAQConfig::getTriggerBadTTId ( ) const [inline]

Definition at line 40 of file ODFEDAQConfig.h.

References m_tbtt.

{ return m_tbtt; }
int ODFEDAQConfig::getTriggerBadXtId ( ) const [inline]

Definition at line 38 of file ODFEDAQConfig.h.

References m_tbxt.

{ return m_tbxt; }
int ODFEDAQConfig::getVersion ( ) const [inline]

Definition at line 24 of file ODFEDAQConfig.h.

References m_version.

{ return m_version; }
int ODFEDAQConfig::getWeightId ( ) const [inline]

Definition at line 31 of file ODFEDAQConfig.h.

References m_wei.

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

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

Implements IODConfig.

Definition at line 76 of file ODFEDAQConfig.cc.

References alignCSCRings::e.

{
  this->checkConnection();
  int next_id=fetchNextId();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO FE_DAQ_CONFIG ( config_id, tag, version, ped_id, " 
                        " del_id, wei_id,bxt_id, btt_id, tr_bxt_id, tr_btt_id, user_comment ) "
                        "VALUES ( :1, :2, :3, :4, :5, :6, :7 ,:8, :9, :10, :11 )" );

    m_writeStmt->setInt(1, next_id);
    m_ID=next_id;

  } catch (SQLException &e) {
    throw(std::runtime_error("ODFEDAQConfig::prepareWrite():  "+e.getMessage()));
  }

}
void ODFEDAQConfig::setBadTTId ( int  x) [inline]

Definition at line 35 of file ODFEDAQConfig.h.

References m_btt, and x.

{ m_btt = x; }
void ODFEDAQConfig::setBadXtId ( int  x) [inline]

Definition at line 33 of file ODFEDAQConfig.h.

References m_bxt, and x.

{ m_bxt = x; }
void ODFEDAQConfig::setComment ( std::string  x) [inline]

Definition at line 42 of file ODFEDAQConfig.h.

References m_com, and x.

{ m_com = x; }
void ODFEDAQConfig::setDelayId ( int  x) [inline]

Definition at line 28 of file ODFEDAQConfig.h.

References m_del, and x.

{ m_del = x; }
void ODFEDAQConfig::setId ( int  id) [inline]
void ODFEDAQConfig::setParameters ( std::map< std::string, std::string >  my_keys_map)
void ODFEDAQConfig::setPedestalId ( int  x) [inline]

Definition at line 26 of file ODFEDAQConfig.h.

References m_ped, and x.

{ m_ped = x; }
void ODFEDAQConfig::setTriggerBadTTId ( int  x) [inline]

Definition at line 39 of file ODFEDAQConfig.h.

References m_tbtt, and x.

{ m_tbtt = x; }
void ODFEDAQConfig::setTriggerBadXtId ( int  x) [inline]

Definition at line 37 of file ODFEDAQConfig.h.

References m_tbxt, and x.

{ m_tbxt = x; }
void ODFEDAQConfig::setVersion ( int  id) [inline]

Definition at line 23 of file ODFEDAQConfig.h.

References errorMatrix2Lands_multiChannel::id, and m_version.

{ m_version = id; }
void ODFEDAQConfig::setWeightId ( int  x) [inline]

Definition at line 30 of file ODFEDAQConfig.h.

References m_wei, and x.

{ m_wei = x; }
void ODFEDAQConfig::writeDB ( ) throw (std::runtime_error) [private]

Definition at line 121 of file ODFEDAQConfig.cc.

References alignCSCRings::e, and SET_INT.

{
  this->checkConnection();
  this->checkPrepare();

  try {

    // number 1 is the id 
    m_writeStmt->setString(2, this->getConfigTag());
    m_writeStmt->setInt(3, this->getVersion());
    SET_INT(m_writeStmt,4, this->getPedestalId());
    SET_INT(m_writeStmt,5, this->getDelayId());
    SET_INT(m_writeStmt,6, this->getWeightId());
    SET_INT(m_writeStmt,7, this->getBadXtId());
    SET_INT(m_writeStmt,8, this->getBadTTId());
    SET_INT(m_writeStmt,9, this->getTriggerBadXtId());
    SET_INT(m_writeStmt,10,this->getTriggerBadTTId());

    m_writeStmt->setString(11, this->getComment());

    m_writeStmt->executeUpdate();


  } catch (SQLException &e) {
    throw(std::runtime_error("ODFEDAQConfig::writeDB():  "+e.getMessage()));
  }
  // Now get the ID
  if (!this->fetchID()) {
    throw(std::runtime_error("ODFEDAQConfig::writeDB:  Failed to write"));
  }


}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 11 of file ODFEDAQConfig.h.


Member Data Documentation

int ODFEDAQConfig::m_btt [private]

Definition at line 67 of file ODFEDAQConfig.h.

Referenced by getBadTTId(), and setBadTTId().

int ODFEDAQConfig::m_bxt [private]

Definition at line 66 of file ODFEDAQConfig.h.

Referenced by getBadXtId(), and setBadXtId().

std::string ODFEDAQConfig::m_com [private]

Definition at line 71 of file ODFEDAQConfig.h.

Referenced by getComment(), and setComment().

int ODFEDAQConfig::m_del [private]

Definition at line 63 of file ODFEDAQConfig.h.

Referenced by getDelayId(), and setDelayId().

int ODFEDAQConfig::m_ID [private]

Definition at line 61 of file ODFEDAQConfig.h.

Referenced by getId(), and setId().

int ODFEDAQConfig::m_ped [private]

Definition at line 62 of file ODFEDAQConfig.h.

Referenced by getPedestalId(), and setPedestalId().

int ODFEDAQConfig::m_tbtt [private]

Definition at line 69 of file ODFEDAQConfig.h.

Referenced by getTriggerBadTTId(), and setTriggerBadTTId().

int ODFEDAQConfig::m_tbxt [private]

Definition at line 68 of file ODFEDAQConfig.h.

Referenced by getTriggerBadXtId(), and setTriggerBadXtId().

int ODFEDAQConfig::m_version [private]

Definition at line 70 of file ODFEDAQConfig.h.

Referenced by getVersion(), and setVersion().

int ODFEDAQConfig::m_wei [private]

Definition at line 64 of file ODFEDAQConfig.h.

Referenced by getWeightId(), and setWeightId().