Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:38

0001 #ifndef CondFormats_GEMObjects_GEMROMapping_h
0002 #define CondFormats_GEMObjects_GEMROMapping_h
0003 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
0004 #include <map>
0005 #include <vector>
0006 #include <algorithm>
0007 
0008 class GEMROMapping {
0009   // EC electronics corrdinate
0010   // DC GEMDetId corrdinate
0011   // geb = GEM electronics board == OptoHybrid
0012 public:
0013   struct sectorEC {
0014     unsigned int fedId;
0015     uint8_t amcNum;
0016     bool operator==(const sectorEC& r) const {
0017       if (fedId == r.fedId) {
0018         return amcNum == r.amcNum;
0019       } else {
0020         return false;
0021       }
0022     }
0023   };
0024 
0025   struct chamEC {
0026     unsigned int fedId;
0027     uint8_t amcNum;
0028     uint8_t gebId;
0029     bool operator<(const chamEC& r) const {
0030       if (fedId == r.fedId) {
0031         if (amcNum == r.amcNum) {
0032           return gebId < r.gebId;
0033         } else {
0034           return amcNum < r.amcNum;
0035         }
0036       } else {
0037         return fedId < r.fedId;
0038       }
0039     }
0040   };
0041 
0042   struct chamDC {
0043     GEMDetId detId;
0044     int vfatVer;
0045     bool operator<(const chamDC& r) const { return detId < r.detId; }
0046   };
0047 
0048   struct vfatEC {
0049     uint16_t vfatAdd;
0050     GEMDetId detId;
0051     bool operator<(const vfatEC& r) const {
0052       if (vfatAdd == r.vfatAdd) {
0053         return detId < r.detId;
0054       } else {
0055         return vfatAdd < r.vfatAdd;
0056       }
0057     }
0058   };
0059 
0060   struct vfatDC {
0061     int vfatType;
0062     GEMDetId detId;
0063     int localPhi;
0064     bool operator<(const vfatDC& r) const {
0065       if (vfatType == r.vfatType) {
0066         if (detId == r.detId) {
0067           return localPhi < r.localPhi;
0068         } else {
0069           return detId < r.detId;
0070         }
0071       } else {
0072         return vfatType < r.vfatType;
0073       }
0074     }
0075   };
0076 
0077   struct channelNum {
0078     int vfatType;
0079     int chNum;
0080     bool operator<(const channelNum& c) const {
0081       if (vfatType == c.vfatType)
0082         return chNum < c.chNum;
0083       else
0084         return vfatType < c.vfatType;
0085     }
0086   };
0087 
0088   struct stripNum {
0089     int vfatType;
0090     int stNum;
0091     bool operator<(const stripNum& s) const {
0092       if (vfatType == s.vfatType)
0093         return stNum < s.stNum;
0094       else
0095         return vfatType < s.vfatType;
0096     }
0097   };
0098 
0099   GEMROMapping() {}
0100 
0101   bool isValidChipID(const vfatEC& r) const { return vfatMap_.find(r) != vfatMap_.end(); }
0102   bool isValidChamber(const chamEC& r) const { return chamberMap_.find(r) != chamberMap_.end(); }
0103 
0104   bool isValidAMC(const sectorEC& r) const { return std::find(amcVec_.begin(), amcVec_.end(), r) != amcVec_.end(); }
0105 
0106   void add(sectorEC e) { amcVec_.push_back(e); }
0107 
0108   const chamDC& chamberPos(const chamEC& r) const { return chamberMap_.at(r); }
0109   void add(chamEC e, chamDC d) { chamberMap_[e] = d; }
0110 
0111   const std::vector<vfatEC> getVfats(const GEMDetId& r) const { return chamVfats_.at(r); }
0112   void add(GEMDetId e, vfatEC d) { chamVfats_[e].push_back(d); }
0113 
0114   const vfatDC& vfatPos(const vfatEC& r) const { return vfatMap_.at(r); }
0115   void add(vfatEC e, vfatDC d) { vfatMap_[e] = d; }
0116 
0117   const channelNum& hitPos(const stripNum& s) const { return stChMap_.at(s); }
0118   const stripNum& hitPos(const channelNum& c) const { return chStMap_.at(c); }
0119 
0120   void add(channelNum c, stripNum s) { chStMap_[c] = s; }
0121   void add(stripNum s, channelNum c) { stChMap_[s] = c; }
0122 
0123 private:
0124   std::vector<sectorEC> amcVec_;
0125 
0126   // electronics map to GEMDetId chamber
0127   std::map<chamEC, chamDC> chamberMap_;
0128 
0129   std::map<GEMDetId, std::vector<vfatEC>> chamVfats_;
0130 
0131   std::map<vfatEC, vfatDC> vfatMap_;
0132 
0133   std::map<channelNum, stripNum> chStMap_;
0134   std::map<stripNum, channelNum> stChMap_;
0135 };
0136 #endif