CMS 3D CMS Logo

RBCProcessRPCDigis.cc
Go to the documentation of this file.
1 // Include files
2 
3 // local
7 #include "GeometryConstants.h"
8 //-----------------------------------------------------------------------------
9 // Implementation file for class : RBCProcessRPCDigis
10 //
11 // 2009-04-15 : Andres Felipe Osorio Oliveros
12 //-----------------------------------------------------------------------------
13 using namespace rpctechnicaltrigger;
14 
15 //=============================================================================
16 // Standard constructor, initializes variables
17 //=============================================================================
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 }
28 
30  for (auto wheel : s_wheelid)
31  m_digiCounters.emplace(wheel, wheel);
32 }
33 
34 //=============================================================================
35 // Destructor
36 //=============================================================================
38 
39 //=============================================================================
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 }
141 
143 
144 void RBCProcessRPCDigis::initialize(std::vector<RPCData>& dataVec) const {
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 }
170 
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 }
197 
198 int RBCProcessRPCDigis::getBarrelLayer(const int& _layer, const int& _station) {
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 }
210 
211 void RBCProcessRPCDigis::setDigiAt(int sector, int digipos, RPCData& block) {
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 }
243 
244 void RBCProcessRPCDigis::setInputBit(std::bitset<15>& signals, int digipos) {
245  int bitpos = s_layermap.at(digipos);
246  if (m_debug)
247  std::cout << "Bitpos: " << bitpos << std::endl;
248  signals.set(bitpos, true);
249 }
250 
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 }
RPCRoll
Definition: RPCRoll.h:12
DigiToRawDM_cff.digiColl
digiColl
Definition: DigiToRawDM_cff.py:32
Handle.h
RPCData
Definition: RPCData.h:42
mps_fire.i
i
Definition: mps_fire.py:428
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
rpctechnicaltrigger
Definition: GeometryConstants.cc:18
RBCProcessRPCDigis::configure
void configure()
Definition: RBCProcessRPCDigis.cc:29
RBCProcessRPCDigis::m_ptr_digiColl
const edm::Handle< RPCDigiCollection > * m_ptr_digiColl
Definition: RBCProcessRPCDigis.h:72
relativeConstraints.station
station
Definition: relativeConstraints.py:67
RBCProcessRPCDigis::builddata
void builddata()
Definition: RBCProcessRPCDigis.cc:171
RPCDetId
Definition: RPCDetId.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
rpctechnicaltrigger::s_wheelid
constexpr std::array< int, 5 > s_wheelid
Definition: GeometryConstants.h:28
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
RBCProcessRPCDigis::setDigiAt
void setDigiAt(int, int, RPCData &)
Definition: RBCProcessRPCDigis.cc:211
RBCProcessRPCDigis::next
int next() override
Definition: RBCProcessRPCDigis.cc:40
edm::Handle< RPCDigiCollection >
RPCRoll::isForward
bool isForward() const
Definition: RPCRoll.cc:43
RBCProcessRPCDigis::initialize
void initialize(std::vector< RPCData > &) const
Definition: RBCProcessRPCDigis.cc:144
rpctechnicaltrigger::s_sec1id
constexpr std::array< int, 6 > s_sec1id
Definition: GeometryConstants.h:29
RPCRoll::id
RPCDetId id() const
Definition: RPCRoll.cc:16
RBCProcessRPCDigis::m_debug
const bool m_debug
Definition: RBCProcessRPCDigis.h:82
RBCProcessRPCDigis::getBarrelLayer
int getBarrelLayer(const int &, const int &)
Definition: RBCProcessRPCDigis.cc:198
RBCLinkBoardGLSignal.h
RBCProcessRPCDigis::~RBCProcessRPCDigis
~RBCProcessRPCDigis() override
Destructor.
Definition: RBCProcessRPCDigis.cc:37
edm::ESHandle< RPCGeometry >
dqmdumpme.k
k
Definition: dqmdumpme.py:60
RBCProcessRPCDigis.h
RBCProcessRPCDigis::m_vecDataperBx
std::map< int, std::vector< RPCData > > m_vecDataperBx
Definition: RBCProcessRPCDigis.h:78
RBCProcessRPCDigis::setInputBit
void setInputBit(std::bitset< 15 > &, int)
Definition: RBCProcessRPCDigis.cc:244
RBCProcessRPCDigis::m_maxBxWindow
const int m_maxBxWindow
Definition: RBCProcessRPCDigis.h:81
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
RBCProcessRPCDigis::m_digiCounters
std::map< int, l1trigger::Counters > m_digiCounters
Definition: RBCProcessRPCDigis.h:80
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
RBCProcessRPCDigis::print_output
void print_output()
Definition: RBCProcessRPCDigis.cc:251
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:29
RBCProcessRPCDigis::RBCProcessRPCDigis
RBCProcessRPCDigis(const edm::ESHandle< RPCGeometry > &, const edm::Handle< RPCDigiCollection > &)
Standard constructor.
Definition: RBCProcessRPCDigis.cc:18
rpctechnicaltrigger::s_layermap
const std::map< int, int > s_layermap
Definition: GeometryConstants.cc:19
RPCDetId::ring
int ring() const
Definition: RPCDetId.h:59
RBCProcessRPCDigis::m_data
std::map< int, RBCInput * > m_data
Definition: RBCProcessRPCDigis.h:76
GeometryConstants.h
RBCProcessRPCDigis::reset
void reset()
Definition: RBCProcessRPCDigis.cc:142
RPCDetId::sector
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:81
RBCInput
Definition: RBCInput.h:22
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
rpctechnicaltrigger::s_sec2id
constexpr std::array< int, 6 > s_sec2id
Definition: GeometryConstants.h:30
RPCDetId::layer
int layer() const
Definition: RPCDetId.h:85