CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EcalCondDBInterface Class Reference

#include <EcalCondDBInterface.h>

Inheritance diagram for EcalCondDBInterface:
EcalDBConnection EcalTPGDBApp

List of all members.

Public Member Functions

void dummy ()
 EcalCondDBInterface (std::string sid, std::string user, std::string pass)
 EcalCondDBInterface (std::string host, std::string sid, std::string user, std::string pass, int port=1521)
CaliIOV fetchCaliIOV (CaliTag *tag, Tm evenTm) throw (std::runtime_error)
template<class DATT , class ICONF >
void fetchConfigDataSet (std::vector< DATT > *fillMap, ICONF *iconf) throw (std::runtime_error)
template<class ICONF >
void fetchConfigSet (ICONF *iconf) throw (std::runtime_error)
template<class DATT , class IOVT >
void fetchDataSet (std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) throw (std::runtime_error)
template<class DATT , class IOVT >
void fetchDataSetWithMap (std::map< EcalLogicID, DATT > *fillMap, IOVT *iov, std::string mapping_name) throw (std::runtime_error)
template<class DATT >
void fetchDCSDataSet (std::list< std::pair< Tm, std::map< EcalLogicID, DATT > > > *fillMap, Tm t) throw (std::runtime_error)
DCSPTMTempList fetchDCSPTMTempList (EcalLogicID ecid) throw (std::runtime_error)
DCSPTMTempList fetchDCSPTMTempList (EcalLogicID ecid, Tm start, Tm end) throw (std::runtime_error)
DCUIOV fetchDCUIOV (DCUTag *tag, Tm evenTm) throw (std::runtime_error)
RunList fetchGlobalRunListByLocation (RunTag tag, int min_run, int max_run, const LocationDef locDef) throw (std::runtime_error)
template<class ICONF >
void fetchLastConfigSet (ICONF *iconf) throw (std::runtime_error)
RunIOV fetchLMFLastRun () const
LMFRunIOV fetchLMFRunIOV (RunTag *runtag, LMFRunTag *lmftag, run_t run, subrun_t lmfrun) throw (std::runtime_error)
bool fetchLMFRunIOV (const LMFSeqDat &, LMFRunIOV &, int lmr, int type, int color) const
MonRunIOV fetchMonRunIOV (RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun) throw (std::runtime_error)
MonRunList fetchMonRunList (RunTag tag, MonRunTag monruntag, int min_run, int max_run) throw (std::runtime_error)
MonRunList fetchMonRunList (RunTag tag, MonRunTag monruntag) throw (std::runtime_error)
MonRunList fetchMonRunListLastNRuns (RunTag tag, MonRunTag monruntag, int max_run, int n_runs) throw (std::runtime_error)
RunList fetchNonEmptyGlobalRunList (RunTag tag, int min_run, int max_run) throw (std::runtime_error)
RunList fetchNonEmptyRunList (RunTag tag, int min_run, int max_run) throw (std::runtime_error)
RunIOV fetchRunIOV (RunTag *tag, run_t run) throw (std::runtime_error)
RunIOV fetchRunIOV (std::string location, run_t run) throw (std::runtime_error)
RunList fetchRunList (RunTag tag, int min_run, int max_run) throw (std::runtime_error)
RunList fetchRunList (RunTag tag) throw (std::runtime_error)
RunList fetchRunListByLocation (RunTag tag, int min_run, int max_run, const LocationDef locDef) throw (std::runtime_error)
RunList fetchRunListLastNRuns (RunTag tag, int max_run, int n_runs) throw (std::runtime_error)
template<class DATT , class IOVT >
void fetchValidDataSet (std::map< EcalLogicID, DATT > *fillMap, IOVT *fillIOV, std::string location, run_t run=(unsigned int)-1) throw (std::runtime_error)
template<class DATT , class IOVT >
void fetchValidDataSet (std::map< EcalLogicID, DATT > *fillMap, IOVT *fillIOV, RunTag *tag, run_t run=(unsigned int)-1) throw (std::runtime_error)
DateHandlergetDateHandler ()
EcalLogicID getEcalLogicID (int logicID) throw (std::runtime_error)
EcalLogicID getEcalLogicID (std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="") throw (std::runtime_error)
std::map< int, int > getEcalLogicID2LmrMap ()
std::vector< EcalLogicIDgetEcalLogicIDSet (std::string name, int fromId1=EcalLogicID::NULLID, int toId1=EcalLogicID::NULLID, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="") throw (std::runtime_error)
std::vector< EcalLogicIDgetEcalLogicIDSetOrdered (std::string name, int fromId1, int toId1, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="", int orderedBy=EcalLogicID::NULLID) throw (std::runtime_error)
template<class DATT , class ICONF >
void insertConfigDataArraySet (const std::vector< DATT > data, ICONF *iconf) throw (std::runtime_error)
template<class DATT , class ICONF >
void insertConfigDataSet (const std::vector< DATT > data, ICONF *iconf) throw (std::runtime_error)
template<class ICONF >
void insertConfigSet (ICONF *iconf) throw (std::runtime_error)
template<class DATT , class IOVT >
void insertDataArraySet (const std::map< EcalLogicID, DATT > *data, IOVT *iov) throw (std::runtime_error)
template<class DATT , class IOVT >
void insertDataSet (const std::map< EcalLogicID, DATT > *data, IOVT *iov) throw (std::runtime_error)
template<class DATT , class IOVT >
void insertDataSetVector (std::vector< EcalLogicID > ecid, std::vector< IOVT > run_iov, std::vector< DATT > data) throw (std::runtime_error)
void insertDCUIOV (DCUIOV *iov) throw (std::runtime_error)
void insertLmfDat (LMFDat *dat) throw (std::runtime_error)
void insertLmfDat (std::list< LMFDat * > dat) throw (std::runtime_error)
void insertLmfIOV (LMFIOV *iov) throw (std::runtime_error)
void insertLmfLmrSubIOV (LMFLmrSubIOV *iov) throw (std::runtime_error)
void insertLmfRunIOV (LMFRunIOV *iov) throw (std::runtime_error)
void insertLmfSeq (LMFSeqDat *iov) throw (std::runtime_error)
void insertMonRunIOV (MonRunIOV *iov) throw (std::runtime_error)
void insertRunIOV (RunIOV *iov) throw (std::runtime_error)
void updateRunConfig (ODRunConfigInfo *od) throw (std::runtime_error)
void updateRunIOV (RunIOV *iov) throw (std::runtime_error)
void updateRunIOVEndTime (RunIOV *iov) throw (std::runtime_error)
void updateRunIOVStartTime (RunIOV *iov) throw (std::runtime_error)
virtual ~EcalCondDBInterface () throw (std::runtime_error)

