33#include "CoralBase/Blob.h"
35#include "TBufferFile.h"
45 return StatusCode::FAILURE;
65 return StatusCode::SUCCESS;
73 int nevt = ctx.eventID().event_number();
74 if (nevt!=1)
return StatusCode::SUCCESS;
82 const std::vector<LArHVPathologiesDb::LArHVElectPathologyDb>* pathologyContainer=
nullptr;
91 return StatusCode::FAILURE;
93 pathologyContainer=&(pathologies->m_v);
96 coral::Blob& blob=(*attrlist)[
"Constants"].data<coral::Blob>();
108 return StatusCode::SUCCESS;
125 std::ifstream infile;
128 if(!infile.is_open()) {
134 char commentSign(
'#');
135 std::string commentLine(
""), foldername(
"");
137 unsigned short electInd, pathologyType;
140 while(!infile.eof()) {
141 infile >> foldername;
148 <<
" in the input file");
152 ATH_MSG_INFO(
"Found folder " << foldername <<
" in the input file");
158 while(!infile.eof()) {
160 checkChar =
static_cast<char> (infile.get());
163 if((checkChar >=
'0') && (checkChar <=
'9')) {
166 std::vector<unsigned int> elecList;
169 infile >> cellID >> electInd >> pathologyType;
170 elecList.push_back(electInd);
172 unsigned int bec,pos_neg,FT,slot,channel,hvModule,hvLine;
173 infile >> bec >> pos_neg >> FT >> slot >> channel >> hvModule >> hvLine >> pathologyType;
174 ATH_MSG_INFO(
" read " << bec <<
" " << pos_neg <<
" " << FT <<
" " << slot <<
" " << channel <<
" " << hvModule <<
" " << hvLine <<
" " << pathologyType);
176 Identifier id = cabling->cnvToIdentifier( hwid);
177 cellID = (
unsigned int)(
id.get_identifier32().get_compact());
178 elecList=
getElectInd(**hvIdMapping,
id,hvModule,hvLine,calodetdescrmgr);
179 ATH_MSG_INFO(
" cellId , elecList size " << cellID <<
" " << elecList.size());
181 for (
unsigned int i=0;i<elecList.size();i++) {
183 electPath.
cellID = cellID;
187 pathologies.
m_v.push_back(electPath);
189 <<
"," << elecList[i]
190 <<
"," << pathologyType <<
")");
193 else if(checkChar==commentSign) {
195 std::getline(infile,commentLine);
205 return std::make_optional<LArHVPathologiesDb>(pathologies);
209 const std::vector<LArHVPathologiesDb::LArHVElectPathologyDb>* pathologyContainer)
const
218 return StatusCode::FAILURE;
221 std::ofstream *
fout=
nullptr;
224 pathologyContainer=&(pathHdl->getPathology());
226 if (!pathologyContainer) {
229 return StatusCode::SUCCESS;
243 ATH_MSG_INFO(
"Got pathology for cell ID: " << electPath.cellID
244 <<
"(" << electPath.electInd
245 <<
"," << electPath.pathologyType <<
") ");
246 if(
fout) *
fout<<electPath.cellID<<
"\t"<<electPath.electInd<<
"\t"<<electPath.pathologyType<<std::endl;
248 ATH_MSG_INFO(
"Got pathology for cell ID: " << electPath.cellID);
250 int HVLine=
getHVline(**hvIdMapping,
Identifier(electPath.cellID),electPath.electInd,calodetdescrmgr);
254 int hvmodule=HVLine/1000;
255 int hvline=HVLine%1000;
269 return StatusCode::SUCCESS;
272std::vector<unsigned int>
280 std::vector<unsigned int> list;
281 int HVline = 1000*
module + line;
288 unsigned int nelec = cell->getNumElectrodes();
289 for (
unsigned int i=0;i<nelec;i++) {
291 for (
unsigned int igap=0;igap<2;igap++) {
292 if (electrode.
hvLineNo(igap, &hvIdMapping)==HVline) {
293 list.push_back(2*i+igap);
303 unsigned int nelec = cell->getNumElectrodes();
304 for (
unsigned int i=0;i<nelec;i++) {
306 for (
unsigned int igap=0;igap<2;igap++) {
307 if (electrode.
hvLineNo(igap, &hvIdMapping)==HVline) {
308 list.push_back(2*i+igap);
319 for (
unsigned int igap=0;igap<2;igap++) {
320 if (hvmodule.
hvLineNo(igap, &hvIdMapping)==HVline) {
321 list.push_back(igap);
331 for (
unsigned int igap=0;igap<2;igap++) {
332 if (hvmodule.
hvLineNo(igap, &hvIdMapping)==HVline) {
333 list.push_back(igap);
343 unsigned int nsubgaps = cell->getNumSubgaps();
344 for (
unsigned int i=0;i<nsubgaps;i++) {
346 if (subgap.
hvLineNo(&hvIdMapping)==HVline) {
355 const FCALTile* tile = fcalElement->getFCALTile();
357 for (
unsigned int i=0;i<nlines;i++) {
360 if (line2->hvLineNo(&hvIdMapping)==HVline) {
374 short unsigned int ElectInd,
378 unsigned int igap, ielec;
385 unsigned int nelec = cell->getNumElectrodes();
387 ielec = std::div(ElectInd - igap, 2).quot;
389 ATH_MSG_ERROR(
"Wrong electrode number " << ielec <<
" for cell "<<
id.get_identifier32().get_compact());
392 return cell->getElectrode(ielec).hvLineNo(igap, &hvIdMapping);
400 unsigned int nelec = cell->getNumElectrodes();
402 ielec = std::div(ElectInd - igap, 2).quot;
404 ATH_MSG_ERROR(
"Wrong electrode number " << ielec <<
" for cell "<<
id.get_identifier32().get_compact());
407 return cell->getElectrode(ielec).hvLineNo(igap, &hvIdMapping);
417 ATH_MSG_ERROR(
"Wrong igap "<<ElectInd<<
" for EMBPS cell "<<
id.get_identifier32().get_compact());
420 return hvmodule.
hvLineNo(ElectInd, &hvIdMapping);
430 ATH_MSG_ERROR(
"Wrong igap "<<ElectInd<<
" for EMECPS cell "<<
id.get_identifier32().get_compact());
433 return hvmodule.
hvLineNo(ElectInd, &hvIdMapping);
442 unsigned int nsubgaps = cell->getNumSubgaps();
443 if( ElectInd >= nsubgaps) {
444 ATH_MSG_ERROR(
"Wrong igap "<<ElectInd<<
" for HEC cell "<<
id.get_identifier32().get_compact());
447 return cell->getSubgap(ElectInd).hvLineNo(&hvIdMapping);
454 const FCALTile* tile = fcalElement->getFCALTile();
456 if( ElectInd >= nlines) {
457 ATH_MSG_ERROR(
"Wrong line "<<ElectInd<<
" for FCAL cell "<<
id.get_identifier32().get_compact());
460 const FCALHVLine* line2 = tile->getHVLine(ElectInd);
462 return line2->hvLineNo(&hvIdMapping);
464 ATH_MSG_ERROR(
"Do not have HVLine for "<<ElectInd<<
" for FCAL cell "<<
id.get_identifier32().get_compact());
478 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
479 spec->extend(
"blobVersion",
481 spec->extend(
"Constants",
"blob");
483 std::unique_ptr<AthenaAttributeList> attrList = std::make_unique<AthenaAttributeList>(*spec);
485 (*attrList)[
"blobVersion"].data<
unsigned int>() = (
unsigned int)0;
486 coral::Blob& blob = (*attrList)[
"Constants"].data<coral::Blob>();
488 TClass* klass = TClass::GetClass(
"LArHVPathologiesDb");
489 if (klass ==
nullptr) {
495 TBufferFile buf(TBuffer::kWrite);
497 if (buf.WriteObjectAny(&pathologyContainer, klass) != 1) {
502 blob.resize(buf.Length());
503 void* adr = blob.startingAddress();
504 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
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
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
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