ATLAS Offline Software
Loading...
Searching...
No Matches
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
10LArHVlineMapAlg::LArHVlineMapAlg(const std::string& name, ISvcLocator* pSvcLocator) :
11 AthReentrantAlgorithm(name,pSvcLocator),
12 m_hvmapTool("LArHVMapTool",this)
13{}
14
15// intialize
17{
18 ATH_CHECK(m_mapKey.initialize());
19 ATH_CHECK(m_hvCablingKey.initialize());
20 ATH_CHECK(m_caloDetDescrMgrKey.initialize());
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
30StatusCode 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
60 CaloCell_Base_ID ::id_iterator itb = m_caloHelper->cell_begin();
61 CaloCell_Base_ID ::id_iterator ite = m_caloHelper->cell_end();
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
This class provides the client interface for accessing the detector description information common to...
This class initializes the Calo (LAr and Tile) offline identifiers.
LArHVlineMapAlg(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< ILArHVMapTool > m_hvmapTool
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
SG::WriteCondHandleKey< LArHVNMap > m_mapKey
SG::ReadCondHandleKey< LArHVIdMapping > m_hvCablingKey
const CaloCell_ID * m_caloHelper
const LArHVLineID * m_hvlineHelper
virtual StatusCode initialize() override final
virtual StatusCode execute(const EventContext &ctx) const override final
const std::string & key() const
void addDependency(const EventIDRange &range)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
double hmax(TH1 *&h)
Definition listroot.cxx:115