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