Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:31

0001 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTORCAMap.h"
0002 
0003 #include <vector>
0004 using std::vector;
0005 
0006 L1RCTORCAMap::L1RCTORCAMap() {
0007   rawEMET = std::vector<unsigned short>(56 * 72);
0008   rawHDET = std::vector<unsigned short>(56 * 72);
0009   rawEMFG = std::vector<unsigned short>(56 * 72);
0010   rawHDFG = std::vector<unsigned short>(56 * 72);
0011   rawHFET = std::vector<unsigned short>(8 * 18);
0012   combEM = std::vector<unsigned short>(56 * 72);
0013   combHD = std::vector<unsigned short>(56 * 72);
0014 
0015   barrelData = std::vector<std::vector<std::vector<unsigned short>>>(
0016       18, std::vector<std::vector<unsigned short>>(7, std::vector<unsigned short>(64)));
0017   hfData = std::vector<std::vector<unsigned short>>(18, std::vector<unsigned short>(8));
0018 }
0019 vector<std::vector<std::vector<unsigned short>>> L1RCTORCAMap::giveBarrel() { return barrelData; }
0020 
0021 vector<std::vector<unsigned short>> L1RCTORCAMap::giveHF() { return hfData; }
0022 void L1RCTORCAMap::makeHFData() {
0023   std::vector<unsigned short> crate(16);
0024   for (int i = 0; i < 9; i++) {
0025     for (int j = 0; j < 16; j++) {
0026       crate.at(j) = rawHFET.at(16 * i + j);
0027     }
0028     hfData.at(i) = crate;
0029   }
0030 }
0031 
0032 void L1RCTORCAMap::makeBarrelData() {
0033   std::vector<int> indices;
0034   for (int phi = 0; phi < 72; phi++) {
0035     for (int eta = 0; eta < 56; eta++) {
0036       indices = orcamap(eta, phi);
0037       (barrelData.at(indices.at(0))).at(indices.at(1)).at(indices.at(2)) = combEM.at(phi * 56 + eta);
0038       (barrelData.at(indices.at(0))).at(indices.at(1)).at(indices.at(2) + 32) = combHD.at(phi * 56 + eta);
0039     }
0040   }
0041 }
0042 
0043 void L1RCTORCAMap::readData(const std::vector<unsigned> &emet,
0044                             const std::vector<unsigned> &hdet,
0045                             const std::vector<bool> &emfg,
0046                             const std::vector<bool> &hdfg,
0047                             const std::vector<unsigned> &hfet) {
0048   for (int i = 0; i < 4032; i++) {
0049     rawEMET.at(i) = emet.at(i);
0050     rawHDET.at(i) = hdet.at(i);
0051     rawEMFG.at(i) = emfg.at(i);
0052     rawHDFG.at(i) = hdfg.at(i);
0053   }
0054   for (int i = 0; i < 144; i++)
0055     rawHFET.at(i) = hfet.at(i);
0056 
0057   combEM = combVec(rawEMET, rawEMFG);
0058   combHD = combVec(rawHDET, rawHDFG);
0059 
0060   makeBarrelData();
0061   makeHFData();
0062 }
0063 
0064 unsigned short L1RCTORCAMap::combine(unsigned short et, unsigned short fg) {
0065   unsigned short newfg = fg << 8;
0066   return newfg + et;
0067 }
0068 
0069 vector<unsigned short> L1RCTORCAMap::combVec(const std::vector<unsigned short> &et,
0070                                              const std::vector<unsigned short> &fg) {
0071   std::vector<unsigned short> comb(56 * 72);
0072   for (int i = 0; i < (int)et.size(); i++)
0073     comb.at(i) = combine(et.at(i), fg.at(i));
0074   return comb;
0075 }
0076 
0077 vector<int> L1RCTORCAMap::orcamap(int eta, int phi) {
0078   int crateNum(20);
0079   std::vector<int> cardTower(2, 0);
0080   std::vector<int> returnVec(3, 0);
0081   int modEta = eta % 28;
0082   int modPhi = phi % 8;
0083   if (phi < 8)
0084     crateNum = 0;
0085   else if (phi < 16)
0086     crateNum = 1;
0087   else if (phi < 24)
0088     crateNum = 2;
0089   else if (phi < 32)
0090     crateNum = 3;
0091   else if (phi < 40)
0092     crateNum = 4;
0093   else if (phi < 48)
0094     crateNum = 5;
0095   else if (phi < 56)
0096     crateNum = 6;
0097   else if (phi < 64)
0098     crateNum = 7;
0099   else if (phi < 72)
0100     crateNum = 8;
0101 
0102   if (eta < 28)
0103     cardTower = lowEtaMap(modEta, modPhi);
0104   else {
0105     cardTower = highEtaMap(modEta, modPhi);
0106     crateNum = crateNum + 9;
0107   }
0108 
0109   returnVec.at(0) = crateNum;
0110   for (int i = 0; i < 2; i++) {
0111     returnVec.at(i + 1) = cardTower.at(i);
0112   }
0113   return returnVec;
0114 }
0115 
0116 vector<int> L1RCTORCAMap::lowEtaMap(int eta, int phi) {
0117   int cardnum = 0;
0118   int towernum = 0;
0119   std::vector<int> returnVec(2);
0120   if (eta < 4) {
0121     cardnum = 6;
0122     if (phi < 4)
0123       towernum = (3 - eta) * 4 + phi;
0124     else
0125       towernum = eta * 4 + phi + 12;
0126   } else if (eta < 12) {
0127     if (phi < 4) {
0128       cardnum = 4;
0129       if (eta < 8)
0130         towernum = (7 - eta) * 4 + phi + 16;
0131       else
0132         towernum = (11 - eta) * 4 + phi;
0133     } else {
0134       cardnum = 5;
0135       if (eta < 8)
0136         towernum = (7 - eta) * 4 + (phi - 4) + 16;
0137       else
0138         towernum = (11 - eta) * 4 + (phi - 4);
0139     }
0140   } else if (eta < 20) {
0141     if (phi < 4) {
0142       cardnum = 2;
0143       if (eta < 16)
0144         towernum = (15 - eta) * 4 + phi + 16;
0145       else
0146         towernum = (19 - eta) * 4 + phi;
0147     } else {
0148       cardnum = 3;
0149       if (eta < 16)
0150         towernum = (15 - eta) * 4 + (phi - 4) + 16;
0151       else
0152         towernum = (19 - eta) * 4 + (phi - 4);
0153     }
0154   } else if (eta < 28) {
0155     if (phi < 4) {
0156       cardnum = 0;
0157       if (eta < 24)
0158         towernum = (23 - eta) * 4 + phi + 16;
0159       else
0160         towernum = (27 - eta) * 4 + phi;
0161     } else {
0162       cardnum = 1;
0163       if (eta < 24)
0164         towernum = (23 - eta) * 4 + (phi - 4) + 16;
0165       else
0166         towernum = (27 - eta) * 4 + (phi - 4);
0167     }
0168   }
0169 
0170   returnVec.at(0) = cardnum;
0171   returnVec.at(1) = towernum;
0172   return returnVec;
0173 }
0174 
0175 vector<int> L1RCTORCAMap::highEtaMap(int eta, int phi) {
0176   int cardnum;
0177   int towernum;
0178   std::vector<int> returnVec(2);
0179   if (eta < 8) {
0180     if (phi < 4) {
0181       cardnum = 0;
0182       towernum = eta * 4 + phi;
0183     } else {
0184       cardnum = 1;
0185       towernum = eta * 4 + (phi - 4);
0186     }
0187   } else if (eta < 16) {
0188     if (phi < 4) {
0189       cardnum = 2;
0190       towernum = (eta - 8) * 4 + phi;
0191     } else {
0192       cardnum = 3;
0193       towernum = (eta - 8) * 4 + (phi - 4);
0194     }
0195   } else if (eta < 24) {
0196     if (phi < 4) {
0197       cardnum = 4;
0198       towernum = (eta - 16) * 4 + phi;
0199     } else {
0200       cardnum = 5;
0201       towernum = (eta - 16) * 4 + (phi - 4);
0202     }
0203   } else {
0204     cardnum = 6;
0205     if (phi < 4)
0206       towernum = (27 - eta) * 4 + phi;
0207     else
0208       towernum = (27 - eta) * 4 + phi + 12;
0209   }
0210 
0211   returnVec.at(0) = cardnum;
0212   returnVec.at(1) = towernum;
0213   return returnVec;
0214 }