11 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalDCSHandler")) {
12 std::cout <<
"EcalDCS Source handler constructor\n" << std::endl;
25 std::cout <<
"==========printDataSet()" << std::endl;
27 std::cout <<
"No data in map!" << std::endl;
33 typedef std::map<EcalLogicID, RunDCSHVDat>::const_iterator CI;
47 std::cout <<
"========================" << std::endl;
53 std::cout <<
"==========printDataSet()" << std::endl;
55 std::cout <<
"No data in map!" << std::endl;
61 typedef std::map<EcalLogicID, RunDCSLVDat>::const_iterator CI;
75 std::cout <<
"========================" << std::endl;
81 uint16_t hv_off_dbstatus = (dbStatus & (1 <<
pos));
82 if (hv_off_dbstatus > 0)
84 return hv_off_dbstatus;
91 uint16_t hv_on_dbstatus = 0;
92 uint16_t hv_nomi_on_dbstatus = 0;
95 hv_nomi_on_dbstatus = 1;
102 for (
int i = 0;
i < 16;
i++) {
113 for (
int i = 0;
i < 16;
i++) {
130 uint16_t lv_on_dbstatus = 0;
131 uint16_t lv_nomi_on_dbstatus = 0;
133 lv_nomi_on_dbstatus = 1;
138 for (
int i = 0;
i < 16;
i++) {
157 std::cout <<
"No data in std::map!" << std::endl;
162 typedef std::map<EcalLogicID, RunDCSHVDat>::const_iterator CI;
168 if (ecid.
getName() ==
"EB_HV_channel") {
179 for (
int ik =
i1; ik <=
i2; ik++) {
184 uint16_t dbStatus = 0;
185 if (
it != dcs_temp->
end()) {
186 dbStatus =
it->getStatusCode();
189 uint16_t new_dbStatus = updateHV(&hv, dbStatus, modo);
190 if (new_dbStatus != dbStatus)
193 dcs_temp->
setValue(ebid, new_dbStatus);
195 if (new_dbStatus != dbStatus) {
196 std::cout <<
"SM/chan:" <<
sm <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old " << dbStatus
230 }
else if (dee == 2) {
243 }
else if (dee == 3) {
256 }
else if (dee == 4) {
270 throw cms::Exception(
"Invalid EcalLogicID") <<
"Unknown ECAL Endcap Dee number " << dee;
274 if (ecid.
getName() ==
"EE_HVD_channel")
277 for (
int ik =
i1; ik <=
i2; ik++) {
278 for (
int ip = j1; ip <= j2; ip++) {
279 bool not_excluded =
true;
281 for (
int l = 0;
l < 6;
l++) {
282 if (ik == ex_x[
l] && ip == ex_y[
l])
283 not_excluded =
false;
291 uint16_t dbStatus = 0;
292 if (
it != dcs_temp->
end()) {
293 dbStatus =
it->getStatusCode();
296 uint16_t new_dbStatus = updateHV(&hv, dbStatus, modo);
297 if (new_dbStatus != dbStatus)
300 dcs_temp->
setValue(eeid, new_dbStatus);
302 if (new_dbStatus != dbStatus) {
303 std::cout <<
"Dee/chan:" << dee <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old " 311 for (
int l = 0;
l < 6;
l++) {
318 uint16_t dbStatus = 0;
319 if (
it != dcs_temp->
end()) {
320 dbStatus =
it->getStatusCode();
322 uint16_t new_dbStatus = updateHV(&hv, dbStatus, modo);
323 if (new_dbStatus != dbStatus)
326 dcs_temp->
setValue(eeid, new_dbStatus);
328 if (new_dbStatus != dbStatus) {
329 std::cout <<
"Dee/chan:" << dee <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old " 352 int ilocal = (
i - 1) -
sm * 4;
354 if (ilocal == 0 || ilocal == 1)
356 if (ilocal == 2 || ilocal == 3)
359 if (ilocal == 0 || ilocal == 1)
361 if (ilocal == 2 || ilocal == 3)
367 hv_chan = (
j - 1) * 2 + hv_chan;
369 hv_chan = (
sm - 1) * 34 + hv_chan - 1;
376 if (dee == 1 || dee == 2)
383 if (dee == 1 &&
chan == 1) {
388 }
else if (dee == 2 &&
chan == 1) {
393 }
else if (dee == 3 &&
chan == 1) {
398 }
else if (dee == 4 &&
chan == 1) {
403 }
else if (dee == 1 &&
chan == 2) {
408 }
else if (dee == 2 &&
chan == 2) {
413 }
else if (dee == 3 &&
chan == 2) {
418 }
else if (dee == 4 &&
chan == 2) {
439 if (
sm > 0 &&
sm <= 18)
441 int j = (
chan - 1) / 2 + 1;
442 int i_local_hv = (
chan - 1) - (
j - 1) * 2 + 1;
446 if (i_local_hv == 1) {
454 if (i_local_hv == 1) {
464 ioffset = (
sm - 1) * 4;
466 ioffset = (
sm - 18 - 1) * 4;
485 if (
sm > 0 &&
sm <= 18)
499 int ch2 = (
chan / 2) * 2;
526 ioffset = (
sm - 1) * 4;
528 ioffset = (
sm - 18 - 1) * 4;
544 const std::vector<EcalLogicID>& my_EELVchan)
const {
547 std::cout <<
"No data in map!" << std::endl;
552 typedef std::map<EcalLogicID, RunDCSLVDat>::const_iterator CI;
557 if (ecid.
getName() ==
"EB_LV_channel") {
569 for (
int ik =
i1; ik <=
i2; ik++) {
570 for (
int j = j1;
j <= j2;
j++) {
574 uint16_t dbStatus = 0;
575 if (
it != dcs_temp->
end()) {
576 dbStatus =
it->getStatusCode();
578 uint16_t new_dbStatus = updateLV(&lv, dbStatus);
579 if (new_dbStatus != dbStatus)
581 dcs_temp->
setValue(ebid, new_dbStatus);
583 if (new_dbStatus != dbStatus) {
584 std::cout <<
"SM/chan:" <<
sm <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old " << dbStatus
596 int n = my_EELVchan.size();
598 for (
int ixt = 0; ixt <
n; ixt++) {
599 if (my_EELVchan[ixt].getID1() == dee && my_EELVchan[ixt].getID2() ==
chan) {
600 int ilogic = my_EELVchan[ixt].getLogicID();
602 if (ilogic == 2012058060 || ilogic == 2010060058 || ilogic == 2012043041 || ilogic == 2010041043) {
603 std::cout <<
"crystal " << ilogic <<
" in the corner ignored" << std::endl;
605 int iz = (ilogic / 1000000) - 2010;
610 if (iz != 1 && iz != -1)
613 int iy = ilogic -
int(ilogic / 1000) * 1000;
615 int ix = (ilogic -
int(ilogic / 1000000) * 1000000 -
iy) / 1000;
617 int ixtower = ((
ix - 1) / 5) + 1;
618 int iytower = ((
iy - 1) / 5) + 1;
620 if (ixtower < 1 || ixtower > 20 || iytower < 1 || iytower > 20)
621 std::cout <<
"BAD x/y" << ilogic <<
"/" << ixtower <<
"/" << iytower << std::endl;
626 uint16_t dbStatus = 0;
627 if (
it != dcs_temp->
end()) {
628 dbStatus =
it->getStatusCode();
631 uint16_t new_dbStatus = updateLV(&lv, dbStatus);
632 if (new_dbStatus != dbStatus)
634 dcs_temp->
setValue(eeid, new_dbStatus);
638 if (new_dbStatus != dbStatus) {
639 std::cout <<
"Dee/chan:" << dee <<
"/" <<
chan <<
" new db status =" << new_dbStatus <<
" old " 653 bool lot_of_printout =
false;
654 std::cout <<
"------- Ecal DCS - > getNewObjects\n";
656 std::ostringstream
ss;
659 unsigned long long max_since = 1;
664 max_since =
tagInfo().lastInterval.since;
665 Ref dcs_db = lastPayload();
666 std::cout <<
"retrieved last payload " << std::endl;
670 for (
int k = 0;
k < 2;
k++) {
675 for (
int i = 1;
i < 73;
i++) {
676 for (
int j = 1;
j < 18;
j++) {
680 uint16_t dbStatus = 0;
681 dbStatus = (dcs_db->barrel(ebid.
hashedIndex())).getStatusCode();
684 if (
it != dcs_db->end()) {
686 std::cout <<
"*** error channel not found: j/i=" <<
j <<
"/" <<
i << std::endl;
695 for (
int k = 0;
k < 2;
k++) {
700 for (
int i = 1;
i < 21;
i++) {
701 for (
int j = 1;
j < 21;
j++) {
707 uint16_t dbStatus = 0;
708 if (
it != dcs_db->end()) {
709 dbStatus =
it->getStatusCode();
719 for (
int k = 0;
k < 2;
k++) {
723 for (
int i = 1;
i < 73;
i++) {
724 for (
int j = 1;
j < 18;
j++) {
732 for (
int i = 1;
i < 21;
i++) {
733 for (
int j = 1;
j < 21;
j++) {
742 std::cout <<
"max_since : " << max_since << std::endl;
746 std::cout <<
"Connection done" << std::endl;
749 std::cout <<
" Problem with OMDS: connection parameters " << m_sid <<
"/" << m_user << std::endl;
753 std::cout <<
"Retrieving last run from ONLINE DB ... " << std::endl;
754 std::map<EcalLogicID, RunDat> rundat;
756 run_t runmax = 10000000;
758 econn->fetchValidDataSet(&rundat, &rp, location_p5, runmax);
760 unsigned long long irun = (
unsigned long long)rp.
getRunNumber();
765 if (max_since < irun) {
768 std::cout <<
"Retrieving endcap channel list from ONLINE DB ... " << std::endl;
770 std::vector<EcalLogicID> my_EELVchan =
econn->getEcalLogicIDSetOrdered(
773 std::cout <<
"done endcap channel list ... " << std::endl;
778 std::map<EcalLogicID, RunDCSHVDat>
dataset;
783 throw(std::runtime_error(
"Zero rows read back"));
791 std::map<EcalLogicID, RunDCSLVDat> dataset_lv;
792 econn->fetchDataSet(&dataset_lv, r);
794 if (dataset_lv.empty()) {
795 throw(std::runtime_error(
"Zero rows read back"));
800 printLVDataSet(&dataset_lv);
802 bool somediff_hv = insertHVDataSetToOffline(&
dataset, dcs_temp);
803 bool somediff_lv = insertLVDataSetToOffline(&dataset_lv, dcs_temp, my_EELVchan);
805 if (somediff_hv || somediff_lv) {
814 std::cout <<
"Generating popcon record for run " << irun <<
"..." << std::flush;
822 ss <<
"Run=" << irun <<
"_DCSchanged_" << std::endl;
824 m_userTextLog =
ss.str() +
";";
830 std::cout <<
"Run " << irun <<
" DCS record was the same as previous run " << std::endl;
831 ss <<
"Run=" << irun <<
"_DCSchanged_" << std::endl;
832 m_userTextLog =
ss.str() +
";";
947 std::cout <<
"Ecal - > end of getNewObjects -----------\n";
static bool validDetId(int ix, int iy, int iz)
EcalDCSHandler(edm::ParameterSet const &)
int * HVEELogicIDToDetID(int, int) const
T getParameter(std::string const &) const
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
static const int HVEEDSTATUS
bool insertLVDataSetToOffline(const std::map< EcalLogicID, RunDCSLVDat > *dataset, EcalDCSTowerStatus *dcs_temp, const std::vector< EcalLogicID > &) const
int * HVLogicIDToDetID(int, int) const
std::string getName() const
uint16_t OffDBStatus(uint16_t dbStatus, int pos)
uint16_t updateHV(RunDCSHVDat *hv, uint16_t dbStatus, int modo=0) const
void getNewObjects() override
static const int HVSTATUS
void printLVDataSet(const std::map< EcalLogicID, RunDCSLVDat > *dataset, int) const
run_t getRunNumber() const
static const int HVNOTNOMINAL
void setValue(const uint32_t id, const Item &item)
static const int LVSTATUS
int * LVLogicIDToDetID(int, int) const
EcalDCSTowerStatusMap EcalDCSTowerStatus
static const int HVNOMINALSTATUS
const_iterator end() const
int detIDToLogicID(int, int, int)
bool insertHVDataSetToOffline(const std::map< EcalLogicID, RunDCSHVDat > *dataset, EcalDCSTowerStatus *dcs_temp) const
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
static const int HVEEDNOMINALSTATUS
constexpr uint32_t rawId() const
get the raw id
const_iterator find(uint32_t rawId) const
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
static const int LVNOTNOMINAL
std::unique_ptr< EcalDCSTowerStatus > Ref
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
ALPAKA_FN_ACC int sm(int ieta, int iphi)
float getHVNominal() const
uint16_t updateLV(RunDCSLVDat *lv, uint16_t dbStatus) const
float getLVNominal() const
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
static const int LVNOMINALSTATUS
std::vector< Item >::const_iterator const_iterator
void printHVDataSet(const std::map< EcalLogicID, RunDCSHVDat > *dataset, int) const
~EcalDCSHandler() override