ATLAS Offline Software
Loading...
Searching...
No Matches
LArHVMapTool.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 "LArHVMapTool.h"
11
13#include "LArHV/EMBHVManager.h"
18#include "LArHV/HECHVSubgap.h"
19#include "LArHV/FCALHVLine.h"
20#include "LArHV/FCALHVManager.h"
21
22LArHVMapTool::LArHVMapTool(const std::string& type, const std::string& name, const IInterface* parent)
23 : AthAlgTool(type,name,parent)
24{
25}
26
28
29 CHECK(detStore()->retrieve(m_caloIdMgr));
30
31 m_larem_id = m_caloIdMgr->getEM_ID();
32 m_larhec_id = m_caloIdMgr->getHEC_ID();
33 m_larfcal_id = m_caloIdMgr->getFCAL_ID();
34
35 ATH_CHECK(m_caloDetDescrMgrKey.initialize());
36 ATH_CHECK( m_hvCablingKey.initialize() );
37
38 ATH_MSG_DEBUG("LArHVMapTool::initialize ...");
39
40 const EventContext& ctx = Gaudi::Hive::currentContext();
41
43 const CaloDetDescrManager *calodetdescrmgr = *caloMgrHandle;
45 m_hvmapping=*hvCabling;
46 if(!m_hvmapping) {
47 ATH_MSG_ERROR("Could not get HV mapping !");
48 return StatusCode::FAILURE;
49 } else {
50 ATH_MSG_DEBUG("Got HV mapping !");
51 }
52
54 Identifier offId;
55 m_larem_id->get_id(h,offId);
56 std::vector<int> hvlineVec;
57 GetHVLines(offId, calodetdescrmgr, hvlineVec);
58
59 return StatusCode::SUCCESS;
60}
61
62void LArHVMapTool::GetHVLines(const Identifier& id, const CaloDetDescrManager *calodetdescrmgr,
63 std::vector<int> &hvLineVec) const {
64 return GetHVLinesCore(id, calodetdescrmgr, &hvLineVec, nullptr);
65}
66
67void LArHVMapTool::GetHVLines(const Identifier& id, const CaloDetDescrManager *calodetdescrmgr,
68 std::vector<HWIdentifier> &hvLineId) const {
69 return GetHVLinesCore(id, calodetdescrmgr, nullptr, &hvLineId);
70}
71
72void LArHVMapTool::GetHVLinesCore(const Identifier& id, const CaloDetDescrManager *calodetdescrmgr,
73 std::vector<int> *hvLineVec, std::vector<HWIdentifier> *hvLineId) const {
74 std::set<int> hv;
75 std::set<HWIdentifier> hvId;
76 if(hvLineVec) hvLineVec->clear();
77 if(hvLineId) hvLineId->clear();
78
79 // LAr EMB
80 if (m_larem_id->is_lar_em(id) && m_larem_id->sampling(id)>0) {
81 if (abs(m_larem_id->barrel_ec(id))==1) {
82 const EMBDetectorElement* embElement = dynamic_cast<const EMBDetectorElement*>(calodetdescrmgr->get_element(id));
83 if (embElement) {
84 const EMBCellConstLink &cell = embElement->getEMBCell();
85 unsigned int nelec = cell->getNumElectrodes();
86 for (unsigned int i=0;i<nelec;i++) {
87 const EMBHVElectrode &electrode = cell->getElectrode(i);
88 for (unsigned int igap=0;igap<2;igap++) {
89 HWIdentifier hvline;
90 hv.insert(electrode.getModule().getManager().hvLineNo(electrode,igap, m_hvmapping, &hvline));
91 hvId.insert(hvline);
92 }
93 }
94 } else {
95 ATH_MSG_ERROR( "Failed d'cast to EMBDetectorElement" );
96 }
97 } else { // LAr EMEC
98 const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(calodetdescrmgr->get_element(id));
99 if (emecElement) {
100 const EMECCellConstLink cell = emecElement->getEMECCell();
101 unsigned int nelec = cell->getNumElectrodes();
102 for (unsigned int i=0;i<nelec;i++) {
103 const EMECHVElectrode &electrode = cell->getElectrode(i);
104 for (unsigned int igap=0;igap<2;igap++) {
105 HWIdentifier hvline;
106 hv.insert(electrode.getModule().getManager().hvLineNo( electrode, igap, m_hvmapping, &hvline));
107 hvId.insert(hvline);
108 }
109 }
110 } else {
111 ATH_MSG_ERROR( "Failed d'cast to EMECDetectorElement" );
112 }
113 }
114 } else if (m_larhec_id->is_lar_hec(id)) { // LAr HEC
115 const HECDetectorElement* hecElement = dynamic_cast<const HECDetectorElement*>(calodetdescrmgr->get_element(id));
116 if (hecElement) {
117 const HECCellConstLink cell = hecElement->getHECCell();
118 unsigned int nsubgaps = cell->getNumSubgaps();
119 for (unsigned int igap=0;igap<nsubgaps;igap++) {
120 const HECHVSubgap &subgap = cell->getSubgap(igap);
121 HWIdentifier hvline;
122 hv.insert(subgap.getModule().getManager().hvLineNo(subgap,m_hvmapping,&hvline));
123 hvId.insert(hvline);
124 }
125 } else {
126 ATH_MSG_ERROR( "Failed d'cast to HECDetectorElement" );
127 }
128 } else if (m_larfcal_id->is_lar_fcal(id)) { // LAr FCAL
129 const FCALDetectorElement* fcalElement = dynamic_cast<const FCALDetectorElement*>(calodetdescrmgr->get_element(id));
130 if (fcalElement) {
131 const FCALTile* tile = fcalElement->getFCALTile();
132 unsigned int nlines = tile->getNumHVLines();
133 unsigned int nlines_found=0;
134 for (unsigned int i=0;i<nlines;i++) {
135 const FCALHVLine *line = tile->getHVLine(i);
136 if (line) nlines_found++;
137 }
138 if ( nlines_found>0 ) {
139 for (unsigned int i=0;i<nlines;i++) {
140 const FCALHVLine *line = tile->getHVLine(i);
141 if (!line) continue;
142 HWIdentifier hvline;
143 hv.insert(line->getModule().getManager().hvLineNo(*line,m_hvmapping,&hvline));
144 hvId.insert(hvline);
145 }
146 }
147 } else {
148 ATH_MSG_ERROR( "Failed d'cast to FCALDetectorElement" );
149 }
150
151 } else if (m_larem_id->is_lar_em(id) && m_larem_id->sampling(id)==0) { // Presamplers
152 if (abs(m_larem_id->barrel_ec(id))==1) {
153 const EMBDetectorElement* embElement = dynamic_cast<const EMBDetectorElement*>(calodetdescrmgr->get_element(id));
154 if (embElement) {
155 const EMBCellConstLink cell = embElement->getEMBCell();
156 const EMBPresamplerHVModule &hvmodule = cell->getPresamplerHVModule();
157 for (unsigned int igap=0;igap<2;igap++) {
158 HWIdentifier hvline;
159 hv.insert(hvmodule.getManager().hvLineNo(hvmodule,igap,m_hvmapping,&hvline));
160 hvId.insert(hvline);
161 }
162 } else {
163 ATH_MSG_ERROR( "Failed d'cast to EMBDetectorElement (for presampler)" );
164 }
165 } else {
166 const EMECDetectorElement* emecElement = dynamic_cast<const EMECDetectorElement*>(calodetdescrmgr->get_element(id));
167 if (emecElement) {
168 const EMECCellConstLink cell = emecElement->getEMECCell();
169 const EMECPresamplerHVModule &hvmodule = cell->getPresamplerHVModule ();
170 HWIdentifier hvline;
171 hv.insert(hvmodule.getManager().hvLineNo(hvmodule, m_hvmapping, &hvline));
172 hvId.insert(hvline);
173 } else {
174 ATH_MSG_ERROR( "Failed d'cast to EMECDetectorElement (for presampler)" );
175 }
176 }
177 }
178
179 ATH_MSG_VERBOSE("Found "<<hvId.size()<<" hvIds for id: "<<id.get_identifier32().get_compact());
180
181 if(hvLineVec) {
182 for (std::set<int>::iterator i=hv.begin();i!=hv.end();++i) hvLineVec->push_back(*i);
183 }
184 if(hvLineId) {
185 for (std::set<HWIdentifier>::iterator i=hvId.begin();i!=hvId.end();++i) hvLineId->push_back(*i);
186 }
187 return;
188}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Calo Subsystem specific Detector Elements + Dummy element for testing.
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
Header file for AthHistogramAlgorithm.
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.
EMBCellConstLink getEMBCell() const
EMB Cell description from LArReadoutGeometry.
const EMBHVModule & getModule() const
int hvLineNo(const EMBHVElectrode &electrode, int gap, const LArHVIdMapping *hvIdMapping, HWIdentifier *hvlId=nullptr) const
const EMBHVManager & getManager() const
int hvLineNo(const EMBPresamplerHVModule &module, int gap, const LArHVIdMapping *hvIdMapping, HWIdentifier *hvlId=nullptr) const
Describes one HV Module within the EMB Presampler.
const EMBPresamplerHVManager & getManager() const
LAr EMEC Detector Element.
EMECCellConstLink getEMECCell() const
EMEC Cell description from LArReadoutGeometry.
const EMECHVModule & getModule() const
int hvLineNo(const EMECHVElectrode &electrode, int gap, const LArHVIdMapping *hvIdMapping, HWIdentifier *hvlId=nullptr) const
const EMECHVManager & getManager() const
int hvLineNo(const EMECPresamplerHVModule &module, const LArHVIdMapping *hvIdMapping, HWIdentifier *hvlineId=nullptr) const
Describes one HV Module within the EMEc Presampler.
const EMECPresamplerHVManager & getManager() const
LAr FCAL Detector Element.
const FCALTile * getFCALTile() const
FCAL Tile description from LArReadoutGeometry.
A tile of the forward calorimeter readout geometry.
Definition FCALTile.h:27
LAr HEC Detector Element.
HECCellConstLink getHECCell() const
HEC Cell description from LArReadoutGeometry.
int hvLineNo(const HECHVSubgap &subgap, const LArHVIdMapping *hvIdMapping, HWIdentifier *hvlId=nullptr) const
const HECHVManager & getManager() const
const HECHVModule & getModule() const
This is a "hash" representation of an Identifier.
SG::ReadCondHandleKey< LArHVIdMapping > m_hvCablingKey
const LArEM_ID * m_larem_id
void GetHVLinesCore(const Identifier &id, const CaloDetDescrManager *cddm, std::vector< int > *hvLineVec, std::vector< HWIdentifier > *hvLineId) const
virtual void GetHVLines(const Identifier &id, const CaloDetDescrManager *cddm, std::vector< int > &hvLineVec) const override final
const LArFCAL_ID * m_larfcal_id
const LArHVIdMapping * m_hvmapping
const CaloIdManager * m_caloIdMgr
LArHVMapTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
const LArHEC_ID * m_larhec_id