CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
RBCProcessRPCDigis Class Reference

#include <RBCProcessRPCDigis.h>

Inheritance diagram for RBCProcessRPCDigis:
ProcessInputSignal

Public Member Functions

void builddata ()
 
void configure ()
 
int next () override
 
void print_output ()
 
 RBCProcessRPCDigis (const edm::ESHandle< RPCGeometry > &, const edm::Handle< RPCDigiCollection > &)
 Standard constructor. More...
 
void reset ()
 
RPCInputSignalretrievedata () override
 
void rewind ()
 
void showfirst ()
 
 ~RBCProcessRPCDigis () override
 Destructor. More...
 
- Public Member Functions inherited from ProcessInputSignal
virtual ~ProcessInputSignal ()
 

Private Member Functions

int getBarrelLayer (const int &, const int &)
 
void initialize (std::vector< RPCData > &) const
 
void setDigiAt (int, int, RPCData &)
 
void setInputBit (std::bitset< 15 > &, int)
 

Private Attributes

std::map< int, RBCInput * > m_data
 
const bool m_debug
 
std::map< int, l1trigger::Countersm_digiCounters
 
std::unique_ptr< RPCInputSignalm_lbin
 
const int m_maxBxWindow
 
const edm::Handle< RPCDigiCollection > * m_ptr_digiColl
 
const edm::ESHandle< RPCGeometry > * m_ptr_rpcGeom
 
std::map< int, std::vector< RPCData > > m_vecDataperBx
 

Detailed Description

Author
Andres Felipe Osorio Oliveros
Date
2009-04-15

Definition at line 39 of file RBCProcessRPCDigis.h.

Constructor & Destructor Documentation

RBCProcessRPCDigis::RBCProcessRPCDigis ( const edm::ESHandle< RPCGeometry > &  rpcGeom,
const edm::Handle< RPCDigiCollection > &  digiColl 
)

Standard constructor.

Definition at line 20 of file RBCProcessRPCDigis.cc.

References configure(), m_data, m_debug, m_lbin, m_ptr_digiColl, and m_ptr_rpcGeom.

21  :
22  m_maxBxWindow{3},
23  m_debug{false}
24 {
25 
26  m_ptr_rpcGeom = & rpcGeom;
27  m_ptr_digiColl = & digiColl;
28 
29  m_lbin =std::make_unique<RBCLinkBoardGLSignal>( &m_data ) ;
30 
31  configure();
32 
33 }
const edm::ESHandle< RPCGeometry > * m_ptr_rpcGeom
const edm::Handle< RPCDigiCollection > * m_ptr_digiColl
std::unique_ptr< RPCInputSignal > m_lbin
std::map< int, RBCInput * > m_data
RBCProcessRPCDigis::~RBCProcessRPCDigis ( )
override

Destructor.

Definition at line 44 of file RBCProcessRPCDigis.cc.

44  {
45 
46 }

Member Function Documentation

void RBCProcessRPCDigis::builddata ( )

Definition at line 187 of file RBCProcessRPCDigis.cc.

References funct::abs(), gather_cfg::cout, gen::k, m_data, m_debug, m_vecDataperBx, and RBCInput::needmapping.

Referenced by next().

188 {
189 
190 
191  for(auto & vecData: m_vecDataperBx) {
192 
193  int bx = vecData.first;
194  int bxsign(1);
195 
196  if ( bx != 0 ) bxsign = ( bx / abs(bx) );
197  else bxsign = 1;
198 
199  for(auto & item : vecData.second) {
200 
201  for(int k=0; k < 6; ++k) {
202 
203  int code = bxsign * ( 1000000*abs(bx)
204  + 10000*item.wheelIdx()
205  + 100 *item.m_sec1[k]
206  + 1 *item.m_sec2[k] );
207 
208  RBCInput * signal = & item.m_orsignals[k];
209  signal->needmapping = false;
210 
211  if ( signal->hasData )
212  m_data.emplace( code , signal );
213 
214  }
215  }
216  }
217 
218  if ( m_debug and not m_vecDataperBx.empty() ) std::cout << "builddata: completed. size of data: " << m_data.size() << std::endl;
219 
220 }
std::map< int, std::vector< RPCData > > m_vecDataperBx
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int k[5][pyjets_maxn]
bool needmapping
Definition: RBCInput.h:52
std::map< int, RBCInput * > m_data
void RBCProcessRPCDigis::configure ( )

Definition at line 35 of file RBCProcessRPCDigis.cc.

