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() [1/2]

RBCProcessRPCSimDigis::RBCProcessRPCSimDigis ( )

Standard constructor.

◆ RBCProcessRPCSimDigis() [2/2]

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

Definition at line 16 of file RBCProcessRPCSimDigis.cc.

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

◆ ~RBCProcessRPCSimDigis()

RBCProcessRPCSimDigis::~RBCProcessRPCSimDigis ( )
override

Destructor.

Definition at line 30 of file RBCProcessRPCSimDigis.cc.

References reset().

Member Function Documentation

◆ builddata()

void RBCProcessRPCSimDigis::builddata ( )

Definition at line 157 of file RBCProcessRPCSimDigis.cc.

References funct::abs(), simKBmtfDigis_cfi::bx, gather_cfg::cout, B2GTnPMonitor_cfi::item, and dqmdumpme::k.

157  {
158  int code(0);
159 
160  for (auto& dataPerBx : m_vecDataperBx) {
161  int bx = dataPerBx.first;
162 
163  int bxsign;
164  if (bx != 0)
165  bxsign = (bx / abs(bx));
166  else
167  bxsign = 1;
168 
169  for (auto& item : dataPerBx.second) {
170  for (int k = 0; k < 6; ++k) {
171  code = bxsign * (1000000 * abs(bx) + 10000 * item.wheelIdx() + 100 * item.m_sec1[k] + 1 * item.m_sec2[k]);
172 
173  RBCInput* signal = &item.m_orsignals[k];
174  signal->needmapping = false;
175 
176  if (signal->hasData)
177  m_data.insert(std::make_pair(code, signal));
178  }
179  }
180  }
181 
182  if (m_debug and not m_vecDataperBx.empty())
183  std::cout << "builddata: completed. size of data: " << m_data.size() << std::endl;
184 }
std::map< int, std::vector< RPCData > > m_vecDataperBx
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< int, RBCInput * > m_data

◆ getBarrelLayer()

int RBCProcessRPCSimDigis::getBarrelLayer ( const int &  _layer,
const int &  _station 
)
private

Definition at line 186 of file RBCProcessRPCSimDigis.cc.

186  {
187  //... Calculates the generic Barrel Layer (1 to 6)
188  int blayer(0);
189 
190  if (_station < 3) {
191  blayer = ((_station - 1) * 2) + _layer;
192  } else {
193  blayer = _station + 2;
194  }
195 
196  return blayer;
197 }

◆ initialize()

void RBCProcessRPCSimDigis::initialize ( std::vector< RPCData > &  dataVec)
private

Definition at line 130 of file RBCProcessRPCSimDigis.cc.

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

130  {
131  if (m_debug)
132  std::cout << "initialize" << std::endl;
133 
134  constexpr int maxWheels = 5;
135  constexpr int maxRbcBrds = 6;
136 
137  dataVec.reserve(maxWheels);
138  for (int i = 0; i < maxWheels; ++i) {
139  auto& block = dataVec.emplace_back();
140 
141  block.m_wheel = s_wheelid[i];
142 
143  for (int j = 0; j < maxRbcBrds; ++j) {
144  block.m_sec1[j] = s_sec1id[j];
145  block.m_sec2[j] = s_sec2id[j];
146  block.m_orsignals[j].input_sec[0].reset();
147  block.m_orsignals[j].input_sec[1].reset();
148  block.m_orsignals[j].needmapping = false;
149  block.m_orsignals[j].hasData = false;
150  }
151  }
152 
153  if (m_debug)
154  std::cout << "initialize: completed" << std::endl;
155 }
constexpr std::array< int, 6 > s_sec2id
constexpr std::array< int, 6 > s_sec1id
constexpr std::array< int, 5 > s_wheelid

◆ next()

int RBCProcessRPCSimDigis::next ( void  )
overridevirtual

Implements ProcessInputSignal.

Definition at line 33 of file RBCProcessRPCSimDigis.cc.

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

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

◆ print_output()

void RBCProcessRPCSimDigis::print_output ( )

Definition at line 239 of file RBCProcessRPCSimDigis.cc.

References gather_cfg::cout.

239  {
240  std::cout << "RBCProcessRPCSimDigis> Output starts" << std::endl;
241 
242  std::map<int, RBCInput*>::const_iterator itr;
243  for (itr = m_data.begin(); itr != m_data.end(); ++itr) {
244  std::cout << (*itr).first << '\t' << (*(*itr).second) << '\n';
245  }
246 
247  std::cout << "RBCProcessRPCSimDigis> Output ends" << std::endl;
248 }
std::map< int, RBCInput * > m_data

