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 = 8
 

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 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
LMFCorrCoefDat::~LMFCorrCoefDat ( )

Definition at line 21 of file LMFCorrCoefDat.cc.

References 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.

References gather_cfg::cout.

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  std::cout << ":-( Can't find crystal " << logic_id << " in last map"
349  << std::endl;
350  }
351 }
tuple cout
Definition: gather_cfg.py:41
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:41
void LMFCorrCoefDat::dump ( void  )

Definition at line 116 of file LMFCorrCoefDat.cc.

References prof2calltree::count, gather_cfg::cout, 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:41
void LMFCorrCoefDat::fetch ( std::list< int >  subiov_ids)

Definition at line 243 of file LMFCorrCoefDat.cc.

References trackerHits::c, gather_cfg::cout, 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:41
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:106
void fetch(std::list< int > subiov_ids)
tuple iov
Definition: o2o.py:307
oracle::occi::Environment * m_env
tuple cout
Definition: gather_cfg.py:41
void LMFCorrCoefDat::fetch ( const LMFLmrSubIOV iov)

Definition at line 284 of file LMFCorrCoefDat.cc.

References 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:51
oracle::occi::Connection * m_conn
void dump() const
Definition: LMFDat.cc:62
std::map< int, LMFCorrCoefDatComponent * > m_data
oracle::occi::Environment * m_env
tuple cout
Definition: gather_cfg.py:41
LMFCorrCoefDatComponent & setLMFLmrSubIOV(const LMFLmrSubIOV &iov)
void debug()
Definition: LMFUnique.h:67
void fetch()
Definition: LMFDat.cc:206
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:172
static const double tmax[3]
Definition: Tm.h:14
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:172
static const double tmax[3]
Definition: Tm.h:14
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:172
oracle::occi::Environment * m_env
std::string str() const
Definition: Tm.cc:82
tuple cout
Definition: gather_cfg.py:41
Definition: Tm.h:14
RunIOV LMFCorrCoefDat::fetchLastInsertedRun ( )

Definition at line 155 of file LMFCorrCoefDat.cc.

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

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:22
tuple iov
Definition: o2o.py:307
oracle::occi::Environment * m_env
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
tuple cout
Definition: gather_cfg.py:41
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 trackerHits::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:51
#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 354 of file LMFCorrCoefDat.cc.

References getCorrections().

354  {
355  return getCorrections(t, Tm().plusInfinity(), max);
356 }
std::map< int, std::map< int, LMFSextuple > > getCorrections(const Tm &t)
const T & max(const T &a, const T &b)
Definition: Tm.h:14
std::map< int, std::map< int, LMFSextuple > > LMFCorrCoefDat::getCorrections ( const Tm t,
const Tm t2,
int  max 
)

Definition at line 359 of file LMFCorrCoefDat.cc.

References trackerHits::c, checkTriplets(), gather_cfg::cout, DateHandler::dateToTm(), i, m_conn, m_debug, m_env, MAX_NUMBER_OF_SEQUENCES_TO_FETCH, NULL, LMFSextuple::p, runTheMatrix::ret, asciidump::s, Tm::str(), LMFSextuple::t, and DateHandler::tmToDate().