References m_digiCounters, rpctechnicaltrigger::s_wheelid, and makeMuonMisalignmentScenario::wheel.

Referenced by RBCProcessRPCDigis().

36 {
37  for( auto wheel : s_wheelid)
38  m_digiCounters.emplace(wheel, wheel);
39 }
constexpr std::array< int, 5 > s_wheelid
std::map< int, l1trigger::Counters > m_digiCounters
int RBCProcessRPCDigis::getBarrelLayer ( const int &  _layer,
const int &  _station 
)
private

Definition at line 222 of file RBCProcessRPCDigis.cc.

Referenced by next(), and showfirst().

223 {
224 
225  //... Calculates the generic Barrel Layer (1 to 6)
226  int blayer(0);
227 
228  if ( _station < 3 ) {
229  blayer = ( (_station-1) * 2 ) + _layer;
230  }
231  else {
232  blayer = _station + 2;
233  }
234 
235  return blayer;
236 
237 }
void RBCProcessRPCDigis::initialize ( std::vector< RPCData > &  dataVec) const
private

Definition at line 159 of file RBCProcessRPCDigis.cc.

References groupFilesInBlocks::block, constexpr, gather_cfg::cout, mps_fire::i, m_debug, rpctechnicaltrigger::s_sec1id, rpctechnicaltrigger::s_sec2id, and rpctechnicaltrigger::s_wheelid.

Referenced by next(), and showfirst().

160 {
161 
162  if ( m_debug ) std::cout << "initialize" << std::endl;
163 
164  constexpr int maxWheels = 5;
165  constexpr int maxRbcBrds = 6;
166 
167  dataVec.reserve(maxWheels);
168  for(int i=0; i < maxWheels; ++i) {
169  auto& block = dataVec.emplace_back();
170 
171  block.m_wheel = s_wheelid[i];
172 
173  for(int j=0; j < maxRbcBrds; ++j) {
174  block.m_sec1[j] = s_sec1id[j];
175  block.m_sec2[j] = s_sec2id[j];
176  block.m_orsignals[j].input_sec[0].reset();
177  block.m_orsignals[j].input_sec[1].reset();
178  block.m_orsignals[j].needmapping = false;
179  block.m_orsignals[j].hasData = false;
180  }
181  }
182 
183  if ( m_debug ) std::cout << "initialize: completed" << std::endl;
184 
185 }
#define constexpr
constexpr std::array< int, 6 > s_sec2id
constexpr std::array< int, 6 > s_sec1id
constexpr std::array< int, 5 > s_wheelid
int RBCProcessRPCDigis::next ( void  )
overridevirtual

Implements ProcessInputSignal.

Definition at line 49 of file RBCProcessRPCDigis.cc.

References funct::abs(), builddata(), gather_cfg::cout, getBarrelLayer(), RPCRoll::id(), initialize(), RPCRoll::isForward(), RPCDetId::layer(), m_data, m_debug, m_digiCounters, m_maxBxWindow, m_ptr_digiColl, m_vecDataperBx, print_output(), reset(), RPCDetId::ring(), RPCDetId::sector(), setDigiAt(), relativeConstraints::station, RPCDetId::station(), and makeMuonMisalignmentScenario::wheel.