Private Member Functions

 EcalCondDBInterface ()
 EcalCondDBInterface (const EcalCondDBInterface &copy)

Private Attributes

DateHandlerdh

Detailed Description

Definition at line 36 of file EcalCondDBInterface.h.


Constructor & Destructor Documentation

EcalCondDBInterface::EcalCondDBInterface ( std::string  host,
std::string  sid,
std::string  user,
std::string  pass,
int  port = 1521 
) [inline]

Constructor, makes connection to DB without TNS_ADMIN === Parameters === host: DB host machine sid: DB SID (name) user: User to connect pass: Password for user port: port number to connect, default 1521

Definition at line 52 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, dh, and EcalDBConnection::env.

    : EcalDBConnection( host, sid, user, pass, port )
    {
      // call the parent constructor

      // create a DateHandler
      dh = new DateHandler(env, conn);
    }
EcalCondDBInterface::EcalCondDBInterface ( std::string  sid,
std::string  user,
std::string  pass 
) [inline]

Constructor, makes connection to DB with TNS_ADMIN === Parameters === sid: DB SID (name) user: User to connect pass: Password for user

Definition at line 74 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, dh, and EcalDBConnection::env.

    : EcalDBConnection( sid, user, pass )
    {
      // call the parent constructor

      // create a DateHandler
      dh = new DateHandler(env, conn);
    }
virtual EcalCondDBInterface::~EcalCondDBInterface ( ) throw (std::runtime_error) [inline, virtual]

Destructor

Definition at line 89 of file EcalCondDBInterface.h.

References dh.

    {
      // call the parent destructor
      
      // destroy the DateHandler
      delete(dh);
    }
EcalCondDBInterface::EcalCondDBInterface ( ) [private]
EcalCondDBInterface::EcalCondDBInterface ( const EcalCondDBInterface copy) [private]

Member Function Documentation

void EcalCondDBInterface::dummy ( )

Definition at line 775 of file EcalCondDBInterface.cc.

{
}
CaliIOV EcalCondDBInterface::fetchCaliIOV ( CaliTag tag,
Tm  evenTm 
) throw (std::runtime_error)

Return a Calibration IOV object

Definition at line 647 of file EcalCondDBInterface.cc.

References CaliIOV::setByTm(), IDBObject::setConnection(), and GlobalPosition_Frontier_DevDB_cff::tag.

{
  CaliIOV caliiov;
  caliiov.setConnection(env, conn);
  caliiov.setByTm(tag, eventTm);
  return caliiov;
}
template<class DATT , class ICONF >
void EcalCondDBInterface::fetchConfigDataSet ( std::vector< DATT > *  fillMap,
ICONF *  iconf 
) throw (std::runtime_error) [inline]

Definition at line 533 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, EcalDBConnection::env, and edm::pset::fillMap().

  {

    DATT datiface;
    datiface.setConnection(env, conn);
    datiface.createReadStatement();
    datiface.setPrefetchRowCount(1024);
    datiface.fetchData( fillMap, iconf );
    datiface.terminateReadStatement();

  }
template<class ICONF >
void EcalCondDBInterface::fetchConfigSet ( ICONF *  iconf) throw (std::runtime_error) [inline]

Definition at line 424 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, and EcalDBConnection::env.

Referenced by EcalTPGDBApp::readFromConfDB_TPGPedestals().

  {

    iconf->clear();
    iconf->setConnection(env, conn);
    iconf->createReadStatement();
    iconf->fetchData(iconf);
    iconf->terminateReadStatement();

  }
template<class DATT , class IOVT >
void EcalCondDBInterface::fetchDataSet ( std::map< EcalLogicID, DATT > *  fillMap,
IOVT *  iov 
) throw (std::runtime_error) [inline]

Definition at line 556 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, EcalDBConnection::env, edm::pset::fillMap(), and o2o::iov.

Referenced by EcalTPGParamBuilder::analyze(), EcalEndcapMonitorClient::endRunDb(), EcalBarrelMonitorClient::endRunDb(), EcalTPGDBApp::readFromCondDB_Pedestals(), and EcalTPGDBApp::readFromConfDB_TPGPedestals().

  {
    fillMap->clear();

    DATT datiface;
    datiface.setConnection(env, conn);
    datiface.createReadStatement();
    datiface.setPrefetchRowCount(1024);
    datiface.fetchData( fillMap, iov );
    datiface.terminateReadStatement();

  }
template<class DATT , class IOVT >
void EcalCondDBInterface::fetchDataSetWithMap ( std::map< EcalLogicID, DATT > *  fillMap,
IOVT *  iov,
std::string  mapping_name 
) throw (std::runtime_error) [inline]

Definition at line 600 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, EcalDBConnection::env, edm::pset::fillMap(), and o2o::iov.

  {
    fillMap->clear();

    DATT datiface;
    datiface.setConnection(env, conn);
    datiface.createReadStatement();
    datiface.setPrefetchRowCount(1024);
    datiface.fetchData( fillMap, iov , mapping_name);
    datiface.terminateReadStatement();

  }
