CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 { init(); }
LMFCorrCoefDat::LMFCorrCoefDat ( EcalDBConnection c)

Definition at line 6 of file LMFCorrCoefDat.cc.

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

6  {
7  init();
8  m_env = c->getEnv();
9  m_conn = c->getConn();
10 }
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 12 of file LMFCorrCoefDat.cc.

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

12  {
13  init();
14  m_env = env;
15  m_conn = conn;
16 }
oracle::occi::Connection * m_conn
oracle::occi::Environment * m_env
tuple conn
Definition: getInfo.py:9
LMFCorrCoefDat::~LMFCorrCoefDat ( )

Definition at line 18 of file LMFCorrCoefDat.cc.

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

18  {
19  std::map<int, LMFCorrCoefDatComponent *>::iterator i = m_data.begin();
20  std::map<int, LMFCorrCoefDatComponent *>::iterator e = m_data.end();
21  while (i != e) {
22  delete i->second;
23  i++;
24  }
25  m_data.clear();
26  std::map<int, LMFLmrSubIOV *>::iterator si = m_subiov.begin();
27  std::map<int, LMFLmrSubIOV *>::iterator se = m_subiov.end();
28  while (si != se) {
29  delete si->second;
30  si++;
31  }
32  m_subiov.clear();
33 }
std::map< int, LMFLmrSubIOV * > m_subiov
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 298 of file LMFCorrCoefDat.cc.

Referenced by getCorrections().

298  {
299  // this method verify that T3 in the last inserted record for a given
300  // crystal coincides with T1 of the newly inserted record
301  if (lastMap.find(logic_id) != lastMap.end()) {
302  const LMFSextuple sold = lastMap.find(logic_id)->second;
303  /* This check is wrong as it is. But we still need to define
304  a reasonable one.
305  if (sold.t[2] != s.t[0]) {
306  std::cout << ":-( T3 in last sequence for crystal " << logic_id
307  << " differs from T1 in this sequence: "
308  << sold.t[2].str() << " != " << s.t[0].str() << std::endl;
309  exit(0);
310  }
311  */
312  } else {
313  /* This check too must be updated
314  std::cout << ":-( Can't find crystal " << logic_id << " in last map"
315  << std::endl;
316  */
317  }
318 }
void LMFCorrCoefDat::debug ( )

Definition at line 135 of file LMFCorrCoefDat.cc.

References gather_cfg::cout, and m_debug.

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

135  {
136  std::cout << "Set debug" << std::endl << std::flush;
137  m_debug = true;
138 }
tuple cout
Definition: gather_cfg.py:144
void LMFCorrCoefDat::dump ( void  )

Definition at line 105 of file LMFCorrCoefDat.cc.

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

105  {
106  std::cout << std::endl;
107  std::cout << "##################### LMF_CORR_COEF_DAT ########################" << std::endl;
108  std::cout << "This structure contains " << m_data.size() << " LMR_SUB_IOV_ID" << std::endl;
109  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
110  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
111  int count = 0;
112  while (i != e) {
113  std::cout << "### SUB IOV ID: " << i->second->getLMFLmrSubIOVID() << std::endl;
114  std::list<int> logic_ids = i->second->getLogicIds();
115  std::cout << " Contains data for " << logic_ids.size() << " xtals" << std::endl;
116  count += logic_ids.size();
117  i++;
118  }
119  std::cout << "Total no. of xtals for which data are stored: " << count << std::endl;
120  std::cout << "##################### LMF_CORR_COEF_DAT ########################" << std::endl;
121 }
std::map< int, LMFCorrCoefDatComponent * > m_data
tuple cout
Definition: gather_cfg.py:144
void LMFCorrCoefDat::fetch ( std::list< int >  subiov_ids)

Definition at line 223 of file LMFCorrCoefDat.cc.

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

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

223  {
224  std::list<int>::const_iterator i = subiov_ids.begin();
225  std::list<int>::const_iterator e = subiov_ids.end();
226  int c = 0;
227  while (i != e) {
228  if (m_debug) {
229  std::cout << "[LMFCorrCoefDat] Fetching data taken "
230  << "during LMR_SUB_IOV no. " << ++c << std::endl;
231  }
232  fetch(*i);
233  i++;
234  }
235  if (m_debug) {
236  std::cout << "[LMFCorrCoefDat] fetch done for all sub iovs" << std::endl << std::flush;
237  }
238 }
const edm::EventSetup & c
void fetch(std::list< int > subiov_ids)
tuple cout
Definition: gather_cfg.py:144
void LMFCorrCoefDat::fetch ( int  subiov_id)

