CMS 3D CMS Logo

RPCHitCleaner.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: RPCHitCleaner
4 //
5 // RPCHitCleaner
6 //
7 //
8 // Author :
9 // G. Flouris U Ioannina Mar. 2015
10 // modifications: G Karathanasis U Athens
11 //--------------------------------------------------
12 
13 #include <iostream>
14 #include <iomanip>
15 #include <iterator>
16 #include <cmath>
17 #include <map>
18 
25 
26 using namespace std;
27 
28 RPCHitCleaner::RPCHitCleaner(RPCDigiCollection const& inrpcDigis) : m_inrpcDigis{inrpcDigis} {}
29 
30 namespace {
31  constexpr int max_rpc_bx = 3;
32  constexpr int min_rpc_bx = -3;
33 
34  //Need to shift the index so that index 0
35  // corresponds to min_rpc_bx
36  class BxToStrips {
37  public:
38  BxToStrips() : m_strips{} {} //zero initializes
39 
40  static bool outOfRange(int iBX) { return (iBX > max_rpc_bx or iBX < min_rpc_bx); }
41 
42  int& operator[](int iBX) { return m_strips[iBX - min_rpc_bx]; }
43 
44  size_t size() const { return m_strips.size(); }
45 
46  private:
47  std::array<int, max_rpc_bx - min_rpc_bx + 1> m_strips;
48  };
49 } // namespace
50 
52  std::map<detId_Ext, int> hits;
53  vector<int> vcluster_size;
54  std::map<RPCDetId, int> bx_hits;
55 
56  int cluster_size = 0;
57  int cluster_id = -1;
58  int itr = 0;
59 
60  for (auto chamber = m_inrpcDigis.begin(); chamber != m_inrpcDigis.end(); ++chamber) {
61  RPCDetId detid = (*chamber).first;
62  int strip_n1 = -10000;
63  int bx_n1 = -10000;
64  if (detid.region() != 0)
65  continue; //Region = 0 Barrel
66  for (auto digi = (*chamber).second.first; digi != (*chamber).second.second; ++digi) {
67  if (fabs(digi->bx()) > 3)
68  continue;
70  //if((digi->strip()-1!=strip_n1) || digi->bx()!=bx_n1){
71  if (abs(digi->strip() - strip_n1) != 1 || digi->bx() != bx_n1) {
72  if (itr != 0)
73  vcluster_size.push_back(cluster_size);
74  cluster_size = 0;
75  cluster_id++;
76  }
77  itr++;
78  cluster_size++;
80  detId_Ext tmp{detid, digi->bx(), digi->strip()};
81  hits[tmp] = cluster_id;
83  strip_n1 = digi->strip();
84  bx_n1 = digi->bx();
85  }
86  }
87  vcluster_size.push_back(cluster_size);
88 
89  for (auto chamber = m_inrpcDigis.begin(); chamber != m_inrpcDigis.end(); ++chamber) {
90  RPCDetId detid = (*chamber).first;
91  if (detid.region() != 0)
92  continue; //Region = 0 Barrel
93  BxToStrips strips;
94  int cluster_n1 = -10;
95  bx_hits[detid] = 10;
96  //Keep cluster with min bx in a roll
97  for (auto digi = (*chamber).second.first; digi != (*chamber).second.second; ++digi) {
98  if (BxToStrips::outOfRange(digi->bx()))
99  continue;
100  //int cluster_id = hits[(detid.ring()+2)][(detid.station()-1)][(detid.sector()-1)][(detid.layer()-1)][(digi->bx()+2)][detid.roll()-1][digi->strip()];
101  detId_Ext tmp{detid, digi->bx(), digi->strip()};
102  int cluster_id = hits[tmp];
104  if (vcluster_size[cluster_id] >= 4)
105  continue;
106  if (bx_hits[detid] > digi->bx())
107  bx_hits[detid] = digi->bx();
108  }
109 
110  for (auto digi = (*chamber).second.first; digi != (*chamber).second.second; ++digi) {
111  if (fabs(digi->bx()) > 3)
112  continue;
113  detId_Ext tmp{detid, digi->bx(), digi->strip()};
114  int cluster_id = hits[tmp];
116  if (vcluster_size[cluster_id] >= 4)
117  continue;
119  if (digi->bx() != bx_hits[detid])
120  continue;
122  if (cluster_n1 != cluster_id) {
123  strips[digi->bx()] = {0};
124  }
125  strips[digi->bx()]++;
126  cluster_n1 = cluster_id;
127 
128  if (vcluster_size[cluster_id] == 3 && strips[digi->bx()] != 2)
129  continue;
131  RPCDigi digi_out(digi->strip(), digi->bx());
132  m_outrpcDigis.insertDigi(detid, digi_out);
133  }
134  }
135 }
size
Write out results.
RPCHitCleaner(RPCDigiCollection const &inrpcDigis)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
Definition: DigiDM_cff.py:32
RPCDigiCollection m_outrpcDigis
Output.
Definition: RPCHitCleaner.h:40
T operator[](int i) const
tmp
align.sh
Definition: createJobs.py:716
RPCDigiCollection const & m_inrpcDigis
Input.
Definition: RPCHitCleaner.h:38