template<class DATT >
void EcalCondDBInterface::fetchDCSDataSet ( std::list< std::pair< Tm, std::map< EcalLogicID, DATT > > > *  fillMap,
Tm  t 
) throw (std::runtime_error) [inline]

Definition at line 577 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, EcalDBConnection::env, edm::pset::fillMap(), and matplotRender::t.

  {
    fillMap->clear();
    
    DATT datiface;
    datiface.setConnection(env, conn);
    datiface.createReadStatement();
    datiface.setPrefetchRowCount(1024);
    datiface.fetchHistoricalData( fillMap, t );
    datiface.terminateReadStatement();
    
  }
DCSPTMTempList EcalCondDBInterface::fetchDCSPTMTempList ( EcalLogicID  ecid,
Tm  start,
Tm  end 
) throw (std::runtime_error)
DCSPTMTempList EcalCondDBInterface::fetchDCSPTMTempList ( EcalLogicID  ecid) throw (std::runtime_error)

Return a PTM Temp List

Definition at line 656 of file EcalCondDBInterface.cc.

References DCSPTMTempList::fetchValuesForECID(), csvReporter::r, and IDBObject::setConnection().

DCUIOV EcalCondDBInterface::fetchDCUIOV ( DCUTag tag,
Tm  evenTm 
) throw (std::runtime_error)

Return a DCU IOV object

Definition at line 592 of file EcalCondDBInterface.cc.

References DCUIOV::setByTm(), IDBObject::setConnection(), and GlobalPosition_Frontier_DevDB_cff::tag.

{
  DCUIOV dcuiov;
  dcuiov.setConnection(env, conn);
  dcuiov.setByTm(tag, eventTm);
  return dcuiov;
}
RunList EcalCondDBInterface::fetchGlobalRunListByLocation ( RunTag  tag,
int  min_run,
int  max_run,
const LocationDef  locDef 
) throw (std::runtime_error)
template<class ICONF >
void EcalCondDBInterface::fetchLastConfigSet ( ICONF *  iconf) throw (std::runtime_error) [inline]

Definition at line 440 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, and EcalDBConnection::env.

  {

    iconf->clear();
    iconf->setConnection(env, conn);
    iconf->createReadStatement();
    iconf->fetchLastData(iconf);
    iconf->terminateReadStatement();

  }
RunIOV EcalCondDBInterface::fetchLMFLastRun ( ) const

Definition at line 601 of file EcalCondDBInterface.cc.

References LMFSeqDat::fetchLastRun().

                                                  {
  LMFSeqDat seq(env, conn);
  return seq.fetchLastRun();
}
bool EcalCondDBInterface::fetchLMFRunIOV ( const LMFSeqDat seq,
LMFRunIOV iov,
int  lmr,
int  type,
int  color 
) const

Definition at line 616 of file EcalCondDBInterface.cc.

References gather_cfg::cout, LMFRunIOV::fetchBySequence(), LMFRunIOV::fetchLastBeforeSequence(), LMFUnique::getID(), ntuplemaker::iovlist, runTheMatrix::ret, asciidump::s, and IDBObject::setConnection().

                                                                              {
  bool ret = false;
  iov.setConnection(env, conn);
  std::list<LMFRunIOV> iovlist = iov.fetchBySequence(seq, lmr, type, color);
  int s = iovlist.size();
  if (s > 0) {
    iov = iovlist.front();
    ret = true;
    if (s > 1) {
      // should not happen
      std::cout << "################################" << std::endl;
      std::cout << "################################" << std::endl;
      std::cout << "WARNING: More than one LMFRUNIOV" << std::endl;
      std::cout << "         Found for seq " << seq.getID() << std::endl;
      std::cout << "         lmr " << lmr << " type " << type << std::endl;
      std::cout << "         and color " << color << std::endl;
      std::cout << "################################" << std::endl;
      std::cout << "################################" << std::endl;
    }
  } else {
    // find the most recent data
    iovlist = iov.fetchLastBeforeSequence(seq, lmr, type, color);
    s = iovlist.size();
    if (s == 1) {
      iov = iovlist.front();
    } 
  }
  return ret;
}
LMFRunIOV EcalCondDBInterface::fetchLMFRunIOV ( RunTag runtag,
LMFRunTag lmftag,
run_t  run,
subrun_t  lmfrun 
) throw (std::runtime_error)

Return a laser monitoring farm run object

Definition at line 606 of file EcalCondDBInterface.cc.

References DTTTrigCorrFirst::run, and IDBObject::setConnection().

{
  RunIOV runiov = fetchRunIOV(runtag, run);
  LMFRunIOV lmfiov;
  lmfiov.setConnection(env, conn);
  //  lmfiov.setByRun(lmftag, &runiov, subrun);
  return lmfiov;
}
MonRunIOV EcalCondDBInterface::fetchMonRunIOV ( RunTag runtag,
MonRunTag montag,
run_t  run,
subrun_t  monrun 
) throw (std::runtime_error)

Return a monitoring run object

Definition at line 580 of file EcalCondDBInterface.cc.

References DTTTrigCorrFirst::run, MonRunIOV::setByRun(), and IDBObject::setConnection().

Referenced by EcalEndcapMonitorClient::writeDb(), EcalBarrelMonitorClient::writeDb(), and EcalPedOffset::writeDb().

