ATLAS Offline Software
Loading...
Searching...
No Matches
LArHVCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "./LArHVCondAlg.h"
12#include "LArHV/LArHVManager.h"
13#include "LArHV/EMBHVManager.h"
14#include "LArHV/EMECHVModule.h"
19#include "LArHV/EMECHVManager.h"
23#include "LArHV/HECHVManager.h"
24#include "LArHV/HECHVSubgap.h"
26#include "LArHV/FCALHVManager.h"
27#include "LArHV/FCALHVLine.h"
28
32
36
37#include "CoralBase/Blob.h"
38
39#include <cmath>
40#include <cstdlib>
41
42#define HV_NON_NOMINAL_TOLERANCE 10 // tolerance : 1V for HV
43#define DEAD_HV_THRESHOLD 10 // HV <10 V="dead"
44#define MAX_LAR_CELLS 182468
45
46//initialize
48 ATH_CHECK( detStore()->retrieve (m_calocellID, "CaloCell_ID") );
49
50 m_larem_id = m_calocellID->em_idHelper();
51 m_larhec_id = m_calocellID->hec_idHelper();
52 m_larfcal_id = m_calocellID->fcal_idHelper();
53
54 ATH_CHECK(detStore()->retrieve(m_electrodeID));
55 ATH_CHECK(detStore()->retrieve(m_hvLineID));
56 ATH_CHECK(detStore()->retrieve(m_onlineID));
57
59
60 if (m_doR) {
61 ATH_MSG_INFO("Will use currents to correct voltage-drop at HV-resistors");
62 }
63 else {
64 ATH_MSG_INFO("Will NOT correct voltage-drop at HV-resistors");
65 }
66
67 // Read Handles
68 ATH_CHECK(m_cablingKey.initialize());
71 ATH_CHECK(m_cablingKey.initialize());
72 ATH_CHECK(m_BFKey.initialize() );
74 ATH_CHECK(m_hvRKey.initialize(m_doR && (m_doHV || m_doAffectedHV)));
76 ATH_CHECK(m_caloMgrKey.initialize());
77 // Write Handles
78
80 ATH_CHECK(m_affectedKey.initialize());
81
82 m_scaleTool=std::make_unique<LArHVScaleCorrTool>(m_calocellID,msg(),m_fixHVStrings);
83
84 ATH_MSG_DEBUG("Configured with doHV " << m_doHV << " doAffected " << m_doAffected << " doAffectedHV " << m_doAffectedHV);
85
86 return StatusCode::SUCCESS;
87}
88
89
90StatusCode LArHVCondAlg::execute(const EventContext& ctx) const
91{
92 ATH_MSG_DEBUG("executing");
93 // Allow sharing this between the two calls.
94 voltagePerLine_t voltagePerLine;
95 if (m_doHV || m_doAffectedHV) {
96 ATH_CHECK( makeHVScaleCorr (ctx, voltagePerLine) );
97 }
98 if (m_doAffected) {
99 ATH_CHECK( makeAffectedRegionInfo (ctx, voltagePerLine) );
100 }
101
102 return StatusCode::SUCCESS;
103}
104
105StatusCode LArHVCondAlg::makeHVScaleCorr (const EventContext& ctx,
106 voltagePerLine_t& voltagePerLine) const
107{
109 if (writeHandle.isValid()) {
110 ATH_MSG_DEBUG("Found valid write handle for LArHVCorr");
111 return StatusCode::SUCCESS;
112 }
113
114 //Start with infinite range and narrow it down
115 const EventIDRange fullRange=IOVInfiniteRange::infiniteMixed();
116 writeHandle.addDependency (fullRange);
117
119 const LArOnOffIdMapping* cabling=*larCablingHdl;
120 ATH_MSG_DEBUG("Range of cabling" << larCablingHdl.getRange() << ", intersection: " << writeHandle.getRange());
121 writeHandle.addDependency(larCablingHdl);
122
124 const CaloDetDescrManager* calodetdescrmgr = *caloMgrHandle;
125 writeHandle.addDependency(caloMgrHandle);
126
127 const ILArHVScaleCorr *onlHVCorr{nullptr};
130 onlHVCorr = *onlHVCorrHdl;
131 writeHandle.addDependency(onlHVCorrHdl);
132 ATH_MSG_DEBUG("Range of online HV correction " << onlHVCorrHdl.getRange() << ", intersection: " << writeHandle.getRange());
133 }
134
136 const LArHVIdMapping* hvCabling = *mappingHdl;
137 writeHandle.addDependency(mappingHdl);
138
139 pathVec hasPathologyEM;
140 pathVec hasPathologyHEC;
141 pathVec hasPathologyFCAL;
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());
145
146 bool doPathology=true;
148 const LArHVPathology* pathologyContainer = *pHdl;
149 if(!pathologyContainer) {
150 ATH_MSG_WARNING("Why do not have HV pathology object " << m_pathologiesKey.fullKey() << " ? Work without pathologies !!!");
151 doPathology=false;
152 }
153
154 if(doPathology) {
155 writeHandle.addDependency(pHdl);
156 ATH_MSG_DEBUG("Range of HV-Pathology " << pHdl.getRange() << ", intersection: " << writeHandle.getRange());
157 const std::vector<LArHVPathologiesDb::LArHVElectPathologyDb> &pathCont = pathologyContainer->getPathology();
158 const size_t nPathologies=pathCont.size();
159 if (m_nPathologies != nPathologies) {
160 ATH_MSG_INFO( "Number of HV pathologies found " << nPathologies);
161 m_nPathologies=nPathologies;
162 }
163 for(unsigned i=0; i<nPathologies; ++i) {
164 LArHVPathologiesDb::LArHVElectPathologyDb electPath = pathCont[i];
165 Identifier id(electPath.cellID);
166 if (m_larem_id->is_lar_em(id)) {
167 IdentifierHash idHash = m_larem_id->channel_hash(id);
168 unsigned int index = (unsigned int)(idHash);
169 if (index<hasPathologyEM.size()) {
170 if(!hasPathologyEM[index].empty()) {
171 if(hasPathologyEM[index].size()<static_cast<size_t>(abs(electPath.electInd+1)))
172 hasPathologyEM[index].resize(electPath.electInd+1);
173 hasPathologyEM[index][electPath.electInd]=electPath.pathologyType;
174 } else {
175 std::vector<unsigned short> svec;
176 svec.resize(electPath.electInd+1);
177 svec[electPath.electInd]=electPath.pathologyType;
178 hasPathologyEM[index]=svec;
179 }
180 }
181 }
182 if (m_larhec_id->is_lar_hec(id)) {
183 IdentifierHash idHash = m_larhec_id->channel_hash(id);
184 unsigned int index = (unsigned int)(idHash);
185 if (index<hasPathologyHEC.size()) {
186 if(!hasPathologyHEC[index].empty()) {
187 if(hasPathologyHEC[index].size()<static_cast<size_t>(abs(electPath.electInd+1)))
188 hasPathologyHEC[index].resize(electPath.electInd+1);
189 hasPathologyHEC[index][electPath.electInd]=electPath.pathologyType;
190 } else {
191 std::vector<unsigned short> svec;
192 svec.resize(electPath.electInd+1);
193 svec[electPath.electInd]=electPath.pathologyType;
194 hasPathologyHEC[index]=svec;
195 }
196 }
197 }
198 if (m_larfcal_id->is_lar_fcal(id)) {
199 IdentifierHash idHash = m_larfcal_id->channel_hash(id);
200 unsigned int index = (unsigned int)(idHash);
201 if (index<hasPathologyFCAL.size()) {
202 if(!hasPathologyFCAL[index].empty()) {
203 if(hasPathologyFCAL[index].size()<static_cast<size_t>(abs(electPath.electInd+1)))
204 hasPathologyFCAL[index].resize(electPath.electInd+1);
205 hasPathologyFCAL[index][electPath.electInd]=electPath.pathologyType;
206 } else {
207 std::vector<unsigned short> svec;
208 svec.resize(electPath.electInd+1);
209 svec[electPath.electInd]=electPath.pathologyType;
210 hasPathologyFCAL[index]=svec;
211 }
212
213 }
214 }
215 } // Pathology containers
216 }//doPathology
217
218 const float* rValues{nullptr};
219 if(m_doR) {
221 const AthenaAttributeList* attr = *readAttrHandle;
222 writeHandle.addDependency(readAttrHandle);
223 // store the conditions blob
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;
228 }
229 rValues = static_cast<const float*>(rBlob.startingAddress());
230 }
231
232 auto addDep = [&writeHandle] (SG::ReadCondHandle<CondAttrListCollection>& h) -> const EventIDRange& {
233 writeHandle.addDependency (h);
234 return writeHandle.getRange();
235 };
236 ATH_CHECK( getVoltagePerLine (ctx, voltagePerLine, addDep) );
237
239 ATH_CHECK(fillPathAndCellHV(calodetdescrmgr,voltageVec, hvCabling, voltagePerLine,
240 pathologyContainer, hasPathologyEM, hasPathologyHEC, hasPathologyFCAL, rValues));
241
242 std::vector<float> vScale;
243 vScale.resize(MAX_LAR_CELLS,(float)1.0);
244 for (unsigned i=0;i<MAX_LAR_CELLS;++i) {
245 IdentifierHash hash(i);
246 const CaloDetDescrElement* dde = calodetdescrmgr->get_element(hash);
247 const HWIdentifier hwid=cabling->createSignalChannelIDFromHash(hash);
248 vScale[i]=m_scaleTool->getHVScale(dde,voltageVec[i],msg());
249 if(onlHVCorr) { // undo the online one
250 const float hvonline = onlHVCorr->HVScaleCorr(hwid);
251 if (hvonline>0. && hvonline<100.) vScale[i]=vScale[i]/hvonline;
252 }
253 //Final sanity check:
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));
256 vScale[i]=1.0;
257 }
258
259 if (vScale[i] < 0.9) {
260 if (vScale[i] < 0.4) {
261 ATH_MSG_WARNING("HV corr for channel " << m_onlineID->channel_name(hwid)
262 << " = " << vScale[i]);
263 } else {
264 ATH_MSG_DEBUG("HV corr for channel " << m_onlineID->channel_name(hwid)
265 << " = " << vScale[i]);
266 }
267 } //end of vScale < 0.9
268 } //end loop over all cells
269
270 auto hvCorr = std::make_unique<LArHVCorr>(std::move(vScale), cabling, m_calocellID);
271
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;
276 }
277 ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
278
279 return StatusCode::SUCCESS;
280}
281
282
283StatusCode LArHVCondAlg::makeAffectedRegionInfo (const EventContext& ctx,
284 voltagePerLine_t& voltagePerLine) const
285{
287 if (writeAffectedHandle.isValid()) {
288 ATH_MSG_DEBUG("Found valid write LArAffectedRegions handle");
289 return StatusCode::SUCCESS;
290 }
291
293 const LArOnOffIdMapping* cabling=*larCablingHdl;
294 ATH_MSG_DEBUG("Range of cabling" << larCablingHdl.getRange() << ", intersection: " << writeAffectedHandle.getRange());
295 writeAffectedHandle.addDependency(larCablingHdl);
296
298 const LArBadFebCont* bfCont = *readBFHandle;
299 writeAffectedHandle.addDependency(readBFHandle);
300 ATH_MSG_DEBUG("Range of BadFeb " << readBFHandle.getRange() << ", intersection: " << writeAffectedHandle.getRange());
301
302 auto vAffected = std::make_unique<CaloAffectedRegionInfoVec>();
303 if (m_doAffectedHV) {
304 auto addDep = [&writeAffectedHandle] (SG::ReadCondHandle<CondAttrListCollection>& h) -> const EventIDRange& {
305 writeAffectedHandle.addDependency (h);
306 return writeAffectedHandle.getRange();
307 };
308 ATH_CHECK( getVoltagePerLine (ctx, voltagePerLine, addDep) );
309
311 const LArHVIdMapping* hvCabling = *mappingHdl;
312 writeAffectedHandle.addDependency(mappingHdl);
313
314 ATH_CHECK(searchNonNominalHV_EMB(vAffected.get(), hvCabling, voltagePerLine));
315 ATH_CHECK(searchNonNominalHV_EMEC_OUTER(vAffected.get(), hvCabling, voltagePerLine));
316 ATH_CHECK(searchNonNominalHV_EMEC_INNER(vAffected.get(), hvCabling, voltagePerLine));
317 ATH_CHECK(searchNonNominalHV_HEC(vAffected.get(), hvCabling, voltagePerLine));
318 ATH_CHECK(searchNonNominalHV_FCAL(vAffected.get(), hvCabling, voltagePerLine));
319 }
320
321 ATH_CHECK(updateMethod(ctx, vAffected.get(), bfCont, cabling));
322 ATH_CHECK(writeAffectedHandle.record(std::move(vAffected)));
323 ATH_MSG_INFO("recorded new " << writeAffectedHandle.key() << " with range "
324 << writeAffectedHandle.getRange()<< " into Conditions Store");
325
326 return StatusCode::SUCCESS;
327}
328
329
330StatusCode LArHVCondAlg::getVoltagePerLine (const EventContext& ctx,
331 voltagePerLine_t& voltagePerLine,
332 const addDepFcn_t& addDep) const
333{
334 // Do this bit unconditionally, so that dependencies are propagated correctly.
335 std::vector<const CondAttrListCollection*> attrvec;
336 // get handles to DCS Database folders
337 for (const auto& fldkey: m_DCSFolderKeys ) {
339 const CondAttrListCollection* cattr = *dcsHdl;
340 if(cattr) {
341 ATH_MSG_DEBUG("Folder: "<<dcsHdl.key()<<" has size: "<<std::distance(cattr->begin(),cattr->end()));
342 attrvec.push_back(cattr);
343 const EventIDRange& range = addDep (dcsHdl);
344 ATH_MSG_DEBUG("Range of " << dcsHdl.key() << " " << dcsHdl.getRange() << ", intersection: " << range);
345
346 } else {
347 ATH_MSG_WARNING("Why do not have DCS folder " << fldkey.fullKey());
348 }
349 } // over DCS folders
350
351 // But we can skip this if we've already done it.
352 if (voltagePerLine.empty()) {
353 ATH_CHECK(dcs2LineVoltage(voltagePerLine, attrvec));
354 }
355
356 return StatusCode::SUCCESS;
357}
358
359
361 , voltagePerCell_t& hvdata
362 , const LArHVIdMapping* hvCabling
363 , const voltagePerLine_t& voltage
364 , const LArHVPathology& pathologies
365 , pathVec& hasPathologyEM
366 , pathVec& hasPathologyHEC
367 , pathVec& hasPathologyFCAL
368 , const float* rValues) const
369{
370
371 std::vector<unsigned int> listElec;
372
373 const float uAkOhm = 1.e-3; // current is uA, rValues kOhm, result should be V
374
375
376 // loop over all EM Identifiers
377 for (auto id: m_larem_id->channel_ids()) {
378 const IdentifierHash hash=m_calocellID->calo_cell_hash(id);
379 voltageCell_t& v=hvdata[hash];
380 if (abs(m_larem_id->barrel_ec(id))==1 && m_larem_id->sampling(id) > 0) { // LAr EMB
381 unsigned int index = (unsigned int)(m_larem_id->channel_hash(id));
382 bool hasPathology=false;
383 if (index<hasPathologyEM.size()) {
384 if (!hasPathologyEM[index].empty()) {
385 hasPathology=true;
386 listElec = getElecList(id,pathologies);
387 }
388 }
389 const EMBDetectorElement* embElement = dynamic_cast<const EMBDetectorElement*>(calodetdescrmgr->get_element(hash));
390 if (!embElement) std::abort();
391 const EMBCellConstLink cell = embElement->getEMBCell();
392 unsigned int nelec = cell->getNumElectrodes();
393 unsigned int ngap = 2*nelec;
394 float wt = 1./ngap;
395 for (unsigned int i=0;i<nelec;i++) {
396 const EMBHVElectrode& electrode = cell->getElectrode(i);
397 // " " << electrode->getModule()->getEtaIndex() << " " << electrode->getModule()->getPhiIndex() <<
398 // " " << electrode->getModule()->getSectorIndex() << " " << electrode->getElectrodeIndex() << std::endl;
399 for (unsigned int igap=0;igap<2;igap++) {
400 float hv=0;
401 float curr=0;
402 unsigned int hvline = electrode.hvLineNo(igap,hvCabling);
403 auto hvIt=voltage.find(hvline);
404 if(hvIt != voltage.end()) { //Found HV line
405 hv=hvIt->second.hv;
406 if(rValues && m_useCurrentEMB) { // modify the current record
407 curr=hvIt->second.curr;
408 const EMBHVModule &hvmod = electrode.getModule();
409 unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(0,
410 hvmod.getSideIndex(),
411 hvCabling->getCellModule(id),
412 hvmod.getPhiIndex(),
413 hvmod.getEtaIndex(),
414 igap,
415 electrode.getElectrodeIndex() ));
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]);
418 }//end if rValues
419 if (hasPathology) {
420 ATH_MSG_VERBOSE( "Has pathology for id: "<< m_larem_id->print_to_string(id)<<" "<<hasPathologyEM[index]);
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]]) {
424 if(hasPathologyEM[index][listElec[ii]]&LArHVPathologyBits::MaskHV) {
425 hv=0.;
426 curr = 0.;
427 } else if(hasPathologyEM[index][listElec[ii]]&LArHVPathologyBits::MaskCurr) {
428 curr = 0.;
429 } else {
430 hv=((hasPathologyEM[index][listElec[ii]]&LArHVPathologyBits::SetHVMask)>>4);
431 curr=0.;
432 }
433 }
434 }
435 msg(MSG::VERBOSE) << "set hv: "<<hv<<endmsg;
436 }//end if has patology
437
438 }//end got hv
439 else {
440 ATH_MSG_WARNING("Do not have hvline: "<<hvline<<" in LArHVData mapping ! Set voltage to 0 !");
441 }
442 addHV(v,hv-curr,wt);
443 }//end loop over gaps
444 }//end loop over electrodes
445 } else if (abs(m_larem_id->barrel_ec(id))==1 && m_larem_id->sampling(id) == 0) { // EMBPS
446
447 const EMBDetectorElement* embElement = dynamic_cast<const EMBDetectorElement*>(calodetdescrmgr->get_element(hash));
448 if (!embElement) std::abort();
449 const EMBCellConstLink cell = embElement->getEMBCell();
450 const EMBPresamplerHVModule& hvmodule = cell->getPresamplerHVModule ();
451
452 float wt = 0.5;
453 for (unsigned int igap=0;igap<2;igap++) {
454 float hv=0;
455 float curr=0;
456 unsigned hvline = hvmodule.hvLineNo(igap,hvCabling);
457 auto hvIt=voltage.find(hvline);
458 if(hvIt != voltage.end()) { //Found HV line
459 hv=hvIt->second.hv;
460 if(rValues && m_useCurrentOthers) { // modify the current record
461 curr=hvIt->second.curr;
462 unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(1,
463 hvmodule.getSideIndex(),
464 hvCabling->getCellModule(id),
465 0, // not used in EMBPS
466 hvmodule.getEtaIndex(),
467 igap,
468 0 // not used in EMBPS
469 ));
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]);
472 }//end have rValue
473 }//end have voltage
474 else {
475 ATH_MSG_WARNING("Do not have hvline: "<<hvline<<" in LArHVData mapping ! Set voltage to 0 !");
476 }
477 addHV(v,hv-curr,wt);
478 }//end loop over gaps
479 } else if (abs(m_larem_id->barrel_ec(id))>1 && m_larem_id->sampling(id) > 0){ // LAr EMEC
480 unsigned int index = (unsigned int)(m_larem_id->channel_hash(id));
481 bool hasPathology=false;
482 if (index<hasPathologyEM.size()) {
483 if (!hasPathologyEM[index].empty()) {
484 hasPathology=true;
485 listElec = getElecList(id, pathologies);
486 }
487 }
488
489 const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(calodetdescrmgr->get_element(hash));
490 if (!emecElement) std::abort();
491 const EMECCellConstLink cell = emecElement->getEMECCell();
492 unsigned int nelec = cell->getNumElectrodes();
493 unsigned int ngap = 2*nelec;
494 float wt = 1./ngap;
495 for (unsigned int i=0;i<nelec;i++) {
496 const EMECHVElectrode& electrode = cell->getElectrode(i);
497 for (unsigned int igap=0;igap<2;igap++) {
498 float hv=0;
499 float curr=0;
500 unsigned hvline = electrode.hvLineNo(igap,hvCabling);
501 auto hvIt=voltage.find(hvline);
502 if(hvIt != voltage.end()) { //Found HV line
503 hv=hvIt->second.hv;
504 if(rValues && m_useCurrentOthers) { // modify the current record
505 curr=hvIt->second.curr;
506 const EMECHVModule &hvmod = electrode.getModule();
507 unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(2,
508 hvmod.getSideIndex(),
509 hvCabling->getCellModule(id),
510 hvmod.getPhiIndex(),
511 hvmod.getEtaIndex(),
512 hvmod.getSectorIndex(),
513 electrode.getElectrodeIndex() ));
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]);
516 }
517 if (hasPathology) {
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]]) {
521 if(hasPathologyEM[index][listElec[ii]]&LArHVPathologyBits::MaskHV) {
522 hv=0.;
523 curr = 0.;
524 } else if(hasPathologyEM[index][listElec[ii]]&LArHVPathologyBits::MaskCurr) {
525 curr = 0.;
526 } else {
527 hv=((hasPathologyEM[index][listElec[ii]]&0xFFF0)>>4);
528 curr=0.;
529 }
530 }
531 }
532 }//end hasPatology
533 }//end have voltage
534 else {
535 ATH_MSG_WARNING("Do not have hvline: "<<hvline<<" in LArHVData mapping ! Set voltage to 0 !");
536 }
537 addHV(v,hv-curr,wt);
538 }//end loop over gaps
539 }//end loop over electrodes
540
541 } else if (abs(m_larem_id->barrel_ec(id))>1 && m_larem_id->sampling(id)==0) { // EMECPS
542
543 const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(calodetdescrmgr->get_element(hash));
544 if (!emecElement) std::abort();
545 const EMECCellConstLink cell = emecElement->getEMECCell();
546 const EMECPresamplerHVModule& hvmodule = cell->getPresamplerHVModule ();
547
548 double wt = 0.5;
549 for (unsigned int igap=0;igap<2;igap++) {
550 float hv=0;
551 float curr=0;
552 unsigned int hvline = hvmodule.hvLineNo(igap,hvCabling);
553 auto hvIt=voltage.find(hvline);
554 if(hvIt != voltage.end()) { //Found HV line
555 hv=hvIt->second.hv;
556 if(rValues && m_useCurrentOthers) { // modify the current record
557 curr=hvIt->second.curr;
558 unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(3,
559 hvmodule.getSideIndex(),
560 hvCabling->getCellModule(id),
561 0, // not used in EMECPS
562 0,
563 igap,
564 0 // not used in EMECPS
565 ));
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]);
568 }//end if rValues
569
570 }//end have hv-value
571 else {
572 ATH_MSG_WARNING("Do not have hvline: "<<hvline<<" in LArHVData mapping ! Set voltage to 0 !");
573 }
574 addHV(v,hv-curr,wt);
575 }//end loop over gaps
576 } else { // something wrong
577 ATH_MSG_ERROR("This could not be, what happened with EM identifiers ?");
578 return StatusCode::FAILURE;
579 }
580 } // end loop over EM-identifiers
581
582
583 // LAr HEC
584 for( auto id: m_larhec_id->channel_ids()) {
585 const IdentifierHash hash=m_calocellID->calo_cell_hash(id);
586 unsigned int index = (unsigned int)(m_larhec_id->channel_hash(id));
587 bool hasPathology=false;
588 if (index<hasPathologyHEC.size()) {
589 if (!hasPathologyHEC[index].empty()) {
590 hasPathology=true;
591 listElec = getElecList(id, pathologies);
592 }
593 }
594 const HECDetectorElement* hecElement = dynamic_cast<const HECDetectorElement*>(calodetdescrmgr->get_element(hash));
595 if (!hecElement) std::abort();
596 const HECCellConstLink cell = hecElement->getHECCell();
597 unsigned int nsubgaps = cell->getNumSubgaps();
598 float wt = 1./nsubgaps;
599 voltageCell_t& v=hvdata[hash];
600 for (unsigned int i=0;i<nsubgaps;i++) {
601 float hv=0;
602 float curr=0;
603 const HECHVSubgap& subgap = cell->getSubgap(i);
604 unsigned int hvline = subgap.hvLineNo(hvCabling);
605 auto hvIt=voltage.find(hvline);
606 if(hvIt != voltage.end()) { //Found HV line
607 hv=hvIt->second.hv;
608 if(rValues && m_useCurrentOthers) { // modify the current record
609 curr=hvIt->second.curr;
610 const HECHVModule &hvmod = subgap.getModule();
611 unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(4,
612 hvmod.getSideIndex(),
613 hvCabling->getCellModule(id),
614 0, // not used in HEC
615 hvmod.getSamplingIndex(),
616 subgap.getSubgapIndex(),
617 0 // not used in HEC
618 ));
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]);
621 }
622 if (hasPathology) {
623 msg(MSG::VERBOSE) << "Has pathology for id: "<< m_larhec_id->print_to_string(id)<<" "<<hasPathologyHEC[index]<<endmsg;
624 for (unsigned int ii=0;ii<listElec.size();ii++) {
625 if (listElec[ii]==i && listElec[ii]<hasPathologyHEC[index].size() && hasPathologyHEC[index][listElec[ii]]) {
626 if(hasPathologyHEC[index][listElec[ii]]&LArHVPathologyBits::MaskHV) {
627 hv=0.;
628 curr = 0.;
629 } else if(hasPathologyHEC[index][listElec[ii]]&LArHVPathologyBits::MaskCurr){
630 curr = 0.;
631 } else {
632 hv=((hasPathologyHEC[index][listElec[ii]]&LArHVPathologyBits::SetHVMask)>>4);
633 curr=0.;
634 }
635 }
636 }
637 }//end have pathology
638 } //end have voltage
639 else {
640 ATH_MSG_WARNING("Do not have hvline: "<<hvline<<" in LArHVData mapping ! Set voltage to 0 !");
641 }
642 addHV(v,hv-curr,wt);
643 }//end loop over subgaps
644 }//end loop over HEC-IDs
645
646
647 for(auto id: m_larfcal_id->channel_ids()) { // LAr FCAL
648 unsigned int index = (unsigned int)(m_larfcal_id->channel_hash(id));
649 const IdentifierHash hash=m_calocellID->calo_cell_hash(id);
650 bool hasPathology=false;
651 if (index<hasPathologyFCAL.size()) {
652 if (!hasPathologyFCAL[index].empty()) {
653 hasPathology=true;
654 listElec = getElecList(id, pathologies);
655 }
656 }
657
658 const FCALDetectorElement* fcalElement = dynamic_cast<const FCALDetectorElement*>(calodetdescrmgr->get_element(hash));
659 if (!fcalElement) std::abort();
660 const FCALTile* tile = fcalElement->getFCALTile();
661 unsigned int nlines = tile->getNumHVLines();
662 unsigned int nlines_found=0;
663 for (unsigned int i=0;i<nlines;i++) {
664 const FCALHVLine* line = tile->getHVLine(i);
665 if (line) nlines_found++;
666 }
667 if (nlines_found>0) {
668 float wt = 1./nlines_found;
669 voltageCell_t& v=hvdata[hash];
670 for (unsigned int i=0;i<nlines;i++) {
671 const FCALHVLine* line = tile->getHVLine(i);
672 if (!line) continue;
673 unsigned int hvline = line->hvLineNo(hvCabling);
674 float hv=0;
675 float curr=0;
676 auto hvIt=voltage.find(hvline);
677 if(hvIt != voltage.end()) { //Found HV line
678 hv=hvIt->second.hv;
679 bool useCurrent= (m_larfcal_id->module(id)==1 && m_useCurrentFCAL1) || (m_larfcal_id->module(id)!=1 && m_useCurrentOthers);
680 if(rValues && useCurrent) { // modify the current record
681 curr=hvIt->second.curr;
682 const FCALHVModule& hvmod = line->getModule();
683 unsigned ridx = m_electrodeID->electrodeHash(m_electrodeID->ElectrodeId(5,
684 hvmod.getSideIndex(),
685 hvCabling->getCellModule(id),
686 0, // not used in FCAL
687 hvmod.getSamplingIndex(),
688 hvmod.getSectorIndex(),
689 line->getLineIndex()
690 ));
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]);
693 }
694 if (hasPathology) {
695 msg(MSG::VERBOSE) << "Has pathology for id: "<< m_larfcal_id->print_to_string(id)<<" "<<hasPathologyFCAL[index]<<endmsg;
696 for (unsigned int ii=0;ii<listElec.size();ii++) {
697 if (listElec[ii]==i && listElec[ii]<hasPathologyFCAL[index].size() && hasPathologyFCAL[index][listElec[ii]]) {
698 if(hasPathologyFCAL[index][listElec[ii]]&LArHVPathologyBits::MaskHV){
699 hv=0.;
700 curr = 0.;
701 } else if(hasPathologyFCAL[index][listElec[ii]]&LArHVPathologyBits::MaskCurr){
702 curr = 0.;
703 } else {
704 hv=((hasPathologyFCAL[index][listElec[ii]]&0xFFF0)>>4);
705 curr=0.;
706 }
707 }
708 }
709 }//end if have pathology
710 }//end got voltage
711 else {
712 ATH_MSG_WARNING("Do not have hvline: "<<hvline<<" in LArHVData mapping ! Set voltage to 0 !");
713 }
714 addHV(v,hv-curr,wt);
715
716 }//end loop over lines
717 }//end if found line
718 }// end loop over fcal ids
719
720 return StatusCode::SUCCESS;
721}
722
723void LArHVCondAlg::addHV(voltageCell_t& v , float hv, float wt) const {
724 bool found=false;
725 for (unsigned int i=0;i<v.size();i++) {
726 if (std::fabs(hv-v[i].hv) <0.1) {
727 found=true;
728 v[i].weight += wt;
729 break;
730 }
731 }
732 if (!found) {
733 v.emplace_back(hv,wt);
734 } // not already in the list
735}
736
737
738std::vector<unsigned int> LArHVCondAlg::getElecList(const Identifier& id, const LArHVPathology& pathologyContainer) const
739{
740 std::vector<unsigned int> myList;
741 myList.clear();
742 for(unsigned i=0; i<pathologyContainer.getPathology().size(); ++i) {
743 LArHVPathologiesDb::LArHVElectPathologyDb electPath = pathologyContainer.getPathology()[i];
744 if (electPath.cellID == (unsigned int)(id.get_identifier32().get_compact())) {
745 myList.push_back(electPath.electInd);
746 }
747 }
748 return myList;
749
750}
751
752
753
754StatusCode LArHVCondAlg::dcs2LineVoltage(voltagePerLine_t& result, const std::vector<const CondAttrListCollection* >& fldvec) const {
755
756
757 result.clear();
758
759 ATH_MSG_DEBUG("Got "<<fldvec.size()<<" DCS HV folders");
760 for(const auto *attrlist : fldvec) { // loop over all DCS folders
761 CondAttrListCollection::const_iterator citr=attrlist->begin();
762 CondAttrListCollection::const_iterator citr_e=attrlist->end();
763 ATH_MSG_DEBUG("Length: "<<std::distance(citr,citr_e));
764 for(;citr!=citr_e;++citr) {
765 const unsigned chan=citr->first;
766 ATH_MSG_VERBOSE("Got HV cool chan: "<< chan);
767 const coral::Attribute& attr=((citr)->second)["R_VMEAS"];
768 float voltage=-999;
769 if (!attr.isNull()) voltage=attr.data<float>(); //Ignore NULL values
770 const coral::Attribute& attrc=((citr)->second)["R_IMEAS"];
771 float current=0.;
772 if (!attrc.isNull()) current=attrc.data<float>(); //Ignore NULL values
773 ATH_MSG_VERBOSE("read voltage: "<<voltage<<" and current: "<<current );
774 auto empl=result.emplace(chan,DCS_t{voltage,current});
775 if (!empl.second) {
776 ATH_MSG_WARNING("DCS channel " << chan << " encountered twice!");
777 }
778 }//end loop over attributeListCollection
779 }
780 return StatusCode::SUCCESS;
781}
782
783//=========================================================================================
785 , const LArHVIdMapping* hvCabling
786 , const voltagePerLine_t& voltage) const { // deals with LAr HV, EMBarrel
787
788 ATH_MSG_DEBUG(" start HV_EMB ");
789 const LArHVManager *manager = nullptr;
790
791 if (detStore()->retrieve(manager)==StatusCode::SUCCESS) {
792
793 // accordion calorimeter
794 float HVnominal = HV_nominal("EMB",0.);
795 const EMBHVManager& hvManager_EMB=manager->getEMBHVManager();
796
797 for (unsigned int iSide=hvManager_EMB.beginSideIndex();iSide<hvManager_EMB.endSideIndex();iSide++) { // loop over HV modules
798 for (unsigned int iPhi=hvManager_EMB.beginPhiIndex();iPhi<hvManager_EMB.endPhiIndex();iPhi++) {
799 for (unsigned int iSector=hvManager_EMB.beginSectorIndex();iSector<hvManager_EMB.endSectorIndex();iSector++) {
800 for (unsigned int iEta=hvManager_EMB.beginEtaIndex();iEta<hvManager_EMB.endEtaIndex();iEta++) { //0 to 7
801 const EMBHVModule& hvMod = hvManager_EMB.getHVModule(iSide,iEta,iPhi,iSector);
802
803 float eta_min=hvMod.getEtaMin();
804 float eta_max=hvMod.getEtaMax();
805
806 ATH_MSG_VERBOSE("iSide,iPhi,iSector,iEta " << iSide << " " << iPhi << " " << iSector << " " << iEta);
807 float phi_min=+30.,phi_max=-30.;
808
809 bool are_previous_HV_affected=false;
810 bool are_previous_HV_dead=false;
811 for (unsigned int ielec=0;ielec<32;ielec++) { //use hvMod->getNumElectrodes when bug is corrected
812 const EMBHVElectrode& electrode = hvMod.getElectrode(ielec);
813
814 double hv[2]={0.,0.};
815 for (unsigned int iGap=0;iGap<2;iGap++) { // EMB : 2, TRY TO FIND AUTOMATICALLY NB OF GAPS
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");
820 continue;
821 }
822 hv[iGap]=hvIt->second.hv;
823 } //end for iGap
824
825 ATH_MSG_VERBOSE(" electrode HV " << ielec << " " << electrode.getPhi() << " "<< hv[0] << " " << hv[1] );
826
827 //take decisions according to all the gaps HV :
828 bool isDead=false;
829 if (fabs(hv[0])<DEAD_HV_THRESHOLD && fabs(hv[1])<DEAD_HV_THRESHOLD) isDead=true;
830 bool isAffected=false;
831 if ( !isDead && ((fabs(hv[0]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) || (fabs(hv[1]-HVnominal)>HV_NON_NOMINAL_TOLERANCE))) isAffected=true;
832 ATH_MSG_VERBOSE(" dead/affected " << isDead << " " << isAffected);
833
834 // end previous dead region
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);
838 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,1,3,CaloAffectedRegionInfo::HVdead);
839 vAffected->push_back(current_CaloAffectedRegionInfo);
840 }
841
842 // end previous affected region
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);
846 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,1,3,CaloAffectedRegionInfo::HVaffected);
847 vAffected->push_back(current_CaloAffectedRegionInfo);
848 }
849
850 if (isDead) {
851 if (!are_previous_HV_dead) {
852 phi_min=CaloPhiRange::fix(electrode.getPhi()-1e-4);
853 phi_max=CaloPhiRange::fix(electrode.getPhi()+1e-4);
854 ATH_MSG_VERBOSE(" -- start dead region " << eta_min << " " << eta_max << " " << phi_min << " " <<phi_max);
855 are_previous_HV_dead = true;
856 }
857 else {
858 extendPhiRegion(electrode.getPhi(),phi_min,phi_max);
859 ATH_MSG_VERBOSE(" extend dead region " << phi_min << " " << phi_max);
860 }
861 }
862
863 if (isAffected) {
864 if (!are_previous_HV_affected) {
865 phi_min=CaloPhiRange::fix(electrode.getPhi()-1e-4);
866 phi_max=CaloPhiRange::fix(electrode.getPhi()+1e-4);
867 ATH_MSG_VERBOSE(" -- start affected region " << eta_min << " " << eta_max << " " << phi_min << " " <<phi_max);
868 are_previous_HV_affected = true;
869 }
870 else {
871 extendPhiRegion(electrode.getPhi(),phi_min,phi_max);
872 ATH_MSG_VERBOSE(" extend affected region " << phi_min << " " << phi_max);
873 }
874 }
875
876 } // end for ielec
877
878 if (are_previous_HV_affected) { //in case a non nominal exists, stores it if we finish the 32 electrodes (because else the are_previous_HV_affected will be reinitialized for the next 32 electrodes serie )
879 ATH_MSG_VERBOSE(" -- finish affected region after electrode loop " << eta_min << " " << eta_max << " " << phi_min << " " <<phi_max);
880 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,1,3,CaloAffectedRegionInfo::HVaffected);
881 vAffected->push_back(current_CaloAffectedRegionInfo);
882 }
883 if (are_previous_HV_dead) {
884 ATH_MSG_VERBOSE(" -- finish dead region after electrode loop " << eta_min << " " << eta_max << " " << phi_min << " " <<phi_max);
885 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,1,3,CaloAffectedRegionInfo::HVdead);
886 vAffected->push_back(current_CaloAffectedRegionInfo);
887 }
888 } // end for iEta
889 } // end for iSector
890 } // end for iPhi
891 } //end for iSide
892
893 // barrel presampler
894 const EMBPresamplerHVManager& hvManager_EMBPS=manager->getEMBPresamplerHVManager();
895 HVnominal = HV_nominal("EMBPS",0.);
896 for (unsigned int iSide=hvManager_EMBPS.beginSideIndex();iSide<hvManager_EMBPS.endSideIndex();iSide++) { // loop over HV modules
897 for (unsigned int iPhi=hvManager_EMBPS.beginPhiIndex();iPhi<hvManager_EMBPS.endPhiIndex();iPhi++) {
898 for (unsigned int iEta=hvManager_EMBPS.beginEtaIndex();iEta<hvManager_EMBPS.endEtaIndex();iEta++) { //0 to 7
899 const EMBPresamplerHVModule& hvMod = hvManager_EMBPS.getHVModule(iSide,iEta,iPhi);
900 ATH_MSG_VERBOSE("iSide,iPhi,iEta " << iSide << " " << iPhi << " " << iEta);
901 double hv[2];
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");
907 continue;
908 }
909 hv[iGap]=hvIt->second.hv;
910 }
911 float eta_min=hvMod.getEtaMin();
912 float eta_max=hvMod.getEtaMax();
913 float phi_min=CaloPhiRange::fix(hvMod.getPhiMin());
914 float phi_max=CaloPhiRange::fix(hvMod.getPhiMax());
915 ATH_MSG_VERBOSE(" HV " << hv[0] << " " << hv[1] << " " << " etamin,etamax,phimin,phimax " << eta_min << " " << eta_max << " " << phi_min << " " << phi_max);
916
917 //take decisions according to all the gaps HV :
918 bool isDead=false;
919 if (fabs(hv[0])<DEAD_HV_THRESHOLD && fabs(hv[1])<DEAD_HV_THRESHOLD) isDead=true;
920 bool isAffected=false;
921 if ( !isDead && ((fabs(hv[0]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) || (fabs(hv[1]-HVnominal)>HV_NON_NOMINAL_TOLERANCE))) isAffected=true;
922 ATH_MSG_VERBOSE(" dead/affected " << isDead << " " << isAffected );
923
924 if (isDead) {
925 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,0,0,CaloAffectedRegionInfo::HVdead);
926 vAffected->push_back(current_CaloAffectedRegionInfo);
927 }
928 if (isAffected) {
929 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,0,0,CaloAffectedRegionInfo::HVaffected);
930 vAffected->push_back(current_CaloAffectedRegionInfo);
931 }
932 } // loop over iEta EMBPS
933 } // loop over iphi EMBPS
934 } // lop over EMBPS side
935 } else {
936 ATH_MSG_ERROR("Do not have EMB HV Manager !!! ");
937 return StatusCode::FAILURE;
938 }
939 return StatusCode::SUCCESS;
940}
941//=========================================================================================
943 , const LArHVIdMapping* hvCabling
944 , const voltagePerLine_t& voltage) const { // deals with LAr HV, EM EndCap OUTER
945
946 const LArHVManager *manager = nullptr;
947
948 ATH_MSG_DEBUG(" start HV_EMEC_OUTER ");
949
950 if (detStore()->retrieve(manager)==StatusCode::SUCCESS) {
951
952 const EMECHVManager& hvManager_EMEC_OUT=manager->getEMECHVManager(EMECHVModule::OUTER);
953
954 for (unsigned int iSide=hvManager_EMEC_OUT.beginSideIndex();iSide<hvManager_EMEC_OUT.endSideIndex();iSide++) { // loop over HV modules
955 for (unsigned int iPhi=hvManager_EMEC_OUT.beginPhiIndex();iPhi<hvManager_EMEC_OUT.endPhiIndex();iPhi++) {
956 for (unsigned int iSector=hvManager_EMEC_OUT.beginSectorIndex();iSector<hvManager_EMEC_OUT.endSectorIndex();iSector++) {
957 for (unsigned int iEta=hvManager_EMEC_OUT.beginEtaIndex();iEta<hvManager_EMEC_OUT.endEtaIndex();iEta++) {
958 const EMECHVModule& hvMod=hvManager_EMEC_OUT.getHVModule(iSide,iEta,iPhi,iSector);
959
960 float etaMod = 0.5*(fabs(hvMod.getEtaMin())+fabs(hvMod.getEtaMax()));
961 float HVnominal = HV_nominal("EMEC",etaMod);
962
963 float eta_min=hvMod.getEtaMin();
964 float eta_max=hvMod.getEtaMax();
965
966 ATH_MSG_VERBOSE("iSide,iPhi,iSector,iEta " << iSide << " " << iPhi << " " << iSector << " "
967 << iEta << " eta_min , eta_max " << eta_min << " " << eta_max );
968
969
970 float phi_min=+30.,phi_max=-30.;
971
972 bool are_previous_HV_affected=false;
973 bool are_previous_HV_dead=false;
974 for (unsigned int ielec=0;ielec<hvMod.getNumElectrodes();ielec++) { //use hvMod->getNumElectrodes when bug is corrected
975 const EMECHVElectrode& electrode = hvMod.getElectrode(ielec);
976
977 double hv[2];
978 for (unsigned int iGap=0;iGap<2;iGap++) { //EMEC : 2 gaps, TRY TO FIND AUTOMATICALLY NB OF GAPS
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");
983 continue;
984 }
985 hv[iGap]=hvIt->second.hv;
986 } //end for iGap
987
988 //------------------
989 //take decisions according to all the gaps HV :
990 bool isDead=false;
991 if (fabs(hv[0])<DEAD_HV_THRESHOLD && fabs(hv[1])<DEAD_HV_THRESHOLD) isDead=true;
992 bool isAffected=false;
993 if ( !isDead && ((fabs(hv[0]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) || (fabs(hv[1]-HVnominal)>HV_NON_NOMINAL_TOLERANCE))) isAffected=true;
994 ATH_MSG_VERBOSE(" electrode HV " << ielec << " " << electrode.getPhi() << " " << hv[0]
995 << " " << hv[1] << " " << " isDead/isAffected " << isDead << " " << isAffected );
996
997 // end previous dead region
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);
1001 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,5,7,CaloAffectedRegionInfo::HVdead);
1002 vAffected->push_back(current_CaloAffectedRegionInfo);
1003 }
1004
1005 // end previous affected region
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);
1009 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,5,7,CaloAffectedRegionInfo::HVaffected);
1010 vAffected->push_back(current_CaloAffectedRegionInfo);
1011 }
1012
1013 if (isDead) {
1014 if (!are_previous_HV_dead) {
1015 phi_min=CaloPhiRange::fix(electrode.getPhi()-1e-4);
1016 phi_max=CaloPhiRange::fix(electrode.getPhi()+1e-4);
1017 are_previous_HV_dead = true;
1018 ATH_MSG_VERBOSE(" -- start dead region " << eta_min << " " << eta_max << " " << phi_min << " " <<phi_max);
1019 }
1020 else {
1021 extendPhiRegion(electrode.getPhi(),phi_min,phi_max);
1022 ATH_MSG_VERBOSE(" extend affected region " << phi_min << " " << phi_max);
1023 }
1024 }
1025
1026 if (isAffected) {
1027 if (!are_previous_HV_affected) {
1028 phi_min=CaloPhiRange::fix(electrode.getPhi()-1e-4);
1029 phi_max=CaloPhiRange::fix(electrode.getPhi()+1e-4);
1030 are_previous_HV_affected = true;
1031 ATH_MSG_VERBOSE(" -- start affected region " << eta_min << " " << eta_max << " " << phi_min << " " <<phi_max);
1032 }
1033 else {
1034 extendPhiRegion(electrode.getPhi(),phi_min,phi_max);
1035 ATH_MSG_VERBOSE(" extend affected region " << phi_min << " " << phi_max);
1036 }
1037 }
1038
1039 } // end for ielec
1040
1041 if (are_previous_HV_affected) {
1042 //in case a non nominal exists, stores it if we finish the 32 electrodes
1043 //(because else the are_previous_HV_affected will be reinitialized
1044 //for the next 32 electrodes serie )
1045 ATH_MSG_VERBOSE(" - finih affected region after electrode loop " << eta_min << " " << eta_max
1046 << " " << phi_max << " " <<phi_max);
1047 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,5,7,CaloAffectedRegionInfo::HVaffected);
1048 vAffected->push_back(current_CaloAffectedRegionInfo);
1049 }
1050 if (are_previous_HV_dead) {
1051 ATH_MSG_VERBOSE(" -- finish dead region after electrode loop " << eta_min << " " << eta_max << " " << phi_max << " " <<phi_max);
1052 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,5,7,CaloAffectedRegionInfo::HVdead);
1053 vAffected->push_back(current_CaloAffectedRegionInfo);
1054 }
1055 } // end for iEta
1056 } // end for iSector
1057 } // end for iPhi
1058 } //end for iSide
1059
1060 // endcap presampler
1061 const EMECPresamplerHVManager& hvManager_EMECPS=manager->getEMECPresamplerHVManager();
1062 float HVnominal = HV_nominal("EMECPS",0.);
1063 for (unsigned int iSide=hvManager_EMECPS.beginSideIndex();iSide<hvManager_EMECPS.endSideIndex();iSide++) { // loop over HV modules
1064 for (unsigned int iPhi=hvManager_EMECPS.beginPhiIndex();iPhi<hvManager_EMECPS.endPhiIndex();iPhi++) {
1065 const EMECPresamplerHVModule& hvMod = hvManager_EMECPS.getHVModule(iSide,iPhi);
1066 double hv[2];
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");
1072 continue;
1073 }
1074 hv[iGap]=hvIt->second.hv;
1075 }//end loop over gaps
1076 float eta_min=hvMod.getEtaMin();
1077 float eta_max=hvMod.getEtaMax();
1078 float phi_min=CaloPhiRange::fix(hvMod.getPhiMin());
1079 float phi_max=CaloPhiRange::fix(hvMod.getPhiMax());
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);
1083
1084 //take decisions according to all the gaps HV :
1085 bool isDead=false;
1086 if (fabs(hv[0])<DEAD_HV_THRESHOLD && fabs(hv[1])<DEAD_HV_THRESHOLD) isDead=true;
1087 bool isAffected=false;
1088 if ( !isDead && ((fabs(hv[0]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) || (fabs(hv[1]-HVnominal)>HV_NON_NOMINAL_TOLERANCE))) isAffected=true;
1089 ATH_MSG_VERBOSE(" dead/affected " << isDead << " " << isAffected);
1090
1091 if (isDead) {
1092 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,4,4,CaloAffectedRegionInfo::HVdead);
1093 vAffected->push_back(current_CaloAffectedRegionInfo);
1094 }
1095 if (isAffected) {
1096 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,4,4,CaloAffectedRegionInfo::HVaffected);
1097 vAffected->push_back(current_CaloAffectedRegionInfo);
1098 }
1099 } // loop over iphi EMECPS
1100 } // lop over EMECPS side
1101 } else {
1102 ATH_MSG_ERROR("DO not have EMEC HV manager !");
1103 return StatusCode::FAILURE;
1104 }
1105 return StatusCode::SUCCESS;
1106}
1107//=========================================================================================
1109 , const LArHVIdMapping* hvCabling
1110 , const voltagePerLine_t& voltage) const { // deals with LAr HV, EM EndCap INNER
1111 const LArHVManager *manager = nullptr;
1112
1113 ATH_MSG_VERBOSE(" start loop over EMEC_INNER ");
1114 if (detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1115
1116 const EMECHVManager& hvManager_EMEC_IN=manager->getEMECHVManager(EMECHVModule::INNER);
1117
1118 for (unsigned int iSide=hvManager_EMEC_IN.beginSideIndex();iSide<hvManager_EMEC_IN.endSideIndex();iSide++) { // loop over HV modules
1119 for (unsigned int iPhi=hvManager_EMEC_IN.beginPhiIndex();iPhi<hvManager_EMEC_IN.endPhiIndex();iPhi++) {
1120 for (unsigned int iSector=hvManager_EMEC_IN.beginSectorIndex();iSector<hvManager_EMEC_IN.endSectorIndex();iSector++) {
1121 for (unsigned int iEta=hvManager_EMEC_IN.beginEtaIndex();iEta<hvManager_EMEC_IN.endEtaIndex();iEta++) {
1122 const EMECHVModule& hvMod=hvManager_EMEC_IN.getHVModule(iSide,iEta,iPhi,iSector);
1123
1124 float etaMod = 0.5*(fabs(hvMod.getEtaMin())+fabs(hvMod.getEtaMax()));
1125 float HVnominal = HV_nominal("EMEC",etaMod);
1126
1127 float eta_min = hvMod.getEtaMin();
1128 float eta_max = hvMod.getEtaMax();
1129
1130 ATH_MSG_VERBOSE("iSide,iPhi,iSector,iEta " << iSide << " " << iPhi << " " << iSector << " "
1131 << iEta << " eta_min , eta_max " << eta_min << " " << eta_max);
1132
1133 float phi_min=+30.,phi_max=-30.;
1134
1135 bool are_previous_HV_affected=0;
1136 bool are_previous_HV_dead=0;
1137 for (unsigned int ielec=0;ielec<hvMod.getNumElectrodes();ielec++) {
1138 const EMECHVElectrode& electrode = hvMod.getElectrode(ielec);
1139
1140 double hv[2];
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");
1146 continue;
1147 }
1148 hv[iGap]=hvIt->second.hv;
1149 } //end for iGap
1150
1151 //------------------
1152 //take decisions according to all the gaps HV :
1153 bool isDead=false;
1154 if (fabs(hv[0])<DEAD_HV_THRESHOLD && fabs(hv[1])<DEAD_HV_THRESHOLD) isDead=true;
1155 bool isAffected=false;
1156 if ( !isDead && ((fabs(hv[0]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) || (fabs(hv[1]-HVnominal)>HV_NON_NOMINAL_TOLERANCE))) isAffected=true;
1157 ATH_MSG_VERBOSE(" electrode HV " << ielec << " " << electrode.getPhi() << " "
1158 << hv[0] << " " << hv[1] << " " << " isDead, isAffected "
1159 << isDead << " " << isAffected);
1160
1161 // end previous dead region
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);
1165 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,5,7,CaloAffectedRegionInfo::HVdead);
1166 vAffected->push_back(current_CaloAffectedRegionInfo);
1167 }
1168
1169 // end previous affected region
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);
1173 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,5,7,CaloAffectedRegionInfo::HVaffected);
1174 vAffected->push_back(current_CaloAffectedRegionInfo);
1175 }
1176
1177 if (isDead) {
1178 if (!are_previous_HV_dead) {
1179 phi_min=CaloPhiRange::fix(electrode.getPhi()-1e-4);
1180 phi_max=CaloPhiRange::fix(electrode.getPhi()+1e-4);
1181 ATH_MSG_VERBOSE(" -- start dead region " << phi_min << " " << phi_max);
1182 are_previous_HV_dead = true;
1183 }
1184 else {
1185 extendPhiRegion(electrode.getPhi(),phi_min,phi_max);
1186 ATH_MSG_VERBOSE(" extend dead region " << phi_min << " " << phi_max);
1187 }
1188 }
1189
1190 if (isAffected) {
1191 if (!are_previous_HV_affected) {
1192 phi_min=CaloPhiRange::fix(electrode.getPhi()-1e-4);
1193 phi_max=CaloPhiRange::fix(electrode.getPhi()+1e-4);
1194 are_previous_HV_affected = true;
1195 ATH_MSG_VERBOSE(" -- start affected region " << phi_min << " " << phi_max);
1196 }
1197 else {
1198 extendPhiRegion(electrode.getPhi(),phi_min,phi_max);
1199 ATH_MSG_VERBOSE(" extend affected region " << phi_min << " " << phi_max);
1200 }
1201 }
1202
1203 } // end for ielec
1204
1205 if (are_previous_HV_affected) {
1206 //in case a non nominal exists, stores it if we finish the 32 electrodes
1207 //(because else the are_previous_HV_affected will be reinitialized
1208 //for the next 32 electrodes serie )
1209 ATH_MSG_VERBOSE(" - finish affected region after electrode loop " << eta_min << " "
1210 << eta_max << " " << phi_max << " " <<phi_max);
1211 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,5,7,CaloAffectedRegionInfo::HVaffected);
1212 vAffected->push_back(current_CaloAffectedRegionInfo);
1213 }
1214 if (are_previous_HV_dead) {
1215 ATH_MSG_VERBOSE(" - end dead region after electrode loop " << eta_min << " " << eta_max << " " << phi_max << " " <<phi_max);
1216 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,5,7,CaloAffectedRegionInfo::HVdead);
1217 vAffected->push_back(current_CaloAffectedRegionInfo);
1218 }
1219 } // end for iEta
1220 } // end for iSector
1221 } // end for iPhi
1222 } //end for iSide
1223 } else {
1224 ATH_MSG_ERROR("DO not have EMEC HV manager ");
1225 return StatusCode::FAILURE;
1226 }
1227 return StatusCode::SUCCESS;
1228}
1229//=========================================================================================
1231 , const LArHVIdMapping* hvCabling
1232 , const voltagePerLine_t& voltage) const { // deals with LAr HV, HEC
1233
1234 ATH_MSG_DEBUG(" in HEC ");
1235 const LArHVManager *manager = nullptr;
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};
1238
1239 float HVnominal = HV_nominal("HEC",0.);
1240
1241
1242 if (detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1243
1244 const HECHVManager& hvManager_HEC=manager->getHECHVManager();
1245
1246 for (unsigned int iSide=hvManager_HEC.beginSideIndex();iSide<hvManager_HEC.endSideIndex();iSide++) { // loop over HV modules
1247 for (unsigned int iPhi=hvManager_HEC.beginPhiIndex();iPhi<hvManager_HEC.endPhiIndex();iPhi++) {
1248 for (unsigned int iSampling=hvManager_HEC.beginSamplingIndex();iSampling<hvManager_HEC.endSamplingIndex();iSampling++) {
1249 float eta_min,eta_max;
1250 if (iSide==1) {
1251 eta_min = etamin_layer[iSampling];
1252 eta_max = etamax_layer[iSampling];
1253 } else {
1254 eta_min = -1.*etamax_layer[iSampling];
1255 eta_max = -1.*etamin_layer[iSampling];
1256 }
1257
1258 const HECHVModule& hvMod = hvManager_HEC.getHVModule(iSide,iPhi,iSampling);
1259 ATH_MSG_VERBOSE(" iSide,iPhi,iSampling " << iSide << " " << iPhi << " " << iSampling);
1260
1261 double hv[4] = {0}; // 4 subgaps in HEC
1262 for (unsigned int iGap=0;iGap<hvMod.getNumSubgaps();iGap++) {
1263 const HECHVSubgap& subgap=hvMod.getSubgap(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");
1268 continue;
1269 }
1270 if(iGap<4) hv[iGap]=hvIt->second.hv;
1271 }// end for iGap
1272
1273 //------------------
1274 //take decisions according to all the gaps HV :
1275 bool isDead=false;
1276 if (fabs(hv[0])<DEAD_HV_THRESHOLD && fabs(hv[1])<DEAD_HV_THRESHOLD && fabs(hv[2])<DEAD_HV_THRESHOLD && fabs(hv[3])<DEAD_HV_THRESHOLD) isDead=true;
1277 bool isAffected=false;
1278 if ( !isDead && ((fabs(hv[0]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) || (fabs(hv[1]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) ||
1279 (fabs(hv[2]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) || (fabs(hv[3]-HVnominal)>HV_NON_NOMINAL_TOLERANCE)) ) isAffected=true;
1280 ATH_MSG_VERBOSE(" HV values " << hv[0] << " " << hv[1] << " " << hv[2] << " " << hv[3] << " "
1281 << " isDead/isAffected " << isDead << " " << isAffected);
1282
1283 float phiMin = CaloPhiRange::fix(hvMod.getPhiMin());
1284 float phiMax = CaloPhiRange::fix(hvMod.getPhiMax());
1285
1286
1287 if (isDead) { //stores it, DEAD means all hvs < threshold
1288 ATH_MSG_VERBOSE(" new dead region " << eta_min << " " << eta_max << " " << phiMin << " " << phiMax << " layer " << 8+iSampling);
1289 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phiMin,phiMax,8+iSampling,8+iSampling,CaloAffectedRegionInfo::HVdead);
1290 vAffected->push_back(current_CaloAffectedRegionInfo);
1291 }
1292 if (isAffected) {
1293 ATH_MSG_VERBOSE(" new affected region " << eta_min << " " << eta_max << " " << phiMin << " " << phiMax << " layer " << 8+iSampling);
1294 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phiMin,phiMax,8+iSampling,8+iSampling,CaloAffectedRegionInfo::HVaffected);
1295 vAffected->push_back(current_CaloAffectedRegionInfo);
1296 }
1297
1298 } //end for iSampling
1299 }//end for iPhi
1300 }//end for iSide
1301 } else {
1302 ATH_MSG_ERROR("Do not have HEC HV manager ");
1303 return StatusCode::FAILURE;
1304 }
1305 return StatusCode::SUCCESS;
1306}
1307//=========================================================================================
1309 , const LArHVIdMapping* hvCabling
1310 , const voltagePerLine_t& voltage) const { // deals with LAr HV, FCAL
1311
1312 ATH_MSG_DEBUG( " inFCAL ");
1313 const LArHVManager *manager = nullptr;
1314 if (detStore()->retrieve(manager)==StatusCode::SUCCESS) {
1315
1316 const FCALHVManager& hvManager_FCAL=manager->getFCALHVManager();
1317
1318 for (unsigned int iSide=hvManager_FCAL.beginSideIndex();iSide<hvManager_FCAL.endSideIndex();iSide++) { // loop over HV modules
1319 float eta_min=3.1,eta_max=4.9;
1320 if (iSide==0) {
1321 eta_min=-4.9;
1322 eta_max=-3.1;
1323 }
1324 for (unsigned int iSampling=hvManager_FCAL.beginSamplingIndex();iSampling<hvManager_FCAL.endSamplingIndex();iSampling++) {
1325 float HVnominal = HV_nominal("FCAL",(float)(iSampling));
1326 for (unsigned int iSector=hvManager_FCAL.beginSectorIndex(iSampling);iSector<hvManager_FCAL.endSectorIndex(iSampling);iSector++) {
1327
1328 const FCALHVModule& hvMod = hvManager_FCAL.getHVModule(iSide,iSector,iSampling);
1329 ATH_MSG_VERBOSE(" FCAL HVModule side,sampling,sector " << iSide << " " << iSampling << " "
1330 << iSector << " HV nominal " << HVnominal);
1331
1332 float dphi=CaloPhiRange::twopi()/16;
1333 if (iSampling==1) dphi=CaloPhiRange::twopi()/8.;
1334 if (iSampling==2) dphi=CaloPhiRange::twopi()/4.;
1335 float phi_min = ((float)(iSector))*dphi;
1336 phi_min = CaloPhiRange::fix(phi_min);
1337 float phi_max = CaloPhiRange::fix(dphi+phi_min);
1338
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());
1341 float hv[4] = {0};
1342 for (unsigned int iLine=0;iLine<hvMod.getNumHVLines();iLine++) {
1343 const FCALHVLine& hvline = hvMod.getHVLine(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");
1348 continue;
1349 }
1350 if (iLine<4) hv[iLine]=hvIt->second.hv;
1351 }
1352 //------------------
1353 //take decisions according to all the gaps HV :
1354 bool isDead=false;
1355 if (fabs(hv[0]) < DEAD_HV_THRESHOLD && fabs(hv[1]) < DEAD_HV_THRESHOLD && fabs(hv[2]) < DEAD_HV_THRESHOLD && fabs(hv[3]) < DEAD_HV_THRESHOLD) isDead=true;
1356 bool isAffected=false;
1357 if ( !isDead && ((fabs(hv[0]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) || (fabs(hv[1]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) ||
1358 (fabs(hv[2]-HVnominal)>HV_NON_NOMINAL_TOLERANCE) || (fabs(hv[3]-HVnominal)>HV_NON_NOMINAL_TOLERANCE)) ) isAffected=true;
1359 ATH_MSG_VERBOSE(" HV values " << hv[0] << " " << hv[1] << " " << hv[2] << " " << hv[3] << " "
1360 << " isDead/isAffected " << isDead << " " << isAffected);
1361
1362
1363 if (isAffected) {
1364 ATH_MSG_VERBOSE(" -- store affected region ");
1365 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,21+iSampling,21+iSampling,CaloAffectedRegionInfo::HVaffected);
1366 vAffected->push_back(current_CaloAffectedRegionInfo);
1367 }
1368 if (isDead) {
1369 ATH_MSG_VERBOSE(" -- store dead region ");
1370 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,21+iSampling,21+iSampling,CaloAffectedRegionInfo::HVdead);
1371 vAffected->push_back(current_CaloAffectedRegionInfo);
1372 }
1373 } //end iSector
1374 } //end iSampling
1375 }// end iSide
1376 } else {
1377 ATH_MSG_ERROR("Do not have FCAL HV manager");
1378 return StatusCode::FAILURE;
1379 }
1380 return StatusCode::SUCCESS;
1381}
1382//=========================================================================================
1383StatusCode LArHVCondAlg::updateMethod(const EventContext& ctx,
1384 CaloAffectedRegionInfoVec *vAffected, const LArBadFebCont* bfCont,
1385 const LArOnOffIdMapping* cabling) const { //store informations on the missing Febs w/ range of eta, phi, layer
1386 ATH_MSG_DEBUG ( "updateMethod()" );
1387
1389 const CaloDetDescrManager* calodetdescrmgr = *caloMgrHandle;
1390
1391 for (const HWIdentifier febId : m_onlineID->feb_range()) {
1392 bool IsMissingFeb=(bfCont->status(febId).deadAll() || bfCont->status(febId).deadReadout());
1393
1394 if (IsMissingFeb) { //flag for special treatment for FEB that has non contiguous eta regions, so we have to separate them
1395 bool is_normal=0; //FEB without discontinuity
1396 bool is_additive1=0; //FEB with a discontinuity
1397
1398 int layer_min=+30,layer_max=-30;
1399 float eta_min=+30,eta_max=-30;
1400 float phi_min=+30,phi_max=-30;
1401
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;
1405
1406 int chans_per_feb = m_onlineID->channelInSlotMax(febId);
1407
1408 for (int icha=0;icha<chans_per_feb;icha++) { //loop on each channel of the relevant FEB
1409 HWIdentifier channelId=m_onlineID->channel_Id(febId,icha);
1410
1411 if (cabling->isOnlineConnected(channelId)) {
1412 Identifier offlineId=cabling->cnvToIdentifier(channelId);
1413 const CaloDetDescrElement* caloddElement=calodetdescrmgr->get_element(offlineId);
1414
1415 CaloCell_ID::CaloSample current_layer=caloddElement->getSampling(); // calo layer
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();
1421
1422 if (caloddElement->is_lar_em_barrel() && caloddElement->getLayer()==3 && fabs(current_eta)>0.79 && fabs(current_eta)<1.33) { //EMB, back sampling, slot 12 : special treatment : this FEB has non contiguous eta regions, so we have to separate them
1423 is_additive1=1; //in order to add it to the summary only if it happens
1424
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;
1429
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;
1434
1435 extendPhiRegion(current_phi_low,phi_min_additive1,phi_max_additive1);
1436 extendPhiRegion(current_phi_high,phi_min_additive1,phi_max_additive1);
1437
1438 }
1439 else { //normal case
1440 is_normal=1; // normal case
1441
1442 if (current_layer<layer_min)
1443 layer_min=current_layer;
1444 if (current_layer>layer_max)
1445 layer_max=current_layer;
1446
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;
1451
1452 extendPhiRegion(current_phi_low,phi_min,phi_max);
1453 extendPhiRegion(current_phi_high,phi_min,phi_max);
1454
1455 }
1456 } //end of isOnlineConnected()
1457 } // end of loop on channels
1458
1459 if (is_normal) {
1460 CaloAffectedRegionInfo current_CaloAffectedRegionInfo(eta_min,eta_max,phi_min,phi_max,layer_min,layer_max,CaloAffectedRegionInfo::missingReadout);
1461 vAffected->push_back(current_CaloAffectedRegionInfo);
1462 }
1463
1464 if (is_additive1) {
1465 CaloAffectedRegionInfo current_additive1_CaloAffectedRegionInfo(eta_min_additive1,eta_max_additive1,phi_min_additive1,phi_max_additive1,layer_min_additive1,layer_max_additive1,CaloAffectedRegionInfo::missingReadout);
1466 vAffected->push_back(current_additive1_CaloAffectedRegionInfo);
1467 }
1468 } // end of isMissingFeb
1469 } // end of loop on Febs
1470 return StatusCode::SUCCESS;
1471}
1472//====================================================================================
1473float LArHVCondAlg::HV_nominal(const char *identification,const float myparameter) const
1474{
1475 if (strcmp(identification,"EMBPS")==0)
1476 return 1200.;
1477 else if (strcmp(identification,"EMECPS")==0)
1478 return 1600.;
1479 else if (strcmp(identification,"EMB")==0)
1480 return 2000.;
1481 else if (strcmp(identification,"EMEC")==0) {
1482 if ( fabs(myparameter)<1.5 )
1483 return 2500.;
1484 else if (fabs(myparameter)<1.6)
1485 return 2300.;
1486 else if (fabs(myparameter)<1.8 )
1487 return 2100.;
1488 else if ( fabs(myparameter) < 2.0 )
1489 return 1700.;
1490 else if ( fabs(myparameter) < 2.1 )
1491 return 1500.;
1492 else if ( fabs(myparameter) < 2.3 )
1493 return 1250.;
1494 else if ( fabs(myparameter) < 2.5 )
1495 return 1000.;
1496 else if ( fabs(myparameter) < 2.8 )
1497 return 2300.;
1498 else return 1800.;
1499 }
1500 else if (strcmp(identification,"HEC")==0) {
1501 return 1800.;
1502 }
1503 else if (strcmp(identification,"FCAL")==0) {
1504 if (myparameter<0.5)
1505 return 250.;
1506 else if (myparameter<1.5)
1507 return 375.;
1508 else if (myparameter<2.5)
1509 return 500.;
1510 }
1511
1512 return -1;
1513}
1514//=========================================================================================
1515
1516void LArHVCondAlg::extendPhiRegion(float phi, float & phi_min, float & phi_max) const {
1517
1518 static const float epsilon=1e-4;
1519
1521
1522 if (phi_min>10. || phi_max<-10.) {
1523 phi_min = CaloPhiRange::fix(phi-epsilon);
1524 phi_max = CaloPhiRange::fix(phi+epsilon);
1525 return;
1526 }
1527
1528 bool isInRegion=false;
1529 if (phi_min<phi_max) {
1530 if (phi>phi_min && phi<phi_max) isInRegion=true;
1531 }
1532 else {
1533 if (phi>phi_min || phi<phi_max) isInRegion=true;
1534 }
1535 if (isInRegion) return;
1536
1537 float dphi1 = CaloPhiRange::diff(phi,phi_min);
1538 float dphi2 = CaloPhiRange::diff(phi,phi_max);
1539 if (fabs(dphi1)<fabs(dphi2) )
1540 phi_min=phi;
1541 else
1542 phi_max=phi;
1543
1544 return;
1545
1546}
Scalar phi() const
phi method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(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...
LArBadXCont< LArBadFeb > LArBadFebCont
#define DEAD_HV_THRESHOLD
#define MAX_LAR_CELLS
#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
Definition CaloCell_ID.h:53
This class groups all DetDescr information related to a CaloCell.
virtual int getLayer() const
cell layer
CaloCell_ID::CaloSample getSampling() const
cell sampling
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 twopi()
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
double getPhi() 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.
Definition EMBHVModule.h:20
const EMBHVElectrode & getElectrode(unsigned int iElectrode) const
double getEtaMin() const
unsigned int getPhiIndex() const
unsigned int getSideIndex() const
double getEtaMax() 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 beginPhiIndex() const
static unsigned int endSideIndex()
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
LAr EMEC Detector Element.
EMECCellConstLink getEMECCell() const
EMEC Cell description from LArReadoutGeometry.
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
double getPhi() 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
double getEtaMax() const
const EMECHVElectrode & getElectrode(unsigned int iElectrode) const
unsigned int getNumElectrodes() const
unsigned int getSideIndex() const
unsigned int getSectorIndex() const
double getEtaMin() const
unsigned int getPhiIndex() const
unsigned int getEtaIndex() const
This class provides direct access to information on the HV electrodes within the EMEC.
const EMECPresamplerHVModule & getHVModule(unsigned int iSide, unsigned int iPhi) const
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.
Definition FCALTile.h:27
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.
Definition HECHVModule.h:21
const HECHVSubgap & getSubgap(unsigned int iElectrode) const
unsigned int getSideIndex() const
unsigned int getSamplingIndex() const
double getPhiMin() const
static unsigned int getNumSubgaps()
double getPhiMax() const
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.
Definition LArBadFeb.h:33
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
Definition index.py:1