CMS 3D CMS Logo

Public Member Functions | Private Attributes | Friends

DCSPTMTempList Class Reference

#include <DCSPTMTempList.h>

Inheritance diagram for DCSPTMTempList:
IDBObject

List of all members.

Public Member Functions

 DCSPTMTempList ()
void fetchValuesForECID (EcalLogicID ecid) throw (std::runtime_error)
void fetchValuesForECIDAndTime (EcalLogicID ecid, Tm start, Tm end) throw (std::runtime_error)
std::vector< DCSPTMTempgetList ()
 ~DCSPTMTempList ()

Private Attributes

std::vector< DCSPTMTempm_vec_temp

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 15 of file DCSPTMTempList.h.


Constructor & Destructor Documentation

DCSPTMTempList::DCSPTMTempList ( )

Definition at line 15 of file DCSPTMTempList.cc.

References NULL.

{
  m_conn = NULL;
}
DCSPTMTempList::~DCSPTMTempList ( )

Definition at line 20 of file DCSPTMTempList.cc.

{
}

Member Function Documentation

void DCSPTMTempList::fetchValuesForECID ( EcalLogicID  ecid) throw (std::runtime_error)

Definition at line 31 of file DCSPTMTempList.cc.

References gather_cfg::cout, DateHandler::dateToTm(), i, csvReporter::r, DCSPTMTemp::setEcalLogicID(), DCSPTMTemp::setEnd(), DCSPTMTemp::setStart(), DCSPTMTemp::setTemperature(), and x.

Referenced by EcalCondDBInterface::fetchDCSPTMTempList().

{

  this->checkConnection();
  int nruns=0;

  int ecid_id=ecid.getLogicID();

  try {
    Statement* stmt0 = m_conn->createStatement();
    stmt0->setSQL("SELECT count(since) FROM PVSS_TEMPERATURE_DAT "
                 "WHERE logic_id = :logic_id  " );
    stmt0->setInt(1, ecid_id);
  
    ResultSet* rset0 = stmt0->executeQuery();
    if (rset0->next()) {
      nruns = rset0->getInt(1);
    }
    m_conn->terminateStatement(stmt0);

    cout <<"DCSPTMTempList::fetchValuesForECID>> Number of records in DB="<< nruns << endl;
    m_vec_temp.reserve(nruns);
    
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT  "
                 "since, till, temperature  FROM PVSS_TEMPERATURE_DAT "
                 "WHERE logic_id = :logic_id  order by since " );
    stmt->setInt(1, ecid_id);

    DateHandler dh(m_env, m_conn);
    Tm runStart;
    Tm runEnd;
  
    ResultSet* rset = stmt->executeQuery();
    int i=0;
    while (i<nruns) {
      rset->next();
     
       Date startDate = rset->getDate(1);
       Date endDate = rset->getDate(2);  
       float x = rset->getFloat(3);      
       runStart = dh.dateToTm( startDate );
       runEnd = dh.dateToTm( endDate );
       
       DCSPTMTemp r ;
       r.setTemperature(x);
       r.setStart(runStart);
       r.setEnd(runEnd);
       r.setEcalLogicID(ecid);
       m_vec_temp.push_back(r);
      
      i++;
    }
   
    cout <<"DCSPTMTempList::fetchValuesForECID>> loop done " << endl;

    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("DCSPTMTempList:  "+e.getMessage()));
  }


}
void DCSPTMTempList::fetchValuesForECIDAndTime ( EcalLogicID  ecid,
Tm  start,
Tm  end 
) throw (std::runtime_error)

Definition at line 96 of file DCSPTMTempList.cc.

References gather_cfg::cout, DateHandler::dateToTm(), end, i, csvReporter::r, DCSPTMTemp::setEcalLogicID(), DCSPTMTemp::setEnd(), DCSPTMTemp::setStart(), DCSPTMTemp::setTemperature(), DateHandler::tmToDate(), and x.

Referenced by EcalCondDBInterface::fetchDCSPTMTempList().

{

  this->checkConnection();
  int nruns=0;

  int ecid_id=ecid.getLogicID();

  DateHandler dh(m_env, m_conn);
  Tm runStart;
  Tm runEnd;


  try {
    Statement* stmt0 = m_conn->createStatement();
    stmt0->setSQL("SELECT count(since) FROM PVSS_TEMPERATURE_DAT "
                 "WHERE logic_id = :logic_id  " 
                 "AND since >= :start_time  " 
                 "AND since <= :till_time  " 
                  );
    stmt0->setInt(1, ecid_id);
    stmt0->setDate(2, dh.tmToDate(start));
    stmt0->setDate(3, dh.tmToDate(end));
  
    ResultSet* rset0 = stmt0->executeQuery();
    if (rset0->next()) {
      nruns = rset0->getInt(1);
    }
    m_conn->terminateStatement(stmt0);

    cout <<"DCSPTMTempList::fetchValuesForECIDAndTime>> Number of records in DB="<< nruns << endl;
    m_vec_temp.reserve(nruns);
    
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT  "
                 "since, till, temperature  FROM PVSS_TEMPERATURE_DAT "
                 "WHERE logic_id = :logic_id "
                 "AND since >= :start_time  " 
                 "AND since <= :till_time  " 
                 " order by since " );
    stmt->setInt(1, ecid_id);
    stmt->setDate(2, dh.tmToDate(start));
    stmt->setDate(3, dh.tmToDate(end));

  
    ResultSet* rset = stmt->executeQuery();
    int i=0;
    while (i<nruns) {
      rset->next();
     
       Date startDate = rset->getDate(1);
       Date endDate = rset->getDate(2);  
       float x = rset->getFloat(3);      
       runStart = dh.dateToTm( startDate );
       runEnd = dh.dateToTm( endDate );
       
       DCSPTMTemp r ;
       r.setTemperature(x);
       r.setStart(runStart);
       r.setEnd(runEnd);
       r.setEcalLogicID(ecid);
       m_vec_temp.push_back(r);
      
      i++;
    }
   

    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("DCSPTMTempList:  "+e.getMessage()));
  }


}
std::vector< DCSPTMTemp > DCSPTMTempList::getList ( )

Definition at line 25 of file DCSPTMTempList.cc.

{
  return m_vec_temp;
}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 17 of file DCSPTMTempList.h.


Member Data Documentation

std::vector<DCSPTMTemp> DCSPTMTempList::m_vec_temp [private]

Definition at line 33 of file DCSPTMTempList.h.