CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  for (auto& digi : digis) {
24  if (allClusters.empty()) {
25  allClusters.emplace_back(digi.strip(), digi.strip());
26  allClusters.back().bx = digi.bx();
27  allClusters.back().timing = convertTiming(digi.time());
28  } else if (digi.strip() - allClusters.back().lastStrip == 1) {
29  allClusters.back().lastStrip = digi.strip();
30  //TODO update bx and timing in some smart way
31  } else if (digi.strip() - allClusters.back().lastStrip > 1) {
32  allClusters.emplace_back(digi.strip(), digi.strip());
33  allClusters.back().bx = digi.bx();
34  allClusters.back().timing = convertTiming(digi.time());
35  }
36  }
37 
38  std::vector<RpcCluster> filteredClusters;
39 
41  if (allClusters.size() > maxClusterCnt)
42  return filteredClusters;
43 
44  //debug printout only
45  if (allClusters.size() > maxClusterCnt) {
46  LogTrace("l1tOmtfEventPrint") << __FUNCTION__ << ":" << __LINE__ << " allClusters.size() >= maxClusterCnt "
47  << std::endl;
48  for (auto& cluster : allClusters)
49  edm::LogVerbatim("l1tOmtfEventPrint")
50  << __FUNCTION__ << ":" << __LINE__ << " roll " << roll << " cluster: firstStrip " << cluster.firstStrip
51  << " lastStrip " << cluster.lastStrip << " halfStrip " << cluster.halfStrip() << std::endl;
52  }
53 
54  //TODO this is very simple filtering of the cluster,
55  //unfortunately the in firmware it is more complicated and cannot be easily emulated from digi
56  //(in principle would required raws, because in the firmware the clusterizaton is based on the 8-bit strip partitions
57  for (auto& cluster : allClusters) {
58  if (cluster.size() <= maxClusterSize)
59  filteredClusters.emplace_back(cluster);
60 
61  if (filteredClusters.size() >= maxClusterCnt)
62  break;
63  }
64 
65  return filteredClusters;
66 }
67 
68 int RpcClusterization::convertTiming(double timing) const {
69  return timing; //TODO implement
70 }
Log< level::Info, true > LogVerbatim
virtual int convertTiming(double timing) const
#define LogTrace(id)
int strip() const
Definition: RPCDigi.h:27
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:118
double a
Definition: hdecay.h:119
unsigned int maxClusterCnt
unsigned int maxClusterSize