CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 { return detId < r.detId; }
50 
52  };
53 
54  struct vfatEC {
56  uint16_t vfatAdd;
57  bool operator<(const vfatEC& r) const {
58  if (vfatAdd == r.vfatAdd) {
59  return chamberType < r.chamberType;
60  } else {
61  return vfatAdd < r.vfatAdd;
62  }
63  }
64 
66  };
67 
68  struct channelNum {
70  int vfatAdd;
71  int chNum;
72  bool operator<(const channelNum& c) const {
73  if (chamberType == c.chamberType) {
74  if (vfatAdd == c.vfatAdd) {
75  return chNum < c.chNum;
76  } else {
77  return vfatAdd < c.vfatAdd;
78  }
79  } else {
80  return chamberType < c.chamberType;
81  }
82  }
83 
85  };
86 
87  struct stripNum {
89  int iEta;
90  int stNum;
91  bool operator<(const stripNum& s) const {
92  if (chamberType == s.chamberType) {
93  if (iEta == s.iEta) {
94  return stNum < s.stNum;
95  } else {
96  return iEta < s.iEta;
97  }
98  } else {
99  return chamberType < s.chamberType;
100  }
101  }
102 
104  };
105 
106  GEMChMap();
107 
108  explicit GEMChMap(const std::string& version);
109 
110  ~GEMChMap();
111 
112  const std::string& version() const;
113  void setDummy();
114 
115  std::map<chamEC, chamDC> chamberMap() { return chamberMap_; };
116 
117  bool isValidAMC(unsigned int fedId, uint8_t amcNum) const {
118  return std::find(amcVec_.begin(), amcVec_.end(), sectorEC({fedId, amcNum})) != amcVec_.end();
119  }
120 
121  bool isValidChamber(unsigned int fedId, uint8_t amcNum, uint16_t gebId) const {
122  return chamberMap_.find({fedId, amcNum, gebId}) != chamberMap_.end();
123  }
124 
125  bool isValidVFAT(int chamberType, uint16_t vfatAdd) const {
126  return chamIEtas_.find({chamberType, vfatAdd}) != chamIEtas_.end();
127  }
128 
129  bool isValidStrip(int chamberType, int iEta, int strip) const {
130  return stChMap_.find({chamberType, iEta, strip}) != stChMap_.end();
131  }
132 
133  void add(sectorEC e) { amcVec_.push_back(e); }
134 
135  const chamDC& chamberPos(unsigned int fedId, uint8_t amcNum, uint16_t gebId) const {
136  return chamberMap_.at({fedId, amcNum, gebId});
137  }
138  void add(chamEC e, chamDC d) { chamberMap_[e] = d; }
139 
140  const std::vector<uint16_t> getVfats(const int type) const { return chamVfats_.at(type); }
141  void add(int type, uint16_t d) {
142  if (std::find(chamVfats_[type].begin(), chamVfats_[type].end(), d) != chamVfats_[type].end())
143  chamVfats_[type].push_back(d);
144  }
145 
146  const std::vector<int> getIEtas(int chamberType, uint16_t vfatAdd) const {
147  return chamIEtas_.at({chamberType, vfatAdd});
148  }
149  void add(vfatEC d, int iEta) {
150  if (std::find(chamIEtas_[d].begin(), chamIEtas_[d].end(), iEta) != chamIEtas_[d].end())
151  chamIEtas_[d].push_back(iEta);
152  }
153 
154  const channelNum& getChannel(int chamberType, int iEta, int strip) const {
155  return stChMap_.at({chamberType, iEta, strip});
156  }
157  const stripNum& getStrip(int chamberType, int vfatAdd, int channel) const {
158  return chStMap_.at({chamberType, vfatAdd, channel});
159  }
160 
161  void add(channelNum c, stripNum s) { chStMap_[c] = s; }
162  void add(stripNum s, channelNum c) { stChMap_[s] = c; }
163 
164 private:
166 
167  std::vector<sectorEC> amcVec_;
168 
169  // electronics map to GEMDetId chamber
170  std::map<chamEC, chamDC> chamberMap_;
171 
172  std::map<int, std::vector<uint16_t>> chamVfats_;
173  std::map<vfatEC, std::vector<int>> chamIEtas_;
174 
175  std::map<channelNum, stripNum> chStMap_;
176  std::map<stripNum, channelNum> stChMap_;
177 
179 
180 public:
181  // size of ID bits
182  static const int chipIdMask_ = 0xfff; // chipId mask for 12 bits
183  static const int maxGEBs_ = 24; // 5 bits for GEB id
184  static const int maxGEB1_ = 12; // 5 bits for GEB id
185  static const int maxGEB2_ = 12; // 5 bits for GEB id
186  static const int maxAMCs_ = 15; // 4 bits for AMC no.
187  static const int maxVFatGE0_ = 12; // vFat per eta partition, not known yet for ME0
188  static const int maxVFatGE11_ = 3; // vFat per eta partition in GE11
189  static const int maxVFatGE21_ = 6; // vFat per eta partition in GE21
190  static const int maxiEtaIdGE0_ = 8; // no. eta partitions for GE0
191  static const int maxiEtaIdGE11_ = 8; // no. eta partitions for GE11
192  static const int maxiEtaIdGE21_ = 16; // no. eta partitions for GE21
193  static const int maxChan_ = 128; // channels per vFat
194 };
195 #endif // GEMChMap_H
static const int chipIdMask_
Definition: GEMChMap.h:182
void add(stripNum s, channelNum c)
Definition: GEMChMap.h:162
unsigned int fedId
Definition: GEMChMap.h:28
const stripNum & getStrip(int chamberType, int vfatAdd, int channel) const
Definition: GEMChMap.h:157
const edm::EventSetup & c
const std::vector< int > getIEtas(int chamberType, uint16_t vfatAdd) const
Definition: GEMChMap.h:146
const channelNum & getChannel(int chamberType, int iEta, int strip) const
Definition: GEMChMap.h:154
GEMChMap()
Definition: GEMChMap.cc:5
const std::string & version() const
Definition: GEMChMap.cc:11
uint32_t detId
Definition: GEMChMap.h:47
bool isValidChamber(unsigned int fedId, uint8_t amcNum, uint16_t gebId) const
Definition: GEMChMap.h:121
std::map< chamEC, chamDC > chamberMap_
Definition: GEMChMap.h:170
std::map< chamEC, chamDC > chamberMap()
Definition: GEMChMap.h:115
void add(vfatEC d, int iEta)
Definition: GEMChMap.h:149
std::map< stripNum, channelNum > stChMap_
Definition: GEMChMap.h:176
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:165
unsigned int fedId
Definition: GEMChMap.h:14
static const int maxiEtaIdGE0_
Definition: GEMChMap.h:190
std::map< int, std::vector< uint16_t > > chamVfats_
Definition: GEMChMap.h:172
static const int maxiEtaIdGE21_
Definition: GEMChMap.h:192
bool isValidAMC(unsigned int fedId, uint8_t amcNum) const
Definition: GEMChMap.h:117
static const int maxGEB1_
Definition: GEMChMap.h:184
tuple d
Definition: ztail.py:151
bool operator<(const stripNum &s) const
Definition: GEMChMap.h:91
~GEMChMap()
Definition: GEMChMap.cc:9
bool isValidStrip(int chamberType, int iEta, int strip) const
Definition: GEMChMap.h:129
uint16_t gebId
Definition: GEMChMap.h:30
void add(channelNum c, stripNum s)
Definition: GEMChMap.h:161
static const int maxGEB2_
Definition: GEMChMap.h:185
bool isValidVFAT(int chamberType, uint16_t vfatAdd) const
Definition: GEMChMap.h:125
std::map< channelNum, stripNum > chStMap_
Definition: GEMChMap.h:175
const chamDC & chamberPos(unsigned int fedId, uint8_t amcNum, uint16_t gebId) const
Definition: GEMChMap.h:135
bool operator<(const chamEC &r) const
Definition: GEMChMap.h:31
static const int maxGEBs_
Definition: GEMChMap.h:183
std::map< vfatEC, std::vector< int > > chamIEtas_
Definition: GEMChMap.h:173
uint8_t amcNum
Definition: GEMChMap.h:29
void add(sectorEC e)
Definition: GEMChMap.h:133
static const int maxVFatGE0_
Definition: GEMChMap.h:187
bool operator==(const sectorEC &r) const
Definition: GEMChMap.h:16
static const int maxChan_
Definition: GEMChMap.h:193
void add(int type, uint16_t d)
Definition: GEMChMap.h:141
static const int maxVFatGE11_
Definition: GEMChMap.h:188
#define COND_SERIALIZABLE
Definition: Serializable.h:39
static const int maxiEtaIdGE11_
Definition: GEMChMap.h:191
std::vector< sectorEC > amcVec_
Definition: GEMChMap.h:167
static const int maxAMCs_
Definition: GEMChMap.h:186
string end
Definition: dataset.py:937
bool operator<(const channelNum &c) const
Definition: GEMChMap.h:72
uint16_t vfatAdd
Definition: GEMChMap.h:56
bool operator<(const vfatEC &r) const
Definition: GEMChMap.h:57
void add(chamEC e, chamDC d)
Definition: GEMChMap.h:138
static const int maxVFatGE21_
Definition: GEMChMap.h:189
bool operator<(const chamDC &r) const
Definition: GEMChMap.h:49
void setDummy()
Definition: GEMChMap.cc:13
uint8_t amcNum
Definition: GEMChMap.h:15
const std::vector< uint16_t > getVfats(const int type) const
Definition: GEMChMap.h:140