27 using namespace oracle::occi;
31 std::vector<EcalLogicID> crystals_EB =
32 getEcalLogicIDSetOrdered(
"EB_crystal_angle",
35 "EB_crystal_number", 4 );
36 std::vector<EcalLogicID> crystals_EE =
37 getEcalLogicIDSetOrdered(
"EE_crystal_number",
40 "EE_crystal_number", 4 );
42 std::vector<EcalLogicID>::const_iterator ieb = crystals_EB.begin();
43 std::vector<EcalLogicID>::const_iterator eeb = crystals_EB.end();
45 int iEta = ieb->getID1();
46 int iPhi = ieb->getID2();
48 _logicId2DetId[ieb->getLogicID()] = ebdetid;
49 _detId2LogicId[ebdetid] = ieb->getLogicID();
54 std::vector<EcalLogicID>::const_iterator iee = crystals_EE.begin();
55 std::vector<EcalLogicID>::const_iterator eee = crystals_EE.end();
58 int iSide = iee->getID1();
59 int iX = iee->getID2();
60 int iY = iee->getID3();
61 EEDetId eedetidpos(iX,iY,iSide);
62 _logicId2DetId[iee->getLogicID()] = eedetidpos;
63 _detId2LogicId[eedetidpos] = iee->getLogicID();
71 throw(std::runtime_error)
74 string sql =
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE logic_id = :logicID AND name=maps_to";
81 stmt->setInt(1, logicID);
85 name = rset->getString(1);
86 logicID = rset->getInt(2);
87 id1 = rset->getInt(3);
89 id2 = rset->getInt(4);
91 id3 = rset->getInt(5);
93 mapsTo = rset->getString(6);
96 msg <<
"ERROR: Cannot build EcalLogicID for logic_id " << logicID;
97 throw(std::runtime_error(msg.str()));
101 throw(std::runtime_error(
"ERROR: Failed to retrive ids: " + e.getMessage() ));
104 return EcalLogicID( name, logicID, id1, id2, id3, mapsTo );
108 throw(std::runtime_error)
110 std::list<ODDelaysDat>
ret;
112 std::map<EcalLogicID, RunFEConfigDat >
fillMap;
116 }
catch (std::runtime_error &
e) {
119 std::map<EcalLogicID, RunFEConfigDat >::const_iterator
i = fillMap.begin();
120 std::map<EcalLogicID, RunFEConfigDat >::const_iterator e = fillMap.end();
124 temp.
setId(i->second.getConfigId());
127 std::vector<ODDelaysDat> delays;
131 std::vector<ODDelaysDat>::const_iterator di = delays.begin();
132 std::vector<ODDelaysDat>::const_iterator de = delays.end();
134 ret.push_back(*di++);
146 throw(std::runtime_error)
155 ss <<
"SELECT logic_id FROM channelView WHERE name = :n AND";
156 int idarray[] = {id1, id2, id3};
157 for (
int i=1;
i<=3;
i++) {
159 ss <<
" id"<<
i<<
" IS NULL AND";
161 ss <<
" id"<<
i<<
" = :id"<<
i<<
" AND";
164 ss <<
" maps_to = :m";
170 stmt->setSQL(ss.str());
174 stmt->setString(j,
name);
176 for (
int i=0;
i<3;
i++) {
178 stmt->setInt(j, idarray[
i]);
182 stmt->setString(j, mapsTo);
186 if ( rset->next() ) {
187 logic_id = rset->getInt(1);
190 msg <<
"ERROR: Query for EcalLogicID failed for parameters [" <<
191 "name=" <<
name <<
",maps_to=" << mapsTo <<
192 ",id1=" << id1 <<
",id2=" << id2 <<
",id3=" << id3 <<
"]";
193 throw(std::runtime_error(msg.str()));
196 throw(std::runtime_error(
"ERROR: Failed to retrive logic_id: " + e.getMessage() ));
204 int fromId1,
int toId1,
205 int fromId2,
int toId2,
206 int fromId3,
int toId3,
208 throw(std::runtime_error)
214 int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
218 ss <<
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
221 for (
int i=1;
i<=3;
i++) {
222 from = idArray[2*(
i-1)];
223 to = idArray[2*(
i-1) + 1];
229 throw(std::runtime_error(
"ERROR: Bad arguments for getEcalLogicIDSet"));
234 ss <<
"id" <<
i <<
" IS NULL AND ";
236 ss <<
"id" <<
i <<
" >= :id" <<
i <<
"from AND " <<
237 "id" <<
i <<
" <= :id" <<
i <<
"to AND ";
240 ss <<
"maps_to = :maps_to ORDER BY id1, id2, id3";
242 std::vector<EcalLogicID>
result;
245 stmt->setSQL(ss.str());
249 stmt->setString(j,
name);
252 for (
int i=0;
i<3;
i++) {
254 to = idArray[2*
i + 1];
256 stmt->setInt(j, from);
263 stmt->setString(j, mapsTo);
270 int id1, id2, id3, logicId;
272 while (rset->next()) {
273 name = rset->getString(1);
274 logicId = rset->getInt(2);
275 id1 = rset->getInt(3);
277 id2 = rset->getInt(4);
279 id3 = rset->getInt(5);
281 mapsTo = rset->getString(6);
284 result.push_back(ecid);
286 stmt->setPrefetchRowCount(0);
289 throw(std::runtime_error(
"ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
296 std::map<int, int>
ret;
297 std::vector<EcalLogicID> crystals_EB =
298 getEcalLogicIDSetOrdered(
"EB_crystal_number",
302 std::vector<EcalLogicID> crystals_EE =
303 getEcalLogicIDSetOrdered(
"EE_crystal_number",
307 std::vector<EcalLogicID> EB_lmr =
308 getEcalLogicIDSetOrdered(
"EB_crystal_number",
312 std::vector<EcalLogicID> EE_lmr =
313 getEcalLogicIDSetOrdered(
"EE_crystal_number",
317 unsigned int neb = crystals_EB.size();
318 unsigned int nee = crystals_EE.size();
319 if (neb != EB_lmr.size()) {
320 throw(std::runtime_error(
"ERROR: EB Vectors size do not agree"));
322 if (nee != EE_lmr.size()) {
323 throw(std::runtime_error(
"ERROR: EE Vectors size do not agree"));
325 for (
unsigned int i = 0;
i < neb;
i++) {
326 ret[crystals_EB[
i].getLogicID()] = EB_lmr[
i].getLogicID() % 100;
328 for (
unsigned int i = 0;
i < nee;
i++) {
329 ret[crystals_EE[
i].getLogicID()] = EE_lmr[
i].getLogicID() % 100;
336 std::string sql =
"SELECT LOGIC_ID, ID1, ID2, ID3 "
337 "FROM CHANNELVIEW WHERE NAME = 'EB_crystal_angle' AND LOGIC_ID IN "
338 "(SELECT LOGIC_ID FROM CHANNELVIEW WHERE NAME = 'EB_crystal_number' AND "
339 "ID1*10000+ID2 IN (SELECT DISTINCT ID1*10000+ID2 FROM CHANNELVIEW "
340 "WHERE LOGIC_ID = :1 AND NAME = 'EB_crystal_number' AND MAPS_TO = :2) "
341 "AND NAME = MAPS_TO)";
342 if ((lmr_logic_id / 1000000000) == 2) {
343 name =
"EE_crystal_number";
344 sql =
"SELECT LOGIC_ID, ID1, ID2, ID3 "
345 "FROM CHANNELVIEW WHERE NAME = 'EE_crystal_number' AND LOGIC_ID IN "
346 "(SELECT LOGIC_ID FROM CHANNELVIEW WHERE NAME = 'EE_crystal_number' AND "
347 "ID1*10000000+ID2*10000+ID3 IN (SELECT DISTINCT "
348 "ID1*10000000+ID2*10000+ID3 FROM CHANNELVIEW "
349 "WHERE LOGIC_ID = :1 AND NAME = 'EE_crystal_number' AND MAPS_TO = :2) "
350 "AND NAME = MAPS_TO) AND NAME = MAPS_TO";
352 std::vector<EcalLogicID>
ret;
354 stmt->setSQL(sql.c_str());
355 stmt->setInt(1, lmr_logic_id);
356 stmt->setString(2, maps_to);
361 while (rset->next()) {
362 int logic_id = rset->getInt(1);
363 int id1 = rset->getInt(2);
365 int id2 = rset->getInt(3);
367 int id3 = rset->getInt(4);
373 stmt->setPrefetchRowCount(0);
376 throw(std::runtime_error(
"ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
382 return getEcalLogicIDMappedTo(lmr,
"ECAL_LMR");
386 return getEcalLogicIDForLMR(lmr.
getLogicID());
390 if ((lmr / 1000000000) == 2) {
391 return getEcalLogicIDMappedTo(lmr,
"EE_LM_PN");
393 return getEcalLogicIDMappedTo(lmr,
"EB_LM_PN");
398 return getEcalLogicIDForLMR(lmr.
getLogicID());
402 int fromId1,
int toId1,
403 int fromId2,
int toId2,
404 int fromId3,
int toId3,
405 string mapsTo,
int orderedBy )
408 throw(std::runtime_error)
414 int idArray[] = { fromId1, toId1, fromId2, toId2, fromId3, toId3 };
418 ss <<
"SELECT name, logic_id, id1, id2, id3, maps_to FROM channelView WHERE name = :name AND ";
421 for (
int i=1;
i<=3;
i++) {
422 from = idArray[2*(
i-1)];
423 to = idArray[2*(
i-1) + 1];
429 throw(std::runtime_error(
"ERROR: Bad arguments for getEcalLogicIDSet"));
434 ss <<
"id" <<
i <<
" IS NULL AND ";
436 ss <<
"id" <<
i <<
" >= :id" <<
i <<
"from AND " <<
437 "id" <<
i <<
" <= :id" <<
i <<
"to AND ";
440 ss <<
"maps_to = :maps_to ";
443 ss<<
" ORDER BY id1, id2, id3";
444 }
else if(orderedBy==1 || orderedBy==12 || orderedBy==123){
445 ss<<
" ORDER BY id1, id2, id3 ";
446 }
else if (orderedBy==213 || orderedBy==21 ){
447 ss<<
" ORDER BY id2, id1, id3 ";
448 }
else if (orderedBy==231|| orderedBy==23){
449 ss<<
" ORDER BY id2, id3, id1 ";
450 }
else if (orderedBy==321|| orderedBy==32){
451 ss<<
" ORDER BY id3, id2, id1 ";
452 }
else if (orderedBy==312|| orderedBy==31){
453 ss<<
" ORDER BY id3, id1, id2 ";
454 }
else if (orderedBy==132|| orderedBy==13){
455 ss<<
" ORDER BY id1, id3, id2 ";
456 }
else if (orderedBy==1234 ){
457 ss<<
" ORDER BY id1, id2, id3, logic_id ";
458 }
else if (orderedBy==4) {
459 ss<<
" ORDER BY logic_id ";
461 ss<<
" ORDER BY id1, id2, id3";
464 std::vector<EcalLogicID>
result;
467 stmt->setSQL(ss.str());
471 stmt->setString(j,
name);
474 for (
int i=0;
i<3;
i++) {
476 to = idArray[2*
i + 1];
478 stmt->setInt(j, from);
485 stmt->setString(j, mapsTo);
492 int id1, id2, id3, logicId;
494 while (rset->next()) {
495 name = rset->getString(1);
496 logicId = rset->getInt(2);
497 id1 = rset->getInt(3);
499 id2 = rset->getInt(4);
501 id3 = rset->getInt(5);
503 mapsTo = rset->getString(6);
506 result.push_back(ecid);
508 stmt->setPrefetchRowCount(0);
511 throw(std::runtime_error(
"ERROR: Failure while getting EcalLogicID set: " + e.getMessage() ));
520 throw(std::runtime_error)
525 }
catch(std::runtime_error &e) {
533 throw(std::runtime_error)
538 }
catch(std::runtime_error &e) {
546 throw(std::runtime_error)
551 }
catch(std::runtime_error &e) {
559 throw(std::runtime_error)
564 }
catch(std::runtime_error &e) {
572 throw(std::runtime_error)
577 }
catch(std::runtime_error &e) {
585 throw(std::runtime_error)
588 std::list<LMFDat *>::iterator
i = dat.begin();
589 std::list<LMFDat *>::iterator e = dat.end();
591 (*i)->setConnection(
env,
conn);
595 }
catch(std::runtime_error &e) {
603 throw(std::runtime_error)
608 }
catch(std::runtime_error &e) {
616 throw(std::runtime_error)
620 iov->updateEndTimeDB();
621 }
catch(std::runtime_error &e) {
629 throw(std::runtime_error)
633 iov->updateEndTimeDB();
634 }
catch(std::runtime_error &e) {
642 throw(std::runtime_error)
646 iov->updateStartTimeDB();
647 }
catch(std::runtime_error &e) {
655 throw(std::runtime_error)
659 od->updateDefaultCycle();
660 }
catch(std::runtime_error &e) {
668 throw(std::runtime_error)
679 throw(std::runtime_error)
688 throw(std::runtime_error)
697 throw(std::runtime_error)
702 }
catch(std::runtime_error &e) {
710 throw(std::runtime_error)
715 }
catch(std::runtime_error &e) {
726 throw(std::runtime_error)
728 RunIOV runiov = fetchRunIOV(runtag,
run);
731 moniov.
setByRun(montag, &runiov, subrun);
738 throw(std::runtime_error)
752 throw(std::runtime_error)
754 RunIOV runiov = fetchRunIOV(runtag,
run);
766 int s = iovlist.size();
768 iov = iovlist.front();
772 std::cout <<
"################################" << std::endl;
773 std::cout <<
"################################" << std::endl;
774 std::cout <<
"WARNING: More than one LMFRUNIOV" << std::endl;
776 std::cout <<
" lmr " << lmr <<
" type " << type << std::endl;
777 std::cout <<
" and color " << color << std::endl;
778 std::cout <<
"################################" << std::endl;
779 std::cout <<
"################################" << std::endl;
786 iov = iovlist.front();
793 throw(std::runtime_error)
802 throw(std::runtime_error)
811 throw(std::runtime_error)
820 throw(std::runtime_error)
854 throw(std::runtime_error) {
863 throw(std::runtime_error) {
872 throw(std::runtime_error){
886 throw(std::runtime_error)
897 throw(std::runtime_error)
908 throw(std::runtime_error)
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="")
tuple start
Check for commandline option errors.
void insertRunIOV(RunIOV *iov)
std::list< LMFRunIOV > fetchBySequence(const LMFSeqDat &s)
std::list< ODDelaysDat > fetchFEDelaysForRun(RunIOV *iov)
void setByTm(DCUTag *tag, Tm time)
void setRunTag(RunTag tag)
RunList fetchNonEmptyGlobalRunList(RunTag tag, int min_run, int max_run)
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 fetchData(ODFEDAQConfig *result)
void updateRunIOVStartTime(RunIOV *iov)
void insertLmfSeq(LMFSeqDat *iov)
std::vector< EcalLogicID > getEcalLogicIDMappedTo(int logic_id, std::string maps_to)
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 > 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)
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)
void fetchData(std::map< EcalLogicID, RunFEConfigDat > *fillMap, RunIOV *iov)
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)
MonRunList fetchMonRunList(RunTag tag, MonRunTag monruntag)
RunList fetchNonEmptyRunList(RunTag tag, int min_run, int max_run)
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 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)
void fillMap(Registry *reg, regmap_type &fillme)
std::vector< EcalLogicID > getEcalLogicIDForLMR(int lmr_logic_id)
void fetchData(std::vector< ODDelaysDat > *fillMap, int id)
void insertLmfLmrSubIOV(LMFLmrSubIOV *iov)
void setByTm(CaliTag *tag, Tm time)
void fetchNonEmptyGlobalRuns()