ATLAS Offline Software
Loading...
Searching...
No Matches
LArCondFEBIdChanMap.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
14
15#ifndef LARRAWCONDITIONS_LARCONDFEBIDCHANMAP_H
16#define LARRAWCONDITIONS_LARCONDFEBIDCHANMAP_H
41
42#include <vector>
43#include <map>
44#include <ostream>
46
47
49{
50public:
51
53 typedef unsigned int FEBId;
54 typedef std::vector<FEBId> FEBIdVector;
55 typedef std::vector<FEBIdVector> ChannelMap;
56 typedef std::map<FEBId, unsigned int> FEBIdMap;
57
61 PSBA = 1001,
62 PSBC = 1002,
63 PSECA = 1003,
64 PSECC = 1004,
65 EMBA = 1005,
66 EMBC = 1006,
67 EMECA = 1007,
68 EMECC = 1008,
69 HECA = 1009,
70 HECC = 1010,
71 FCALA = 1011,
72 FCALC = 1012,
74 };
75
78
82 LArCondFEBIdChanMap(unsigned int nChanPerGain,
83 unsigned int minGain,
84 unsigned int nGain);
85
87 virtual ~LArCondFEBIdChanMap() = default;
88
89
91 const FEBIdVector& febIdVector(unsigned int gain,
92 unsigned int coolChannel) const;
93
96 bool getChannel (FEBId febId,
97 unsigned int gain,
98 unsigned int& coolChannel ) const;
99
102 bool getCorrectionSetChannels(unsigned int gain,
103 std::vector<unsigned int>& coolChannels) const;
104
107 unsigned int nGroups() const;
108
111 unsigned int groupNumber(unsigned int coolChannel) const;
112
113
115 unsigned int channelsPerGain() const;
116
118 unsigned int minGain() const;
119
121 unsigned int nGains() const;
122
124 unsigned int nOffsetChannels() const;
125
128 unsigned int totalChannels() const;
129
132 void addFEBIdVector(unsigned int channel, const FEBIdVector& febIdVec);
133
134 void dump(std::ostream& o, const LArOnlineID* onlineID=NULL) const;
135
136private:
137
140 NUMOFFSETCHANNELSPERGAIN = 1, // Number of special channels per gain
141 CORRECTIONSETCHANNEL = 0 // Channel for the correction sets
142 };
143
144
147 void fillMap(unsigned int channel, const FEBIdVector& febIdVec);
148
150 //void fillMap() const;
151
154 unsigned int m_chansPerGain;
155 unsigned int m_totalChannels;
156 unsigned int m_minGain;
157 unsigned int m_maxGain;
158 unsigned int m_nGains;
161};
162
163
164// INLINE FUNCTIONS
165
166inline
179
180inline
182 unsigned int minGain,
183 unsigned int nGains)
184 :
185 m_febIdVecs(chansPerGain),
186 m_chansPerGain(chansPerGain),
192
193{}
194
195inline
196void
197LArCondFEBIdChanMap::fillMap(unsigned int channel, const FEBIdVector& febIdVec)
198{
199 // add channel to map for each feb id
200 for (unsigned int i = 0; i < febIdVec.size(); ++i) {
201 m_channelMap[febIdVec[i]] = channel;
202 }
203}
204
205#if 0
206inline
207void
209{
210 // loop over existing vector of feb id vectors and set up map for
211 // each feb id. This is needed, for example on readback
212 // Though these objects are not read directly, so this should
213 // no longer be needed.
214 for (unsigned int i = 0; i < m_febIdVecs.size(); ++i) {
215 for (unsigned int j = 0; j < m_febIdVecs[i].size(); ++j) {
216 m_channelMap[m_febIdVecs[i][j]] = i;
217 }
218 }
219}
220#endif
221
222
223
224inline
226LArCondFEBIdChanMap::febIdVector(unsigned int gain, unsigned int coolChannel) const
227{
228
229 unsigned int channel = m_chansPerGain;
230 if (coolChannel >= (gain - m_minGain)*m_chansPerGain + m_numOffsetChannels) {
231 channel = coolChannel - (gain - m_minGain)*m_chansPerGain - m_numOffsetChannels;
232 }
233 if (channel < m_chansPerGain) {
234 return (m_febIdVecs[channel]);
235 }
236 return (m_empty);
237}
238
239inline
240bool
242 unsigned int gain,
243 unsigned int& coolChannel ) const
244{
245 if (1 == m_chansPerGain) {
246 // All FEB IDs in the same group
247 coolChannel = (gain - m_minGain) + m_numOffsetChannels;
248 return (true);
249 }
250 coolChannel = 9999;
251 FEBIdMap::const_iterator it = m_channelMap.find(febId);
252 if (it != m_channelMap.end()) {
253 if (m_minGain <= gain && gain <= m_maxGain) {
254 coolChannel = (gain - m_minGain)*m_chansPerGain + (*it).second + m_numOffsetChannels;
255 return (true);
256 }
257 }
258 return (false);
259}
260
261inline
262bool
264 std::vector<unsigned int>& coolChannels) const
265{
266 coolChannels.clear();
267 if (m_minGain <= gain && gain <= m_maxGain) {
268 coolChannels.reserve(1 + NCORRTYPE);
269 // loop over all correction types, including the "old" first
270 // one which included everything
271 coolChannels.push_back( (gain - m_minGain) + CORRECTIONSETCHANNEL);
272 unsigned int gainOffset = (gain - m_minGain)*NCORRTYPE;
273 coolChannels.push_back(PSBA + gainOffset);
274 coolChannels.push_back(PSBC + gainOffset);
275 coolChannels.push_back(PSECA + gainOffset);
276 coolChannels.push_back(PSECC + gainOffset);
277 coolChannels.push_back(EMBA + gainOffset);
278 coolChannels.push_back(EMBC + gainOffset);
279 coolChannels.push_back(EMECA + gainOffset);
280 coolChannels.push_back(EMECC + gainOffset);
281 coolChannels.push_back(HECA + gainOffset);
282 coolChannels.push_back(HECC + gainOffset);
283 coolChannels.push_back(FCALA + gainOffset);
284 coolChannels.push_back(FCALC + gainOffset);
285 return (true);
286 }
287 return (false);
288}
289
290inline
291unsigned int
296
297
298inline
299unsigned int
300LArCondFEBIdChanMap::groupNumber(unsigned int coolChannel) const
301{
302 return (coolChannel/m_nGains);
303}
304
305
306inline
307unsigned int
312
313inline
314unsigned int
316{
317 return (m_minGain);
318}
319
320inline
321unsigned int
323{
324 return (m_nGains);
325}
326
327inline
328unsigned int
333
334
335inline
336unsigned int
341
342inline
343void
344LArCondFEBIdChanMap::addFEBIdVector(unsigned int channel, const FEBIdVector& febIdVec)
345{
346 // Make sure vector is large enough - should have been sized in
347 // constructor!!
348 if (channel >= m_chansPerGain) m_febIdVecs.resize(channel + 1);
349 m_febIdVecs[channel] = febIdVec;
350 fillMap(channel, febIdVec);
351}
352
353#endif // LARRAWCONDITIONS_LARCONDFEBIDCHANMAP_H
354
355
356
void addFEBIdVector(unsigned int channel, const FEBIdVector &febIdVec)
Add in a FEBIdVector - channel number should be from 0 to NChannelsPerGain-1.
unsigned int nOffsetChannels() const
Number of offset channels - i.e. correction channels.
std::map< FEBId, unsigned int > FEBIdMap
std::vector< FEBId > FEBIdVector
unsigned int minGain() const
Mininum gain value.
virtual ~LArCondFEBIdChanMap()=default
destructor
CorrectionType
Correction type.
LArCondFEBIdChanMap()
Default constructor.
const FEBIdVector & febIdVector(unsigned int gain, unsigned int coolChannel) const
Access to a FEB ID vector for a given gain and COOL channel.
bool getCorrectionSetChannels(unsigned int gain, std::vector< unsigned int > &coolChannels) const
Access to the cool channel numbers for the correction sets of a particular gain - bool == false if no...
unsigned int groupNumber(unsigned int coolChannel) const
Group number of a cool channel (0 - correction group, 1-N for FEB ID groups)
unsigned int channelsPerGain() const
Number of cool channels per gain.
bool getChannel(FEBId febId, unsigned int gain, unsigned int &coolChannel) const
Access to the cool channel number for a given FEB ID and gain - bool == false if not found.
ChanMapOffets
Offsets for the special channels.
unsigned int nGroups() const
Number of groups - minimum is 2 (1 correction group, 1 FEB ID group)
void fillMap(unsigned int channel, const FEBIdVector &febIdVec)
Fill map from chan/febid vec - channel here is 0 to chansPerGain-1.
unsigned int nGains() const
Number of gain values.
std::vector< FEBIdVector > ChannelMap
unsigned int totalChannels() const
Total number of channels for all gains and includes special offset channels.
unsigned int FEBId
Public typedefs.
ChannelMap m_febIdVecs
File map from existing ChannelMap - e.g. on read back.
-event-from-file