26 using namespace oracle::occi;
30 std::vector<EcalLogicID> crystals_EB =
31 getEcalLogicIDSetOrdered(
"EB_crystal_angle",
34 "EB_crystal_number", 4 );
35 std::vector<EcalLogicID> crystals_EE =
36 getEcalLogicIDSetOrdered(
"EE_crystal_number",
39 "EE_crystal_number", 4 );
41 std::vector<EcalLogicID>::const_iterator ieb = crystals_EB.begin();
42 std::vector<EcalLogicID>::const_iterator eeb = crystals_EB.end();
44 int iEta = ieb->getID1();
45 int iPhi = ieb->getID2();
47 _logicId2DetId[ieb->getLogicID()] = ebdetid;
48 _detId2LogicId[ebdetid] = ieb->getLogicID();
53 std::vector<EcalLogicID>::const_iterator iee = crystals_EE.begin();
54 std::vector<EcalLogicID>::const_iterator eee = crystals_EE.end();
57 int iSide = iee->getID1();
58 int iX = iee->getID2();
59 int iY = iee->getID3();
60 EEDetId eedetidpos(iX,iY,iSide);
61 _logicId2DetId[iee->getLogicID()] = eedetidpos;
62 _detId2LogicId[eedetidpos] = iee->getLogicID();
70 throw(std::runtime_error)
73 string sql =
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE logic_id = :logicID AND name=maps_to";
80 stmt->setInt(1, logicID);
84 name = rset->getString(1);
85 logicID = rset->getInt(2);
86 id1 = rset->getInt(3);
88 id2 = rset->getInt(4);
90 id3 = rset->getInt(5);
92 mapsTo = rset->getString(6);
95 msg <<
"ERROR: Cannot build EcalLogicID for logic_id " << logicID;
96 throw(std::runtime_error(msg.str()));
100 throw(std::runtime_error(
"ERROR: Failed to retrive ids: " + e.getMessage() ));
103 return EcalLogicID( name, logicID, id1, id2, id3, mapsTo );
107 throw(std::runtime_error)
109 std::list<ODDelaysDat>
ret;
111 std::map<EcalLogicID, RunFEConfigDat > fillMap;
115 }
catch (std::runtime_error &
e) {
118 std::map<EcalLogicID, RunFEConfigDat >::const_iterator
i = fillMap.begin();
119 std::map<EcalLogicID, RunFEConfigDat >::const_iterator e = fillMap.end();
123 temp.
setId(i->second.getConfigId());
126 std::vector<ODDelaysDat> delays;
130 std::vector<ODDelaysDat>::const_iterator di = delays.begin();
131 std::vector<ODDelaysDat>::const_iterator de = delays.end();
133 ret.push_back(*di++);
145 throw(std::runtime_error)
154 ss <<
"SELECT logic_id FROM channelView WHERE name = :n AND";
155 int idarray[] = {id1, id2, id3};
156 for (
int i=1;
i<=3;
i++) {
158 ss <<
" id"<<
i<<
" IS NULL AND";
160 ss <<
" id"<<
i<<
" = :id"<<
i<<
" AND";
163 ss <<
" maps_to = :m";
169 stmt->setSQL(ss.str());
173 stmt->setString(j,
name);
175 for (
int i=0;
i<3;
i++) {
177 stmt->setInt(j, idarray[
i]);
181 stmt->setString(j, mapsTo);
185 if ( rset->next() ) {
186 logic_id = rset->getInt(1);
189 msg <<
"ERROR: Query for EcalLogicID failed for parameters [" <<
190 "name=" <<
name <<
",maps_to=" << mapsTo <<
191 ",id1=" << id1 <<
",id2=" << id2 <<
",id3=" << id3 <<
"]";
192 throw(std::runtime_error(msg.str()));
195 throw(std::runtime_error(
"ERROR: Failed to retrive logic_id: " + e.getMessage() ));
203 int fromId1,
int toId1,
204 int fromId2,
int toId2,
205 int fromId3,
int toId3,
207 throw(std::runtime_error)
213 int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
217 ss <<
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
220 for (
int i=1;
i<=3;
i++) {
221 from = idArray[2*(
i-1)];
222 to = idArray[2*(
i-1) + 1];
228 throw(std::runtime_error(
"ERROR: Bad arguments for getEcalLogicIDSet"));
233 ss <<
"id" <<
i <<
" IS NULL AND ";
235 ss <<
"id" <<
i <<
" >= :id" <<
i <<
"from AND " <<
236 "id" <<
i <<
" <= :id" <<
i <<
"to AND ";
239 ss <<
"maps_to = :maps_to ORDER BY id1, id2, id3";
241 std::vector<EcalLogicID>
result;
244 stmt->setSQL(ss.str());
248 stmt->setString(j,
name);
251 for (
int i=0;
i<3;
i++) {
253 to = idArray[2*
i + 1];
255 stmt->setInt(j, from);
262 stmt->setString(j, mapsTo);
269 int id1, id2, id3, logicId;
271 while (rset->next()) {
272 name = rset->getString(1);
273 logicId = rset->getInt(2);
274 id1 = rset->getInt(3);
276 id2 = rset->getInt(4);
278 id3 = rset->getInt(5);
280 mapsTo = rset->getString(6);
283 result.push_back(ecid);
285 stmt->setPrefetchRowCount(0);
288 throw(std::runtime_error(
"ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
295 std::map<int, int>
ret;
296 std::vector<EcalLogicID> crystals_EB =
297 getEcalLogicIDSetOrdered(
"EB_crystal_number",
301 std::vector<EcalLogicID> crystals_EE =
302 getEcalLogicIDSetOrdered(
"EE_crystal_number",
306 std::vector<EcalLogicID> EB_lmr =
307 getEcalLogicIDSetOrdered(
"EB_crystal_number",
311 std::vector<EcalLogicID> EE_lmr =
312 getEcalLogicIDSetOrdered(
"EE_crystal_number",
316 unsigned int neb = crystals_EB.size();
317 unsigned int nee = crystals_EE.size();
318 if (neb != EB_lmr.size()) {
319 throw(std::runtime_error(
"ERROR: EB Vectors size do not agree"));
321 if (nee != EE_lmr.size()) {
322 throw(std::runtime_error(
"ERROR: EE Vectors size do not agree"));
324 for (
unsigned int i = 0;
i < neb;
i++) {
325 ret[crystals_EB[
i].getLogicID()] = EB_lmr[
i].getLogicID() % 100;
327 for (
unsigned int i = 0;
i < nee;
i++) {
328 ret[crystals_EE[
i].getLogicID()] = EE_lmr[
i].getLogicID() % 100;
335 std::string sql =
"SELECT LOGIC_ID, ID1, ID2, ID3 "
336 "FROM CHANNELVIEW WHERE NAME = 'EB_crystal_angle' AND LOGIC_ID IN "
337 "(SELECT LOGIC_ID FROM CHANNELVIEW WHERE NAME = 'EB_crystal_number' AND "
338 "ID1*10000+ID2 IN (SELECT DISTINCT ID1*10000+ID2 FROM CHANNELVIEW "
339 "WHERE LOGIC_ID = :1 AND NAME = 'EB_crystal_number' AND MAPS_TO = :2) "
340 "AND NAME = MAPS_TO)";
341 if ((lmr_logic_id / 1000000000) == 2) {
342 name =
"EE_crystal_number";
343 sql =
"SELECT LOGIC_ID, ID1, ID2, ID3 "
344 "FROM CHANNELVIEW WHERE NAME = 'EE_crystal_number' AND LOGIC_ID IN "
345 "(SELECT LOGIC_ID FROM CHANNELVIEW WHERE NAME = 'EE_crystal_number' AND "
346 "ID1*10000000+ID2*10000+ID3 IN (SELECT DISTINCT "
347 "ID1*10000000+ID2*10000+ID3 FROM CHANNELVIEW "
348 "WHERE LOGIC_ID = :1 AND NAME = 'EE_crystal_number' AND MAPS_TO = :2) "
349 "AND NAME = MAPS_TO) AND NAME = MAPS_TO";
351 std::vector<EcalLogicID>
ret;
353 stmt->setSQL(sql.c_str());
354 stmt->setInt(1, lmr_logic_id);
355 stmt->setString(2, maps_to);
360 while (rset->next()) {
361 int logic_id = rset->getInt(1);
362 int id1 = rset->getInt(2);
364 int id2 = rset->getInt(3);
366 int id3 = rset->getInt(4);
372 stmt->setPrefetchRowCount(0);
375 throw(std::runtime_error(
"ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
381 return getEcalLogicIDMappedTo(lmr,
"ECAL_LMR");
385 return getEcalLogicIDForLMR(lmr.
getLogicID());
389 if ((lmr / 1000000000) == 2) {
390 return getEcalLogicIDMappedTo(lmr,
"EE_LM_PN");
392 return getEcalLogicIDMappedTo(lmr,
"EB_LM_PN");
397 return getEcalLogicIDForLMR(lmr.
getLogicID());
401 int fromId1,
int toId1,
402 int fromId2,
int toId2,
403 int fromId3,
int toId3,
404 string mapsTo,
int orderedBy )
407 throw(std::runtime_error)
413 int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
417 ss <<
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
420 for (
int i=1;
i<=3;
i++) {
421 from = idArray[2*(
i-1)];
422 to = idArray[2*(
i-1) + 1];
428 throw(std::runtime_error(
"ERROR: Bad arguments for getEcalLogicIDSet"));
433 ss <<
"id" <<
i <<
" IS NULL AND ";
435 ss <<
"id" <<
i <<
" >= :id" <<
i <<
"from AND " <<
436 "id" <<
i <<
" <= :id" <<
i <<
"to AND ";
439 ss <<
"maps_to = :maps_to ";
442 ss<<
" ORDER BY id1, id2, id3";
443 }
else if(orderedBy==1 || orderedBy==12 || orderedBy==123){
444 ss<<
" ORDER BY id1, id2, id3 ";
445 }
else if (orderedBy==213 || orderedBy==21 ){
446 ss<<
" ORDER BY id2, id1, id3 ";
447 }
else if (orderedBy==231|| orderedBy==23){
448 ss<<
" ORDER BY id2, id3, id1 ";
449 }
else if (orderedBy==321|| orderedBy==32){
450 ss<<
" ORDER BY id3, id2, id1 ";
451 }
else if (orderedBy==312|| orderedBy==31){
452 ss<<
" ORDER BY id3, id1, id2 ";
453 }
else if (orderedBy==132|| orderedBy==13){
454 ss<<
" ORDER BY id1, id3, id2 ";
455 }
else if (orderedBy==1234 ){
456 ss<<
" ORDER BY id1, id2, id3, logic_id ";
457 }
else if (orderedBy==4) {
458 ss<<
" ORDER BY logic_id ";
460 ss<<
" ORDER BY id1, id2, id3";
463 std::vector<EcalLogicID>
result;
466 stmt->setSQL(ss.str());
470 stmt->setString(j,
name);
473 for (
int i=0;
i<3;
i++) {
475 to = idArray[2*
i + 1];
477 stmt->setInt(j, from);
484 stmt->setString(j, mapsTo);
491 int id1, id2, id3, logicId;
493 while (rset->next()) {
494 name = rset->getString(1);
495 logicId = rset->getInt(2);
496 id1 = rset->getInt(3);
498 id2 = rset->getInt(4);
500 id3 = rset->getInt(5);
502 mapsTo = rset->getString(6);
505 result.push_back(ecid);
507 stmt->setPrefetchRowCount(0);
510 throw(std::runtime_error(
"ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
519 throw(std::runtime_error)
524 }
catch(std::runtime_error &e) {
532 throw(std::runtime_error)
537 }
catch(std::runtime_error &e) {
545 throw(std::runtime_error)
550 }
catch(std::runtime_error &e) {
558 throw(std::runtime_error)
563 }
catch(std::runtime_error &e) {
571 throw(std::runtime_error)
576 }
catch(std::runtime_error &e) {
584 throw(std::runtime_error)
587 std::list<LMFDat *>::iterator
i = dat.begin();
588 std::list<LMFDat *>::iterator e = dat.end();
590 (*i)->setConnection(
env,
conn);
594 }
catch(std::runtime_error &e) {
602 throw(std::runtime_error)
607 }
catch(std::runtime_error &e) {
615 throw(std::runtime_error)
619 iov->updateEndTimeDB();
620 }
catch(std::runtime_error &e) {
628 throw(std::runtime_error)
632 iov->updateEndTimeDB();
633 }
catch(std::runtime_error &e) {
641 throw(std::runtime_error)
645 iov->updateStartTimeDB();
646 }
catch(std::runtime_error &e) {
654 throw(std::runtime_error)
658 od->updateDefaultCycle();
659 }
catch(std::runtime_error &e) {
667 throw(std::runtime_error)
678 throw(std::runtime_error)
687 throw(std::runtime_error)
696 throw(std::runtime_error)
701 }
catch(std::runtime_error &e) {
709 throw(std::runtime_error)
714 }
catch(std::runtime_error &e) {
725 throw(std::runtime_error)
727 RunIOV runiov = fetchRunIOV(runtag,
run);
730 moniov.
setByRun(montag, &runiov, subrun);
737 throw(std::runtime_error)
751 throw(std::runtime_error)
753 RunIOV runiov = fetchRunIOV(runtag,
run);
765 int s = iovlist.size();
767 iov = iovlist.front();
771 std::cout <<
"################################" << std::endl;
772 std::cout <<
"################################" << std::endl;
773 std::cout <<
"WARNING: More than one LMFRUNIOV" << std::endl;
775 std::cout <<
" lmr " << lmr <<
" type " << type << std::endl;
776 std::cout <<
" and color " << color << std::endl;
777 std::cout <<
"################################" << std::endl;
778 std::cout <<
"################################" << std::endl;
785 iov = iovlist.front();
792 throw(std::runtime_error)
801 throw(std::runtime_error)
810 throw(std::runtime_error)
819 throw(std::runtime_error)
853 throw(std::runtime_error) {
862 throw(std::runtime_error) {
871 throw(std::runtime_error){
885 throw(std::runtime_error)
896 throw(std::runtime_error)
907 throw(std::runtime_error)
DCUIOV fetchDCUIOV(DCUTag *tag, const Tm &evenTm)
void setByTime(std::string location, const Tm &t)
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="")
RunList fetchRunList(const RunTag &tag)
tuple start
Check for commandline option errors.
RunList fetchRunListLastNRuns(const RunTag &tag, int max_run, int n_runs)
void insertRunIOV(RunIOV *iov)
std::list< LMFRunIOV > fetchBySequence(const LMFSeqDat &s)
void setByTm(DCUTag *tag, const Tm &time)
std::list< ODDelaysDat > fetchFEDelaysForRun(RunIOV *iov)
void setRunTag(const RunTag &tag)
void fetchLastNRuns(int max_run, int n_runs)
void insertLmfDat(LMFDat *dat)
RunIOV fetchRunIOV(RunTag *tag, run_t run)
void fetchData(ODFEDAQConfig *result)
void updateRunIOVStartTime(RunIOV *iov)
void setByTm(CaliTag *tag, const Tm &time)
void insertLmfSeq(LMFSeqDat *iov)
std::vector< EcalLogicID > getEcalLogicIDMappedTo(int logic_id, std::string maps_to)
MonRunList fetchMonRunList(const RunTag &tag, const MonRunTag &monruntag)
oracle::occi::SQLException SQLException
LMFRunIOV fetchLMFRunIOV(RunTag *runtag, LMFRunTag *lmftag, run_t run, subrun_t lmfrun)
std::vector< EcalLogicID > getEcalLogicIDForLMPN(int lmr_logic_id)
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)
void setRunTag(const RunTag &tag)
void setByRun(RunTag *tag, run_t run)
void setByRun(MonRunTag *montag, RunIOV *runiov, subrun_t subrun)
MonRunList fetchMonRunListLastNRuns(const RunTag &tag, const MonRunTag &monruntag, int max_run, int n_runs)
void fetchData(std::map< EcalLogicID, RunFEConfigDat > *fillMap, RunIOV *iov)
std::map< int, int > getEcalLogicID2LmrMap()
RunList fetchGlobalRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef)
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 insertLmfRunIOV(LMFRunIOV *iov)
RunList fetchNonEmptyGlobalRunList(const RunTag &tag, int min_run, int max_run)
void fetchRunsByLocation(int min_run, int max_run, const LocationDef &locDef)
void insertLmfIOV(LMFIOV *iov)
void updateRunConfig(ODRunConfigInfo *od)
DCSPTMTempList fetchDCSPTMTempList(const EcalLogicID &ecid)
void fetchLastNRuns(int max_run, int n_runs)
void fetchGlobalRunsByLocation(int min_run, int max_run, const LocationDef &locDef)
oracle::occi::ResultSet ResultSet
void fetchValuesForECIDAndTime(const EcalLogicID &ecid, const Tm &start, const Tm &end)
void setMonRunTag(const MonRunTag &tag)
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun)
static int const ECALDB_NROWS
void insertMonRunIOV(MonRunIOV *iov)
CaliIOV fetchCaliIOV(CaliTag *tag, const Tm &evenTm)
void fillLogicId2DetIdMaps()
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)
std::vector< EcalLogicID > getEcalLogicIDForLMR(int lmr_logic_id)
RunList fetchNonEmptyRunList(const RunTag &tag, int min_run, int max_run)
void fetchData(std::vector< ODDelaysDat > *fillMap, int id)
void insertLmfLmrSubIOV(LMFLmrSubIOV *iov)
void fetchNonEmptyGlobalRuns()
void fetchValuesForECID(const EcalLogicID &ecid)
RunList fetchRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef)