Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LArHVPathologyDbCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 
12 #include "CoralBase/AttributeListException.h"
13 #include "CoralBase/Blob.h"
14 
21 
25 
26 #include "TBufferFile.h"
27 #include "TClass.h"
28 
29 
30 LArHVPathologyDbCondAlg::LArHVPathologyDbCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
31  : AthReentrantAlgorithm(name,pSvcLocator), m_hvmapTool("LArHVMapTool",this)
32 { }
33 
35 { }
36 
38 {
43 
44  const CaloCell_ID* idHelper = nullptr;
45  ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
46 
47  m_larem_id = idHelper->em_idHelper();
48  m_larhec_id = idHelper->hec_idHelper();
49  m_larfcal_id = idHelper->fcal_idHelper();
50 
51  ATH_CHECK( detStore()->retrieve(m_laronline_id,"LArOnlineID") );
52  ATH_CHECK(detStore()->retrieve(m_hvlineHelper,"LArHVLineID"));
53 
54 
55  m_klass = TClass::GetClass("LArHVPathologiesDb");
56  if(m_klass==nullptr){
57  ATH_MSG_ERROR ( "Can't find TClass LArHVPathologiesDb" );
58  return StatusCode::FAILURE;
59  }
60  else
61  ATH_MSG_DEBUG ( "Got TClass LArHVPathologiesDb" );
62 
63  m_klass->GetStreamerInfo();
64 
65  return StatusCode::SUCCESS;
66 }
67 
69 {
70  return StatusCode::SUCCESS;
71 }
72 
73 
74 StatusCode LArHVPathologyDbCondAlg::execute(const EventContext& ctx) const {
75 
77 
78  if (writeHandle.isValid()) {
79  ATH_MSG_DEBUG("Found valid write handle");
80  return StatusCode::SUCCESS;
81  }
82 
83  //Get Conditions input
85  const AthenaAttributeList *attrList = *fldrHdl;
86  if (!attrList) {
87  ATH_MSG_ERROR("Do not have AthenaAttributeList for pathology");
88  return StatusCode::FAILURE;
89  }
90  writeHandle.addDependency(fldrHdl);
91 
93  const CaloDetDescrManager* calodetdescrmgr = *caloMgrHandle;
94  writeHandle.addDependency(caloMgrHandle);
95 
96  try {
97  const unsigned blobVersion=(*attrList)["blobVersion"].data<unsigned int>();
98  const coral::Blob& blob = (*attrList)["Constants"].data<coral::Blob>();
99 
100  if (blobVersion!=0) {
101  ATH_MSG_ERROR ( "Can't interpret BLOB version " << blobVersion );
102  return StatusCode::FAILURE;
103  }
104 
105 
106  void* blob_data ATLAS_THREAD_SAFE = const_cast<void*> (blob.startingAddress());
107  TBufferFile buf(TBuffer::kRead, blob.size(), blob_data, false);
108  std::unique_ptr<LArHVPathologiesDb> hvpathdb
109  (static_cast<LArHVPathologiesDb*>(buf.ReadObjectAny(m_klass)));
110 
111  auto hvpath = std::make_unique<LArHVPathology>(hvpathdb.get());
112 
113  fillElectMap(calodetdescrmgr, hvpath.get(), writeHandle);
114 
115 
116  if(writeHandle.record(std::move(hvpath)).isFailure()) {
117  ATH_MSG_ERROR("Could not record LArHVPathology object with "
118  << writeHandle.key()
119  << " with EventRange " << writeHandle.getRange()
120  << " into Conditions Store");
121  return StatusCode::FAILURE;
122  }
123 
124  return StatusCode::SUCCESS;
125 
126  }catch (coral::AttributeListException &e) {
127  ATH_MSG_ERROR ( e.what() );
128  return StatusCode::FAILURE;
129  }
130  // should not come here, but syntactically
131  return StatusCode::SUCCESS;
132 }
133 
134 void
136  LArHVPathology* hvpath,
137  SG::WriteCondHandle<LArHVPathology>& writeHandle) const
138 {
140  const LArHVIdMapping* hvCabling = *cHdl;
141  if(!hvCabling) {
142  ATH_MSG_WARNING("Do not have HV mapping, will not fill LArHVPathology electIndMap !!!");
143  return;
144  }
145  writeHandle.addDependency (cHdl);
146 
147  std::lock_guard<std::mutex> lock(m_mut);
148 
149  std::map<std::pair<Identifier, unsigned int>, std::vector<unsigned short> > &elecMap = hvpath->getElecMap(); //shorthand
150 
151  std::vector<unsigned short> list;
152  std::vector<HWIdentifier> hwlineId;
153  unsigned int HVline = 0;
154  // loop over all EM Identifiers
155  for (auto id: m_larem_id->channel_ids()) {
156  hwlineId.clear();
157  m_hvmapTool->GetHVLines(id,calodetdescrmgr, hwlineId);
158  // LAr EMB
159  if (abs(m_larem_id->barrel_ec(id))==1 && m_larem_id->sampling(id) > 0) {
160  if (const EMBDetectorElement* embElement = dynamic_cast<const EMBDetectorElement*>(calodetdescrmgr->get_element(id))) {
161  const EMBCellConstLink cell = embElement->getEMBCell();
162  unsigned int nelec = cell->getNumElectrodes();
163  for(auto hwid:hwlineId) {
164  list.clear();
165  HVline = m_hvlineHelper->hv_line(hwid);
166  for (unsigned int i=0;i<nelec;i++) {
167  const EMBHVElectrode& electrode = cell->getElectrode(i);
168  for (unsigned int igap=0;igap<2;igap++) {
169  if ((unsigned)electrode.hvLineNo(igap,hvCabling)==HVline) {
170  list.push_back(2*i+igap);
171  }
172  }
173  }
174  }
175  elecMap.insert(std::make_pair(std::make_pair(id,HVline) ,list));
176  continue;
177  }
178  }
179  // LAr EMEC
180  if (abs(m_larem_id->barrel_ec(id))>1 && m_larem_id->sampling(id) > 0) {
181  if (const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(calodetdescrmgr->get_element(id))) {
182  const EMECCellConstLink cell = emecElement->getEMECCell();
183  unsigned int nelec = cell->getNumElectrodes();
184  for(auto hwid:hwlineId) {
185  list.clear();
186  HVline = m_hvlineHelper->hv_line(hwid);
187  for (unsigned int i=0;i<nelec;i++) {
188  const EMECHVElectrode& electrode = cell->getElectrode(i);
189  for (unsigned int igap=0;igap<2;igap++) {
190  if ((unsigned)electrode.hvLineNo(igap,hvCabling)==HVline) {
191  list.push_back(2*i+igap);
192  }
193  }
194  }
195  }
196  elecMap.insert(std::make_pair(std::make_pair(id,HVline),list));
197  continue;
198  }
199  }
200  // EMBPS
201  if (abs(m_larem_id->barrel_ec(id))==1 && m_larem_id->sampling(id)==0) {
202  if (const EMBDetectorElement* embElement = dynamic_cast<const EMBDetectorElement*>(calodetdescrmgr->get_element(id))) {
203  const EMBCellConstLink cell = embElement->getEMBCell();
204  const EMBPresamplerHVModule& hvmodule = cell->getPresamplerHVModule ();
205  for(auto hwid:hwlineId) {
206  list.clear();
207  HVline = m_hvlineHelper->hv_line(hwid);
208  for (unsigned int igap=0;igap<2;igap++) {
209  if ((unsigned)hvmodule.hvLineNo(igap,hvCabling)==HVline) {
210  list.push_back(igap);
211  }
212  }
213  elecMap.insert(std::make_pair(std::make_pair(id,HVline),list));
214  continue;
215  }
216  }
217  }
218  // EMECPS
219  if (abs(m_larem_id->barrel_ec(id))>1 && m_larem_id->sampling(id)==0) {
220  if (const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(calodetdescrmgr->get_element(id))) {
221  const EMECCellConstLink cell = emecElement->getEMECCell();
222  const EMECPresamplerHVModule& hvmodule = cell->getPresamplerHVModule ();
223  for(auto hwid:hwlineId) {
224  list.clear();
225  HVline = m_hvlineHelper->hv_line(hwid);
226  for (unsigned int igap=0;igap<2;igap++) {
227  if ((unsigned)hvmodule.hvLineNo(igap,hvCabling)==HVline) {
228  list.push_back(igap);
229  }
230  }
231  elecMap.insert(std::make_pair(std::make_pair(id,HVline),list));
232  continue;
233  }
234  }
235  }
236  }
237  // loop over all HEC Identifiers
238  for (auto const& id: m_larhec_id->channel_ids()) {
239  hwlineId.clear();
240  m_hvmapTool->GetHVLines(id,calodetdescrmgr,hwlineId);
241  if (const HECDetectorElement* hecElement = dynamic_cast<const HECDetectorElement*>(calodetdescrmgr->get_element(id))) {
242  const HECCellConstLink cell = hecElement->getHECCell();
243  unsigned int nsubgaps = cell->getNumSubgaps();
244  for(auto hwid:hwlineId) {
245  list.clear();
246  HVline = m_hvlineHelper->hv_line(hwid);
247  for (unsigned int i=0;i<nsubgaps;i++) {
248  const HECHVSubgap& subgap = cell->getSubgap(i);
249  if ((unsigned)subgap.hvLineNo(hvCabling)==HVline) {
250  list.push_back(i);
251  }
252  }
253  elecMap.insert(std::make_pair(std::make_pair(id,HVline),list));
254  continue;
255  }
256  }
257  }
258  // loop over all FCAL Identifiers
259  for (auto const& id: m_larfcal_id->channel_ids()) {
260  hwlineId.clear();
261  m_hvmapTool->GetHVLines(id,calodetdescrmgr, hwlineId);
262  if (const FCALDetectorElement* fcalElement = dynamic_cast<const FCALDetectorElement*>(calodetdescrmgr->get_element(id))) {
263  const FCALTile* tile = fcalElement->getFCALTile();
264  unsigned int nlines = tile->getNumHVLines();
265  for(auto hwid:hwlineId) {
266  list.clear();
267  HVline = m_hvlineHelper->hv_line(hwid);
268  for (unsigned int i=0;i<nlines;i++) {
269  const FCALHVLine* line2 = tile->getHVLine(i);
270  if (line2) {
271  if ((unsigned)line2->hvLineNo(hvCabling)==HVline) {
272  list.push_back(i);
273  }
274  }
275  }
276  elecMap.insert(std::make_pair(std::make_pair(id,HVline),list));
277  continue;
278  }
279  }
280  }
281 
282  return;
283 
284 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
LArHVPathologyDbCondAlg::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: LArHVPathologyDbCondAlg.h:48
LArHVPathologyDbCondAlg::initialize
virtual StatusCode initialize() override
Definition: LArHVPathologyDbCondAlg.cxx:37
EMBHVElectrode
Definition: EMBHVElectrode.h:15
LArHVPathologyDbCondAlg::m_hvmapTool
ToolHandle< ILArHVMapTool > m_hvmapTool
Definition: LArHVPathologyDbCondAlg.h:52
LArEM_ID.h
LArHVPathologyDbCondAlg::m_larfcal_id
const LArFCAL_ID * m_larfcal_id
Definition: LArHVPathologyDbCondAlg.h:56
EMECDetectorElement
LAr EMEC Detector Element.
Definition: CaloDetectorElements.h:116
LArHVPathology.h
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LArHVPathologyDbCondAlg::LArHVPathologyDbCondAlg
LArHVPathologyDbCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArHVPathologyDbCondAlg.cxx:30
CaloCell_ID::em_idHelper
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition: CaloCell_ID.h:63
LArHVPathologyDbCondAlg::m_klass
TClass * m_klass
Definition: LArHVPathologyDbCondAlg.h:62
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
LArHVLineID::hv_line
int hv_line(const HWIdentifier id) const
Return the HV line number from an HighVoltage line identifier.
Definition: LArHVLineID.h:286
LArHVPathology::getElecMap
std::map< std::pair< Identifier, unsigned int >, std::vector< unsigned short > > & getElecMap()
Definition: LArHVPathology.h:26
LArHVPathologyDbCondAlg::fillElectMap
void fillElectMap(const CaloDetDescrManager *calodetdescrmgr, LArHVPathology *hvpath, SG::WriteCondHandle< LArHVPathology > &writeHandle) const
Definition: LArHVPathologyDbCondAlg.cxx:135
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
LArEM_Base_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
LArHEC_ID.h
LArHVLineID.h
EMBDetectorElement
LAr EMB Detector Element.
Definition: CaloDetectorElements.h:52
AthenaAttributeList.h
LArHVPathologyDbCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: LArHVPathologyDbCondAlg.cxx:74
EMECPresamplerHVModule.h
CaloCell_ID.h
CaloCell_ID::hec_idHelper
const LArHEC_ID * hec_idHelper() const
access to HEC idHelper
Definition: CaloCell_ID.h:69
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
HECDetectorElement
LAr HEC Detector Element.
Definition: CaloDetectorElements.h:189
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
ReadCellNoiseFromCool.tile
tile
Definition: ReadCellNoiseFromCool.py:92
FCALTile
A tile of the forward calorimeter readout geometry.
Definition: FCALTile.h:27
EMBCell.h
LArHVPathologyDbCondAlg::m_larem_id
const LArEM_ID * m_larem_id
Definition: LArHVPathologyDbCondAlg.h:54
LArHVPathologiesDb.h
FCALHVLine
Definition: FCALHVLine.h:15
EMBHVElectrode::hvLineNo
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
Definition: EMBHVElectrode.cxx:43
LArFCAL_Base_ID::channel_ids
const std::vector< Identifier > & channel_ids() const
provide acces to channel id vector, accessed via hash
LArHVPathologyDbCondAlg::m_pathologyFolderKey
SG::ReadCondHandleKey< AthenaAttributeList > m_pathologyFolderKey
Definition: LArHVPathologyDbCondAlg.h:46
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
FCALDetectorElement
LAr FCAL Detector Element.
Definition: CaloDetectorElements.h:261
HECHVSubgap::hvLineNo
int hvLineNo(const LArHVIdMapping *hvIdMapping) const
Definition: HECHVSubgap.cxx:45
LArHVPathologyDbCondAlg::m_hvlineHelper
const LArHVLineID * m_hvlineHelper
Definition: LArHVPathologyDbCondAlg.h:58
EMBPresamplerHVModule::hvLineNo
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
Definition: EMBPresamplerHVModule.cxx:91
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
LArHVPathologyDbCondAlg::finalize
virtual StatusCode finalize() override
Definition: LArHVPathologyDbCondAlg.cxx:68
LArHVPathologyDbCondAlg::m_mut
std::mutex m_mut
Definition: LArHVPathologyDbCondAlg.h:60
WriteCalibToCool.blobVersion
blobVersion
Definition: WriteCalibToCool.py:82
EMBPresamplerHVModule.h
EMECPresamplerHVModule::hvLineNo
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
Definition: EMECPresamplerHVModule.cxx:74
LArHVPathologiesDb
Definition: LArHVPathologiesDb.h:19
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
LArEM_Base_ID::barrel_ec
int barrel_ec(const Identifier id) const
return barrel_ec according to :
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArHVPathologyDbCondAlg::~LArHVPathologyDbCondAlg
virtual ~LArHVPathologyDbCondAlg()
Definition: LArHVPathologyDbCondAlg.cxx:34
LArFCAL_ID.h
LArHVIdMapping
Definition: LArHVIdMapping.h:21
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
EMECPresamplerHVModule
Describes one HV Module within the EMEc Presampler.
Definition: EMECPresamplerHVModule.h:22
LArHVPathology
Definition: LArHVPathology.h:15
LArG4FSStartPointFilterLegacy.line2
line2
Definition: LArG4FSStartPointFilterLegacy.py:59
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
LArHVPathologyDbCondAlg::m_laronline_id
const LArOnlineID * m_laronline_id
Definition: LArHVPathologyDbCondAlg.h:57
EMECHVElectrode
Definition: EMECHVElectrode.h:15
LArEM_Base_ID::channel_ids
const std::vector< Identifier > & channel_ids() const
provide access to channel id vector, accessed via hash
LArHEC_Base_ID::channel_ids
const std::vector< Identifier > & channel_ids() const
provide access to channel id vector, accessed via hash
checker_macros.h
Define macros for attributes used to control the static checker.
LArHVPathologyDbCondAlg::m_hvPathologyKey
SG::WriteCondHandleKey< LArHVPathology > m_hvPathologyKey
Definition: LArHVPathologyDbCondAlg.h:50
LArHVPathologyDbCondAlg::m_larhec_id
const LArHEC_ID * m_larhec_id
Definition: LArHVPathologyDbCondAlg.h:55
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
HECHVSubgap
Definition: HECHVSubgap.h:15
EMECHVElectrode::hvLineNo
int hvLineNo(int iGap, const LArHVIdMapping *hvIdMapping) const
Definition: EMECHVElectrode.cxx:49
EMBPresamplerHVModule
Describes one HV Module within the EMB Presampler.
Definition: EMBPresamplerHVModule.h:22
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
CaloCell_ID::fcal_idHelper
const LArFCAL_ID * fcal_idHelper() const
access to FCAL idHelper
Definition: CaloCell_ID.h:75
CaloDetectorElements.h
Calo Subsystem specific Detector Elements + Dummy element for testing.
LArHVPathologyDbCondAlg.h
LArOnlineID.h
LArHVPathologyDbCondAlg::m_hvMappingKey
SG::ReadCondHandleKey< LArHVIdMapping > m_hvMappingKey
Definition: LArHVPathologyDbCondAlg.h:47
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:279