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();
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 );
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++);
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,
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 )
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() ));
522 iov->setConnection(
env, conn);
524 }
catch(std::runtime_error &
e) {
535 iov->setConnection(
env, conn);
537 }
catch(std::runtime_error &
e) {
548 iov->setConnection(
env, conn);
550 }
catch(std::runtime_error &
e) {
561 iov->setConnection(
env, conn);
563 }
catch(std::runtime_error &
e) {
574 dat->setConnection(
env, conn);
576 }
catch(std::runtime_error &
e) {
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) {
605 iov->setConnection(
env, conn);
607 }
catch(std::runtime_error &
e) {
618 iov->setConnection(
env, conn);
619 iov->updateEndTimeDB();
620 }
catch(std::runtime_error &
e) {
631 iov->setConnection(
env, conn);
632 iov->updateEndTimeDB();
633 }
catch(std::runtime_error &
e) {
644 iov->setConnection(
env, conn);
645 iov->updateStartTimeDB();
646 }
catch(std::runtime_error &
e) {
657 od->setConnection(
env, conn);
658 od->updateDefaultCycle();
659 }
catch(std::runtime_error &
e) {
699 iov->setConnection(
env, conn);
701 }
catch(std::runtime_error &
e) {
712 iov->setConnection(
env, conn);
714 }
catch(std::runtime_error &
e) {
727 RunIOV runiov = fetchRunIOV(runtag,
run);
730 moniov.
setByRun(montag, &runiov, subrun);
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();
void insertLmfSeq(LMFSeqDat *iov) noexcept(false)
void setByTime(std::string location, const Tm &t) noexcept(false)
void fetchRuns() 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)
void setRunTag(const RunTag &tag)
void updateRunConfig(ODRunConfigInfo *od) noexcept(false)
void fetchRunsByLocation(int min_run, int max_run, const LocationDef &locDef) noexcept(false)
void insertDCUIOV(DCUIOV *iov) noexcept(false)
std::list< ODDelaysDat > fetchFEDelaysForRun(RunIOV *iov) noexcept(false)
DCUIOV fetchDCUIOV(DCUTag *tag, const Tm &evenTm) noexcept(false)
void fetchLastNRuns(int max_run, int n_runs) 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)
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)
oracle::occi::SQLException SQLException
RunList fetchNonEmptyGlobalRunList(const RunTag &tag, int min_run, int max_run) noexcept(false)
void fetchNonEmptyRuns() noexcept(false)
std::vector< EcalLogicID > getEcalLogicIDForLMPN(int lmr_logic_id)
void setRunTag(const RunTag &tag)
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()
RunIOV fetchLMFLastRun() const
void fetchValuesForECID(const EcalLogicID &ecid) noexcept(false)
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)
void fetchRuns() 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)
oracle::occi::ResultSet ResultSet
void setMonRunTag(const MonRunTag &tag)
void insertLmfLmrSubIOV(LMFLmrSubIOV *iov) noexcept(false)
static int const ECALDB_NROWS
void fetchLastNRuns(int max_run, int n_runs) noexcept(false)
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)
void fetchData(std::map< EcalLogicID, RunFEConfigDat > *fillMap, RunIOV *iov) noexcept(false)
void fetchNonEmptyGlobalRuns() noexcept(false)
void fetchValuesForECIDAndTime(const EcalLogicID &ecid, const Tm &start, const Tm &end) noexcept(false)
void fetchGlobalRunsByLocation(int min_run, int max_run, const LocationDef &locDef) noexcept(false)