49  {
50 
51  //...clean up previous data contents
52 
53  reset();
54 
55  int ndigis(0);
56 
57  for (auto const& detUnit : *(*m_ptr_digiColl) ) {
58 
59  if ( m_debug ) std::cout << "looping over digis 1 ..." << std::endl;
60 
61  auto digiItr = detUnit.second.first;
62  int bx = (*digiItr).bx();
63 
64  if ( abs(bx) >= m_maxBxWindow ) {
65  if ( m_debug ) std::cout << "RBCProcessRPCDigis> found a bx bigger than max allowed: "
66  << bx << std::endl;
67  continue;
68  }
69 
70  const RPCDetId & id = detUnit.first;
71  const RPCRoll * roll = dynamic_cast<const RPCRoll* >( (*m_ptr_rpcGeom)->roll(id));
72 
73  if((roll->isForward())) {
74  if( m_debug ) std::cout << "RBCProcessRPCDigis: roll is forward" << std::endl;
75  continue;
76  }
77 
78  int wheel = roll->id().ring(); // -2,-1,0,+1,+2
79  int sector = roll->id().sector(); // 1 to 12
80  int layer = roll->id().layer(); // 1,2
81  int station = roll->id().station(); // 1-4
82  int blayer = getBarrelLayer( layer, station ); // 1 to 6
83  int rollid = id.roll();
84 
85  int digipos = (station * 100) + (layer * 10) + rollid;
86 
87  if ( (wheel == -1 || wheel == 0 || wheel == 1) && station == 2 && layer == 1 )
88  digipos = 30000 + digipos;
89  if ( (wheel == -2 || wheel == 2) && station == 2 && layer == 2 )
90  digipos = 30000 + digipos;
91 
92  if ( (wheel == -1 || wheel == 0 || wheel == 1) && station == 2 && layer == 2 )
93  digipos = 20000 + digipos;
94  if ( (wheel == -2 || wheel == 2) && station == 2 && layer == 1 )
95  digipos = 20000 + digipos;
96 
97  if ( m_debug ) std::cout << "Bx: " << bx << '\t'
98  << "Wheel: " << wheel << '\t'
99  << "Sector: " << sector << '\t'
100  << "Station: " << station << '\t'
101  << "Layer: " << layer << '\t'
102  << "B-Layer: " << blayer << '\t'
103  << "Roll id: " << rollid << '\t'
104  << "Digi at: " << digipos << '\n';
105 
106  //... Construct the RBCinput objects
107  auto itr = m_vecDataperBx.find( bx );
108 
109  if ( itr == m_vecDataperBx.end() ) {
110  if ( m_debug ) std::cout << "Found a new Bx: " << bx << std::endl;
111  auto& wheelData = m_vecDataperBx[bx];
112  initialize(wheelData);
113  setDigiAt( sector, digipos, wheelData[ (wheel + 2) ] );
114  }
115  else{
116  setDigiAt( sector, digipos, (*itr).second[ (wheel + 2) ] );
117  }
118 
119  auto wheelCounter = m_digiCounters.find( wheel );
120 
121  if ( wheelCounter != m_digiCounters.end() )
122  (*wheelCounter).second.incrementSector( sector );
123 
124  if ( m_debug ) std::cout << "looping over digis 2 ..." << std::endl;
125 
126  ++ndigis;
127 
128  }
129 
130  if ( m_debug ) std::cout << "size of data vectors: " << m_vecDataperBx.size() << std::endl;
131 
132  builddata();
133 
134  if ( m_debug ) {
135  std::cout << "after reset" << std::endl;
136  print_output();
137  }
138 
139  if ( m_debug ) std::cout << "RBCProcessRPCDigis: DataSize: " << m_data.size()
140  << " ndigis " << ndigis << std::endl;
141 
142  for( auto& wheelCounter : m_digiCounters) {
143  wheelCounter.second.evalCounters();
144  if ( m_debug ) wheelCounter.second.printSummary();
145  }
146 
147  if ( m_data.empty() ) return 0;
148 
149  return 1;
150 
151 }
void initialize(std::vector< RPCData > &) const
RPCDetId id() const
Definition: RPCRoll.cc:24
std::map< int, std::vector< RPCData > > m_vecDataperBx
int ring() const
Definition: RPCDetId.h:72
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::Handle< RPCDigiCollection > * m_ptr_digiColl
int layer() const
Definition: RPCDetId.h:108
std::map< int, l1trigger::Counters > m_digiCounters
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
void setDigiAt(int, int, RPCData &)
int getBarrelLayer(const int &, const int &)
bool isForward() const
Definition: RPCRoll.cc:98
std::map< int, RBCInput * > m_data
int station() const
Definition: RPCDetId.h:96
void RBCProcessRPCDigis::print_output ( )

Definition at line 281 of file RBCProcessRPCDigis.cc.

References gather_cfg::cout, and m_data.

Referenced by next().

282 {
283 
284  std::cout << "RBCProcessRPCDigis> Output starts" << std::endl;
285 
286  for( auto const& item: m_data) {
287  std::cout << item.first << '\t' << (* item.second ) << '\n';
288  }
289 
290  std::cout << "RBCProcessRPCDigis> Output ends" << std::endl;
291 
292 }
std::map< int, RBCInput * > m_data
void RBCProcessRPCDigis::reset ( void  )

Definition at line 153 of file RBCProcessRPCDigis.cc.

References m_vecDataperBx.

Referenced by next().

154 {
155  m_vecDataperBx.clear();
156 }
std::map< int, std::vector< RPCData > > m_vecDataperBx
RPCInputSignal* RBCProcessRPCDigis::retrievedata ( )
inlineoverridevirtual

Implements ProcessInputSignal.

Definition at line 58 of file RBCProcessRPCDigis.h.

References m_lbin.

