CMS 3D CMS Logo

RecHitProcessor.cc
Go to the documentation of this file.
9 
11 
13 
15  const edm::EventSetup &iSetup,
16  const edm::EDGetToken &recHitToken,
17  const edm::EDGetToken &rpcDigiToken,
18  const edm::EDGetToken &rpcDigiSimLinkToken,
19  std::vector<RecHitProcessor::CppfItem> &CppfVec1,
20  l1t::CPPFDigiCollection &cppfDigis,
21  const int MaxClusterSize) const {
23  iEvent.getByToken(recHitToken, recHits);
24 
26  iEvent.getByToken(rpcDigiToken, rpcDigis);
27 
29  iEvent.getByToken(rpcDigiSimLinkToken, theSimlinkDigis);
30 
32  iSetup.get<MuonGeometryRecord>().get(rpcGeom);
33 
34  for (const auto &&rpcdgIt : (*rpcDigis)) {
35  const RPCDetId &rpcId = rpcdgIt.first;
36  const RPCDigiCollection::Range &range = rpcdgIt.second;
37  if (rpcId.region() == 0)
38  continue;
39 
40  CPPFClusterizer clizer;
41  CPPFClusterContainer tcls = clizer.doAction(range);
42  CPPFMaskReClusterizer mrclizer;
44  CPPFClusterContainer cls = mrclizer.doAction(rpcId, tcls, mask);
45 
46  for (const auto &cl : cls) {
47  int isValid = rpcDigis.isValid();
48  int rawId = rpcId.rawId();
49  int Bx = cl.bx();
50  const int firststrip = cl.firstStrip();
51  const int clustersize = cl.clusterSize();
52  const int laststrip = cl.lastStrip();
53  const RPCRoll *roll = rpcGeom->roll(rpcId);
54  // Get Average Strip position
55  const float fstrip = (roll->centreOfStrip(firststrip)).x();
56  const float lstrip = (roll->centreOfStrip(laststrip)).x();
57  const float centreOfCluster = (fstrip + lstrip) / 2;
58  const double y = cl.hasY() ? cl.y() : 0;
59  LocalPoint lPos(centreOfCluster, y, 0);
60  if (roll->id().region() != 0) {
61  const auto &topo = dynamic_cast<const TrapezoidalStripTopology &>(roll->topology());
62  const double angle = topo.stripAngle((firststrip + laststrip) / 2.);
63  const double x = centreOfCluster - y * std::tan(angle);
64  lPos = LocalPoint(x, y, 0);
65  }
66  const BoundPlane &rollSurface = roll->surface();
67  GlobalPoint gPos = rollSurface.toGlobal(lPos);
68  float global_theta = emtf::rad_to_deg(gPos.theta().value());
69  float global_phi = emtf::rad_to_deg(gPos.phi().value());
70 
71  // Establish the average position of the rechit
72  int rechitstrip = firststrip;
73 
74  if (clustersize > 2) {
75  int medium = 0;
76  if (clustersize % 2 == 0)
77  medium = 0.5 * (clustersize);
78  else
79  medium = 0.5 * (clustersize - 1);
80  rechitstrip += medium;
81  }
82  if (clustersize > MaxClusterSize)
83  continue;
84  // This is just for test CPPFDigis with the RPC Geometry, It must be
85  // "true" in the normal runs
86  bool Geo = true;
88  // Set the EMTF Sector
89  int EMTFsector1 = 0;
90  int EMTFsector2 = 0;
91 
92  // sector 1
93  if ((global_phi > 15.) && (global_phi <= 16.3)) {
94  EMTFsector1 = 1;
95  EMTFsector2 = 6;
96  } else if ((global_phi > 16.3) && (global_phi <= 53.)) {
97  EMTFsector1 = 1;
98  EMTFsector2 = 0;
99  } else if ((global_phi > 53.) && (global_phi <= 75.)) {
100  EMTFsector1 = 1;
101  EMTFsector2 = 2;
102  }
103  // sector 2
104  else if ((global_phi > 75.) && (global_phi <= 76.3)) {
105  EMTFsector1 = 1;
106  EMTFsector2 = 2;
107  } else if ((global_phi > 76.3) && (global_phi <= 113.)) {
108  EMTFsector1 = 2;
109  EMTFsector2 = 0;
110  } else if ((global_phi > 113.) && (global_phi <= 135.)) {
111  EMTFsector1 = 2;
112  EMTFsector2 = 3;
113  }
114  // sector 3
115  // less than 180
116  else if ((global_phi > 135.) && (global_phi <= 136.3)) {
117  EMTFsector1 = 2;
118  EMTFsector2 = 3;
119  } else if ((global_phi > 136.3) && (global_phi <= 173.)) {
120  EMTFsector1 = 3;
121  EMTFsector2 = 0;
122  } else if ((global_phi > 173.) && (global_phi <= 180.)) {
123  EMTFsector1 = 3;
124  EMTFsector2 = 4;
125  }
126  // Greater than -180
127  else if ((global_phi < -165.) && (global_phi >= -180.)) {
128  EMTFsector1 = 3;
129  EMTFsector2 = 4;
130  }
131  // Fourth sector
132  else if ((global_phi > -165.) && (global_phi <= -163.7)) {
133  EMTFsector1 = 3;
134  EMTFsector2 = 4;
135  } else if ((global_phi > -163.7) && (global_phi <= -127.)) {
136  EMTFsector1 = 4;
137  EMTFsector2 = 0;
138  } else if ((global_phi > -127.) && (global_phi <= -105.)) {
139  EMTFsector1 = 4;
140  EMTFsector2 = 5;
141  }
142  // fifth sector
143  else if ((global_phi > -105.) && (global_phi <= -103.7)) {
144  EMTFsector1 = 4;
145  EMTFsector2 = 5;
146  } else if ((global_phi > -103.7) && (global_phi <= -67.)) {
147  EMTFsector1 = 5;
148  EMTFsector2 = 0;
149  } else if ((global_phi > -67.) && (global_phi <= -45.)) {
150  EMTFsector1 = 5;
151  EMTFsector2 = 6;
152  }
153  // sixth sector
154  else if ((global_phi > -45.) && (global_phi <= -43.7)) {
155  EMTFsector1 = 5;
156  EMTFsector2 = 6;
157  } else if ((global_phi > -43.7) && (global_phi <= -7.)) {
158  EMTFsector1 = 6;
159  EMTFsector2 = 0;
160  } else if ((global_phi > -7.) && (global_phi <= 15.)) {
161  EMTFsector1 = 6;
162  EMTFsector2 = 1;
163  }
164 
165  double EMTFLink1 = 0.;
166  double EMTFLink2 = 0.;
167  std::vector<RecHitProcessor::CppfItem>::iterator cppf1;
168  std::vector<RecHitProcessor::CppfItem>::iterator cppf;
169  for (cppf1 = CppfVec1.begin(); cppf1 != CppfVec1.end(); cppf1++) {
170  // Condition to save the CPPFDigi
171  if (((*cppf1).rawId == rawId) && ((*cppf1).strip == rechitstrip)) {
172  int old_strip = (*cppf1).strip;
173  int before = 0;
174  int after = 0;
175 
176  if (cppf1 != CppfVec1.begin())
177  before = (*(cppf1 - 2)).strip;
178  else if (cppf1 == CppfVec1.begin())
179  before = (*cppf1).strip;
180  if (cppf1 != CppfVec1.end())
181  after = (*(cppf1 + 2)).strip;
182  else if (cppf1 == CppfVec1.end())
183  after = (*cppf1).strip;
184  cppf = cppf1;
185 
186  if (clustersize == 2) {
187  if (firststrip == 1) {
188  if (before < after)
189  cppf = (cppf1 - 1);
190  else if (before > after)
191  cppf = (cppf1 + 1);
192  } else if (firststrip > 1) {
193  if (before < after)
194  cppf = (cppf1 + 1);
195  else if (before > after)
196  cppf = (cppf1 - 1);
197  }
198  }
199  // Using the RPCGeometry
200  if (Geo) {
201  std::shared_ptr<l1t::CPPFDigi> MainVariables1(new l1t::CPPFDigi(rpcId,
202  Bx,
203  (*cppf).int_phi,
204  (*cppf).int_theta,
205  isValid,
206  (*cppf).lb,
207  (*cppf).halfchannel,
208  EMTFsector1,
209  EMTFLink1,
210  old_strip,
211  clustersize,
212  global_phi,
213  global_theta));
214  std::shared_ptr<l1t::CPPFDigi> MainVariables2(new l1t::CPPFDigi(rpcId,
215  Bx,
216  (*cppf).int_phi,
217  (*cppf).int_theta,
218  isValid,
219  (*cppf).lb,
220  (*cppf).halfchannel,
221  EMTFsector2,
222  EMTFLink2,
223  old_strip,
224  clustersize,
225  global_phi,
226  global_theta));
227 
228  if ((EMTFsector1 > 0) && (EMTFsector2 == 0)) {
229  cppfDigis.push_back(*MainVariables1.get());
230  } else if ((EMTFsector1 > 0) && (EMTFsector2 > 0)) {
231  cppfDigis.push_back(*MainVariables1.get());
232  cppfDigis.push_back(*MainVariables2.get());
233  } else if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) {
234  continue;
235  }
236  } // Geo is true
237  else {
238  global_phi = 0.;
239  global_theta = 0.;
240  std::shared_ptr<l1t::CPPFDigi> MainVariables1(new l1t::CPPFDigi(rpcId,
241  Bx,
242  (*cppf).int_phi,
243  (*cppf).int_theta,
244  isValid,
245  (*cppf).lb,
246  (*cppf).halfchannel,
247  EMTFsector1,
248  EMTFLink1,
249  old_strip,
250  clustersize,
251  global_phi,
252  global_theta));
253  std::shared_ptr<l1t::CPPFDigi> MainVariables2(new l1t::CPPFDigi(rpcId,
254  Bx,
255  (*cppf).int_phi,
256  (*cppf).int_theta,
257  isValid,
258  (*cppf).lb,
259  (*cppf).halfchannel,
260  EMTFsector2,
261  EMTFLink2,
262  old_strip,
263  clustersize,
264  global_phi,
265  global_theta));
266  if ((EMTFsector1 > 0) && (EMTFsector2 == 0)) {
267  cppfDigis.push_back(*MainVariables1.get());
268  } else if ((EMTFsector1 > 0) && (EMTFsector2 > 0)) {
269  cppfDigis.push_back(*MainVariables1.get());
270  cppfDigis.push_back(*MainVariables2.get());
271  } else if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) {
272  continue;
273  }
274  }
275  } // Condition to save the CPPFDigi
276  } // Loop over the LUTVector
277  } //end loop over cludters
278  } //end loop over digis
279 } //end processlook function
280 
282  const edm::EventSetup &iSetup,
283  const edm::EDGetToken &recHitToken,
284  const edm::EDGetToken &rpcDigiToken,
285  const edm::EDGetToken &rpcDigiSimLinkToken,
286  l1t::CPPFDigiCollection &cppfDigis) const {
287  // Get the RPC Geometry
289  iSetup.get<MuonGeometryRecord>().get(rpcGeom);
290 
292  iEvent.getByToken(rpcDigiToken, rpcDigis);
293 
294  // Get the RecHits from the event
296  iEvent.getByToken(recHitToken, recHits);
297 
298  for (const auto &&rpcdgIt : (*rpcDigis)) {
299  const RPCDetId &rpcId = rpcdgIt.first;
300  const RPCDigiCollection::Range &range = rpcdgIt.second;
301  if (rpcId.region() == 0)
302  continue;
303 
304  CPPFClusterizer clizer;
305  CPPFClusterContainer tcls = clizer.doAction(range);
306  CPPFMaskReClusterizer mrclizer;
308  CPPFClusterContainer cls = mrclizer.doAction(rpcId, tcls, mask);
309 
310  for (const auto &cl : cls) {
311  int region = rpcId.region();
312  int isValid = rpcDigis.isValid();
313  // int rawId = rpcId.rawId();
314  int Bx = cl.bx();
315  const int firststrip = cl.firstStrip();
316  const int clustersize = cl.clusterSize();
317  const int laststrip = cl.lastStrip();
318  const RPCRoll *roll = rpcGeom->roll(rpcId);
319  // Get Average Strip position
320  const float fstrip = (roll->centreOfStrip(firststrip)).x();
321  const float lstrip = (roll->centreOfStrip(laststrip)).x();
322  const float centreOfCluster = (fstrip + lstrip) / 2;
323  const double y = cl.hasY() ? cl.y() : 0;
324  LocalPoint lPos(centreOfCluster, y, 0);
325  if (roll->id().region() != 0) {
326  const auto &topo = dynamic_cast<const TrapezoidalStripTopology &>(roll->topology());
327  const double angle = topo.stripAngle((firststrip + laststrip) / 2.);
328  const double x = centreOfCluster - y * std::tan(angle);
329  lPos = LocalPoint(x, y, 0);
330  }
331  const BoundPlane &rollSurface = roll->surface();
332  GlobalPoint gPos = rollSurface.toGlobal(lPos);
333  float global_theta = emtf::rad_to_deg(gPos.theta().value());
334  float global_phi = emtf::rad_to_deg(gPos.phi().value());
335 
336  // Endcap region only
337  if (region != 0) {
338  int int_theta =
339  (region == -1 ? 180. * 32. / 36.5 : 0.) + (float)region * global_theta * 32. / 36.5 - 8.5 * 32 / 36.5;
340  if (region == 1) {
341  if (global_theta < 8.5)
342  int_theta = 0;
343  if (global_theta > 45.)
344  int_theta = 31;
345  } else if (region == -1) {
346  if (global_theta < 135.)
347  int_theta = 31;
348  if (global_theta > 171.5)
349  int_theta = 0;
350  }
351  // Local EMTF
352  double local_phi = 0.;
353  int EMTFsector1 = 0;
354  int EMTFsector2 = 0;
355 
356  // sector 1
357  if ((global_phi > 15.) && (global_phi <= 16.3)) {
358  local_phi = global_phi - 15.;
359  EMTFsector1 = 1;
360  EMTFsector2 = 6;
361  } else if ((global_phi > 16.3) && (global_phi <= 53.)) {
362  local_phi = global_phi - 15.;
363  EMTFsector1 = 1;
364  EMTFsector2 = 0;
365  } else if ((global_phi > 53.) && (global_phi <= 75.)) {
366  local_phi = global_phi - 15.;
367  EMTFsector1 = 1;
368  EMTFsector2 = 2;
369  }
370  // sector 2
371  else if ((global_phi > 75.) && (global_phi <= 76.3)) {
372  local_phi = global_phi - 15.;
373  EMTFsector1 = 1;
374  EMTFsector2 = 2;
375  } else if ((global_phi > 76.3) && (global_phi <= 113.)) {
376  local_phi = global_phi - 75.;
377  EMTFsector1 = 2;
378  EMTFsector2 = 0;
379  } else if ((global_phi > 113.) && (global_phi <= 135.)) {
380  local_phi = global_phi - 75.;
381  EMTFsector1 = 2;
382  EMTFsector2 = 3;
383  }
384  // sector 3
385  // less than 180
386  else if ((global_phi > 135.) && (global_phi <= 136.3)) {
387  local_phi = global_phi - 75.;
388  EMTFsector1 = 2;
389  EMTFsector2 = 3;
390  } else if ((global_phi > 136.3) && (global_phi <= 173.)) {
391  local_phi = global_phi - 135.;
392  EMTFsector1 = 3;
393  EMTFsector2 = 0;
394  } else if ((global_phi > 173.) && (global_phi <= 180.)) {
395  local_phi = global_phi - 135.;
396  EMTFsector1 = 3;
397  EMTFsector2 = 4;
398  }
399  // Greater than -180
400  else if ((global_phi < -165.) && (global_phi >= -180.)) {
401  local_phi = global_phi + 225.;
402  EMTFsector1 = 3;
403  EMTFsector2 = 4;
404  }
405  // Fourth sector
406  else if ((global_phi > -165.) && (global_phi <= -163.7)) {
407  local_phi = global_phi + 225.;
408  EMTFsector1 = 3;
409  EMTFsector2 = 4;
410  } else if ((global_phi > -163.7) && (global_phi <= -127.)) {
411  local_phi = global_phi + 165.;
412  EMTFsector1 = 4;
413  EMTFsector2 = 0;
414  } else if ((global_phi > -127.) && (global_phi <= -105.)) {
415  local_phi = global_phi + 165.;
416  EMTFsector1 = 4;
417  EMTFsector2 = 5;
418  }
419  // fifth sector
420  else if ((global_phi > -105.) && (global_phi <= -103.7)) {
421  local_phi = global_phi + 165.;
422  EMTFsector1 = 4;
423  EMTFsector2 = 5;
424  } else if ((global_phi > -103.7) && (global_phi <= -67.)) {
425  local_phi = global_phi + 105.;
426  EMTFsector1 = 5;
427  EMTFsector2 = 0;
428  } else if ((global_phi > -67.) && (global_phi <= -45.)) {
429  local_phi = global_phi + 105.;
430  EMTFsector1 = 5;
431  EMTFsector2 = 6;
432  }
433  // sixth sector
434  else if ((global_phi > -45.) && (global_phi <= -43.7)) {
435  local_phi = global_phi + 105.;
436  EMTFsector1 = 5;
437  EMTFsector2 = 6;
438  } else if ((global_phi > -43.7) && (global_phi <= -7.)) {
439  local_phi = global_phi + 45.;
440  EMTFsector1 = 6;
441  EMTFsector2 = 0;
442  } else if ((global_phi > -7.) && (global_phi <= 15.)) {
443  local_phi = global_phi + 45.;
444  EMTFsector1 = 6;
445  EMTFsector2 = 1;
446  }
447 
448  int int_phi = int((local_phi + 22.0) * 15. + .5);
449  double EMTFLink1 = 0.;
450  double EMTFLink2 = 0.;
451  double lb = 0.;
452  double halfchannel = 0.;
453 
454  // Invalid hit
455  if (isValid == 0)
456  int_phi = 2047;
457  // Right integers range
458  assert(0 <= int_phi && int_phi < 1250);
459  assert(0 <= int_theta && int_theta < 32);
460 
461  std::shared_ptr<l1t::CPPFDigi> MainVariables1(new l1t::CPPFDigi(rpcId,
462  Bx,
463  int_phi,
464  int_theta,
465  isValid,
466  lb,
467  halfchannel,
468  EMTFsector1,
469  EMTFLink1,
470  firststrip,
471  clustersize,
472  global_phi,
473  global_theta));
474  std::shared_ptr<l1t::CPPFDigi> MainVariables2(new l1t::CPPFDigi(rpcId,
475  Bx,
476  int_phi,
477  int_theta,
478  isValid,
479  lb,
480  halfchannel,
481  EMTFsector2,
482  EMTFLink2,
483  firststrip,
484  clustersize,
485  global_phi,
486  global_theta));
487  if (int_theta == 31)
488  continue;
489  if ((EMTFsector1 > 0) && (EMTFsector2 == 0)) {
490  cppfDigis.push_back(*MainVariables1.get());
491  }
492  if ((EMTFsector1 > 0) && (EMTFsector2 > 0)) {
493  cppfDigis.push_back(*MainVariables1.get());
494  cppfDigis.push_back(*MainVariables2.get());
495  }
496  if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) {
497  continue;
498  }
499  } // No barrel hits
500  } //end loop over clusters
501  } //end loop over digis
502 } // End function: void RecHitProcessor::process()
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
assert(be >=bs)
CPPFClusterContainer doAction(const RPCDigiCollection::Range &digiRange)
constexpr uint32_t mask
Definition: gpuClustering.h:24
std::set< CPPFCluster > CPPFClusterContainer
void process(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::EDGetToken &recHitToken, const edm::EDGetToken &rpcDigiToken, const edm::EDGetToken &rpcDigiSimLinkToken, l1t::CPPFDigiCollection &cppfDigis) const
int iEvent
Definition: GenABIO.cc:224
void processLook(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::EDGetToken &recHitToken, const edm::EDGetToken &rpcDigiToken, const edm::EDGetToken &rpcDigiSimLinkToken, std::vector< RecHitProcessor::CppfItem > &CppfVec1, l1t::CPPFDigiCollection &cppfDigis, const int MaxClusterSize) const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
T get() const
Definition: EventSetup.h:82
CPPFClusterContainer doAction(const RPCDetId &id, CPPFClusterContainer &initClusters, const CPPFRollMask &mask) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::pair< const_iterator, const_iterator > Range
std::bitset< maskCPPFSIZE > CPPFRollMask
bool isValid() const
Definition: HandleBase.h:70
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
const Topology & topology() const override
Definition: RPCRoll.cc:18
RPCDetId id() const
Definition: RPCRoll.cc:16
double rad_to_deg(double rad)
Definition: TrackTools.h:77
T1 value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:75
std::vector< CPPFDigi > CPPFDigiCollection
Definition: CPPFDigi.h:83
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:26
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11