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 
30  m_inrpcDigis {inrpcDigis}
31 {
32 }
33 
34 namespace {
35  constexpr int max_rpc_bx = 3;
36  constexpr int min_rpc_bx = -3;
37 
38  //Need to shift the index so that index 0
39  // corresponds to min_rpc_bx
40  class BxToStrips {
41  public:
42  BxToStrips(): m_strips{} {} //zero initializes
43 
44  static bool outOfRange(int iBX) {
45  return (iBX > max_rpc_bx or iBX < min_rpc_bx) ;
46  }
47 
48  int& operator[](int iBX) {
49  return m_strips[iBX-min_rpc_bx];
50  }
51 
52  size_t size() const { return m_strips.size(); }
53  private:
54  std::array<int,max_rpc_bx-min_rpc_bx+1> m_strips;
55  };
56 }
57 
59 
60  std::map<detId_Ext, int> hits;
61  vector<int> vcluster_size;
62  std::map<RPCDetId, int> bx_hits;
63 
64  int cluster_size = 0;
65  int cluster_id = -1;
66  int itr=0;
67 
68  for( auto chamber = m_inrpcDigis.begin(); chamber != m_inrpcDigis.end(); ++chamber ){
69  RPCDetId detid = (*chamber).first;
70  int strip_n1 = -10000;
71  int bx_n1 = -10000;
72  if(detid.region()!=0 ) continue; //Region = 0 Barrel
73  for( auto digi = (*chamber).second.first ; digi != (*chamber).second.second; ++digi ) {
74  if(fabs(digi->bx())>3 ) continue;
76  //if((digi->strip()-1!=strip_n1) || digi->bx()!=bx_n1){
77  if( abs(digi->strip()-strip_n1)!=1 || digi->bx()!=bx_n1){
78  if(itr!=0)vcluster_size.push_back(cluster_size);
79  cluster_size = 0;
80  cluster_id++;
81  }
82  itr++;
83  cluster_size++;
85  detId_Ext tmp{detid,digi->bx(),digi->strip()};
86  hits[tmp] = cluster_id;
88  strip_n1 = digi->strip();
89  bx_n1 = digi->bx();
90  }
91  }
92  vcluster_size.push_back(cluster_size);
93 
94  for( auto chamber = m_inrpcDigis.begin(); chamber != m_inrpcDigis.end(); ++chamber ){
95  RPCDetId detid = (*chamber).first;
96  if(detid.region()!=0 ) continue; //Region = 0 Barrel
97  BxToStrips strips;
98  int cluster_n1 = -10;
99  bx_hits[detid] = 10;
100  //Keep cluster with min bx in a roll
101  for( auto digi = (*chamber).second.first ; digi != (*chamber).second.second; ++digi ) {
102  if(BxToStrips::outOfRange(digi->bx()) ) continue;
103  //int cluster_id = hits[(detid.ring()+2)][(detid.station()-1)][(detid.sector()-1)][(detid.layer()-1)][(digi->bx()+2)][detid.roll()-1][digi->strip()];
104  detId_Ext tmp{detid,digi->bx(),digi->strip()};
105  int cluster_id = hits[tmp];
107  if( vcluster_size[cluster_id] >=4 ) continue;
108  if(bx_hits[detid]>digi->bx())
109  bx_hits[detid] = digi->bx();
110  }
111 
112  for( auto digi = (*chamber).second.first ; digi != (*chamber).second.second; ++digi ) {
113  if(fabs(digi->bx())>3 ) continue;
114  detId_Ext tmp{detid,digi->bx(),digi->strip()};
115  int cluster_id = hits[tmp];
117  if( vcluster_size[cluster_id] >=4 ) continue;
119  if(digi->bx()!=bx_hits[detid] ) continue;
121  if(cluster_n1 != cluster_id) {strips[digi->bx()] = {0}; }
122  strips[digi->bx()] ++ ;
123  cluster_n1 = cluster_id;
124 
125  if( vcluster_size[cluster_id] ==3 && strips[digi->bx()]!=2) continue;
127  RPCDigi digi_out(digi->strip(), digi->bx());
128  m_outrpcDigis.insertDigi(detid, digi_out);
129  }
130  }
131 }
size
Write out results.
void run(const edm::EventSetup &c)
RPCHitCleaner(RPCDigiCollection const &inrpcDigis)
#define constexpr
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
T operator[](int i) const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
RPCDigiCollection m_outrpcDigis
Output.
Definition: RPCHitCleaner.h:53
RPCDigiCollection const & m_inrpcDigis
Input.
Definition: RPCHitCleaner.h:51
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63