{
  RunIOV runiov = fetchRunIOV(runtag, run);
  MonRunIOV moniov;
  moniov.setConnection(env, conn);
  moniov.setByRun(montag, &runiov, subrun);
  return moniov;
}
MonRunList EcalCondDBInterface::fetchMonRunList ( RunTag  tag,
MonRunTag  monruntag 
) throw (std::runtime_error)
MonRunList EcalCondDBInterface::fetchMonRunList ( RunTag  tag,
MonRunTag  monruntag,
int  min_run,
int  max_run 
) throw (std::runtime_error)
MonRunList EcalCondDBInterface::fetchMonRunListLastNRuns ( RunTag  tag,
MonRunTag  monruntag,
int  max_run,
int  n_runs 
) throw (std::runtime_error)
RunList EcalCondDBInterface::fetchNonEmptyGlobalRunList ( RunTag  tag,
int  min_run,
int  max_run 
) throw (std::runtime_error)
RunList EcalCondDBInterface::fetchNonEmptyRunList ( RunTag  tag,
int  min_run,
int  max_run 
) throw (std::runtime_error)
RunIOV EcalCondDBInterface::fetchRunIOV ( RunTag tag,
run_t  run 
) throw (std::runtime_error)
RunIOV EcalCondDBInterface::fetchRunIOV ( std::string  location,
run_t  run 
) throw (std::runtime_error)

Return a run IOV object for a given location. It is not guarunteed that a run is unique for a location only, so an exception is thrown if more than one result exists.

Definition at line 539 of file EcalCondDBInterface.cc.

References o2o::iov, tests::location, DTTTrigCorrFirst::run, RunIOV::setByRun(), and IDBObject::setConnection().

{  
  RunIOV iov;
  iov.setConnection(env, conn);
  iov.setByRun(location, run);
  return iov;
}
RunList EcalCondDBInterface::fetchRunList ( RunTag  tag,
int  min_run,
int  max_run 
) throw (std::runtime_error)
RunList EcalCondDBInterface::fetchRunList ( RunTag  tag) throw (std::runtime_error)
RunList EcalCondDBInterface::fetchRunListByLocation ( RunTag  tag,
int  min_run,
int  max_run,
const LocationDef  locDef 
) throw (std::runtime_error)
RunList EcalCondDBInterface::fetchRunListLastNRuns ( RunTag  tag,
int  max_run,
int  n_runs 
) throw (std::runtime_error)
template<class DATT , class IOVT >
void EcalCondDBInterface::fetchValidDataSet ( std::map< EcalLogicID, DATT > *  fillMap,
IOVT *  fillIOV,
std::string  location,
run_t  run = (unsigned int)-1 
) throw (std::runtime_error) [inline]

Definition at line 646 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, EcalDBConnection::env, tests::location, and DTTTrigCorrFirst::run.

  {
    fillMap->clear();
    DATT datiface;
    fillIOV->setConnection(env, conn);
    fillIOV->setByRecentData(datiface.getTable(), location, run);
    datiface.setConnection(env, conn);
    datiface.createReadStatement();
    datiface.setPrefetchRowCount(1024);
    datiface.fetchData( fillMap, fillIOV );
    datiface.terminateReadStatement();
  }
template<class DATT , class IOVT >
void EcalCondDBInterface::fetchValidDataSet ( std::map< EcalLogicID, DATT > *  fillMap,
IOVT *  fillIOV,
RunTag tag,
run_t  run = (unsigned int)-1 
) throw (std::runtime_error) [inline]

Definition at line 622 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, EcalDBConnection::env, DTTTrigCorrFirst::run, and GlobalPosition_Frontier_DevDB_cff::tag.

  {
    fillMap->clear();
    DATT datiface;
    fillIOV->setConnection(env, conn);
    fillIOV->setByRecentData(datiface.getTable(), tag, run);
    datiface.setConnection(env, conn);
    datiface.createReadStatement();
    datiface.setPrefetchRowCount(1024);
    datiface.fetchData( fillMap, fillIOV );
    datiface.terminateReadStatement();
  }
DateHandler* EcalCondDBInterface::getDateHandler ( ) [inline]

Return a date handler associated with this connection

Definition at line 103 of file EcalCondDBInterface.h.

References dh.

    {
      return dh;
    }
EcalLogicID EcalCondDBInterface::getEcalLogicID ( std::string  name,
int  id1 = EcalLogicID::NULLID,
int  id2 = EcalLogicID::NULLID,
int  id3 = EcalLogicID::NULLID,
std::string  mapsTo = "" 
) throw (std::runtime_error)

Look up the "human readable" ids and return an EcalLogicID object which contains the "database readable" logic_id === Parameters === name: name of the channel type you are specifying id1, id2, id3: ids of the channel type mapsTo: name of the channel type you are mapping to

Referenced by EcalTPGParamBuilder::analyze(), popcon::EcalLaserHandler::dumpBarrelPayload(), popcon::EcalLaserHandler::dumpEndcapPayload(), and EcalPedOffset::writeDb().

EcalLogicID EcalCondDBInterface::getEcalLogicID ( int  logicID) throw (std::runtime_error)

Look up the database logic_id and return the EcalLogicID object which contains the "human readable" ids === Parameters === logicID: DB logic_id

Definition at line 30 of file EcalCondDBInterface.cc.

References MatrixRunner::msg, mergeVDriftHistosByStation::name, and EcalLogicID::NULLID.

{

  string sql = "SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE logic_id = :logicID AND name=maps_to";
  
  int id1, id2, id3;
  string name, mapsTo;
  
  try {
    stmt->setSQL(sql);
    stmt->setInt(1, logicID);
    ResultSet* rset = stmt->executeQuery();

    if (rset->next()) {
      name = rset->getString(1);
      logicID = rset->getInt(2);
      id1 = rset->getInt(3);
      if (rset->isNull(3)) { id1 = EcalLogicID::NULLID; }
      id2 = rset->getInt(4);
      if (rset->isNull(4)) { id2 = EcalLogicID::NULLID; }
      id3 = rset->getInt(5);
      if (rset->isNull(5)) { id3 = EcalLogicID::NULLID; }
      mapsTo = rset->getString(6);
    } else {
      stringstream msg;
      msg << "ERROR:  Cannot build EcalLogicID for logic_id " << logicID;
      throw(std::runtime_error(msg.str()));
    }

  } catch (SQLException &e) {    
    throw(std::runtime_error("ERROR:  Failed to retrive ids:  " + e.getMessage() ));
  }
  
  return EcalLogicID( name, logicID, id1, id2, id3, mapsTo );  
}
std::map< int, int > EcalCondDBInterface::getEcalLogicID2LmrMap ( )

