CMS 3D CMS Logo

GEMChMap.h
Go to the documentation of this file.
1 #ifndef CondFormats_GEMObjects_GEMChMap_h
2 #define CondFormats_GEMObjects_GEMChMap_h
3 
6 #include <map>
7 #include <string>
8 #include <vector>
9 #include <algorithm>
10 
11 class GEMChMap {
12 public:
13  struct sectorEC {
14  unsigned int fedId;
15  uint8_t amcNum;
16  bool operator==(const sectorEC& r) const {
17  if (fedId == r.fedId) {
18  return amcNum == r.amcNum;
19  } else {
20  return false;
21  }
22  }
23 
25  };
26 
27  struct chamEC {
28  unsigned int fedId;
29  uint8_t amcNum;
30  uint16_t gebId;
31  bool operator<(const chamEC& r) const {
32  if (fedId == r.fedId) {
33  if (amcNum == r.amcNum) {
34  return gebId < r.gebId;
35  } else {
36  return amcNum < r.amcNum;
37  }
38  } else {
39  return fedId < r.fedId;
40  }
41  }
42 
44  };
45 
46  struct chamDC {
47  uint32_t detId;
49  bool operator<(const chamDC& r) const {
50  if (detId == r.detId) {
51  return chamberType < r.chamberType;
52  } else {
53  return detId < r.detId;
54  }
55  }
56 
58  };
59 
60  struct vfatEC {
62  uint16_t vfatAdd;
63  bool operator<(const vfatEC& r) const {
64  if (vfatAdd == r.vfatAdd) {
65  return chamberType < r.chamberType;
66  } else {
67  return vfatAdd < r.vfatAdd;
68  }
69  }
70 
72  };
73 
74  struct channelNum {
76  int vfatAdd;
77  int chNum;
78  bool operator<(const channelNum& c) const {
79  if (chamberType == c.chamberType) {
80  if (vfatAdd == c.vfatAdd) {
81  return chNum < c.chNum;
82  } else {
83  return vfatAdd < c.vfatAdd;
84  }
85  } else {
86  return chamberType < c.chamberType;
87  }
88  }
89 
91  };
92 
93  struct stripNum {
95  int iEta;
96  int stNum;
97  bool operator<(const stripNum& s) const {
98  if (chamberType == s.chamberType) {
99  if (iEta == s.iEta) {
100  return stNum < s.stNum;
101  } else {
102  return iEta < s.iEta;
103  }
104  } else {
105  return chamberType < s.chamberType;
106  }
107  }
108 
110  };
111 
112  GEMChMap();
113 
114  explicit GEMChMap(const std::string& version);
115 
116  ~GEMChMap();
117 
118  const std::string& version() const;
119  void setDummy();
120 
121  std::map<chamEC, chamDC> chamberMap() { return chamberMap_; };
122 
123  bool isValidAMC(unsigned int fedId, uint8_t amcNum) const {
124  return std::find(amcVec_.begin(), amcVec_.end(), sectorEC({fedId, amcNum})) != amcVec_.end();
125  }
126 
127  bool isValidChamber(unsigned int fedId, uint8_t amcNum, uint16_t gebId) const {
128  return chamberMap_.find({fedId, amcNum, gebId}) != chamberMap_.end();
129  }
130 
131  bool isValidVFAT(int chamberType, uint16_t vfatAdd) const {
132  return chamIEtas_.find({chamberType, vfatAdd}) != chamIEtas_.end();
133  }
134 
135  bool isValidStrip(int chamberType, int iEta, int strip) const {
136  return stChMap_.find({chamberType, iEta, strip}) != stChMap_.end();
137  }
138 
139  void add(sectorEC e) { amcVec_.push_back(e); }
140 
141  const chamDC& chamberPos(unsigned int fedId, uint8_t amcNum, uint16_t gebId) const {
142  return chamberMap_.at({fedId, amcNum, gebId});
143  }
144  void add(chamEC e, chamDC d) { chamberMap_[e] = d; }
145 
146  const std::vector<uint16_t> getVfats(const int type) const { return chamVfats_.at(type); }
147  void add(int type, uint16_t d) {
148  if (std::find(chamVfats_[type].begin(), chamVfats_[type].end(), d) == chamVfats_[type].end())
149  chamVfats_[type].push_back(d);
150  }
151 
152  const std::vector<int> getIEtas(int chamberType, uint16_t vfatAdd) const {
153  return chamIEtas_.at({chamberType, vfatAdd});
154  }
155  void add(vfatEC d, int iEta) {
156  if (std::find(chamIEtas_[d].begin(), chamIEtas_[d].end(), iEta) == chamIEtas_[d].end())
157  chamIEtas_[d].push_back(iEta);
158  }
159 
160  const channelNum& getChannel(int chamberType, int iEta, int strip) const {
161  return stChMap_.at({chamberType, iEta, strip});
162  }
163  const stripNum& getStrip(int chamberType, int vfatAdd, int channel) const {
164  return chStMap_.at({chamberType, vfatAdd, channel});
165  }
166 
167  void add(channelNum c, stripNum s) { chStMap_[c] = s; }
168  void add(stripNum s, channelNum c) { stChMap_[s] = c; }
169 
170 private:
172 
173  std::vector<sectorEC> amcVec_;
174 
175  // electronics map to GEMDetId chamber
176  std::map<chamEC, chamDC> chamberMap_;
177 
178  std::map<int, std::vector<uint16_t>> chamVfats_;
179  std::map<vfatEC, std::vector<int>> chamIEtas_;
180 
181  std::map<channelNum, stripNum> chStMap_;
182  std::map<stripNum, channelNum> stChMap_;
183 
185 
186 public:
187  // size of ID bits
188  static const int chipIdMask_ = 0xfff; // chipId mask for 12 bits
189  static const int maxGEBs_ = 24; // 5 bits for GEB id
190  static const int maxGEB1_ = 12; // 5 bits for GEB id
191  static const int maxGEB2_ = 12; // 5 bits for GEB id
192  static const int maxAMCs_ = 15; // 4 bits for AMC no.
193  static const int maxVFatGE0_ = 12; // vFat per eta partition, not known yet for ME0
194  static const int maxVFatGE11_ = 3; // vFat per eta partition in GE11
195  static const int maxVFatGE21_ = 6; // vFat per eta partition in GE21
196  static const int maxiEtaIdGE0_ = 8; // no. eta partitions for GE0
197  static const int maxiEtaIdGE11_ = 8; // no. eta partitions for GE11
198  static const int maxiEtaIdGE21_ = 16; // no. eta partitions for GE21
199  static const int maxChan_ = 128; // channels per vFat
200 };
201 #endif // GEMChMap_H
static const int chipIdMask_
Definition: GEMChMap.h:188
void add(stripNum s, channelNum c)
Definition: GEMChMap.h:168
unsigned int fedId
Definition: GEMChMap.h:28
bool operator<(const chamEC &r) const
Definition: GEMChMap.h:31
const std::vector< int > getIEtas(int chamberType, uint16_t vfatAdd) const
Definition: GEMChMap.h:152
bool isValidVFAT(int chamberType, uint16_t vfatAdd) const
Definition: GEMChMap.h:131
const std::vector< uint16_t > getVfats(const int type) const
Definition: GEMChMap.h:146
GEMChMap()
Definition: GEMChMap.cc:5
uint32_t detId
Definition: GEMChMap.h:47
const std::string & version() const
Definition: GEMChMap.cc:11
std::map< chamEC, chamDC > chamberMap_
Definition: GEMChMap.h:176
std::map< chamEC, chamDC > chamberMap()
Definition: GEMChMap.h:121
const chamDC & chamberPos(unsigned int fedId, uint8_t amcNum, uint16_t gebId) const
Definition: GEMChMap.h:141
void add(vfatEC d, int iEta)
Definition: GEMChMap.h:155
std::map< stripNum, channelNum > stChMap_
Definition: GEMChMap.h:182
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::string theVersion
Definition: GEMChMap.h:171
unsigned int fedId
Definition: GEMChMap.h:14
bool operator<(const chamDC &r) const
Definition: GEMChMap.h:49
static const int maxiEtaIdGE0_
Definition: GEMChMap.h:196
std::map< int, std::vector< uint16_t > > chamVfats_
Definition: GEMChMap.h:178
static const int maxiEtaIdGE21_
Definition: GEMChMap.h:198
static const int maxGEB1_
Definition: GEMChMap.h:190
bool isValidAMC(unsigned int fedId, uint8_t amcNum) const
Definition: GEMChMap.h:123
~GEMChMap()
Definition: GEMChMap.cc:9
uint16_t gebId
Definition: GEMChMap.h:30
void add(channelNum c, stripNum s)
Definition: GEMChMap.h:167
static const int maxGEB2_
Definition: GEMChMap.h:191
std::map< channelNum, stripNum > chStMap_
Definition: GEMChMap.h:181
bool isValidChamber(unsigned int fedId, uint8_t amcNum, uint16_t gebId) const
Definition: GEMChMap.h:127
static const int maxGEBs_
Definition: GEMChMap.h:189
d
Definition: ztail.py:151
const stripNum & getStrip(int chamberType, int vfatAdd, int channel) const
Definition: GEMChMap.h:163
std::map< vfatEC, std::vector< int > > chamIEtas_
Definition: GEMChMap.h:179
bool operator<(const vfatEC &r) const
Definition: GEMChMap.h:63
uint8_t amcNum
Definition: GEMChMap.h:29
void add(sectorEC e)
Definition: GEMChMap.h:139
static const int maxVFatGE0_
Definition: GEMChMap.h:193
static const int maxChan_
Definition: GEMChMap.h:199
void add(int type, uint16_t d)
Definition: GEMChMap.h:147
static const int maxVFatGE11_
Definition: GEMChMap.h:194
#define COND_SERIALIZABLE
Definition: Serializable.h:39
bool operator==(const sectorEC &r) const
Definition: GEMChMap.h:16
bool operator<(const stripNum &s) const
Definition: GEMChMap.h:97
static const int maxiEtaIdGE11_
Definition: GEMChMap.h:197
std::vector< sectorEC > amcVec_
Definition: GEMChMap.h:173
static const int maxAMCs_
Definition: GEMChMap.h:192
uint16_t vfatAdd
Definition: GEMChMap.h:62
void add(chamEC e, chamDC d)
Definition: GEMChMap.h:144
static const int maxVFatGE21_
Definition: GEMChMap.h:195
const channelNum & getChannel(int chamberType, int iEta, int strip) const
Definition: GEMChMap.h:160
void setDummy()
Definition: GEMChMap.cc:13
uint8_t amcNum
Definition: GEMChMap.h:15
bool operator<(const channelNum &c) const
Definition: GEMChMap.h:78
bool isValidStrip(int chamberType, int iEta, int strip) const
Definition: GEMChMap.h:135