CMS 3D CMS Logo

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

#include <interface/RBCProcessRPCSimDigis.h>

Inheritance diagram for RBCProcessRPCSimDigis:
ProcessInputSignal

Public Member Functions

void builddata ()
 
int next () override
 
void print_output ()
 
 RBCProcessRPCSimDigis ()
 Standard constructor. More...
 
 RBCProcessRPCSimDigis (const edm::ESHandle< RPCGeometry > &, const edm::Handle< edm::DetSetVector< RPCDigiSimLink > > &)
 
void reset ()
 
RPCInputSignalretrievedata () override
 
void rewind ()
 
void showfirst ()
 
 ~RBCProcessRPCSimDigis () 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 > &)
 
void setDigiAt (int, int, RPCData &)
 
void setInputBit (std::bitset< 15 > &, int)
 

Private Attributes

std::map< int, RBCInput * > m_data
 
bool m_debug
 
edm::DetSet< RPCDigiSimLink >::const_iterator m_digiItr
 
std::unique_ptr< RPCInputSignalm_lbin
 
edm::DetSetVector< RPCDigiSimLink >::const_iterator m_linkItr
 
int m_maxBxWindow
 
const edm::Handle< edm::DetSetVector< RPCDigiSimLink > > * m_ptr_digiSimLink
 
const edm::ESHandle< RPCGeometry > * m_ptr_rpcGeom
 
std::map< int, std::vector< RPCData > > m_vecDataperBx
 

Detailed Description

Author
Andres Felipe Osorio Oliveros
Date
2009-09-20

Definition at line 40 of file RBCProcessRPCSimDigis.h.

Constructor & Destructor Documentation

RBCProcessRPCSimDigis::RBCProcessRPCSimDigis ( )

Standard constructor.

RBCProcessRPCSimDigis::RBCProcessRPCSimDigis ( const edm::ESHandle< RPCGeometry > &  rpcGeom,
const edm::Handle< edm::DetSetVector< RPCDigiSimLink > > &  digiSimLink 
)

Definition at line 17 of file RBCProcessRPCSimDigis.cc.

19 {
20 
21  m_ptr_rpcGeom = & rpcGeom;
22  m_ptr_digiSimLink = & digiSimLink;
23 
24  m_lbin = std::make_unique<RBCLinkBoardGLSignal>( &m_data ) ;
25 
26  m_debug = false;
27  m_maxBxWindow = 3;
28 
29 }
std::map< int, RBCInput * > m_data
const edm::Handle< edm::DetSetVector< RPCDigiSimLink > > * m_ptr_digiSimLink
std::unique_ptr< RPCInputSignal > m_lbin
const edm::ESHandle< RPCGeometry > * m_ptr_rpcGeom
RBCProcessRPCSimDigis::~RBCProcessRPCSimDigis ( )
override

Destructor.

Definition at line 34 of file RBCProcessRPCSimDigis.cc.

References reset().

Referenced by showfirst().

34  {
35  reset();
36 }

Member Function Documentation

void RBCProcessRPCSimDigis::builddata ( )

Definition at line 180 of file RBCProcessRPCSimDigis.cc.

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

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

Definition at line 217 of file RBCProcessRPCSimDigis.cc.

Referenced by showfirst().

218 {
219 
220  //... Calculates the generic Barrel Layer (1 to 6)
221  int blayer(0);
222 
223  if ( _station < 3 ) {
224  blayer = ( (_station-1) * 2 ) + _layer;
225  }
226  else {
227  blayer = _station + 2;
228  }
229 
230  return blayer;
231 
232 }
void RBCProcessRPCSimDigis::initialize ( std::vector< RPCData > &  dataVec)
private

Definition at line 151 of file RBCProcessRPCSimDigis.cc.

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

Referenced by showfirst().

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

Implements ProcessInputSignal.

Definition at line 39 of file RBCProcessRPCSimDigis.cc.

References funct::abs(), groupFilesInBlocks::block, gather_cfg::cout, RPCRoll::id(), triggerObjects_cff::id, initialize(), RPCRoll::isForward(), RPCDetId::layer(), reset(), RPCDetId::ring(), RPCDetId::sector(), relativeConstraints::station, RPCDetId::station(), and makeMuonMisalignmentScenario::wheel.

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

Definition at line 276 of file RBCProcessRPCSimDigis.cc.

References gather_cfg::cout.

