CMS 3D CMS Logo

GEMROMapping.h
Go to the documentation of this file.
1 #ifndef CondFormats_GEMObjects_GEMROMapping_h
2 #define CondFormats_GEMObjects_GEMROMapping_h
4 #include <map>
5 #include <vector>
6 #include <algorithm>
7 
8 class GEMROMapping {
9  // EC electronics corrdinate
10  // DC GEMDetId corrdinate
11  // geb = GEM electronics board == OptoHybrid
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  };
24 
25  struct chamEC {
26  unsigned int fedId;
27  uint8_t amcNum;
28  uint8_t gebId;
29  bool operator<(const chamEC& r) const {
30  if (fedId == r.fedId) {
31  if (amcNum == r.amcNum) {
32  return gebId < r.gebId;
33  } else {
34  return amcNum < r.amcNum;
35  }
36  } else {
37  return fedId < r.fedId;
38  }
39  }
40  };
41 
42  struct chamDC {
44  int vfatVer;
45  bool operator<(const chamDC& r) const { return detId < r.detId; }
46  };
47 
48  struct vfatEC {
49  uint16_t vfatAdd;
51  bool operator<(const vfatEC& r) const {
52  if (vfatAdd == r.vfatAdd) {
53  return detId < r.detId;
54  } else {
55  return vfatAdd < r.vfatAdd;
56  }
57  }
58  };
59 
60  struct vfatDC {
61  int vfatType;
63  int localPhi;
64  bool operator<(const vfatDC& r) const {
65  if (vfatType == r.vfatType) {
66  if (detId == r.detId) {
67  return localPhi < r.localPhi;
68  } else {
69  return detId < r.detId;
70  }
71  } else {
72  return vfatType < r.vfatType;
73  }
74  }
75  };
76 
77  struct channelNum {
78  int vfatType;
79  int chNum;
80  bool operator<(const channelNum& c) const {
81  if (vfatType == c.vfatType)
82  return chNum < c.chNum;
83  else
84  return vfatType < c.vfatType;
85  }
86  };
87 
88  struct stripNum {
89  int vfatType;
90  int stNum;
91  bool operator<(const stripNum& s) const {
92  if (vfatType == s.vfatType)
93  return stNum < s.stNum;
94  else
95  return vfatType < s.vfatType;
96  }
97  };
98 
100 
101  bool isValidChipID(const vfatEC& r) const { return vfatMap_.find(r) != vfatMap_.end(); }
102  bool isValidChamber(const chamEC& r) const { return chamberMap_.find(r) != chamberMap_.end(); }
103 
104  bool isValidAMC(const sectorEC& r) const { return std::find(amcVec_.begin(), amcVec_.end(), r) != amcVec_.end(); }
105 
106  void add(sectorEC e) { amcVec_.push_back(e); }
107 
108  const chamDC& chamberPos(const chamEC& r) const { return chamberMap_.at(r); }
109  void add(chamEC e, chamDC d) { chamberMap_[e] = d; }
110 
111  const std::vector<vfatEC> getVfats(const GEMDetId& r) const { return chamVfats_.at(r); }
112  void add(GEMDetId e, vfatEC d) { chamVfats_[e].push_back(d); }
113 
114  const vfatDC& vfatPos(const vfatEC& r) const { return vfatMap_.at(r); }
115  void add(vfatEC e, vfatDC d) { vfatMap_[e] = d; }
116 
117  const channelNum& hitPos(const stripNum& s) const { return stChMap_.at(s); }
118  const stripNum& hitPos(const channelNum& c) const { return chStMap_.at(c); }
119 
120  void add(channelNum c, stripNum s) { chStMap_[c] = s; }
121  void add(stripNum s, channelNum c) { stChMap_[s] = c; }
122 
123 private:
124  std::vector<sectorEC> amcVec_;
125 
126  // electronics map to GEMDetId chamber
127  std::map<chamEC, chamDC> chamberMap_;
128 
129  std::map<GEMDetId, std::vector<vfatEC>> chamVfats_;
130 
131  std::map<vfatEC, vfatDC> vfatMap_;
132 
133  std::map<channelNum, stripNum> chStMap_;
134  std::map<stripNum, channelNum> stChMap_;
135 };
136 #endif
void add(channelNum c, stripNum s)
Definition: GEMROMapping.h:120
void add(stripNum s, channelNum c)
Definition: GEMROMapping.h:121
std::map< stripNum, channelNum > stChMap_
Definition: GEMROMapping.h:134
bool operator<(const vfatDC &r) const
Definition: GEMROMapping.h:64
const stripNum & hitPos(const channelNum &c) const
Definition: GEMROMapping.h:118
void add(chamEC e, chamDC d)
Definition: GEMROMapping.h:109
unsigned int fedId
Definition: GEMROMapping.h:26
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::map< chamEC, chamDC > chamberMap_
Definition: GEMROMapping.h:127
bool operator<(const vfatEC &r) const
Definition: GEMROMapping.h:51
bool isValidChipID(const vfatEC &r) const
Definition: GEMROMapping.h:101
void add(sectorEC e)
Definition: GEMROMapping.h:106
d
Definition: ztail.py:151
bool isValidChamber(const chamEC &r) const
Definition: GEMROMapping.h:102
void add(GEMDetId e, vfatEC d)
Definition: GEMROMapping.h:112
std::map< GEMDetId, std::vector< vfatEC > > chamVfats_
Definition: GEMROMapping.h:129
const std::vector< vfatEC > getVfats(const GEMDetId &r) const
Definition: GEMROMapping.h:111
bool operator==(const sectorEC &r) const
Definition: GEMROMapping.h:16
std::vector< sectorEC > amcVec_
Definition: GEMROMapping.h:124
const vfatDC & vfatPos(const vfatEC &r) const
Definition: GEMROMapping.h:114
bool operator<(const chamDC &r) const
Definition: GEMROMapping.h:45
bool operator<(const stripNum &s) const
Definition: GEMROMapping.h:91
bool operator<(const chamEC &r) const
Definition: GEMROMapping.h:29
const chamDC & chamberPos(const chamEC &r) const
Definition: GEMROMapping.h:108
std::map< channelNum, stripNum > chStMap_
Definition: GEMROMapping.h:133
std::map< vfatEC, vfatDC > vfatMap_
Definition: GEMROMapping.h:131
bool operator<(const channelNum &c) const
Definition: GEMROMapping.h:80
bool isValidAMC(const sectorEC &r) const
Definition: GEMROMapping.h:104
const channelNum & hitPos(const stripNum &s) const
Definition: GEMROMapping.h:117
void add(vfatEC e, vfatDC d)
Definition: GEMROMapping.h:115