File indexing completed on 2025-03-05 03:16:36
0001 #ifndef L1Trigger_L1TGEM_ME0StubAlgoSubfunction_H
0002 #define L1Trigger_L1TGEM_ME0StubAlgoSubfunction_H
0003
0004 #include <cmath>
0005 #include <vector>
0006 #include <map>
0007 #include <cstdint>
0008 #include <algorithm>
0009 #include <bitset>
0010 #include <iostream>
0011 #include <numeric>
0012 #include "L1Trigger/L1TGEM/interface/ME0StubPrimitive.h"
0013
0014 namespace l1t {
0015 namespace me0 {
0016 typedef std::bitset<192> UInt192;
0017
0018 struct Config {
0019 bool skipCentroids;
0020 std::vector<int32_t> layerThresholdPatternId;
0021 std::vector<int32_t> layerThresholdEta;
0022 int32_t maxSpan;
0023 int32_t width;
0024 bool deghostPre;
0025 bool deghostPost;
0026 int32_t groupWidth;
0027 int32_t ghostWidth;
0028 bool xPartitionEnabled;
0029 bool enableNonPointing;
0030 int32_t crossPartitionSegmentWidth;
0031 int32_t numOutputs;
0032 bool checkIds;
0033 int32_t edgeDistance;
0034 int32_t numOr;
0035 };
0036
0037 class HiLo {
0038 private:
0039 public:
0040 int hi, lo;
0041 HiLo(int hi, int lo) : hi(hi), lo(lo) {}
0042 };
0043
0044 class PatternDefinition {
0045 private:
0046 public:
0047 int id;
0048 std::vector<HiLo> layers;
0049 PatternDefinition(int id, std::vector<HiLo> layers) : id(id), layers(layers) {}
0050 };
0051
0052 class Mask {
0053 private:
0054 public:
0055 int id;
0056 std::vector<uint64_t> mask;
0057 Mask(int id, std::vector<uint64_t> mask) : id(id), mask(mask) {}
0058 std::string toString() const;
0059 };
0060
0061 HiLo mirrorHiLo(const HiLo& layer);
0062 PatternDefinition mirrorPatternDefinition(const PatternDefinition& pattern, int id);
0063 std::vector<HiLo> createPatternLayer(double lower, double upper);
0064
0065 int countOnes(uint64_t x);
0066 int maxClusterSize(uint64_t x);
0067 UInt192 setBit(int index, UInt192 num);
0068 UInt192 clearBit(int index, UInt192 num);
0069 uint64_t oneBitMask(int num);
0070 std::vector<int> findOnes(uint64_t& data);
0071 std::pair<double, std::vector<int>> findCentroid(uint64_t& data);
0072 std::vector<std::vector<ME0StubPrimitive>> chunk(const std::vector<ME0StubPrimitive>& inList, int n);
0073 void segmentSorter(std::vector<ME0StubPrimitive>& segments, int n);
0074 std::vector<int> concatVector(const std::vector<std::vector<int>>& vec);
0075 std::vector<ME0StubPrimitive> concatVector(const std::vector<std::vector<ME0StubPrimitive>>& vec);
0076 }
0077 }
0078 #endif