CMS 3D CMS Logo

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

LMFLmrSubIOV Class Reference

#include <LMFLmrSubIOV.h>

Inheritance diagram for LMFLmrSubIOV:
LMFUnique IUniqueDBObject IDBObject

List of all members.

Public Member Functions

std::list< LMFLmrSubIOVfetchByLMFIOV (const LMFIOV &iov)
std::list< int > getIOVIDsLaterThan (const Tm &tmin, const Tm &tmax) throw (std::runtime_error)
std::list< int > getIOVIDsLaterThan (const Tm &t, int howMany) throw (std::runtime_error)
std::list< int > getIOVIDsLaterThan (const Tm &t, const Tm &tmax, int howMany) throw (std::runtime_error)
std::list< int > getIOVIDsLaterThan (const Tm &t) throw (std::runtime_error)
LMFIOV getLMFIOV () const
int getLMFIOVID () const
Tm getT1 ()
Tm getT2 ()
Tm getT3 ()
Tm getTime (int i)
void getTimes (Tm *t) const
std::vector< TmgetTimes () const
void getTimes (Tm *t1, Tm *t2, Tm *t3) const
 LMFLmrSubIOV ()
 LMFLmrSubIOV (EcalDBConnection *c)
 LMFLmrSubIOV (oracle::occi::Environment *env, oracle::occi::Connection *conn)
bool operator!= (const LMFLmrSubIOV &m) const
bool operator== (const LMFLmrSubIOV &m) const
LMFLmrSubIOVsetLMFIOV (const LMFIOV &iov)
LMFLmrSubIOVsetLMFIOV (int i)
LMFLmrSubIOVsetTimes (std::vector< Tm > t)
LMFLmrSubIOVsetTimes (Tm *t)
LMFLmrSubIOVsetTimes (Tm t1, Tm t2, Tm t3)
 ~LMFLmrSubIOV ()

Private Member Functions

std::string fetchIdSql (Statement *stmt)
void getParameters (ResultSet *rset)
void init ()
std::string setByIDSql (Statement *stmt, int id)
std::string writeDBSql (Statement *stmt)

Private Attributes

int m_lmfIOV
Tm m_t [3]

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 13 of file LMFLmrSubIOV.h.


Constructor & Destructor Documentation

LMFLmrSubIOV::LMFLmrSubIOV ( )

Definition at line 12 of file LMFLmrSubIOV.cc.

References init().

                           {
  init();
}
LMFLmrSubIOV::LMFLmrSubIOV ( EcalDBConnection c)

Definition at line 16 of file LMFLmrSubIOV.cc.

References init().

                                             : LMFUnique(c) {
  init();
}
LMFLmrSubIOV::LMFLmrSubIOV ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

Definition at line 20 of file LMFLmrSubIOV.cc.

References init().

                                                      : LMFUnique(env, conn)
{
  init();
}
LMFLmrSubIOV::~LMFLmrSubIOV ( )

Definition at line 26 of file LMFLmrSubIOV.cc.

                            {
}

Member Function Documentation

std::list<LMFLmrSubIOV> LMFLmrSubIOV::fetchByLMFIOV ( const LMFIOV iov)
std::string LMFLmrSubIOV::fetchIdSql ( Statement stmt) [private, virtual]

Reimplemented from LMFUnique.

Definition at line 52 of file LMFLmrSubIOV.cc.

References gather_cfg::cout, cuy::dh, i, LMFUnique::m_className, IDBObject::m_conn, LMFUnique::m_debug, IDBObject::m_env, m_lmfIOV, m_t, AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, and DateHandler::tmToDate().

                                                  {
  if (!m_lmfIOV) {
    if (m_debug) {
      std::cout << m_className << ": LMFIOV not set" << std::endl;
    }
    return "";
  }

  std::string sql = "SELECT LMR_SUB_IOV_ID FROM "
    "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV "
    "WHERE "
    "IOV_ID  = :1 AND "
    "T1      = :2 AND "
    "T2      = :3 AND "
    "T3      = :4";
  stmt->setSQL(sql);
  stmt->setInt(1, m_lmfIOV);
  DateHandler dh(m_env, m_conn);
  for (int i = 0; i < 3; i++) {
    oracle::occi::Date t = dh.tmToDate(m_t[i]);
    stmt->setDate(i + 2, t);
  }
  return sql;

}
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t,
int  howMany 
) throw (std::runtime_error)