Definition at line 223 of file EcalCondDBInterface.cc.

References i, EcalLogicID::NULLID, and runTheMatrix::ret.

                                                            {
  std::map<int, int> ret;
  std::vector<EcalLogicID> crystals_EB  =
    getEcalLogicIDSetOrdered( "EB_crystal_number",
                              1,36,1,1700,
                              EcalLogicID::NULLID,EcalLogicID::NULLID,
                              "EB_crystal_number", EcalLogicID::NULLID);
  std::vector<EcalLogicID> crystals_EE  =
    getEcalLogicIDSetOrdered( "EE_crystal_number",
                              -1,1,1,100,
                              1,100,
                              "EE_crystal_number", EcalLogicID::NULLID);
  std::vector<EcalLogicID> EB_lmr  =
    getEcalLogicIDSetOrdered( "EB_crystal_number",
                              1,36,1,1700,
                              EcalLogicID::NULLID,EcalLogicID::NULLID,
                              "ECAL_LMR", EcalLogicID::NULLID);
  std::vector<EcalLogicID> EE_lmr  =
    getEcalLogicIDSetOrdered( "EE_crystal_number",
                              -1,1,1,100,
                              1,100,
                              "ECAL_LMR", EcalLogicID::NULLID);
  unsigned int neb = crystals_EB.size();
  unsigned int nee = crystals_EE.size();
  if (neb != EB_lmr.size()) {
    throw(std::runtime_error("ERROR: EB Vectors size do not agree"));
  }
  if (nee != EE_lmr.size()) {
    throw(std::runtime_error("ERROR: EE Vectors size do not agree"));
  }
  for (unsigned int i = 0; i < neb; i++) {
    ret[crystals_EB[i].getLogicID()] = EB_lmr[i].getLogicID() % 100;
  }
  for (unsigned int i = 0; i < nee; i++) {
    ret[crystals_EE[i].getLogicID()] = EE_lmr[i].getLogicID() % 100;
  }
  return ret;
}
std::vector< EcalLogicID > EcalCondDBInterface::getEcalLogicIDSet ( std::string  name,
int  fromId1 = EcalLogicID::NULLID,
int  toId1 = EcalLogicID::NULLID,
int  fromId2 = EcalLogicID::NULLID,
int  toId2 = EcalLogicID::NULLID,
int  fromId3 = EcalLogicID::NULLID,
int  toId3 = EcalLogicID::NULLID,
std::string  mapsTo = "" 
) throw (std::runtime_error)

Get a set of EcalLogicID in one transaction === Parameters === name: name of the channel type you are specifying fromId1, toId1: Range of id1 in the DB to retrieve fromId2, toId2: Range of id2 in the DB to retrieve fromId3, toId3: Range of id3 in the DB to retrieve string mapsTo: channel type name these ids map to

Definition at line 131 of file EcalCondDBInterface.cc.

References IDBObject::ECALDB_NROWS, Capri::details::from(), i, mergeVDriftHistosByStation::name, EcalLogicID::NULLID, and query::result.

{
  if (mapsTo == "") {
    mapsTo = name;
  }
  
  int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
  int from, to;
  
  stringstream ss;
  ss << "SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
  
  // loop through the three ids
  for (int i=1; i<=3; i++) {
    from = idArray[2*(i-1)];
    to   = idArray[2*(i-1) + 1];
    
    // check the id arguments in pairs
    if ((from == EcalLogicID::NULLID && to != EcalLogicID::NULLID) || // one is null
        (from != EcalLogicID::NULLID && to == EcalLogicID::NULLID) || //   but not the other
        (from > to)) { // negative interval
      throw(std::runtime_error("ERROR:  Bad arguments for getEcalLogicIDSet"));
    }
    
    // build the sql
    if (from == EcalLogicID::NULLID && to == EcalLogicID::NULLID) {
      ss << "id" << i << " IS NULL AND ";
    } else {
      ss << "id" << i << " >= :id" << i << "from AND " <<
        "id" << i << " <= :id" << i << "to AND ";
    }
  }
  ss << "maps_to = :maps_to ORDER BY id1, id2, id3";
  
  std::vector<EcalLogicID> result;
  
  try {
    stmt->setSQL(ss.str());

    // bind the parameters
    int j = 1;  // parameter number counter
    stmt->setString(j, name);
    j++;
    
    for (int i=0; i<3; i++) {
      from = idArray[2*i];
      to   = idArray[2*i + 1];
      if (from != EcalLogicID::NULLID) {
        stmt->setInt(j, from);
        j++;
        stmt->setInt(j, to);
        j++;
      }
    }

    stmt->setString(j, mapsTo);

  
    stmt->setPrefetchRowCount(IDBObject::ECALDB_NROWS);    

    ResultSet* rset = stmt->executeQuery();

    int id1, id2, id3, logicId;

    while (rset->next()) {
      name = rset->getString(1);
      logicId = rset->getInt(2);
      id1 = rset->getInt(3);
      if (rset->isNull(3)) { id1 = EcalLogicID::NULLID; }
      id2 = rset->getInt(4);
      if (rset->isNull(4)) { id2 = EcalLogicID::NULLID; }
      id3 = rset->getInt(5);
      if (rset->isNull(5)) { id3 = EcalLogicID::NULLID; }
      mapsTo = rset->getString(6);

      EcalLogicID ecid = EcalLogicID( name, logicId, id1, id2, id3, mapsTo );
      result.push_back(ecid);
    }
    stmt->setPrefetchRowCount(0);

  } catch (SQLException &e) {
    throw(std::runtime_error("ERROR:  Failure while getting EcalLogicID set:  " + e.getMessage() ));    
  }

  return result;
}
std::vector< EcalLogicID > EcalCondDBInterface::getEcalLogicIDSetOrdered ( std::string  name,
int  fromId1,
int  toId1,
int  fromId2 = EcalLogicID::NULLID,
int  toId2 = EcalLogicID::NULLID,
int  fromId3 = EcalLogicID::NULLID,
int  toId3 = EcalLogicID::NULLID,
std::string  mapsTo = "",
int  orderedBy = EcalLogicID::NULLID 
) throw (std::runtime_error)

