ATLAS Offline Software
Loading...
Searching...
No Matches
EMBPresamplerHVManager.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "GeoModelKernel/CellBinning.h"
8#include "GeoModelKernel/CellPartitioning.h"
9#include <cmath>
10#include <vector>
11#include <fstream>
13
15#include "GaudiKernel/ISvcLocator.h"
16#include "GaudiKernel/IToolSvc.h"
17#include "GaudiKernel/Bootstrap.h"
18#include "GaudiKernel/ServiceHandle.h"
19
22
25
26#ifndef SIMULATIONBASE
27#ifndef GENERATIONBASE
29#endif
30#endif
31
33
34#include <atomic>
35
36
38public:
39 explicit Clockwork(const EMBPresamplerHVManager* manager) {
40 CellPartitioning etaPartitioning;
41 for (unsigned int i= 0; i<4; i++) etaPartitioning.addValue(i*0.4);
42 etaPartitioning.addValue(1.525);
43 descriptor = std::make_unique<EMBPresamplerHVDescriptor>(etaPartitioning,CellBinning(0.0, 2*M_PI, 32));
44
45 for(int iSide=0; iSide<2; ++iSide) {
46 for(int iEta=0; iEta<4; ++iEta) {
47 for(int iPhi=0; iPhi<32; ++iPhi) {
48 moduleArray[iSide][iEta][iPhi] = std::make_unique<EMBPresamplerHVModule>(manager, iSide, iEta,iPhi);
49 }
50 }
51 }
52
53 ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager");
54 if (StatusCode::SUCCESS!=detStore->retrieve(elecId, "LArElectrodeID")) {
55 throw std::runtime_error("EMBPresamplerHVManager failed to retrieve LArElectrodeID");
56 }
57
58 if (StatusCode::SUCCESS!=detStore->retrieve(hvId,"LArHVLineID")) {
59 throw std::runtime_error("EMBPresamplerHVManager failed to retrieve LArHVLineID");
60 }
61 }
62 ~Clockwork() = default;
63 std::unique_ptr<EMBPresamplerHVDescriptor> descriptor;
64 std::unique_ptr<const EMBPresamplerHVModule> moduleArray[2][4][32];
65 const LArElectrodeID* elecId = nullptr;
66 const LArHVLineID* hvId = nullptr;
67};
68
69
71{
72public:
73 std::vector<EMBPresamplerHVPayload> m_payloadArray;
74};
75
76
78
79
81 (std::unique_ptr<Payload> payload)
82 : m_payload (std::move (payload))
83{
84}
85
86
89 if (this != &other) {
90 m_payload = std::move (other.m_payload);
91 }
92 return *this;
93}
94
95
97= default;
98
99
101 (const EMBPresamplerHVModule& module, const int& iGap) const
102{
103 return voltage (module, iGap) > INVALID;
104}
105
106
108 (const EMBPresamplerHVModule& module, const int& iGap) const
109{
110 return m_payload->m_payloadArray[index(module)].voltage[iGap];
111}
112
113
115 (const EMBPresamplerHVModule& module, const int& iGap) const
116{
117 return m_payload->m_payloadArray[index(module)].current[iGap];
118}
119
120
122 (const EMBPresamplerHVModule& module, const int& iGap) const
123{
124 return m_payload->m_payloadArray[index(module)].hvLineNo[iGap];
125}
126
127
129 (const EMBPresamplerHVModule& module)
130{
131 unsigned int sideIndex = module.getSideIndex();
132 unsigned int phiIndex = module.getPhiIndex();
133 unsigned int etaIndex = module.getEtaIndex();
134 unsigned int index = 128*sideIndex+32*etaIndex+phiIndex;
135 return index;
136}
137
138
140 : m_c (std::make_unique<Clockwork> (this))
141{
142}
143
145= default;
146
148{
149 return m_c->descriptor.get();
150}
151
153{
154 return m_c->descriptor->getPhiBinning().getFirstDivisionNumber();
155}
156
158{
159 return m_c->descriptor->getPhiBinning().getFirstDivisionNumber() + m_c->descriptor->getPhiBinning().getNumDivisions();
160}
161
163{
164 return m_c->descriptor->getEtaPartitioning().getFirstDivisionNumber();
165}
166
168{
169 return m_c->descriptor->getEtaPartitioning().getFirstDivisionNumber() + m_c->descriptor->getEtaPartitioning().getNumDivisions();
170}
171
172const EMBPresamplerHVModule& EMBPresamplerHVManager::getHVModule(unsigned int iSide, unsigned int iEta,unsigned int iPhi) const
173{
174 return *(m_c->moduleArray[iSide][iEta][iPhi]);
175}
176
178{
179 return 0;
180}
181
183{
184 return 2;
185}
186
187
190 const std::vector<const CondAttrListCollection*>& attrLists) const
191{
192 auto payload = std::make_unique<EMBPresamplerHVData::Payload>();
193 payload->m_payloadArray.reserve(2*4*32);
194
195 for (int i=0;i<256;i++) {
196 payload->m_payloadArray[i].voltage[0] = EMBPresamplerHVData::INVALID;
197 payload->m_payloadArray[i].voltage[1] = EMBPresamplerHVData::INVALID;
198 }
199
200 for (const CondAttrListCollection* atrlistcol : attrLists) {
201
202 for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) {
203
204 // Construct HWIdentifier
205 // 1. decode COOL Channel ID
206 unsigned int chanID = (*citr).first;
207 int cannode = chanID/1000;
208 int line = chanID%1000;
209
210 // 2. Construct the identifier
211 HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line);
212
213 const std::vector<HWIdentifier>& electrodeIdVec = idfunc(id);
214
215
216 for(size_t i=0;i<electrodeIdVec.size();i++)
217 {
218 HWIdentifier elecHWID = electrodeIdVec[i];
219 int detector = m_c->elecId->detector(elecHWID);
220 if (detector==1) {
221
222// side in standard offline 0 for z<0 (C) 1 for z>0 (A)
223// in electrode numbering, this is the opposite (0 for A and 1 for C)
224 unsigned int sideIndex=1-m_c->elecId->zside(elecHWID);
225// eta index, no trouble
226 unsigned int etaIndex=m_c->elecId->hv_eta(elecHWID)-1;
227// phi index
228// offline 0 to 2pi in 2pi/32 bins (2 presampler cells per phi_HV)
229// module from elecID : 0 to 31
230// phi 0 pi 2pi
231// M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12 M13 M14 M15 M0
232// FT 0 -1 0 -1 0 -1
233// Module 0 1 2 3 4 5 6 7 9 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 39 30 31
234// offline phi 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
235 unsigned int phiIndex;
236 if (sideIndex==1) {
237 phiIndex=m_c->elecId->module(elecHWID);
238 }
239// module numbering on the C side 0 around phi=pi, running backwards
240// phi 0 pi 2pi
241// P8 P7 P6 P5 P4 P3 P2 P1 P0 P15 P14 P13 P12 P11 P10 P9 P8
242// FT -1 0 0 -1 0 -1 0
243// Module 15 14 9 8 7 6 5 4 3 2 1 0 31 30 29 38 27 26 25 24 23 22 21 20 19 18 17 16
244// offline phi 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
245 else {
246 int imodule=m_c->elecId->module(elecHWID);
247 if (imodule<16) phiIndex = 15 - imodule;
248 else phiIndex = 47 - imodule;
249 }
250
251 unsigned int index = 128*sideIndex+32*etaIndex+phiIndex;
252
253 unsigned int gapIndex=m_c->elecId->gap(elecHWID);
254 if (sideIndex==0) gapIndex=1-gapIndex;
255
256
257 float voltage = EMBPresamplerHVData::INVALID;
258 if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>();
259 float current = 0.;
260 if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>();
261
262 payload->m_payloadArray[index].voltage[gapIndex]=voltage;
263 payload->m_payloadArray[index].current[gapIndex]=current;
264 payload->m_payloadArray[index].hvLineNo[gapIndex]=chanID;
265 }
266 }
267 }
268 }
269
270 return {std::move (payload)};
271}
272
273#ifndef SIMULATIONBASE
274#ifndef GENERATIONBASE
277 const std::vector<const CondAttrListCollection*>& attrLists) const
278{
279 auto idfunc = [&] (HWIdentifier id) -> const std::vector<HWIdentifier>
280 { return hvIdMapping.getLArElectrodeIDvec(id); };
281 return getData (idfunc, attrLists);
282}
283
284
286 , int gap
287 , const LArHVIdMapping* hvIdMapping
288 , HWIdentifier *hvlId ) const {
289
290 int sideIndex = module.getSideIndex();
291 int phiIndex = module.getPhiIndex();
292 int etaIndex = module.getEtaIndex();
293
294 // ________________________ Construct ElectrodeID ________________________________
295 int id_detector = 1;
296 int id_zside = 1 - sideIndex;
297 int id_module{0};
298 if(sideIndex==1){
299 id_module = phiIndex;
300 }
301 else {
302 if(phiIndex<16) {
303 id_module = 15 - phiIndex;
304 }
305 else {
306 id_module = 47 - phiIndex;
307 }
308 }
309 int id_hv_phi{0};
310 int id_hv_eta = etaIndex + 1;
311 int id_gap = sideIndex==0 ? 1-gap : gap;
312 int id_electrode{0};
313
314 HWIdentifier elecHWID = m_c->elecId->ElectrodeId(id_detector
315 ,id_zside
316 ,id_module
317 ,id_hv_phi
318 ,id_hv_eta
319 ,id_gap
320 ,id_electrode);
321 // ________________________ ________________________________
322
323 // Get LArHVLineID corresponding to a given LArElectrodeId
324 HWIdentifier id = hvIdMapping->getLArHVLineID(elecHWID);
325
326 if(hvlId) *hvlId = id;
327
328 // Extract HV Line No
329 return m_c->hvId->can_node(id)*1000 + m_c->hvId->hv_line(id);
330}
331#endif
332#endif
#define M_PI
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
This class is a collection of AttributeLists where each one is associated with a channel number.
ChanAttrListMap::const_iterator const_iterator
std::unique_ptr< EMBPresamplerHVDescriptor > descriptor
Clockwork(const EMBPresamplerHVManager *manager)
std::unique_ptr< const EMBPresamplerHVModule > moduleArray[2][4][32]
double voltage(const EMBPresamplerHVModule &module, const int &iGap) const
bool hvOn(const EMBPresamplerHVModule &module, const int &iGap) const
double current(const EMBPresamplerHVModule &module, const int &iGap) const
EMBPresamplerHVData & operator=(EMBPresamplerHVData &&other) noexcept
int hvLineNo(const EMBPresamplerHVModule &module, const int &iGap) const
static int index(const EMBPresamplerHVModule &module)
const EMBPresamplerHVModule & getHVModule(unsigned int iSide, unsigned int iEta, unsigned int iPhi) const
std::unique_ptr< const Clockwork > m_c
const EMBPresamplerHVDescriptor * getDescriptor() const
EMBPresamplerHVData getData(const LArHVIdMapping &hvIdMapping, const std::vector< const CondAttrListCollection * > &attrLists) const
static unsigned int beginSideIndex()
unsigned int beginPhiIndex() const
static unsigned int endSideIndex()
std::function< std::vector< HWIdentifier >(HWIdentifier)> idfunc_t
unsigned int beginEtaIndex() const
int hvLineNo(const EMBPresamplerHVModule &module, int gap, const LArHVIdMapping *hvIdMapping, HWIdentifier *hvlId=nullptr) const
Describes one HV Module within the EMB Presampler.
Helper for the Liquid Argon Calorimeter cell at the electrode level.
const std::vector< HWIdentifier > & getLArElectrodeIDvec(HWIdentifier &hvlineId) const
Return a vector of LArElectrodeID corresponding to a given LArHVLineID.
const HWIdentifier getLArHVLineID(HWIdentifier &electrodeId) const
Return the LArHVLineID corresponding to a given LArElectrodeId.
Helper for the Liquid Argon Calorimeter High-Voltage identifiers.
Definition LArHVLineID.h:43
Definition index.py:1
STL namespace.