Definition at line 127 of file LMFLmrSubIOV.cc.

References Tm::setToString(), and lumiQTWidget::t.

                          {
  Tm tinf;
  tinf.setToString("9999-12-31 23:59:59");
  return getIOVIDsLaterThan(t, tinf, howmany);
}
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t,
const Tm tmax,
int  howMany 
) throw (std::runtime_error)

Definition at line 140 of file LMFLmrSubIOV.cc.

References gather_cfg::cout, cuy::dh, alignCSCRings::e, NULL, run_regression::ret, Tm::setToString(), AlCaHLTBitMon_QueryRunRegistry::string, tmax, and DateHandler::tmToDate().

                          {
  Tm tinf;
  tinf.setToString("9999-12-31 23:59:59");
  std::string sql = "SELECT * FROM (SELECT LMR_SUB_IOV_ID "  
    "FROM CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV WHERE T3 > :1 ";
  if (tmax != tinf) {
    sql += "AND T3 < :2 ORDER BY T3 ASC) ";
    if (howMany > 0) {
      sql += "WHERE ROWNUM <= :3";
    }
  } else {
    sql += "ORDER BY T3 ASC) ";
    if (howMany > 0) {
      sql += "WHERE ROWNUM <= :2";
    }
  }
  if (m_debug) {
    std::cout << "Executing query: " << std::endl << sql << std::endl;
  }
  std::list<int> ret; 
  if (m_conn != NULL) {
    try {
      DateHandler dh(m_env, m_conn);
      Statement *stmt = m_conn->createStatement();
      stmt->setPrefetchRowCount(10000);
      stmt->setSQL(sql);
      stmt->setDate(1, dh.tmToDate(tmin));
      if (tmax != tinf) {
        stmt->setDate(2, dh.tmToDate(tmax));
        if (howMany > 0) {
          stmt->setInt(3, howMany);
        }
      } else {
        if (howMany > 0) {
          stmt->setInt(2, howMany);
        }
      }
      ResultSet *rset = stmt->executeQuery();
      int row = 1;
      while (rset->next() != 0) {
        if (m_debug) {
          std::cout << "Getting row " << row++ << std::endl;
        }
        ret.push_back(rset->getInt(1));
      }
      stmt->setPrefetchRowCount(0);
      m_conn->terminateStatement(stmt);
    }
    catch (oracle::occi::SQLException e) {
      throw(std::runtime_error(m_className + "::getLmrSubIOVLaterThan: " +
                               e.getMessage()));
    }
  } else {
    throw(std::runtime_error(m_className + "::getLmrSubIOVLaterThan: " +
                             "Connection not set"));
  }
  if (m_debug) {
    std::cout << "Sorting..." << std::flush;
  }
  ret.sort();
  if (m_debug) {
    std::cout << "Done!" << std::endl << std::flush;
  }
  return ret;
}
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm t) throw (std::runtime_error)

Definition at line 120 of file LMFLmrSubIOV.cc.

References Tm::setToString(), and lumiQTWidget::t.

Referenced by LMFCorrCoefDat::fetchBetween().

                          {
  Tm tinf;
  tinf.setToString("9999-12-31 23:59:59");
  return getIOVIDsLaterThan(t, tinf, 0);
}
std::list< int > LMFLmrSubIOV::getIOVIDsLaterThan ( const Tm tmin,
const Tm tmax 
) throw (std::runtime_error)

