CMS 3D CMS Logo

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

ODRunConfigInfo Class Reference

#include <ODRunConfigInfo.h>

Inheritance diagram for ODRunConfigInfo:
IODConfig IDBObject

List of all members.

Public Member Functions

Tm getDBTime () const
int getDefaults () const
std::string getDescription () const
int getId () const
int getNumberOfEvents () const
int getNumberOfSequences () const
RunModeDef getRunModeDef () const
RunTypeDef getRunTypeDef () const
std::string getTable ()
std::string getTag () const
std::string getTriggerMode () const
std::string getUsageStatus () const
int getVersion () const
 ODRunConfigInfo ()
bool operator!= (const ODRunConfigInfo &r) const
bool operator== (const ODRunConfigInfo &r) const
void setDBTime (Tm x)
void setDefaults (int x)
void setDescription (std::string x)
void setId (int id)
void setNumberOfEvents (int x)
void setNumberOfSequences (int n)
void setRunModeDef (const RunModeDef runModeDef)
void setRunTypeDef (const RunTypeDef runTypeDef)
void setTag (std::string x)
void setTriggerMode (std::string x)
void setUsageStatus (std::string x)
void setVersion (int x)
 ~ODRunConfigInfo ()

Private Member Functions

void clear ()
void fetchData (ODRunConfigInfo *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
int fetchIDFromTagAndVersion () throw (std::runtime_error)
int fetchIDLast () throw (std::runtime_error)
int fetchNextId () throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void setByID (int id) throw (std::runtime_error)
int updateDefaultCycle () throw (std::runtime_error)
void writeDB () throw (std::runtime_error)

Private Attributes

Tm m_db_time
int m_defaults
std::string m_description
int m_ID
int m_num_events
int m_num_seq
RunModeDef m_runModeDef
RunTypeDef m_runTypeDef
std::string m_tag
std::string m_trigger_mode
std::string m_usage_status
int m_version

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 12 of file ODRunConfigInfo.h.


Constructor & Destructor Documentation

ODRunConfigInfo::ODRunConfigInfo ( )

Definition at line 12 of file ODRunConfigInfo.cc.

References NULL.

ODRunConfigInfo::~ODRunConfigInfo ( )

Definition at line 30 of file ODRunConfigInfo.cc.

{}

Member Function Documentation

void ODRunConfigInfo::clear ( void  ) [private]

Definition at line 294 of file ODRunConfigInfo.cc.

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

Definition at line 303 of file ODRunConfigInfo.cc.

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

{
  this->checkConnection();
  DateHandler dh(m_env, m_conn);
  //  result->clear();

  if(result->getId()==0){
    //throw(std::runtime_error("FEConfigMainInfo::fetchData(): no Id defined for this FEConfigMainInfo "));
    result->fetchID();
  }
  try {
    m_readStmt->setSQL("SELECT config_id, tag, version, run_type_def_id, run_mode_def_id, \
      num_of_sequences, description, defaults, trg_mode, num_of_events, db_timestamp, usage_status \
      FROM ECAL_RUN_CONFIGURATION_DAT WHERE config_id = :1 ");
    m_readStmt->setInt(1, result->getId());

    ResultSet* rset = m_readStmt->executeQuery();
    rset->next();

    result->setId(               rset->getInt(1) );
    result->setTag(              rset->getString(2) );
    result->setVersion(          rset->getInt(3) );
    //    RunTypeDef myRunType = rset->getInt(4);
    //    result->setRunTypeDef( myRunType );
    //    RunModeDef myRunMode = rset->getInt(5);
    //    result->setRunModeDef( myRunMode );
    result->setNumberOfSequences(rset->getInt(6) );
    result->setDescription(      rset->getString(7) );
    result->setDefaults(         rset->getInt(8) );
    result->setTriggerMode(      rset->getString(9) );
    result->setNumberOfEvents(   rset->getInt(10) );
    Date dbdate = rset->getDate(11);
    result->setDBTime(dh.dateToTm( dbdate ));
    result->setUsageStatus(      rset->getString(12) );

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

Definition at line 75 of file ODRunConfigInfo.cc.

References alignCSCRings::e.

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

  this->checkConnection();


  DateHandler dh(m_env, m_conn);

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT config_id from ECAL_RUN_CONFIGURATION_DAT "
                 "WHERE tag = :tag " 
                 " and version = :version " );
    stmt->setString(1, m_tag);
    stmt->setInt(2, m_version);

    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("ODRunConfigInfo::fetchID:  "+e.getMessage()));
  }
  setByID(m_ID);
  return m_ID;
}
int ODRunConfigInfo::fetchIDFromTagAndVersion ( ) throw (std::runtime_error) [private]

