28#include "GaudiKernel/ThreadLocalContext.h"
34#include "CoralBase/Blob.h"
36#include "TBufferFile.h"
46 return StatusCode::FAILURE;
66 return StatusCode::SUCCESS;
73 const EventContext& ctx = Gaudi::Hive::currentContext();
75 int nevt = ctx.eventID().event_number();
76 if (nevt!=1)
return StatusCode::SUCCESS;
84 const std::vector<LArHVPathologiesDb::LArHVElectPathologyDb>* pathologyContainer=
nullptr;
93 return StatusCode::FAILURE;
95 pathologyContainer=&(pathologies->m_v);
98 coral::Blob& blob=(*attrlist)[
"Constants"].data<coral::Blob>();
101 if(!
sc.isSuccess()) {
110 return StatusCode::SUCCESS;
127 std::ifstream infile;
130 if(!infile.is_open()) {
136 char commentSign(
'#');
137 std::string commentLine(
""), foldername(
"");
139 unsigned short electInd, pathologyType;
142 while(!infile.eof()) {
143 infile >> foldername;
150 <<
" in the input file");
154 ATH_MSG_INFO(
"Found folder " << foldername <<
" in the input file");
160 while(!infile.eof()) {
162 checkChar =
static_cast<char> (infile.get());
165 if((checkChar >=
'0') && (checkChar <=
'9')) {
168 std::vector<unsigned int> elecList;
171 infile >> cellID >> electInd >> pathologyType;
172 elecList.push_back(electInd);
174 unsigned int bec,pos_neg,FT,slot,channel,hvModule,hvLine;
175 infile >> bec >> pos_neg >> FT >> slot >> channel >> hvModule >> hvLine >> pathologyType;
176 ATH_MSG_INFO(
" read " << bec <<
" " << pos_neg <<
" " << FT <<
" " << slot <<
" " << channel <<
" " << hvModule <<
" " << hvLine <<
" " << pathologyType);
178 Identifier id = cabling->cnvToIdentifier( hwid);
179 cellID = (
unsigned int)(
id.get_identifier32().get_compact());
180 elecList=
getElectInd(**hvIdMapping,
id,hvModule,hvLine,calodetdescrmgr);
181 ATH_MSG_INFO(
" cellId , elecList size " << cellID <<
" " << elecList.size());
183 for (
unsigned int i=0;i<elecList.size();i++) {
185 electPath.
cellID = cellID;
189 pathologies.
m_v.push_back(electPath);
191 <<
"," << elecList[i]
192 <<
"," << pathologyType <<
")");
195 else if(checkChar==commentSign) {
197 std::getline(infile,commentLine);
207 return std::make_optional<LArHVPathologiesDb>(pathologies);
211 const std::vector<LArHVPathologiesDb::LArHVElectPathologyDb>* pathologyContainer)
const
220 return StatusCode::FAILURE;
223 std::ofstream *
fout=
nullptr;
226 pathologyContainer=&(pathHdl->getPathology());
228 if (!pathologyContainer) {
231 return StatusCode::SUCCESS;
245 ATH_MSG_INFO(
"Got pathology for cell ID: " << electPath.cellID
246 <<
"(" << electPath.electInd
247 <<
"," << electPath.pathologyType <<
") ");
248 if(
fout) *
fout<<electPath.cellID<<
"\t"<<electPath.electInd<<
"\t"<<electPath.pathologyType<<std::endl;
250 ATH_MSG_INFO(
"Got pathology for cell ID: " << electPath.cellID);
252 int HVLine=
getHVline(**hvIdMapping,
Identifier(electPath.cellID),electPath.electInd,calodetdescrmgr);
256 int hvmodule=HVLine/1000;
257 int hvline=HVLine%1000;
271 return StatusCode::SUCCESS;
274std::vector<unsigned int>
282 std::vector<unsigned int> list;
283 int HVline = 1000*
module + line;
290 unsigned int nelec = cell->getNumElectrodes();
291 for (
unsigned int i=0;i<nelec;i++) {
293 for (
unsigned int igap=0;igap<2;igap++) {
294 if (electrode.
hvLineNo(igap, &hvIdMapping)==HVline) {
295 list.push_back(2*i+igap);
305 unsigned int nelec = cell->getNumElectrodes();
306 for (
unsigned int i=0;i<nelec;i++) {
308 for (
unsigned int igap=0;igap<2;igap++) {
309 if (electrode.
hvLineNo(igap, &hvIdMapping)==HVline) {
310 list.push_back(2*i+igap);
321 for (
unsigned int igap=0;igap<2;igap++) {
322 if (hvmodule.
hvLineNo(igap, &hvIdMapping)==HVline) {
323 list.push_back(igap);
333 for (
unsigned int igap=0;igap<2;igap++) {
334 if (hvmodule.
hvLineNo(igap, &hvIdMapping)==HVline) {
335 list.push_back(igap);
345 unsigned int nsubgaps = cell->getNumSubgaps();
346 for (
unsigned int i=0;i<nsubgaps;i++) {
348 if (subgap.
hvLineNo(&hvIdMapping)==HVline) {
357 const FCALTile* tile = fcalElement->getFCALTile();
359 for (
unsigned int i=0;i<nlines;i++) {
362 if (line2->hvLineNo(&hvIdMapping)==HVline) {
376 short unsigned int ElectInd,
380 unsigned int igap, ielec;
387 unsigned int nelec = cell->getNumElectrodes();
389 ielec = std::div(ElectInd - igap, 2).quot;
391 ATH_MSG_ERROR(
"Wrong electrode number " << ielec <<
" for cell "<<
id.get_identifier32().get_compact());
394 return cell->getElectrode(ielec).hvLineNo(igap, &hvIdMapping);
402 unsigned int nelec = cell->getNumElectrodes();
404 ielec = std::div(ElectInd - igap, 2).quot;
406 ATH_MSG_ERROR(
"Wrong electrode number " << ielec <<
" for cell "<<
id.get_identifier32().get_compact());
409 return cell->getElectrode(ielec).hvLineNo(igap, &hvIdMapping);
419 ATH_MSG_ERROR(
"Wrong igap "<<ElectInd<<
" for EMBPS cell "<<
id.get_identifier32().get_compact());
422 return hvmodule.
hvLineNo(ElectInd, &hvIdMapping);
432 ATH_MSG_ERROR(
"Wrong igap "<<ElectInd<<
" for EMECPS cell "<<
id.get_identifier32().get_compact());
435 return hvmodule.
hvLineNo(ElectInd, &hvIdMapping);
444 unsigned int nsubgaps = cell->getNumSubgaps();
445 if( ElectInd >= nsubgaps) {
446 ATH_MSG_ERROR(
"Wrong igap "<<ElectInd<<
" for HEC cell "<<
id.get_identifier32().get_compact());
449 return cell->getSubgap(ElectInd).hvLineNo(&hvIdMapping);
456 const FCALTile* tile = fcalElement->getFCALTile();
458 if( ElectInd >= nlines) {
459 ATH_MSG_ERROR(
"Wrong line "<<ElectInd<<
" for FCAL cell "<<
id.get_identifier32().get_compact());
462 const FCALHVLine* line2 = tile->getHVLine(ElectInd);
464 return line2->hvLineNo(&hvIdMapping);
466 ATH_MSG_ERROR(
"Do not have HVLine for "<<ElectInd<<
" for FCAL cell "<<
id.get_identifier32().get_compact());
480 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
481 spec->extend(
"blobVersion",
483 spec->extend(
"Constants",
"blob");
485 std::unique_ptr<AthenaAttributeList> attrList = std::make_unique<AthenaAttributeList>(*spec);
487 (*attrList)[
"blobVersion"].data<
unsigned int>() = (
unsigned int)0;
488 coral::Blob& blob = (*attrList)[
"Constants"].data<coral::Blob>();
490 TClass* klass = TClass::GetClass(
"LArHVPathologiesDb");
491 if (klass ==
nullptr) {
497 TBufferFile buf(TBuffer::kWrite);
499 if (buf.WriteObjectAny(&pathologyContainer, klass) != 1) {
504 blob.resize(buf.Length());
505 void* adr = blob.startingAddress();
506 memcpy(adr, buf.Buffer(), buf.Length());
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Calo Subsystem specific Detector Elements + Dummy element for testing.
GeoIntrusivePtr< const EMBCell > EMBCellConstLink
GeoIntrusivePtr< const HECCell > HECCellConstLink
@Class: HECCellConstLink
This is an interface to a tool used to register conditions objects in the Interval of Validity (IOV) ...
const ServiceHandle< StoreGateSvc > & detStore() const
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...
LAr EMB Detector Element.
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
Describes one HV Module within the EMB Presampler.
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
Smart Pointer to EMEC Cells.
LAr EMEC Detector Element.
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
Describes one HV Module within the EMEc Presampler.
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
LAr FCAL Detector Element.
A tile of the forward calorimeter readout geometry.
static unsigned int getNumHVLines()
Get num hvlines.
LAr HEC Detector Element.
int hvLineNo(const LArHVIdMapping *hvIdMapping) const
std::vector< LArHVElectPathologyDb > m_v
SG::ReadCondHandleKey< LArHVIdMapping > m_hvCablingKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode execute() override
const CaloIdManager * m_caloIdMgr
std::vector< unsigned int > getElectInd(const LArHVIdMapping &hvIdMapping, const Identifier &id, unsigned int module, unsigned int line, const CaloDetDescrManager *calodetdescrmgr) const
virtual StatusCode initialize() override
const LArHEC_ID * m_larhec_id
SG::ReadCondHandleKey< LArHVPathology > m_hvPathologyKey
std::unique_ptr< AthenaAttributeList > hvPathology2AttrList(const LArHVPathologiesDb &pathologyContainer) const
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
StatusCode printCondObjects(const EventContext &ctx, const CaloDetDescrManager *calodetdescrmgr, const std::vector< LArHVPathologiesDb::LArHVElectPathologyDb > *path=nullptr) const
const LArFCAL_ID * m_larfcal_id
std::optional< LArHVPathologiesDb > createCondObjects(const EventContext &ctx, const CaloDetDescrManager *calodetdescrmgr) const
BooleanProperty m_writeCondObjs
int getHVline(const LArHVIdMapping &hvIdMapping, const Identifier &id, short unsigned int ElectInd, const CaloDetDescrManager *calodetdescrmgr) const
const LArEM_ID * m_larem_id
const LArOnlineID * m_laronline_id
unsigned short pathologyType