Definition at line 134 of file LMFLmrSubIOV.cc.

References tmax.

                          {
  return getIOVIDsLaterThan(tmin, tmax, 0);
}
LMFIOV LMFLmrSubIOV::getLMFIOV ( ) const [inline]

Definition at line 32 of file LMFLmrSubIOV.h.

References o2o::iov, IDBObject::m_conn, IDBObject::m_env, m_lmfIOV, and LMFUnique::setByID().

                           {
    LMFIOV iov(m_env, m_conn);
    iov.setByID(m_lmfIOV);
    return iov;
  };
int LMFLmrSubIOV::getLMFIOVID ( ) const [inline]

Definition at line 29 of file LMFLmrSubIOV.h.

References m_lmfIOV.

                          {
    return m_lmfIOV;
  };
void LMFLmrSubIOV::getParameters ( ResultSet rset) [private, virtual]

Reimplemented from LMFUnique.

Definition at line 112 of file LMFLmrSubIOV.cc.

References i, m_lmfIOV, m_t, Tm::setToString(), and lumiQTWidget::t.

                                                {
  m_lmfIOV = rset->getInt(1);
  for (int i = 0; i < 3; i++) {
    oracle::occi::Date t = rset->getDate(i + 2);
    m_t[i].setToString(t.toText("YYYY-MM-DD HH24:MI:SS"));
  }
}
Tm LMFLmrSubIOV::getT1 ( ) [inline]

Definition at line 61 of file LMFLmrSubIOV.h.

References m_t.

                    {
    return m_t[0];
  }
Tm LMFLmrSubIOV::getT2 ( ) [inline]

Definition at line 64 of file LMFLmrSubIOV.h.

References m_t.

                    {
    return m_t[1];
  }
Tm LMFLmrSubIOV::getT3 ( ) [inline]

Definition at line 67 of file LMFLmrSubIOV.h.

References m_t.

                    {
    return m_t[2];
  }
Tm LMFLmrSubIOV::getTime ( int  i) [inline]

Definition at line 54 of file LMFLmrSubIOV.h.

References m_t, and lumiQTWidget::t.

                           {
    Tm t;
    if ((i > 0) && (i < 4)) {
      t = m_t[i - 1];
    }
    return t;
  }
std::vector<Tm> LMFLmrSubIOV::getTimes ( ) const [inline]

Definition at line 42 of file LMFLmrSubIOV.h.

References m_t, and findQualityFiles::v.

                                 {
    std::vector<Tm> v;
    v.push_back(m_t[0]);
    v.push_back(m_t[1]);
    v.push_back(m_t[2]);
    return v;
  }
void LMFLmrSubIOV::getTimes ( Tm t1,
Tm t2,
Tm t3 
) const [inline]

Definition at line 37 of file LMFLmrSubIOV.h.

References m_t.

Referenced by LMFCorrCoefDat::getTimes().

                                                     {
    *t1 = m_t[0];
    *t2 = m_t[1];
    *t3 = m_t[2];
  }
void LMFLmrSubIOV::getTimes ( Tm t) const [inline]

Definition at line 49 of file LMFLmrSubIOV.h.

References m_t.

                                    {
    t[0] = m_t[0];
    t[1] = m_t[1];
    t[2] = m_t[2];
  }
void LMFLmrSubIOV::init ( void  ) [private]

Definition at line 3 of file LMFLmrSubIOV.cc.

References LMFUnique::m_className, m_lmfIOV, and m_t.

Referenced by LMFLmrSubIOV().

                        {
  m_className = "LMFLmrSubIOV";

  m_lmfIOV = 0;
  m_t[0] = Tm();
  m_t[1] = Tm();
  m_t[2] = Tm();
}
bool LMFLmrSubIOV::operator!= ( const LMFLmrSubIOV m) const [inline]

Definition at line 90 of file LMFLmrSubIOV.h.