Definition at line 262 of file EcalCondDBInterface.cc.

References IDBObject::ECALDB_NROWS, Capri::details::from(), i, mergeVDriftHistosByStation::name, EcalLogicID::NULLID, and query::result.

Referenced by EcalTPGParamBuilder::analyze().

{
  if (mapsTo == "") {
    mapsTo = name;
  }
  
  int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
  int from, to;
  
  stringstream ss;
  ss << "SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
  
  // loop through the three ids
  for (int i=1; i<=3; i++) {
    from = idArray[2*(i-1)];
    to   = idArray[2*(i-1) + 1];
    
    // check the id arguments in pairs
    if ((from == EcalLogicID::NULLID && to != EcalLogicID::NULLID) || // one is null
        (from != EcalLogicID::NULLID && to == EcalLogicID::NULLID) || //   but not the other
        (from > to)) { // negative interval
      throw(std::runtime_error("ERROR:  Bad arguments for getEcalLogicIDSet"));
    }
    
    // build the sql
    if (from == EcalLogicID::NULLID && to == EcalLogicID::NULLID) {
      ss << "id" << i << " IS NULL AND ";
    } else {
      ss << "id" << i << " >= :id" << i << "from AND " <<
        "id" << i << " <= :id" << i << "to AND ";
    }
  }
  ss << "maps_to = :maps_to ";

  if(orderedBy==EcalLogicID::NULLID){
    ss<<"  ORDER BY id1, id2, id3";
  } else if(orderedBy==1 || orderedBy==12 || orderedBy==123){
    ss<<"  ORDER BY id1, id2, id3 ";
  } else if (orderedBy==213 || orderedBy==21 ){ 
    ss<<"  ORDER BY id2, id1, id3 ";
  } else if (orderedBy==231|| orderedBy==23){ 
    ss<<"  ORDER BY id2, id3, id1 ";
  } else if (orderedBy==321|| orderedBy==32){
    ss<<"  ORDER BY id3, id2, id1 ";
  } else if (orderedBy==312|| orderedBy==31){
    ss<<"  ORDER BY id3, id1, id2 ";
  } else if (orderedBy==132|| orderedBy==13){ 
    ss<<"  ORDER BY id1, id3, id2 ";
  } else if (orderedBy==1234 ){ 
    ss<<"  ORDER BY id1, id2, id3, logic_id ";
  } else if (orderedBy==4) {
    ss<<"  ORDER BY logic_id ";
  } else {
    ss<<"  ORDER BY id1, id2, id3";
  }
  
  std::vector<EcalLogicID> result;
  
  try {
    stmt->setSQL(ss.str());

    // bind the parameters
    int j = 1;  // parameter number counter
    stmt->setString(j, name);
    j++;
    
    for (int i=0; i<3; i++) {
      from = idArray[2*i];
      to   = idArray[2*i + 1];
      if (from != EcalLogicID::NULLID) {
        stmt->setInt(j, from);
        j++;
        stmt->setInt(j, to);
        j++;
      }
    }

    stmt->setString(j, mapsTo);

  
    stmt->setPrefetchRowCount(IDBObject::ECALDB_NROWS);    

    ResultSet* rset = stmt->executeQuery();

    int id1, id2, id3, logicId;

    while (rset->next()) {
      name = rset->getString(1);
      logicId = rset->getInt(2);
      id1 = rset->getInt(3);
      if (rset->isNull(3)) { id1 = EcalLogicID::NULLID; }
      id2 = rset->getInt(4);
      if (rset->isNull(4)) { id2 = EcalLogicID::NULLID; }
      id3 = rset->getInt(5);
      if (rset->isNull(5)) { id3 = EcalLogicID::NULLID; }
      mapsTo = rset->getString(6);

      EcalLogicID ecid = EcalLogicID( name, logicId, id1, id2, id3, mapsTo );
      result.push_back(ecid);
    }
    stmt->setPrefetchRowCount(0);

  } catch (SQLException &e) {
    throw(std::runtime_error("ERROR:  Failure while getting EcalLogicID set:  " + e.getMessage() ));    
  }

  return result;
}
template<class DATT , class ICONF >
void EcalCondDBInterface::insertConfigDataArraySet ( const std::vector< DATT >  data,
ICONF *  iconf 
) throw (std::runtime_error) [inline]

Definition at line 497 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, gather_cfg::cout, AlCaHLTBitMon_QueryRunRegistry::data, and EcalDBConnection::env.

Referenced by EcalDccWeightBuilder::writeWeightToDB().

  {
    try {
      iconf->setConnection(env, conn);
      // if it has not yet been written then write 
      if(iconf->getId()==0){
        std::cout<<"EcalCondDBInterface>> config_id was not set we retrieve it from DB"<<std::endl;
        iconf->fetchID();
      } 
      if(iconf->getId()==0){
        std::cout<<"EcalCondDBInterface>> configuration info was not written we write it"<<std::endl;
        iconf->writeDB();
      } 
      
      DATT dataIface;
      dataIface.setConnection(env, conn);
      dataIface.prepareWrite();
      
      dataIface.writeArrayDB(data, iconf);
      conn->commit();
      
      dataIface.terminateWriteStatement();
   
    } catch (std::runtime_error &e) {
      conn->rollback();
      throw(e);
    } catch (...) {
      conn->rollback();
      throw(std::runtime_error("EcalCondDBInterface::insertConfigDataArraySet:  Unknown exception caught"));
    }
  }