◆ reset()

void RBCProcessRPCSimDigis::reset ( void  )

Definition at line 128 of file RBCProcessRPCSimDigis.cc.

128 { m_vecDataperBx.clear(); }
std::map< int, std::vector< RPCData > > m_vecDataperBx

◆ retrievedata()

RPCInputSignal* RBCProcessRPCSimDigis::retrievedata ( )
inlineoverridevirtual

Implements ProcessInputSignal.

Definition at line 55 of file RBCProcessRPCSimDigis.h.

References m_lbin.

55 { return m_lbin.get(); };
std::unique_ptr< RPCInputSignal > m_lbin

◆ rewind()

void RBCProcessRPCSimDigis::rewind ( )
inline

Definition at line 57 of file RBCProcessRPCSimDigis.h.

57 {};

◆ setDigiAt()

void RBCProcessRPCSimDigis::setDigiAt ( int  sector,
int  digipos,
RPCData block 
)
private

Definition at line 199 of file RBCProcessRPCSimDigis.cc.

References groupFilesInBlocks::block, gather_cfg::cout, spr::find(), rpctechnicaltrigger::s_sec1id, rpctechnicaltrigger::s_sec2id, and hgcalTBTopologyTester_cfi::sector.

199  {
200  int pos = 0;
201  int isAoB = 0;
202 
203  if (m_debug)
204  std::cout << "setDigiAt" << std::endl;
205 
206  auto itr = std::find(s_sec1id.begin(), s_sec1id.end(), sector);
207 
208  if (itr == s_sec1id.end()) {
209  itr = std::find(s_sec2id.begin(), s_sec2id.end(), sector);
210  isAoB = 1;
211  }
212 
213  for (pos = 0; pos < 6; ++pos) {
214  if (block.m_sec1[pos] == sector || block.m_sec2[pos] == sector)
215  break;
216  }
217 
218  if (m_debug)
219  std::cout << block.m_orsignals[pos];
220 
221  setInputBit(block.m_orsignals[pos].input_sec[isAoB], digipos);
222 
223  block.m_orsignals[pos].hasData = true;
224 
225  if (m_debug)
226  std::cout << block.m_orsignals[pos];
227 
228  if (m_debug)
229  std::cout << "setDigiAt completed" << std::endl;
230 }
constexpr std::array< int, 6 > s_sec2id
constexpr std::array< int, 6 > s_sec1id
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void setInputBit(std::bitset< 15 > &, int)

◆ setInputBit()

void RBCProcessRPCSimDigis::setInputBit ( std::bitset< 15 > &  signals,
int  digipos 
)
private

Definition at line 232 of file RBCProcessRPCSimDigis.cc.

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

232  {
233  int bitpos = s_layermap.at(digipos);
234  if (m_debug)
235  std::cout << "Bitpos: " << bitpos << std::endl;
236  signals.set(bitpos, true);
237 }
const std::map< int, int > s_layermap

◆ showfirst()

void RBCProcessRPCSimDigis::showfirst ( )
inline

Definition at line 58 of file RBCProcessRPCSimDigis.h.

58 {};

Member Data Documentation

◆ m_data

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

Definition at line 80 of file RBCProcessRPCSimDigis.h.

◆ m_debug

bool RBCProcessRPCSimDigis::m_debug
private

Definition at line 84 of file RBCProcessRPCSimDigis.h.

◆ m_digiItr

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

Definition at line 76 of file RBCProcessRPCSimDigis.h.

◆ m_lbin

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

Definition at line 78 of file RBCProcessRPCSimDigis.h.

Referenced by retrievedata().

◆ m_linkItr

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

Definition at line 75 of file RBCProcessRPCSimDigis.h.

◆ m_maxBxWindow

int RBCProcessRPCSimDigis::m_maxBxWindow
private

Definition at line 85 of file RBCProcessRPCSimDigis.h.

◆ m_ptr_digiSimLink

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

Definition at line 73 of file RBCProcessRPCSimDigis.h.

◆ m_ptr_rpcGeom

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

Definition at line 72 of file RBCProcessRPCSimDigis.h.

◆ m_vecDataperBx

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

Definition at line 82 of file RBCProcessRPCSimDigis.h.