CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
LMFCorrCoefDat Class Reference

#include <LMFCorrCoefDat.h>

Public Member Functions

void debug ()
 
void dump ()
 
void fetch (std::list< int > subiov_ids)
 
void fetch (int subiov_id)
 
void fetch (const LMFLmrSubIOV &iov)
 
void fetchAfter (const Tm &t)
 
void fetchAfter (const Tm &t, int howMany)
 
void fetchBetween (const Tm &tmin, const Tm &tmax)
 
void fetchBetween (const Tm &tmin, const Tm &tmax, int maxNumberOfIOVs)
 
RunIOV fetchLastInsertedRun ()
 
std::map< int, std::map< int,
LMFSextuple > > 
getCorrections (const Tm &t)
 
std::map< int, std::map< int,
LMFSextuple > > 
getCorrections (const Tm &t, int max)
 
std::map< int, std::map< int,
LMFSextuple > > 
getCorrections (const Tm &t, const Tm &t2, int max)
 
int getFlag (const LMFLmrSubIOV &iov, const EcalLogicID &id)
 
std::vector< float > getParameterErrors (const LMFLmrSubIOV &iov, const EcalLogicID &id)
 
std::list< std::vector< float > > getParameters (int id)
 
std::list< std::vector< float > > getParameters (const EcalLogicID &id)
 
std::vector< float > getParameters (const LMFLmrSubIOV &iov, const EcalLogicID &id)
 
int getSeqID (const LMFLmrSubIOV &iov, const EcalLogicID &id)
 
LMFSeqDat getSequence (const LMFLmrSubIOV &iov, const EcalLogicID &id)
 
std::list< int > getSubIOVIDs ()
 
std::vector< TmgetTimes (const LMFLmrSubIOV &iov)
 
