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");
92 return StatusCode::SUCCESS;
108 return StatusCode::SUCCESS;
115 std::set<unsigned> changes;
118 for (
auto [prop, store]: items) {
120 for (
auto& p: prop->value()) {
121 std::stringstream
ss(p);
124 ss >> hvline >> value >> std::skipws;
125 if (
ss &&
ss.eof()) {
126 changes.insert(hvline);
127 if (
auto empl = store->emplace(hvline, value); !empl.second) {
128 ATH_MSG_WARNING(
"Setting multiple times HV and/or current for line " << hvline
129 <<
", this will replace the previous value(s).");
130 empl.first->second = value;
134 ATH_MSG_ERROR(
"Couldn't interpret HV or current setting: \"" << p <<
"\"");
135 return StatusCode::FAILURE;
138 if (changes.size() > 0) {
139 ATH_MSG_INFO(
"Fixed values of voltage and/or current to be used instead of DCS readings are provided for "
140 << changes.size() <<
" HV line(s)");
142 return StatusCode::SUCCESS;
149 constexpr int RESIDUAL = 0, FULL = 1;
150 std::map<int, SG::WriteCondHandle<LArHVCorr>> writeHandle;
151 for (
int ct: {RESIDUAL, FULL}) {
153 if (key.empty())
continue;
154 auto itr = writeHandle.try_emplace(ct, key, ctx).first;
155 if (itr->second.isValid()) {
156 ATH_MSG_DEBUG(
"Found valid write handle for LArHVCorr, key " << key.key());
157 writeHandle.erase(itr);
160 if (writeHandle.empty())
return StatusCode::SUCCESS;
161 const bool doFull = writeHandle.count(FULL), doResid = writeHandle.count(RESIDUAL);
162 auto addDep = [&](
auto& dep,
const char* debugDescr=
nullptr) {
163 for (
auto&[ct, wh]: writeHandle) {
164 wh.addDependency(dep);
165 if (!debugDescr)
return;
167 if constexpr(
requires{dep.getRange();}) {
173 <<
", intersection (corr. type " << ct <<
"): " << wh.getRange());
185 addDep(larCablingHdl,
"cabling");
189 addDep(caloMgrHandle);
192 if(writeHandle.count(RESIDUAL)) {
194 onlHVCorr = *onlHVCorrHdl;
195 writeHandle.at(RESIDUAL).addDependency(onlHVCorrHdl);
196 ATH_MSG_DEBUG(
"Range of online HV correction " << onlHVCorrHdl.
getRange() <<
", intersection: " << writeHandle.at(RESIDUAL).getRange());
206 hasPathologyEM.resize(
m_larem_id->channel_hash_max());
207 hasPathologyHEC.resize(
m_larhec_id->channel_hash_max());
208 hasPathologyFCAL.resize(
m_larfcal_id->channel_hash_max());
210 bool doPathology=
true;
213 if(!pathologyContainer) {
219 addDep(pHdl,
"HV-Pathology");
220 const std::vector<LArHVPathologiesDb::LArHVElectPathologyDb> &pathCont = pathologyContainer->
getPathology();
221 const size_t nPathologies=pathCont.size();
223 ATH_MSG_INFO(
"Number of HV pathologies found " << nPathologies);
226 for(
unsigned i=0; i<nPathologies; ++i) {
231 unsigned int index = (
unsigned int)(idHash);
232 if (
index<hasPathologyEM.size()) {
238 std::vector<unsigned short> svec;
241 hasPathologyEM[
index]=svec;
247 unsigned int index = (
unsigned int)(idHash);
248 if (
index<hasPathologyHEC.size()) {
254 std::vector<unsigned short> svec;
257 hasPathologyHEC[
index]=svec;
263 unsigned int index = (
unsigned int)(idHash);
264 if (
index<hasPathologyFCAL.size()) {
266 if(hasPathologyFCAL[
index].
size()<
static_cast<size_t>(abs(electPath.
electInd+1)))
270 std::vector<unsigned short> svec;
273 hasPathologyFCAL[
index]=svec;
281 const float* rValues{
nullptr};
285 addDep(readAttrHandle);
287 const coral::Blob& rBlob = (*attr)[
"ElectrodeRvalues"].data<coral::Blob>();
288 if(rBlob.size()/
sizeof(
float) !=
m_electrodeID->electrodeHashMax()) {
289 ATH_MSG_ERROR(
"Expected " <<
m_electrodeID->electrodeHashMax() <<
" R values, but got " << rBlob.size()/
sizeof(
float) <<
" aborting");
290 return StatusCode::FAILURE;
292 rValues =
static_cast<const float*
>(rBlob.startingAddress());
299 pathologyContainer, hasPathologyEM, hasPathologyHEC, hasPathologyFCAL, rValues));
301 auto clampCorr = [&](
float value,
const HWIdentifier hwid) {
304 ATH_MSG_WARNING(
"Ignoring suspiciously small correction factor of " << value
305 <<
" for channel " <<
m_onlineID->channel_name(hwid));
307 }
else if (value < 0.4f) {
317 std::vector<float> vScale[2];
323 const HWIdentifier hwid=cabling->createSignalChannelIDFromHash(hash);
327 if (onlineCorr<=0.f || onlineCorr>=100.f) onlineCorr = 1.f;
328 vScale[RESIDUAL][i] = clampCorr(scale/onlineCorr, hwid);
330 if (doFull) vScale[FULL][i] = clampCorr(scale, hwid);
332 for (
auto& [ct, wh]: writeHandle) {
333 auto hvCorr = std::make_unique<LArHVCorr>(std::move(vScale[ct]), cabling,
m_calocellID);
334 if (wh.record(std::move(hvCorr)).isFailure()) {
335 ATH_MSG_ERROR(
"Could not record LArHVCorr object with " << wh.key()
336 <<
" with EventRange " << wh.getRange() <<
" into Conditions Store");
337 return StatusCode::FAILURE;
339 ATH_MSG_INFO(
"recorded new " << wh.key() <<
" with range " << wh.getRange() <<
" into Conditions Store");
341 return StatusCode::SUCCESS;
349 if (writeAffectedHandle.
isValid()) {
350 ATH_MSG_DEBUG(
"Found valid write LArAffectedRegions handle");
351 return StatusCode::SUCCESS;
364 auto vAffected = std::make_unique<CaloAffectedRegionInfoVec>();
368 if (debugDescr)
ATH_MSG_DEBUG(
"Range of " << debugDescr <<
" " <<
h.getRange()
369 <<
", intersection: " << writeAffectedHandle.
getRange());
386 ATH_MSG_INFO(
"recorded new " << writeAffectedHandle.
key() <<
" with range "
387 << writeAffectedHandle.
getRange()<<
" into Conditions Store");
389 return StatusCode::SUCCESS;
398 std::vector<const CondAttrListCollection*> attrvec;
405 attrvec.push_back(cattr);
406 addDep (dcsHdl, dcsHdl.
key().c_str());
413 if (voltagePerLine.empty()) {
417 return StatusCode::SUCCESS;
429 ,
const float* rValues)
const
432 std::vector<unsigned int> listElec;
434 const float uAkOhm = 1.e-3;
443 bool hasPathology=
false;
444 if (
index<hasPathologyEM.size()) {
451 if (!embElement) std::abort();
453 unsigned int nelec = cell->getNumElectrodes();
454 unsigned int ngap = 2*nelec;
456 for (
unsigned int i=0;i<nelec;i++) {
460 for (
unsigned int igap=0;igap<2;igap++) {
463 unsigned int hvline = electrode.
hvLineNo(igap,hvCabling);
464 auto hvIt=voltage.find(hvline);
465 if(hvIt != voltage.end()) {
468 curr=hvIt->second.curr;
477 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
478 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
482 msg(MSG::VERBOSE) <<
"Original hv: "<<hv<<
" ";
483 for (
unsigned int ii=0;ii<listElec.size();ii++) {
484 if (listElec[ii]==(2*i+igap) && listElec[ii]<hasPathologyEM[
index].
size() && hasPathologyEM[
index][listElec[ii]]) {
496 msg(MSG::VERBOSE) <<
"set hv: "<<hv<<
endmsg;
501 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
509 if (!embElement) std::abort();
514 for (
unsigned int igap=0;igap<2;igap++) {
517 unsigned hvline = hvmodule.
hvLineNo(igap,hvCabling);
518 auto hvIt=voltage.find(hvline);
519 if(hvIt != voltage.end()) {
522 curr=hvIt->second.curr;
531 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0;
532 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
536 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
542 bool hasPathology=
false;
543 if (
index<hasPathologyEM.size()) {
551 if (!emecElement) std::abort();
553 unsigned int nelec = cell->getNumElectrodes();
554 unsigned int ngap = 2*nelec;
556 for (
unsigned int i=0;i<nelec;i++) {
558 for (
unsigned int igap=0;igap<2;igap++) {
561 unsigned hvline = electrode.
hvLineNo(igap,hvCabling);
562 auto hvIt=voltage.find(hvline);
563 if(hvIt != voltage.end()) {
566 curr=hvIt->second.curr;
575 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
576 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
579 msg(MSG::VERBOSE) <<
"Has pathology for id: "<<
m_larem_id->print_to_string(
id)<<
" "<<hasPathologyEM[
index]<<
endmsg;
580 for (
unsigned int ii=0;ii<listElec.size();ii++) {
581 if (listElec[ii]==(2*i+igap) && listElec[ii]<hasPathologyEM[
index].
size() && hasPathologyEM[
index][listElec[ii]]) {
588 hv=((hasPathologyEM[
index][listElec[ii]]&0xFFF0)>>4);
596 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
605 if (!emecElement) std::abort();
610 for (
unsigned int igap=0;igap<2;igap++) {
613 unsigned int hvline = hvmodule.
hvLineNo(igap,hvCabling);
614 auto hvIt=voltage.find(hvline);
615 if(hvIt != voltage.end()) {
618 curr=hvIt->second.curr;
627 if(curr >0.) curr *= uAkOhm * rValues[ridx];
else curr=0.;
628 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr. " << curr <<
" R: "<<rValues[ridx]);
633 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
638 ATH_MSG_ERROR(
"This could not be, what happened with EM identifiers ?");
639 return StatusCode::FAILURE;
648 bool hasPathology=
false;
649 if (
index<hasPathologyHEC.size()) {
656 if (!hecElement) std::abort();
658 unsigned int nsubgaps = cell->getNumSubgaps();
659 float wt = 1./nsubgaps;
661 for (
unsigned int i=0;i<nsubgaps;i++) {
665 unsigned int hvline = subgap.
hvLineNo(hvCabling);
666 auto hvIt=voltage.find(hvline);
667 if(hvIt != voltage.end()) {
670 curr=hvIt->second.curr;
680 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
681 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" cur. " << curr <<
" R: "<<rValues[ridx]);
685 for (
unsigned int ii=0;ii<listElec.size();ii++) {
686 if (listElec[ii]==i && listElec[ii]<hasPathologyHEC[
index].
size() && hasPathologyHEC[
index][listElec[ii]]) {
701 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
711 bool hasPathology=
false;
712 if (
index<hasPathologyFCAL.size()) {
720 if (!fcalElement) std::abort();
722 unsigned int nlines = tile->getNumHVLines();
723 unsigned int nlines_found=0;
724 for (
unsigned int i=0;i<nlines;i++) {
726 if (line) nlines_found++;
728 if (nlines_found>0) {
729 float wt = 1./nlines_found;
731 for (
unsigned int i=0;i<nlines;i++) {
734 unsigned int hvline = line->hvLineNo(hvCabling);
737 auto hvIt=voltage.find(hvline);
738 if(hvIt != voltage.end()) {
741 if(rValues && useCurrent) {
742 curr=hvIt->second.curr;
752 if(curr > 0.) curr *= uAkOhm * rValues[ridx];
else curr = 0.;
753 ATH_MSG_VERBOSE(
"channel. "<<std::hex<<
id.get_identifier32()<<std::dec <<
" hvline: "<<hvline<<
" curr." << curr <<
" R: "<<rValues[ridx]);
757 for (
unsigned int ii=0;ii<listElec.size();ii++) {
758 if (listElec[ii]==i && listElec[ii]<hasPathologyFCAL[
index].
size() && hasPathologyFCAL[
index][listElec[ii]]) {
765 hv=((hasPathologyFCAL[
index][listElec[ii]]&0xFFF0)>>4);
773 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData mapping ! Set voltage to 0 !");
781 return StatusCode::SUCCESS;
786 for (
unsigned int i=0;i<v.size();i++) {
787 if (std::fabs(hv-v[i].hv) <0.1) {
794 v.emplace_back(hv,wt);
801 std::vector<unsigned int> myList;
805 if (electPath.
cellID == (
unsigned int)(
id.get_identifier32().get_compact())) {
806 myList.push_back(electPath.
electInd);
821 for(
const auto *attrlist : fldvec) {
825 for(;citr!=citr_e;++citr) {
826 const unsigned chan=citr->first;
828 const coral::Attribute& attr=((citr)->second)[
"R_VMEAS"];
830 if (!attr.isNull()) voltage=attr.data<
float>();
831 const coral::Attribute& attrc=((citr)->second)[
"R_IMEAS"];
833 if (!attrc.isNull()) current=attrc.data<
float>();
834 ATH_MSG_VERBOSE(
"read voltage: "<<voltage<<
" and current: "<<current );
835 auto empl=result.emplace(chan,
DCS_t{voltage,current});
842 if (
auto empl = result.emplace(chan,
DCS_t{desired, 0.f}); !empl.second) {
843 DCS_t& dcs = empl.first->second;
844 ATH_MSG_DEBUG(
"Changing voltage for " << chan <<
" from " << dcs.
hv <<
" to " << desired);
847 ATH_MSG_WARNING(
"voltage set for channel " << chan <<
" unknown to DCS.");
851 if (
auto empl = result.emplace(chan,
DCS_t{0.f, desired}); !empl.second) {
852 DCS_t& dcs = empl.first->second;
853 ATH_MSG_DEBUG(
"Changing current for " << chan <<
" from " << dcs.
curr <<
" to " << desired);
856 ATH_MSG_WARNING(
"current set for channel " << chan <<
" unknown to DCS and voltage remains 0?!");
859 return StatusCode::SUCCESS;
871 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
875 const EMBHVManager& hvManager_EMB=manager->getEMBHVManager();
886 ATH_MSG_VERBOSE(
"iSide,iPhi,iSector,iEta " << iSide <<
" " << iPhi <<
" " << iSector <<
" " << iEta);
887 float phi_min=+30.,phi_max=-30.;
889 bool are_previous_HV_affected=
false;
890 bool are_previous_HV_dead=
false;
891 for (
unsigned int ielec=0;ielec<32;ielec++) {
894 double hv[2]={0.,0.};
895 for (
unsigned int iGap=0;iGap<2;iGap++) {
896 unsigned int hvline = electrode.
hvLineNo(iGap,hvCabling);
897 auto hvIt=voltage.find(hvline);
898 if(hvIt == voltage.end()) {
899 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
902 hv[iGap]=hvIt->second.hv;
905 ATH_MSG_VERBOSE(
" electrode HV " << ielec <<
" " << electrode.
getPhi() <<
" "<< hv[0] <<
" " << hv[1] );
910 bool isAffected=
false;
915 if (are_previous_HV_dead && !isDead) {
916 are_previous_HV_dead=
false;
917 ATH_MSG_VERBOSE(
" -- end dead region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
919 vAffected->push_back(current_CaloAffectedRegionInfo);
923 if (are_previous_HV_affected && !isAffected) {
924 are_previous_HV_affected=
false;
925 ATH_MSG_VERBOSE(
" -- end affected region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
927 vAffected->push_back(current_CaloAffectedRegionInfo);
931 if (!are_previous_HV_dead) {
934 ATH_MSG_VERBOSE(
" -- start dead region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
935 are_previous_HV_dead =
true;
944 if (!are_previous_HV_affected) {
947 ATH_MSG_VERBOSE(
" -- start affected region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
948 are_previous_HV_affected =
true;
952 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
958 if (are_previous_HV_affected) {
959 ATH_MSG_VERBOSE(
" -- finish affected region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
961 vAffected->push_back(current_CaloAffectedRegionInfo);
963 if (are_previous_HV_dead) {
964 ATH_MSG_VERBOSE(
" -- finish dead region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
966 vAffected->push_back(current_CaloAffectedRegionInfo);
980 ATH_MSG_VERBOSE(
"iSide,iPhi,iEta " << iSide <<
" " << iPhi <<
" " << iEta);
982 for (
int iGap=0;iGap<2;iGap++) {
983 unsigned int hvline = hvMod.
hvLineNo(iGap,hvCabling);
984 auto hvIt=voltage.find(hvline);
985 if(hvIt == voltage.end()) {
986 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
989 hv[iGap]=hvIt->second.hv;
995 ATH_MSG_VERBOSE(
" HV " << hv[0] <<
" " << hv[1] <<
" " <<
" etamin,etamax,phimin,phimax " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " << phi_max);
1000 bool isAffected=
false;
1006 vAffected->push_back(current_CaloAffectedRegionInfo);
1010 vAffected->push_back(current_CaloAffectedRegionInfo);
1017 return StatusCode::FAILURE;
1019 return StatusCode::SUCCESS;
1030 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1046 ATH_MSG_VERBOSE(
"iSide,iPhi,iSector,iEta " << iSide <<
" " << iPhi <<
" " << iSector <<
" "
1047 << iEta <<
" eta_min , eta_max " << eta_min <<
" " << eta_max );
1050 float phi_min=+30.,phi_max=-30.;
1052 bool are_previous_HV_affected=
false;
1053 bool are_previous_HV_dead=
false;
1058 for (
unsigned int iGap=0;iGap<2;iGap++) {
1059 unsigned int hvline = electrode.
hvLineNo(iGap,hvCabling);
1060 auto hvIt=voltage.find(hvline);
1061 if(hvIt == voltage.end()) {
1062 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1065 hv[iGap]=hvIt->second.hv;
1072 bool isAffected=
false;
1075 <<
" " << hv[1] <<
" " <<
" isDead/isAffected " << isDead <<
" " << isAffected );
1078 if (are_previous_HV_dead && !isDead) {
1079 are_previous_HV_dead=
false;
1080 ATH_MSG_VERBOSE(
" -- end dead region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1082 vAffected->push_back(current_CaloAffectedRegionInfo);
1086 if (are_previous_HV_affected && !isAffected) {
1087 are_previous_HV_affected=
false;
1088 ATH_MSG_VERBOSE(
" -- end affected region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1090 vAffected->push_back(current_CaloAffectedRegionInfo);
1094 if (!are_previous_HV_dead) {
1097 are_previous_HV_dead =
true;
1098 ATH_MSG_VERBOSE(
" -- start dead region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
1102 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
1107 if (!are_previous_HV_affected) {
1110 are_previous_HV_affected =
true;
1111 ATH_MSG_VERBOSE(
" -- start affected region " << eta_min <<
" " << eta_max <<
" " << phi_min <<
" " <<phi_max);
1115 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
1121 if (are_previous_HV_affected) {
1125 ATH_MSG_VERBOSE(
" - finih affected region after electrode loop " << eta_min <<
" " << eta_max
1126 <<
" " << phi_max <<
" " <<phi_max);
1128 vAffected->push_back(current_CaloAffectedRegionInfo);
1130 if (are_previous_HV_dead) {
1131 ATH_MSG_VERBOSE(
" -- finish dead region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_max <<
" " <<phi_max);
1133 vAffected->push_back(current_CaloAffectedRegionInfo);
1147 for (
int iGap=0;iGap<2;iGap++) {
1148 unsigned int hvline = hvMod.
hvLineNo(iGap,hvCabling);
1149 auto hvIt=voltage.find(hvline);
1150 if(hvIt == voltage.end()) {
1151 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1154 hv[iGap]=hvIt->second.hv;
1160 ATH_MSG_VERBOSE(
"iSide,iPhi" << iSide <<
" " << iPhi <<
" HV " << hv[0] <<
" " << hv[1] <<
" "
1161 <<
" etamin,etamax,phimin,phimax " << eta_min <<
" " << eta_max <<
" "
1162 << phi_min <<
" " << phi_max);
1167 bool isAffected=
false;
1173 vAffected->push_back(current_CaloAffectedRegionInfo);
1177 vAffected->push_back(current_CaloAffectedRegionInfo);
1183 return StatusCode::FAILURE;
1185 return StatusCode::SUCCESS;
1194 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1210 ATH_MSG_VERBOSE(
"iSide,iPhi,iSector,iEta " << iSide <<
" " << iPhi <<
" " << iSector <<
" "
1211 << iEta <<
" eta_min , eta_max " << eta_min <<
" " << eta_max);
1213 float phi_min=+30.,phi_max=-30.;
1215 bool are_previous_HV_affected=0;
1216 bool are_previous_HV_dead=0;
1221 for (
unsigned int iGap=0;iGap<2;iGap++) {
1222 unsigned int hvline = electrode.
hvLineNo(iGap,hvCabling);
1223 auto hvIt=voltage.find(hvline);
1224 if(hvIt == voltage.end()) {
1225 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1228 hv[iGap]=hvIt->second.hv;
1235 bool isAffected=
false;
1238 << hv[0] <<
" " << hv[1] <<
" " <<
" isDead, isAffected "
1239 << isDead <<
" " << isAffected);
1242 if (are_previous_HV_dead && !isDead) {
1243 are_previous_HV_dead=
false;
1244 ATH_MSG_VERBOSE(
" -- end dead region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1246 vAffected->push_back(current_CaloAffectedRegionInfo);
1250 if (are_previous_HV_affected && !isAffected) {
1251 are_previous_HV_affected=
false;
1252 ATH_MSG_VERBOSE(
" -- end affected region " << eta_min <<
" " << eta_max <<
" " <<phi_min <<
" " << phi_max);
1254 vAffected->push_back(current_CaloAffectedRegionInfo);
1258 if (!are_previous_HV_dead) {
1261 ATH_MSG_VERBOSE(
" -- start dead region " << phi_min <<
" " << phi_max);
1262 are_previous_HV_dead =
true;
1271 if (!are_previous_HV_affected) {
1274 are_previous_HV_affected =
true;
1275 ATH_MSG_VERBOSE(
" -- start affected region " << phi_min <<
" " << phi_max);
1279 ATH_MSG_VERBOSE(
" extend affected region " << phi_min <<
" " << phi_max);
1285 if (are_previous_HV_affected) {
1289 ATH_MSG_VERBOSE(
" - finish affected region after electrode loop " << eta_min <<
" "
1290 << eta_max <<
" " << phi_max <<
" " <<phi_max);
1292 vAffected->push_back(current_CaloAffectedRegionInfo);
1294 if (are_previous_HV_dead) {
1295 ATH_MSG_VERBOSE(
" - end dead region after electrode loop " << eta_min <<
" " << eta_max <<
" " << phi_max <<
" " <<phi_max);
1297 vAffected->push_back(current_CaloAffectedRegionInfo);
1305 return StatusCode::FAILURE;
1307 return StatusCode::SUCCESS;
1316 float etamax_layer[4]={3.3,3.1,3.1,3.3};
1317 float etamin_layer[4]={1.5,1.5,1.6,1.7};
1322 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1324 const HECHVManager& hvManager_HEC=manager->getHECHVManager();
1329 float eta_min,eta_max;
1331 eta_min = etamin_layer[iSampling];
1332 eta_max = etamax_layer[iSampling];
1334 eta_min = -1.*etamax_layer[iSampling];
1335 eta_max = -1.*etamin_layer[iSampling];
1339 ATH_MSG_VERBOSE(
" iSide,iPhi,iSampling " << iSide <<
" " << iPhi <<
" " << iSampling);
1342 for (
unsigned int iGap=0;iGap<hvMod.
getNumSubgaps();iGap++) {
1344 unsigned int hvline = subgap.
hvLineNo(hvCabling);
1345 auto hvIt=voltage.find(hvline);
1346 if(hvIt == voltage.end()) {
1347 ATH_MSG_WARNING(
"Do not have hvline: "<<hvline<<
" in LArHVData ! Assuming missing DCS data");
1350 if(iGap<4) hv[iGap]=hvIt->second.hv;
1357 bool isAffected=
false;
1360 ATH_MSG_VERBOSE(
" HV values " << hv[0] <<
" " << hv[1] <<
" " << hv[2] <<
" " << hv[3] <<
" "
1361 <<
" isDead/isAffected " << isDead <<
" " << isAffected);
1368 ATH_MSG_VERBOSE(
" new dead region " << eta_min <<
" " << eta_max <<
" " << phiMin <<
" " << phiMax <<
" layer " << 8+iSampling);
1370 vAffected->push_back(current_CaloAffectedRegionInfo);
1373 ATH_MSG_VERBOSE(
" new affected region " << eta_min <<
" " << eta_max <<
" " << phiMin <<
" " << phiMax <<
" layer " << 8+iSampling);
1375 vAffected->push_back(current_CaloAffectedRegionInfo);
1383 return StatusCode::FAILURE;
1385 return StatusCode::SUCCESS;
1394 if (
detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1396 const FCALHVManager& hvManager_FCAL=manager->getFCALHVManager();
1399 float eta_min=3.1,eta_max=4.9;
1405 float HVnominal =
HV_nominal(
"FCAL",(
float)(iSampling));
1409 ATH_MSG_VERBOSE(
" FCAL HVModule side,sampling,sector " << iSide <<
" " << iSampling <<
" "
1410 << iSector <<
" HV nominal " << HVnominal);
1415 float phi_min = ((float)(iSector))*dphi;
1419 ATH_MSG_VERBOSE(
" eta_min,eta_max,phi_min,phi_max " << eta_min <<
" " << eta_max <<
" " << phi_min
1420 <<
" " << phi_max <<
" number of lines " << hvMod.
getNumHVLines());
1422 for (
unsigned int iLine=0;iLine<hvMod.
getNumHVLines();iLine++) {
1424 unsigned int ihvline = hvline.hvLineNo(hvCabling);
1425 auto hvIt=voltage.find(ihvline);
1426 if(hvIt == voltage.end()) {
1427 ATH_MSG_WARNING(
"Do not have hvline: "<<ihvline<<
" in LArHVData ! Assuming missing DCS data");
1430 if (iLine<4) hv[iLine]=hvIt->second.hv;
1436 bool isAffected=
false;
1439 ATH_MSG_VERBOSE(
" HV values " << hv[0] <<
" " << hv[1] <<
" " << hv[2] <<
" " << hv[3] <<
" "
1440 <<
" isDead/isAffected " << isDead <<
" " << isAffected);
1446 vAffected->push_back(current_CaloAffectedRegionInfo);
1451 vAffected->push_back(current_CaloAffectedRegionInfo);
1458 return StatusCode::FAILURE;
1460 return StatusCode::SUCCESS;
1476 bool is_additive1=0;
1478 int layer_min=+30,layer_max=-30;
1479 float eta_min=+30,eta_max=-30;
1480 float phi_min=+30,phi_max=-30;
1482 int layer_min_additive1=+30,layer_max_additive1=-30;
1483 float eta_min_additive1=+30,eta_max_additive1=-30;
1484 float phi_min_additive1=+30,phi_max_additive1=-30;
1486 int chans_per_feb =
m_onlineID->channelInSlotMax(febId);
1488 for (
int icha=0;icha<chans_per_feb;icha++) {
1491 if (cabling->isOnlineConnected(channelId)) {
1492 Identifier offlineId=cabling->cnvToIdentifier(channelId);
1496 float current_eta=caloddElement->
eta();
1497 float current_eta_low=caloddElement->
eta()-0.5*caloddElement->
deta();
1498 float current_eta_high=caloddElement->
eta()+0.5*caloddElement->
deta();
1499 float current_phi_low=caloddElement->
phi()-0.5*caloddElement->
dphi();
1500 float current_phi_high=caloddElement->
phi()+0.5*caloddElement->
dphi();
1502 if (caloddElement->
is_lar_em_barrel() && caloddElement->
getLayer()==3 && fabs(current_eta)>0.79 && fabs(current_eta)<1.33) {
1505 if (current_layer<layer_min_additive1)
1506 layer_min_additive1=current_layer;
1507 if (current_layer>layer_max_additive1)
1508 layer_max_additive1=current_layer;
1510 if (current_eta_low<eta_min_additive1)
1511 eta_min_additive1=current_eta_low;
1512 if (current_eta_high>eta_max_additive1)
1513 eta_max_additive1=current_eta_high;
1516 extendPhiRegion(current_phi_high,phi_min_additive1,phi_max_additive1);
1522 if (current_layer<layer_min)
1523 layer_min=current_layer;
1524 if (current_layer>layer_max)
1525 layer_max=current_layer;
1527 if (current_eta_low<eta_min)
1528 eta_min=current_eta_low;
1529 if (current_eta_high>eta_max)
1530 eta_max=current_eta_high;
1541 vAffected->push_back(current_CaloAffectedRegionInfo);
1546 vAffected->push_back(current_additive1_CaloAffectedRegionInfo);
1550 return StatusCode::SUCCESS;
1555 if (strcmp(identification,
"EMBPS")==0)
1557 else if (strcmp(identification,
"EMECPS")==0)
1559 else if (strcmp(identification,
"EMB")==0)
1561 else if (strcmp(identification,
"EMEC")==0) {
1562 if ( fabs(myparameter)<1.5 )
1564 else if (fabs(myparameter)<1.6)
1566 else if (fabs(myparameter)<1.8 )
1568 else if ( fabs(myparameter) < 2.0 )
1570 else if ( fabs(myparameter) < 2.1 )
1572 else if ( fabs(myparameter) < 2.3 )
1574 else if ( fabs(myparameter) < 2.5 )
1576 else if ( fabs(myparameter) < 2.8 )
1580 else if (strcmp(identification,
"HEC")==0) {
1583 else if (strcmp(identification,
"FCAL")==0) {
1584 if (myparameter<0.5)
1586 else if (myparameter<1.5)
1588 else if (myparameter<2.5)
1598 static const float epsilon=1e-4;
1602 if (phi_min>10. || phi_max<-10.) {
1608 bool isInRegion=
false;
1609 if (phi_min<phi_max) {
1610 if (
phi>phi_min &&
phi<phi_max) isInRegion=
true;
1613 if (
phi>phi_min ||
phi<phi_max) isInRegion=
true;
1615 if (isInRegion)
return;
1619 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.
size_t size() const
Number of registered mappings.
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< 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_outputHVScaleFullCorrKey
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
SG::WriteCondHandleKey< LArHVCorr > m_outputHVScaleResidCorrKey
StatusCode makeHVScaleCorr(const EventContext &ctx, voltagePerLine_t &voltagePerLine) const
virtual StatusCode initialize() override
std::function< void(SG::ReadCondHandle< CondAttrListCollection > &dep, const char *debugDescr)> addDepFcn_t
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