Definition at line 140 of file ODRunConfigInfo.cc.

{
  fetchID();
  return m_ID;
}
int ODRunConfigInfo::fetchIDLast ( ) throw (std::runtime_error) [private]

Definition at line 112 of file ODRunConfigInfo.cc.

References alignCSCRings::e.

{

  this->checkConnection();

  DateHandler dh(m_env, m_conn);

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT max(config_id) FROM ecal_run_configuration_dat "       );
    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("ODRunConfigInfo::fetchIDLast:  "+e.getMessage()));
  }

  setByID(m_ID);
  return m_ID;
}
int ODRunConfigInfo::fetchNextId ( ) throw (std::runtime_error) [private]

Definition at line 54 of file ODRunConfigInfo.cc.

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

                                                          {

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

    m_readStmt = m_conn->createStatement(); 
    m_readStmt->setSQL("select ecal_run_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("ODDCCConfig::fetchNextId():  "+e.getMessage()));
  }

}
Tm ODRunConfigInfo::getDBTime ( ) const [inline]

Definition at line 26 of file ODRunConfigInfo.h.

References m_db_time.

{  return m_db_time;}
int ODRunConfigInfo::getDefaults ( ) const [inline]

Definition at line 41 of file ODRunConfigInfo.h.

References m_defaults.

{  return m_defaults;}
std::string ODRunConfigInfo::getDescription ( ) const [inline]

Definition at line 32 of file ODRunConfigInfo.h.

References m_description.

{  return m_description;}
int ODRunConfigInfo::getId ( ) const [inline]

Definition at line 21 of file ODRunConfigInfo.h.

References m_ID.

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

{ return m_ID; }
int ODRunConfigInfo::getNumberOfEvents ( ) const [inline]

Definition at line 47 of file ODRunConfigInfo.h.

References m_num_events.

{  return m_num_events ;}
int ODRunConfigInfo::getNumberOfSequences ( ) const [inline]

Definition at line 38 of file ODRunConfigInfo.h.

References m_num_seq.

{return m_num_seq;  }
RunModeDef ODRunConfigInfo::getRunModeDef ( ) const

Definition at line 44 of file ODRunConfigInfo.cc.

{  return m_runModeDef;}
RunTypeDef ODRunConfigInfo::getRunTypeDef ( ) const

Definition at line 35 of file ODRunConfigInfo.cc.

{  return m_runTypeDef;}
std::string ODRunConfigInfo::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 18 of file ODRunConfigInfo.h.

{ return "ECAL_RUN_CONFIGURATION_DAT"; }
std::string ODRunConfigInfo::getTag ( void  ) const [inline]

Definition at line 29 of file ODRunConfigInfo.h.

References m_tag.

{  return m_tag;}
std::string ODRunConfigInfo::getTriggerMode ( ) const [inline]

Definition at line 44 of file ODRunConfigInfo.h.

References m_trigger_mode.

{  return m_trigger_mode;}
std::string ODRunConfigInfo::getUsageStatus ( ) const [inline]

Definition at line 50 of file ODRunConfigInfo.h.

References m_usage_status.

{  return m_usage_status;}
int ODRunConfigInfo::getVersion ( ) const [inline]

Definition at line 35 of file ODRunConfigInfo.h.

References m_version.

{return m_version;  }
bool ODRunConfigInfo::operator!= ( const ODRunConfigInfo r) const [inline]

Definition at line 61 of file ODRunConfigInfo.h.

References alignCSCRings::r.

{ return !(*this == r); }
bool ODRunConfigInfo::operator== ( const ODRunConfigInfo r) const [inline]

Definition at line 60 of file ODRunConfigInfo.h.

References m_ID.

{  return (m_ID   == r.m_ID ); }
void ODRunConfigInfo::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 192 of file ODRunConfigInfo.cc.

References alignCSCRings::e.

