test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWRecoGeometryESProducer.cc
Go to the documentation of this file.
4 
28 
29 #include "TNamed.h"
30 # define ADD_PIXEL_TOPOLOGY( rawid, detUnit ) \
31  const PixelGeomDetUnit* det = dynamic_cast<const PixelGeomDetUnit*>( detUnit ); \
32  if( det ) \
33  { \
34  const PixelTopology* topo = &det->specificTopology(); \
35  m_fwGeometry->idToName[rawid].topology[0] = topo->nrows(); \
36  m_fwGeometry->idToName[rawid].topology[1] = topo->ncolumns(); \
37  } \
38 
39 # define ADD_SISTRIP_TOPOLOGY( rawid, detUnit ) \
40  const StripGeomDetUnit* det = dynamic_cast<const StripGeomDetUnit*>( detUnit ); \
41  if( det ) \
42  { \
43  const StripTopology* topo = dynamic_cast<const StripTopology*>( &det->specificTopology() ); \
44  m_fwGeometry->idToName[rawid].topology[0] = 0; \
45  m_fwGeometry->idToName[rawid].topology[1] = topo->nstrips(); \
46  m_fwGeometry->idToName[rawid].topology[2] = topo->stripLength(); \
47  if( const RadialStripTopology* rtop = dynamic_cast<const RadialStripTopology*>( &(det->specificType().specificTopology()) ) ) \
48  { \
49  m_fwGeometry->idToName[rawid].topology[0] = 1; \
50  m_fwGeometry->idToName[rawid].topology[3] = rtop->yAxisOrientation(); \
51  m_fwGeometry->idToName[rawid].topology[4] = rtop->originToIntersection(); \
52  m_fwGeometry->idToName[rawid].topology[5] = rtop->phiOfOneEdge(); \
53  m_fwGeometry->idToName[rawid].topology[6] = rtop->angularWidth(); \
54  } \
55  else if( dynamic_cast<const RectangularStripTopology*>( &(det->specificType().specificTopology()) ) ) \
56  { \
57  m_fwGeometry->idToName[rawid].topology[0] = 2; \
58  m_fwGeometry->idToName[rawid].topology[3] = topo->pitch(); \
59  } \
60  else if( dynamic_cast<const TrapezoidalStripTopology*>( &(det->specificType().specificTopology()) ) ) \
61  { \
62  m_fwGeometry->idToName[rawid].topology[0] = 3; \
63  m_fwGeometry->idToName[rawid].topology[3] = topo->pitch(); \
64  } \
65  } \
66 
68  : m_current( -1 )
69 {
70  setWhatProduced( this );
71 }
72 
74 {}
75 
76 boost::shared_ptr<FWRecoGeometry>
78 {
79  using namespace edm;
80 
81  m_fwGeometry = boost::shared_ptr<FWRecoGeometry>( new FWRecoGeometry );
82 
84 
85  DetId detId( DetId::Tracker, 0 );
86  m_trackerGeom = (const TrackerGeometry*) m_geomRecord->slaveGeometry( detId );
87 
88  record.getRecord<CaloGeometryRecord>().get( m_caloGeom );
89 
96  addDTGeometry();
100  addME0Geometry();
101  addCaloGeometry();
102 
103  m_fwGeometry->idToName.resize( m_current + 1 );
104  std::vector<FWRecoGeom::Info>( m_fwGeometry->idToName ).swap( m_fwGeometry->idToName );
105  std::sort( m_fwGeometry->idToName.begin(), m_fwGeometry->idToName.end());
106 
107  return m_fwGeometry;
108 }
109 
110 void
112 {
113  DetId detId( DetId::Muon, 2 );
114  const CSCGeometry* cscGeometry = (const CSCGeometry*) m_geomRecord->slaveGeometry( detId );
115  for( auto it = cscGeometry->chambers().begin(),
116  end = cscGeometry->chambers().end();
117  it != end; ++it )
118  {
119  const CSCChamber *chamber = *it;
120 
121  if( chamber )
122  {
123  unsigned int rawid = chamber->geographicalId();
124  unsigned int current = insert_id( rawid );
125  fillShapeAndPlacement( current, chamber );
126  //
127  // CSC layers geometry
128  //
129  for( std::vector< const CSCLayer* >::const_iterator lit = chamber->layers().begin(),
130  lend = chamber->layers().end();
131  lit != lend; ++lit )
132  {
133  const CSCLayer* layer = *lit;
134 
135  if( layer )
136  {
137  unsigned int rawid = layer->geographicalId();
138  unsigned int current = insert_id( rawid );
139  fillShapeAndPlacement( current, layer );
140 
141  const CSCStripTopology* stripTopology = layer->geometry()->topology();
142  m_fwGeometry->idToName[current].topology[0] = stripTopology->yAxisOrientation();
143  m_fwGeometry->idToName[current].topology[1] = stripTopology->centreToIntersection();
144  m_fwGeometry->idToName[current].topology[2] = stripTopology->yCentreOfStripPlane();
145  m_fwGeometry->idToName[current].topology[3] = stripTopology->phiOfOneEdge();
146  m_fwGeometry->idToName[current].topology[4] = stripTopology->stripOffset();
147  m_fwGeometry->idToName[current].topology[5] = stripTopology->angularWidth();
148 
149  const CSCWireTopology* wireTopology = layer->geometry()->wireTopology();
150  m_fwGeometry->idToName[current].topology[6] = wireTopology->wireSpacing();
151  m_fwGeometry->idToName[current].topology[7] = wireTopology->wireAngle();
152  }
153  }
154  }
155  }
156 }
157 
158 void
160 {
161  DetId detId( DetId::Muon, 1 );
162  const DTGeometry* dtGeometry = (const DTGeometry*) m_geomRecord->slaveGeometry( detId );
163 
164  //
165  // DT chambers geometry
166  //
167  for( auto it = dtGeometry->chambers().begin(),
168  end = dtGeometry->chambers().end();
169  it != end; ++it )
170  {
171  const DTChamber *chamber = *it;
172 
173  if( chamber )
174  {
175  unsigned int rawid = chamber->geographicalId().rawId();
176  unsigned int current = insert_id( rawid );
177  fillShapeAndPlacement( current, chamber );
178  }
179  }
180 
181  // Fill in DT layer parameters
182  for( auto it = dtGeometry->layers().begin(),
183  end = dtGeometry->layers().end();
184  it != end; ++it )
185  {
186  const DTLayer* layer = *it;
187 
188  if( layer )
189  {
190  unsigned int rawid = layer->id().rawId();
191  unsigned int current = insert_id( rawid );
192  fillShapeAndPlacement( current, layer );
193 
194  const DTTopology& topo = layer->specificTopology();
195  const BoundPlane& surf = layer->surface();
196  // Topology W/H/L:
197  m_fwGeometry->idToName[current].topology[0] = topo.cellWidth();
198  m_fwGeometry->idToName[current].topology[1] = topo.cellHeight();
199  m_fwGeometry->idToName[current].topology[2] = topo.cellLenght();
200  m_fwGeometry->idToName[current].topology[3] = topo.firstChannel();
201  m_fwGeometry->idToName[current].topology[4] = topo.lastChannel();
202  m_fwGeometry->idToName[current].topology[5] = topo.channels();
203 
204  // Bounds W/H/L:
205  m_fwGeometry->idToName[current].topology[6] = surf.bounds().width();
206  m_fwGeometry->idToName[current].topology[7] = surf.bounds().thickness();
207  m_fwGeometry->idToName[current].topology[8] = surf.bounds().length();
208  }
209  }
210 }
211 
212 void
214 {
215  //
216  // RPC rolls geometry
217  //
218  DetId detId( DetId::Muon, 3 );
219  const RPCGeometry* rpcGeom = (const RPCGeometry*) m_geomRecord->slaveGeometry( detId );
220  for( auto it = rpcGeom->rolls().begin(),
221  end = rpcGeom->rolls().end();
222  it != end; ++it )
223  {
224  const RPCRoll* roll = (*it);
225  if( roll )
226  {
227  unsigned int rawid = roll->geographicalId().rawId();
228  unsigned int current = insert_id( rawid );
229  fillShapeAndPlacement( current, roll );
230 
231  const StripTopology& topo = roll->specificTopology();
232  m_fwGeometry->idToName[current].topology[0] = topo.nstrips();
233  m_fwGeometry->idToName[current].topology[1] = topo.stripLength();
234  m_fwGeometry->idToName[current].topology[2] = topo.pitch();
235  }
236  }
237 
238 
239  try {
240  RPCDetId id(1, 1, 4, 1, 1, 1, 1 );
241  m_geomRecord->slaveGeometry( detId );
242  m_fwGeometry->extraDet.Add(new TNamed("RE4", "RPC endcap station 4"));
243  }
244  catch (...) {}
245 }
246 
247 void
249 {
250  //
251  // GEM geometry
252  //
253  DetId detId( DetId::Muon, 4 );
254 
255  try
256  {
257  const GEMGeometry* gemGeom = (const GEMGeometry*) m_geomRecord->slaveGeometry( detId );
258  for(auto roll : gemGeom->etaPartitions())
259  {
260  if( roll )
261  {
262  unsigned int rawid = roll->geographicalId().rawId();
263  unsigned int current = insert_id( rawid );
264  fillShapeAndPlacement( current, roll );
265 
266  const StripTopology& topo = roll->specificTopology();
267  m_fwGeometry->idToName[current].topology[0] = topo.nstrips();
268  m_fwGeometry->idToName[current].topology[1] = topo.stripLength();
269  m_fwGeometry->idToName[current].topology[2] = topo.pitch();
270 
271  float height = topo.stripLength()/2;
272  LocalPoint lTop( 0., height, 0.);
273  LocalPoint lBottom( 0., -height, 0.);
274  m_fwGeometry->idToName[current].topology[3] = roll->localPitch(lTop);
275  m_fwGeometry->idToName[current].topology[4] = roll->localPitch(lBottom);
276  m_fwGeometry->idToName[current].topology[5] = roll->npads();
277  }
278  }
279 
280  m_fwGeometry->extraDet.Add(new TNamed("GEM", "GEM muon detector"));
281  try {
282  GEMDetId id(1, 1, 2, 1, 1, 1 );
283  m_geomRecord->slaveGeometry( detId );
284  m_fwGeometry->extraDet.Add(new TNamed("GE2", "GEM endcap station 2"));
285  }
286  catch (...) {}
287 
288  }
289  catch( cms::Exception &exception )
290  {
291  edm::LogInfo("FWRecoGeometry") << "failed to produce GEM geometry " << exception.what() << std::endl;
292  }
293 }
294 
295 void
297 {
298  //
299  // ME0 geometry
300  //
301 
302  DetId detId( DetId::Muon, 5 );
303  try
304  {
305  const ME0Geometry* me0Geom = (const ME0Geometry*) m_geomRecord->slaveGeometry( detId );
306  for(auto roll : me0Geom->etaPartitions())
307  {
308  if( roll )
309  {
310  unsigned int rawid = roll->geographicalId().rawId();
311  unsigned int current = insert_id( rawid );
312  fillShapeAndPlacement( current, roll );
313 
314  const StripTopology& topo = roll->specificTopology();
315  m_fwGeometry->idToName[current].topology[0] = topo.nstrips();
316  m_fwGeometry->idToName[current].topology[1] = topo.stripLength();
317  m_fwGeometry->idToName[current].topology[2] = topo.pitch();
318 
319  float height = topo.stripLength()/2;
320  LocalPoint lTop( 0., height, 0.);
321  LocalPoint lBottom( 0., -height, 0.);
322  m_fwGeometry->idToName[current].topology[3] = roll->localPitch(lTop);
323  m_fwGeometry->idToName[current].topology[4] = roll->localPitch(lBottom);
324  m_fwGeometry->idToName[current].topology[5] = roll->npads();
325  }
326  }
327  m_fwGeometry->extraDet.Add(new TNamed("ME0", "ME0 muon detector"));
328  }
329  catch( cms::Exception &exception )
330  {
331  edm::LogInfo("FWRecoGeometry") << "failed to produce ME0 geometry " << exception.what() << std::endl;
332  }
333 }
334 
335 void
337 {
338  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXB().begin(),
339  end = m_trackerGeom->detsPXB().end();
340  it != end; ++it)
341  {
342  const GeomDet *det = *it;
343 
344  if( det )
345  {
346  DetId detid = det->geographicalId();
347  unsigned int rawid = detid.rawId();
348  unsigned int current = insert_id( rawid );
349  fillShapeAndPlacement( current, det );
350 
351  ADD_PIXEL_TOPOLOGY( current, m_trackerGeom->idToDetUnit( detid ));
352  }
353  }
354 }
355 
356 void
358 {
359  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXF().begin(),
360  end = m_trackerGeom->detsPXF().end();
361  it != end; ++it )
362  {
363  const GeomDet *det = *it;
364 
365  if( det )
366  {
367  DetId detid = det->geographicalId();
368  unsigned int rawid = detid.rawId();
369  unsigned int current = insert_id( rawid );
370  fillShapeAndPlacement( current, det );
371 
372  ADD_PIXEL_TOPOLOGY( current, m_trackerGeom->idToDetUnit( detid ));
373  }
374  }
375 }
376 
377 void
379 {
380  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTIB().begin(),
381  end = m_trackerGeom->detsTIB().end();
382  it != end; ++it )
383  {
384  const GeomDet *det = *it;
385 
386  if( det )
387  {
388  DetId detid = det->geographicalId();
389  unsigned int rawid = detid.rawId();
390  unsigned int current = insert_id( rawid );
391  fillShapeAndPlacement( current, det );
392 
393  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
394  }
395  }
396 }
397 
398 void
400 {
401  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTOB().begin(),
402  end = m_trackerGeom->detsTOB().end();
403  it != end; ++it )
404  {
405  const GeomDet *det = *it;
406 
407  if( det )
408  {
409  DetId detid = det->geographicalId();
410  unsigned int rawid = detid.rawId();
411  unsigned int current = insert_id( rawid );
412  fillShapeAndPlacement( current, det );
413 
414  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
415  }
416  }
417 }
418 
419 void
421 {
422  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTID().begin(),
423  end = m_trackerGeom->detsTID().end();
424  it != end; ++it)
425  {
426  const GeomDet *det = *it;
427 
428  if( det )
429  {
430  DetId detid = det->geographicalId();
431  unsigned int rawid = detid.rawId();
432  unsigned int current = insert_id( rawid );
433  fillShapeAndPlacement( current, det );
434 
435  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
436  }
437  }
438 }
439 
440 void
442 {
443  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTEC().begin(),
444  end = m_trackerGeom->detsTEC().end();
445  it != end; ++it )
446  {
447  const GeomDet *det = *it;
448 
449  if( det )
450  {
451  DetId detid = det->geographicalId();
452  unsigned int rawid = detid.rawId();
453  unsigned int current = insert_id( rawid );
454  fillShapeAndPlacement( current, det );
455 
456  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
457  }
458  }
459 }
460 
461 void
463 {
464  std::vector<DetId> vid = m_caloGeom->getValidDetIds(); // Calo
465  for( std::vector<DetId>::const_iterator it = vid.begin(),
466  end = vid.end();
467  it != end; ++it )
468  {
469  const CaloCellGeometry::CornersVec& cor( m_caloGeom->getGeometry( *it )->getCorners());
470  unsigned int id = insert_id( it->rawId());
471  fillPoints( id, cor.begin(), cor.end());
472  }
473 }
474 
475 unsigned int
477 {
478  ++m_current;
479  m_fwGeometry->idToName.push_back(FWRecoGeom::Info());
480  m_fwGeometry->idToName.back().id = rawid;
481 
482  return m_current;
483 }
484 
485 void
486 FWRecoGeometryESProducer::fillPoints( unsigned int id, std::vector<GlobalPoint>::const_iterator begin, std::vector<GlobalPoint>::const_iterator end )
487 {
488  unsigned int index( 0 );
489  for( std::vector<GlobalPoint>::const_iterator i = begin; i != end; ++i )
490  {
491  assert( index < 23 );
492  m_fwGeometry->idToName[id].points[index] = i->x();
493  m_fwGeometry->idToName[id].points[++index] = i->y();
494  m_fwGeometry->idToName[id].points[++index] = i->z();
495  ++index;
496  }
497 }
498 
499 
501 void
503 {
504  // Trapezoidal
505  const Bounds *b = &((det->surface ()).bounds ());
506  if( const TrapezoidalPlaneBounds *b2 = dynamic_cast<const TrapezoidalPlaneBounds *> (b))
507  {
508  std::array< const float, 4 > const & par = b2->parameters ();
509 
510  // These parameters are half-lengths, as in CMSIM/GEANT3
511  m_fwGeometry->idToName[id].shape[0] = 1;
512  m_fwGeometry->idToName[id].shape[1] = par [0]; // hBottomEdge
513  m_fwGeometry->idToName[id].shape[2] = par [1]; // hTopEdge
514  m_fwGeometry->idToName[id].shape[3] = par [2]; // thickness
515  m_fwGeometry->idToName[id].shape[4] = par [3]; // apothem
516  }
517  if( const RectangularPlaneBounds *b2 = dynamic_cast<const RectangularPlaneBounds *> (b))
518  {
519  // Rectangular
520  m_fwGeometry->idToName[id].shape[0] = 2;
521  m_fwGeometry->idToName[id].shape[1] = b2->width() * 0.5; // half width
522  m_fwGeometry->idToName[id].shape[2] = b2->length() * 0.5; // half length
523  m_fwGeometry->idToName[id].shape[3] = b2->thickness() * 0.5; // half thickness
524  }
525 
526  // Position of the DetUnit's center
527  GlobalPoint pos = det->surface().position();
528  m_fwGeometry->idToName[id].translation[0] = pos.x();
529  m_fwGeometry->idToName[id].translation[1] = pos.y();
530  m_fwGeometry->idToName[id].translation[2] = pos.z();
531 
532  // Add the coeff of the rotation matrix
533  // with a projection on the basis vectors
534  TkRotation<float> detRot = det->surface().rotation();
535  m_fwGeometry->idToName[id].matrix[0] = detRot.xx();
536  m_fwGeometry->idToName[id].matrix[1] = detRot.yx();
537  m_fwGeometry->idToName[id].matrix[2] = detRot.zx();
538  m_fwGeometry->idToName[id].matrix[3] = detRot.xy();
539  m_fwGeometry->idToName[id].matrix[4] = detRot.yy();
540  m_fwGeometry->idToName[id].matrix[5] = detRot.zy();
541  m_fwGeometry->idToName[id].matrix[6] = detRot.xz();
542  m_fwGeometry->idToName[id].matrix[7] = detRot.yz();
543  m_fwGeometry->idToName[id].matrix[8] = detRot.zz();
544 }
T xx() const
virtual char const * what() const
Definition: Exception.cc:141
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:70
virtual int nstrips() const =0
virtual const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
int i
Definition: DBlmapReader.cc:9
const std::vector< const CSCLayer * > & layers() const
Return all layers.
Definition: CSCChamber.h:57
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:85
const CSCWireTopology * wireTopology() const
JetCorrectorParameters::Record record
Definition: classes.h:7
FWRecoGeometryESProducer(const edm::ParameterSet &)
DTLayerId id() const
Return the DetId of this SL.
Definition: DTLayer.cc:46
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:67
assert(m_qm.get())
T y() const
Definition: PV3DBase.h:63
T yx() const
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:68
edm::ESHandle< GlobalTrackingGeometry > m_geomRecord
const ChamberContainer & chambers() const
Return a vector of all chambers.
Definition: CSCGeometry.cc:106
double wireSpacing() const
const StripTopology & specificTopology() const
Definition: RPCRoll.cc:107
const TrackerGeometry * m_trackerGeom
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
boost::shared_ptr< FWRecoGeometry > m_fwGeometry
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:78
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T zx() const
void fillShapeAndPlacement(unsigned int id, const GeomDet *det)
T xy() const
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:80
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
T zz() const
virtual float stripLength() const =0
float wireAngle() const
const DetContainer & detsTEC() const
T z() const
Definition: PV3DBase.h:64
const DetContainer & detsPXB() const
boost::shared_ptr< FWRecoGeometry > produce(const FWRecoGeometryRecord &)
T zy() const
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:63
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:77
#define end
Definition: vmac.h:37
float cellHeight() const
Returns the cell height.
Definition: DTTopology.h:70
T yy() const
#define ADD_PIXEL_TOPOLOGY(rawid, detUnit)
unsigned int insert_id(unsigned int id)
const DetContainer & detsTIB() const
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
Definition: ME0Geometry.cc:57
Definition: DetId.h:18
const CSCStripTopology * topology() const
void fillPoints(unsigned int id, std::vector< GlobalPoint >::const_iterator begin, std::vector< GlobalPoint >::const_iterator end)
virtual float stripOffset(void) const
int channels() const
Returns the number of wires in the layer.
Definition: DTTopology.h:75
const std::vector< const DTLayer * > & layers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:95
#define ADD_SISTRIP_TOPOLOGY(rawid, detUnit)
double b
Definition: hdecay.h:120
edm::ESHandle< CaloGeometry > m_caloGeom
#define begin
Definition: vmac.h:30
T xz() const
virtual float pitch() const =0
const DetContainer & detsPXF() const
const DetContainer & detsTOB() const
const RotationType & rotation() const
Definition: Bounds.h:22
float cellLenght() const
Definition: DTTopology.h:73
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
T yz() const
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
const DetContainer & detsTID() const
virtual const TrackerGeomDet * idToDet(DetId) const