Definition at line 240 of file LMFCorrCoefDat.cc.

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

240  {
241  LMFLmrSubIOV iov(m_env, m_conn);
242  iov.setByID(subiov_id);
243  if (m_debug) {
244  std::cout << "[LMFCorrCoefDat] Looking for LMR_SUB_IOV with ID " << iov.getID() << std::endl << std::flush;
245  }
246  // create an instance of LMFLmrSubIOV to associate to this IOV_ID
247  LMFLmrSubIOV *subiov = new LMFLmrSubIOV(m_env, m_conn);
248  *subiov = iov;
249  m_subiov[subiov_id] = subiov;
250  if (m_debug) {
251  std::cout << "[LMFCorrCoefDat] Latest LMR_SUB_IOV data follows" << std::endl;
252  subiov->dump();
253  std::cout << "[LMFCorrCoefDat] Fetching data taken "
254  << "during LMR_SUB_IOV ID " << subiov_id << std::endl
255  << std::flush;
256  }
257  fetch(iov);
258 }
std::map< int, LMFLmrSubIOV * > m_subiov
oracle::occi::Connection * m_conn
virtual void dump() const
Definition: LMFUnique.cc:104
void fetch(std::list< int > subiov_ids)
oracle::occi::Environment * m_env
tuple cout
Definition: gather_cfg.py:144
void LMFCorrCoefDat::fetch ( const LMFLmrSubIOV iov)

Definition at line 260 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().

260  {
261  // fetch data with given LMR_SUB_IOV_ID from the database
262  if (m_data.find(iov.getID()) == m_data.end()) {
263  if (m_debug) {
264  std::cout << " Data collected in LMR_SUB_IOV " << iov.getID() << " not found in private data. "
265  << "Getting it from DB " << std::endl
266  << std::flush;
267  }
269  if (m_debug) {
270  comp->debug();
271  }
272  // assign this IOV to comp to be able to retrieve it from the DB
273  comp->setLMFLmrSubIOV(iov);
274  comp->fetch();
275  if (m_debug) {
276  std::cout << "====== DEBUGGING: Data collected during this LMR_SUB_IOV" << std::endl;
277  comp->dump();
278  std::cout << "====== DEBUGGING: ======================================" << std::endl << std::endl;
279  }
280  m_data[iov.getID()] = comp;
281  } else if (m_debug) {
282  // this is not going to happen, but...
283  std::cout << " Data collected in LMR_SUB_IOV " << iov.getID() << " found in private data. "
284  << std::endl
285  << std::flush;
286  }
287  if (m_debug) {
288  std::cout << "[LMFCorrCoefDat] Fetch done" << std::endl << std::endl << std::flush;
289  }
290 }
int getID() const
Definition: LMFUnique.h:58
oracle::occi::Connection * m_conn
void fetch() noexcept(false)
Definition: LMFDat.cc:201
std::map< int, LMFCorrCoefDatComponent * > m_data
oracle::occi::Environment * m_env
void dump() const override
Definition: LMFDat.cc:64
tuple cout
Definition: gather_cfg.py:144
LMFCorrCoefDatComponent & setLMFLmrSubIOV(const LMFLmrSubIOV &iov)
void debug()
Definition: LMFUnique.h:74
void LMFCorrCoefDat::fetchAfter ( const Tm t)

Definition at line 185 of file LMFCorrCoefDat.cc.

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

185  {
186  Tm tmax;
187  tmax.setToString("9999-12-31 23:59:59");
188  fetchBetween(t, tmax, 0);
189 }
void fetchBetween(const Tm &tmin, const Tm &tmax)
static const double tmax[3]
void setToString(const std::string s) noexcept(false)
Definition: Tm.cc:150
Definition: Tm.h:13
void LMFCorrCoefDat::fetchAfter ( const Tm t,
int  howMany 
)

Definition at line 191 of file LMFCorrCoefDat.cc.

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