template<class DATT , class ICONF >
void EcalCondDBInterface::insertConfigDataSet ( const std::vector< DATT >  data,
ICONF *  iconf 
) throw (std::runtime_error) [inline]

Definition at line 458 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, gather_cfg::cout, AlCaHLTBitMon_QueryRunRegistry::data, EcalDBConnection::env, and AlCaHLTBitMon_ParallelJobs::p.

  {
    try {
      iconf->setConnection(env, conn);
      // if it has not yet been written then write 
      if(iconf->getId()==0){
        std::cout<<"EcalCondDBInterface>> config_id was not set we retrieve it from DB"<<std::endl;
        iconf->fetchID();
      } 
      if(iconf->getId()==0){
        std::cout<<"EcalCondDBInterface>> configuration info was not written we write it"<<std::endl;
        iconf->writeDB();
      } 
      
      DATT dataIface;
      dataIface.setConnection(env, conn);
      dataIface.prepareWrite();
      
      const DATT* dataitem;

      for (int p = 0; p != data->size(); ++p) {
        dataitem = data[p];
        dataIface.writeDB( dataitem, iconf);
      }
      conn->commit();
      dataIface.terminateWriteStatement();
    } catch (std::runtime_error &e) {
      conn->rollback();
      throw(e);
    } catch (...) {
      conn->rollback();
      throw(std::runtime_error("EcalCondDBInterface::insertConfigDataSet:  Unknown exception caught"));
    }
  }
template<class ICONF >
void EcalCondDBInterface::insertConfigSet ( ICONF *  iconf) throw (std::runtime_error) [inline]

Definition at line 400 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, gather_cfg::cout, and EcalDBConnection::env.

Referenced by EcalTPGDBApp::writeToConfDB_Delay(), EcalTPGDBApp::writeToConfDB_Spike(), EcalTPGDBApp::writeToConfDB_TPGFgr(), EcalTPGDBApp::writeToConfDB_TPGLinearCoef(), EcalTPGDBApp::writeToConfDB_TPGLUT(), EcalTPGDBApp::writeToConfDB_TPGMain(), EcalTPGDBApp::writeToConfDB_TPGPedestals(), EcalTPGDBApp::writeToConfDB_TPGSliding(), EcalTPGDBApp::writeToConfDB_TPGWeight(), and EcalDccWeightBuilder::writeWeightToDB().

   {
     try {
       iconf->setConnection(env, conn);
       iconf->prepareWrite();
       // if it has not yet been written then write 
       iconf->writeDB();
       std::cout<< "iconf inserted with ID="<<iconf->getId()<<std::endl;
       conn->commit();
       iconf->terminateWriteStatement();
     } catch (std::runtime_error &e) {
       conn->rollback();
       throw(e);
     } catch (...) {
       conn->rollback();
       throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
     }
   }
template<class DATT , class IOVT >
void EcalCondDBInterface::insertDataArraySet ( const std::map< EcalLogicID, DATT > *  data,
IOVT *  iov 
) throw (std::runtime_error) [inline]

Definition at line 323 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, gather_cfg::cout, AlCaHLTBitMon_QueryRunRegistry::data, EcalDBConnection::env, and o2o::iov.

Referenced by EcalTPGDBApp::writeToConfDB_Delay(), EcalTPGDBApp::writeToConfDB_Spike(), EcalTPGDBApp::writeToConfDB_TPGFgr(), EcalTPGDBApp::writeToConfDB_TPGLinearCoef(), EcalTPGDBApp::writeToConfDB_TPGLUT(), EcalTPGDBApp::writeToConfDB_TPGPedestals(), EcalTPGDBApp::writeToConfDB_TPGSliding(), and EcalTPGDBApp::writeToConfDB_TPGWeight().

  {
    try {
      iov->setConnection(env, conn);
      if(iov->getID()==0){
        std::cout<<"IOV was not set we retrieve it from DB"<<std::endl;
        iov->fetchID();
      } 
      if(iov->getID()==0){
        std::cout<<"IOV was not written we write it"<<std::endl;
        iov->writeDB();
      } 

      std::cout<<"id="<<iov->getID()<<std::endl;

      DATT dataIface;
      dataIface.setConnection(env, conn);
      dataIface.prepareWrite();
      
      dataIface.writeArrayDB(data, iov);
      conn->commit();
      
      dataIface.terminateWriteStatement();
   
    } catch (std::runtime_error &e) {
      conn->rollback();
      throw(e);
    } catch (...) {
      conn->rollback();
      throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
    }
  }
template<class DATT , class IOVT >
void EcalCondDBInterface::insertDataSet ( const std::map< EcalLogicID, DATT > *  data,
IOVT *  iov 
) throw (std::runtime_error) [inline]

