37#include "CoralBase/Blob.h"
42#define HV_NON_NOMINAL_TOLERANCE 10
43#define DEAD_HV_THRESHOLD 10
44#define MAX_LAR_CELLS 182468
61 ATH_MSG_INFO(
"Will use currents to correct voltage-drop at HV-resistors");
64 ATH_MSG_INFO(
"Will NOT correct voltage-drop at HV-resistors");
86 return StatusCode::SUCCESS;
102 return StatusCode::SUCCESS;
111 return StatusCode::SUCCESS;
130 onlHVCorr = *onlHVCorrHdl;
142 hasPathologyEM.resize(
m_larem_id->channel_hash_max());
143 hasPathologyHEC.resize(
m_larhec_id->channel_hash_max());
144 hasPathologyFCAL.resize(
m_larfcal_id->channel_hash_max());
146 bool doPathology=
true;
149 if(!pathologyContainer) {
157 const std::vector<LArHVPathologiesDb::LArHVElectPathologyDb> &pathCont = pathologyContainer->
getPathology();
158 const size_t nPathologies=pathCont.size();
160 ATH_MSG_INFO(
"Number of HV pathologies found " << nPathologies);
163 for(
unsigned i=0; i<nPathologies; ++i) {
168 unsigned int index = (
unsigned int)(idHash);
169 if (
index<hasPathologyEM.size()) {
171 if(hasPathologyEM[
index].size()<
static_cast<size_t>(abs(electPath.
electInd+1)))
175 std::vector<unsigned short> svec;
178 hasPathologyEM[
index]=svec;
184 unsigned int index = (
unsigned int)(idHash);
185 if (
index<hasPathologyHEC.size()) {
187 if(hasPathologyHEC[
index].size()<
static_cast<size_t>(abs(electPath.
electInd+1)))
191 std::vector<unsigned short> svec;
194 hasPathologyHEC[
index]=svec;
200 unsigned int index = (
unsigned int)(idHash);
201 if (
index<hasPathologyFCAL.size()) {
203 if(hasPathologyFCAL[
index].size()<
static_cast<size_t>(abs(electPath.
electInd+1)))
207 std::vector<unsigned short> svec;
210 hasPathologyFCAL[
index]=svec;
218 const float* rValues{
nullptr};
224 const coral::Blob& rBlob = (*attr)[
"ElectrodeRvalues"].data<coral::Blob>();
225 if(rBlob.size()/
sizeof(
float) !=
m_electrodeID->electrodeHashMax()) {
226 ATH_MSG_ERROR(
"Expected " <<
m_electrodeID->electrodeHashMax() <<
" R values, but got " << rBlob.size()/
sizeof(
float) <<
" aborting");
227 return StatusCode::FAILURE;
229 rValues =
static_cast<const float*
>(rBlob.startingAddress());
240 pathologyContainer, hasPathologyEM, hasPathologyHEC, hasPathologyFCAL, rValues));
242 std::vector<float> vScale;
247 const HWIdentifier hwid=cabling->createSignalChannelIDFromHash(hash);
250 const float hvonline = onlHVCorr->
HVScaleCorr(hwid);
251 if (hvonline>0. && hvonline<100.) vScale[i]=vScale[i]/hvonline;
254 if (vScale[i]<0.01) {
255 ATH_MSG_WARNING(
"Ignoring suspicously small correction factor of " << vScale[i] <<
" for channel " <<
m_onlineID->channel_name(hwid));
259 if (vScale[i] < 0.9) {
260 if (vScale[i] < 0.4) {
262 <<
" = " << vScale[i]);
265 <<
" = " << vScale[i]);
270 auto hvCorr = std::make_unique<LArHVCorr>(std::move(vScale), cabling,
m_calocellID);
272 if (writeHandle.
record(std::move(hvCorr)).isFailure()) {
273 ATH_MSG_ERROR(
"Could not record LArHVCorr object with " << writeHandle.
key()
274 <<
" with EventRange " << writeHandle.
getRange() <<
" into Conditions Store");
275 return StatusCode::FAILURE;
277 ATH_MSG_INFO(
"recorded new " << writeHandle.
key() <<
" with range " << writeHandle.
getRange() <<
" into Conditions Store");
279 return StatusCode::SUCCESS;
287 if (writeAffectedHandle.
isValid()) {
288 ATH_MSG_DEBUG(
"Found valid write LArAffectedRegions handle");
289 return StatusCode::SUCCESS;
302 auto vAffected = std::make_unique<CaloAffectedRegionInfoVec>();
306 return writeAffectedHandle.
getRange();
323 ATH_MSG_INFO(
"recorded new " << writeAffectedHandle.
key() <<
" with range "
324 << writeAffectedHandle.
getRange()<<
" into Conditions Store");
326 return StatusCode::SUCCESS;
335 std::vector<const CondAttrListCollection*> attrvec;
342 attrvec.push_back(cattr);
343 const EventIDRange& range = addDep (dcsHdl);
352 if (voltagePerLine.empty()) {
356 return StatusCode::SUCCESS;
368 ,
const float* rValues)
const
371 std::vector<unsigned int> listElec;
373 const float uAkOhm = 1.e-3;
382 bool hasPathology=
false;
383 if (
index<hasPathologyEM.size()) {
390 if (!embElement) std::abort();
392 unsigned int nelec = cell->getNumElectrodes();
393 unsigned int ngap = 2*nelec;
395 for (
unsigned int i=0;i<nelec;i++) {
399 for (
unsigned int igap=0;igap<2;igap++) {
402 unsigned int hvline = electrode.
hvLineNo(igap,hvCabling);
403 auto hvIt=voltage.find(hvline);
404 if(hvIt != voltage.end()) {
407 curr=hvIt->second.curr;
416 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
417 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
421 msg(MSG::VERBOSE) <<
"Original hv: "<<hv<<
" ";
422 for (
unsigned int ii=0;ii<listElec.size();ii++) {
423 if (listElec[ii]==(2*i+igap) && listElec[ii]<hasPathologyEM[
index].size() && hasPathologyEM[
index][listElec[ii]]) {
435 msg(MSG::VERBOSE) <<
"set hv: "<<hv<<
endmsg;
440 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
448 if (!embElement) std::abort();
453 for (
unsigned int igap=0;igap<2;igap++) {
456 unsigned hvline = hvmodule.
hvLineNo(igap,hvCabling);
457 auto hvIt=voltage.find(hvline);
458 if(hvIt != voltage.end()) {
461 curr=hvIt->second.curr;
470 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0;
471 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
475 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
481 bool hasPathology=
false;
482 if (
index<hasPathologyEM.size()) {
490 if (!emecElement) std::abort();
492 unsigned int nelec = cell->getNumElectrodes();
493 unsigned int ngap = 2*nelec;
495 for (
unsigned int i=0;i<nelec;i++) {
497 for (
unsigned int igap=0;igap<2;igap++) {
500 unsigned hvline = electrode.
hvLineNo(igap,hvCabling);
501 auto hvIt=voltage.find(hvline);
502 if(hvIt != voltage.end()) {
505 curr=hvIt->second.curr;
514 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
515 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
518 msg(MSG::VERBOSE) <<
"Has pathology for id: "<<
m_larem_id->print_to_string(
id)<<
" "<<hasPathologyEM[
index]<<
endmsg;
519 for (
unsigned int ii=0;ii<listElec.size();ii++) {
520 if (listElec[ii]==(2*i+igap) && listElec[ii]<hasPathologyEM[
index].size() && hasPathologyEM[
index][listElec[ii]]) {
527 hv=((hasPathologyEM[
index][listElec[ii]]&0xFFF0)>>4);
535 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
544 if (!emecElement) std::abort();
549 for (
unsigned int igap=0;igap<2;igap++) {
552 unsigned int hvline = hvmodule.
hvLineNo(igap,hvCabling);
553 auto hvIt=voltage.find(hvline);
554 if(hvIt != voltage.end()) {
557 curr=hvIt->second.curr;
566 if(curr >0.) curr *= uAkOhm * rValues[ridx];
else curr=0.;
567 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
572 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
577 ATH_MSG_ERROR(
"This could not be, what happened with EM identifiers ?");
578 return StatusCode::FAILURE;
587 bool hasPathology=
false;
588 if (
index<hasPathologyHEC.size()) {
595 if (!hecElement) std::abort();
597 unsigned int nsubgaps = cell->getNumSubgaps();
598 float wt = 1./nsubgaps;
600 for (
unsigned int i=0;i<nsubgaps;i++) {
604 unsigned int hvline = subgap.
hvLineNo(hvCabling);
605 auto hvIt=voltage.find(hvline);
606 if(hvIt != voltage.end()) {
609 curr=hvIt->second.curr;
619 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
620 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" cur. " << curr <<
" R: "<<rValues[ridx]);
624 for (
unsigned int ii=0;ii<listElec.size();ii++) {
625 if (listElec[ii]==i && listElec[ii]<hasPathologyHEC[
index].size() && hasPathologyHEC[
index][listElec[ii]]) {
640 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
650 bool hasPathology=
false;
651 if (
index<hasPathologyFCAL.size()) {
659 if (!fcalElement) std::abort();
661 unsigned int nlines = tile->getNumHVLines();
662 unsigned int nlines_found=0;
663 for (
unsigned int i=0;i<nlines;i++) {
665 if (line) nlines_found++;
667 if (nlines_found>0) {
668 float wt = 1./nlines_found;
670 for (
unsigned int i=0;i<nlines;i++) {
673 unsigned int hvline = line->hvLineNo(hvCabling);
676 auto hvIt=voltage.find(hvline);
677 if(hvIt != voltage.end()) {
680 if(rValues && useCurrent) {
681 curr=hvIt->second.curr;
691 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
692 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr." << curr <<
" R: "<<rValues[ridx]);
696 for (
unsigned int ii=0;ii<listElec.size();ii++) {
697 if (listElec[ii]==i && listElec[ii]<hasPathologyFCAL[
index].size() && hasPathologyFCAL[
index][listElec[ii]]) {
704 hv=((hasPathologyFCAL[
index][listElec[ii]]&0xFFF0)>>4);
712 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
720 return StatusCode::SUCCESS;
725 for (
unsigned int i=0;i<v.size();i++) {
726 if (std::fabs(hv-v[i].hv) <0.1) {
733 v.emplace_back(hv,wt);
740 std::vector<unsigned int> myList;
742 for(
unsigned i=0; i<pathologyContainer.
getPathology().size(); ++i) {
744 if (electPath.
cellID == (
unsigned int)(
id.get_identifier32().get_compact())) {
745 myList.push_back(electPath.
electInd);
760 for(
const auto *attrlist : fldvec) {
764 for(;citr!=citr_e;++citr) {
765 const unsigned chan=citr->first;
767 const coral::Attribute& attr=((citr)->second)[
"R_VMEAS"];
769 if (!attr.isNull()) voltage=attr.data<
float>();
770 const coral::Attribute& attrc=((citr)->second)[
"R_IMEAS"];
772 if (!attrc.isNull()) current=attrc.data<
float>();
773 ATH_MSG_VERBOSE(
"read voltage: "<<voltage<<
" and current: "<<current );
774 auto empl=
result.emplace(chan,
DCS_t{voltage,current});
780 return StatusCode::SUCCESS;
791 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
795 const EMBHVManager& hvManager_EMB=manager->getEMBHVManager();
806 ATH_MSG_VERBOSE(
"iSide,iPhi,iSector,iEta " << iSide <<
" " << iPhi <<
" " << iSector <<
" " << iEta);
807 float phi_min=+30.,phi_max=-30.;
809 bool are_previous_HV_affected=
false;
810 bool are_previous_HV_dead=
false;
811 for (
unsigned int ielec=0;ielec<32;ielec++) {
814 double hv[2]={0.,0.};
815 for (
unsigned int iGap=0;iGap<2;iGap++) {
816 unsigned int hvline = electrode.
hvLineNo(iGap,hvCabling);
817 auto hvIt=voltage.find(hvline);
818 if(hvIt == voltage.end()) {
819 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
822 hv[iGap]=hvIt->second.hv;
825 ATH_MSG_VERBOSE(
" electrode HV " << ielec <<
" " << electrode.
getPhi() <<
" "<< hv[0] <<
" " << hv[1] );
830 bool isAffected=
false;
835 if (are_previous_HV_dead && !isDead) {
836 are_previous_HV_dead=
false;
837 ATH_MSG_VERBOSE(
" -- end dead region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
839 vAffected->push_back(current_CaloAffectedRegionInfo);
843 if (are_previous_HV_affected && !isAffected) {
844 are_previous_HV_affected=
false;
845 ATH_MSG_VERBOSE(
" -- end affected region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
847 vAffected->push_back(current_CaloAffectedRegionInfo);
851 if (!are_previous_HV_dead) {
854 ATH_MSG_VERBOSE(
" -- start dead region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
855 are_previous_HV_dead =
true;
864 if (!are_previous_HV_affected) {
867 ATH_MSG_VERBOSE(
" -- start affected region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
868 are_previous_HV_affected =
true;
872 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
878 if (are_previous_HV_affected) {
879 ATH_MSG_VERBOSE(
" -- finish affected region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
881 vAffected->push_back(current_CaloAffectedRegionInfo);
883 if (are_previous_HV_dead) {
884 ATH_MSG_VERBOSE(
" -- finish dead region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
886 vAffected->push_back(current_CaloAffectedRegionInfo);
900 ATH_MSG_VERBOSE(
"iSide,iPhi,iEta " << iSide <<
" " << iPhi <<
" " << iEta);
902 for (
int iGap=0;iGap<2;iGap++) {
903 unsigned int hvline = hvMod.
hvLineNo(iGap,hvCabling);
904 auto hvIt=voltage.find(hvline);
905 if(hvIt == voltage.end()) {
906 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
909 hv[iGap]=hvIt->second.hv;
915 ATH_MSG_VERBOSE(
" HV " << hv[0] <<
" " << hv[1] <<
" " <<
" etamin,etamax,phimin,phimax " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " << phi_max);
920 bool isAffected=
false;
926 vAffected->push_back(current_CaloAffectedRegionInfo);
930 vAffected->push_back(current_CaloAffectedRegionInfo);
937 return StatusCode::FAILURE;
939 return StatusCode::SUCCESS;
950 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
966 ATH_MSG_VERBOSE(
"iSide,iPhi,iSector,iEta " << iSide <<
" " << iPhi <<
" " << iSector <<
" "
967 << iEta <<
" eta_min , eta_max " << eta_min <<
" " << eta_max );
970 float phi_min=+30.,phi_max=-30.;
972 bool are_previous_HV_affected=
false;
973 bool are_previous_HV_dead=
false;
978 for (
unsigned int iGap=0;iGap<2;iGap++) {
979 unsigned int hvline = electrode.
hvLineNo(iGap,hvCabling);
980 auto hvIt=voltage.find(hvline);
981 if(hvIt == voltage.end()) {
982 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
985 hv[iGap]=hvIt->second.hv;
992 bool isAffected=
false;
995 <<
" " << hv[1] <<
" " <<
" isDead/isAffected " << isDead <<
" " << isAffected );
998 if (are_previous_HV_dead && !isDead) {
999 are_previous_HV_dead=
false;
1000 ATH_MSG_VERBOSE(
" -- end dead region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1002 vAffected->push_back(current_CaloAffectedRegionInfo);
1006 if (are_previous_HV_affected && !isAffected) {
1007 are_previous_HV_affected=
false;
1008 ATH_MSG_VERBOSE(
" -- end affected region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1010 vAffected->push_back(current_CaloAffectedRegionInfo);
1014 if (!are_previous_HV_dead) {
1017 are_previous_HV_dead =
true;
1018 ATH_MSG_VERBOSE(
" -- start dead region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
1022 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
1027 if (!are_previous_HV_affected) {
1030 are_previous_HV_affected =
true;
1031 ATH_MSG_VERBOSE(
" -- start affected region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
1035 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
1041 if (are_previous_HV_affected) {
1045 ATH_MSG_VERBOSE(
" - finih affected region after electrode loop " << eta_min <<
" " << eta_max
1046 <<
" " << phi_max <<
" " <<phi_max);
1048 vAffected->push_back(current_CaloAffectedRegionInfo);
1050 if (are_previous_HV_dead) {
1051 ATH_MSG_VERBOSE(
" -- finish dead region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_max <<
" " <<phi_max);
1053 vAffected->push_back(current_CaloAffectedRegionInfo);
1067 for (
int iGap=0;iGap<2;iGap++) {
1068 unsigned int hvline = hvMod.
hvLineNo(iGap,hvCabling);
1069 auto hvIt=voltage.find(hvline);
1070 if(hvIt == voltage.end()) {
1071 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1074 hv[iGap]=hvIt->second.hv;
1080 ATH_MSG_VERBOSE(
"iSide,iPhi" << iSide <<
" " << iPhi <<
" HV " << hv[0] <<
" " << hv[1] <<
" "
1081 <<
" etamin,etamax,phimin,phimax " << eta_min <<
" " << eta_max <<
" "
1082 << phi_min <<
" " << phi_max);
1087 bool isAffected=
false;
1093 vAffected->push_back(current_CaloAffectedRegionInfo);
1097 vAffected->push_back(current_CaloAffectedRegionInfo);
1103 return StatusCode::FAILURE;
1105 return StatusCode::SUCCESS;
1114 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1130 ATH_MSG_VERBOSE(
"iSide,iPhi,iSector,iEta " << iSide <<
" " << iPhi <<
" " << iSector <<
" "
1131 << iEta <<
" eta_min , eta_max " << eta_min <<
" " << eta_max);
1133 float phi_min=+30.,phi_max=-30.;
1135 bool are_previous_HV_affected=0;
1136 bool are_previous_HV_dead=0;
1141 for (
unsigned int iGap=0;iGap<2;iGap++) {
1142 unsigned int hvline = electrode.
hvLineNo(iGap,hvCabling);
1143 auto hvIt=voltage.find(hvline);
1144 if(hvIt == voltage.end()) {
1145 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1148 hv[iGap]=hvIt->second.hv;
1155 bool isAffected=
false;
1158 << hv[0] <<
" " << hv[1] <<
" " <<
" isDead, isAffected "
1159 << isDead <<
" " << isAffected);
1162 if (are_previous_HV_dead && !isDead) {
1163 are_previous_HV_dead=
false;
1164 ATH_MSG_VERBOSE(
" -- end dead region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1166 vAffected->push_back(current_CaloAffectedRegionInfo);
1170 if (are_previous_HV_affected && !isAffected) {
1171 are_previous_HV_affected=
false;
1172 ATH_MSG_VERBOSE(
" -- end affected region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1174 vAffected->push_back(current_CaloAffectedRegionInfo);
1178 if (!are_previous_HV_dead) {
1181 ATH_MSG_VERBOSE(
" -- start dead region " << phi_min <<
" " << phi_max);
1182 are_previous_HV_dead =
true;
1191 if (!are_previous_HV_affected) {
1194 are_previous_HV_affected =
true;
1195 ATH_MSG_VERBOSE(
" -- start affected region " << phi_min <<
" " << phi_max);
1199 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
1205 if (are_previous_HV_affected) {
1209 ATH_MSG_VERBOSE(
" - finish affected region after electrode loop " << eta_min <<
" "
1210 << eta_max <<
" " << phi_max <<
" " <<phi_max);
1212 vAffected->push_back(current_CaloAffectedRegionInfo);
1214 if (are_previous_HV_dead) {
1215 ATH_MSG_VERBOSE(
" - end dead region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_max <<
" " <<phi_max);
1217 vAffected->push_back(current_CaloAffectedRegionInfo);
1225 return StatusCode::FAILURE;
1227 return StatusCode::SUCCESS;
1236 float etamax_layer[4]={3.3,3.1,3.1,3.3};
1237 float etamin_layer[4]={1.5,1.5,1.6,1.7};
1242 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1244 const HECHVManager& hvManager_HEC=manager->getHECHVManager();
1249 float eta_min,eta_max;
1251 eta_min = etamin_layer[iSampling];
1252 eta_max = etamax_layer[iSampling];
1254 eta_min = -1.*etamax_layer[iSampling];
1255 eta_max = -1.*etamin_layer[iSampling];
1259 ATH_MSG_VERBOSE(
" iSide,iPhi,iSampling " << iSide <<
" " << iPhi <<
" " << iSampling);
1262 for (
unsigned int iGap=0;iGap<hvMod.
getNumSubgaps();iGap++) {
1264 unsigned int hvline = subgap.
hvLineNo(hvCabling);
1265 auto hvIt=voltage.find(hvline);
1266 if(hvIt == voltage.end()) {
1267 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1270 if(iGap<4) hv[iGap]=hvIt->second.hv;
1277 bool isAffected=
false;
1280 ATH_MSG_VERBOSE(
" HV values " << hv[0] <<
" " << hv[1] <<
" " << hv[2] <<
" " << hv[3] <<
" "
1281 <<
" isDead/isAffected " << isDead <<
" " << isAffected);
1288 ATH_MSG_VERBOSE(
" new dead region " << eta_min <<
" " << eta_max <<
" " << phiMin <<
" " << phiMax <<
" layer " << 8+iSampling);
1290 vAffected->push_back(current_CaloAffectedRegionInfo);
1293 ATH_MSG_VERBOSE(
" new affected region " << eta_min <<
" " << eta_max <<
" " << phiMin <<
" " << phiMax <<
" layer " << 8+iSampling);
1295 vAffected->push_back(current_CaloAffectedRegionInfo);
1303 return StatusCode::FAILURE;
1305 return StatusCode::SUCCESS;
1314 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1316 const FCALHVManager& hvManager_FCAL=manager->getFCALHVManager();
1319 float eta_min=3.1,eta_max=4.9;
1325 float HVnominal =
HV_nominal(
"FCAL",(
float)(iSampling));
1329 ATH_MSG_VERBOSE(
" FCAL HVModule side,sampling,sector " << iSide <<
" " << iSampling <<
" "
1330 << iSector <<
" HV nominal " << HVnominal);
1335 float phi_min = ((float)(iSector))*dphi;
1339 ATH_MSG_VERBOSE(
" eta_min,eta_max,phi_min,phi_max " << eta_min <<
" " << eta_max <<
" " << phi_min
1340 <<
" " << phi_max <<
" number of lines " << hvMod.
getNumHVLines());
1342 for (
unsigned int iLine=0;iLine<hvMod.
getNumHVLines();iLine++) {
1344 unsigned int ihvline = hvline.hvLineNo(hvCabling);
1345 auto hvIt=voltage.find(ihvline);
1346 if(hvIt == voltage.end()) {
1347 ATH_MSG_WARNING(
"Do not have hvline: "<<ihvline<<
" in LArHVData ! Assuming missing DCS data");
1350 if (iLine<4) hv[iLine]=hvIt->second.hv;
1356 bool isAffected=
false;
1359 ATH_MSG_VERBOSE(
" HV values " << hv[0] <<
" " << hv[1] <<
" " << hv[2] <<
" " << hv[3] <<
" "
1360 <<
" isDead/isAffected " << isDead <<
" " << isAffected);
1366 vAffected->push_back(current_CaloAffectedRegionInfo);
1371 vAffected->push_back(current_CaloAffectedRegionInfo);
1378 return StatusCode::FAILURE;
1380 return StatusCode::SUCCESS;
1396 bool is_additive1=0;
1398 int layer_min=+30,layer_max=-30;
1399 float eta_min=+30,eta_max=-30;
1400 float phi_min=+30,phi_max=-30;
1402 int layer_min_additive1=+30,layer_max_additive1=-30;
1403 float eta_min_additive1=+30,eta_max_additive1=-30;
1404 float phi_min_additive1=+30,phi_max_additive1=-30;
1406 int chans_per_feb =
m_onlineID->channelInSlotMax(febId);
1408 for (
int icha=0;icha<chans_per_feb;icha++) {
1411 if (cabling->isOnlineConnected(channelId)) {
1412 Identifier offlineId=cabling->cnvToIdentifier(channelId);
1416 float current_eta=caloddElement->
eta();
1417 float current_eta_low=caloddElement->
eta()-0.5*caloddElement->
deta();
1418 float current_eta_high=caloddElement->
eta()+0.5*caloddElement->
deta();
1419 float current_phi_low=caloddElement->
phi()-0.5*caloddElement->
dphi();
1420 float current_phi_high=caloddElement->
phi()+0.5*caloddElement->
dphi();
1422 if (caloddElement->
is_lar_em_barrel() && caloddElement->
getLayer()==3 && fabs(current_eta)>0.79 && fabs(current_eta)<1.33) {
1425 if (current_layer<layer_min_additive1)
1426 layer_min_additive1=current_layer;
1427 if (current_layer>layer_max_additive1)
1428 layer_max_additive1=current_layer;
1430 if (current_eta_low<eta_min_additive1)
1431 eta_min_additive1=current_eta_low;
1432 if (current_eta_high>eta_max_additive1)
1433 eta_max_additive1=current_eta_high;
1436 extendPhiRegion(current_phi_high,phi_min_additive1,phi_max_additive1);
1442 if (current_layer<layer_min)
1443 layer_min=current_layer;
1444 if (current_layer>layer_max)
1445 layer_max=current_layer;
1447 if (current_eta_low<eta_min)
1448 eta_min=current_eta_low;
1449 if (current_eta_high>eta_max)
1450 eta_max=current_eta_high;
1461 vAffected->push_back(current_CaloAffectedRegionInfo);
1466 vAffected->push_back(current_additive1_CaloAffectedRegionInfo);
1470 return StatusCode::SUCCESS;
1475 if (strcmp(identification,
"EMBPS")==0)
1477 else if (strcmp(identification,
"EMECPS")==0)
1479 else if (strcmp(identification,
"EMB")==0)
1481 else if (strcmp(identification,
"EMEC")==0) {
1482 if ( fabs(myparameter)<1.5 )
1484 else if (fabs(myparameter)<1.6)
1486 else if (fabs(myparameter)<1.8 )
1488 else if ( fabs(myparameter) < 2.0 )
1490 else if ( fabs(myparameter) < 2.1 )
1492 else if ( fabs(myparameter) < 2.3 )
1494 else if ( fabs(myparameter) < 2.5 )
1496 else if ( fabs(myparameter) < 2.8 )
1500 else if (strcmp(identification,
"HEC")==0) {
1503 else if (strcmp(identification,
"FCAL")==0) {
1504 if (myparameter<0.5)
1506 else if (myparameter<1.5)
1508 else if (myparameter<2.5)
1518 static const float epsilon=1e-4;
1522 if (phi_min>10. || phi_max<-10.) {
1528 bool isInRegion=
false;
1529 if (phi_min<phi_max) {
1530 if (
phi>phi_min &&
phi<phi_max) isInRegion=
true;
1533 if (
phi>phi_min ||
phi<phi_max) isInRegion=
true;
1535 if (isInRegion)
return;
1539 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
StatusCode searchNonNominalHV_EMEC_INNER(CaloAffectedRegionInfoVec *vAffected, const LArHVIdMapping *hvCabling, const voltagePerLine_t &voltage) const
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
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
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
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