191  {
192  Tm tmax;
193  tmax.setToString("9999-12-31 23:59:59");
194  fetchBetween(t, tmax, howmany);
195 }
void fetchBetween(const Tm &tmin, const Tm &tmax)
static const double tmax[3]
void setToString(const std::string s) noexcept(false)
Definition: Tm.cc:150
Definition: Tm.h:13
void LMFCorrCoefDat::fetchBetween ( const Tm tmin,
const Tm tmax 
)

Definition at line 197 of file LMFCorrCoefDat.cc.

Referenced by fetchAfter().

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

Definition at line 199 of file LMFCorrCoefDat.cc.

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

199  {
200  LMFLmrSubIOV iov(m_env, m_conn);
201  Tm tinf;
202  tinf.setToString("9999-12-31 23:59:59");
203  if (m_debug) {
204  std::cout << "Searching for data collected after " << tmin.str();
205  if (tmax != tinf) {
206  std::cout << " and before " << tmax.str();
207  }
208  std::cout << ". Retrieving the first " << maxNumberOfIOVs << " records" << std::endl;
209  iov.debug();
210  }
211  std::list<int> l = iov.getIOVIDsLaterThan(tmin, tmax, maxNumberOfIOVs);
212  if (m_debug) {
213  std::cout << "Now we are going to fetch details about "
214  << "data collected within the above mentioned "
215  << "LMR_SUB_IOV's" << std::endl;
216  }
217  fetch(l);
218  if (m_debug) {
219  std::cout << "Fetched a list of " << m_data.size() << " IOVs" << std::endl << std::flush;
220  }
221 }
oracle::occi::Connection * m_conn
void fetch(std::list< int > subiov_ids)
std::map< int, LMFCorrCoefDatComponent * > m_data
oracle::occi::Environment * m_env
void setToString(const std::string s) noexcept(false)
Definition: Tm.cc:150
std::string str() const
Definition: Tm.cc:66
tuple cout
Definition: gather_cfg.py:144
Definition: Tm.h:13
RunIOV LMFCorrCoefDat::fetchLastInsertedRun ( )

Definition at line 142 of file LMFCorrCoefDat.cc.

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

142  {
143  RunIOV iov;
144  if (m_conn == nullptr) {
145  throw std::runtime_error(
146  "[LMFCorrCoefDat::fetchLastInsertedRun] ERROR: "
147  "Connection not set");
148  }
149  iov.setConnection(m_env, m_conn);
150  std::string sql =
151  "SELECT IOV_ID FROM CMS_ECAL_COND.RUN_IOV WHERE "
152  "IOV_ID = (SELECT RUN_IOV_ID FROM LMF_SEQ_DAT WHERE SEQ_ID = "
153  "(SELECT MAX(SEQ_ID) FROM LMF_CORR_COEF_DAT))";
154  oracle::occi::Statement *stmt;
155  try {
156  stmt = m_conn->createStatement();
157  stmt->setSQL(sql);
158  } catch (oracle::occi::SQLException &e) {
159  throw(std::runtime_error("[LMFCorrCoefDat::fetchLastInsertedRun]: " + e.getMessage()));
160  }
161  if (m_debug) {
162  std::cout << "[LMFCorrCoefDat::fetchLastInsertedRun] executing query" << std::endl
163  << sql << std::endl
164  << std::flush;
165  }
166  oracle::occi::ResultSet *rset = stmt->executeQuery();
167  if (m_debug) {
168  std::cout << " done" << std::endl << std::flush;
169  }
170  int iov_id = -1;
171  try {
172  while (rset->next()) {
173  // there should be just one result
174  iov_id = rset->getInt(1);
175  }
176  } catch (oracle::occi::SQLException &e) {
177  throw(std::runtime_error("[LMFCorrCoefDat::fetchLastInsertedRun]: " + e.getMessage()));
178  }
179  if (iov_id > 0) {
180  iov.setByID(iov_id);
181  }
182  return iov;
183 }
void setByID(int id) noexcept(false) override
Definition: RunIOV.cc:106
oracle::occi::Connection * m_conn
oracle::occi::Environment * m_env
tuple cout
Definition: gather_cfg.py:144
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 87 of file LMFCorrCoefDat.cc.

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

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