void init ()
 
 LMFCorrCoefDat ()
 
 LMFCorrCoefDat (EcalDBConnection *c)
 
 LMFCorrCoefDat (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
void nodebug ()
 
LMFCorrCoefDatsetConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
LMFCorrCoefDatsetFlag (const LMFLmrSubIOV &iov, const EcalLogicID &id, int flag)
 
LMFCorrCoefDatsetP123 (const LMFLmrSubIOV &iov, const EcalLogicID &id, float p1, float p2, float p3)
 
LMFCorrCoefDatsetP123 (const LMFLmrSubIOV &iov, const EcalLogicID &id, float p1, float p2, float p3, float p1e, float p2e, float p3e)
 
LMFCorrCoefDatsetP123Errors (const LMFLmrSubIOV &iov, const EcalLogicID &id, float p1e, float p2e, float p3e)
 
LMFCorrCoefDatsetSequence (const LMFLmrSubIOV &iov, const EcalLogicID &id, int seq_id)
 
LMFCorrCoefDatsetSequence (const LMFLmrSubIOV &iov, const EcalLogicID &id, const LMFSeqDat &seq)
 
int size () const
 
void writeDB ()
 
 ~LMFCorrCoefDat ()
 

Private Member Functions

void checkTriplets (int logic_id, const LMFSextuple &s, const std::map< int, LMFSextuple > &lastMap)
 
LMFCorrCoefDatComponentfind (const LMFLmrSubIOV &iov)
 

Private Attributes

oracle::occi::Connection * m_conn
 
std::map< int,
LMFCorrCoefDatComponent * > 
m_data
 
bool m_debug
 
oracle::occi::Environment * m_env
 
std::map< int, LMFLmrSubIOV * > m_subiov
 

Static Private Attributes

static const int MAX_NUMBER_OF_SEQUENCES_TO_FETCH = 32
 

Detailed Description

Definition at line 16 of file LMFCorrCoefDat.h.

Constructor & Destructor Documentation

LMFCorrCoefDat::LMFCorrCoefDat ( )

Definition at line 4 of file LMFCorrCoefDat.cc.

References init().

4  {
5  init();
6 }
LMFCorrCoefDat::LMFCorrCoefDat ( EcalDBConnection c)

Definition at line 8 of file LMFCorrCoefDat.cc.

References EcalDBConnection::getConn(), EcalDBConnection::getEnv(), init(), m_conn, and m_env.

8  {
9  init();
10  m_env = c->getEnv();
11  m_conn = c->getConn();
12 }
oracle::occi::Connection * m_conn
oracle::occi::Environment * getEnv() const
oracle::occi::Connection * getConn() const
oracle::occi::Environment * m_env
LMFCorrCoefDat::LMFCorrCoefDat ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

Definition at line 14 of file LMFCorrCoefDat.cc.

References results_mgr::conn, web.browse_db::env, init(), m_conn, and m_env.

15  {
16  init();
17  m_env = env;
18  m_conn = conn;
19 }
oracle::occi::Connection * m_conn
oracle::occi::Environment * m_env
tuple conn
Definition: results_mgr.py:53
LMFCorrCoefDat::~LMFCorrCoefDat ( )

Definition at line 21 of file LMFCorrCoefDat.cc.

References alignCSCRings::e, i, m_data, and m_subiov.

21  {
22  std::map<int, LMFCorrCoefDatComponent*>::iterator i = m_data.begin();
23  std::map<int, LMFCorrCoefDatComponent*>::iterator e = m_data.end();
24  while (i != e) {
25  delete i->second;
26  i++;
27  }
28  m_data.clear();
29  std::map<int, LMFLmrSubIOV*>::iterator si = m_subiov.begin();
30  std::map<int, LMFLmrSubIOV*>::iterator se = m_subiov.end();
31  while (si != se) {
32  delete si->second;
33  si++;
34  }
35  m_subiov.clear();
36 }
std::map< int, LMFLmrSubIOV * > m_subiov
int i
Definition: DBlmapReader.cc:9
std::map< int, LMFCorrCoefDatComponent * > m_data

Member Function Documentation

void LMFCorrCoefDat::checkTriplets ( int  logic_id,
const LMFSextuple s,
const std::map< int, LMFSextuple > &  lastMap 
)
private

Definition at line 331 of file LMFCorrCoefDat.cc.

Referenced by getCorrections().

333 {
334  // this method verify that T3 in the last inserted record for a given
335  // crystal coincides with T1 of the newly inserted record
336  if (lastMap.find(logic_id) != lastMap.end()) {
337  const LMFSextuple sold = lastMap.find(logic_id)->second;
338  /* This check is wrong as it is. But we still need to define
339  a reasonable one.
340  if (sold.t[2] != s.t[0]) {
341  std::cout << ":-( T3 in last sequence for crystal " << logic_id
342  << " differs from T1 in this sequence: "
343  << sold.t[2].str() << " != " << s.t[0].str() << std::endl;
344  exit(0);
345  }
346  */
347  } else {
348  /* This check too must be updated
349  std::cout << ":-( Can't find crystal " << logic_id << " in last map"
350  << std::endl;
351  */
352  }
353 }
void LMFCorrCoefDat::debug ( )

Definition at line 146 of file LMFCorrCoefDat.cc.

References gather_cfg::cout, and m_debug.

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

146  {
147  std::cout << "Set debug" << std::endl << std::flush;
148  m_debug = true;
149 }
tuple cout
Definition: gather_cfg.py:121
void LMFCorrCoefDat::dump ( void  )

Definition at line 116 of file LMFCorrCoefDat.cc.

References prof2calltree::count, gather_cfg::cout, alignCSCRings::e, i, and m_data.

116  {
117  std::cout << std::endl;
118  std::cout << "##################### LMF_CORR_COEF_DAT ########################" << std::endl;
119  std::cout << "This structure contains " << m_data.size() << " LMR_SUB_IOV_ID" << std::endl;
120  std::map<int, LMFCorrCoefDatComponent*>::const_iterator i = m_data.begin();
121  std::map<int, LMFCorrCoefDatComponent*>::const_iterator e = m_data.end();
122  int count = 0;
123  while (i != e) {
124  std::cout << "### SUB IOV ID: " << i->second->getLMFLmrSubIOVID() << std::endl;
125  std::list<int> logic_ids = i->second->getLogicIds();
126  std::cout << " Contains data for " << logic_ids.size() << " xtals" << std::endl;
127  count += logic_ids.size();
128  i++;
129  }
130  std::cout << "Total no. of xtals for which data are stored: " << count << std::endl;
131  std::cout << "##################### LMF_CORR_COEF_DAT ########################" << std::endl;
132 }
int i
Definition: DBlmapReader.cc:9
std::map< int, LMFCorrCoefDatComponent * > m_data
tuple cout
Definition: gather_cfg.py:121
void LMFCorrCoefDat::fetch ( std::list< int >  subiov_ids)

Definition at line 243 of file LMFCorrCoefDat.cc.

References EnergyCorrector::c, gather_cfg::cout, alignCSCRings::e, i, and m_debug.

Referenced by fetch(), fetchBetween(), getFlag(), getParameterErrors(), getParameters(), getSeqID(), and getSequence().

243  {
244  std::list<int>::const_iterator i = subiov_ids.begin();
245  std::list<int>::const_iterator e = subiov_ids.end();
246  int c = 0;
247  while (i != e) {
248  if (m_debug) {
249  std::cout << "[LMFCorrCoefDat] Fetching data taken "
250  << "during LMR_SUB_IOV no. " << ++c << std::endl;
251  }
252  fetch(*i);
253  i++;
254  }
255  if (m_debug) {
256  std::cout << "[LMFCorrCoefDat] fetch done for all sub iovs"
257  << std::endl << std::flush;
258  }
259 }
int i
Definition: DBlmapReader.cc:9
void fetch(std::list< int > subiov_ids)
tuple cout
Definition: gather_cfg.py:121
void LMFCorrCoefDat::fetch ( int  subiov_id)

Definition at line 261 of file LMFCorrCoefDat.cc.

References gather_cfg::cout, LMFUnique::dump(), fetch(), LMFUnique::getID(), o2o::iov, m_conn, m_debug, m_env, m_subiov, and LMFUnique::setByID().

261  {
263  iov.setByID(subiov_id);
264  if (m_debug) {
265  std::cout << "[LMFCorrCoefDat] Looking for LMR_SUB_IOV with ID "
266  << iov.getID() << std::endl
267  << std::flush;
268  }
269  // create an instance of LMFLmrSubIOV to associate to this IOV_ID
270  LMFLmrSubIOV *subiov = new LMFLmrSubIOV(m_env, m_conn);
271  *subiov = iov;
272  m_subiov[subiov_id] = subiov;
273  if (m_debug) {
274  std::cout << "[LMFCorrCoefDat] Latest LMR_SUB_IOV data follows"
275  << std::endl;
276  subiov->dump();
277  std::cout << "[LMFCorrCoefDat] Fetching data taken "
278  << "during LMR_SUB_IOV ID " << subiov_id << std::endl
279  << std::flush;
280  }
281  fetch(iov);
282 }
std::map< int, LMFLmrSubIOV * > m_subiov
oracle::occi::Connection * m_conn
virtual void dump() const
Definition: LMFUnique.cc:112
void fetch(std::list< int > subiov_ids)
tuple iov
Definition: o2o.py:307
oracle::occi::Environment * m_env
tuple cout
Definition: gather_cfg.py:121
void LMFCorrCoefDat::fetch ( const LMFLmrSubIOV iov)

Definition at line 284 of file LMFCorrCoefDat.cc.

References AlCaHLTBitMon_QueryRunRegistry::comp, gather_cfg::cout, LMFUnique::debug(), LMFDat::dump(), LMFDat::fetch(), LMFUnique::getID(), m_conn, m_data, m_debug, m_env, and LMFCorrCoefDatComponent::setLMFLmrSubIOV().

285 {
286  // fetch data with given LMR_SUB_IOV_ID from the database
287  if (m_data.find(iov.getID()) == m_data.end()) {
288  if (m_debug) {
289  std::cout << " Data collected in LMR_SUB_IOV "
290  << iov.getID()
291  << " not found in private data. "
292  << "Getting it from DB " << std::endl
293  << std::flush;
294  }
296  if (m_debug) {
297  comp->debug();
298  }
299  // assign this IOV to comp to be able to retrieve it from the DB
300  comp->setLMFLmrSubIOV(iov);
301  comp->fetch();
302  if (m_debug) {
303  std::cout << "====== DEBUGGING: Data collected during this LMR_SUB_IOV"
304  << std::endl;
305  comp->dump();
306  std::cout << "====== DEBUGGING: ======================================"
307  << std::endl << std::endl;
308  }
309  m_data[iov.getID()] = comp;
310  } else if (m_debug) {
311  // this is not going to happen, but...
312  std::cout << " Data collected in LMR_SUB_IOV "
313  << iov.getID()
314  << " found in private data. "
315  << std::endl << std::flush;
316  }
317  if (m_debug) {
318  std::cout << "[LMFCorrCoefDat] Fetch done" << std::endl << std::endl << std::flush;
319  }
320 }
int getID() const
Definition: LMFUnique.h:52
oracle::occi::Connection * m_conn
void dump() const
Definition: LMFDat.cc:68
std::map< int, LMFCorrCoefDatComponent * > m_data
oracle::occi::Environment * m_env
tuple cout
Definition: gather_cfg.py:121
LMFCorrCoefDatComponent & setLMFLmrSubIOV(const LMFLmrSubIOV &iov)
void debug()
Definition: LMFUnique.h:68
void fetch()
Definition: LMFDat.cc:237
void LMFCorrCoefDat::fetchAfter ( const Tm t)

Definition at line 200 of file LMFCorrCoefDat.cc.

References fetchBetween(), Tm::setToString(), and tmax.

200  {
201  Tm tmax;
202  tmax.setToString("9999-12-31 23:59:59");
203  fetchBetween(t, tmax, 0);
204 }
void fetchBetween(const Tm &tmin, const Tm &tmax)
void setToString(const std::string s)
Definition: Tm.cc:193
static const double tmax[3]
Definition: Tm.h:13
void LMFCorrCoefDat::fetchAfter ( const Tm t,
int  howMany 
)

Definition at line 206 of file LMFCorrCoefDat.cc.

References fetchBetween(), Tm::setToString(), and tmax.

206  {
207  Tm tmax;
208  tmax.setToString("9999-12-31 23:59:59");
209  fetchBetween(t, tmax, howmany);
210 }
void fetchBetween(const Tm &tmin, const Tm &tmax)
void setToString(const std::string s)
Definition: Tm.cc:193
static const double tmax[3]
Definition: Tm.h:13
void LMFCorrCoefDat::fetchBetween ( const Tm tmin,
const Tm tmax 
)

Definition at line 212 of file LMFCorrCoefDat.cc.

Referenced by fetchAfter().

212  {
213  fetchBetween(tmin, tmax, 0);
214 }
void fetchBetween(const Tm &tmin, const Tm &tmax)
void LMFCorrCoefDat::fetchBetween ( const Tm tmin,
const Tm tmax,
int  maxNumberOfIOVs 
)

Definition at line 216 of file LMFCorrCoefDat.cc.

References gather_cfg::cout, LMFUnique::debug(), fetch(), LMFLmrSubIOV::getIOVIDsLaterThan(), o2o::iov, prof2calltree::l, m_conn, m_data, m_debug, m_env, Tm::setToString(), and Tm::str().

217  {
219  Tm tinf;
220  tinf.setToString("9999-12-31 23:59:59");
221  if (m_debug) {
222  std::cout << "Searching for data collected after " << tmin.str();
223  if (tmax != tinf) {
224  std::cout << " and before " << tmax.str();
225  }
226  std::cout << ". Retrieving the first "
227  << maxNumberOfIOVs << " records" << std::endl;
228  iov.debug();
229  }
230  std::list<int> l = iov.getIOVIDsLaterThan(tmin, tmax, maxNumberOfIOVs);
231  if (m_debug) {
232  std::cout << "Now we are going to fetch details about "
233  << "data collected within the above mentioned "
234  << "LMR_SUB_IOV's" << std::endl;
235  }
236  fetch(l);
237  if (m_debug) {
238  std::cout << "Fetched a list of " << m_data.size() << " IOVs"
239  << std::endl << std::flush;
240  }
241 }
oracle::occi::Connection * m_conn
void fetch(std::list< int > subiov_ids)
tuple iov
Definition: o2o.py:307
std::map< int, LMFCorrCoefDatComponent * > m_data
void setToString(const std::string s)
Definition: Tm.cc:193
oracle::occi::Environment * m_env
std::string str() const
Definition: Tm.cc:89
tuple cout
Definition: gather_cfg.py:121
Definition: Tm.h:13
RunIOV LMFCorrCoefDat::fetchLastInsertedRun ( )

Definition at line 155 of file LMFCorrCoefDat.cc.

References gather_cfg::cout, alignCSCRings::e, o2o::iov, m_conn, m_debug, m_env, NULL, RunIOV::setByID(), IDBObject::setConnection(), and AlCaHLTBitMon_QueryRunRegistry::string.

155  {
156  RunIOV iov;
157  if (m_conn == NULL) {
158  throw std::runtime_error("[LMFCorrCoefDat::fetchLastInsertedRun] ERROR: "
159  "Connection not set");
160  }
161  iov.setConnection(m_env, m_conn);
162  std::string sql = "SELECT IOV_ID FROM CMS_ECAL_COND.RUN_IOV WHERE "
163  "IOV_ID = (SELECT RUN_IOV_ID FROM LMF_SEQ_DAT WHERE SEQ_ID = "
164  "(SELECT MAX(SEQ_ID) FROM LMF_CORR_COEF_DAT))";
165  oracle::occi::Statement * stmt;
166  try {
167  stmt = m_conn->createStatement();
168  stmt->setSQL(sql);
169  }
170  catch (oracle::occi::SQLException &e) {
171  throw(std::runtime_error("[LMFCorrCoefDat::fetchLastInsertedRun]: " +
172  e.getMessage()));
173  }
174  if (m_debug) {
175  std::cout << "[LMFCorrCoefDat::fetchLastInsertedRun] executing query"
176  << std::endl << sql << std::endl << std::flush;
177  }
178  oracle::occi::ResultSet *rset = stmt->executeQuery();
179  if (m_debug) {
180  std::cout << " done"
181  << std::endl << std::flush;
182  }
183  int iov_id = -1;
184  try {
185  while (rset->next()) {
186  // there should be just one result
187  iov_id = rset->getInt(1);
188  }
189  }
190  catch (oracle::occi::SQLException &e) {
191  throw(std::runtime_error("[LMFCorrCoefDat::fetchLastInsertedRun]: " +
192  e.getMessage()));
193  }
194  if (iov_id > 0) {
195  iov.setByID(iov_id);
196  }
197  return iov;
198 }
void setByID(int id)
Definition: RunIOV.cc:152
#define NULL
Definition: scimark2.h:8
oracle::occi::Connection * m_conn
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
tuple iov
Definition: o2o.py:307
oracle::occi::Environment * m_env
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
tuple cout
Definition: gather_cfg.py:121
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
Definition: RunIOV.h:13
LMFCorrCoefDatComponent * LMFCorrCoefDat::find ( const LMFLmrSubIOV iov)
private

Definition at line 98 of file LMFCorrCoefDat.cc.

References EnergyCorrector::c, LMFUnique::getID(), o2o::iov, m_conn, m_data, m_env, m_subiov, NULL, IDBObject::setConnection(), and LMFCorrCoefDatComponent::setLMFLmrSubIOV().

Referenced by setFlag(), setP123(), setP123Errors(), and setSequence().

98  {
99  if (m_data.find(iov.getID()) != m_data.end()) {
100  return m_data[iov.getID()];
101  } else {
103  LMFLmrSubIOV *subiov = new LMFLmrSubIOV();
104  if (m_conn != NULL) {
106  subiov->setConnection(m_env, m_conn);
107  }
108  *subiov = iov;
109  c->setLMFLmrSubIOV(*subiov);
110  m_data[subiov->getID()] = c;
111  m_subiov[subiov->getID()] = subiov;
112  return c;
113  }
114 }
std::map< int, LMFLmrSubIOV * > m_subiov
int getID() const
Definition: LMFUnique.h:52
#define NULL
Definition: scimark2.h:8
oracle::occi::Connection * m_conn
tuple iov
Definition: o2o.py:307
std::map< int, LMFCorrCoefDatComponent * > m_data
oracle::occi::Environment * m_env
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
LMFCorrCoefDatComponent & setLMFLmrSubIOV(const LMFLmrSubIOV &iov)
std::map< int, std::map< int, LMFSextuple > > LMFCorrCoefDat::getCorrections ( const Tm t)

Definition at line 327 of file LMFCorrCoefDat.cc.

References MAX_NUMBER_OF_SEQUENCES_TO_FETCH.

Referenced by getCorrections(), and popcon::EcalLaserHandler::getNewObjects().

327  {
329 }
std::map< int, std::map< int, LMFSextuple > > getCorrections(const Tm &t)
static const int MAX_NUMBER_OF_SEQUENCES_TO_FETCH
std::map< int, std::map< int, LMFSextuple > > LMFCorrCoefDat::getCorrections ( const Tm t,
int  max 
)

Definition at line 356 of file LMFCorrCoefDat.cc.

References getCorrections().

356  {
357  return getCorrections(t, Tm().plusInfinity(), max);
358 }
std::map< int, std::map< int, LMFSextuple > > getCorrections(const Tm &t)
Definition: Tm.h:13
std::map< int, std::map< int, LMFSextuple > > LMFCorrCoefDat::getCorrections ( const Tm t,
const Tm t2,
int  max 
)

Definition at line 361 of file LMFCorrCoefDat.cc.

References EnergyCorrector::c, checkTriplets(), gather_cfg::cout, ztail::d, DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, i, m_conn, m_debug, m_env, MAX_NUMBER_OF_SEQUENCES_TO_FETCH, NULL, LMFSextuple::p, run_regression::ret, alignCSCRings::s, Tm::str(), AlCaHLTBitMon_QueryRunRegistry::string, and LMFSextuple::t.

361  {
362  // returns a map whose key is the sequence_id and whose value is another
363  // map. The latter has the logic_id of a crystal as key and the corresponding
364  // sextuple p1, p2, p3, t1, t2, t3 as value.
365  // Crystal corrections, then, are organized by sequences
366  // First of all, checks that the connection is active (TODO)
367  //
368  // For fixed-time IOV's sequence ID's are always 0. In that case
369  // use the LMR_SUB_IOV_ID as a key
370  if (m_conn == NULL) {
371  throw std::runtime_error("[LMFCorrCoefDat::getCorrections] ERROR: "
372  "Connection not set");
373  }
374  // limit the maximum number of rows to fetch
376  if (m_debug) {
377  std::cout << " Required to fetch " << max << " sequences from OMDS. "
378  << MAX_NUMBER_OF_SEQUENCES_TO_FETCH << " allowed"
379  << std::endl;
380  }
382  }
383  // we must define some criteria to select the right rows
384  std::map<int, std::map<int, LMFSextuple> > ret;
385  std::string sql = "SELECT * FROM (SELECT LOGIC_ID, T1, T2, T3, P1, P2, P3, "
386  "SEQ_ID, D.LMR_SUB_IOV_ID FROM LMF_LMR_SUB_IOV JOIN LMF_CORR_COEF_DAT D ON "
387  "D.LMR_SUB_IOV_ID = LMF_LMR_SUB_IOV.LMR_SUB_IOV_ID "
388  "WHERE T1 > TO_DATE(:1, 'YYYY-MM-DD HH24:MI:SS') AND "
389  "T1 <= TO_DATE(:2, 'YYYY-MM-DD HH24:MI:SS') ORDER BY T1) WHERE ROWNUM <= :3";
390  try {
392  const int PREFETCH = 10000;
393  oracle::occi::Statement * stmt = m_conn->createStatement();
394  stmt->setSQL(sql);
395  int toFetch = (max * (61200 + 14648));
396  stmt->setString(1, t.str());
397  stmt->setString(2, t2.str());
398  stmt->setInt(3, toFetch);
399  stmt->setPrefetchRowCount(PREFETCH);
400  if (m_debug) {
401  std::cout << "[LMFCorrCoefDat::getCorrections] executing query"
402  << std::endl << sql << std::endl
403  << "Parameters 1 = " << t.str() << " 2 = "
404  << t2.str() << " 3 = " << toFetch << std::endl
405  << "Prefetching " << PREFETCH << " rows "
406  << std::endl << std::flush;
407  }
408  oracle::occi::ResultSet *rset = stmt->executeQuery();
409  if (m_debug) {
410  std::cout << " done"
411  << std::endl << std::flush;
412  }
413  int c = 0;
414  std::map<int, LMFSextuple> theMap;
415  int lastSeqId = 0;
416  int previousSeqId = 0;
417  int startingSeqId = -1; // this variable contains the very first SEQ_ID
418  LMFSextuple s;
419  bool proceed = true;
420  while (rset->next()) {
421  int logic_id = rset->getInt(1);
422  int seq_id = rset->getInt(8);
423  if (startingSeqId < 0) {
424  startingSeqId = seq_id;
425  }
426  if ((seq_id == 0) && (startingSeqId == 0)) {
427  // check if we are in fixed-time IOV mode or not.
428  // In any case do not mix the modes.
429  if (c == 0) {
430  std::cout << "[LMFCorrCoefDat::getCorrections] Using fixed-time IOV"
431  << std::endl;
432  }
433  seq_id = rset->getInt(9); // for fixed-time intervals use LMR_SUB_IOV_ID
434  } else if ((startingSeqId == 0) && (proceed = true)) {
435  std::cout << "[LMFCorrCoefDat::getCorrections] Switch to normal (sequence based) mode. "
436  << "Exiting..." << std::endl;
437  proceed = false;
438  } else if ((seq_id == 0) && (proceed = true)) {
439  std::cout << "[LMFCorrCoefDat::getCorrections] Switch to fixed-time IOV mode. "
440  << "Exiting..." << std::endl;
441  proceed = false;
442  }
443  if (proceed) {
444  if (seq_id != lastSeqId) {
445  if (m_debug) {
446  if (lastSeqId != 0) {
447  std::cout << " Triplets in sequences: " << c
448  << std::endl;
449  std::cout << " T1: " << s.t[0].str() << " T2: " << s.t[1].str()
450  << " T3: " << s.t[2].str() << std::endl;
451  }
452  c = 0;
453  std::cout << " Found new sequence: " << seq_id
454  << std::endl;
455  }
456  // the triplet of dates is equal for all rows in a sequence:
457  // get them once
458  for (int i = 0; i < 3; i++) {
459  oracle::occi::Date d = rset->getDate(i + 2);
460  s.t[i] = dh.dateToTm(d);
461  }
462  if (lastSeqId > 0) {
463  ret[lastSeqId] = theMap;
464  }
465  theMap.clear();
466  previousSeqId = lastSeqId;
467  lastSeqId = seq_id;
468  }
469  for (int i = 0; i <3; i++) {
470  s.p[i] = rset->getDouble(i + 5);
471  }
472  theMap[logic_id] = s;
473  // verify that the sequence of time is correct
474  if (ret.size() > 0) {
475  checkTriplets(logic_id, s, ret[previousSeqId]);
476  }
477  c++;
478  }
479  }
480  // insert the last map in the outer map
481  ret[lastSeqId] = theMap;
482  if (m_debug) {
483  std::cout << " Triplets in sequences: " << c
484  << std::endl;
485  std::cout << " T1: " << s.t[0].str() << " T2: " << s.t[1].str()
486  << " T3: " << s.t[2].str() << std::endl;
487  std::cout << std::endl;
488  }
489  }
490  catch (oracle::occi::SQLException &e) {
491  throw(std::runtime_error("LMFCorrCoefDat::getCorrections: " +
492  e.getMessage()));
493  }
494  if (m_debug) {
495  std::cout << "[LMFCorrCoefDat::getCorrections] Map built" << std::endl
496  << " Contains " << ret.size()
497  << " sequences. These are the size of all sequences"
498  << std::endl;
499  std::map<int, std::map<int, LMFSextuple> >::const_iterator i = ret.begin();
500  std::map<int, std::map<int, LMFSextuple> >::const_iterator e = ret.end();
501  while (i != e) {
502  std::cout << " SEQ " << i->first
503  << " Size " << i->second.size() << std::endl;
504  i++;
505  }
506  }
507  return ret;
508 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
oracle::occi::Connection * m_conn
static const int MAX_NUMBER_OF_SEQUENCES_TO_FETCH
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
float p[3]
Definition: LMFSextuple.h:19
tuple d
Definition: ztail.py:151
oracle::occi::Environment * m_env
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void checkTriplets(int logic_id, const LMFSextuple &s, const std::map< int, LMFSextuple > &lastMap)
std::string str() const
Definition: Tm.cc:89
tuple cout
Definition: gather_cfg.py:121
tuple dh
Definition: cuy.py:353
int LMFCorrCoefDat::getFlag ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 567 of file LMFCorrCoefDat.cc.

References fetch(), LMFUnique::getID(), m_data, edm::second(), and x.

568  {
569  int x = -1;
570  fetch(iov);
571  if (m_data.find(iov.getID()) != m_data.end()) {
572  x = (m_data.find(iov.getID())->second)->getFlag(id);
573  }
574  return x;
575 }
int getID() const
Definition: LMFUnique.h:52
void fetch(std::list< int > subiov_ids)
U second(std::pair< T, U > const &p)
std::map< int, LMFCorrCoefDatComponent * > m_data
std::vector< float > LMFCorrCoefDat::getParameterErrors ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 555 of file LMFCorrCoefDat.cc.

References fetch(), LMFUnique::getID(), relval_steps::key, m_data, and x.

557 {
558  std::vector<float> x;
559  int key = iov.getID();
560  fetch(iov);
561  if (m_data.find(key) != m_data.end()) {
562  x = (m_data.find(key)->second)->getParameterErrors(id);
563  }
564  return x;
565 }
int getID() const
Definition: LMFUnique.h:52
std::vector< float > getParameterErrors(const LMFLmrSubIOV &iov, const EcalLogicID &id)
void fetch(std::list< int > subiov_ids)
std::map< int, LMFCorrCoefDatComponent * > m_data
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::list< std::vector< float > > LMFCorrCoefDat::getParameters ( int  id)

Definition at line 516 of file LMFCorrCoefDat.cc.

References alignCSCRings::e, spr::find(), i, relval_steps::k, m_data, m_subiov, AlCaHLTBitMon_ParallelJobs::p, and run_regression::ret.

Referenced by getParameters().

516  {
517  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
518  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
519  std::list<std::vector<float> > ret;
520  while (i != e) {
521  std::list<int> logic_ids = i->second->getLogicIds();
522  std::list<int>::iterator p =
523  std::find(logic_ids.begin(), logic_ids.end(), id);
524  if (p != logic_ids.end()) {
525  // the given logic id is contained in at least an element of this map
526  std::vector<float> ppar;
527  std::vector<Tm> tpar;
528  // get P1, P2, P3 and T1, T2, T3
529  i->second->getData(id, ppar);
530  tpar = m_subiov[i->first]->getTimes();
531  // construct the resulting pair of triplets
532  std::vector<float> par(6);
533  for (int k = 0; k < 3; k++) {
534  par[k + 3] = ppar[k];
535  par[k] = tpar[k].microsTime();
536  }
537  ret.push_back(par);
538  }
539  i++;
540  }
541  return ret;
542 }
std::map< int, LMFLmrSubIOV * > m_subiov
int i
Definition: DBlmapReader.cc:9
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::map< int, LMFCorrCoefDatComponent * > m_data
std::list< std::vector< float > > LMFCorrCoefDat::getParameters ( const EcalLogicID id)

Definition at line 510 of file LMFCorrCoefDat.cc.

References getParameters().

511  {
512  return getParameters(id.getLogicID());
513 }
std::list< std::vector< float > > getParameters(int id)
std::vector< float > LMFCorrCoefDat::getParameters ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 544 of file LMFCorrCoefDat.cc.

References fetch(), LMFUnique::getID(), getParameters(), relval_steps::key, m_data, and x.

545  {
546  std::vector<float> x(3);
547  int key = iov.getID();
548  fetch(iov);
549  if (m_data.find(key) != m_data.end()) {
550  x = (m_data.find(key)->second)->getParameters(id);
551  }
552  return x;
553 }
int getID() const
Definition: LMFUnique.h:52
std::list< std::vector< float > > getParameters(int id)
void fetch(std::list< int > subiov_ids)
std::map< int, LMFCorrCoefDatComponent * > m_data
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
int LMFCorrCoefDat::getSeqID ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 577 of file LMFCorrCoefDat.cc.

References fetch(), LMFUnique::getID(), m_data, edm::second(), and x.

578  {
579  int x = -1;
580  fetch(iov);
581  if (m_data.find(iov.getID()) != m_data.end()) {
582  x = (m_data.find(iov.getID())->second)->getSeqID(id);
583  }
584  return x;
585 }
int getID() const
Definition: LMFUnique.h:52
void fetch(std::list< int > subiov_ids)
U second(std::pair< T, U > const &p)
std::map< int, LMFCorrCoefDatComponent * > m_data
LMFSeqDat LMFCorrCoefDat::getSequence ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 587 of file LMFCorrCoefDat.cc.

References fetch(), LMFUnique::getID(), m_conn, m_data, m_env, and edm::second().

588  {
589  LMFSeqDat seq(m_env, m_conn);
590  fetch(iov);
591  if (m_data.find(iov.getID()) != m_data.end()) {
592  seq = (m_data.find(iov.getID())->second)->getSequence(id);
593  }
594  return seq;
595 }
int getID() const
Definition: LMFUnique.h:52
oracle::occi::Connection * m_conn
void fetch(std::list< int > subiov_ids)
U second(std::pair< T, U > const &p)
std::map< int, LMFCorrCoefDatComponent * > m_data
oracle::occi::Environment * m_env
std::list< int > LMFCorrCoefDat::getSubIOVIDs ( )

Definition at line 608 of file LMFCorrCoefDat.cc.

References alignCSCRings::e, i, m_data, and run_regression::ret.

608  {
609  std::list<int> ret;
610  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
611  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
612  while (i != e) {
613  ret.push_back(i->first);
614  i++;
615  }
616  return ret;
617 }
int i
Definition: DBlmapReader.cc:9
std::map< int, LMFCorrCoefDatComponent * > m_data
std::vector< Tm > LMFCorrCoefDat::getTimes ( const LMFLmrSubIOV iov)

Definition at line 322 of file LMFCorrCoefDat.cc.

References LMFLmrSubIOV::getTimes().

322  {
323  return iov.getTimes();
324 }
void getTimes(Tm *t1, Tm *t2, Tm *t3) const
Definition: LMFLmrSubIOV.h:37
void LMFCorrCoefDat::init ( void  )

Definition at line 38 of file LMFCorrCoefDat.cc.

References m_conn, m_data, m_env, m_subiov, nodebug(), and NULL.

Referenced by LMFCorrCoefDat().

38  {
39  m_data.clear();
40  m_subiov.clear();
41  m_env = NULL;
42  m_conn = NULL;
43  nodebug();
44 }
std::map< int, LMFLmrSubIOV * > m_subiov
#define NULL
Definition: scimark2.h:8
oracle::occi::Connection * m_conn
std::map< int, LMFCorrCoefDatComponent * > m_data
oracle::occi::Environment * m_env
void LMFCorrCoefDat::nodebug ( )

Definition at line 151 of file LMFCorrCoefDat.cc.

References m_debug.

Referenced by init().

151  {
152  m_debug = false;
153 }
LMFCorrCoefDat & LMFCorrCoefDat::setConnection ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

Definition at line 46 of file LMFCorrCoefDat.cc.

References results_mgr::conn, alignCSCRings::e, web.browse_db::env, i, m_conn, m_data, and m_env.

47  {
48  m_env = env;
49  m_conn = conn;
50  std::map<int, LMFCorrCoefDatComponent*>::iterator i = m_data.begin();
51  std::map<int, LMFCorrCoefDatComponent*>::iterator e = m_data.end();
52  while (i != e) {
53  i->second->setConnection(m_env, m_conn);
54  i++;
55  }
56  return *this;
57 }
int i
Definition: DBlmapReader.cc:9
oracle::occi::Connection * m_conn
std::map< int, LMFCorrCoefDatComponent * > m_data
oracle::occi::Environment * m_env
tuple conn
Definition: results_mgr.py:53
LMFCorrCoefDat & LMFCorrCoefDat::setFlag ( const LMFLmrSubIOV iov,
const EcalLogicID id,
int  flag 
)

Definition at line 79 of file LMFCorrCoefDat.cc.

References find(), and LMFCorrCoefDatComponent::setFlag().

80  {
81  find(iov)->setFlag(id, flag);
82  return *this;
83 }
LMFCorrCoefDatComponent & setFlag(const EcalLogicID &id, int flag)
LMFCorrCoefDatComponent * find(const LMFLmrSubIOV &iov)
LMFCorrCoefDat & LMFCorrCoefDat::setP123 ( const LMFLmrSubIOV iov,
const EcalLogicID id,
float  p1,
float  p2,
float  p3 
)

Definition at line 59 of file LMFCorrCoefDat.cc.

References find(), and LMFCorrCoefDatComponent::setP123().

60  {
61  find(iov)->setP123(id, p1, p2, p3);
62  return *this;
63 }
double p2[4]
Definition: TauolaWrapper.h:90
LMFCorrCoefDatComponent & setP123(const EcalLogicID &id, float p1, float p2, float p3)
double p1[4]
Definition: TauolaWrapper.h:89
LMFCorrCoefDatComponent * find(const LMFLmrSubIOV &iov)
double p3[4]
Definition: TauolaWrapper.h:91
LMFCorrCoefDat & LMFCorrCoefDat::setP123 ( const LMFLmrSubIOV iov,
const EcalLogicID id,
float  p1,
float  p2,
float  p3,
float  p1e,
float  p2e,
float  p3e 
)

Definition at line 65 of file LMFCorrCoefDat.cc.

References find(), and LMFCorrCoefDatComponent::setP123().

67  {
68  find(iov)->setP123(id, p1, p2, p3, p1e, p2e, p3e);
69  return *this;
70 }
double p2[4]
Definition: TauolaWrapper.h:90
LMFCorrCoefDatComponent & setP123(const EcalLogicID &id, float p1, float p2, float p3)
double p1[4]
Definition: TauolaWrapper.h:89
LMFCorrCoefDatComponent * find(const LMFLmrSubIOV &iov)
double p3[4]
Definition: TauolaWrapper.h:91
LMFCorrCoefDat & LMFCorrCoefDat::setP123Errors ( const LMFLmrSubIOV iov,
const EcalLogicID id,
float  p1e,
float  p2e,
float  p3e 
)

Definition at line 72 of file LMFCorrCoefDat.cc.

References find(), and LMFCorrCoefDatComponent::setP123Errors().

74  {
75  find(iov)->setP123Errors(id, p1e, p2e, p3e);
76  return *this;
77 }
LMFCorrCoefDatComponent & setP123Errors(const EcalLogicID &id, float p1e, float p2e, float p3e)
LMFCorrCoefDatComponent * find(const LMFLmrSubIOV &iov)
LMFCorrCoefDat & LMFCorrCoefDat::setSequence ( const LMFLmrSubIOV iov,
const EcalLogicID id,
int  seq_id 
)

Definition at line 85 of file LMFCorrCoefDat.cc.

References find(), and LMFCorrCoefDatComponent::setSequence().

86  {
87  find(iov)->setSequence(id, seq_id);
88  return *this;
89 }
LMFCorrCoefDatComponent & setSequence(const EcalLogicID &id, int seq_id)
LMFCorrCoefDatComponent * find(const LMFLmrSubIOV &iov)
LMFCorrCoefDat & LMFCorrCoefDat::setSequence ( const LMFLmrSubIOV iov,
const EcalLogicID id,
const LMFSeqDat seq 
)

Definition at line 91 of file LMFCorrCoefDat.cc.

References find(), and LMFCorrCoefDatComponent::setSequence().

93  {
94  find(iov)->setSequence(id, seq);
95  return *this;
96 }
LMFCorrCoefDatComponent & setSequence(const EcalLogicID &id, int seq_id)
LMFCorrCoefDatComponent * find(const LMFLmrSubIOV &iov)
int LMFCorrCoefDat::size ( void  ) const

Definition at line 597 of file LMFCorrCoefDat.cc.

References EnergyCorrector::c, alignCSCRings::e, i, and m_data.

597  {
598  int c = 0;
599  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
600  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
601  while (i != e) {
602  c += i->second->size();
603  i++;
604  }
605  return c;
606 }
int i
Definition: DBlmapReader.cc:9
std::map< int, LMFCorrCoefDatComponent * > m_data
void LMFCorrCoefDat::writeDB ( )

Definition at line 134 of file LMFCorrCoefDat.cc.

References gather_cfg::cout, alignCSCRings::e, i, m_data, and m_debug.

134  {
135  std::map<int, LMFCorrCoefDatComponent*>::iterator i = m_data.begin();
136  std::map<int, LMFCorrCoefDatComponent*>::iterator e = m_data.end();
137  while (i != e) {
138  if (m_debug) {
139  std::cout << "Writing data for LMR_SUB_IOV_ID " << i->first << std::endl;
140  }
141  i->second->writeDB();
142  i++;
143  }
144 }
int i
Definition: DBlmapReader.cc:9
std::map< int, LMFCorrCoefDatComponent * > m_data
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

oracle::occi::Connection* LMFCorrCoefDat::m_conn
private
std::map<int, LMFCorrCoefDatComponent *> LMFCorrCoefDat::m_data
private
bool LMFCorrCoefDat::m_debug
private
oracle::occi::Environment* LMFCorrCoefDat::m_env
private
std::map<int, LMFLmrSubIOV *> LMFCorrCoefDat::m_subiov
private

Definition at line 79 of file LMFCorrCoefDat.h.

Referenced by fetch(), find(), getParameters(), init(), and ~LMFCorrCoefDat().

const int LMFCorrCoefDat::MAX_NUMBER_OF_SEQUENCES_TO_FETCH = 32
staticprivate

Definition at line 76 of file LMFCorrCoefDat.h.

Referenced by getCorrections().