Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-03-05 03:16:36

0001 #include "L1Trigger/L1TGEM/interface/ME0StubAlgoMask.h"
0002 
0003 using namespace l1t::me0;
0004 
0005 std::vector<int> l1t::me0::shiftCenter(const HiLo& layer, int maxSpan) {
0006   /*
0007     Patterns are defined as a +hi and -lo around a center point of a pattern.
0008 
0009     e.g. for a pattern 37 strips wide, there is a central strip,
0010     and 18 strips to the left and right of it.
0011 
0012     This patterns shifts from a +hi and -lo around the central strip, to an offset +hi and -lo.
0013 
0014     e.g. for (hi, lo) = (1, -1) and a window of 37, this will return (17,19)
0015   */
0016   int center = std::floor(maxSpan / 2);
0017   int hi = layer.hi + center;
0018   int lo = layer.lo + center;
0019   std::vector<int> out = {lo, hi};
0020   return out;
0021 }
0022 
0023 uint64_t l1t::me0::setHighBits(const std::vector<int>& loHiPair) {
0024   /*
0025     Given a high bit and low bit, this function will return a bitmask with all the bits in
0026     between the high and low set to 1
0027   */
0028   int lo = loHiPair[0], hi = loHiPair[1];
0029   uint64_t out = std::pow(2, (hi - lo + 1)) - 1;
0030   out <<= lo;
0031   return out;
0032 }
0033 
0034 Mask l1t::me0::getLayerMask(const PatternDefinition& layerPattern, int maxSpan) {
0035   /*
0036     takes in a given layer pattern and returns a list of integer bit masks
0037     for each layer
0038   */
0039   std::vector<std::vector<int>> mVals;
0040   std::vector<uint64_t> mVec;
0041 
0042   // for each layer, shift the provided hi and lo values for each layer from
0043   // pattern definition by center
0044   mVals.reserve(layerPattern.layers.size());
0045   for (HiLo layer : layerPattern.layers) {
0046     mVals.push_back(shiftCenter(layer, maxSpan));
0047   }
0048 
0049   // use the high and low indices to determine where the high bits must go for
0050   // each layer
0051   mVec.reserve(mVals.size());
0052   for (const std::vector<int>& x : mVals) {
0053     mVec.push_back(setHighBits(x));
0054   }
0055 
0056   Mask mask_{layerPattern.id, mVec};
0057   return mask_;
0058 }