ATLAS Offline Software
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 
15 #ifndef LARRAWCONDITIONS_LARCONDFEBIDCHANMAP_H
16 #define LARRAWCONDITIONS_LARCONDFEBIDCHANMAP_H
17 
42 #include <vector>
43 #include <map>
44 #include <ostream>
46 
47 
49 {
50 public:
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 
60  Original = 0,
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,
73  NCORRTYPE = 12
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 
136 private:
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;
159  unsigned int m_numOffsetChannels;
161 };
162 
163 
164 // INLINE FUNCTIONS
165 
166 inline
168  :
169  m_febIdVecs(1),
170  m_chansPerGain(1),
171  m_totalChannels(PSBA + 3*NCORRTYPE),
172  m_minGain(0),
173  m_maxGain(2),
174  m_nGains(3),
175  m_numOffsetChannels(3)
176 
177 
178 {}
179 
180 inline
181 LArCondFEBIdChanMap::LArCondFEBIdChanMap(unsigned int chansPerGain,
182  unsigned int minGain,
183  unsigned int nGains)
184  :
185  m_febIdVecs(chansPerGain),
186  m_chansPerGain(chansPerGain),
187  m_totalChannels(PSBA + 3*NCORRTYPE),
188  m_minGain(minGain),
189  m_maxGain(minGain + nGains),
190  m_nGains(nGains),
191  m_numOffsetChannels(nGains*NUMOFFSETCHANNELSPERGAIN)
192 
193 {}
194 
195 inline
196 void
197 LArCondFEBIdChanMap::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
206 inline
207 void
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 
224 inline
226 LArCondFEBIdChanMap::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) {
232  }
233  if (channel < m_chansPerGain) {
234  return (m_febIdVecs[channel]);
235  }
236  return (m_empty);
237 }
238 
239 inline
240 bool
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 
261 inline
262 bool
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 
290 inline
291 unsigned int
293 {
295 }
296 
297 
298 inline
299 unsigned int
300 LArCondFEBIdChanMap::groupNumber(unsigned int coolChannel) const
301 {
302  return (coolChannel/m_nGains);
303 }
304 
305 
306 inline
307 unsigned int
309 {
310  return (m_chansPerGain);
311 }
312 
313 inline
314 unsigned int
316 {
317  return (m_minGain);
318 }
319 
320 inline
321 unsigned int
323 {
324  return (m_nGains);
325 }
326 
327 inline
328 unsigned int
330 {
331  return (m_numOffsetChannels);
332 }
333 
334 
335 inline
336 unsigned int
338 {
339  return (m_totalChannels);
340 }
341 
342 inline
343 void
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 
LArCondFEBIdChanMap::CORRECTIONSETCHANNEL
@ CORRECTIONSETCHANNEL
Definition: LArCondFEBIdChanMap.h:141
LArCondFEBIdChanMap::totalChannels
unsigned int totalChannels() const
Total number of channels for all gains and includes special offset channels.
Definition: LArCondFEBIdChanMap.h:337
LArCondFEBIdChanMap::fillMap
void fillMap(unsigned int channel, const FEBIdVector &febIdVec)
Fill map from chan/febid vec - channel here is 0 to chansPerGain-1.
Definition: LArCondFEBIdChanMap.h:197
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
LArCondFEBIdChanMap::ChannelMap
std::vector< FEBIdVector > ChannelMap
Definition: LArCondFEBIdChanMap.h:55
LArCondFEBIdChanMap::EMBA
@ EMBA
Definition: LArCondFEBIdChanMap.h:65
LArCondFEBIdChanMap::channelsPerGain
unsigned int channelsPerGain() const
Number of cool channels per gain.
Definition: LArCondFEBIdChanMap.h:308
LArCondFEBIdChanMap::~LArCondFEBIdChanMap
virtual ~LArCondFEBIdChanMap()=default
destructor
LArCondFEBIdChanMap::m_minGain
unsigned int m_minGain
Definition: LArCondFEBIdChanMap.h:156
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LArCondFEBIdChanMap::EMECC
@ EMECC
Definition: LArCondFEBIdChanMap.h:68
LArCondFEBIdChanMap::LArCondFEBIdChanMap
LArCondFEBIdChanMap()
Default constructor.
Definition: LArCondFEBIdChanMap.h:167
LArCondFEBIdChanMap::EMBC
@ EMBC
Definition: LArCondFEBIdChanMap.h:66
LArCondFEBIdChanMap::PSECA
@ PSECA
Definition: LArCondFEBIdChanMap.h:63
LArCondFEBIdChanMap::nOffsetChannels
unsigned int nOffsetChannels() const
Number of offset channels - i.e. correction channels.
Definition: LArCondFEBIdChanMap.h:329
LArCondFEBIdChanMap::m_chansPerGain
unsigned int m_chansPerGain
Definition: LArCondFEBIdChanMap.h:154
LArCondFEBIdChanMap::m_maxGain
unsigned int m_maxGain
Definition: LArCondFEBIdChanMap.h:157
LArCondFEBIdChanMap::getChannel
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.
Definition: LArCondFEBIdChanMap.h:241
LArCondFEBIdChanMap::m_totalChannels
unsigned int m_totalChannels
Definition: LArCondFEBIdChanMap.h:155
LArCondFEBIdChanMap::FCALA
@ FCALA
Definition: LArCondFEBIdChanMap.h:71
LArCondFEBIdChanMap::groupNumber
unsigned int groupNumber(unsigned int coolChannel) const
Group number of a cool channel (0 - correction group, 1-N for FEB ID groups)
Definition: LArCondFEBIdChanMap.h:300
LArCondFEBIdChanMap::getCorrectionSetChannels
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...
Definition: LArCondFEBIdChanMap.h:263
LArCondFEBIdChanMap::NUMOFFSETCHANNELSPERGAIN
@ NUMOFFSETCHANNELSPERGAIN
Definition: LArCondFEBIdChanMap.h:140
LArCondFEBIdChanMap::PSECC
@ PSECC
Definition: LArCondFEBIdChanMap.h:64
LArCondFEBIdChanMap::m_numOffsetChannels
unsigned int m_numOffsetChannels
Definition: LArCondFEBIdChanMap.h:159
LArCondFEBIdChanMap::HECC
@ HECC
Definition: LArCondFEBIdChanMap.h:70
LArCondFEBIdChanMap::EMECA
@ EMECA
Definition: LArCondFEBIdChanMap.h:67
LArCondFEBIdChanMap::minGain
unsigned int minGain() const
Mininum gain value.
Definition: LArCondFEBIdChanMap.h:315
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCondFEBIdChanMap::HECA
@ HECA
Definition: LArCondFEBIdChanMap.h:69
LArCondFEBIdChanMap::m_empty
FEBIdVector m_empty
Definition: LArCondFEBIdChanMap.h:160
LArCondFEBIdChanMap::febIdVector
const FEBIdVector & febIdVector(unsigned int gain, unsigned int coolChannel) const
Access to a FEB ID vector for a given gain and COOL channel.
Definition: LArCondFEBIdChanMap.h:226
LArCondFEBIdChanMap::nGroups
unsigned int nGroups() const
Number of groups - minimum is 2 (1 correction group, 1 FEB ID group)
Definition: LArCondFEBIdChanMap.h:292
LArCondFEBIdChanMap::Original
@ Original
Definition: LArCondFEBIdChanMap.h:60
LArCondFEBIdChanMap::m_channelMap
FEBIdMap m_channelMap
Definition: LArCondFEBIdChanMap.h:153
LArOnlineID
Definition: LArOnlineID.h:20
LArCondFEBIdChanMap::dump
void dump(std::ostream &o, const LArOnlineID *onlineID=NULL) const
Definition: LArCondFEBIdChanMap.cxx:7
LArCondFEBIdChanMap::FEBIdVector
std::vector< FEBId > FEBIdVector
Definition: LArCondFEBIdChanMap.h:54
LArCondFEBIdChanMap::FEBId
unsigned int FEBId
Public typedefs.
Definition: LArCondFEBIdChanMap.h:53
LArCondFEBIdChanMap::nGains
unsigned int nGains() const
Number of gain values.
Definition: LArCondFEBIdChanMap.h:322
LArCondFEBIdChanMap::PSBA
@ PSBA
Definition: LArCondFEBIdChanMap.h:61
LArCondFEBIdChanMap::FEBIdMap
std::map< FEBId, unsigned int > FEBIdMap
Definition: LArCondFEBIdChanMap.h:56
LArCondFEBIdChanMap::addFEBIdVector
void addFEBIdVector(unsigned int channel, const FEBIdVector &febIdVec)
Add in a FEBIdVector - channel number should be from 0 to NChannelsPerGain-1
Definition: LArCondFEBIdChanMap.h:344
LArCondFEBIdChanMap
This class maps FEB IDs to/from COOL channel ids.
Definition: LArCondFEBIdChanMap.h:49
LArCondFEBIdChanMap::PSBC
@ PSBC
Definition: LArCondFEBIdChanMap.h:62
LArCondFEBIdChanMap::ChanMapOffets
ChanMapOffets
Offsets for the special channels.
Definition: LArCondFEBIdChanMap.h:139
LArCondFEBIdChanMap::CorrectionType
CorrectionType
Correction type.
Definition: LArCondFEBIdChanMap.h:59
LArCondFEBIdChanMap::NCORRTYPE
@ NCORRTYPE
Definition: LArCondFEBIdChanMap.h:73
LArCondFEBIdChanMap::FCALC
@ FCALC
Definition: LArCondFEBIdChanMap.h:72
LArCondFEBIdChanMap::m_febIdVecs
ChannelMap m_febIdVecs
File map from existing ChannelMap - e.g. on read back.
Definition: LArCondFEBIdChanMap.h:152
LArCondFEBIdChanMap::m_nGains
unsigned int m_nGains
Definition: LArCondFEBIdChanMap.h:158
LArOnlineID.h