CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FWRecoGeometryESProducer.cc
Go to the documentation of this file.
1 #include <fstream>
2 #include <streambuf>
3 
8 
38 
39 #include "TNamed.h"
41 
43  const GeomDet* detUnit,
44  FWRecoGeometry& fwRecoGeometry) {
45  const PixelGeomDetUnit* det = dynamic_cast<const PixelGeomDetUnit*>(detUnit);
46  if (det) {
47  const PixelTopology* topo = &det->specificTopology();
48 
49  std::pair<float, float> pitch = topo->pitch();
50  fwRecoGeometry.idToName[rawid].topology[0] = pitch.first;
51  fwRecoGeometry.idToName[rawid].topology[1] = pitch.second;
52 
53  fwRecoGeometry.idToName[rawid].topology[2] = topo->localX(0.f); // offsetX
54  fwRecoGeometry.idToName[rawid].topology[3] = topo->localY(0.f); // offsetY
55 
56  // big pixels layout
57  fwRecoGeometry.idToName[rawid].topology[4] = topo->isItBigPixelInX(80) ? 0 : 1;
58  }
59 }
60 
63 
64 #define ADD_SISTRIP_TOPOLOGY(rawid, detUnit) \
65  const StripGeomDetUnit* det = dynamic_cast<const StripGeomDetUnit*>(detUnit); \
66  if (det) { \
67  if (const StripTopology* topo = dynamic_cast<const StripTopology*>(&det->specificTopology())) { \
68  fwRecoGeometry.idToName[rawid].topology[0] = 0; \
69  fwRecoGeometry.idToName[rawid].topology[1] = topo->nstrips(); \
70  fwRecoGeometry.idToName[rawid].topology[2] = topo->stripLength(); \
71  } \
72  if (const RadialStripTopology* rtop = \
73  dynamic_cast<const RadialStripTopology*>(&(det->specificType().specificTopology()))) { \
74  fwRecoGeometry.idToName[rawid].topology[0] = 1; \
75  fwRecoGeometry.idToName[rawid].topology[3] = rtop->yAxisOrientation(); \
76  fwRecoGeometry.idToName[rawid].topology[4] = rtop->originToIntersection(); \
77  fwRecoGeometry.idToName[rawid].topology[5] = rtop->phiOfOneEdge(); \
78  fwRecoGeometry.idToName[rawid].topology[6] = rtop->angularWidth(); \
79  } else if (const RectangularStripTopology* topo = \
80  dynamic_cast<const RectangularStripTopology*>(&(det->specificType().specificTopology()))) { \
81  fwRecoGeometry.idToName[rawid].topology[0] = 2; \
82  fwRecoGeometry.idToName[rawid].topology[3] = topo->pitch(); \
83  } else if (const TrapezoidalStripTopology* topo = \
84  dynamic_cast<const TrapezoidalStripTopology*>(&(det->specificType().specificTopology()))) { \
85  fwRecoGeometry.idToName[rawid].topology[0] = 3; \
86  fwRecoGeometry.idToName[rawid].topology[3] = topo->pitch(); \
87  } \
88  } else { \
89  const Phase2TrackerGeomDetUnit* det = dynamic_cast<const Phase2TrackerGeomDetUnit*>(detUnit); \
90  if (det) { \
91  if (const Phase2TrackerTopology* topo = \
92  dynamic_cast<const Phase2TrackerTopology*>(&(det->specificTopology()))) { \
93  fwRecoGeometry.idToName[rawid].topology[0] = topo->pitch().first; \
94  fwRecoGeometry.idToName[rawid].topology[1] = topo->pitch().second; \
95  } \
96  } \
97  }
98 
99 namespace {
100  const std::array<std::string, 3> hgcal_geom_names = {
101  {"HGCalEESensitive", "HGCalHESiliconSensitive", "HGCalHEScintillatorSensitive"}};
102 }
103 
105  m_tracker = pset.getUntrackedParameter<bool>("Tracker", true);
106  m_muon = pset.getUntrackedParameter<bool>("Muon", true);
107  m_gem = pset.getUntrackedParameter<bool>("GEM", false);
108  m_calo = pset.getUntrackedParameter<bool>("Calo", true);
109  m_timing = pset.getUntrackedParameter<bool>("Timing", false);
110  auto cc = setWhatProduced(this);
111 
112  if (m_muon)
113  m_gem = true;
114  if (m_tracker or m_muon or m_gem) {
115  m_trackingGeomToken = cc.consumes();
116  }
117  if (m_timing) {
118  m_ftlBarrelGeomToken = cc.consumes(edm::ESInputTag{"", "FastTimeBarrel"});
119  m_ftlEndcapGeomToken = cc.consumes(edm::ESInputTag{"", "SFBX"});
120  }
121  if (m_calo) {
122  m_caloGeomToken = cc.consumes();
123  }
124 }
125 
127 
128 std::unique_ptr<FWRecoGeometry> FWRecoGeometryESProducer::produce(const FWRecoGeometryRecord& record) {
129  using namespace edm;
130 
131  auto fwRecoGeometry = std::make_unique<FWRecoGeometry>();
132 
133  if (m_tracker || m_muon || m_gem) {
135  }
136 
137  if (m_tracker) {
138  DetId detId(DetId::Tracker, 0);
139  m_trackerGeom = static_cast<const TrackerGeometry*>(m_trackingGeom->slaveGeometry(detId));
140  addPixelBarrelGeometry(*fwRecoGeometry);
141  addPixelForwardGeometry(*fwRecoGeometry);
142  addTIBGeometry(*fwRecoGeometry);
143  addTIDGeometry(*fwRecoGeometry);
144  addTOBGeometry(*fwRecoGeometry);
145  addTECGeometry(*fwRecoGeometry);
146  writeTrackerParametersXML(*fwRecoGeometry);
147  }
148  if (m_muon) {
149  addDTGeometry(*fwRecoGeometry);
150  addCSCGeometry(*fwRecoGeometry);
151  addRPCGeometry(*fwRecoGeometry);
152  addME0Geometry(*fwRecoGeometry);
153  }
154  if (m_gem) {
155  addGEMGeometry(*fwRecoGeometry);
156  }
157  if (m_calo) {
159  addCaloGeometry(*fwRecoGeometry);
160  }
161 
162  if (m_timing) {
165  addFTLGeometry(*fwRecoGeometry);
166  }
167 
168  fwRecoGeometry->idToName.resize(m_current + 1);
169  std::vector<FWRecoGeom::Info>(fwRecoGeometry->idToName).swap(fwRecoGeometry->idToName);
170  std::sort(fwRecoGeometry->idToName.begin(), fwRecoGeometry->idToName.end());
171 
172  return fwRecoGeometry;
173 }
174 
176  DetId detId(DetId::Muon, 2);
177  const CSCGeometry* cscGeometry = static_cast<const CSCGeometry*>(m_trackingGeom->slaveGeometry(detId));
178  for (auto it = cscGeometry->chambers().begin(), end = cscGeometry->chambers().end(); it != end; ++it) {
179  const CSCChamber* chamber = *it;
180 
181  if (chamber) {
182  unsigned int rawid = chamber->geographicalId();
183  unsigned int current = insert_id(rawid, fwRecoGeometry);
184  fillShapeAndPlacement(current, chamber, fwRecoGeometry);
185  //
186  // CSC layers geometry
187  //
188  for (std::vector<const CSCLayer*>::const_iterator lit = chamber->layers().begin(), lend = chamber->layers().end();
189  lit != lend;
190  ++lit) {
191  const CSCLayer* layer = *lit;
192 
193  if (layer) {
194  unsigned int rawid = layer->geographicalId();
195  unsigned int current = insert_id(rawid, fwRecoGeometry);
196  fillShapeAndPlacement(current, layer, fwRecoGeometry);
197 
198  const CSCStripTopology* stripTopology = layer->geometry()->topology();
199  fwRecoGeometry.idToName[current].topology[0] = stripTopology->yAxisOrientation();
200  fwRecoGeometry.idToName[current].topology[1] = stripTopology->centreToIntersection();
201  fwRecoGeometry.idToName[current].topology[2] = stripTopology->yCentreOfStripPlane();
202  fwRecoGeometry.idToName[current].topology[3] = stripTopology->phiOfOneEdge();
203  fwRecoGeometry.idToName[current].topology[4] = stripTopology->stripOffset();
204  fwRecoGeometry.idToName[current].topology[5] = stripTopology->angularWidth();
205 
206  const CSCWireTopology* wireTopology = layer->geometry()->wireTopology();
207  fwRecoGeometry.idToName[current].topology[6] = wireTopology->wireSpacing();
208  fwRecoGeometry.idToName[current].topology[7] = wireTopology->wireAngle();
209  }
210  }
211  }
212  }
213 }
214 
216  DetId detId(DetId::Muon, 1);
217  const DTGeometry* dtGeometry = static_cast<const DTGeometry*>(m_trackingGeom->slaveGeometry(detId));
218 
219  //
220  // DT chambers geometry
221  //
222  for (auto it = dtGeometry->chambers().begin(), end = dtGeometry->chambers().end(); it != end; ++it) {
223  const DTChamber* chamber = *it;
224 
225  if (chamber) {
226  unsigned int rawid = chamber->geographicalId().rawId();
227  unsigned int current = insert_id(rawid, fwRecoGeometry);
228  fillShapeAndPlacement(current, chamber, fwRecoGeometry);
229  }
230  }
231 
232  // Fill in DT layer parameters
233  for (auto it = dtGeometry->layers().begin(), end = dtGeometry->layers().end(); it != end; ++it) {
234  const DTLayer* layer = *it;
235 
236  if (layer) {
237  unsigned int rawid = layer->id().rawId();
238  unsigned int current = insert_id(rawid, fwRecoGeometry);
239  fillShapeAndPlacement(current, layer, fwRecoGeometry);
240 
241  const DTTopology& topo = layer->specificTopology();
242  const BoundPlane& surf = layer->surface();
243  // Topology W/H/L:
244  fwRecoGeometry.idToName[current].topology[0] = topo.cellWidth();
245  fwRecoGeometry.idToName[current].topology[1] = topo.cellHeight();
246  fwRecoGeometry.idToName[current].topology[2] = topo.cellLenght();
247  fwRecoGeometry.idToName[current].topology[3] = topo.firstChannel();
248  fwRecoGeometry.idToName[current].topology[4] = topo.lastChannel();
249  fwRecoGeometry.idToName[current].topology[5] = topo.channels();
250 
251  // Bounds W/H/L:
252  fwRecoGeometry.idToName[current].topology[6] = surf.bounds().width();
253  fwRecoGeometry.idToName[current].topology[7] = surf.bounds().thickness();
254  fwRecoGeometry.idToName[current].topology[8] = surf.bounds().length();
255  }
256  }
257 }
258 
260  //
261  // RPC rolls geometry
262  //
263  DetId detId(DetId::Muon, 3);
264  const RPCGeometry* rpcGeom = static_cast<const RPCGeometry*>(m_trackingGeom->slaveGeometry(detId));
265  for (auto it = rpcGeom->rolls().begin(), end = rpcGeom->rolls().end(); it != end; ++it) {
266  const RPCRoll* roll = (*it);
267  if (roll) {
268  unsigned int rawid = roll->geographicalId().rawId();
269  unsigned int current = insert_id(rawid, fwRecoGeometry);
270  fillShapeAndPlacement(current, roll, fwRecoGeometry);
271 
272  const StripTopology& topo = roll->specificTopology();
273  fwRecoGeometry.idToName[current].topology[0] = topo.nstrips();
274  fwRecoGeometry.idToName[current].topology[1] = topo.stripLength();
275  fwRecoGeometry.idToName[current].topology[2] = topo.pitch();
276  }
277  }
278 
279  try {
280  RPCDetId id(1, 1, 4, 1, 1, 1, 1);
282  fwRecoGeometry.extraDet.Add(new TNamed("RE4", "RPC endcap station 4"));
283  } catch (std::runtime_error& e) {
284  std::cerr << e.what() << std::endl;
285  }
286 }
287 
289  //
290  // GEM geometry
291  //
292 
293  try {
294  DetId detId(DetId::Muon, 4);
295  const GEMGeometry* gemGeom = static_cast<const GEMGeometry*>(m_trackingGeom->slaveGeometry(detId));
296 
297  // add in superChambers - gem Segments are based on superChambers
298  for (auto sc : gemGeom->superChambers()) {
299  if (sc) {
300  unsigned int rawid = sc->geographicalId().rawId();
301  unsigned int current = insert_id(rawid, fwRecoGeometry);
302  fillShapeAndPlacement(current, sc, fwRecoGeometry);
303  }
304  }
305  // add in chambers
306  for (auto ch : gemGeom->chambers()) {
307  if (ch) {
308  unsigned int rawid = ch->geographicalId().rawId();
309  unsigned int current = insert_id(rawid, fwRecoGeometry);
310  fillShapeAndPlacement(current, ch, fwRecoGeometry);
311  }
312  }
313  // add in etaPartitions - gem rechits are based on etaPartitions
314  for (auto roll : gemGeom->etaPartitions()) {
315  if (roll) {
316  unsigned int rawid = roll->geographicalId().rawId();
317  unsigned int current = insert_id(rawid, fwRecoGeometry);
318  fillShapeAndPlacement(current, roll, fwRecoGeometry);
319 
320  const StripTopology& topo = roll->specificTopology();
321  fwRecoGeometry.idToName[current].topology[0] = topo.nstrips();
322  fwRecoGeometry.idToName[current].topology[1] = topo.stripLength();
323  fwRecoGeometry.idToName[current].topology[2] = topo.pitch();
324 
325  float height = topo.stripLength() / 2;
326  LocalPoint lTop(0., height, 0.);
327  LocalPoint lBottom(0., -height, 0.);
328  fwRecoGeometry.idToName[current].topology[3] = roll->localPitch(lTop);
329  fwRecoGeometry.idToName[current].topology[4] = roll->localPitch(lBottom);
330  fwRecoGeometry.idToName[current].topology[5] = roll->npads();
331  }
332  }
333 
334  fwRecoGeometry.extraDet.Add(new TNamed("GEM", "GEM muon detector"));
335  try {
336  GEMDetId id(1, 1, 2, 1, 1, 1);
338  fwRecoGeometry.extraDet.Add(new TNamed("GE2", "GEM endcap station 2"));
339  } catch (std::runtime_error& e) {
340  std::cerr << e.what() << std::endl;
341  }
342 
343  } catch (cms::Exception& exception) {
344  edm::LogError("FWRecoGeometry") << " GEM geometry not found " << exception.what() << std::endl;
345  }
346 }
347 
349  //
350  // ME0 geometry
351  //
352 
353  DetId detId(DetId::Muon, 5);
354  try {
355  const ME0Geometry* me0Geom = static_cast<const ME0Geometry*>(m_trackingGeom->slaveGeometry(detId));
356  for (auto roll : me0Geom->etaPartitions()) {
357  if (roll) {
358  unsigned int rawid = roll->geographicalId().rawId();
359  unsigned int current = insert_id(rawid, fwRecoGeometry);
360  fillShapeAndPlacement(current, roll, fwRecoGeometry);
361 
362  const StripTopology& topo = roll->specificTopology();
363  fwRecoGeometry.idToName[current].topology[0] = topo.nstrips();
364  fwRecoGeometry.idToName[current].topology[1] = topo.stripLength();
365  fwRecoGeometry.idToName[current].topology[2] = topo.pitch();
366 
367  float height = topo.stripLength() / 2;
368  LocalPoint lTop(0., height, 0.);
369  LocalPoint lBottom(0., -height, 0.);
370  fwRecoGeometry.idToName[current].topology[3] = roll->localPitch(lTop);
371  fwRecoGeometry.idToName[current].topology[4] = roll->localPitch(lBottom);
372  fwRecoGeometry.idToName[current].topology[5] = roll->npads();
373  }
374  }
375  fwRecoGeometry.extraDet.Add(new TNamed("ME0", "ME0 muon detector"));
376  } catch (cms::Exception& exception) {
377  edm::LogError("FWRecoGeometry") << " ME0 geometry not found " << exception.what() << std::endl;
378  }
379 }
380 
382  for (TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXB().begin(),
383  end = m_trackerGeom->detsPXB().end();
384  it != end;
385  ++it) {
386  const GeomDet* det = *it;
387 
388  if (det) {
389  DetId detid = det->geographicalId();
390  unsigned int rawid = detid.rawId();
391  unsigned int current = insert_id(rawid, fwRecoGeometry);
392  fillShapeAndPlacement(current, det, fwRecoGeometry);
393 
394  ADD_PIXEL_TOPOLOGY(current, m_trackerGeom->idToDetUnit(detid), fwRecoGeometry);
395  }
396  }
397 }
398 
400  for (TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXF().begin(),
401  end = m_trackerGeom->detsPXF().end();
402  it != end;
403  ++it) {
404  const GeomDet* det = *it;
405 
406  if (det) {
407  DetId detid = det->geographicalId();
408  unsigned int rawid = detid.rawId();
409  unsigned int current = insert_id(rawid, fwRecoGeometry);
410  fillShapeAndPlacement(current, det, fwRecoGeometry);
411 
412  ADD_PIXEL_TOPOLOGY(current, m_trackerGeom->idToDetUnit(detid), fwRecoGeometry);
413  }
414  }
415 }
416 
418  for (TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTIB().begin(),
419  end = m_trackerGeom->detsTIB().end();
420  it != end;
421  ++it) {
422  const GeomDet* det = *it;
423 
424  if (det) {
425  DetId detid = det->geographicalId();
426  unsigned int rawid = detid.rawId();
427  unsigned int current = insert_id(rawid, fwRecoGeometry);
428  fillShapeAndPlacement(current, det, fwRecoGeometry);
429 
430  ADD_SISTRIP_TOPOLOGY(current, m_trackerGeom->idToDet(detid));
431  }
432  }
433 }
434 
436  for (TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTOB().begin(),
437  end = m_trackerGeom->detsTOB().end();
438  it != end;
439  ++it) {
440  const GeomDet* det = *it;
441 
442  if (det) {
443  DetId detid = det->geographicalId();
444  unsigned int rawid = detid.rawId();
445  unsigned int current = insert_id(rawid, fwRecoGeometry);
446  fillShapeAndPlacement(current, det, fwRecoGeometry);
447 
448  ADD_SISTRIP_TOPOLOGY(current, m_trackerGeom->idToDet(detid));
449  }
450  }
451 }
452 
454  for (TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTID().begin(),
455  end = m_trackerGeom->detsTID().end();
456  it != end;
457  ++it) {
458  const GeomDet* det = *it;
459 
460  if (det) {
461  DetId detid = det->geographicalId();
462  unsigned int rawid = detid.rawId();
463  unsigned int current = insert_id(rawid, fwRecoGeometry);
464  fillShapeAndPlacement(current, det, fwRecoGeometry);
465 
466  ADD_SISTRIP_TOPOLOGY(current, m_trackerGeom->idToDet(detid));
467  }
468  }
469 }
470 
472  for (TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTEC().begin(),
473  end = m_trackerGeom->detsTEC().end();
474  it != end;
475  ++it) {
476  const GeomDet* det = *it;
477 
478  if (det) {
479  DetId detid = det->geographicalId();
480  unsigned int rawid = detid.rawId();
481  unsigned int current = insert_id(rawid, fwRecoGeometry);
482  fillShapeAndPlacement(current, det, fwRecoGeometry);
483 
484  ADD_SISTRIP_TOPOLOGY(current, m_trackerGeom->idToDet(detid));
485  }
486  }
487 }
488 
490  std::vector<DetId> vid = m_caloGeom->getValidDetIds(); // Calo
491  std::set<DetId> cache;
492  for (std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it) {
493  unsigned int id = insert_id(it->rawId(), fwRecoGeometry);
494  if (!((DetId::Forward == it->det()) || (DetId::HGCalEE == it->det()) || (DetId::HGCalHSi == it->det()) ||
495  (DetId::HGCalHSc == it->det()))) {
496  const CaloCellGeometry::CornersVec& cor = m_caloGeom->getGeometry(*it)->getCorners();
497  fillPoints(id, cor.begin(), cor.end(), fwRecoGeometry);
498  } else {
499  DetId::Detector det = it->det();
500  int subdet = (((DetId::HGCalEE == det) || (DetId::HGCalHSi == det) || (DetId::HGCalHSc == det)) ? ForwardEmpty
501  : it->subdetId());
502  const HGCalGeometry* geom = dynamic_cast<const HGCalGeometry*>(m_caloGeom->getSubdetectorGeometry(det, subdet));
503  hgcal::RecHitTools rhtools;
504  rhtools.setGeometry(*m_caloGeom);
505  const auto cor = geom->getNewCorners(*it);
506 
507  // roll = yaw = pitch = 0
508  fwRecoGeometry.idToName[id].matrix[0] = 1.0;
509  fwRecoGeometry.idToName[id].matrix[4] = 1.0;
510  fwRecoGeometry.idToName[id].matrix[8] = 1.0;
511 
512  // corners of the front face
513  for (uint i = 0; i < (cor.size() - 1); ++i) {
514  fwRecoGeometry.idToName[id].points[i * 3 + 0] = cor[i].x();
515  fwRecoGeometry.idToName[id].points[i * 3 + 1] = cor[i].y();
516  fwRecoGeometry.idToName[id].points[i * 3 + 2] = cor[i].z();
517  }
518 
519  // center
520  auto center = geom->getPosition(*it);
521  fwRecoGeometry.idToName[id].points[(cor.size() - 1) * 3 + 0] = center.x();
522  fwRecoGeometry.idToName[id].points[(cor.size() - 1) * 3 + 1] = center.y();
523  fwRecoGeometry.idToName[id].points[(cor.size() - 1) * 3 + 2] = center.z();
524 
525  // Cells rotation (read few lines below)
526  fwRecoGeometry.idToName[id].shape[2] = 0.;
527 
528  // Thickness
529  fwRecoGeometry.idToName[id].shape[3] = cor[cor.size() - 1].z();
530 
531  // total points
532  fwRecoGeometry.idToName[id].topology[0] = cor.size() - 1;
533 
534  // Layer with Offset
535  fwRecoGeometry.idToName[id].topology[1] = rhtools.getLayerWithOffset(it->rawId());
536 
537  // Zside, +/- 1
538  fwRecoGeometry.idToName[id].topology[2] = rhtools.zside(it->rawId());
539 
540  // Is Silicon
541  fwRecoGeometry.idToName[id].topology[3] = rhtools.isSilicon(it->rawId());
542 
543  // Silicon index
544  fwRecoGeometry.idToName[id].topology[4] =
545  rhtools.isSilicon(it->rawId()) ? rhtools.getSiThickIndex(it->rawId()) : -1.;
546 
547  // Last EE layer
548  fwRecoGeometry.idToName[id].topology[5] = rhtools.lastLayerEE();
549 
550  // Compute the orientation of each cell. The orientation here is simply
551  // addressing the corner or side bottom layout of the cell and should not
552  // be confused with the concept of orientation embedded in the flat-file
553  // description. The default orientation of the cells within a wafer is
554  // with the side at the bottom. The points returned by the HGCal query
555  // will be ordered counter-clockwise, with the first corner in the
556  // uppermost-right position. The corners used to calculate the angle wrt
557  // the Y scale are corner 0 and corner 3, that are opposite in the cells.
558  // The angle should be 30 degrees wrt the Y axis for all cells in the
559  // default position. For the rotated layers in CE-H, the situation is
560  // such that the cells are oriented with a vertex down (assuming those
561  // layers will have a 30 degrees rotation): this will establish an angle
562  // of 60 degrees wrt the Y axis. The default way in which an hexagon is
563  // rendered inside Fireworks is with the vertex down.
564  if (rhtools.isSilicon(it->rawId())) {
565  auto val_x = (cor[0].x() - cor[3].x());
566  auto val_y = (cor[0].y() - cor[3].y());
567  auto val = round(std::acos(val_y / std::sqrt(val_x * val_x + val_y * val_y)) / M_PI * 180.);
568  // Pass down the chain the vaue of the rotation of the cell wrt the Y axis.
569  fwRecoGeometry.idToName[id].shape[2] = val;
570  }
571 
572  // For each and every wafer in HGCal, add a "fake" DetId with cells'
573  // (u,v) bits set to 1 . Those DetIds will be used inside Fireworks to
574  // render the HGCal Geometry. Due to the huge number of cells involved,
575  // the HGCal geometry for the Silicon Sensor is wafer-based, not cells
576  // based. The representation of the single RecHits and of all quantities
577  // derived from those, is instead fully cells based. The geometry
578  // representation of the Scintillator is directly based on tiles,
579  // therefore no fake DetId creations is needed.
580  if ((det == DetId::HGCalEE) || (det == DetId::HGCalHSi)) {
581  // Avoid hard coding masks by using static data members from HGCSiliconDetId
584  DetId wafer_detid = it->rawId() | maskZeroUV;
585  // Just be damn sure that's a fake id.
586  assert(wafer_detid != it->rawId());
587  auto [iter, is_new] = cache.insert(wafer_detid);
588  if (is_new) {
589  unsigned int local_id = insert_id(wafer_detid, fwRecoGeometry);
590  auto const& dddConstants = geom->topology().dddConstants();
591  auto wafer_size = static_cast<float>(dddConstants.waferSize(true));
592  auto R = wafer_size / std::sqrt(3.f);
593  auto r = wafer_size / 2.f;
594  float x[6] = {-r, -r, 0.f, r, r, 0.f};
595  float y[6] = {R / 2.f, -R / 2.f, -R, -R / 2.f, R / 2.f, R};
596  float z[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
597  for (unsigned int i = 0; i < 6; ++i) {
598  HepGeom::Point3D<float> wafer_corner(x[i], y[i], z[i]);
599  auto point =
600  geom->topology().dddConstants().waferLocal2Global(wafer_corner, wafer_detid, true, true, false);
601  fwRecoGeometry.idToName[local_id].points[i * 3 + 0] = point.x();
602  fwRecoGeometry.idToName[local_id].points[i * 3 + 1] = point.y();
603  fwRecoGeometry.idToName[local_id].points[i * 3 + 2] = point.z();
604  }
605  // Nota Bene: rotations of full layers (and wafers therein) is taken
606  // care of internally by the call to the waferLocal2Global method.
607  // Therefore we set up the unit matrix for the rotation.
608  // roll = yaw = pitch = 0
609  fwRecoGeometry.idToName[local_id].matrix[0] = 1.0;
610  fwRecoGeometry.idToName[local_id].matrix[4] = 1.0;
611  fwRecoGeometry.idToName[local_id].matrix[8] = 1.0;
612 
613  // thickness
614  fwRecoGeometry.idToName[local_id].shape[3] = cor[cor.size() - 1].z();
615 
616  // total points
617  fwRecoGeometry.idToName[local_id].topology[0] = 6;
618 
619  // Layer with Offset
620  fwRecoGeometry.idToName[local_id].topology[1] = rhtools.getLayerWithOffset(it->rawId());
621 
622  // Zside, +/- 1
623  fwRecoGeometry.idToName[local_id].topology[2] = rhtools.zside(it->rawId());
624 
625  // Is Silicon
626  fwRecoGeometry.idToName[local_id].topology[3] = rhtools.isSilicon(it->rawId());
627 
628  // Silicon index
629  fwRecoGeometry.idToName[local_id].topology[4] =
630  rhtools.isSilicon(it->rawId()) ? rhtools.getSiThickIndex(it->rawId()) : -1.;
631 
632  // Last EE layer
633  fwRecoGeometry.idToName[local_id].topology[5] = rhtools.lastLayerEE();
634  }
635  }
636  }
637  }
638 }
639 
641  // do the barrel
642  for (const auto& detid : m_ftlBarrelGeom->getValidDetIds()) {
643  unsigned int id = insert_id(detid.rawId(), fwRecoGeometry);
644  const auto& cor = m_ftlBarrelGeom->getCorners(detid);
645  fillPoints(id, cor.begin(), cor.end(), fwRecoGeometry);
646  }
647  // do the endcap
648  for (const auto& detid : m_ftlEndcapGeom->getValidDetIds()) {
649  unsigned int id = insert_id(detid.rawId(), fwRecoGeometry);
650  const auto& cor = m_ftlEndcapGeom->getCorners(detid);
651  fillPoints(id, cor.begin(), cor.end(), fwRecoGeometry);
652  }
653 }
654 
655 unsigned int FWRecoGeometryESProducer::insert_id(unsigned int rawid, FWRecoGeometry& fwRecoGeometry) {
656  ++m_current;
657  fwRecoGeometry.idToName.push_back(FWRecoGeom::Info());
658  fwRecoGeometry.idToName.back().id = rawid;
659 
660  return m_current;
661 }
662 
664  std::vector<GlobalPoint>::const_iterator begin,
665  std::vector<GlobalPoint>::const_iterator end,
666  FWRecoGeometry& fwRecoGeometry) {
667  unsigned int index(0);
668  for (std::vector<GlobalPoint>::const_iterator i = begin; i != end; ++i) {
670  fwRecoGeometry.idToName[id].points[index] = i->x();
671  fwRecoGeometry.idToName[id].points[++index] = i->y();
672  fwRecoGeometry.idToName[id].points[++index] = i->z();
673  ++index;
674  }
675 }
676 
679  const GeomDet* det,
680  FWRecoGeometry& fwRecoGeometry) {
681  // Trapezoidal
682  const Bounds* b = &((det->surface()).bounds());
683  if (const TrapezoidalPlaneBounds* b2 = dynamic_cast<const TrapezoidalPlaneBounds*>(b)) {
684  std::array<const float, 4> const& par = b2->parameters();
685 
686  // These parameters are half-lengths, as in CMSIM/GEANT3
687  fwRecoGeometry.idToName[id].shape[0] = 1;
688  fwRecoGeometry.idToName[id].shape[1] = par[0]; // hBottomEdge
689  fwRecoGeometry.idToName[id].shape[2] = par[1]; // hTopEdge
690  fwRecoGeometry.idToName[id].shape[3] = par[2]; // thickness
691  fwRecoGeometry.idToName[id].shape[4] = par[3]; // apothem
692  }
693  if (const RectangularPlaneBounds* b2 = dynamic_cast<const RectangularPlaneBounds*>(b)) {
694  // Rectangular
695  fwRecoGeometry.idToName[id].shape[0] = 2;
696  fwRecoGeometry.idToName[id].shape[1] = b2->width() * 0.5; // half width
697  fwRecoGeometry.idToName[id].shape[2] = b2->length() * 0.5; // half length
698  fwRecoGeometry.idToName[id].shape[3] = b2->thickness() * 0.5; // half thickness
699  }
700 
701  // Position of the DetUnit's center
702  GlobalPoint pos = det->surface().position();
703  fwRecoGeometry.idToName[id].translation[0] = pos.x();
704  fwRecoGeometry.idToName[id].translation[1] = pos.y();
705  fwRecoGeometry.idToName[id].translation[2] = pos.z();
706 
707  // Add the coeff of the rotation matrix
708  // with a projection on the basis vectors
709  TkRotation<float> detRot = det->surface().rotation();
710  fwRecoGeometry.idToName[id].matrix[0] = detRot.xx();
711  fwRecoGeometry.idToName[id].matrix[1] = detRot.yx();
712  fwRecoGeometry.idToName[id].matrix[2] = detRot.zx();
713  fwRecoGeometry.idToName[id].matrix[3] = detRot.xy();
714  fwRecoGeometry.idToName[id].matrix[4] = detRot.yy();
715  fwRecoGeometry.idToName[id].matrix[5] = detRot.zy();
716  fwRecoGeometry.idToName[id].matrix[6] = detRot.xz();
717  fwRecoGeometry.idToName[id].matrix[7] = detRot.yz();
718  fwRecoGeometry.idToName[id].matrix[8] = detRot.zz();
719 }
720 
722  std::string path = "Geometry/TrackerCommonData/data/";
724  path += "PhaseI/";
727  path += "PhaseII/";
728  }
729  path += "trackerParameters.xml";
731  std::ifstream t(fullPath);
732  std::stringstream buffer;
733  buffer << t.rdbuf();
734  fwRecoGeometry.trackerTopologyXML = buffer.str();
735 }
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > m_caloGeomToken
const DetContainer & detsTIB() const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
virtual int nstrips() const =0
std::string trackerTopologyXML
float centreToIntersection() const override
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const FastTimeGeometry * m_ftlBarrelGeom
T xx() const
void fillShapeAndPlacement(unsigned int id, const GeomDet *det, FWRecoGeometry &)
void addFTLGeometry(FWRecoGeometry &)
std::string fullPath() const
Definition: FileInPath.cc:161
const DetContainer & detsPXB() const
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
void addTOBGeometry(FWRecoGeometry &)
float cellLenght() const
Definition: DTTopology.h:74
CornersVec getCorners(const DetId &id) const
Returns the corner points of this cell&#39;s volume.
FWRecoGeometryESProducer(const edm::ParameterSet &)
void addTIBGeometry(FWRecoGeometry &)
T xy() const
float phiOfOneEdge() const override
static const int kHGCalCellUMask
static const int maxPoints_
T zz() const
const DetContainer & detsPXF() const
T yy() const
const GlobalTrackingGeometry * m_trackingGeom
T yz() const
Log< level::Error, false > LogError
void addRPCGeometry(FWRecoGeometry &)
static const int kHGCalCellVOffset
assert(be >=bs)
const TrackerGeometry * m_trackerGeom
int zside(const DetId &id) const
Definition: RecHitTools.cc:163
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
std::unique_ptr< FWRecoGeometry > produce(const FWRecoGeometryRecord &)
constexpr std::array< uint8_t, layerIndexSize > layer
float yAxisOrientation() const override
void fillPoints(unsigned int id, std::vector< GlobalPoint >::const_iterator begin, std::vector< GlobalPoint >::const_iterator end, FWRecoGeometry &)
FWRecoGeom::InfoMap idToName
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
void addCaloGeometry(FWRecoGeometry &)
virtual float localX(float mpX) const =0
T zx() const
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:38
float wireAngle() const override
virtual float stripLength() const =0
const_iterator end() const
Definition: EZArrayFL.h:53
const FastTimeGeometry * m_ftlEndcapGeom
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:69
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > m_trackingGeomToken
const DetContainer & detsTOB() const
static const int kHGCalCellVMask
virtual float stripOffset(void) const
virtual bool isItBigPixelInX(int ixbin) const =0
bool isThere(GeomDetEnumerators::SubDetector subdet) const
T sqrt(T t)
Definition: SSEVec.h:19
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void addPixelForwardGeometry(FWRecoGeometry &)
const_iterator begin() const
Definition: EZArrayFL.h:52
void writeTrackerParametersXML(FWRecoGeometry &)
T zy() const
bool isSilicon(const DetId &) const
Definition: RecHitTools.cc:428
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:60
double f[11][100]
float angularWidth() const override
weight_default_t b2[10]
Definition: b2.h:9
double wireSpacing() const
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
void ADD_PIXEL_TOPOLOGY(unsigned int rawid, const GeomDet *detUnit, FWRecoGeometry &)
const TrackerGeomDet * idToDet(DetId) const override
const StripTopology & specificTopology() const
Definition: RPCRoll.cc:49
#define M_PI
void addCSCGeometry(FWRecoGeometry &)
void addTECGeometry(FWRecoGeometry &)
edm::ESGetToken< FastTimeGeometry, IdealGeometryRecord > m_ftlBarrelGeomToken
Definition: DetId.h:17
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
float yCentreOfStripPlane() const override
const PositionType & position() const
virtual float localY(float mpY) const =0
const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const override
Get a list of valid detector ids (for the given subdetector)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:75
Detector
Definition: DetId.h:24
static const int kHGCalCellUOffset
#define ADD_SISTRIP_TOPOLOGY(rawid, detUnit)
double b
Definition: hdecay.h:118
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
TObjArray extraDet
HLT enums.
void addGEMGeometry(FWRecoGeometry &)
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
def cache(function)
Definition: utilities.py:3
virtual float pitch() const =0
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:81
void addTIDGeometry(FWRecoGeometry &)
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:44
const std::vector< const DTLayer * > & layers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:88
const DetContainer & detsTEC() const
const RotationType & rotation() const
Definition: Bounds.h:18
void addPixelBarrelGeometry(FWRecoGeometry &)
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
virtual std::pair< float, float > pitch() const =0
unsigned int insert_id(unsigned int id, FWRecoGeometry &)
const ChamberContainer & chambers() const
Return a vector of all chambers.
Definition: CSCGeometry.cc:96
edm::ESGetToken< FastTimeGeometry, IdealGeometryRecord > m_ftlEndcapGeomToken
int getSiThickIndex(const DetId &) const
Definition: RecHitTools.cc:205
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
T xz() const
int channels() const
Returns the number of wires in the layer.
Definition: DTTopology.h:76
void addDTGeometry(FWRecoGeometry &)
const std::vector< const GEMSuperChamber * > & superChambers() const
Return a vector of all GEM super chambers.
Definition: GEMGeometry.cc:36
T yx() const
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
Definition: ME0Geometry.cc:33
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:75
void addME0Geometry(FWRecoGeometry &)
const DetContainer & detsTID() const
float cellHeight() const
Returns the cell height.
Definition: DTTopology.h:71
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:365
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:40