{
  this->checkConnection();

  int next_id=fetchNextId();




  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_RUN_CONFIGURATION_DAT (CONFIG_ID, tag, version, run_type_def_id, "
                 " run_mode_def_id, num_of_sequences, defaults, trg_mode, num_of_events, description, usage_status ) "
                 " 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("ODRunConfigInfo::prepareWrite():  "+e.getMessage()));
  }
}
void ODRunConfigInfo::setByID ( int  id) throw (std::runtime_error) [private]

Definition at line 149 of file ODRunConfigInfo.cc.

References DateHandler::dateToTm(), alignCSCRings::e, and errorMatrix2Lands_multiChannel::id.

{
   this->checkConnection();

   DateHandler dh(m_env, m_conn);

   try {
     Statement* stmt = m_conn->createStatement();

     stmt->setSQL("SELECT tag, version, run_type_def_id, run_mode_def_id, num_of_sequences, description, defaults,"
                  " trg_mode,num_of_events, db_timestamp, usage_status"
                  " FROM ECAL_RUN_CONFIGURATION_DAT WHERE config_id = :1");
     stmt->setInt(1, id);
     
     ResultSet* rset = stmt->executeQuery();
     if (rset->next()) {
       m_tag= rset->getString(1);
       m_version= rset->getInt(2);
       int run_type_id=rset->getInt(3);
       int run_mode_id=rset->getInt(4);
       m_num_seq=rset->getInt(5);
       m_description= rset->getString(6);
       m_defaults= rset->getInt(7);
       m_trigger_mode= rset->getString(8);
       m_num_events= rset->getInt(9);
       Date dbdate = rset->getDate(10);
       m_db_time = dh.dateToTm( dbdate );
       m_ID = id;
       m_runModeDef.setConnection(m_env, m_conn);
       m_runModeDef.setByID(run_mode_id);
       m_runTypeDef.setConnection(m_env, m_conn);
       m_runTypeDef.setByID(run_type_id);
       m_usage_status=rset->getString(11);
     } else {
       throw(std::runtime_error("ODRunConfigInfo::setByID:  Given config_id is not in the database"));
     }
     m_conn->terminateStatement(stmt);
   } catch (SQLException &e) {
     throw(std::runtime_error("ODRunConfigInfo::setByID:  "+e.getMessage()));
   }
}
void ODRunConfigInfo::setDBTime ( Tm  x) [inline]

Definition at line 25 of file ODRunConfigInfo.h.

References m_db_time, and x.

{ m_db_time=x; }
void ODRunConfigInfo::setDefaults ( int  x) [inline]

Definition at line 40 of file ODRunConfigInfo.h.

References m_defaults, and x.

{ m_defaults = x;}
void ODRunConfigInfo::setDescription ( std::string  x) [inline]

Definition at line 31 of file ODRunConfigInfo.h.

References m_description, and x.

void ODRunConfigInfo::setId ( int  id) [inline]

Definition at line 20 of file ODRunConfigInfo.h.

References errorMatrix2Lands_multiChannel::id, and m_ID.

{ m_ID = id; }
void ODRunConfigInfo::setNumberOfEvents ( int  x) [inline]

Definition at line 46 of file ODRunConfigInfo.h.

References m_num_events, and x.

{ m_num_events = x ;}
void ODRunConfigInfo::setNumberOfSequences ( int  n) [inline]

Definition at line 37 of file ODRunConfigInfo.h.

References m_num_seq, and n.

{ m_num_seq = n;  }
void ODRunConfigInfo::setRunModeDef ( const RunModeDef  runModeDef)

Definition at line 45 of file ODRunConfigInfo.cc.

{
  if (runModeDef != m_runModeDef) {
    m_ID = 0;
    m_runModeDef = runModeDef;
  }
}
void ODRunConfigInfo::setRunTypeDef ( const RunTypeDef  runTypeDef)

Definition at line 36 of file ODRunConfigInfo.cc.

{
  if (runTypeDef != m_runTypeDef) {
    m_ID = 0;
    m_runTypeDef = runTypeDef;
  }
}
void ODRunConfigInfo::setTag ( std::string  x) [inline]

Definition at line 28 of file ODRunConfigInfo.h.

References m_tag, and x.

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