277 {
278 
279  std::cout << "RBCProcessRPCSimDigis> Output starts" << std::endl;
280 
281  std::map<int,RBCInput*>::const_iterator itr;
282  for( itr = m_data.begin(); itr != m_data.end(); ++itr) {
283  std::cout << (*itr).first << '\t' << (* (*itr).second ) << '\n';
284  }
285 
286  std::cout << "RBCProcessRPCSimDigis> Output ends" << std::endl;
287 
288 }
std::map< int, RBCInput * > m_data
void RBCProcessRPCSimDigis::reset ( void  )

Definition at line 143 of file RBCProcessRPCSimDigis.cc.

144 {
145 
146  m_vecDataperBx.clear();
147 
148 }
std::map< int, std::vector< RPCData > > m_vecDataperBx
RPCInputSignal* RBCProcessRPCSimDigis::retrievedata ( )
inlineoverridevirtual

Implements ProcessInputSignal.

Definition at line 56 of file RBCProcessRPCSimDigis.h.

References m_lbin.

56  {
57  return m_lbin.get();
58  };
std::unique_ptr< RPCInputSignal > m_lbin
void RBCProcessRPCSimDigis::rewind ( )
inline

Definition at line 60 of file RBCProcessRPCSimDigis.h.

60 {};
void RBCProcessRPCSimDigis::setDigiAt ( int  sector,
int  digipos,
RPCData block 
)
private

Definition at line 235 of file RBCProcessRPCSimDigis.cc.

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

Referenced by showfirst().

236 {
237 
238  int pos = 0;
239  int isAoB = 0;
240 
241  if ( m_debug ) std::cout << "setDigiAt" << std::endl;
242 
243  auto itr = std::find( s_sec1id.begin(), s_sec1id.end(), sector );
244 
245  if ( itr == s_sec1id.end()) {
246  itr = std::find( s_sec2id.begin(), s_sec2id.end(), sector );
247  isAoB = 1;
248  }
249 
250  for ( pos = 0; pos < 6; ++pos ) {
251  if (block.m_sec1[pos] == sector || block.m_sec2[pos] == sector )
252  break;
253  }
254 
255  if ( m_debug ) std::cout << block.m_orsignals[pos];
256 
257  setInputBit( block.m_orsignals[pos].input_sec[ isAoB ] , digipos );
258 
259  block.m_orsignals[pos].hasData = true;
260 
261  if ( m_debug ) std::cout << block.m_orsignals[pos];
262 
263  if ( m_debug ) std::cout << "setDigiAt completed" << std::endl;
264 
265 }
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
void setInputBit(std::bitset< 15 > &, int)
std::array< int,6 > m_sec2
Definition: RPCData.h:51
std::array< int, 6 > m_sec1
Definition: RPCData.h:50
void RBCProcessRPCSimDigis::setInputBit ( std::bitset< 15 > &  signals,
int  digipos 
)
private

Definition at line 267 of file RBCProcessRPCSimDigis.cc.

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

Referenced by showfirst().

268 {
269 
270  int bitpos = s_layermap.at(digipos);
271  if( m_debug ) std::cout << "Bitpos: " << bitpos << std::endl;
272  signals.set( bitpos , true );
273 
274 }
const std::map< int, int > s_layermap
void RBCProcessRPCSimDigis::showfirst ( )
inline

Member Data Documentation

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

Definition at line 85 of file RBCProcessRPCSimDigis.h.

bool RBCProcessRPCSimDigis::m_debug
private

Definition at line 89 of file RBCProcessRPCSimDigis.h.

edm::DetSet<RPCDigiSimLink>::const_iterator RBCProcessRPCSimDigis::m_digiItr
private

Definition at line 81 of file RBCProcessRPCSimDigis.h.

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

Definition at line 83 of file RBCProcessRPCSimDigis.h.

Referenced by retrievedata().

edm::DetSetVector<RPCDigiSimLink>::const_iterator RBCProcessRPCSimDigis::m_linkItr
private

Definition at line 80 of file RBCProcessRPCSimDigis.h.

int RBCProcessRPCSimDigis::m_maxBxWindow
private

Definition at line 90 of file RBCProcessRPCSimDigis.h.

const edm::Handle<edm::DetSetVector<RPCDigiSimLink> >* RBCProcessRPCSimDigis::m_ptr_digiSimLink
private

Definition at line 78 of file RBCProcessRPCSimDigis.h.

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

Definition at line 77 of file RBCProcessRPCSimDigis.h.

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

Definition at line 87 of file RBCProcessRPCSimDigis.h.