27 using namespace oracle::occi;
31 throw(std::runtime_error)
34 string sql =
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE logic_id = :logicID AND name=maps_to";
41 stmt->setInt(1, logicID);
45 name = rset->getString(1);
46 logicID = rset->getInt(2);
47 id1 = rset->getInt(3);
49 id2 = rset->getInt(4);
51 id3 = rset->getInt(5);
53 mapsTo = rset->getString(6);
56 msg <<
"ERROR: Cannot build EcalLogicID for logic_id " << logicID;
57 throw(std::runtime_error(msg.str()));
61 throw(std::runtime_error(
"ERROR: Failed to retrive ids: " + e.getMessage() ));
64 return EcalLogicID( name, logicID, id1, id2, id3, mapsTo );
74 throw(std::runtime_error)
83 ss <<
"SELECT logic_id FROM channelView WHERE name = :n AND";
84 int idarray[] = {id1, id2, id3};
85 for (
int i=1;
i<=3;
i++) {
87 ss <<
" id"<<
i<<
" IS NULL AND";
89 ss <<
" id"<<
i<<
" = :id"<<
i<<
" AND";
98 stmt->setSQL(ss.str());
102 stmt->setString(j,
name);
104 for (
int i=0;
i<3;
i++) {
106 stmt->setInt(j, idarray[
i]);
110 stmt->setString(j, mapsTo);
114 if ( rset->next() ) {
115 logic_id = rset->getInt(1);
118 msg <<
"ERROR: Query for EcalLogicID failed for parameters [" <<
119 "name=" <<
name <<
",maps_to=" << mapsTo <<
120 ",id1=" << id1 <<
",id2=" << id2 <<
",id3=" << id3 <<
"]";
121 throw(std::runtime_error(msg.str()));
124 throw(std::runtime_error(
"ERROR: Failed to retrive logic_id: " + e.getMessage() ));
132 int fromId1,
int toId1,
133 int fromId2,
int toId2,
134 int fromId3,
int toId3,
136 throw(std::runtime_error)
142 int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
146 ss <<
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
149 for (
int i=1;
i<=3;
i++) {
150 from = idArray[2*(
i-1)];
151 to = idArray[2*(
i-1) + 1];
157 throw(std::runtime_error(
"ERROR: Bad arguments for getEcalLogicIDSet"));
162 ss <<
"id" <<
i <<
" IS NULL AND ";
164 ss <<
"id" <<
i <<
" >= :id" <<
i <<
"from AND " <<
165 "id" <<
i <<
" <= :id" <<
i <<
"to AND ";
168 ss <<
"maps_to = :maps_to ORDER BY id1, id2, id3";
170 std::vector<EcalLogicID>
result;
173 stmt->setSQL(ss.str());
177 stmt->setString(j,
name);
180 for (
int i=0;
i<3;
i++) {
182 to = idArray[2*
i + 1];
184 stmt->setInt(j, from);
191 stmt->setString(j, mapsTo);
198 int id1, id2, id3, logicId;
200 while (rset->next()) {
201 name = rset->getString(1);
202 logicId = rset->getInt(2);
203 id1 = rset->getInt(3);
205 id2 = rset->getInt(4);
207 id3 = rset->getInt(5);
209 mapsTo = rset->getString(6);
212 result.push_back(ecid);
214 stmt->setPrefetchRowCount(0);
217 throw(std::runtime_error(
"ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
224 std::map<int, int>
ret;
225 std::vector<EcalLogicID> crystals_EB =
226 getEcalLogicIDSetOrdered(
"EB_crystal_number",
230 std::vector<EcalLogicID> crystals_EE =
231 getEcalLogicIDSetOrdered(
"EE_crystal_number",
235 std::vector<EcalLogicID> EB_lmr =
236 getEcalLogicIDSetOrdered(
"EB_crystal_number",
240 std::vector<EcalLogicID> EE_lmr =
241 getEcalLogicIDSetOrdered(
"EE_crystal_number",
245 unsigned int neb = crystals_EB.size();
246 unsigned int nee = crystals_EE.size();
247 if (neb != EB_lmr.size()) {
248 throw(std::runtime_error(
"ERROR: EB Vectors size do not agree"));
250 if (nee != EE_lmr.size()) {
251 throw(std::runtime_error(
"ERROR: EE Vectors size do not agree"));
253 for (
unsigned int i = 0;
i < neb;
i++) {
254 ret[crystals_EB[
i].getLogicID()] = EB_lmr[
i].getLogicID() % 100;
256 for (
unsigned int i = 0;
i < nee;
i++) {
257 ret[crystals_EE[
i].getLogicID()] = EE_lmr[
i].getLogicID() % 100;
263 int fromId1,
int toId1,
264 int fromId2,
int toId2,
265 int fromId3,
int toId3,
266 string mapsTo,
int orderedBy )
269 throw(std::runtime_error)
275 int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
279 ss <<
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
282 for (
int i=1;
i<=3;
i++) {
283 from = idArray[2*(
i-1)];
284 to = idArray[2*(
i-1) + 1];
290 throw(std::runtime_error(
"ERROR: Bad arguments for getEcalLogicIDSet"));
295 ss <<
"id" <<
i <<
" IS NULL AND ";
297 ss <<
"id" <<
i <<
" >= :id" <<
i <<
"from AND " <<
298 "id" <<
i <<
" <= :id" <<
i <<
"to AND ";
301 ss <<
"maps_to = :maps_to ";
304 ss<<
" ORDER BY id1, id2, id3";
305 }
else if(orderedBy==1 || orderedBy==12 || orderedBy==123){
306 ss<<
" ORDER BY id1, id2, id3 ";
307 }
else if (orderedBy==213 || orderedBy==21 ){
308 ss<<
" ORDER BY id2, id1, id3 ";
309 }
else if (orderedBy==231|| orderedBy==23){
310 ss<<
" ORDER BY id2, id3, id1 ";
311 }
else if (orderedBy==321|| orderedBy==32){
312 ss<<
" ORDER BY id3, id2, id1 ";
313 }
else if (orderedBy==312|| orderedBy==31){
314 ss<<
" ORDER BY id3, id1, id2 ";
315 }
else if (orderedBy==132|| orderedBy==13){
316 ss<<
" ORDER BY id1, id3, id2 ";
317 }
else if (orderedBy==1234 ){
318 ss<<
" ORDER BY id1, id2, id3, logic_id ";
319 }
else if (orderedBy==4) {
320 ss<<
" ORDER BY logic_id ";
322 ss<<
" ORDER BY id1, id2, id3";
325 std::vector<EcalLogicID>
result;
328 stmt->setSQL(ss.str());
332 stmt->setString(j,
name);
335 for (
int i=0;
i<3;
i++) {
337 to = idArray[2*
i + 1];
339 stmt->setInt(j, from);
346 stmt->setString(j, mapsTo);
353 int id1, id2, id3, logicId;
355 while (rset->next()) {
356 name = rset->getString(1);
357 logicId = rset->getInt(2);
358 id1 = rset->getInt(3);
360 id2 = rset->getInt(4);
362 id3 = rset->getInt(5);
364 mapsTo = rset->getString(6);
367 result.push_back(ecid);
369 stmt->setPrefetchRowCount(0);
372 throw(std::runtime_error(
"ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
381 throw(std::runtime_error)
384 iov->setConnection(env, conn);
386 }
catch(std::runtime_error &e) {
394 throw(std::runtime_error)
397 iov->setConnection(env, conn);
399 }
catch(std::runtime_error &e) {
407 throw(std::runtime_error)
410 iov->setConnection(env, conn);
412 }
catch(std::runtime_error &e) {
420 throw(std::runtime_error)
423 iov->setConnection(env, conn);
425 }
catch(std::runtime_error &e) {
433 throw(std::runtime_error)
436 dat->setConnection(env, conn);
438 }
catch(std::runtime_error &e) {
446 throw(std::runtime_error)
449 std::list<LMFDat *>::iterator
i = dat.begin();
450 std::list<LMFDat *>::iterator e = dat.end();
452 (*i)->setConnection(env, conn);
456 }
catch(std::runtime_error &e) {
464 throw(std::runtime_error)
467 iov->setConnection(env, conn);
469 }
catch(std::runtime_error &e) {
477 throw(std::runtime_error)
480 iov->setConnection(env, conn);
481 iov->updateEndTimeDB();
482 }
catch(std::runtime_error &e) {
490 throw(std::runtime_error)
493 iov->setConnection(env, conn);
494 iov->updateEndTimeDB();
495 }
catch(std::runtime_error &e) {
503 throw(std::runtime_error)
506 iov->setConnection(env, conn);
507 iov->updateStartTimeDB();
508 }
catch(std::runtime_error &e) {
516 throw(std::runtime_error)
519 od->setConnection(env, conn);
520 od->updateDefaultCycle();
521 }
catch(std::runtime_error &e) {
529 throw(std::runtime_error)
540 throw(std::runtime_error)
552 throw(std::runtime_error)
555 iov->setConnection(env, conn);
557 }
catch(std::runtime_error &e) {
565 throw(std::runtime_error)
568 iov->setConnection(env, conn);
570 }
catch(std::runtime_error &e) {
581 throw(std::runtime_error)
583 RunIOV runiov = fetchRunIOV(runtag,
run);
586 moniov.
setByRun(montag, &runiov, subrun);
593 throw(std::runtime_error)
607 throw(std::runtime_error)
609 RunIOV runiov = fetchRunIOV(runtag,
run);
617 int lmr,
int type,
int color )
const {
621 int s = iovlist.size();
623 iov = iovlist.front();
627 std::cout <<
"################################" << std::endl;
628 std::cout <<
"################################" << std::endl;
629 std::cout <<
"WARNING: More than one LMFRUNIOV" << std::endl;
631 std::cout <<
" lmr " << lmr <<
" type " << type << std::endl;
632 std::cout <<
" and color " << color << std::endl;
633 std::cout <<
"################################" << std::endl;
634 std::cout <<
"################################" << std::endl;
641 iov = iovlist.front();
648 throw(std::runtime_error)
657 throw(std::runtime_error)
666 throw(std::runtime_error)
675 throw(std::runtime_error)
693 throw(std::runtime_error) {
702 throw(std::runtime_error) {
711 throw(std::runtime_error){
725 throw(std::runtime_error)
736 throw(std::runtime_error)
747 throw(std::runtime_error)
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="")
void insertRunIOV(RunIOV *iov)
std::list< LMFRunIOV > fetchBySequence(const LMFSeqDat &s)
void setByTm(DCUTag *tag, Tm time)
void setRunTag(RunTag tag)
RunList fetchRunListByLocation(RunTag tag, int min_run, int max_run, const LocationDef locDef)
DCSPTMTempList fetchDCSPTMTempList(EcalLogicID ecid)
void fetchLastNRuns(int max_run, int n_runs)
void insertLmfDat(LMFDat *dat)
RunIOV fetchRunIOV(RunTag *tag, run_t run)
void updateRunIOVStartTime(RunIOV *iov)
void insertLmfSeq(LMFSeqDat *iov)
oracle::occi::SQLException SQLException
void setRunTag(RunTag tag)
DCUIOV fetchDCUIOV(DCUTag *tag, Tm evenTm)
LMFRunIOV fetchLMFRunIOV(RunTag *runtag, LMFRunTag *lmftag, run_t run, subrun_t lmfrun)
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)
CaliIOV fetchCaliIOV(CaliTag *tag, Tm evenTm)
void setByRun(RunTag *tag, run_t run)
RunList fetchGlobalRunListByLocation(RunTag tag, int min_run, int max_run, const LocationDef locDef)
void setByRun(MonRunTag *montag, RunIOV *runiov, subrun_t subrun)
RunList fetchRunList(RunTag tag)
MonRunList fetchMonRunListLastNRuns(RunTag tag, MonRunTag monruntag, int max_run, int n_runs)
std::map< int, int > getEcalLogicID2LmrMap()
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="")
RunIOV fetchLMFLastRun() const
void insertDCUIOV(DCUIOV *iov)
void fetchValuesForECIDAndTime(EcalLogicID ecid, Tm start, Tm end)
void insertLmfRunIOV(LMFRunIOV *iov)
void insertLmfIOV(LMFIOV *iov)
void updateRunConfig(ODRunConfigInfo *od)
void fetchGlobalRunsByLocation(int min_run, int max_run, const LocationDef locDef)
static std::string from(" from ")
MonRunList fetchMonRunList(RunTag tag, MonRunTag monruntag)
void fetchLastNRuns(int max_run, int n_runs)
oracle::occi::ResultSet ResultSet
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun)
static int const ECALDB_NROWS
void fetchValuesForECID(EcalLogicID ecid)
RunList fetchRunListLastNRuns(RunTag tag, int max_run, int n_runs)
void fetchRunsByLocation(int min_run, int max_run, const LocationDef locDef)
void insertMonRunIOV(MonRunIOV *iov)
void setMonRunTag(MonRunTag tag)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
void updateRunIOV(RunIOV *iov)
std::list< LMFRunIOV > fetchLastBeforeSequence(const LMFSeqDat &s, int lmr, int type, int color)
void updateRunIOVEndTime(RunIOV *iov)
void insertLmfLmrSubIOV(LMFLmrSubIOV *iov)
void setByTm(CaliTag *tag, Tm time)