Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-23 02:25:20

0001 #include "CondFormats/GEMObjects/interface/GEMeMap.h"
0002 #include "CondFormats/GEMObjects/interface/GEMROMapping.h"
0003 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
0004 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0005 
0006 GEMeMap::GEMeMap() : theVersion("") {}
0007 
0008 GEMeMap::GEMeMap(const std::string& version) : theVersion(version) {}
0009 
0010 GEMeMap::~GEMeMap() {}
0011 
0012 const std::string& GEMeMap::version() const { return theVersion; }
0013 
0014 void GEMeMap::convert(GEMROMapping& romap) {
0015   // fed->amc->geb mapping to GEMDetId
0016   for (auto imap : theChamberMap_) {
0017     for (unsigned int ix = 0; ix < imap.fedId.size(); ix++) {
0018       GEMROMapping::chamEC ec{imap.fedId[ix], imap.amcNum[ix], imap.gebId[ix]};
0019       GEMROMapping::chamDC dc;
0020       dc.detId = GEMDetId((imap.gemNum[ix] > 0) ? 1 : -1,
0021                           1,
0022                           abs(imap.gemNum[ix] / 1000),
0023                           abs(imap.gemNum[ix] / 100 % 10),
0024                           abs(imap.gemNum[ix] % 100),
0025                           0);
0026       dc.vfatVer = imap.vfatVer[ix];
0027       romap.add(ec, dc);
0028       GEMROMapping::sectorEC amcEC = {imap.fedId[ix], imap.amcNum[ix]};
0029       if (!romap.isValidAMC(amcEC))
0030         romap.add(amcEC);
0031     }
0032   }
0033 
0034   // chamberType to vfatType
0035   for (auto imap : theVFatMap_) {
0036     for (unsigned int ix = 0; ix < imap.vfatAdd.size(); ix++) {
0037       GEMDetId gemId((imap.gemNum[ix] > 0) ? 1 : -1,
0038                      1,
0039                      abs(imap.gemNum[ix] / 1000),
0040                      abs(imap.gemNum[ix] / 100 % 10),
0041                      abs(imap.gemNum[ix] % 100),
0042                      imap.iEta[ix]);
0043 
0044       GEMROMapping::vfatEC ec;
0045       ec.detId = gemId.chamberId();
0046       ec.vfatAdd = imap.vfatAdd[ix] & chipIdMask_;
0047 
0048       GEMROMapping::vfatDC dc;
0049       dc.vfatType = imap.vfatType[ix];
0050       dc.detId = gemId;
0051       dc.localPhi = imap.localPhi[ix];
0052 
0053       romap.add(ec, dc);
0054       romap.add(gemId.chamberId(), ec);
0055     }
0056   }
0057   // channel mapping
0058   for (auto imap : theStripMap_) {
0059     for (unsigned int ix = 0; ix < imap.vfatType.size(); ix++) {
0060       GEMROMapping::channelNum cMap;
0061       cMap.vfatType = imap.vfatType[ix];
0062       cMap.chNum = imap.vfatCh[ix];
0063 
0064       GEMROMapping::stripNum sMap;
0065       sMap.vfatType = imap.vfatType[ix];
0066       sMap.stNum = imap.vfatStrip[ix];
0067 
0068       romap.add(cMap, sMap);
0069       romap.add(sMap, cMap);
0070     }
0071   }
0072 }
0073 
0074 void GEMeMap::convertDummy(GEMROMapping& romap) {
0075   // 12 bits for vfat, 5 bits for geb, 8 bit long GLIB serial number
0076   unsigned int fedId = 0;
0077 
0078   for (int st = GEMDetId::minStationId0; st <= GEMDetId::maxStationId; ++st) {
0079     for (int re = -1; re <= 1; re = re + 2) {
0080       uint8_t amcNum = 1;  //amc
0081       uint8_t gebId = 0;
0082       int maxVFat = 0;
0083       int maxLayerId = GEMDetId::maxLayerId;
0084       int maxiEtaId = 0;
0085       if (st == 0) {
0086         maxVFat = maxVFatGE0_;
0087         fedId = (re == 1 ? FEDNumbering::MINGE0FEDID + 1 : FEDNumbering::MINGE0FEDID);
0088         maxLayerId = GEMDetId::maxLayerId0;
0089         maxiEtaId = maxiEtaIdGE0_;
0090       } else if (st == 1) {
0091         maxVFat = maxVFatGE11_;
0092         fedId = (re == 1 ? FEDNumbering::MINGEMFEDID + 1 : FEDNumbering::MINGEMFEDID);
0093         maxiEtaId = maxiEtaIdGE11_;
0094       } else if (st == 2) {
0095         maxVFat = maxVFatGE21_;
0096         fedId = (re == 1 ? FEDNumbering::MINGE21FEDID + 1 : FEDNumbering::MINGE21FEDID);
0097         maxiEtaId = maxiEtaIdGE21_;
0098       }
0099 
0100       for (int ch = 1; ch <= GEMDetId::maxChamberId; ++ch) {
0101         for (int ly = 1; ly <= maxLayerId; ++ly) {
0102           GEMDetId gemId(re, 1, st, ly, ch, 0);
0103 
0104           GEMROMapping::chamEC ec;
0105           ec.fedId = fedId;
0106           ec.gebId = gebId;
0107           ec.amcNum = amcNum;
0108 
0109           GEMROMapping::chamDC dc;
0110           dc.detId = gemId;
0111           dc.vfatVer = vfatVerV3_;
0112           romap.add(ec, dc);
0113 
0114           GEMROMapping::sectorEC amcEC = {fedId, amcNum};
0115           if (!romap.isValidAMC(amcEC))
0116             romap.add(amcEC);
0117 
0118           uint16_t chipPos = 0;
0119           for (int lphi = 0; lphi < maxVFat; ++lphi) {
0120             for (int ieta = 1; ieta <= maxiEtaId; ++ieta) {
0121               GEMROMapping::vfatEC vec;
0122               vec.vfatAdd = chipPos;
0123               vec.detId = gemId;
0124 
0125               GEMROMapping::vfatDC vdc;
0126               vdc.vfatType = vfatTypeV3_;  // > 10 is vfat v3
0127               vdc.detId = GEMDetId(re, 1, st, ly, ch, ieta);
0128               vdc.localPhi = lphi;
0129 
0130               romap.add(vec, vdc);
0131               romap.add(gemId.chamberId(), vec);
0132 
0133               chipPos++;
0134             }
0135           }
0136 
0137           // 5 bits for gebId
0138           if (st > 0 && gebId == maxGEB1_) {
0139             gebId = 0;
0140             amcNum += 2;  // only odd amc No. is used for GE11
0141           } else if (st == 0 && gebId == maxGEBs_) {
0142             gebId = 0;
0143             amcNum++;
0144           } else {
0145             // 1 geb per chamber
0146             gebId++;
0147           }
0148         }
0149       }
0150     }
0151   }
0152 
0153   for (int i = 0; i < maxChan_; ++i) {
0154     // only 1 vfat type for dummy map
0155     GEMROMapping::channelNum cMap;
0156     cMap.vfatType = vfatTypeV3_;
0157     cMap.chNum = i;
0158 
0159     GEMROMapping::stripNum sMap;
0160     sMap.vfatType = vfatTypeV3_;
0161     sMap.stNum = i;
0162 
0163     romap.add(cMap, sMap);
0164     romap.add(sMap, cMap);
0165   }
0166 }