30 std::vector<EcalLogicID> crystals_EB = getEcalLogicIDSetOrdered(
32 std::vector<EcalLogicID> crystals_EE =
33 getEcalLogicIDSetOrdered(
"EE_crystal_number", -1, 1, 1, 100, 1, 100,
"EE_crystal_number", 4);
35 std::vector<EcalLogicID>::const_iterator ieb = crystals_EB.begin();
36 std::vector<EcalLogicID>::const_iterator eeb = crystals_EB.end();
38 int iEta = ieb->getID1();
39 int iPhi = ieb->getID2();
41 _logicId2DetId[ieb->getLogicID()] = ebdetid;
42 _detId2LogicId[ebdetid] = ieb->getLogicID();
47 std::vector<EcalLogicID>::const_iterator iee = crystals_EE.begin();
48 std::vector<EcalLogicID>::const_iterator eee = crystals_EE.end();
51 int iSide = iee->getID1();
52 int iX = iee->getID2();
53 int iY = iee->getID3();
54 EEDetId eedetidpos(iX, iY, iSide);
55 _logicId2DetId[iee->getLogicID()] = eedetidpos;
56 _detId2LogicId[eedetidpos] = iee->getLogicID();
63 "SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE logic_id = :logicID AND name=maps_to";
70 stmt->setInt(1, logicID);
71 ResultSet* rset = stmt->executeQuery();
74 name = rset->getString(1);
75 logicID = rset->getInt(2);
76 id1 = rset->getInt(3);
77 if (rset->isNull(3)) {
80 id2 = rset->getInt(4);
81 if (rset->isNull(4)) {
84 id3 = rset->getInt(5);
85 if (rset->isNull(5)) {
88 mapsTo = rset->getString(6);
91 msg <<
"ERROR: Cannot build EcalLogicID for logic_id " << logicID;
92 throw(std::runtime_error(
msg.str()));
95 }
catch (SQLException&
e) {
96 throw(std::runtime_error(
std::string(
"ERROR: Failed to retrive ids: ") +
e.getMessage()));
103 std::list<ODDelaysDat>
ret;
105 std::map<EcalLogicID, RunFEConfigDat> fillMap;
108 d.fetchData(&fillMap, iov);
109 }
catch (std::runtime_error&
e) {
112 std::map<EcalLogicID, RunFEConfigDat>::const_iterator
i = fillMap.begin();
113 std::map<EcalLogicID, RunFEConfigDat>::const_iterator
e = fillMap.end();
117 temp.setId(
i->second.getConfigId());
120 std::vector<ODDelaysDat> delays;
124 std::vector<ODDelaysDat>::const_iterator di = delays.begin();
125 std::vector<ODDelaysDat>::const_iterator de = delays.end();
127 ret.push_back(*di++);
135 if (mapsTo.empty()) {
141 ss <<
"SELECT logic_id FROM channelView WHERE name = :n AND";
142 int idarray[] = {
id1,
id2, id3};
143 for (
int i = 1;
i <= 3;
i++) {
145 ss <<
" id" <<
i <<
" IS NULL AND";
147 ss <<
" id" <<
i <<
" = :id" <<
i <<
" AND";
150 ss <<
" maps_to = :m";
156 stmt->setSQL(
ss.str());
160 stmt->setString(
j,
name);
162 for (
int i = 0;
i < 3;
i++) {
164 stmt->setInt(
j, idarray[
i]);
168 stmt->setString(
j, mapsTo);
171 ResultSet* rset = stmt->executeQuery();
173 logic_id = rset->getInt(1);
176 msg <<
"ERROR: Query for EcalLogicID failed for parameters [" 177 <<
"name=" <<
name <<
",maps_to=" << mapsTo <<
",id1=" <<
id1 <<
",id2=" <<
id2 <<
",id3=" << id3 <<
"]";
178 throw(std::runtime_error(
msg.str()));
180 }
catch (SQLException&
e) {
181 throw(std::runtime_error(
std::string(
"ERROR: Failed to retrive logic_id: ") +
e.getMessage()));
189 string name,
int fromId1,
int toId1,
int fromId2,
int toId2,
int fromId3,
int toId3,
string mapsTo) noexcept(
false) {
190 if (mapsTo.empty()) {
194 int idArray[] = {fromId1, toId1, fromId2, toId2, fromId3, toId3};
198 ss <<
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
201 for (
int i = 1;
i <= 3;
i++) {
202 from = idArray[2 * (
i - 1)];
203 to = idArray[2 * (
i - 1) + 1];
209 throw(std::runtime_error(
"ERROR: Bad arguments for getEcalLogicIDSet"));
214 ss <<
"id" <<
i <<
" IS NULL AND ";
216 ss <<
"id" <<
i <<
" >= :id" <<
i <<
"from AND " 217 <<
"id" <<
i <<
" <= :id" <<
i <<
"to AND ";
220 ss <<
"maps_to = :maps_to ORDER BY id1, id2, id3";
222 std::vector<EcalLogicID>
result;
225 stmt->setSQL(
ss.str());
229 stmt->setString(
j,
name);
232 for (
int i = 0;
i < 3;
i++) {
233 from = idArray[2 *
i];
234 to = idArray[2 *
i + 1];
236 stmt->setInt(
j, from);
243 stmt->setString(
j, mapsTo);
247 ResultSet* rset = stmt->executeQuery();
249 int id1,
id2, id3, logicId;
251 while (rset->next()) {
252 name = rset->getString(1);
253 logicId = rset->getInt(2);
254 id1 = rset->getInt(3);
255 if (rset->isNull(3)) {
258 id2 = rset->getInt(4);
259 if (rset->isNull(4)) {
262 id3 = rset->getInt(5);
263 if (rset->isNull(5)) {
266 mapsTo = rset->getString(6);
271 stmt->setPrefetchRowCount(0);
273 }
catch (SQLException&
e) {
274 throw(std::runtime_error(
std::string(
"ERROR: Failure while getting EcalLogicID set: ") +
e.getMessage()));
281 std::map<int, int>
ret;
282 std::vector<EcalLogicID> crystals_EB = getEcalLogicIDSetOrdered(
"EB_crystal_number",
291 std::vector<EcalLogicID> crystals_EE =
292 getEcalLogicIDSetOrdered(
"EE_crystal_number", -1, 1, 1, 100, 1, 100,
"EE_crystal_number",
EcalLogicID::NULLID);
293 std::vector<EcalLogicID> EB_lmr = getEcalLogicIDSetOrdered(
295 std::vector<EcalLogicID> EE_lmr =
296 getEcalLogicIDSetOrdered(
"EE_crystal_number", -1, 1, 1, 100, 1, 100,
"ECAL_LMR",
EcalLogicID::NULLID);
297 unsigned int neb = crystals_EB.size();
298 unsigned int nee = crystals_EE.size();
299 if (neb != EB_lmr.size()) {
300 throw(std::runtime_error(
"ERROR: EB Vectors size do not agree"));
302 if (nee != EE_lmr.size()) {
303 throw(std::runtime_error(
"ERROR: EE Vectors size do not agree"));
305 for (
unsigned int i = 0;
i < neb;
i++) {
306 ret[crystals_EB[
i].getLogicID()] = EB_lmr[
i].getLogicID() % 100;
308 for (
unsigned int i = 0;
i < nee;
i++) {
309 ret[crystals_EE[
i].getLogicID()] = EE_lmr[
i].getLogicID() % 100;
317 "SELECT LOGIC_ID, ID1, ID2, ID3 " 318 "FROM CHANNELVIEW WHERE NAME = 'EB_crystal_angle' AND LOGIC_ID IN " 319 "(SELECT LOGIC_ID FROM CHANNELVIEW WHERE NAME = 'EB_crystal_number' AND " 320 "ID1*10000+ID2 IN (SELECT DISTINCT ID1*10000+ID2 FROM CHANNELVIEW " 321 "WHERE LOGIC_ID = :1 AND NAME = 'EB_crystal_number' AND MAPS_TO = :2) " 322 "AND NAME = MAPS_TO)";
323 if ((lmr_logic_id / 1000000000) == 2) {
324 name =
"EE_crystal_number";
326 "SELECT LOGIC_ID, ID1, ID2, ID3 " 327 "FROM CHANNELVIEW WHERE NAME = 'EE_crystal_number' AND LOGIC_ID IN " 328 "(SELECT LOGIC_ID FROM CHANNELVIEW WHERE NAME = 'EE_crystal_number' AND " 329 "ID1*10000000+ID2*10000+ID3 IN (SELECT DISTINCT " 330 "ID1*10000000+ID2*10000+ID3 FROM CHANNELVIEW " 331 "WHERE LOGIC_ID = :1 AND NAME = 'EE_crystal_number' AND MAPS_TO = :2) " 332 "AND NAME = MAPS_TO) AND NAME = MAPS_TO";
334 std::vector<EcalLogicID>
ret;
337 stmt->setInt(1, lmr_logic_id);
338 stmt->setString(2, maps_to);
341 ResultSet* rset = stmt->executeQuery();
343 while (rset->next()) {
344 int logic_id = rset->getInt(1);
345 int id1 = rset->getInt(2);
346 if (rset->isNull(2)) {
349 int id2 = rset->getInt(3);
350 if (rset->isNull(3)) {
353 int id3 = rset->getInt(4);
354 if (rset->isNull(4)) {
361 stmt->setPrefetchRowCount(0);
362 }
catch (SQLException&
e) {
363 throw(std::runtime_error(
std::string(
"ERROR: Failure while getting EcalLogicID set: ") +
e.getMessage()));
369 return getEcalLogicIDMappedTo(lmr,
"ECAL_LMR");
373 return getEcalLogicIDForLMR(lmr.
getLogicID());
377 if ((lmr / 1000000000) == 2) {
378 return getEcalLogicIDMappedTo(lmr,
"EE_LM_PN");
380 return getEcalLogicIDMappedTo(lmr,
"EB_LM_PN");
385 return getEcalLogicIDForLMR(lmr.
getLogicID());
389 string name,
int fromId1,
int toId1,
int fromId2,
int toId2,
int fromId3,
int toId3,
string mapsTo,
int orderedBy)
393 if (mapsTo.empty()) {
397 int idArray[] = {fromId1, toId1, fromId2, toId2, fromId3, toId3};
401 ss <<
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
404 for (
int i = 1;
i <= 3;
i++) {
405 from = idArray[2 * (
i - 1)];
406 to = idArray[2 * (
i - 1) + 1];
412 throw(std::runtime_error(
"ERROR: Bad arguments for getEcalLogicIDSet"));
417 ss <<
"id" <<
i <<
" IS NULL AND ";
419 ss <<
"id" <<
i <<
" >= :id" <<
i <<
"from AND " 420 <<
"id" <<
i <<
" <= :id" <<
i <<
"to AND ";
423 ss <<
"maps_to = :maps_to ";
426 ss <<
" ORDER BY id1, id2, id3";
427 }
else if (orderedBy == 1 || orderedBy == 12 || orderedBy == 123) {
428 ss <<
" ORDER BY id1, id2, id3 ";
429 }
else if (orderedBy == 213 || orderedBy == 21) {
430 ss <<
" ORDER BY id2, id1, id3 ";
431 }
else if (orderedBy == 231 || orderedBy == 23) {
432 ss <<
" ORDER BY id2, id3, id1 ";
433 }
else if (orderedBy == 321 || orderedBy == 32) {
434 ss <<
" ORDER BY id3, id2, id1 ";
435 }
else if (orderedBy == 312 || orderedBy == 31) {
436 ss <<
" ORDER BY id3, id1, id2 ";
437 }
else if (orderedBy == 132 || orderedBy == 13) {
438 ss <<
" ORDER BY id1, id3, id2 ";
439 }
else if (orderedBy == 1234) {
440 ss <<
" ORDER BY id1, id2, id3, logic_id ";
441 }
else if (orderedBy == 4) {
442 ss <<
" ORDER BY logic_id ";
444 ss <<
" ORDER BY id1, id2, id3";
447 std::vector<EcalLogicID>
result;
450 stmt->setSQL(
ss.str());
454 stmt->setString(
j,
name);
457 for (
int i = 0;
i < 3;
i++) {
458 from = idArray[2 *
i];
459 to = idArray[2 *
i + 1];
461 stmt->setInt(
j, from);
468 stmt->setString(
j, mapsTo);
472 ResultSet* rset = stmt->executeQuery();
474 int id1,
id2, id3, logicId;
476 while (rset->next()) {
477 name = rset->getString(1);
478 logicId = rset->getInt(2);
479 id1 = rset->getInt(3);
480 if (rset->isNull(3)) {
483 id2 = rset->getInt(4);
484 if (rset->isNull(4)) {
487 id3 = rset->getInt(5);
488 if (rset->isNull(5)) {
491 mapsTo = rset->getString(6);
496 stmt->setPrefetchRowCount(0);
498 }
catch (SQLException&
e) {
499 throw(std::runtime_error(
std::string(
"ERROR: Failure while getting EcalLogicID set: ") +
e.getMessage()));
509 }
catch (std::runtime_error&
e) {
520 }
catch (std::runtime_error&
e) {
531 }
catch (std::runtime_error&
e) {
542 }
catch (std::runtime_error&
e) {
553 }
catch (std::runtime_error&
e) {
562 std::list<LMFDat*>::iterator
i = dat.begin();
563 std::list<LMFDat*>::iterator
e = dat.end();
565 (*i)->setConnection(
env,
conn);
569 }
catch (std::runtime_error&
e) {
580 }
catch (std::runtime_error&
e) {
590 iov->updateEndTimeDB();
591 }
catch (std::runtime_error&
e) {
601 iov->updateEndTimeDB();
602 }
catch (std::runtime_error&
e) {
612 iov->updateStartTimeDB();
613 }
catch (std::runtime_error&
e) {
623 od->updateDefaultCycle();
624 }
catch (std::runtime_error&
e) {
656 }
catch (std::runtime_error&
e) {
667 }
catch (std::runtime_error&
e) {
681 moniov.
setByRun(montag, &runiov, subrun);
694 return seq.fetchLastRun();
718 std::cout <<
"################################" << std::endl;
719 std::cout <<
"################################" << std::endl;
720 std::cout <<
"WARNING: More than one LMFRUNIOV" << std::endl;
721 std::cout <<
" Found for seq " <<
seq.getID() << std::endl;
722 std::cout <<
" lmr " << lmr <<
" type " <<
type << std::endl;
723 std::cout <<
" and color " << color << std::endl;
724 std::cout <<
"################################" << std::endl;
725 std::cout <<
"################################" << std::endl;
748 r.fetchValuesForECID(ecid);
754 const Tm&
end) noexcept(
false) {
757 r.fetchValuesForECIDAndTime(ecid,
start,
end);
773 r.fetchRuns(min_run, max_run);
781 r.fetchNonEmptyRuns(min_run, max_run);
789 r.fetchNonEmptyGlobalRuns(min_run, max_run);
800 r.fetchRunsByLocation(min_run, max_run, locDef);
811 r.fetchGlobalRunsByLocation(min_run, max_run, locDef);
819 r.fetchLastNRuns(max_run, n_runs);
829 r.setMonRunTag(monrunTag);
837 int max_run) noexcept(
false) {
841 r.setMonRunTag(monrunTag);
842 r.fetchRuns(min_run, max_run);
849 int n_runs) noexcept(
false) {
853 r.setMonRunTag(monrunTag);
854 r.fetchLastNRuns(max_run, n_runs);
void insertLmfSeq(LMFSeqDat *iov) noexcept(false)
void setByTime(std::string location, const Tm &t) noexcept(false)
RunList fetchGlobalRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef) noexcept(false)
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun) noexcept(false)
std::list< LMFRunIOV > fetchBySequence(const LMFSeqDat &s)
void insertMonRunIOV(MonRunIOV *iov) noexcept(false)
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="") noexcept(false)
ret
prodAgent to be discontinued
void updateRunConfig(ODRunConfigInfo *od) noexcept(false)
void insertDCUIOV(DCUIOV *iov) noexcept(false)
RunIOV fetchLMFLastRun() const
std::list< ODDelaysDat > fetchFEDelaysForRun(RunIOV *iov) noexcept(false)
DCUIOV fetchDCUIOV(DCUTag *tag, const Tm &evenTm) noexcept(false)
RunList fetchNonEmptyRunList(const RunTag &tag, int min_run, int max_run) noexcept(false)
MonRunList fetchMonRunList(const RunTag &tag, const MonRunTag &monruntag) noexcept(false)
void insertLmfDat(LMFDat *dat) noexcept(false)
location
10.6 INPUT and workflows
RunList fetchRunListLastNRuns(const RunTag &tag, int max_run, int n_runs) noexcept(false)
void fetchData(std::vector< ODDelaysDat > *fillMap, int id) noexcept(false)
std::vector< EcalLogicID > getEcalLogicIDMappedTo(int logic_id, std::string maps_to)
RunList fetchNonEmptyGlobalRunList(const RunTag &tag, int min_run, int max_run) noexcept(false)
std::vector< EcalLogicID > getEcalLogicIDForLMPN(int lmr_logic_id)
std::vector< EcalLogicID > getEcalLogicIDSet(std::string name, int fromId1=EcalLogicID::NULLID, int toId1=EcalLogicID::NULLID, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="") noexcept(false)
void updateRunIOV(RunIOV *iov) noexcept(false)
RunIOV fetchRunIOV(RunTag *tag, run_t run) noexcept(false)
void updateRunIOVStartTime(RunIOV *iov) noexcept(false)
MonRunList fetchMonRunListLastNRuns(const RunTag &tag, const MonRunTag &monruntag, int max_run, int n_runs) noexcept(false)
DCSPTMTempList fetchDCSPTMTempList(const EcalLogicID &ecid) noexcept(false)
std::vector< EcalLogicID > getEcalLogicIDSetOrdered(std::string name, int fromId1, int toId1, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="", int orderedBy=EcalLogicID::NULLID) noexcept(false)
std::map< int, int > getEcalLogicID2LmrMap()
void insertRunIOV(RunIOV *iov) noexcept(false)
void setByRun(RunTag *tag, run_t run) noexcept(false)
void insertLmfRunIOV(LMFRunIOV *iov) noexcept(false)
CaliIOV fetchCaliIOV(CaliTag *tag, const Tm &evenTm) noexcept(false)
void setByTm(DCUTag *tag, const Tm &time) noexcept(false)
LMFRunIOV fetchLMFRunIOV(RunTag *runtag, LMFRunTag *lmftag, run_t run, subrun_t lmfrun) noexcept(false)
RunList fetchRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef) noexcept(false)
void updateRunIOVEndTime(RunIOV *iov) noexcept(false)
void fetchData(ODFEDAQConfig *result) noexcept(false)
RunList fetchRunList(const RunTag &tag) noexcept(false)
void insertLmfLmrSubIOV(LMFLmrSubIOV *iov) noexcept(false)
static int const ECALDB_NROWS
void insertLmfIOV(LMFIOV *iov) noexcept(false)
void fillLogicId2DetIdMaps()
void setByTm(CaliTag *tag, const Tm &time) noexcept(false)
void setByRun(MonRunTag *montag, RunIOV *runiov, subrun_t subrun) noexcept(false)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
std::list< LMFRunIOV > fetchLastBeforeSequence(const LMFSeqDat &s, int lmr, int type, int color)
std::vector< EcalLogicID > getEcalLogicIDForLMR(int lmr_logic_id)