87  {
88  if (m_data.find(iov.getID()) != m_data.end()) {
89  return m_data[iov.getID()];
90  } else {
92  LMFLmrSubIOV *subiov = new LMFLmrSubIOV();
93  if (m_conn != nullptr) {
95  subiov->setConnection(m_env, m_conn);
96  }
97  *subiov = iov;
98  c->setLMFLmrSubIOV(*subiov);
99  m_data[subiov->getID()] = c;
100  m_subiov[subiov->getID()] = subiov;
101  return c;
102  }
103 }
std::map< int, LMFLmrSubIOV * > m_subiov
int getID() const
Definition: LMFUnique.h:58
const edm::EventSetup & c
oracle::occi::Connection * m_conn
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 294 of file LMFCorrCoefDat.cc.

References MAX_NUMBER_OF_SEQUENCES_TO_FETCH.

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

294  {
296 }
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 320 of file LMFCorrCoefDat.cc.

References getCorrections().

320  {
321  return getCorrections(t, Tm().plusInfinity(), max);
322 }
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 324 of file LMFCorrCoefDat.cc.

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

324  {
325  // returns a map whose key is the sequence_id and whose value is another
326  // map. The latter has the logic_id of a crystal as key and the corresponding
327  // sextuple p1, p2, p3, t1, t2, t3 as value.
328  // Crystal corrections, then, are organized by sequences
329  // First of all, checks that the connection is active (TODO)
330  //
331  // For fixed-time IOV's sequence ID's are always 0. In that case
332  // use the LMR_SUB_IOV_ID as a key
333  if (m_conn == nullptr) {
334  throw std::runtime_error(
335  "[LMFCorrCoefDat::getCorrections] ERROR: "
336  "Connection not set");
337  }
338  // limit the maximum number of rows to fetch
340  if (m_debug) {
341  std::cout << " Required to fetch " << max << " sequences from OMDS. " << MAX_NUMBER_OF_SEQUENCES_TO_FETCH
342  << " allowed" << std::endl;
343  }
345  }
346  // we must define some criteria to select the right rows
347  std::map<int, std::map<int, LMFSextuple> > ret;
348  std::string sql =
349  "SELECT * FROM (SELECT LOGIC_ID, T1, T2, T3, P1, P2, P3, "
350  "SEQ_ID, D.LMR_SUB_IOV_ID FROM LMF_LMR_SUB_IOV JOIN LMF_CORR_COEF_DAT D ON "
351  "D.LMR_SUB_IOV_ID = LMF_LMR_SUB_IOV.LMR_SUB_IOV_ID "
352  "WHERE T1 > TO_DATE(:1, 'YYYY-MM-DD HH24:MI:SS') AND "
353  "T1 <= TO_DATE(:2, 'YYYY-MM-DD HH24:MI:SS') ORDER BY T1) WHERE ROWNUM <= :3";
354  try {
356  const int PREFETCH = 10000;
357  oracle::occi::Statement *stmt = m_conn->createStatement();
358  stmt->setSQL(sql);
359  int toFetch = (max * (61200 + 14648));
360  stmt->setString(1, t.str());
361  stmt->setString(2, t2.str());
362  stmt->setInt(3, toFetch);
363  stmt->setPrefetchRowCount(PREFETCH);
364  if (m_debug) {
365  std::cout << "[LMFCorrCoefDat::getCorrections] executing query" << std::endl
366  << sql << std::endl
367  << "Parameters 1 = " << t.str() << " 2 = " << t2.str() << " 3 = " << toFetch << std::endl
368  << "Prefetching " << PREFETCH << " rows " << std::endl
369  << std::flush;
370  }
371  oracle::occi::ResultSet *rset = stmt->executeQuery();
372  if (m_debug) {
373  std::cout << " done" << std::endl << std::flush;
374  }
375  int c = 0;
376  std::map<int, LMFSextuple> theMap;
377  int lastSeqId = 0;
378  int previousSeqId = 0;
379  int startingSeqId = -1; // this variable contains the very first SEQ_ID
380  LMFSextuple s;
381  bool proceed = true;
382  while (rset->next()) {
383  int logic_id = rset->getInt(1);
384  int seq_id = rset->getInt(8);
385  if (startingSeqId < 0) {
386  startingSeqId = seq_id;
387  }
388  if ((seq_id == 0) && (startingSeqId == 0)) {
389  // check if we are in fixed-time IOV mode or not.
390  // In any case do not mix the modes.
391  if (c == 0) {
392  std::cout << "[LMFCorrCoefDat::getCorrections] Using fixed-time IOV" << std::endl;
393  }
394  seq_id = rset->getInt(9); // for fixed-time intervals use LMR_SUB_IOV_ID
395  } else if ((startingSeqId == 0) && (proceed = true)) {
396  std::cout << "[LMFCorrCoefDat::getCorrections] Switch to normal (sequence based) mode. "
397  << "Exiting..." << std::endl;
398  proceed = false;
399  } else if ((seq_id == 0) && (proceed = true)) {
400  std::cout << "[LMFCorrCoefDat::getCorrections] Switch to fixed-time IOV mode. "
401  << "Exiting..." << std::endl;
402  proceed = false;
403  }
404  if (proceed) {
405  if (seq_id != lastSeqId) {
406  if (m_debug) {
407  if (lastSeqId != 0) {
408  std::cout << " Triplets in sequences: " << c << std::endl;
409  std::cout << " T1: " << s.t[0].str() << " T2: " << s.t[1].str() << " T3: " << s.t[2].str()
410  << std::endl;
411  }
412  c = 0;
413  std::cout << " Found new sequence: " << seq_id << std::endl;
414  }
415  // the triplet of dates is equal for all rows in a sequence:
416  // get them once
417  for (int i = 0; i < 3; i++) {
418  oracle::occi::Date d = rset->getDate(i + 2);
419  s.t[i] = dh.dateToTm(d);
420  }
421  if (lastSeqId > 0) {
422  ret[lastSeqId] = theMap;
423  }
424  theMap.clear();
425  previousSeqId = lastSeqId;
426  lastSeqId = seq_id;
427  }
428  for (int i = 0; i < 3; i++) {
429  s.p[i] = rset->getDouble(i + 5);
430  }
431  theMap[logic_id] = s;
432  // verify that the sequence of time is correct
433  if (!ret.empty()) {
434  checkTriplets(logic_id, s, ret[previousSeqId]);
435  }
436  c++;
437  }
438  }
439  // insert the last map in the outer map
440  ret[lastSeqId] = theMap;
441  if (m_debug) {
442  std::cout << " Triplets in sequences: " << c << std::endl;
443  std::cout << " T1: " << s.t[0].str() << " T2: " << s.t[1].str() << " T3: " << s.t[2].str() << std::endl;
444  std::cout << std::endl;
445  }
446  } catch (oracle::occi::SQLException &e) {
447  throw(std::runtime_error("LMFCorrCoefDat::getCorrections: " + e.getMessage()));
448  }
449  if (m_debug) {
450  std::cout << "[LMFCorrCoefDat::getCorrections] Map built" << std::endl
451  << " Contains " << ret.size()
452  << " sequences. These are the size of all sequences" << std::endl;
453  std::map<int, std::map<int, LMFSextuple> >::const_iterator i = ret.begin();
454  std::map<int, std::map<int, LMFSextuple> >::const_iterator e = ret.end();
455  while (i != e) {
456  std::cout << " SEQ " << i->first << " Size " << i->second.size() << std::endl;
457  i++;
458  }
459  }
460  return ret;
461 }
tuple ret
prodAgent to be discontinued
const edm::EventSetup & c
oracle::occi::Connection * m_conn
static const int MAX_NUMBER_OF_SEQUENCES_TO_FETCH
float p[3]
Definition: LMFSextuple.h:20
tuple d
Definition: ztail.py:151
oracle::occi::Environment * m_env
void checkTriplets(int logic_id, const LMFSextuple &s, const std::map< int, LMFSextuple > &lastMap)
std::string str() const
Definition: Tm.cc:66
tuple cout
Definition: gather_cfg.py:144
tuple dh
Definition: cuy.py:354
int LMFCorrCoefDat::getFlag ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 514 of file LMFCorrCoefDat.cc.

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