References m.

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

Definition at line 82 of file LMFLmrSubIOV.h.

References m_lmfIOV, and m_t.

    {
      return ( (m_lmfIOV   == m.m_lmfIOV) &&
               (m_t[0]    == m.m_t[0]) &&
               (m_t[1]    == m.m_t[1]) && 
               (m_t[2]    == m.m_t[2]));
    }
std::string LMFLmrSubIOV::setByIDSql ( Statement stmt,
int  id 
) [private, virtual]

Reimplemented from LMFUnique.

Definition at line 78 of file LMFLmrSubIOV.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

                                                          {
  std::string sql = "SELECT IOV_ID, T1, T2, T3 FROM "
    "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV "
    "WHERE LMR_SUB_IOV_ID = :1";
  stmt->setSQL(sql);
  stmt->setInt(1, id);
  return sql;
}
LMFLmrSubIOV & LMFLmrSubIOV::setLMFIOV ( const LMFIOV iov)

Definition at line 29 of file LMFLmrSubIOV.cc.

References gather_cfg::cout, LMFUnique::getID(), LMFUnique::m_debug, and m_lmfIOV.

                                                       {
  if (m_debug) {
    std::cout << "[LMFLmrSubIOV] Setting IOV_ID as " << iov.getID() 
              << std::endl << std::flush; 
  }
  m_lmfIOV = iov.getID();
  return *this;
}
LMFLmrSubIOV& LMFLmrSubIOV::setLMFIOV ( int  i)
LMFLmrSubIOV & LMFLmrSubIOV::setTimes ( Tm  t1,
Tm  t2,
Tm  t3 
)

Definition at line 45 of file LMFLmrSubIOV.cc.

References m_t.

                                                        {
  m_t[0] = t1;
  m_t[1] = t2;
  m_t[2] = t3;
  return *this;
}
LMFLmrSubIOV & LMFLmrSubIOV::setTimes ( Tm t)

Definition at line 38 of file LMFLmrSubIOV.cc.

References m_t.

                                          {
  m_t[0] = t[0];
  m_t[1] = t[1];
  m_t[2] = t[2];
  return *this;
}
LMFLmrSubIOV& LMFLmrSubIOV::setTimes ( std::vector< Tm t)
std::string LMFLmrSubIOV::writeDBSql ( Statement stmt) [private, virtual]

Reimplemented from LMFUnique.

Definition at line 87 of file LMFLmrSubIOV.cc.

References cuy::dh, DateHandler::getPlusInfTm(), i, LMFUnique::m_className, IDBObject::m_conn, IDBObject::m_env, m_lmfIOV, m_t, LMFUnique::sequencePostfix(), AlCaHLTBitMon_QueryRunRegistry::string, and DateHandler::tmToDate().

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

  for (int i = 0; i < 3; i++) {
    if (m_t[i].isNull()) {
      m_t[i] = dh.getPlusInfTm();
    }
  }

  if (m_lmfIOV == 0) {
    throw(std::runtime_error(m_className + "::writeDB: LMFIOV not set"));
  }
  std::string sp = sequencePostfix(m_t[0]);
  std::string sql = "INSERT INTO LMF_LMR_SUB_IOV (LMR_SUB_IOV_ID, "
    "IOV_ID, T1, T2, T3) "
    "VALUES (LMF_LMR_SUB_IOV_ID_" + sp + "_SQ.NextVal, :1, :2, :3, :4)";
  stmt->setSQL(sql);
  stmt->setInt(1, m_lmfIOV);
  for (int i = 0; i < 3; i++) {
    stmt->setDate(i + 2, dh.tmToDate(m_t[i]));
  }
  return sql;
}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from LMFUnique.

Definition at line 15 of file LMFLmrSubIOV.h.


Member Data Documentation

int LMFLmrSubIOV::m_lmfIOV [private]
Tm LMFLmrSubIOV::m_t[3] [private]