File indexing completed on 2024-04-06 12:21:11
0001
0002
0003
0004
0005
0006
0007
0008 #include "L1Trigger/L1TMuonOverlapPhase1/interface/RpcClusterization.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010
0011 #include <cmath>
0012 #include <algorithm>
0013
0014 RpcClusterization::~RpcClusterization() {}
0015
0016 std::vector<RpcCluster> RpcClusterization::getClusters(const RPCDetId& roll, std::vector<RPCDigi>& digis) const {
0017 std::vector<RpcCluster> allClusters;
0018
0019 std::sort(digis.begin(), digis.end(), [](const RPCDigi& a, const RPCDigi& b) { return a.strip() < b.strip(); });
0020
0021 typedef std::pair<unsigned int, unsigned int> Cluster;
0022
0023
0024
0025
0026
0027
0028
0029 for (unsigned int iDigi = 0; iDigi < digis.size(); iDigi++) {
0030
0031
0032
0033
0034
0035 bool duplicatedDigi = false;
0036 for (unsigned int iDigi2 = 0; iDigi2 < iDigi; iDigi2++) {
0037 if (digis[iDigi].strip() == digis[iDigi2].strip()) {
0038 duplicatedDigi = true;
0039
0040 break;
0041 }
0042 }
0043
0044 if (duplicatedDigi)
0045 continue;
0046
0047 bool addNewCluster = true;
0048
0049 for (auto& cluster : allClusters) {
0050 if (digis[iDigi].strip() - cluster.lastStrip == 1) {
0051 cluster.lastStrip = digis[iDigi].strip();
0052 addNewCluster = false;
0053 } else if (digis[iDigi].strip() - cluster.firstStrip == -1) {
0054 cluster.firstStrip = digis[iDigi].strip();
0055 addNewCluster = false;
0056 } else if (digis[iDigi].strip() >= cluster.firstStrip && digis[iDigi].strip() <= cluster.lastStrip) {
0057 addNewCluster = false;
0058 }
0059 }
0060
0061 if (addNewCluster) {
0062 allClusters.emplace_back(digis[iDigi].strip(), digis[iDigi].strip());
0063 allClusters.back().bx = digis[iDigi].bx();
0064 allClusters.back().timing = convertTiming(digis[iDigi].time());
0065 }
0066 }
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076 return allClusters;
0077 }
0078
0079 int RpcClusterization::convertTiming(double timing) const {
0080 return timing;
0081 }