359  {
360  // returns a map whose key is the sequence_id and whose value is another
361  // map. The latter has the logic_id of a crystal as key and the corresponding
362  // sextuple p1, p2, p3, t1, t2, t3 as value.
363  // Crystal corrections, then, are organized by sequences
364  // First of all, checks that the connection is active (TODO)
365  if (m_conn == NULL) {
366  throw std::runtime_error("[LMFCorrCoefDat::getCorrections] ERROR: "
367  "Connection not set");
368  }
369  // limit the maximum number of rows to fetch
371  if (m_debug) {
372  std::cout << " Required to fetch " << max << " sequences from OMDS. "
373  << MAX_NUMBER_OF_SEQUENCES_TO_FETCH << " allowed"
374  << std::endl;
375  }
377  }
378  // we must define some criteria to select the right rows
379  std::map<int, std::map<int, LMFSextuple> > ret;
380  std::string sql = "SELECT * FROM (SELECT LOGIC_ID, T1, T2, T3, P1, P2, P3, "
381  "SEQ_ID FROM LMF_LMR_SUB_IOV JOIN LMF_CORR_COEF_DAT ON "
382  "LMF_CORR_COEF_DAT.LMR_SUB_IOV_ID = LMF_LMR_SUB_IOV.LMR_SUB_IOV_ID "
383  "WHERE T1 > :1 AND T1 <= :2 ORDER BY T1) WHERE ROWNUM <= :3";
384  try {
385  DateHandler dh(m_env, m_conn);
386  oracle::occi::Statement * stmt = m_conn->createStatement();
387  stmt->setSQL(sql);
388  int toFetch = max * (61200 + 14648);
389  stmt->setDate(1, dh.tmToDate(t));
390  stmt->setDate(2, dh.tmToDate(t2));
391  stmt->setInt(3, toFetch);
392  stmt->setPrefetchRowCount(toFetch);
393  if (m_debug) {
394  std::cout << "[LMFCorrCoefDat::getCorrections] executing query"
395  << std::endl << sql << std::endl
396  << "Prefetching " << toFetch << " rows "
397  << std::endl << std::flush;
398  }
399  oracle::occi::ResultSet *rset = stmt->executeQuery();
400  if (m_debug) {
401  std::cout << " done"
402  << std::endl << std::flush;
403  }
404  int c = 0;
405  std::map<int, LMFSextuple> theMap;
406  int lastSeqId = 0;
407  int previousSeqId = 0;
408  LMFSextuple s;
409  while (rset->next()) {
410  int logic_id = rset->getInt(1);
411  int seq_id = rset->getInt(8);
412  if (seq_id != lastSeqId) {
413  if (m_debug) {
414  if (lastSeqId != 0) {
415  std::cout << " Triplets in sequences: " << c
416  << std::endl;
417  std::cout << " T1: " << s.t[0].str() << " T2: " << s.t[1].str()
418  << " T3: " << s.t[2].str() << std::endl;
419  }
420  c = 0;
421  std::cout << " Found new sequence: " << seq_id
422  << std::endl;
423  }
424  // the triplet of dates is equal for all rows in a sequence:
425  // get them once
426  for (int i = 0; i < 3; i++) {
427  oracle::occi::Date d = rset->getDate(i + 2);
428  s.t[i] = dh.dateToTm(d);
429  }
430  if (lastSeqId > 0) {
431  ret[lastSeqId] = theMap;
432  }
433  theMap.clear();
434  previousSeqId = lastSeqId;
435  lastSeqId = seq_id;
436  }
437  for (int i = 0; i <3; i++) {
438  s.p[i] = rset->getDouble(i + 5);
439  }
440  theMap[logic_id] = s;
441  // verify that the sequence of time is correct
442  if (ret.size() > 0) {
443  checkTriplets(logic_id, s, ret[previousSeqId]);
444  }
445  c++;
446  }
447  // insert the last map in the outer map
448  ret[lastSeqId] = theMap;
449  if (m_debug) {
450  std::cout << " Triplets in sequences: " << c
451  << std::endl;
452  std::cout << " T1: " << s.t[0].str() << " T2: " << s.t[1].str()
453  << " T3: " << s.t[2].str() << std::endl;
454  std::cout << std::endl;
455  }
456  }
457  catch (oracle::occi::SQLException &e) {
458  throw(std::runtime_error("LMFCorrCoefDat::getCorrections: " +
459  e.getMessage()));
460  }
461  if (m_debug) {
462  std::cout << "[LMFCorrCoefDat::getCorrections] Map built" << std::endl
463  << " Contains " << ret.size()
464  << " sequences. These are the size of all sequences"
465  << std::endl;
466  std::map<int, std::map<int, LMFSextuple> >::const_iterator i = ret.begin();
467  std::map<int, std::map<int, LMFSextuple> >::const_iterator e = ret.end();
468  while (i != e) {
469  std::cout << " SEQ " << i->first
470  << " Size " << i->second.size() << std::endl;
471  i++;
472  }
473  }
474  return ret;
475 }
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:22
float p[3]
Definition: LMFSextuple.h:14
const T & max(const T &a, const T &b)
oracle::occi::Environment * m_env
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void checkTriplets(int logic_id, const LMFSextuple &s, const std::map< int, LMFSextuple > &lastMap)
std::string str() const
Definition: Tm.cc:82
tuple cout
Definition: gather_cfg.py:41
string s
Definition: asciidump.py:422
int LMFCorrCoefDat::getFlag ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 534 of file LMFCorrCoefDat.cc.

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

535  {
536  int x = -1;
537  fetch(iov);
538  if (m_data.find(iov.getID()) != m_data.end()) {
539  x = (m_data.find(iov.getID())->second)->getFlag(id);
540  }
541  return x;
542 }
int getID() const
Definition: LMFUnique.h:51
void fetch(std::list< int > subiov_ids)
U second(std::pair< T, U > const &p)
std::map< int, LMFCorrCoefDatComponent * > m_data
Definition: DDAxes.h:10
std::vector< float > LMFCorrCoefDat::getParameterErrors ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 522 of file LMFCorrCoefDat.cc.

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