514  {
515  int x = -1;
516  fetch(iov);
517  if (m_data.find(iov.getID()) != m_data.end()) {
518  x = (m_data.find(iov.getID())->second)->getFlag(id);
519  }
520  return x;
521 }
int getID() const
Definition: LMFUnique.h:58
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 504 of file LMFCorrCoefDat.cc.

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

504  {
505  std::vector<float> x;
506  int key = iov.getID();
507  fetch(iov);
508  if (m_data.find(key) != m_data.end()) {
509  x = (m_data.find(key)->second)->getParameterErrors(id);
510  }
511  return x;
512 }
int getID() const
Definition: LMFUnique.h:58
std::vector< float > getParameterErrors(const LMFLmrSubIOV &iov, const EcalLogicID &id)
void fetch(std::list< int > subiov_ids)
std::map< int, LMFCorrCoefDatComponent * > m_data
tuple key
prepare the HTCondor submission files and eventually submit them
std::list< std::vector< float > > LMFCorrCoefDat::getParameters ( int  id)

Definition at line 467 of file LMFCorrCoefDat.cc.

References alignCSCRings::e, spr::find(), mps_fire::i, gpuClustering::id, isotrackApplyRegressor::k, m_data, m_subiov, AlCaHLTBitMon_ParallelJobs::p, and runTheMatrix::ret.

