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);
101 if(!
sc.isSuccess()) {
110 return StatusCode::SUCCESS;
136 char commentSign(
'#');
139 unsigned short electInd, pathologyType;
150 <<
" in the input file");
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);
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;
186 electPath.electInd = elecList[
i];
187 if(
m_mode==2) electPath.pathologyType = ((pathologyType&0x0FFF)<<4);
188 else electPath.pathologyType = pathologyType;
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;
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;
271 return StatusCode::SUCCESS;
274 std::vector<unsigned int>
282 std::vector<unsigned int>
list;
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) {
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);
458 if( ElectInd >= nlines) {
459 ATH_MSG_ERROR(
"Wrong line "<<ElectInd<<
" for FCAL cell "<<
id.get_identifier32().get_compact());
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;
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());