10 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalDCSHandler")) {
11 std::cout <<
"EcalDCS Source handler constructor\n" << std::endl;
24 std::cout <<
"==========printDataSet()" << std::endl;
26 std::cout <<
"No data in map!" << std::endl;
32 typedef std::map<EcalLogicID, RunDCSHVDat>::const_iterator CI;
46 std::cout <<
"========================" << std::endl;
52 std::cout <<
"==========printDataSet()" << std::endl;
54 std::cout <<
"No data in map!" << std::endl;
60 typedef std::map<EcalLogicID, RunDCSLVDat>::const_iterator CI;
74 std::cout <<
"========================" << std::endl;
80 uint16_t hv_off_dbstatus = (dbStatus & (1 <<
pos));
81 if (hv_off_dbstatus > 0)
83 return hv_off_dbstatus;
90 uint16_t hv_on_dbstatus = 0;
91 uint16_t hv_nomi_on_dbstatus = 0;
94 hv_nomi_on_dbstatus = 1;
101 for (
int i = 0;
i < 16;
i++) {
112 for (
int i = 0;
i < 16;
i++) {
129 uint16_t lv_on_dbstatus = 0;
130 uint16_t lv_nomi_on_dbstatus = 0;
132 lv_nomi_on_dbstatus = 1;
138 if (lv_off_dbstatus > 0)
140 if (lv_nomi_off_dbstatus > 0)
141 lv_nomi_off_dbstatus = 1;
144 for (
int i = 0;
i < 16;
i++) {
163 std::cout <<
"No data in std::map!" << std::endl;
168 typedef std::map<EcalLogicID, RunDCSHVDat>::const_iterator CI;
174 if (ecid.
getName() ==
"EB_HV_channel") {
185 for (
int ik =
i1; ik <=
i2; ik++) {
190 uint16_t dbStatus = 0;
191 if (it != dcs_temp->
end()) {
192 dbStatus = it->getStatusCode();
195 uint16_t new_dbStatus = updateHV(&hv, dbStatus, modo);
196 if (new_dbStatus != dbStatus)
199 dcs_temp->
setValue(ebid, new_dbStatus);
201 if (new_dbStatus != dbStatus) {
202 std::cout <<
"SM/chan:" << sm <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old " << dbStatus
236 }
else if (dee == 2) {
249 }
else if (dee == 3) {
262 }
else if (dee == 4) {
278 if (ecid.
getName() ==
"EE_HVD_channel")
281 for (
int ik =
i1; ik <=
i2; ik++) {
282 for (
int ip = j1; ip <= j2; ip++) {
283 bool not_excluded =
true;
285 for (
int l = 0;
l < 6;
l++) {
286 if (ik == ex_x[
l] && ip == ex_y[
l])
287 not_excluded =
false;
295 uint16_t dbStatus = 0;
296 if (it != dcs_temp->
end()) {
297 dbStatus = it->getStatusCode();
300 uint16_t new_dbStatus = updateHV(&hv, dbStatus, modo);
301 if (new_dbStatus != dbStatus)
304 dcs_temp->
setValue(eeid, new_dbStatus);
306 if (new_dbStatus != dbStatus) {
307 std::cout <<
"Dee/chan:" << dee <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old "
315 for (
int l = 0;
l < 6;
l++) {
322 uint16_t dbStatus = 0;
323 if (it != dcs_temp->
end()) {
324 dbStatus = it->getStatusCode();
326 uint16_t new_dbStatus = updateHV(&hv, dbStatus, modo);
327 if (new_dbStatus != dbStatus)
330 dcs_temp->
setValue(eeid, new_dbStatus);
332 if (new_dbStatus != dbStatus) {
333 std::cout <<
"Dee/chan:" << dee <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old "
356 int ilocal = (
i - 1) - sm * 4;
358 if (ilocal == 0 || ilocal == 1)
360 if (ilocal == 2 || ilocal == 3)
363 if (ilocal == 0 || ilocal == 1)
365 if (ilocal == 2 || ilocal == 3)
371 hv_chan = (
j - 1) * 2 + hv_chan;
373 hv_chan = (sm - 1) * 34 + hv_chan - 1;
380 if (dee == 1 || dee == 2)
387 if (dee == 1 &&
chan == 1) {
392 }
else if (dee == 2 &&
chan == 1) {
397 }
else if (dee == 3 &&
chan == 1) {
402 }
else if (dee == 4 &&
chan == 1) {
407 }
else if (dee == 1 &&
chan == 2) {
412 }
else if (dee == 2 &&
chan == 2) {
417 }
else if (dee == 3 &&
chan == 2) {
422 }
else if (dee == 4 &&
chan == 2) {
443 if (sm > 0 && sm <= 18)
445 int j = (
chan - 1) / 2 + 1;
446 int i_local_hv = (
chan - 1) - (
j - 1) * 2 + 1;
450 if (i_local_hv == 1) {
458 if (i_local_hv == 1) {
468 ioffset = (sm - 1) * 4;
470 ioffset = (sm - 18 - 1) * 4;
489 if (sm > 0 && sm <= 18)
503 int ch2 = (
chan / 2) * 2;
530 ioffset = (sm - 1) * 4;
532 ioffset = (sm - 18 - 1) * 4;
548 const std::vector<EcalLogicID>& my_EELVchan)
const {
551 std::cout <<
"No data in map!" << std::endl;
556 typedef std::map<EcalLogicID, RunDCSLVDat>::const_iterator CI;
561 if (ecid.
getName() ==
"EB_LV_channel") {
573 for (
int ik =
i1; ik <=
i2; ik++) {
574 for (
int j = j1;
j <= j2;
j++) {
578 uint16_t dbStatus = 0;
579 if (it != dcs_temp->
end()) {
580 dbStatus = it->getStatusCode();
582 uint16_t new_dbStatus = updateLV(&lv, dbStatus);
583 if (new_dbStatus != dbStatus)
585 dcs_temp->
setValue(ebid, new_dbStatus);
587 if (new_dbStatus != dbStatus) {
588 std::cout <<
"SM/chan:" << sm <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old " << dbStatus
600 int n = my_EELVchan.size();
602 for (
int ixt = 0; ixt <
n; ixt++) {
603 if (my_EELVchan[ixt].getID1() == dee && my_EELVchan[ixt].getID2() ==
chan) {
604 int ilogic = my_EELVchan[ixt].getLogicID();
606 if (ilogic == 2012058060 || ilogic == 2010060058 || ilogic == 2012043041 || ilogic == 2010041043) {
607 std::cout <<
"crystal " << ilogic <<
" in the corner ignored" << std::endl;
609 int iz = (ilogic / 1000000) - 2010;
614 if (iz != 1 && iz != -1)
617 int iy = ilogic -
int(ilogic / 1000) * 1000;
619 int ix = (ilogic -
int(ilogic / 1000000) * 1000000 - iy) / 1000;
621 int ixtower = ((ix - 1) / 5) + 1;
622 int iytower = ((iy - 1) / 5) + 1;
624 if (ixtower < 1 || ixtower > 20 || iytower < 1 || iytower > 20)
625 std::cout <<
"BAD x/y" << ilogic <<
"/" << ixtower <<
"/" << iytower << std::endl;
630 uint16_t dbStatus = 0;
631 if (it != dcs_temp->
end()) {
632 dbStatus = it->getStatusCode();
635 uint16_t new_dbStatus = updateLV(&lv, dbStatus);
636 if (new_dbStatus != dbStatus)
638 dcs_temp->
setValue(eeid, new_dbStatus);
642 if (new_dbStatus != dbStatus) {
643 std::cout <<
"Dee/chan:" << dee <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old "
657 bool lot_of_printout =
false;
658 std::cout <<
"------- Ecal DCS - > getNewObjects\n";
660 std::ostringstream
ss;
663 unsigned long long max_since = 1;
668 max_since =
tagInfo().lastInterval.since;
669 Ref dcs_db = lastPayload();
670 std::cout <<
"retrieved last payload " << std::endl;
674 for (
int k = 0;
k < 2;
k++) {
679 for (
int i = 1;
i < 73;
i++) {
680 for (
int j = 1;
j < 18;
j++) {
684 uint16_t dbStatus = 0;
685 dbStatus = (dcs_db->barrel(ebid.
hashedIndex())).getStatusCode();
688 if (it != dcs_db->end()) {
690 std::cout <<
"*** error channel not found: j/i=" <<
j <<
"/" <<
i << std::endl;
699 for (
int k = 0;
k < 2;
k++) {
704 for (
int i = 1;
i < 21;
i++) {
705 for (
int j = 1;
j < 21;
j++) {
711 uint16_t dbStatus = 0;
712 if (it != dcs_db->end()) {
713 dbStatus = it->getStatusCode();
723 for (
int k = 0;
k < 2;
k++) {
727 for (
int i = 1;
i < 73;
i++) {
728 for (
int j = 1;
j < 18;
j++) {
736 for (
int i = 1;
i < 21;
i++) {
737 for (
int j = 1;
j < 21;
j++) {
746 std::cout <<
"max_since : " << max_since << std::endl;
750 std::cout <<
"Connection done" << std::endl;
753 std::cout <<
" Problem with OMDS: connection parameters " << m_sid <<
"/" << m_user << std::endl;
757 std::cout <<
"Retrieving last run from ONLINE DB ... " << std::endl;
758 std::map<EcalLogicID, RunDat> rundat;
760 run_t runmax = 10000000;
762 econn->fetchValidDataSet(&rundat, &rp, location_p5, runmax);
764 unsigned long long irun = (
unsigned long long)rp.
getRunNumber();
769 if (max_since < irun) {
772 std::cout <<
"Retrieving endcap channel list from ONLINE DB ... " << std::endl;
774 std::vector<EcalLogicID> my_EELVchan =
econn->getEcalLogicIDSetOrdered(
777 std::cout <<
"done endcap channel list ... " << std::endl;
782 std::map<EcalLogicID, RunDCSHVDat>
dataset;
787 throw(std::runtime_error(
"Zero rows read back"));
795 std::map<EcalLogicID, RunDCSLVDat> dataset_lv;
796 econn->fetchDataSet(&dataset_lv,
r);
798 if (dataset_lv.empty()) {
799 throw(std::runtime_error(
"Zero rows read back"));
804 printLVDataSet(&dataset_lv);
806 bool somediff_hv = insertHVDataSetToOffline(&
dataset, dcs_temp);
807 bool somediff_lv = insertLVDataSetToOffline(&dataset_lv, dcs_temp, my_EELVchan);
809 if (somediff_hv || somediff_lv) {
818 std::cout <<
"Generating popcon record for run " << irun <<
"..." << std::flush;
826 ss <<
"Run=" << irun <<
"_DCSchanged_" << std::endl;
828 m_userTextLog =
ss.str() +
";";
834 std::cout <<
"Run " << irun <<
" DCS record was the same as previous run " << std::endl;
835 ss <<
"Run=" << irun <<
"_DCSchanged_" << std::endl;
836 m_userTextLog =
ss.str() +
";";
951 std::cout <<
"Ecal - > end of getNewObjects -----------\n";