CMS 3D CMS Logo

RBCProcessRPCSimDigis.cc
Go to the documentation of this file.
1 // Include files
2 
3 // local
7 #include "GeometryConstants.h"
8 
9 //-----------------------------------------------------------------------------
10 // Implementation file for class : RBCProcessRPCSimDigis
11 //
12 // 2009-09-20 : Andres Felipe Osorio Oliveros
13 //-----------------------------------------------------------------------------
14 using namespace rpctechnicaltrigger;
15 
17  const edm::Handle<edm::DetSetVector<RPCDigiSimLink> >& digiSimLink) {
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 }
26 
27 //=============================================================================
28 // Destructor
29 //=============================================================================
31 
32 //=============================================================================
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 }
127 
128 void RBCProcessRPCSimDigis::reset() { m_vecDataperBx.clear(); }
129 
130 void RBCProcessRPCSimDigis::initialize(std::vector<RPCData>& dataVec) {
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 }
156 
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 }
185 
186 int RBCProcessRPCSimDigis::getBarrelLayer(const int& _layer, const int& _station) {
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 }
198 
199 void RBCProcessRPCSimDigis::setDigiAt(int sector, int digipos, RPCData& block) {
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 }
231 
232 void RBCProcessRPCSimDigis::setInputBit(std::bitset<15>& signals, int digipos) {
233  int bitpos = s_layermap.at(digipos);
234  if (m_debug)
235  std::cout << "Bitpos: " << bitpos << std::endl;
236  signals.set(bitpos, true);
237 }
238 
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 }
RPCRoll
Definition: RPCRoll.h:12
edm::DetSetVector< RPCDigiSimLink >
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
RBCProcessRPCSimDigis::print_output
void print_output()
Definition: RBCProcessRPCSimDigis.cc:239
relativeConstraints.station
station
Definition: relativeConstraints.py:67
RPCDetId
Definition: RPCDetId.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
rpctechnicaltrigger::s_wheelid
constexpr std::array< int, 5 > s_wheelid
Definition: GeometryConstants.h:28
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
RBCProcessRPCSimDigis::next
int next() override
Definition: RBCProcessRPCSimDigis.cc:33
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
RBCProcessRPCSimDigis.h
edm::Handle
Definition: AssociativeIterator.h:50
RPCRoll::isForward
bool isForward() const
Definition: RPCRoll.cc:43
rpctechnicaltrigger::s_sec1id
constexpr std::array< int, 6 > s_sec1id
Definition: GeometryConstants.h:29
RPCRoll::id
RPCDetId id() const
Definition: RPCRoll.cc:16
RBCProcessRPCSimDigis::builddata
void builddata()
Definition: RBCProcessRPCSimDigis.cc:157
RBCLinkBoardGLSignal.h
edm::ESHandle< RPCGeometry >
RBCProcessRPCSimDigis::initialize
void initialize(std::vector< RPCData > &)
Definition: RBCProcessRPCSimDigis.cc:130
dqmdumpme.k
k
Definition: dqmdumpme.py:60
RBCProcessRPCSimDigis::setInputBit
void setInputBit(std::bitset< 15 > &, int)
Definition: RBCProcessRPCSimDigis.cc:232
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:29
rpctechnicaltrigger::s_layermap
const std::map< int, int > s_layermap
Definition: GeometryConstants.cc:19
RPCDetId::ring
int ring() const
Definition: RPCDetId.h:59
GeometryConstants.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
RBCProcessRPCSimDigis::getBarrelLayer
int getBarrelLayer(const int &, const int &)
Definition: RBCProcessRPCSimDigis.cc:186
RPCDetId::sector
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:81
RBCProcessRPCSimDigis::setDigiAt
void setDigiAt(int, int, RPCData &)
Definition: RBCProcessRPCSimDigis.cc:199
RBCProcessRPCSimDigis::reset
void reset()
Definition: RBCProcessRPCSimDigis.cc:128
RBCProcessRPCSimDigis::~RBCProcessRPCSimDigis
~RBCProcessRPCSimDigis() override
Destructor.
Definition: RBCProcessRPCSimDigis.cc:30
reset
void reset(double vett[256])
Definition: TPedValues.cc:11
RBCInput
Definition: RBCInput.h:22
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RBCProcessRPCSimDigis::RBCProcessRPCSimDigis
RBCProcessRPCSimDigis()
Standard constructor.
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