{ m_tag = x; }
void ODRunConfigInfo::setTriggerMode ( std::string  x) [inline]

Definition at line 43 of file ODRunConfigInfo.h.

References m_trigger_mode, and x.

void ODRunConfigInfo::setUsageStatus ( std::string  x) [inline]

Definition at line 49 of file ODRunConfigInfo.h.

References m_usage_status, and x.

void ODRunConfigInfo::setVersion ( int  x) [inline]

Definition at line 34 of file ODRunConfigInfo.h.

References m_version, and x.

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

{ m_version = x;  }
int ODRunConfigInfo::updateDefaultCycle ( ) throw (std::runtime_error) [private]

Definition at line 265 of file ODRunConfigInfo.cc.

References alignCSCRings::e.

{
  this->checkConnection();

  // Check if this has already been written
  if(!this->fetchID()){
    this->writeDB();
  }


  try {
    Statement* stmt = m_conn->createStatement();
    
    stmt->setSQL("UPDATE ecal_run_configuration_dat set defaults=:1 where config_id=:2 " );
   
    stmt->setInt(1, m_defaults);
    stmt->setInt(2, m_ID);

    stmt->executeUpdate();

    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("ODRunConfigInfo::writeDB:  "+e.getMessage()));
  }
  
  return m_ID;
}
void ODRunConfigInfo::writeDB ( ) throw (std::runtime_error) [private]

Definition at line 217 of file ODRunConfigInfo.cc.

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

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

  // Validate the data, use infinity-till convention
  DateHandler dh(m_env, m_conn);

  try {
    
    // get the run mode
    m_runModeDef.setConnection(m_env, m_conn);
    int run_mode_id = m_runModeDef.fetchID();

    // get the run type
    m_runTypeDef.setConnection(m_env, m_conn);
    int run_type_id = m_runTypeDef.fetchID();

    // now insert 

    m_writeStmt->setString(2, this->getTag());
    m_writeStmt->setInt(3, this->getVersion());
    m_writeStmt->setInt(4, run_type_id);
    m_writeStmt->setInt(5, run_mode_id);
    m_writeStmt->setInt(6, this->getNumberOfSequences());
    m_writeStmt->setInt(7, this->getDefaults());
    m_writeStmt->setString(8, this->getTriggerMode());
    m_writeStmt->setInt(9, this->getNumberOfEvents());
    m_writeStmt->setString(10, this->getDescription());
    m_writeStmt->setString(11, this->getUsageStatus());

    m_writeStmt->executeUpdate();

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

  this->setByID(m_ID);

  cout<< "ODRunConfigInfo::writeDB>> done inserting ODRunConfigInfo with id="<<m_ID<<endl;
}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file ODRunConfigInfo.h.


Member Data Documentation

Definition at line 66 of file ODRunConfigInfo.h.

Referenced by getDBTime(), and setDBTime().

Definition at line 73 of file ODRunConfigInfo.h.

Referenced by getDefaults(), and setDefaults().

std::string ODRunConfigInfo::m_description [private]

Definition at line 72 of file ODRunConfigInfo.h.

Referenced by getDescription(), and setDescription().

int ODRunConfigInfo::m_ID [private]

Definition at line 65 of file ODRunConfigInfo.h.

Referenced by getId(), operator==(), and setId().

Definition at line 75 of file ODRunConfigInfo.h.

Referenced by getNumberOfEvents(), and setNumberOfEvents().

Definition at line 71 of file ODRunConfigInfo.h.

Referenced by getNumberOfSequences(), and setNumberOfSequences().

Definition at line 69 of file ODRunConfigInfo.h.

Definition at line 70 of file ODRunConfigInfo.h.

std::string ODRunConfigInfo::m_tag [private]

Definition at line 67 of file ODRunConfigInfo.h.

Referenced by getTag(), and setTag().

std::string ODRunConfigInfo::m_trigger_mode [private]

Definition at line 74 of file ODRunConfigInfo.h.

Referenced by getTriggerMode(), and setTriggerMode().

std::string ODRunConfigInfo::m_usage_status [private]

Definition at line 76 of file ODRunConfigInfo.h.

Referenced by getUsageStatus(), and setUsageStatus().

Definition at line 68 of file ODRunConfigInfo.h.

Referenced by getVersion(), and setVersion().