58  {
59  return m_lbin.get();
60  };
std::unique_ptr< RPCInputSignal > m_lbin
void RBCProcessRPCDigis::rewind ( )
inline

Definition at line 62 of file RBCProcessRPCDigis.h.

62 {};
void RBCProcessRPCDigis::setDigiAt ( int  sector,
int  digipos,
RPCData block 
)
private

Definition at line 240 of file RBCProcessRPCDigis.cc.

References gather_cfg::cout, spr::find(), m_debug, RPCData::m_orsignals, RPCData::m_sec1, RPCData::m_sec2, rpctechnicaltrigger::s_sec1id, rpctechnicaltrigger::s_sec2id, and setInputBit().

Referenced by next(), and showfirst().

241 {
242 
243  int pos = 0;
244  int isAoB = 0;
245 
246  if ( m_debug ) std::cout << "setDigiAt" << std::endl;
247 
248  auto itr = std::find( s_sec1id.begin(), s_sec1id.end(), sector );
249 
250  if ( itr == s_sec1id.end()) {
251  itr = std::find( s_sec2id.begin(), s_sec2id.end(), sector );
252  isAoB = 1;
253  }
254 
255  for ( pos = 0; pos < 6; ++pos ) {
256  if (block.m_sec1[pos] == sector || block.m_sec2[pos] == sector )
257  break;
258  }
259 
260  if ( m_debug ) std::cout << block.m_orsignals[pos];
261 
262  setInputBit( block.m_orsignals[pos].input_sec[ isAoB ] , digipos );
263 
264  block.m_orsignals[pos].hasData = true;
265 
266  if ( m_debug ) std::cout << block.m_orsignals[pos];
267 
268  if ( m_debug ) std::cout << "setDigiAt completed" << std::endl;
269 
270 }
void setInputBit(std::bitset< 15 > &, int)
std::array< RBCInput, 6 > m_orsignals
Definition: RPCData.h:52
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
constexpr std::array< int, 6 > s_sec2id
constexpr std::array< int, 6 > s_sec1id
std::array< int,6 > m_sec2
Definition: RPCData.h:51
std::array< int, 6 > m_sec1
Definition: RPCData.h:50
void RBCProcessRPCDigis::setInputBit ( std::bitset< 15 > &  signals,
int  digipos 
)
private

Definition at line 272 of file RBCProcessRPCDigis.cc.

References gather_cfg::cout, m_debug, and rpctechnicaltrigger::s_layermap.

Referenced by setDigiAt(), and showfirst().

273 {
274 
275  int bitpos = s_layermap.at(digipos);
276  if( m_debug ) std::cout << "Bitpos: " << bitpos << std::endl;
277  signals.set( bitpos , true );
278 
279 }
const std::map< int, int > s_layermap
void RBCProcessRPCDigis::showfirst ( )
inline

Definition at line 63 of file RBCProcessRPCDigis.h.

References getBarrelLayer(), initialize(), setDigiAt(), and setInputBit().

63 {};

Member Data Documentation

std::map<int, RBCInput*> RBCProcessRPCDigis::m_data
private

Definition at line 81 of file RBCProcessRPCDigis.h.

Referenced by builddata(), next(), print_output(), and RBCProcessRPCDigis().

const bool RBCProcessRPCDigis::m_debug
private
std::map<int, l1trigger::Counters> RBCProcessRPCDigis::m_digiCounters
private

Definition at line 86 of file RBCProcessRPCDigis.h.

Referenced by configure(), and next().

std::unique_ptr<RPCInputSignal> RBCProcessRPCDigis::m_lbin
private

Definition at line 79 of file RBCProcessRPCDigis.h.

Referenced by RBCProcessRPCDigis(), and retrievedata().

const int RBCProcessRPCDigis::m_maxBxWindow
private

Definition at line 87 of file RBCProcessRPCDigis.h.

Referenced by next().

const edm::Handle<RPCDigiCollection>* RBCProcessRPCDigis::m_ptr_digiColl
private

Definition at line 77 of file RBCProcessRPCDigis.h.

Referenced by next(), and RBCProcessRPCDigis().

const edm::ESHandle<RPCGeometry>* RBCProcessRPCDigis::m_ptr_rpcGeom
private

Definition at line 76 of file RBCProcessRPCDigis.h.

Referenced by RBCProcessRPCDigis().

std::map<int, std::vector<RPCData> > RBCProcessRPCDigis::m_vecDataperBx
private

Definition at line 83 of file RBCProcessRPCDigis.h.

Referenced by builddata(), next(), and reset().