12 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalDCSHandler")) {
14 std::cout <<
"EcalDCS Source handler constructor\n" << std::endl;
33 std::cout <<
"==========printDataSet()" << std::endl;
34 if (dataset->empty()) {
35 std::cout <<
"No data in map!" << std::endl;
41 typedef std::map< EcalLogicID, RunDCSHVDat >::const_iterator CI;
42 for (CI
p = dataset->begin();
p != dataset->end(); ++
p) {
53 std::cout <<
"========================" << std::endl;
61 std::cout <<
"==========printDataSet()" << std::endl;
62 if (dataset->empty()) {
63 std::cout <<
"No data in map!" << std::endl;
69 typedef std::map< EcalLogicID, RunDCSLVDat >::const_iterator CI;
70 for (CI
p = dataset->begin();
p != dataset->end(); ++
p) {
81 std::cout <<
"========================" << std::endl;
87 uint16_t hv_off_dbstatus = ( dbStatus & (1 << pos ) ) ;
88 if(hv_off_dbstatus>0) hv_off_dbstatus=1;
89 return hv_off_dbstatus;
96 uint16_t hv_on_dbstatus=0;
97 uint16_t hv_nomi_on_dbstatus=0;
106 if(mode == 0 || mode == 1) {
107 for (
int i=0;
i<16;
i++) {
109 temp = temp | (1<<
i) ;
111 temp = temp | (0<<
i);
114 result= dbStatus &
temp ;
117 for (
int i=0;
i<16;
i++) {
119 temp = temp | (1<<
i) ;
121 temp = temp | (0<<
i);
124 result= dbStatus &
temp ;
134 uint16_t lv_on_dbstatus=0;
135 uint16_t lv_nomi_on_dbstatus=0;
141 if(lv_off_dbstatus>0) lv_off_dbstatus=1;
142 if(lv_nomi_off_dbstatus>0) lv_nomi_off_dbstatus=1;
146 for (
int i=0;
i<16;
i++) {
148 temp = temp | (1<<
i) ;
150 temp = temp | ( 0 <<
i );
155 result= dbStatus &
temp ;
165 if (dataset->empty()) {
166 std::cout <<
"No data in std::map!" << std::endl;
172 typedef std::map< EcalLogicID, RunDCSHVDat >::const_iterator CI ;
174 for (CI
p = dataset->begin();
p != dataset->end(); ++
p) {
180 if(ecid.
getName()==
"EB_HV_channel"){
191 for(
int ik=i1; ik<=i2; ik++){
196 uint16_t dbStatus = 0;
197 if ( it != dcs_temp->
end() ) {
198 dbStatus = it->getStatusCode();
201 uint16_t new_dbStatus=
updateHV(&hv, dbStatus, modo);
202 if(new_dbStatus != dbStatus ) result=
true;
204 dcs_temp->
setValue( ebid, new_dbStatus );
206 if(new_dbStatus != dbStatus) {
207 std::cout <<
"SM/chan:"<<sm<<
"/"<<chan <<
" new db status ="<< new_dbStatus <<
" old "<<dbStatus<<
" HV: "<< hv.
getHV()<<
"/"<<hv.
getHVNominal()<<std::endl;
229 ex_x[0]=4; ex_y[0]=8;
230 ex_x[1]=4; ex_y[1]=9;
231 ex_x[2]=4; ex_y[2]=10;
232 ex_x[3]=5; ex_y[3]=9;
233 ex_x[4]=5; ex_y[4]=10;
234 ex_x[5]=6; ex_y[5]=10;
236 ex_x[0]=17; ex_y[0]=11;
237 ex_x[1]=17; ex_y[1]=12;
238 ex_x[2]=17; ex_y[2]=13;
239 ex_x[3]=16; ex_y[3]=11;
240 ex_x[4]=16; ex_y[4]=12;
241 ex_x[5]=15; ex_y[5]=11;
243 ex_x[0]=17; ex_y[0]=8;
244 ex_x[1]=17; ex_y[1]=9;
245 ex_x[2]=17; ex_y[2]=10;
246 ex_x[3]=16; ex_y[3]=9;
247 ex_x[4]=16; ex_y[4]=10;
248 ex_x[5]=15; ex_y[5]=10;
250 ex_x[0]=4; ex_y[0]=11;
251 ex_x[1]=4; ex_y[1]=12;
252 ex_x[2]=4; ex_y[2]=13;
253 ex_x[3]=5; ex_y[3]=11;
254 ex_x[4]=5; ex_y[4]=12;
255 ex_x[5]=6; ex_y[5]=11;
259 if(ecid.
getName()==
"EE_HVD_channel") modo=2;
261 for(
int ik=i1; ik<=i2; ik++){
262 for(
int ip=j1; ip<=j2; ip++){
263 bool not_excluded=
true;
265 for (
int l=0;
l<6;
l++){
266 if(ik== ex_x[
l] && ip== ex_y[
l] ) not_excluded=
false;
274 uint16_t dbStatus = 0;
275 if ( it != dcs_temp->
end() ) {
276 dbStatus = it->getStatusCode();
279 uint16_t new_dbStatus=
updateHV(&hv, dbStatus, modo);
280 if(new_dbStatus != dbStatus ) result=
true;
282 dcs_temp->
setValue( eeid, new_dbStatus );
284 if(new_dbStatus != dbStatus) {
285 std::cout <<
"Dee/chan:"<<dee<<
"/"<<chan <<
" new db status ="<< new_dbStatus <<
" old "<<dbStatus<<
" HV: "<< hv.
getHV()<<
"/"<<hv.
getHVNominal()<<std::endl;
293 for (
int l=0;
l<6;
l++){
300 uint16_t dbStatus = 0;
301 if ( it != dcs_temp->
end() ) {
302 dbStatus = it->getStatusCode();
304 uint16_t new_dbStatus=
updateHV(&hv, dbStatus,modo);
305 if(new_dbStatus != dbStatus ) result=
true;
307 dcs_temp->
setValue( eeid, new_dbStatus );
309 if(new_dbStatus != dbStatus) {
310 std::cout <<
"Dee/chan:"<<dee<<
"/"<<chan <<
" new db status ="<< new_dbStatus <<
" old "<<dbStatus<<
" HV: "<< hv.
getHV()<<
"/"<<hv.
getHVNominal()<<std::endl;
334 int ilocal=(i-1)-sm*4;
336 if(ilocal==0 || ilocal==1) hv_chan=1;
337 if(ilocal==2 || ilocal==3) hv_chan=2;
339 if(ilocal==0 || ilocal==1) hv_chan=2;
340 if(ilocal==2 || ilocal==3) hv_chan=1;
345 hv_chan=(j-1)*2+hv_chan;
347 hv_chan=(sm-1)*34+hv_chan -1 ;
357 if(dee==1 || dee==2) iz=1;
363 if(dee==1 && chan==1) {
366 }
else if(dee==2 && chan==1) {
369 }
else if(dee==3 && chan==1) {
372 }
else if(dee==4 && chan==1) {
375 }
else if(dee==1 && chan==2) {
378 }
else if(dee==2 && chan==2) {
381 }
else if(dee==3 && chan==2) {
384 }
else if(dee==4 && chan==2) {
404 if(sm>0 && sm <= 18) iz=1;
405 int j = (chan-1)/2 +1;
406 int i_local_hv = (chan-1) - (j-1)*2 + 1;
427 if(iz==1) ioffset=(sm-1)*4;
428 if(iz==-1) ioffset=(sm-18-1)*4;
448 if(sm>0 && sm <= 18) iz=1;
487 if(iz==1) ioffset=(sm-1)*4;
488 if(iz==-1) ioffset=(sm-18-1)*4;
507 if (dataset->empty()) {
508 std::cout <<
"No data in map!" << std::endl;
514 typedef std::map< EcalLogicID, RunDCSLVDat >::const_iterator CI;
515 for (CI
p = dataset->begin();
p != dataset->end(); ++
p) {
520 if(ecid.
getName()==
"EB_LV_channel"){
533 for(
int ik=i1; ik<=i2; ik++){
534 for(
int j=j1; j<=j2; j++){
538 uint16_t dbStatus = 0;
539 if ( it != dcs_temp->
end() ) {
540 dbStatus = it->getStatusCode();
542 uint16_t new_dbStatus=
updateLV(&lv, dbStatus);
543 if(new_dbStatus != dbStatus ) result=
true;
544 dcs_temp->
setValue( ebid, new_dbStatus );
546 if(new_dbStatus != dbStatus) {
547 std::cout <<
"SM/chan:"<<sm<<
"/"<<chan <<
" new db status ="<< new_dbStatus <<
" old "<<dbStatus<<
" LV: "<< lv.
getLV()<<
"/"<<lv.
getLVNominal()<<std::endl;
563 int n=my_EELVchan.size();
565 for (
int ixt=0; ixt<
n; ixt++) {
566 if(my_EELVchan[ixt].getID1()==dee && my_EELVchan[ixt].getID2()==chan){
568 int ilogic=my_EELVchan[ixt].getLogicID();
570 if(ilogic == 2012058060 || ilogic == 2010060058
571 || ilogic == 2012043041 || ilogic == 2010041043) {
572 std::cout<<
"crystal " << ilogic <<
" in the corner ignored" << std::endl;
575 int iz= (ilogic/1000000)-2010;
578 if(iz != 1 && iz!= -1)
std::cout<<
"BAD z"<< std::endl;
580 int iy=ilogic-
int(ilogic/1000)*1000;
582 int ix=(ilogic-
int(ilogic/1000000)*1000000 -iy)/1000;
584 int ixtower= ((ix-1)/5) +1;
585 int iytower= ((iy-1)/5) +1;
587 if(ixtower<1 || ixtower>20 || iytower <1 || iytower >20)
588 std::cout<<
"BAD x/y"<<ilogic<<
"/"<< ixtower<<
"/"<<iytower<< std::endl;
593 uint16_t dbStatus = 0;
594 if ( it != dcs_temp->
end() ) {
595 dbStatus = it->getStatusCode();
598 uint16_t new_dbStatus=
updateLV(&lv, dbStatus);
599 if(new_dbStatus != dbStatus ) result=
true;
600 dcs_temp->
setValue( eeid, new_dbStatus );
604 if(new_dbStatus != dbStatus) {
605 std::cout <<
"Dee/chan:"<<dee<<
"/"<<chan <<
" new db status ="<< new_dbStatus <<
" old "<<dbStatus<<
" LV: "<< lv.
getLV()<<
"/"<<lv.
getLVNominal()<<std::endl;
628 bool lot_of_printout=
false;
629 std::cout <<
"------- Ecal DCS - > getNewObjects\n";
631 std::ostringstream ss;
634 unsigned long long max_since= 1;
641 std::cout <<
"retrieved last payload " << std::endl;
645 for(
int k=0 ;
k<2;
k++ ) {
648 for(
int i=1 ;
i<73;
i++) {
649 for(
int j=1 ; j<18; j++) {
653 uint16_t dbStatus = 0;
654 dbStatus =(dcs_db->barrel( ebid.
hashedIndex())).getStatusCode();
657 if ( it != dcs_db->end() ) {
659 std::cout<<
"*** error channel not found: j/i="<<j<<
"/"<<
i << std::endl;
661 dcs_temp->
setValue( ebid, dbStatus );
668 for(
int k=0 ;
k<2;
k++ ) {
671 for(
int i=1 ;
i<21;
i++) {
672 for(
int j=1 ; j<21; j++) {
678 uint16_t dbStatus = 0;
679 if ( it != dcs_db->end() ) {
680 dbStatus = it->getStatusCode();
682 dcs_temp->
setValue( eeid, dbStatus );
690 for(
int k = 0 ;
k < 2;
k++ ) {
693 for(
int i = 1 ;
i < 73;
i++) {
694 for(
int j = 1 ; j < 18; j++) {
702 for(
int i=1 ;
i<21;
i++) {
703 for(
int j=1 ; j<21; j++) {
712 std::cout <<
"max_since : " << max_since << std::endl;
716 std::cout <<
"Connection done" << std::endl;
726 std::cout <<
"Retrieving last run from ONLINE DB ... " << std::endl;
727 std::map<EcalLogicID, RunDat> rundat;
733 unsigned long long irun=(
unsigned long long) rp.
getRunNumber();
738 if(max_since< irun) {
743 std::cout <<
"Retrieving endcap channel list from ONLINE DB ... " << std::endl;
747 "EE_LV_channel", 12 ) ;
749 std::cout <<
"done endcap channel list ... " << std::endl;
754 std::map<EcalLogicID, RunDCSHVDat>
dataset;
758 if (dataset.empty()) {
759 throw(std::runtime_error(
"Zero rows read back"));
763 if(lot_of_printout)
std::cout <<
"read OK" << std::endl;
766 std::map<EcalLogicID, RunDCSLVDat> dataset_lv;
769 if (dataset_lv.empty()) {
770 throw(std::runtime_error(
"Zero rows read back"));
772 if(lot_of_printout)
std::cout <<
"read OK" << std::endl;
778 if(somediff_hv || somediff_lv) {
789 std::cout <<
"Generating popcon record for run " << irun <<
"..." << std::flush;
797 ss <<
"Run=" << irun <<
"_DCSchanged_"<<std::endl;
806 std::cout<<
"Run " << irun <<
" DCS record was the same as previous run " << std::endl;
807 ss <<
"Run=" << irun <<
"_DCSchanged_"<<std::endl;
925 std::cout <<
"Ecal - > end of getNewObjects -----------\n";
static bool validDetId(int ix, int iy, int iz)
T getParameter(std::string const &) const
EcalDCSHandler(edm::ParameterSet const &)
float getHVNominal() const
std::string m_userTextLog
edm::Ref< Container > Ref
const_iterator end() const
static const int HVEEDSTATUS
EcalCondDBInterface * econn
uint16_t OffDBStatus(uint16_t dbStatus, int pos)
void getNewObjects() override
static const int HVSTATUS
uint16_t updateLV(RunDCSLVDat *lv, uint16_t dbStatus) const
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
int * LVLogicIDToDetID(int, int) const
int * HVEELogicIDToDetID(int, int) const
static const int HVNOTNOMINAL
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
void setValue(const uint32_t id, const Item &item)
static const int LVSTATUS
const_iterator find(uint32_t rawId) const
OldContainer m_to_transfer
uint32_t rawId() const
get the raw id
cond::ValidityInterval lastInterval
std::string getName() const
void printLVDataSet(const std::map< EcalLogicID, RunDCSLVDat > *dataset, int) const
int * HVLogicIDToDetID(int, int) const
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)
float getLVNominal() const
EcalDCSTowerStatusMap EcalDCSTowerStatus
static const int HVNOMINALSTATUS
bool insertLVDataSetToOffline(const std::map< EcalLogicID, RunDCSLVDat > *dataset, EcalDCSTowerStatus *dcs_temp, const std::vector< EcalLogicID > &) const
int detIDToLogicID(int, int, int)
void printHVDataSet(const std::map< EcalLogicID, RunDCSHVDat > *dataset, int) const
static const int HVEEDNOMINALSTATUS
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
run_t getRunNumber() const
static const int LVNOTNOMINAL
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
bool insertHVDataSetToOffline(const std::map< EcalLogicID, RunDCSHVDat > *dataset, EcalDCSTowerStatus *dcs_temp) const
static const int LVNOMINALSTATUS
std::vector< Item >::const_iterator const_iterator
uint16_t updateHV(RunDCSHVDat *hv, uint16_t dbStatus, int modo=0) const
void fetchValidDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *fillIOV, RunTag *tag, run_t run=(unsigned int)-1) noexcept(false)
cond::TagInfo_t const & tagInfo() const
~EcalDCSHandler() override