ATLAS Offline Software
EMECPresamplerHVManager.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <cmath>
8 #include <stdexcept>
9 #include <iostream>
10 
12 
13 #include "StoreGate/StoreGateSvc.h"
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 
36 public:
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 {
62 public:
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 
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 
137 const CellBinning *EMECPresamplerHVManager::getPhiBinning() const
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 
152 const 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  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) { return hvIdMapping.getLArElectrodeIDvec(id); };
245  return getData (idfunc, attrLists);
246 }
247 
248 
250  , const LArHVIdMapping* hvIdMapping) const {
251  int sideIndex = module.getSideIndex();
252  int phiIndex = module.getPhiIndex()/2;
253 
254  // ________________________ Construct ElectrodeID ________________________________
255  int id_detector = 3;
256  int id_zside = 1 - sideIndex;
257  int id_module{0};
258  if(sideIndex==1){
259  id_module = phiIndex;
260  }
261  else {
262  if(phiIndex<16) {
263  id_module = 15 - phiIndex;
264  }
265  else {
266  id_module = 47 - phiIndex;
267  }
268  }
269  int id_hv_phi{0};
270  int id_hv_eta{0};
271  int id_gap = module.getPhiIndex()%2;
272  int id_electrode{0};
273 
274  HWIdentifier elecHWID = m_c->elecId->ElectrodeId(id_detector
275  ,id_zside
276  ,id_module
277  ,id_hv_phi
278  ,id_hv_eta
279  ,id_gap
280  ,id_electrode);
281  // ________________________ ________________________________
282 
283  // Get LArHVLineID corresponding to a given LArElectrodeId
284  HWIdentifier id = hvIdMapping->getLArHVLineID(elecHWID);
285 
286  // Extract HV Line No
287  return m_c->hvId->can_node(id)*1000 + m_c->hvId->hv_line(id);
288 }
289 #endif
EMECPresamplerHVManager
This class provides direct access to information on the HV electrodes within the EMEC....
Definition: EMECPresamplerHVManager.h:36
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
EMECPresamplerHVManager::hvLineNo
int hvLineNo(const EMECPresamplerHVModule &module, const LArHVIdMapping *hvIdMapping) const
Definition: EMECPresamplerHVManager.cxx:249
EMECPresamplerHVManager::EMECPresamplerHVManager
EMECPresamplerHVManager()
Definition: EMECPresamplerHVManager.cxx:129
checkFileSG.line
line
Definition: checkFileSG.py:75
EMECPresamplerHVManager::Clockwork::moduleArray
std::unique_ptr< const EMECPresamplerHVModule > moduleArray[2][64]
Definition: EMECPresamplerHVManager.cxx:54
EMECPresamplerHVManager::EMECPresamplerHVData::Payload
Definition: EMECPresamplerHVManager.cxx:61
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
EMECPresamplerHVManager::EMECPresamplerHVData::current
double current(const EMECPresamplerHVModule &module, const int &iGap) const
Definition: EMECPresamplerHVManager.cxx:106
EMECPresamplerHVManager::EMECPresamplerHVData::voltage
double voltage(const EMECPresamplerHVModule &module, const int &iGap) const
Definition: EMECPresamplerHVManager.cxx:99
EMECPresamplerHVManager::endSideIndex
static unsigned int endSideIndex()
Definition: EMECPresamplerHVManager.cxx:162
EMECPresamplerHVManager::beginSideIndex
static unsigned int beginSideIndex()
Definition: EMECPresamplerHVManager.cxx:157
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
LArElectrodeID
Helper for the Liquid Argon Calorimeter cell at the electrode level.
Definition: LArElectrodeID.h:101
index
Definition: index.py:1
EMECPresamplerHVManager::getData
EMECPresamplerHVData getData(const LArHVIdMapping &hvIdMapping, const std::vector< const CondAttrListCollection * > &attrLists) const
Definition: EMECPresamplerHVManager.cxx:241
EMECPresamplerHVManager::Clockwork::elecId
const LArElectrodeID * elecId
Definition: EMECPresamplerHVManager.cxx:55
M_PI
#define M_PI
Definition: ActiveFraction.h:11
LArHVIdMapping::getLArHVLineID
const HWIdentifier getLArHVLineID(HWIdentifier &electrodeId) const
Return the LArHVLineID corresponding to a given LArElectrodeId.
Definition: LArHVIdMapping.cxx:22
EMECPresamplerHVManager.h
EMECPresamplerHVManager::~EMECPresamplerHVManager
~EMECPresamplerHVManager()
LArHVLineID.h
HWIdentifier
Definition: HWIdentifier.h:13
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
CxxUtils::INVALID
@ INVALID
Definition: CachedValue.h:28
AthenaAttributeList.h
EMECPresamplerHVManager::beginPhiIndex
unsigned int beginPhiIndex() const
Definition: EMECPresamplerHVManager.cxx:142
EMECPresamplerHVManager::getHVModule
const EMECPresamplerHVModule & getHVModule(unsigned int iSide, unsigned int iPhi) const
Definition: EMECPresamplerHVManager.cxx:152
EMECPresamplerHVModule.h
EMECPresamplerHVManager::Clockwork::phiBinning
CellBinning phiBinning
Definition: EMECPresamplerHVManager.cxx:53
TRT::Hit::detector
@ detector
Definition: HitInfo.h:78
python.PyAthena.module
module
Definition: PyAthena.py:134
EMECPresamplerHVManager::EMECPresamplerHVData::hvOn
bool hvOn(const EMECPresamplerHVModule &module, const int &iGap) const
Definition: EMECPresamplerHVManager.cxx:92
lumiFormat.i
int i
Definition: lumiFormat.py:92
EMECPresamplerHVManager::EMECPresamplerHVData::index
static int index(const EMECPresamplerHVModule &module)
Definition: EMECPresamplerHVManager.cxx:120
LArHVIdMapping.h
EMECPresamplerHVManager::EMECPresamplerHVData::EMECPresamplerHVData
EMECPresamplerHVData()
EMECPresamplerHVManager::EMECPresamplerHVData::INVALID
static constexpr double INVALID
Definition: EMECPresamplerHVManager.h:41
EMECPresamplerHVPayload.h
EMECPresamplerHVManager::EMECPresamplerHVData::~EMECPresamplerHVData
~EMECPresamplerHVData()
EMECPresamplerHVManager::EMECPresamplerHVData
Definition: EMECPresamplerHVManager.h:39
EMECPresamplerHVManager::getPhiBinning
const CellBinning * getPhiBinning() const
Definition: EMECPresamplerHVManager.cxx:137
EMECPresamplerHVManager::Clockwork::~Clockwork
~Clockwork()=default
EMECPresamplerHVManager::EMECPresamplerHVData::Payload::m_payloadArray
std::vector< EMECPresamplerHVPayload > m_payloadArray
Definition: EMECPresamplerHVManager.cxx:63
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
EMECPresamplerHVManager::Clockwork::Clockwork
Clockwork(const EMECPresamplerHVManager *manager)
Definition: EMECPresamplerHVManager.cxx:37
HWIdentifier.h
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
EMECPresamplerHVManager::Clockwork::hvId
const LArHVLineID * hvId
Definition: EMECPresamplerHVManager.cxx:56
EMECPresamplerHVManager::EMECPresamplerHVData::hvLineNo
int hvLineNo(const EMECPresamplerHVModule &module, const int &iGap) const
Definition: EMECPresamplerHVManager.cxx:113
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:53
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
DeMoScan.index
string index
Definition: DeMoScan.py:362
EMECPresamplerHVManager::m_c
std::unique_ptr< const Clockwork > m_c
Definition: EMECPresamplerHVManager.h:88
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
LArHVIdMapping
Definition: LArHVIdMapping.h:21
EMECPresamplerHVManager::Clockwork
Definition: EMECPresamplerHVManager.cxx:35
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
EMECPresamplerHVModule
Describes one HV Module within the EMEc Presampler.
Definition: EMECPresamplerHVModule.h:22
EMECPresamplerHVManager::EMECPresamplerHVData::operator=
EMECPresamplerHVData & operator=(EMECPresamplerHVData &&other) noexcept
Definition: EMECPresamplerHVManager.cxx:79
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
LArElectrodeID.h
EMECPresamplerHVManager::endPhiIndex
unsigned int endPhiIndex() const
Definition: EMECPresamplerHVManager.cxx:147
StoreGateSvc.h
EMECPresamplerHVManager::idfunc_t
std::function< std::vector< HWIdentifier >(HWIdentifier)> idfunc_t
Definition: EMECPresamplerHVManager.h:80
LArHVIdMapping::getLArElectrodeIDvec
const std::vector< HWIdentifier > & getLArElectrodeIDvec(HWIdentifier &hvlineId) const
Return a vector of LArElectrodeID corresponding to a given LArHVLineID.
Definition: LArHVIdMapping.cxx:83
ServiceHandle< StoreGateSvc >
LArHVLineID
Helper for the Liquid Argon Calorimeter High-Voltage identifiers.
Definition: LArHVLineID.h:48