ATLAS Offline Software
Loading...
Searching...
No Matches
EMECPresamplerHVManager.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 <cmath>
8#include <stdexcept>
9#include <iostream>
10
12
14#include "GaudiKernel/ISvcLocator.h"
15#include "GaudiKernel/IToolSvc.h"
16#include "GaudiKernel/Bootstrap.h"
17#include "GaudiKernel/ServiceHandle.h"
18
21
24
25#if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE))
27#endif
28
30#include "GeoModelKernel/CellBinning.h"
31
32#include <atomic>
33
34
36public:
37 explicit Clockwork(const EMECPresamplerHVManager* manager) {
38 for(int iSide=0; iSide<2; ++iSide) {
39 for(int iPhi=0; iPhi<64; ++iPhi) {
40 moduleArray[iSide][iPhi] = std::make_unique<EMECPresamplerHVModule>(manager, iSide, iPhi);
41 }
42 }
43 ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager");
44 if (StatusCode::SUCCESS!=detStore->retrieve(elecId, "LArElectrodeID")) {
45 throw std::runtime_error("EMECPresamplerHVManager failed to retrieve LArElectrodeID");
46 }
47
48 if (StatusCode::SUCCESS!=detStore->retrieve(hvId,"LArHVLineID")) {
49 throw std::runtime_error("EMECPresamplerHVManager failed to retrieve LArHVLineID");
50 }
51 }
52 ~Clockwork() = default;
53 CellBinning phiBinning{0.0, 2*M_PI, 64};
54 std::unique_ptr<const EMECPresamplerHVModule> moduleArray[2][64]; // not dense
55 const LArElectrodeID* elecId = nullptr;
56 const LArHVLineID* hvId = nullptr;
57};
58
59
61{
62public:
63 std::vector<EMECPresamplerHVPayload> m_payloadArray;
64};
65
66
68= default;
69
70
72 (std::unique_ptr<Payload> payload)
73 : m_payload (std::move (payload))
74{
75}
76
77
80 if (this != &other) {
81 m_payload = std::move (other.m_payload);
82 }
83 return *this;
84}
85
86
88= default;
89
90
92 (const EMECPresamplerHVModule& module, const int& iGap) const
93{
94 return voltage (module, iGap) > INVALID;
95}
96
97
99 (const EMECPresamplerHVModule& module, const int& /*iGap*/) const
100{
101 return m_payload->m_payloadArray[index(module)].voltage;
102}
103
104
106 (const EMECPresamplerHVModule& module, const int& /*iGap*/) const
107{
108 return m_payload->m_payloadArray[index(module)].current;
109}
110
111
113 (const EMECPresamplerHVModule& module, const int& /*iGap*/) const
114{
115 return m_payload->m_payloadArray[index(module)].hvLineNo;
116}
117
118
120 (const EMECPresamplerHVModule& module)
121{
122 unsigned int phiIndex = module.getPhiIndex();
123 unsigned int sideIndex = module.getSideIndex();
124 unsigned int index = 64*sideIndex+phiIndex;
125 return index;
126}
127
128
130 : m_c (std::make_unique<Clockwork> (this))
131{
132}
133
135= default;
136
138{
139 return &(m_c->phiBinning);
140}
141
143{
144 return m_c->phiBinning.getFirstDivisionNumber();
145}
146
148{
149 return m_c->phiBinning.getFirstDivisionNumber() + m_c->phiBinning.getNumDivisions();
150}
151
152const EMECPresamplerHVModule& EMECPresamplerHVManager::getHVModule(unsigned int iSide, unsigned int iPhi) const
153{
154 return *(m_c->moduleArray[iSide][iPhi]);
155}
156
158{
159 return 0;
160}
161
163{
164 return 2;
165}
166
169 const std::vector<const CondAttrListCollection*>& attrLists) const
170{
171 auto payload = std::make_unique<EMECPresamplerHVData::Payload>();
172 payload->m_payloadArray.reserve(2*64);
173 for (unsigned int i=0;i<64;i++) {
174 payload->m_payloadArray[i].voltage = EMECPresamplerHVData::INVALID;
175 }
176
177 for (const CondAttrListCollection* atrlistcol : attrLists) {
178
179 for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) {
180
181 // Construct HWIdentifier
182 // 1. decode COOL Channel ID
183 unsigned int chanID = (*citr).first;
184 int cannode = chanID/1000;
185 int line = chanID%1000;
186
187 // 2. Construct the identifier
188 HWIdentifier id = m_c->hvId->HVLineId(1,1,cannode,line);
189
190
191 const std::vector<HWIdentifier>& electrodeIdVec = idfunc(id);
192
193 for(size_t i=0;i<electrodeIdVec.size();i++) {
194 HWIdentifier elecHWID = electrodeIdVec[i];
195 int detector = m_c->elecId->detector(elecHWID);
196 // check we are in EMECPresampler
197 if (detector==3) {
198
199
200 unsigned int sideIndex=1-m_c->elecId->zside(elecHWID);
201 unsigned int phiIndex=m_c->elecId->module(elecHWID); // from 0 to 31
202// rotation for C side
203 if (sideIndex==0) {
204 if (phiIndex<16) phiIndex=15-phiIndex;
205 else phiIndex=47-phiIndex;
206 }
207
208// GU January 2017 - fix for HV EMEC PS distribution
209// 0-31 in phi module
210// each module has 2 cell in phi, in the mapping database this is referred by "gapIndex"
211// 0 is on the low phi side (in the ATLAS frame)
212// 1 in on the high phi side
213// so in total 64 sectors in phi given by 2*phiIndex+gapIndex
214// the two gap of these sectors are powered by the same line and have the same HV
215
216 unsigned int gapIndex=m_c->elecId->gap(elecHWID);
217
218 unsigned int index = 64*sideIndex+2*phiIndex+gapIndex;
219
220
221 float voltage = EMECPresamplerHVData::INVALID;
222 if (!((*citr).second)["R_VMEAS"].isNull()) voltage = ((*citr).second)["R_VMEAS"].data<float>();
223 float current = 0.;
224 if (!((*citr).second)["R_IMEAS"].isNull()) current = ((*citr).second)["R_IMEAS"].data<float>();
225
226
227 payload->m_payloadArray[index].voltage=voltage;
228 payload->m_payloadArray[index].current=current;
229 payload->m_payloadArray[index].hvLineNo=chanID;
230 } // for (electrodeIdVec)
231 } // is EMECPresampler
232 } // for (atrlistcol)
233 }
234
235 return {std::move (payload)};
236}
237
238
239#if !(defined(SIMULATIONBASE) || defined(GENERATIONBASE))
242 const std::vector<const CondAttrListCollection*>& attrLists) const
243{
244 auto idfunc = [&] (HWIdentifier id) -> const std::vector<HWIdentifier>
245 { return hvIdMapping.getLArElectrodeIDvec(id); };
246 return getData (idfunc, attrLists);
247}
248
249
251 , const LArHVIdMapping* hvIdMapping, HWIdentifier *hvlId) const {
252 int sideIndex = module.getSideIndex();
253 int phiIndex = module.getPhiIndex()/2;
254
255 // ________________________ Construct ElectrodeID ________________________________
256 int id_detector = 3;
257 int id_zside = 1 - sideIndex;
258 int id_module{0};
259 if(sideIndex==1){
260 id_module = phiIndex;
261 }
262 else {
263 if(phiIndex<16) {
264 id_module = 15 - phiIndex;
265 }
266 else {
267 id_module = 47 - phiIndex;
268 }
269 }
270 int id_hv_phi{0};
271 int id_hv_eta{0};
272 int id_gap = module.getPhiIndex()%2;
273 int id_electrode{0};
274
275 HWIdentifier elecHWID = m_c->elecId->ElectrodeId(id_detector
276 ,id_zside
277 ,id_module
278 ,id_hv_phi
279 ,id_hv_eta
280 ,id_gap
281 ,id_electrode);
282 // ________________________ ________________________________
283
284 // Get LArHVLineID corresponding to a given LArElectrodeId
285 HWIdentifier id = hvIdMapping->getLArHVLineID(elecHWID);
286
287 if(hvlId) *hvlId = id;
288
289 // Extract HV Line No
290 return m_c->hvId->can_node(id)*1000 + m_c->hvId->hv_line(id);
291}
292#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< const EMECPresamplerHVModule > moduleArray[2][64]
Clockwork(const EMECPresamplerHVManager *manager)
EMECPresamplerHVData & operator=(EMECPresamplerHVData &&other) noexcept
bool hvOn(const EMECPresamplerHVModule &module, const int &iGap) const
double voltage(const EMECPresamplerHVModule &module, const int &iGap) const
double current(const EMECPresamplerHVModule &module, const int &iGap) const
int hvLineNo(const EMECPresamplerHVModule &module, const int &iGap) const
static int index(const EMECPresamplerHVModule &module)
EMECPresamplerHVData getData(const LArHVIdMapping &hvIdMapping, const std::vector< const CondAttrListCollection * > &attrLists) const
const CellBinning * getPhiBinning() const
int hvLineNo(const EMECPresamplerHVModule &module, const LArHVIdMapping *hvIdMapping, HWIdentifier *hvlineId=nullptr) const
std::unique_ptr< const Clockwork > m_c
const EMECPresamplerHVModule & getHVModule(unsigned int iSide, unsigned int iPhi) const
std::function< std::vector< HWIdentifier >(HWIdentifier)> idfunc_t
static unsigned int beginSideIndex()
Describes one HV Module within the EMEc 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.