CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::Counters
m_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 18 of file RBCProcessRPCDigis.cc.

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

Destructor.

Definition at line 37 of file RBCProcessRPCDigis.cc.

37 {}

Member Function Documentation

void RBCProcessRPCDigis::builddata ( )

Definition at line 171 of file RBCProcessRPCDigis.cc.

References funct::abs(), makePileupJSON::bx, gather_cfg::cout, B2GTnPMonitor_cfi::item, isotrackApplyRegressor::k, m_data, m_debug, and m_vecDataperBx.

Referenced by next().

171  {
172  for (auto& vecData : m_vecDataperBx) {
173  int bx = vecData.first;
174  int bxsign(1);
175 
176  if (bx != 0)
177  bxsign = (bx / abs(bx));
178  else
179  bxsign = 1;
180 
181  for (auto& item : vecData.second) {
182  for (int k = 0; k < 6; ++k) {
183  int code = bxsign * (1000000 * abs(bx) + 10000 * item.wheelIdx() + 100 * item.m_sec1[k] + 1 * item.m_sec2[k]);
184 
185  RBCInput* signal = &item.m_orsignals[k];
186  signal->needmapping = false;
187 
188  if (signal->hasData)
189  m_data.emplace(code, signal);
190  }
191  }
192  }
193 
194  if (m_debug and not m_vecDataperBx.empty())
195  std::cout << "builddata: completed. size of data: " << m_data.size() << std::endl;
196 }
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
tuple cout
Definition: gather_cfg.py:144
void RBCProcessRPCDigis::configure ( )

Definition at line 29 of file RBCProcessRPCDigis.cc.

References m_digiCounters, and rpctechnicaltrigger::s_wheelid.

29  {
30  for (auto wheel : s_wheelid)
31  m_digiCounters.emplace(wheel, wheel);
32 }
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 198 of file RBCProcessRPCDigis.cc.

Referenced by next().

198  {
199  //... Calculates the generic Barrel Layer (1 to 6)
200  int blayer(0);
201 
202  if (_station < 3) {
203  blayer = ((_station - 1) * 2) + _layer;
204  } else {
205  blayer = _station + 2;
206  }
207 
208  return blayer;
209 }
void RBCProcessRPCDigis::initialize ( std::vector< RPCData > &  dataVec) const
private

Definition at line 144 of file RBCProcessRPCDigis.cc.

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

Referenced by next().

144  {
145  if (m_debug)
146  std::cout << "initialize" << std::endl;
147 
148  constexpr int maxWheels = 5;
149  constexpr int maxRbcBrds = 6;
150 
151  dataVec.reserve(maxWheels);
152  for (int i = 0; i < maxWheels; ++i) {
153  auto& block = dataVec.emplace_back();
154 
155  block.m_wheel = s_wheelid[i];
156 
157  for (int j = 0; j < maxRbcBrds; ++j) {
158  block.m_sec1[j] = s_sec1id[j];
159  block.m_sec2[j] = s_sec2id[j];
160  block.m_orsignals[j].input_sec[0].reset();
161  block.m_orsignals[j].input_sec[1].reset();
162  block.m_orsignals[j].needmapping = false;
163  block.m_orsignals[j].hasData = false;
164  }
165  }
166 
167  if (m_debug)
168  std::cout << "initialize: completed" << std::endl;
169 }
constexpr std::array< int, 6 > s_sec2id
constexpr std::array< int, 6 > s_sec1id
constexpr std::array< int, 5 > s_wheelid
tuple cout
Definition: gather_cfg.py:144
int RBCProcessRPCDigis::next ( void  )
overridevirtual

Implements ProcessInputSignal.

Definition at line 40 of file RBCProcessRPCDigis.cc.

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

Referenced by BeautifulSoup.PageElement::_invert().

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

Definition at line 251 of file RBCProcessRPCDigis.cc.

