CMS 3D CMS Logo

RpcClusterization.cc
Go to the documentation of this file.
1 /*
2  * RpcClusterization.cpp
3  *
4  * Created on: Jan 14, 2019
5  * Author: kbunkow
6  */
7 
10 
11 #include <cmath>
12 #include <algorithm>
13 
15 
16 std::vector<RpcCluster> RpcClusterization::getClusters(const RPCDetId& roll, std::vector<RPCDigi>& digis) const {
17  std::vector<RpcCluster> allClusters;
18 
19  std::sort(digis.begin(), digis.end(), [](const RPCDigi& a, const RPCDigi& b) { return a.strip() < b.strip(); });
20 
21  typedef std::pair<unsigned int, unsigned int> Cluster;
22 
23  //This implementation of clusterization emulation gives the cluster in the same order as the order of digis,
24  //and the order of unpacked digis should be the same as the order of the LB channels on which the clustrization
25  //in the firmware is performed.
26  //This cluster order plays role in some rare cases for the OMTF algorithm
27  //when two hits has the same abs(minDistPhi), and then the phi of the resulting candidate
28  //depends on the order of these hits.
29  for (unsigned int iDigi = 0; iDigi < digis.size(); iDigi++) {
30  //edm::LogVerbatim("l1tOmtfEventPrint")<< __FUNCTION__ << ":" << __LINE__<<" "<<roll<<" iDigi "<<iDigi<<" digi "<<digis[iDigi];
31 
32  //removing duplicated digis
33  //the digis might be duplicated, because the same data might be received by two OMTF boards (as the same link goes to two neighboring boards)
34  //and the unpacker is not cleaning them
35  bool duplicatedDigi = false;
36  for (unsigned int iDigi2 = 0; iDigi2 < iDigi; iDigi2++) {
37  if (digis[iDigi].strip() == digis[iDigi2].strip()) {
38  duplicatedDigi = true;
39  //edm::LogVerbatim("l1tOmtfEventPrint")<<"duplicatedDigi";
40  break;
41  }
42  }
43 
44  if (duplicatedDigi)
45  continue;
46 
47  bool addNewCluster = true;
48 
49  for (auto& cluster : allClusters) {
50  if (digis[iDigi].strip() - cluster.lastStrip == 1) {
51  cluster.lastStrip = digis[iDigi].strip();
52  addNewCluster = false;
53  } else if (digis[iDigi].strip() - cluster.firstStrip == -1) {
54  cluster.firstStrip = digis[iDigi].strip();
55  addNewCluster = false;
56  } else if (digis[iDigi].strip() >= cluster.firstStrip && digis[iDigi].strip() <= cluster.lastStrip) {
57  addNewCluster = false;
58  }
59  }
60 
61  if (addNewCluster) {
62  allClusters.emplace_back(digis[iDigi].strip(), digis[iDigi].strip());
63  allClusters.back().bx = digis[iDigi].bx();
64  allClusters.back().timing = convertTiming(digis[iDigi].time());
65  }
66  }
67 
68  /* Debug only
69  if(allClusters.size())
70  edm::LogVerbatim("l1tOmtfEventPrint")<< __FUNCTION__ <<" "<<roll<<" allClusters.size() "<<allClusters.size();
71  for (auto& cluster : allClusters)
72  edm::LogVerbatim("l1tOmtfEventPrint")
73  << __FUNCTION__ << " cluster: firstStrip " << cluster.firstStrip
74  << " lastStrip " << cluster.lastStrip << " halfStrip " << cluster.halfStrip() << std::endl;*/
75 
76  return allClusters;
77 }
78 
80  return timing; //TODO implement
81 }
virtual int convertTiming(double timing) const
virtual ~RpcClusterization()
virtual std::vector< RpcCluster > getClusters(const RPCDetId &roll, std::vector< RPCDigi > &digis) const
N.B. digis are sorted inside the function.
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121