524 {
525  std::vector<float> x;
526  int key = iov.getID();
527  fetch(iov);
528  if (m_data.find(key) != m_data.end()) {
529  x = (m_data.find(key)->second)->getParameterErrors(id);
530  }
531  return x;
532 }
int getID() const
Definition: LMFUnique.h:51
std::vector< float > getParameterErrors(const LMFLmrSubIOV &iov, const EcalLogicID &id)
void fetch(std::list< int > subiov_ids)
std::map< int, LMFCorrCoefDatComponent * > m_data
list key
Definition: combine.py:13
Definition: DDAxes.h:10
std::list< std::vector< float > > LMFCorrCoefDat::getParameters ( int  id)

Definition at line 483 of file LMFCorrCoefDat.cc.

References spr::find(), i, gen::k, m_data, m_subiov, L1TEmulatorMonitor_cff::p, Gflash::par, and runTheMatrix::ret.

Referenced by getParameters().

483  {
484  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
485  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
486  std::list<std::vector<float> > ret;
487  while (i != e) {
488  std::list<int> logic_ids = i->second->getLogicIds();
489  std::list<int>::iterator p =
490  std::find(logic_ids.begin(), logic_ids.end(), id);
491  if (p != logic_ids.end()) {
492  // the given logic id is contained in at least an element of this map
493  std::vector<float> ppar;
494  std::vector<Tm> tpar;
495  // get P1, P2, P3 and T1, T2, T3
496  i->second->getData(id, ppar);
497  tpar = m_subiov[i->first]->getTimes();
498  // construct the resulting pair of triplets
499  std::vector<float> par(6);
500  for (int k = 0; k < 3; k++) {
501  par[k + 3] = ppar[k];
502  par[k] = tpar[k].microsTime();
503  }
504  ret.push_back(par);
505  }
506  i++;
507  }
508  return ret;
509 }
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
int k[5][pyjets_maxn]
const double par[8 *NPar][4]
std::list< std::vector< float > > LMFCorrCoefDat::getParameters ( const EcalLogicID id)

Definition at line 477 of file LMFCorrCoefDat.cc.

References getParameters().

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

Definition at line 511 of file LMFCorrCoefDat.cc.

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

512  {
513  std::vector<float> x(3);
514  int key = iov.getID();
515  fetch(iov);
516  if (m_data.find(key) != m_data.end()) {
517  x = (m_data.find(key)->second)->getParameters(id);
518  }
519  return x;
520 }
int getID() const
Definition: LMFUnique.h:51
std::list< std::vector< float > > getParameters(int id)
void fetch(std::list< int > subiov_ids)
std::map< int, LMFCorrCoefDatComponent * > m_data
list key
Definition: combine.py:13
Definition: DDAxes.h:10
int LMFCorrCoefDat::getSeqID ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 544 of file LMFCorrCoefDat.cc.

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

545  {
546  int x = -1;
547  fetch(iov);
548  if (m_data.find(iov.getID()) != m_data.end()) {
549  x = (m_data.find(iov.getID())->second)->getSeqID(id);
550  }
551  return x;
552 }
int getID() const
Definition: LMFUnique.h:51
void fetch(std::list< int > subiov_ids)
U second(std::pair< T, U > const &p)
std::map< int, LMFCorrCoefDatComponent * > m_data
Definition: DDAxes.h:10
LMFSeqDat LMFCorrCoefDat::getSequence ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 554 of file LMFCorrCoefDat.cc.

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

555  {
556  LMFSeqDat seq(m_env, m_conn);
557  fetch(iov);
558  if (m_data.find(iov.getID()) != m_data.end()) {
559  seq = (m_data.find(iov.getID())->second)->getSequence(id);
560  }
561  return seq;
562 }
int getID() const
Definition: LMFUnique.h:51
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 575 of file LMFCorrCoefDat.cc.

References i, m_data, and runTheMatrix::ret.

575  {
576  std::list<int> ret;
577  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
578  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
579  while (i != e) {
580  ret.push_back(i->first);
581  i++;
582  }
583  return ret;
584 }
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 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
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 }
long int flag
Definition: mlp_lapack.h:47
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 564 of file LMFCorrCoefDat.cc.

References trackerHits::c, i, and m_data.

564  {
565  int c = 0;
566  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
567  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
568  while (i != e) {
569  c += i->second->size();
570  i++;
571  }
572  return c;
573 }
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, 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:41

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 = 8
staticprivate

Definition at line 76 of file LMFCorrCoefDat.h.

Referenced by getCorrections().