Referenced by getParameters().

467  {
468  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
469  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
470  std::list<std::vector<float> > ret;
471  while (i != e) {
472  std::list<int> logic_ids = i->second->getLogicIds();
473  std::list<int>::iterator p = std::find(logic_ids.begin(), logic_ids.end(), id);
474  if (p != logic_ids.end()) {
475  // the given logic id is contained in at least an element of this map
476  std::vector<float> ppar;
477  std::vector<Tm> tpar;
478  // get P1, P2, P3 and T1, T2, T3
479  i->second->getData(id, ppar);
480  tpar = m_subiov[i->first]->getTimes();
481  // construct the resulting pair of triplets
482  std::vector<float> par(6);
483  for (int k = 0; k < 3; k++) {
484  par[k + 3] = ppar[k];
485  par[k] = tpar[k].microsTime();
486  }
487  ret.push_back(par);
488  }
489  i++;
490  }
491  return ret;
492 }
std::map< int, LMFLmrSubIOV * > m_subiov
tuple ret
prodAgent to be discontinued
uint16_t *__restrict__ id
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::map< int, LMFCorrCoefDatComponent * > m_data
std::list< std::vector< float > > LMFCorrCoefDat::getParameters ( const EcalLogicID id)

Definition at line 463 of file LMFCorrCoefDat.cc.

References getParameters().

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

Definition at line 494 of file LMFCorrCoefDat.cc.

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

494  {
495  std::vector<float> x(3);
496  int key = iov.getID();
497  fetch(iov);
498  if (m_data.find(key) != m_data.end()) {
499  x = (m_data.find(key)->second)->getParameters(id);
500  }
501  return x;
502 }
int getID() const
Definition: LMFUnique.h:58
std::list< std::vector< float > > getParameters(int id)
void fetch(std::list< int > subiov_ids)
std::map< int, LMFCorrCoefDatComponent * > m_data
tuple key
prepare the HTCondor submission files and eventually submit them
int LMFCorrCoefDat::getSeqID ( const LMFLmrSubIOV iov,
const EcalLogicID id 
)

Definition at line 523 of file LMFCorrCoefDat.cc.

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

523  {
524  int x = -1;
525  fetch(iov);
526  if (m_data.find(iov.getID()) != m_data.end()) {
527  x = (m_data.find(iov.getID())->second)->getSeqID(id);
528  }
529  return x;
530 }
int getID() const
Definition: LMFUnique.h:58
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 532 of file LMFCorrCoefDat.cc.

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

532  {
534  fetch(iov);
535  if (m_data.find(iov.getID()) != m_data.end()) {
536  seq = (m_data.find(iov.getID())->second)->getSequence(id);
537  }
538  return seq;
539 }
int getID() const
Definition: LMFUnique.h:58
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 552 of file LMFCorrCoefDat.cc.

References alignCSCRings::e, mps_fire::i, m_data, and runTheMatrix::ret.

552  {
553  std::list<int> ret;
554  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
555  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
556  while (i != e) {
557  ret.push_back(i->first);
558  i++;
559  }
560  return ret;
561 }
tuple ret
prodAgent to be discontinued
std::map< int, LMFCorrCoefDatComponent * > m_data
std::vector< Tm > LMFCorrCoefDat::getTimes ( const LMFLmrSubIOV iov)

Definition at line 292 of file LMFCorrCoefDat.cc.

References LMFLmrSubIOV::getTimes().

292 { return iov.getTimes(); }
void getTimes(Tm *t1, Tm *t2, Tm *t3) const
Definition: LMFLmrSubIOV.h:34
void LMFCorrCoefDat::init ( void  )