Definition at line 283 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, gather_cfg::cout, EcalDBConnection::env, o2o::iov, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by EcalEndcapMonitorClient::endRunDb(), EcalBarrelMonitorClient::endRunDb(), EcalEndcapMonitorClient::writeDb(), EcalBarrelMonitorClient::writeDb(), and EcalPedOffset::writeDb().

  {
    try {
      iov->setConnection(env, conn);
      // if it has not yet been written then write 
      if(iov->getID()==0){
        std::cout<<"IOV was not set we retrieve it from DB"<<std::endl;
        iov->fetchID();
      } 
      if(iov->getID()==0){
        std::cout<<"IOV was not written we write it"<<std::endl;
        iov->writeDB();
      } 
      
      DATT dataIface;
      dataIface.setConnection(env, conn);
      dataIface.prepareWrite();
      
      const EcalLogicID* channel;
      const DATT* dataitem;
      typedef typename std::map< EcalLogicID, DATT >::const_iterator CI;
      for (CI p = data->begin(); p != data->end(); ++p) {
        channel = &(p->first);
        dataitem = &(p->second);
        dataIface.writeDB( channel, dataitem, iov);
      }
      conn->commit();
      dataIface.terminateWriteStatement();
    } catch (std::runtime_error &e) {
      conn->rollback();
      throw(e);
    } catch (...) {
      conn->rollback();
      throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
    }
  }
template<class DATT , class IOVT >
void EcalCondDBInterface::insertDataSetVector ( std::vector< EcalLogicID ecid,
std::vector< IOVT >  run_iov,
std::vector< DATT >  data 
) throw (std::runtime_error) [inline]

Definition at line 358 of file EcalCondDBInterface.h.

References EcalDBConnection::conn, AlCaHLTBitMon_QueryRunRegistry::data, EcalDBConnection::env, and i.

  {
   
    int nruns= run_iov.size();
   
    if(run_iov.size()!=ecid.size() &&ecid.size()!=data.size()){
      throw(std::runtime_error("EcalCondDBInterface::insertDataSetVector:  vector sizes are different.."));
    } 


    try {
      
      DATT dataIface;
      dataIface.setConnection(env, conn);
      dataIface.prepareWrite();

      for (int i=0; i<nruns; i++){

        run_iov[i].setConnection(env, conn);
        run_iov[i].writeDB();
      
        dataIface.writeDB( &ecid[i], &data[i], &run_iov[i]);
        
        conn->commit();
      }
    } catch (std::runtime_error &e) {
      conn->rollback();
      throw(e);
    } catch (...) {
      conn->rollback();
      throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
    }
  }
void EcalCondDBInterface::insertDCUIOV ( DCUIOV iov) throw (std::runtime_error)

Insert a DCU IOV object. Nothing is committed in the event of an exception

Definition at line 564 of file EcalCondDBInterface.cc.

References o2o::iov.

{
  try {
    iov->setConnection(env, conn);
    iov->writeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::insertLmfDat ( LMFDat dat) throw (std::runtime_error)

Definition at line 432 of file EcalCondDBInterface.cc.

{
  try {
    dat->setConnection(env, conn);
    dat->writeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::insertLmfDat ( std::list< LMFDat * >  dat) throw (std::runtime_error)

Definition at line 445 of file EcalCondDBInterface.cc.

References i.

{
  try {
    std::list<LMFDat *>::iterator i = dat.begin();
    std::list<LMFDat *>::iterator e = dat.end();
    while (i != e) {
      (*i)->setConnection(env, conn);
      (*i)->writeDB();
      i++;
    }
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::insertLmfIOV ( LMFIOV iov) throw (std::runtime_error)

Definition at line 419 of file EcalCondDBInterface.cc.

References o2o::iov.

{
  try {
    iov->setConnection(env, conn);
    iov->writeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::insertLmfLmrSubIOV ( LMFLmrSubIOV iov) throw (std::runtime_error)

Definition at line 406 of file EcalCondDBInterface.cc.

References o2o::iov.

{
  try {
    iov->setConnection(env, conn);
    iov->writeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::insertLmfRunIOV ( LMFRunIOV iov) throw (std::runtime_error)

Definition at line 463 of file EcalCondDBInterface.cc.

References o2o::iov.

{
  try {
    iov->setConnection(env, conn);
    iov->writeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::insertLmfSeq ( LMFSeqDat iov) throw (std::runtime_error)

Definition at line 393 of file EcalCondDBInterface.cc.

References o2o::iov.

{
  try {
    iov->setConnection(env, conn);
    iov->writeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::insertMonRunIOV ( MonRunIOV iov) throw (std::runtime_error)

Insert a monitoring run object. Nothing is committed in the event of an exception

Definition at line 551 of file EcalCondDBInterface.cc.

References o2o::iov.

Referenced by EcalEndcapMonitorClient::writeDb(), and EcalBarrelMonitorClient::writeDb().

{
  try {
    iov->setConnection(env, conn);
    iov->writeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::insertRunIOV ( RunIOV iov) throw (std::runtime_error)

Insert a run IOV object. Nothing is committed in the event of an exception

Definition at line 380 of file EcalCondDBInterface.cc.

References o2o::iov.

Referenced by EcalEndcapMonitorClient::beginRunDb(), and EcalBarrelMonitorClient::beginRunDb().

{
  try {
    iov->setConnection(env, conn);
    iov->writeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::updateRunConfig ( ODRunConfigInfo od) throw (std::runtime_error)

Definition at line 515 of file EcalCondDBInterface.cc.

{
  try {
    od->setConnection(env, conn);
    od->updateDefaultCycle();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::updateRunIOV ( RunIOV iov) throw (std::runtime_error)

Definition at line 476 of file EcalCondDBInterface.cc.

References o2o::iov.

{
  try {
    iov->setConnection(env, conn);
    iov->updateEndTimeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::updateRunIOVEndTime ( RunIOV iov) throw (std::runtime_error)

Definition at line 489 of file EcalCondDBInterface.cc.

References o2o::iov.

{
  try {
    iov->setConnection(env, conn);
    iov->updateEndTimeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}
void EcalCondDBInterface::updateRunIOVStartTime ( RunIOV iov) throw (std::runtime_error)

Definition at line 502 of file EcalCondDBInterface.cc.

References o2o::iov.

{
  try {
    iov->setConnection(env, conn);
    iov->updateStartTimeDB();
  } catch(std::runtime_error &e) {
    conn->rollback();
    throw(e);
  }
  conn->commit();
}

Member Data Documentation