Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-03 01:58:09

0001 #ifndef UCTGeometry_hh
0002 #define UCTGeometry_hh
0003 
0004 // UCT Geometric mapping between EB+EE/HB+HE & HF TPGs to CPT7s
0005 // Access methods check if the mapping is correct
0006 // Access methods also allow conversion of TPG to CTP7 mapping
0007 // This class only has functions and defintions, no local memory
0008 
0009 /*
0010     
0011   Crate Eta mapping:
0012 
0013   eta:      -5 ... -4 ... -3 ... -2 ... -1 ... 0 ... 1 ... 2 ...  3 ...  4 ...  5
0014   absIEta:  41   ...  30(29)28     ...        1 1     ...       28(29)30   ... 41
0015   region:   12 11 10  9  8  7  6  5  4 3 2 1  0 0 1 2  3  4   5  6 7 8 9 10 11 12
0016 
0017   For EB/EE towers we have 8-bit ET + 1-bit finegrain input
0018   For HB/HE towers we have 8-bit ET + 5-bit feature (TBD)
0019   For HF only 8-bits ET per input tower
0020 
0021   Each EB/HB+EE/HE regions are 4x4 == ~0.35 x 0.35 iEta x iPhi wide
0022 
0023   Calo TPG eta index is 1 through 28 for EB/HB+EE/HE
0024   Note that tower 29 is unused in trigger as it shadows portion of HE
0025   Corresponding negative values are for negative eta
0026 
0027   The uHTR HF eta index is 30-41 for 12 divisions in eta between 3-5
0028   Note that eta=30-39 are 10-degree phi towers.  However, Layer2 wants the same
0029   5-degree phi towers as in 1-28.  Therefore, we make artificial splitting for
0030   output.  For eta=40,42 we take 20-degree phi tower and split four ways !
0031 
0032   In the HF region size is proposed as 2x4 HF towers in etaxphi == 0.33 x 0.35,
0033   where the phi division of x4 assumes above /2 and /4 splits.
0034 
0035 */
0036 
0037 #include <iostream>
0038 
0039 #include <utility>
0040 
0041 namespace l1tcalo {
0042   constexpr uint32_t NCrates{3};
0043   constexpr uint32_t NCardsInCrate{6};
0044   constexpr uint32_t NRegionsInCard{7};
0045   constexpr uint32_t NEtaInRegion{4};
0046   constexpr uint32_t NPhiInRegion{4};
0047   constexpr uint32_t NPhiInCard{
0048       NPhiInRegion};  // For convenience of Layer-2 we always have the same number of phi divisions
0049 
0050   constexpr uint32_t HFEtaOffset{NRegionsInCard * NEtaInRegion + 1};
0051   constexpr uint32_t NHFRegionsInCard{6};
0052   constexpr uint32_t NHFEtaInRegion{2};
0053 
0054   constexpr uint32_t NSides{2};  // Positive and Negative Eta sides
0055   constexpr uint32_t NEta{NRegionsInCard * NEtaInRegion};
0056   constexpr uint32_t NPhi{NCrates * NCardsInCrate * NPhiInRegion};
0057   constexpr uint32_t NHFEta{NHFRegionsInCard * NHFEtaInRegion};
0058   constexpr uint32_t NHFPhi{NCrates * NCardsInCrate * NPhiInRegion};
0059 
0060   constexpr uint32_t MaxCrateNumber{(NCrates - 1)};
0061   constexpr uint32_t MaxCardNumber{(NCardsInCrate - 1)};
0062   constexpr uint32_t MaxRegionNumber{(NRegionsInCard - 1)};
0063   constexpr uint32_t MaxEtaInRegion{(NEtaInRegion - 1)};
0064   constexpr uint32_t MaxPhiInRegion{(NPhiInRegion - 1)};
0065 
0066   constexpr int MaxCaloEta{41};
0067   constexpr int MaxCaloPhi{72};
0068   constexpr uint32_t CaloHFRegionStart{7};
0069   constexpr uint32_t CaloVHFRegionStart{12};
0070 
0071   constexpr uint32_t MaxUCTRegionsPhi{MaxCaloPhi / NPhiInRegion};
0072   constexpr uint32_t MaxUCTRegionsEta{NRegionsInCard +
0073                                       NHFRegionsInCard};  // Labelled -MaxUCTRegionsEta to +MaxUCTRegionsEta skipping 0
0074 
0075   // Binning for Layer1 calibration LUTs
0076   const uint32_t nEtBins = 256;
0077   const uint32_t nCalEtaBins = 28;
0078   const uint32_t nCalSideBins = 2;
0079   const uint32_t nHfEtaBins = 12;
0080 
0081 }  // namespace l1tcalo
0082 
0083 typedef std::pair<int, uint32_t> UCTRegionIndex;
0084 typedef std::pair<int, int> UCTTowerIndex;
0085 
0086 class UCTGeometry {
0087 public:
0088   UCTGeometry();
0089   ~UCTGeometry() = default;
0090 
0091   // Calorimeter indices are defined to be ints and do not count from zero
0092   // Eta index sign indicates negative or positive eta
0093   // The zero eta value is illegal
0094   // Phi indices go 1 through 72 and other values are illegal
0095 
0096   int getCaloEtaIndex(bool negativeSide, uint32_t region, uint32_t iEta);
0097   int getCaloPhiIndex(uint32_t crate, uint32_t card, uint32_t region, uint32_t iPhi);
0098 
0099   uint32_t getLinkNumber(bool negativeSide, uint32_t region, uint32_t iEta, uint32_t iPhi);
0100   uint32_t getChannelNumber(bool negativeSide, uint32_t iEta, uint32_t iPhi);
0101 
0102   uint32_t getNCrates() { return l1tcalo::NCrates; }
0103   uint32_t getNCards() { return l1tcalo::NCardsInCrate; }
0104   uint32_t getNRegions() { return (l1tcalo::NRegionsInCard + l1tcalo::NHFRegionsInCard); }
0105   uint32_t getNEta(uint32_t region);
0106   uint32_t getNPhi(uint32_t region);
0107 
0108   uint32_t getCrate(int caloEta, int caloPhi);
0109   uint32_t getCard(int caloEta, int caloPhi);
0110   uint32_t getRegion(int caloEta, int caloPhi);
0111   uint32_t getiEta(int caloEta);
0112   uint32_t getiPhi(int caloPhi);
0113   bool getNegativeSide(int caloEta) { return (caloEta < 0); }
0114 
0115   bool checkCrate(uint32_t crate) { return !(crate < l1tcalo::NCrates); }
0116   bool checkCard(uint32_t card) { return !(card < l1tcalo::NCardsInCrate); }
0117   bool checkRegion(uint32_t region) { return !(region < (l1tcalo::NRegionsInCard + l1tcalo::NHFRegionsInCard)); }
0118   bool checkEtaIndex(uint32_t region, uint32_t iEta) {
0119     if (region < l1tcalo::NRegionsInCard)
0120       return !(iEta < l1tcalo::NEtaInRegion);
0121     else
0122       return !(iEta < l1tcalo::NHFEtaInRegion);
0123   }
0124   bool checkPhiIndex(uint32_t region, uint32_t iPhi) { return !(iPhi < l1tcalo::NPhiInRegion); }
0125 
0126   // We label regions by phi and eta indices
0127   //  UCTRegionPhiIndices are 0-17
0128   //  UCTRegionEtaIndices are 1-7 for EB/HB+EE/HE and 8-13 for HF,
0129   //   with negative values for negative eta, and zero being illegal
0130   //  GCTRegionPhiIndices are the same
0131   //  GCTRegionEtaIndices are 4-10 for -7 thru -1 and 11-17 for 1 thru 7
0132   //  GCTRegionEtaIndices 0-3 are for -HF and 18-22 are for +HF, which are now unused!
0133   // We label by the pair (UCTRegionPhiIndex, UCTRegionEtaIndex)
0134 
0135   uint32_t getUCTRegionPhiIndex(int caloPhi) {
0136     if (caloPhi < 71)
0137       return ((caloPhi + 1) / 4);
0138     else if (caloPhi < 73)
0139       return 0;
0140     else
0141       return 0xDEADBEEF;
0142   }
0143   uint32_t getGCTRegionPhiIndex(int caloPhi) { return getUCTRegionPhiIndex(caloPhi); }
0144   uint32_t getGCTRegionPhiIndex(UCTRegionIndex r) { return r.second; }
0145 
0146   int getUCTRegionEtaIndex(int caloEta) {
0147     // Region index is same for all phi; so get for phi = 1
0148     uint32_t rgn = getRegion(caloEta, 1);
0149     if (caloEta < 0)
0150       return -(rgn + 1);
0151     return (rgn + 1);
0152   }
0153   uint32_t getGCTRegionEtaIndex(int caloEta) {
0154     uint32_t gctEta = 0xDEADBEEF;
0155     // Region index is same for all phi; so get for phi = 1
0156     uint32_t region = getRegion(caloEta, 1);
0157     if (caloEta > 0 && region < l1tcalo::NRegionsInCard)
0158       gctEta = region + 11;
0159     else if (caloEta < 0 && region < l1tcalo::NRegionsInCard)
0160       gctEta = 10 - region;
0161     return gctEta;
0162   }
0163   uint32_t getGCTRegionEtaIndex(UCTRegionIndex r) {
0164     uint32_t gctEta = 0xDEADBEEF;
0165     uint32_t region = std::abs(r.first) - 1;
0166     if (r.first > 0 && region < l1tcalo::NRegionsInCard)
0167       gctEta = region + 11;
0168     else if (r.first < 0 && region < l1tcalo::NRegionsInCard)
0169       gctEta = 10 - region;
0170     return gctEta;
0171   }
0172 
0173   uint32_t getUCTRegionPhiIndex(uint32_t crate, uint32_t card);
0174 
0175   int getUCTRegionEtaIndex(bool negativeSide, uint32_t region) {
0176     if (negativeSide)
0177       return -(region + 1);
0178     else
0179       return (region + 1);
0180   }
0181 
0182   UCTRegionIndex getUCTRegionIndex(UCTTowerIndex caloTower) {
0183     return getUCTRegionIndex(caloTower.first, caloTower.second);
0184   }
0185 
0186   UCTRegionIndex getUCTRegionIndex(int caloEta, int caloPhi);
0187 
0188   UCTRegionIndex getUCTRegionIndex(bool negativeSide, uint32_t crate, uint32_t card, uint32_t region);
0189 
0190   UCTTowerIndex getUCTTowerIndex(UCTRegionIndex r, uint32_t iEta = 0, uint32_t iPhi = 0);
0191 
0192   double getUCTTowerEta(int caloEta);
0193   double getUCTTowerPhi(int caloPhi);
0194 
0195   UCTRegionIndex getUCTRegionIndexFromL1CaloRegion(uint32_t caloRegionEta, uint32_t caloRegionPhi);
0196 
0197   UCTTowerIndex getUCTTowerIndexFromL1CaloRegion(UCTRegionIndex r, uint32_t rawData);
0198 
0199 private:
0200 };
0201 
0202 #endif