Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:12

0001 #ifndef CondFormats_GEMObjects_GEMROmap_h
0002 #define CondFormats_GEMObjects_GEMROmap_h
0003 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
0004 #include <map>
0005 
0006 class GEMROmap {
0007 public:
0008   struct eCoord {
0009     uint16_t amcId;
0010     uint16_t gebId;
0011     uint16_t vfatId;
0012     bool operator<(const eCoord& r) const {
0013       if (amcId == r.amcId) {
0014         if (gebId == r.gebId) {
0015           return vfatId < r.vfatId;
0016         } else {
0017           return gebId < r.gebId;
0018         }
0019       } else {
0020         return amcId < r.amcId;
0021       }
0022     }
0023   };
0024 
0025   struct dCoord {
0026     int vfatType;
0027     GEMDetId gemDetId;
0028     int iPhi;
0029     bool operator<(const dCoord& r) const {
0030       if (vfatType == r.vfatType) {
0031         if (gemDetId == r.gemDetId) {
0032           return iPhi < r.iPhi;
0033         } else {
0034           return gemDetId < r.gemDetId;
0035         }
0036       } else {
0037         return vfatType < r.vfatType;
0038       }
0039     }
0040   };
0041 
0042   struct channelNum {
0043     int vfatType;
0044     int chNum;
0045     bool operator<(const channelNum& c) const {
0046       if (vfatType == c.vfatType)
0047         return chNum < c.chNum;
0048       else
0049         return vfatType < c.vfatType;
0050     }
0051   };
0052 
0053   struct stripNum {
0054     int vfatType;
0055     int stNum;
0056     bool operator<(const stripNum& s) const {
0057       if (vfatType == s.vfatType)
0058         return stNum < s.stNum;
0059       else
0060         return vfatType < s.vfatType;
0061     }
0062   };
0063 
0064   GEMROmap(){};
0065 
0066   bool isValidChipID(const eCoord& r) const { return roMapED_.find(r) != roMapED_.end(); }
0067   const dCoord& hitPosition(const eCoord& r) const { return roMapED_.at(r); }
0068   const eCoord& hitPosition(const dCoord& r) const { return roMapDE_.at(r); }
0069 
0070   void add(eCoord e, dCoord d) { roMapED_[e] = d; }
0071   void add(dCoord d, eCoord e) { roMapDE_[d] = e; }
0072 
0073   const std::map<eCoord, dCoord>* getRoMap() const { return &roMapED_; }
0074 
0075   void add(channelNum c, stripNum s) { chStMap_[c] = s; }
0076   void add(stripNum s, channelNum c) { stChMap_[s] = c; }
0077 
0078   const channelNum& hitPosition(const stripNum& s) const { return stChMap_.at(s); }
0079   const stripNum& hitPosition(const channelNum& c) const { return chStMap_.at(c); }
0080 
0081 private:
0082   std::map<eCoord, dCoord> roMapED_;
0083   std::map<dCoord, eCoord> roMapDE_;
0084 
0085   std::map<channelNum, stripNum> chStMap_;
0086   std::map<stripNum, channelNum> stChMap_;
0087 };
0088 #endif