References gather_cfg::cout, B2GTnPMonitor_cfi::item, and m_data.

Referenced by next().

251  {
252  std::cout << "RBCProcessRPCDigis> Output starts" << std::endl;
253 
254  for (auto const& item : m_data) {
255  std::cout << item.first << '\t' << (*item.second) << '\n';
256  }
257 
258  std::cout << "RBCProcessRPCDigis> Output ends" << std::endl;
259 }
std::map< int, RBCInput * > m_data
tuple cout
Definition: gather_cfg.py:144
void RBCProcessRPCDigis::reset ( void  )

Definition at line 142 of file RBCProcessRPCDigis.cc.

References m_vecDataperBx.

Referenced by next().

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

Implements ProcessInputSignal.

Definition at line 56 of file RBCProcessRPCDigis.h.

References m_lbin.

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

Definition at line 58 of file RBCProcessRPCDigis.h.

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

Definition at line 211 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().

211  {
212  int pos = 0;
213  int isAoB = 0;
214 
215  if (m_debug)
216  std::cout << "setDigiAt" << std::endl;
217 
218  auto itr = std::find(s_sec1id.begin(), s_sec1id.end(), sector);
219 
220  if (itr == s_sec1id.end()) {
221  itr = std::find(s_sec2id.begin(), s_sec2id.end(), sector);
222  isAoB = 1;
223  }
224 
225  for (pos = 0; pos < 6; ++pos) {
226  if (block.m_sec1[pos] == sector || block.m_sec2[pos] == sector)
227  break;
228  }
229 
230  if (m_debug)
231  std::cout << block.m_orsignals[pos];
232 
233  setInputBit(block.m_orsignals[pos].input_sec[isAoB], digipos);
234 
235  block.m_orsignals[pos].hasData = true;
236 
237  if (m_debug)
238  std::cout << block.m_orsignals[pos];
239 
240  if (m_debug)
241  std::cout << "setDigiAt completed" << std::endl;
242 }
constexpr std::array< int, 6 > s_sec2id
void setInputBit(std::bitset< 15 > &, int)
std::array< int, 6 > m_sec1
Definition: RPCData.h:49
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
std::array< RBCInput, 6 > m_orsignals
Definition: RPCData.h:51
tuple cout
Definition: gather_cfg.py:144
std::array< int, 6 > m_sec2
Definition: RPCData.h:50
void RBCProcessRPCDigis::setInputBit ( std::bitset< 15 > &  signals,
int  digipos 
)
private

Definition at line 244 of file RBCProcessRPCDigis.cc.

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

Referenced by setDigiAt().

244  {
245  int bitpos = s_layermap.at(digipos);
246  if (m_debug)
247  std::cout << "Bitpos: " << bitpos << std::endl;
248  signals.set(bitpos, true);
249 }
const std::map< int, int > s_layermap
tuple cout
Definition: gather_cfg.py:144
void RBCProcessRPCDigis::showfirst ( )
inline

Definition at line 59 of file RBCProcessRPCDigis.h.

59 {};

Member Data Documentation

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

Definition at line 76 of file RBCProcessRPCDigis.h.

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

const bool RBCProcessRPCDigis::m_debug
private

Definition at line 82 of file RBCProcessRPCDigis.h.

Referenced by builddata(), initialize(), next(), setDigiAt(), and setInputBit().

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

Definition at line 80 of file RBCProcessRPCDigis.h.

Referenced by configure(), and next().

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

Definition at line 74 of file RBCProcessRPCDigis.h.

Referenced by retrievedata().

const int RBCProcessRPCDigis::m_maxBxWindow
private

Definition at line 81 of file RBCProcessRPCDigis.h.

Referenced by next().

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

Definition at line 72 of file RBCProcessRPCDigis.h.

Referenced by next().

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

Definition at line 71 of file RBCProcessRPCDigis.h.

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

Definition at line 78 of file RBCProcessRPCDigis.h.

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