37#include "CoralBase/Blob.h"
44#define HV_NON_NOMINAL_TOLERANCE 10
45#define DEAD_HV_THRESHOLD 10
46#define MAX_LAR_CELLS 182468
63 ATH_MSG_INFO(
"Will use currents to correct voltage-drop at HV-resistors");
66 ATH_MSG_INFO(
"Will NOT correct voltage-drop at HV-resistors");
91 return StatusCode::SUCCESS;
107 return StatusCode::SUCCESS;
114 std::set<unsigned> changes;
117 for (
auto [prop, store]: items) {
119 for (
auto& p: prop->value()) {
120 std::stringstream
ss(p);
123 ss >> hvline >> value >> std::skipws;
124 if (
ss &&
ss.eof()) {
125 changes.insert(hvline);
126 if (
auto empl = store->emplace(hvline, value); !empl.second) {
127 ATH_MSG_WARNING(
"Setting multiple times HV and/or current for line " << hvline
128 <<
", this will replace the previous value(s).");
129 empl.first->second = value;
133 ATH_MSG_ERROR(
"Couldn't interpret HV or current setting: \"" << p <<
"\"");
134 return StatusCode::FAILURE;
137 if (changes.size() > 0) {
138 ATH_MSG_INFO(
"Fixed values of voltage and/or current to be used instead of DCS readings are provided for "
139 << changes.size() <<
" HV line(s)");
141 return StatusCode::SUCCESS;
151 return StatusCode::SUCCESS;
170 onlHVCorr = *onlHVCorrHdl;
182 hasPathologyEM.resize(
m_larem_id->channel_hash_max());
183 hasPathologyHEC.resize(
m_larhec_id->channel_hash_max());
184 hasPathologyFCAL.resize(
m_larfcal_id->channel_hash_max());
186 bool doPathology=
true;
189 if(!pathologyContainer) {
197 const std::vector<LArHVPathologiesDb::LArHVElectPathologyDb> &pathCont = pathologyContainer->
getPathology();
198 const size_t nPathologies=pathCont.size();
200 ATH_MSG_INFO(
"Number of HV pathologies found " << nPathologies);
203 for(
unsigned i=0; i<nPathologies; ++i) {
208 unsigned int index = (
unsigned int)(idHash);
209 if (
index<hasPathologyEM.size()) {
211 if(hasPathologyEM[
index].size()<
static_cast<size_t>(abs(electPath.
electInd+1)))
215 std::vector<unsigned short> svec;
218 hasPathologyEM[
index]=svec;
224 unsigned int index = (
unsigned int)(idHash);
225 if (
index<hasPathologyHEC.size()) {
227 if(hasPathologyHEC[
index].size()<
static_cast<size_t>(abs(electPath.
electInd+1)))
231 std::vector<unsigned short> svec;
234 hasPathologyHEC[
index]=svec;
240 unsigned int index = (
unsigned int)(idHash);
241 if (
index<hasPathologyFCAL.size()) {
243 if(hasPathologyFCAL[
index].size()<
static_cast<size_t>(abs(electPath.
electInd+1)))
247 std::vector<unsigned short> svec;
250 hasPathologyFCAL[
index]=svec;
258 const float* rValues{
nullptr};
264 const coral::Blob& rBlob = (*attr)[
"ElectrodeRvalues"].data<coral::Blob>();
265 if(rBlob.size()/
sizeof(
float) !=
m_electrodeID->electrodeHashMax()) {
266 ATH_MSG_ERROR(
"Expected " <<
m_electrodeID->electrodeHashMax() <<
" R values, but got " << rBlob.size()/
sizeof(
float) <<
" aborting");
267 return StatusCode::FAILURE;
269 rValues =
static_cast<const float*
>(rBlob.startingAddress());
280 pathologyContainer, hasPathologyEM, hasPathologyHEC, hasPathologyFCAL, rValues));
282 std::vector<float> vScale;
287 const HWIdentifier hwid=cabling->createSignalChannelIDFromHash(hash);
290 const float hvonline = onlHVCorr->
HVScaleCorr(hwid);
291 if (hvonline>0. && hvonline<100.) vScale[i]=vScale[i]/hvonline;
294 if (vScale[i]<0.01) {
295 ATH_MSG_WARNING(
"Ignoring suspicously small correction factor of " << vScale[i] <<
" for channel " <<
m_onlineID->channel_name(hwid));
299 if (vScale[i] < 0.9) {
300 if (vScale[i] < 0.4) {
302 <<
" = " << vScale[i]);
305 <<
" = " << vScale[i]);
310 auto hvCorr = std::make_unique<LArHVCorr>(std::move(vScale), cabling,
m_calocellID);
312 if (writeHandle.
record(std::move(hvCorr)).isFailure()) {
313 ATH_MSG_ERROR(
"Could not record LArHVCorr object with " << writeHandle.
key()
314 <<
" with EventRange " << writeHandle.
getRange() <<
" into Conditions Store");
315 return StatusCode::FAILURE;
317 ATH_MSG_INFO(
"recorded new " << writeHandle.
key() <<
" with range " << writeHandle.
getRange() <<
" into Conditions Store");
319 return StatusCode::SUCCESS;
327 if (writeAffectedHandle.
isValid()) {
328 ATH_MSG_DEBUG(
"Found valid write LArAffectedRegions handle");
329 return StatusCode::SUCCESS;
342 auto vAffected = std::make_unique<CaloAffectedRegionInfoVec>();
346 return writeAffectedHandle.
getRange();
363 ATH_MSG_INFO(
"recorded new " << writeAffectedHandle.
key() <<
" with range "
364 << writeAffectedHandle.
getRange()<<
" into Conditions Store");
366 return StatusCode::SUCCESS;
375 std::vector<const CondAttrListCollection*> attrvec;
382 attrvec.push_back(cattr);
383 const EventIDRange& range = addDep (dcsHdl);
392 if (voltagePerLine.empty()) {
396 return StatusCode::SUCCESS;
408 ,
const float* rValues)
const
411 std::vector<unsigned int> listElec;
413 const float uAkOhm = 1.e-3;
422 bool hasPathology=
false;
423 if (
index<hasPathologyEM.size()) {
430 if (!embElement) std::abort();
432 unsigned int nelec = cell->getNumElectrodes();
433 unsigned int ngap = 2*nelec;
435 for (
unsigned int i=0;i<nelec;i++) {
439 for (
unsigned int igap=0;igap<2;igap++) {
442 unsigned int hvline = electrode.
hvLineNo(igap,hvCabling);
443 auto hvIt=voltage.find(hvline);
444 if(hvIt != voltage.end()) {
447 curr=hvIt->second.curr;
456 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
457 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
461 msg(MSG::VERBOSE) <<
"Original hv: "<<hv<<
" ";
462 for (
unsigned int ii=0;ii<listElec.size();ii++) {
463 if (listElec[ii]==(2*i+igap) && listElec[ii]<hasPathologyEM[
index].size() && hasPathologyEM[
index][listElec[ii]]) {
475 msg(MSG::VERBOSE) <<
"set hv: "<<hv<<
endmsg;
480 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
488 if (!embElement) std::abort();
493 for (
unsigned int igap=0;igap<2;igap++) {
496 unsigned hvline = hvmodule.
hvLineNo(igap,hvCabling);
497 auto hvIt=voltage.find(hvline);
498 if(hvIt != voltage.end()) {
501 curr=hvIt->second.curr;
510 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0;
511 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
515 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
521 bool hasPathology=
false;
522 if (
index<hasPathologyEM.size()) {
530 if (!emecElement) std::abort();
532 unsigned int nelec = cell->getNumElectrodes();
533 unsigned int ngap = 2*nelec;
535 for (
unsigned int i=0;i<nelec;i++) {
537 for (
unsigned int igap=0;igap<2;igap++) {
540 unsigned hvline = electrode.
hvLineNo(igap,hvCabling);
541 auto hvIt=voltage.find(hvline);
542 if(hvIt != voltage.end()) {
545 curr=hvIt->second.curr;
554 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
555 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
558 msg(MSG::VERBOSE) <<
"Has pathology for id: "<<
m_larem_id->print_to_string(
id)<<
" "<<hasPathologyEM[
index]<<
endmsg;
559 for (
unsigned int ii=0;ii<listElec.size();ii++) {
560 if (listElec[ii]==(2*i+igap) && listElec[ii]<hasPathologyEM[
index].size() && hasPathologyEM[
index][listElec[ii]]) {
567 hv=((hasPathologyEM[
index][listElec[ii]]&0xFFF0)>>4);
575 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
584 if (!emecElement) std::abort();
589 for (
unsigned int igap=0;igap<2;igap++) {
592 unsigned int hvline = hvmodule.
hvLineNo(igap,hvCabling);
593 auto hvIt=voltage.find(hvline);
594 if(hvIt != voltage.end()) {
597 curr=hvIt->second.curr;
606 if(curr >0.) curr *= uAkOhm * rValues[ridx];
else curr=0.;
607 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
612 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
617 ATH_MSG_ERROR(
"This could not be, what happened with EM identifiers ?");
618 return StatusCode::FAILURE;
627 bool hasPathology=
false;
628 if (
index<hasPathologyHEC.size()) {
635 if (!hecElement) std::abort();
637 unsigned int nsubgaps = cell->getNumSubgaps();
638 float wt = 1./nsubgaps;
640 for (
unsigned int i=0;i<nsubgaps;i++) {
644 unsigned int hvline = subgap.
hvLineNo(hvCabling);
645 auto hvIt=voltage.find(hvline);
646 if(hvIt != voltage.end()) {
649 curr=hvIt->second.curr;
659 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
660 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" cur. " << curr <<
" R: "<<rValues[ridx]);
664 for (
unsigned int ii=0;ii<listElec.size();ii++) {
665 if (listElec[ii]==i && listElec[ii]<hasPathologyHEC[
index].size() && hasPathologyHEC[
index][listElec[ii]]) {
680 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
690 bool hasPathology=
false;
691 if (
index<hasPathologyFCAL.size()) {
699 if (!fcalElement) std::abort();
701 unsigned int nlines = tile->getNumHVLines();
702 unsigned int nlines_found=0;
703 for (
unsigned int i=0;i<nlines;i++) {
705 if (line) nlines_found++;
707 if (nlines_found>0) {
708 float wt = 1./nlines_found;
710 for (
unsigned int i=0;i<nlines;i++) {
713 unsigned int hvline = line->hvLineNo(hvCabling);
716 auto hvIt=voltage.find(hvline);
717 if(hvIt != voltage.end()) {
720 if(rValues && useCurrent) {
721 curr=hvIt->second.curr;
731 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
732 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr." << curr <<
" R: "<<rValues[ridx]);
736 for (
unsigned int ii=0;ii<listElec.size();ii++) {
737 if (listElec[ii]==i && listElec[ii]<hasPathologyFCAL[
index].size() && hasPathologyFCAL[
index][listElec[ii]]) {
744 hv=((hasPathologyFCAL[
index][listElec[ii]]&0xFFF0)>>4);
752 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
760 return StatusCode::SUCCESS;
765 for (
unsigned int i=0;i<v.size();i++) {
766 if (std::fabs(hv-v[i].hv) <0.1) {
773 v.emplace_back(hv,wt);
780 std::vector<unsigned int> myList;
782 for(
unsigned i=0; i<pathologyContainer.
getPathology().size(); ++i) {
784 if (electPath.
cellID == (
unsigned int)(
id.get_identifier32().get_compact())) {
785 myList.push_back(electPath.
electInd);
800 for(
const auto *attrlist : fldvec) {
804 for(;citr!=citr_e;++citr) {
805 const unsigned chan=citr->first;
807 const coral::Attribute& attr=((citr)->second)[
"R_VMEAS"];
809 if (!attr.isNull()) voltage=attr.data<
float>();
810 const coral::Attribute& attrc=((citr)->second)[
"R_IMEAS"];
812 if (!attrc.isNull()) current=attrc.data<
float>();
813 ATH_MSG_VERBOSE(
"read voltage: "<<voltage<<
" and current: "<<current );
814 auto empl=result.emplace(chan,
DCS_t{voltage,current});
821 if (
auto empl = result.emplace(chan,
DCS_t{desired, 0.f}); !empl.second) {
822 DCS_t& dcs = empl.first->second;
823 ATH_MSG_DEBUG(
"Changing voltage for " << chan <<
" from " << dcs.
hv <<
" to " << desired);
826 ATH_MSG_WARNING(
"voltage set for channel " << chan <<
" unknown to DCS.");
830 if (
auto empl = result.emplace(chan,
DCS_t{0.f, desired}); !empl.second) {
831 DCS_t& dcs = empl.first->second;
832 ATH_MSG_DEBUG(
"Changing current for " << chan <<
" from " << dcs.
curr <<
" to " << desired);
835 ATH_MSG_WARNING(
"current set for channel " << chan <<
" unknown to DCS and voltage remains 0?!");
838 return StatusCode::SUCCESS;
850 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
854 const EMBHVManager& hvManager_EMB=manager->getEMBHVManager();
865 ATH_MSG_VERBOSE(
"iSide,iPhi,iSector,iEta " << iSide <<
" " << iPhi <<
" " << iSector <<
" " << iEta);
866 float phi_min=+30.,phi_max=-30.;
868 bool are_previous_HV_affected=
false;
869 bool are_previous_HV_dead=
false;
870 for (
unsigned int ielec=0;ielec<32;ielec++) {
873 double hv[2]={0.,0.};
874 for (
unsigned int iGap=0;iGap<2;iGap++) {
875 unsigned int hvline = electrode.
hvLineNo(iGap,hvCabling);
876 auto hvIt=voltage.find(hvline);
877 if(hvIt == voltage.end()) {
878 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
881 hv[iGap]=hvIt->second.hv;
884 ATH_MSG_VERBOSE(
" electrode HV " << ielec <<
" " << electrode.
getPhi() <<
" "<< hv[0] <<
" " << hv[1] );
889 bool isAffected=
false;
894 if (are_previous_HV_dead && !isDead) {
895 are_previous_HV_dead=
false;
896 ATH_MSG_VERBOSE(
" -- end dead region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
898 vAffected->push_back(current_CaloAffectedRegionInfo);
902 if (are_previous_HV_affected && !isAffected) {
903 are_previous_HV_affected=
false;
904 ATH_MSG_VERBOSE(
" -- end affected region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
906 vAffected->push_back(current_CaloAffectedRegionInfo);
910 if (!are_previous_HV_dead) {
913 ATH_MSG_VERBOSE(
" -- start dead region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
914 are_previous_HV_dead =
true;
923 if (!are_previous_HV_affected) {
926 ATH_MSG_VERBOSE(
" -- start affected region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
927 are_previous_HV_affected =
true;
931 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
937 if (are_previous_HV_affected) {
938 ATH_MSG_VERBOSE(
" -- finish affected region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
940 vAffected->push_back(current_CaloAffectedRegionInfo);
942 if (are_previous_HV_dead) {
943 ATH_MSG_VERBOSE(
" -- finish dead region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
945 vAffected->push_back(current_CaloAffectedRegionInfo);
959 ATH_MSG_VERBOSE(
"iSide,iPhi,iEta " << iSide <<
" " << iPhi <<
" " << iEta);
961 for (
int iGap=0;iGap<2;iGap++) {
962 unsigned int hvline = hvMod.
hvLineNo(iGap,hvCabling);
963 auto hvIt=voltage.find(hvline);
964 if(hvIt == voltage.end()) {
965 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
968 hv[iGap]=hvIt->second.hv;
974 ATH_MSG_VERBOSE(
" HV " << hv[0] <<
" " << hv[1] <<
" " <<
" etamin,etamax,phimin,phimax " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " << phi_max);
979 bool isAffected=
false;
985 vAffected->push_back(current_CaloAffectedRegionInfo);
989 vAffected->push_back(current_CaloAffectedRegionInfo);
996 return StatusCode::FAILURE;
998 return StatusCode::SUCCESS;
1009 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1025 ATH_MSG_VERBOSE(
"iSide,iPhi,iSector,iEta " << iSide <<
" " << iPhi <<
" " << iSector <<
" "
1026 << iEta <<
" eta_min , eta_max " << eta_min <<
" " << eta_max );
1029 float phi_min=+30.,phi_max=-30.;
1031 bool are_previous_HV_affected=
false;
1032 bool are_previous_HV_dead=
false;
1037 for (
unsigned int iGap=0;iGap<2;iGap++) {
1038 unsigned int hvline = electrode.
hvLineNo(iGap,hvCabling);
1039 auto hvIt=voltage.find(hvline);
1040 if(hvIt == voltage.end()) {
1041 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1044 hv[iGap]=hvIt->second.hv;
1051 bool isAffected=
false;
1054 <<
" " << hv[1] <<
" " <<
" isDead/isAffected " << isDead <<
" " << isAffected );
1057 if (are_previous_HV_dead && !isDead) {
1058 are_previous_HV_dead=
false;
1059 ATH_MSG_VERBOSE(
" -- end dead region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1061 vAffected->push_back(current_CaloAffectedRegionInfo);
1065 if (are_previous_HV_affected && !isAffected) {
1066 are_previous_HV_affected=
false;
1067 ATH_MSG_VERBOSE(
" -- end affected region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1069 vAffected->push_back(current_CaloAffectedRegionInfo);
1073 if (!are_previous_HV_dead) {
1076 are_previous_HV_dead =
true;
1077 ATH_MSG_VERBOSE(
" -- start dead region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
1081 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
1086 if (!are_previous_HV_affected) {
1089 are_previous_HV_affected =
true;
1090 ATH_MSG_VERBOSE(
" -- start affected region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
1094 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
1100 if (are_previous_HV_affected) {
1104 ATH_MSG_VERBOSE(
" - finih affected region after electrode loop " << eta_min <<
" " << eta_max
1105 <<
" " << phi_max <<
" " <<phi_max);
1107 vAffected->push_back(current_CaloAffectedRegionInfo);
1109 if (are_previous_HV_dead) {
1110 ATH_MSG_VERBOSE(
" -- finish dead region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_max <<
" " <<phi_max);
1112 vAffected->push_back(current_CaloAffectedRegionInfo);
1126 for (
int iGap=0;iGap<2;iGap++) {
1127 unsigned int hvline = hvMod.
hvLineNo(iGap,hvCabling);
1128 auto hvIt=voltage.find(hvline);
1129 if(hvIt == voltage.end()) {
1130 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1133 hv[iGap]=hvIt->second.hv;
1139 ATH_MSG_VERBOSE(
"iSide,iPhi" << iSide <<
" " << iPhi <<
" HV " << hv[0] <<
" " << hv[1] <<
" "
1140 <<
" etamin,etamax,phimin,phimax " << eta_min <<
" " << eta_max <<
" "
1141 << phi_min <<
" " << phi_max);
1146 bool isAffected=
false;
1152 vAffected->push_back(current_CaloAffectedRegionInfo);
1156 vAffected->push_back(current_CaloAffectedRegionInfo);
1162 return StatusCode::FAILURE;
1164 return StatusCode::SUCCESS;
1173 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1189 ATH_MSG_VERBOSE(
"iSide,iPhi,iSector,iEta " << iSide <<
" " << iPhi <<
" " << iSector <<
" "
1190 << iEta <<
" eta_min , eta_max " << eta_min <<
" " << eta_max);
1192 float phi_min=+30.,phi_max=-30.;
1194 bool are_previous_HV_affected=0;
1195 bool are_previous_HV_dead=0;
1200 for (
unsigned int iGap=0;iGap<2;iGap++) {
1201 unsigned int hvline = electrode.
hvLineNo(iGap,hvCabling);
1202 auto hvIt=voltage.find(hvline);
1203 if(hvIt == voltage.end()) {
1204 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1207 hv[iGap]=hvIt->second.hv;
1214 bool isAffected=
false;
1217 << hv[0] <<
" " << hv[1] <<
" " <<
" isDead, isAffected "
1218 << isDead <<
" " << isAffected);
1221 if (are_previous_HV_dead && !isDead) {
1222 are_previous_HV_dead=
false;
1223 ATH_MSG_VERBOSE(
" -- end dead region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1225 vAffected->push_back(current_CaloAffectedRegionInfo);
1229 if (are_previous_HV_affected && !isAffected) {
1230 are_previous_HV_affected=
false;
1231 ATH_MSG_VERBOSE(
" -- end affected region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1233 vAffected->push_back(current_CaloAffectedRegionInfo);
1237 if (!are_previous_HV_dead) {
1240 ATH_MSG_VERBOSE(
" -- start dead region " << phi_min <<
" " << phi_max);
1241 are_previous_HV_dead =
true;
1250 if (!are_previous_HV_affected) {
1253 are_previous_HV_affected =
true;
1254 ATH_MSG_VERBOSE(
" -- start affected region " << phi_min <<
" " << phi_max);
1258 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
1264 if (are_previous_HV_affected) {
1268 ATH_MSG_VERBOSE(
" - finish affected region after electrode loop " << eta_min <<
" "
1269 << eta_max <<
" " << phi_max <<
" " <<phi_max);
1271 vAffected->push_back(current_CaloAffectedRegionInfo);
1273 if (are_previous_HV_dead) {
1274 ATH_MSG_VERBOSE(
" - end dead region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_max <<
" " <<phi_max);
1276 vAffected->push_back(current_CaloAffectedRegionInfo);
1284 return StatusCode::FAILURE;
1286 return StatusCode::SUCCESS;
1295 float etamax_layer[4]={3.3,3.1,3.1,3.3};
1296 float etamin_layer[4]={1.5,1.5,1.6,1.7};
1301 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1303 const HECHVManager& hvManager_HEC=manager->getHECHVManager();
1308 float eta_min,eta_max;
1310 eta_min = etamin_layer[iSampling];
1311 eta_max = etamax_layer[iSampling];
1313 eta_min = -1.*etamax_layer[iSampling];
1314 eta_max = -1.*etamin_layer[iSampling];
1318 ATH_MSG_VERBOSE(
" iSide,iPhi,iSampling " << iSide <<
" " << iPhi <<
" " << iSampling);
1321 for (
unsigned int iGap=0;iGap<hvMod.
getNumSubgaps();iGap++) {
1323 unsigned int hvline = subgap.
hvLineNo(hvCabling);
1324 auto hvIt=voltage.find(hvline);
1325 if(hvIt == voltage.end()) {
1326 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1329 if(iGap<4) hv[iGap]=hvIt->second.hv;
1336 bool isAffected=
false;
1339 ATH_MSG_VERBOSE(
" HV values " << hv[0] <<
" " << hv[1] <<
" " << hv[2] <<
" " << hv[3] <<
" "
1340 <<
" isDead/isAffected " << isDead <<
" " << isAffected);
1347 ATH_MSG_VERBOSE(
" new dead region " << eta_min <<
" " << eta_max <<
" " << phiMin <<
" " << phiMax <<
" layer " << 8+iSampling);
1349 vAffected->push_back(current_CaloAffectedRegionInfo);
1352 ATH_MSG_VERBOSE(
" new affected region " << eta_min <<
" " << eta_max <<
" " << phiMin <<
" " << phiMax <<
" layer " << 8+iSampling);
1354 vAffected->push_back(current_CaloAffectedRegionInfo);
1362 return StatusCode::FAILURE;
1364 return StatusCode::SUCCESS;
1373 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1375 const FCALHVManager& hvManager_FCAL=manager->getFCALHVManager();
1378 float eta_min=3.1,eta_max=4.9;
1384 float HVnominal =
HV_nominal(
"FCAL",(
float)(iSampling));
1388 ATH_MSG_VERBOSE(
" FCAL HVModule side,sampling,sector " << iSide <<
" " << iSampling <<
" "
1389 << iSector <<
" HV nominal " << HVnominal);
1394 float phi_min = ((float)(iSector))*dphi;
1398 ATH_MSG_VERBOSE(
" eta_min,eta_max,phi_min,phi_max " << eta_min <<
" " << eta_max <<
" " << phi_min
1399 <<
" " << phi_max <<
" number of lines " << hvMod.
getNumHVLines());
1401 for (
unsigned int iLine=0;iLine<hvMod.
getNumHVLines();iLine++) {
1403 unsigned int ihvline = hvline.hvLineNo(hvCabling);
1404 auto hvIt=voltage.find(ihvline);
1405 if(hvIt == voltage.end()) {
1406 ATH_MSG_WARNING(
"Do not have hvline: "<<ihvline<<
" in LArHVData ! Assuming missing DCS data");
1409 if (iLine<4) hv[iLine]=hvIt->second.hv;
1415 bool isAffected=
false;
1418 ATH_MSG_VERBOSE(
" HV values " << hv[0] <<
" " << hv[1] <<
" " << hv[2] <<
" " << hv[3] <<
" "
1419 <<
" isDead/isAffected " << isDead <<
" " << isAffected);
1425 vAffected->push_back(current_CaloAffectedRegionInfo);
1430 vAffected->push_back(current_CaloAffectedRegionInfo);
1437 return StatusCode::FAILURE;
1439 return StatusCode::SUCCESS;
1455 bool is_additive1=0;
1457 int layer_min=+30,layer_max=-30;
1458 float eta_min=+30,eta_max=-30;
1459 float phi_min=+30,phi_max=-30;
1461 int layer_min_additive1=+30,layer_max_additive1=-30;
1462 float eta_min_additive1=+30,eta_max_additive1=-30;
1463 float phi_min_additive1=+30,phi_max_additive1=-30;
1465 int chans_per_feb =
m_onlineID->channelInSlotMax(febId);
1467 for (
int icha=0;icha<chans_per_feb;icha++) {
1470 if (cabling->isOnlineConnected(channelId)) {
1471 Identifier offlineId=cabling->cnvToIdentifier(channelId);
1475 float current_eta=caloddElement->
eta();
1476 float current_eta_low=caloddElement->
eta()-0.5*caloddElement->
deta();
1477 float current_eta_high=caloddElement->
eta()+0.5*caloddElement->
deta();
1478 float current_phi_low=caloddElement->
phi()-0.5*caloddElement->
dphi();
1479 float current_phi_high=caloddElement->
phi()+0.5*caloddElement->
dphi();
1481 if (caloddElement->
is_lar_em_barrel() && caloddElement->
getLayer()==3 && fabs(current_eta)>0.79 && fabs(current_eta)<1.33) {
1484 if (current_layer<layer_min_additive1)
1485 layer_min_additive1=current_layer;
1486 if (current_layer>layer_max_additive1)
1487 layer_max_additive1=current_layer;
1489 if (current_eta_low<eta_min_additive1)
1490 eta_min_additive1=current_eta_low;
1491 if (current_eta_high>eta_max_additive1)
1492 eta_max_additive1=current_eta_high;
1495 extendPhiRegion(current_phi_high,phi_min_additive1,phi_max_additive1);
1501 if (current_layer<layer_min)
1502 layer_min=current_layer;
1503 if (current_layer>layer_max)
1504 layer_max=current_layer;
1506 if (current_eta_low<eta_min)
1507 eta_min=current_eta_low;
1508 if (current_eta_high>eta_max)
1509 eta_max=current_eta_high;
1520 vAffected->push_back(current_CaloAffectedRegionInfo);
1525 vAffected->push_back(current_additive1_CaloAffectedRegionInfo);
1529 return StatusCode::SUCCESS;
1534 if (strcmp(identification,
"EMBPS")==0)
1536 else if (strcmp(identification,
"EMECPS")==0)
1538 else if (strcmp(identification,
"EMB")==0)
1540 else if (strcmp(identification,
"EMEC")==0) {
1541 if ( fabs(myparameter)<1.5 )
1543 else if (fabs(myparameter)<1.6)
1545 else if (fabs(myparameter)<1.8 )
1547 else if ( fabs(myparameter) < 2.0 )
1549 else if ( fabs(myparameter) < 2.1 )
1551 else if ( fabs(myparameter) < 2.3 )
1553 else if ( fabs(myparameter) < 2.5 )
1555 else if ( fabs(myparameter) < 2.8 )
1559 else if (strcmp(identification,
"HEC")==0) {
1562 else if (strcmp(identification,
"FCAL")==0) {
1563 if (myparameter<0.5)
1565 else if (myparameter<1.5)
1567 else if (myparameter<2.5)
1577 static const float epsilon=1e-4;
1581 if (phi_min>10. || phi_max<-10.) {
1587 bool isInRegion=
false;
1588 if (phi_min<phi_max) {
1589 if (
phi>phi_min &&
phi<phi_max) isInRegion=
true;
1592 if (
phi>phi_min ||
phi<phi_max) isInRegion=
true;
1594 if (isInRegion)
return;
1598 if (fabs(dphi1)<fabs(dphi2) )
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::vector< CaloAffectedRegionInfo > CaloAffectedRegionInfoVec
Definition of CaloDetDescrManager.
Calo Subsystem specific Detector Elements + Dummy element for testing.
CaloPhiRange class declaration.
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
GeoIntrusivePtr< const EMBCell > EMBCellConstLink
GeoIntrusivePtr< const HECCell > HECCellConstLink
@Class: HECCellConstLink
LArBadXCont< LArBadFeb > LArBadFebCont
#define DEAD_HV_THRESHOLD
#define HV_NON_NOMINAL_TOLERANCE
An AttributeList represents a logical row of attributes in a metadata table.
static const Attributes_t empty
const ServiceHandle< StoreGateSvc > & detStore() const
Header file for AthHistogramAlgorithm.
An AttributeList represents a logical row of attributes in a metadata table.
CaloSampling::CaloSample CaloSample
This class groups all DetDescr information related to a CaloCell.
virtual int getLayer() const
cell layer
float dphi() const
cell dphi
CaloCell_ID::CaloSample getSampling() const
cell sampling
float eta() const
cell eta
float phi() const
cell phi
float deta() const
cell deta
bool is_lar_em_barrel() const
cell belongs to EM barrel
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
static double fix(double phi)
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator
LAr EMB Detector Element.
EMBCellConstLink getEMBCell() const
EMB Cell description from LArReadoutGeometry.
const EMBHVModule & getModule() const
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
unsigned int getElectrodeIndex() const
This class provides direct access to information on the HV electrodes within the barrels.
unsigned int beginPhiIndex() const
unsigned int endEtaIndex() const
static unsigned int endSectorIndex()
unsigned int beginEtaIndex() const
static unsigned int beginSectorIndex()
const EMBHVModule & getHVModule(unsigned int iSide, unsigned int iEta, unsigned int iPhi, unsigned int iSector) const
unsigned int endPhiIndex() const
static unsigned int beginSideIndex()
static unsigned int endSideIndex()
Describes one HV Module within the EMB.
const EMBHVElectrode & getElectrode(unsigned int iElectrode) const
unsigned int getPhiIndex() const
unsigned int getSideIndex() const
unsigned int getEtaIndex() const
This class provides direct access to information on the HV electrodes within the barrels.
const EMBPresamplerHVModule & getHVModule(unsigned int iSide, unsigned int iEta, unsigned int iPhi) const
static unsigned int beginSideIndex()
unsigned int endPhiIndex() const
unsigned int beginPhiIndex() const
static unsigned int endSideIndex()
unsigned int endEtaIndex() const
unsigned int beginEtaIndex() const
Describes one HV Module within the EMB Presampler.
unsigned int getSideIndex() const
unsigned int getEtaIndex() const
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
Smart Pointer to EMEC Cells.
LAr EMEC Detector Element.
EMECCellConstLink getEMECCell() const
EMEC Cell description from LArReadoutGeometry.
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
unsigned int getElectrodeIndex() const
const EMECHVModule & getModule() const
This class provides direct access to information on the HV electrodes within the EMEC.
unsigned int beginEtaIndex() const
const EMECHVModule & getHVModule(unsigned int iSide, unsigned int iEta, unsigned int iPhi, unsigned int iSector) const
unsigned int beginSectorIndex() const
unsigned int endPhiIndex() const
static unsigned int beginSideIndex()
static unsigned int endSideIndex()
unsigned int endEtaIndex() const
unsigned int endSectorIndex() const
unsigned int beginPhiIndex() const
const EMECHVElectrode & getElectrode(unsigned int iElectrode) const
unsigned int getNumElectrodes() const
unsigned int getSideIndex() const
unsigned int getSectorIndex() const
unsigned int getPhiIndex() const
unsigned int getEtaIndex() const
This class provides direct access to information on the HV electrodes within the EMEC.
unsigned int beginPhiIndex() const
unsigned int endPhiIndex() const
const EMECPresamplerHVModule & getHVModule(unsigned int iSide, unsigned int iPhi) const
static unsigned int endSideIndex()
static unsigned int beginSideIndex()
Describes one HV Module within the EMEc Presampler.
unsigned int getSideIndex() const
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
LAr FCAL Detector Element.
const FCALTile * getFCALTile() const
FCAL Tile description from LArReadoutGeometry.
This class provides direct access to information on the HV electrodes within the barrels.
static unsigned int beginSideIndex()
static unsigned int endSamplingIndex()
static unsigned int endSideIndex()
static unsigned int beginSectorIndex(unsigned int iSampling)
static unsigned int beginSamplingIndex()
const FCALHVModule & getHVModule(unsigned int iSide, unsigned int iSector, unsigned int iSampling) const
static unsigned int endSectorIndex(unsigned int iSampling)
Describes one HV Module within the FCAL.
const FCALHVLine & getHVLine(unsigned int iLine) const
unsigned int getSamplingIndex() const
unsigned int getSideIndex() const
unsigned int getSectorIndex() const
static unsigned int getNumHVLines()
A tile of the forward calorimeter readout geometry.
LAr HEC Detector Element.
HECCellConstLink getHECCell() const
HEC Cell description from LArReadoutGeometry.
This class provides direct access to information on the HV electrodes within the barrels.
static unsigned int beginPhiIndex()
static unsigned int endSamplingIndex()
const HECHVModule & getHVModule(unsigned int iSide, unsigned int iPhi, unsigned int iSampling) const
static unsigned int endSideIndex()
static unsigned int beginSideIndex()
static unsigned int beginSamplingIndex()
static unsigned int endPhiIndex()
Describes one HV Module within the HEC.
const HECHVSubgap & getSubgap(unsigned int iElectrode) const
unsigned int getSideIndex() const
unsigned int getSamplingIndex() const
static unsigned int getNumSubgaps()
const HECHVModule & getModule() const
unsigned int getSubgapIndex() const
int hvLineNo(const LArHVIdMapping *hvIdMapping) const
virtual const float & HVScaleCorr(const HWIdentifier &id) const =0
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
This is a "hash" representation of an Identifier.
bool deadReadout() const
FEB is not sending readout data, but the L1 trigger path is working.
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
void extendPhiRegion(float phi, float &phi_min, float &phi_max) const
Gaudi::Property< bool > m_doHV
StatusCode execute(const EventContext &ctx) const override
const LArHVLineID * m_hvLineID
SG::ReadCondHandleKey< ILArHVScaleCorr > m_onlineHVScaleCorrKey
const CaloCell_ID * m_calocellID
SG::ReadCondHandleKey< AthenaAttributeList > m_hvRKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
void addHV(voltageCell_t &v, float hv, float weight) const
Add voltage/weight for a sub-gap of a cell.
Gaudi::Property< bool > m_useCurrentFCAL1
Gaudi::Property< bool > m_useCurrentEMB
SG::ReadCondHandleKey< LArHVPathology > m_pathologiesKey
Gaudi::Property< bool > m_undoOnlineHVCorr
Gaudi::Property< std::vector< std::string > > m_fixHVCorrStrings
StatusCode searchNonNominalHV_EMEC_INNER(CaloAffectedRegionInfoVec *vAffected, const LArHVIdMapping *hvCabling, const voltagePerLine_t &voltage) const
StatusCode fixVoltageAndCurrent()
StatusCode searchNonNominalHV_HEC(CaloAffectedRegionInfoVec *vAffected, const LArHVIdMapping *hvCabling, const voltagePerLine_t &voltage) const
StatusCode searchNonNominalHV_FCAL(CaloAffectedRegionInfoVec *vAffected, const LArHVIdMapping *hvCabling, const voltagePerLine_t &voltage) const
SG::ReadCondHandleKeyArray< CondAttrListCollection > m_DCSFolderKeys
std::unordered_map< unsigned, DCS_t > voltagePerLine_t
SG::WriteCondHandleKey< LArHVCorr > m_outputHVScaleCorrKey
std::function< const EventIDRange &(SG::ReadCondHandle< CondAttrListCollection > &h)> addDepFcn_t
std::unordered_map< unsigned, float > m_fixCurrentPerLine
SG::WriteCondHandleKey< CaloAffectedRegionInfoVec > m_affectedKey
std::vector< unsigned int > getElecList(const Identifier &id, const LArHVPathology &pathologies) const
StatusCode updateMethod(const EventContext &ctx, CaloAffectedRegionInfoVec *vAffected, const LArBadFebCont *bfCont, const LArOnOffIdMapping *cabling) const
std::unique_ptr< const LArHVScaleCorrTool > m_scaleTool
StatusCode searchNonNominalHV_EMB(CaloAffectedRegionInfoVec *vAffected, const LArHVIdMapping *hvCabling, const voltagePerLine_t &voltage) const
StatusCode makeAffectedRegionInfo(const EventContext &ctx, voltagePerLine_t &voltagePerLine) const
LArHVScaleCorrTool::voltageCell_t voltageCell_t
const LArElectrodeID * m_electrodeID
StatusCode getVoltagePerLine(const EventContext &ctx, voltagePerLine_t &voltagePerLine, const addDepFcn_t &addDep) const
std::vector< voltageCell_t > voltagePerCell_t
const LArHEC_ID * m_larhec_id
SG::ReadCondHandleKey< LArBadFebCont > m_BFKey
std::unordered_map< unsigned, float > m_fixVoltagePerLine
Gaudi::Property< std::vector< std::string > > m_fixHVStrings
std::atomic< unsigned > m_nPathologies
StatusCode makeHVScaleCorr(const EventContext &ctx, voltagePerLine_t &voltagePerLine) const
virtual StatusCode initialize() override
const LArOnlineID * m_onlineID
Gaudi::Property< bool > m_doRProp
StatusCode fillPathAndCellHV(const CaloDetDescrManager *calodetdescrmgr, voltagePerCell_t &hvdata, const LArHVIdMapping *hvCabling, const voltagePerLine_t &voltage, const LArHVPathology &pathologies, pathVec &hasPathologyEM, pathVec &hasPathologyHEC, pathVec &hasPathologyFCAL, const float *rValues) const
Read the voltage per HV line and store it in structure per readout-cell (resolve the many-HV-lines-to...
Gaudi::Property< bool > m_doAffected
StatusCode searchNonNominalHV_EMEC_OUTER(CaloAffectedRegionInfoVec *vAffected, const LArHVIdMapping *hvCabling, const voltagePerLine_t &voltage) const
const LArEM_ID * m_larem_id
Gaudi::Property< bool > m_doAffectedHV
Gaudi::Property< std::vector< std::string > > m_fixCurrentStrings
StatusCode dcs2LineVoltage(voltagePerLine_t &result, const std::vector< const CondAttrListCollection * > &fldvec) const
Read HV from DCS, store them in internal data structure per HV-line (Step 1)
const LArFCAL_ID * m_larfcal_id
SG::ReadCondHandleKey< LArHVIdMapping > m_hvMappingKey
Gaudi::Property< bool > m_useCurrentOthers
std::vector< std::vector< unsigned short > > pathVec
Internal structure for HV pathologies.
float HV_nominal(const char *identification, const float eta) const
int getCellModule(const Identifier &offId) const
returns the Module of a given offId
This class provides access to the High Voltage throughout the LAr.
static const unsigned short MaskCurr
static const unsigned short SetHVMask
static const unsigned short MaskHV
const std::vector< LArHVPathologiesDb::LArHVElectPathologyDb > & getPathology() const
const std::string & key() const
const EventIDRange & getRange()
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
unsigned short pathologyType