ATLAS Offline Software
LArHVlineMapAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "LArHVlineMapAlg.h"
9 
10 LArHVlineMapAlg::LArHVlineMapAlg(const std::string& name, ISvcLocator* pSvcLocator) :
11  AthReentrantAlgorithm(name,pSvcLocator),
12  m_hvmapTool("LArHVMapTool",this)
13 {}
14 
15 // intialize
17 {
21  ATH_CHECK(detStore()->retrieve(m_caloHelper, "CaloCell_ID") );
22  ATH_CHECK(detStore()->retrieve(m_hvlineHelper, "LArHVLineID") );
23 
24  const CaloIdManager *caloIdMgr;
25  ATH_CHECK(detStore()->retrieve(caloIdMgr));
26 
27  return StatusCode::SUCCESS;
28 }
29 
30 StatusCode LArHVlineMapAlg::execute(const EventContext& ctx ) const
31 {
33 
34  if (writeHandle.isValid()) {
35  ATH_MSG_DEBUG("Found valid write handle");
36  return StatusCode::SUCCESS;
37  }
38 
40  const CaloDetDescrManager *calodetdescrmgr = *caloMgrHandle;
41  if(!calodetdescrmgr) {
42  ATH_MSG_ERROR("Why do not have CaloDetDescrManager ? "<<m_caloDetDescrMgrKey.fullKey());
43  return StatusCode::FAILURE;
44  }
45 
47  if(!hvCabling.isValid()) {
48  ATH_MSG_ERROR("Could not get HV mapping !");
49  return StatusCode::FAILURE;
50  } else {
51  ATH_MSG_DEBUG("Got HV mapping !");
52  }
53 
54  writeHandle.addDependency(hvCabling);
55 
56  unsigned hmax=m_hvlineHelper->hvlineHashMax();
57 
58  std::unique_ptr<LArHVNMap> hvmap=std::make_unique<LArHVNMap>(hmax,m_hvlineHelper);
59 
62 
63  for(; itb<ite; ++itb) {
64 
65  if(m_caloHelper->is_tile(*itb)) continue;
66  std::vector<HWIdentifier> linevec;
67  m_hvmapTool->GetHVLines(*itb, calodetdescrmgr, linevec);
68  if(linevec.size()) {
69  for(unsigned int i=0; i<linevec.size(); ++i) {
70  unsigned lhash = m_hvlineHelper->hvlineHash(linevec[i]);
71  hvmap->incHVline(lhash);
72  ATH_MSG_VERBOSE("Adding cell: "<<itb->get_identifier32().get_compact() << " to a line: "<<linevec[i].get_identifier32().get_compact());
73  }
74  } else {
75  ATH_MSG_WARNING("Why do not have HVlines for the cell: " << itb->get_identifier32().get_compact());
76  }
77  }
78 
79  if(writeHandle.record(std::move(hvmap)).isFailure()) {
80  ATH_MSG_ERROR("Could not record LArHVNMap object with " << writeHandle.key());
81  return StatusCode::FAILURE;
82  }
83 
84  ATH_MSG_INFO("recorded new " << writeHandle.key());
85 
86  return StatusCode::SUCCESS;
87 
88 }
89 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArHVlineMapAlg::m_mapKey
SG::WriteCondHandleKey< LArHVNMap > m_mapKey
Definition: LArHVlineMapAlg.h:39
LArHVlineMapAlg::m_hvmapTool
ToolHandle< ILArHVMapTool > m_hvmapTool
Definition: LArHVlineMapAlg.h:35
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArHVlineMapAlg::m_hvCablingKey
SG::ReadCondHandleKey< LArHVIdMapping > m_hvCablingKey
Definition: LArHVlineMapAlg.h:38
LArHVNMap::incHVline
void incHVline(unsigned hvHash)
Definition: LArHVNMap.h:51
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:210
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
CaloCell_Base_ID::id_iterator
std::vector< Identifier >::const_iterator id_iterator
Type for iterators over identifiers.
Definition: CaloCell_Base_ID.h:176
CaloCell_ID.h
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
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
CaloCell_Base_ID::cell_begin
id_iterator cell_begin() const
begin iterator over full set of Identifiers (LAr + Tiles)
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloIdManager
This class initializes the Calo (LAr and Tile) offline identifiers.
Definition: CaloIdManager.h:45
LArHVlineMapAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: LArHVlineMapAlg.cxx:30
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArHVlineMapAlg::initialize
virtual StatusCode initialize() override final
Definition: LArHVlineMapAlg.cxx:16
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_Base_ID::cell_end
id_iterator cell_end() const
end iterator over full set of Identifiers (LAr + Tiles)
LArHVlineMapAlg::m_caloHelper
const CaloCell_ID * m_caloHelper
Definition: LArHVlineMapAlg.h:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
LArHVlineMapAlg.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArHVlineMapAlg::LArHVlineMapAlg
LArHVlineMapAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArHVlineMapAlg.cxx:10
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
LArHVlineMapAlg::m_hvlineHelper
const LArHVLineID * m_hvlineHelper
Definition: LArHVlineMapAlg.h:42
hmax
double hmax(TH1 *&h)
Definition: listroot.cxx:115
CaloIdManager.h
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
LArHVLineID::hvlineHashMax
size_type hvlineHashMax() const
Define hash tables max size.
Definition: LArHVLineID.h:247
LArHVlineMapAlg::m_caloDetDescrMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
Definition: LArHVlineMapAlg.h:37
LArOnlineID.h
LArHVLineID::hvlineHash
IdentifierHash hvlineHash(HWIdentifier hvline_id) const
Create an HighVoltage line hash identifiers from identifiers.
Definition: LArHVLineID.h:237