Definition at line 35 of file LMFCorrCoefDat.cc.

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

Referenced by LMFCorrCoefDat().

35  {
36  m_data.clear();
37  m_subiov.clear();
38  m_env = nullptr;
39  m_conn = nullptr;
40  nodebug();
41 }
std::map< int, LMFLmrSubIOV * > m_subiov
oracle::occi::Connection * m_conn
std::map< int, LMFCorrCoefDatComponent * > m_data
oracle::occi::Environment * m_env
void LMFCorrCoefDat::nodebug ( )

Definition at line 140 of file LMFCorrCoefDat.cc.

References m_debug.

Referenced by init().

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

Definition at line 43 of file LMFCorrCoefDat.cc.

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

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

Definition at line 72 of file LMFCorrCoefDat.cc.

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

72  {
73  find(iov)->setFlag(id, flag);
74  return *this;
75 }
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 55 of file LMFCorrCoefDat.cc.

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

55  {
56  find(iov)->setP123(id, p1, p2, p3);
57  return *this;
58 }
const TString p2
Definition: fwPaths.cc:13
const TString p1
Definition: fwPaths.cc:12
LMFCorrCoefDatComponent & setP123(const EcalLogicID &id, float p1, float p2, float p3)
LMFCorrCoefDatComponent * find(const LMFLmrSubIOV &iov)
LMFCorrCoefDat & LMFCorrCoefDat::setP123 ( const LMFLmrSubIOV iov,
const EcalLogicID id,
float  p1,
float  p2,
float  p3,
float  p1e,
float  p2e,
float  p3e 
)

Definition at line 60 of file LMFCorrCoefDat.cc.

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

61  {
62  find(iov)->setP123(id, p1, p2, p3, p1e, p2e, p3e);
63  return *this;
64 }
const TString p2
Definition: fwPaths.cc:13
const TString p1
Definition: fwPaths.cc:12
LMFCorrCoefDatComponent & setP123(const EcalLogicID &id, float p1, float p2, float p3)
LMFCorrCoefDatComponent * find(const LMFLmrSubIOV &iov)
LMFCorrCoefDat & LMFCorrCoefDat::setP123Errors ( const LMFLmrSubIOV iov,
const EcalLogicID id,
float  p1e,
float  p2e,
float  p3e 
)

Definition at line 66 of file LMFCorrCoefDat.cc.

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

67  {
68  find(iov)->setP123Errors(id, p1e, p2e, p3e);
69  return *this;
70 }
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 77 of file LMFCorrCoefDat.cc.

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

77  {
78  find(iov)->setSequence(id, seq_id);
79  return *this;
80 }
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 82 of file LMFCorrCoefDat.cc.

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

82  {
83  find(iov)->setSequence(id, seq);
84  return *this;
85 }
LMFCorrCoefDatComponent & setSequence(const EcalLogicID &id, int seq_id)
LMFCorrCoefDatComponent * find(const LMFLmrSubIOV &iov)
int LMFCorrCoefDat::size ( void  ) const

Definition at line 541 of file LMFCorrCoefDat.cc.

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

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

541  {
542  int c = 0;
543  std::map<int, LMFCorrCoefDatComponent *>::const_iterator i = m_data.begin();
544  std::map<int, LMFCorrCoefDatComponent *>::const_iterator e = m_data.end();
545  while (i != e) {
546  c += i->second->size();
547  i++;
548  }
549  return c;
550 }
const edm::EventSetup & c
std::map< int, LMFCorrCoefDatComponent * > m_data
void LMFCorrCoefDat::writeDB ( )

Definition at line 123 of file LMFCorrCoefDat.cc.

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

123  {
124  std::map<int, LMFCorrCoefDatComponent *>::iterator i = m_data.begin();
125  std::map<int, LMFCorrCoefDatComponent *>::iterator e = m_data.end();
126  while (i != e) {
127  if (m_debug) {
128  std::cout << "Writing data for LMR_SUB_IOV_ID " << i->first << std::endl;
129  }
130  i->second->writeDB();
131  i++;
132  }
133 }
std::map< int, LMFCorrCoefDatComponent * > m_data
tuple cout
Definition: gather_cfg.py:144

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 64 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 61 of file LMFCorrCoefDat.h.

Referenced by getCorrections().