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 
27 
28 # define ADD_PIXEL_TOPOLOGY( rawid, detUnit ) \
29  const PixelGeomDetUnit* det = dynamic_cast<const PixelGeomDetUnit*>( detUnit ); \
30  if( det ) \
31  { \
32  const PixelTopology* topo = &det->specificTopology(); \
33  m_fwGeometry->idToName[rawid].topology[0] = topo->nrows(); \
34  m_fwGeometry->idToName[rawid].topology[1] = topo->ncolumns(); \
35  } \
36 
37 # define ADD_SISTRIP_TOPOLOGY( rawid, detUnit ) \
38  const StripGeomDetUnit* det = dynamic_cast<const StripGeomDetUnit*>( detUnit ); \
39  if( det ) \
40  { \
41  const StripTopology* topo = dynamic_cast<const StripTopology*>( &det->specificTopology() ); \
42  m_fwGeometry->idToName[rawid].topology[0] = 0; \
43  m_fwGeometry->idToName[rawid].topology[1] = topo->nstrips(); \
44  m_fwGeometry->idToName[rawid].topology[2] = topo->stripLength(); \
45  if( const RadialStripTopology* rtop = dynamic_cast<const RadialStripTopology*>( &(det->specificType().specificTopology()) ) ) \
46  { \
47  m_fwGeometry->idToName[rawid].topology[0] = 1; \
48  m_fwGeometry->idToName[rawid].topology[3] = rtop->yAxisOrientation(); \
49  m_fwGeometry->idToName[rawid].topology[4] = rtop->originToIntersection(); \
50  m_fwGeometry->idToName[rawid].topology[5] = rtop->phiOfOneEdge(); \
51  m_fwGeometry->idToName[rawid].topology[6] = rtop->angularWidth(); \
52  } \
53  else if( dynamic_cast<const RectangularStripTopology*>( &(det->specificType().specificTopology()) ) ) \
54  { \
55  m_fwGeometry->idToName[rawid].topology[0] = 2; \
56  m_fwGeometry->idToName[rawid].topology[3] = topo->pitch(); \
57  } \
58  else if( dynamic_cast<const TrapezoidalStripTopology*>( &(det->specificType().specificTopology()) ) ) \
59  { \
60  m_fwGeometry->idToName[rawid].topology[0] = 3; \
61  m_fwGeometry->idToName[rawid].topology[3] = topo->pitch(); \
62  } \
63  } \
64 
66  : m_current( -1 )
67 {
68  setWhatProduced( this );
69 }
70 
72 {}
73 
74 boost::shared_ptr<FWRecoGeometry>
76 {
77  using namespace edm;
78 
79  m_fwGeometry = boost::shared_ptr<FWRecoGeometry>( new FWRecoGeometry );
80 
82 
83  DetId detId( DetId::Tracker, 0 );
84  m_trackerGeom = (const TrackerGeometry*) m_geomRecord->slaveGeometry( detId );
85 
86  record.getRecord<CaloGeometryRecord>().get( m_caloGeom );
87 
94  addDTGeometry();
97 
98  try
99  {
100  addGEMGeometry();
101  }
102  catch( cms::Exception& exception )
103  {
104  edm::LogWarning("FWRecoGeometryProducerException")
105  << "Exception caught while building GEM geometry: " << exception.what()
106  << std::endl;
107  }
108 
109  addCaloGeometry();
110 
111  m_fwGeometry->idToName.resize( m_current + 1 );
112  std::vector<FWRecoGeom::Info>( m_fwGeometry->idToName ).swap( m_fwGeometry->idToName );
113  std::sort( m_fwGeometry->idToName.begin(), m_fwGeometry->idToName.end());
114 
115  return m_fwGeometry;
116 }
117 
118 void
120 {
121  DetId detId( DetId::Muon, 2 );
122  const CSCGeometry* cscGeometry = (const CSCGeometry*) m_geomRecord->slaveGeometry( detId );
123  for( auto it = cscGeometry->chambers().begin(),
124  end = cscGeometry->chambers().end();
125  it != end; ++it )
126  {
127  const CSCChamber *chamber = *it;
128 
129  if( chamber )
130  {
131  unsigned int rawid = chamber->geographicalId();
132  unsigned int current = insert_id( rawid );
133  fillShapeAndPlacement( current, chamber );
134  //
135  // CSC layers geometry
136  //
137  for( std::vector< const CSCLayer* >::const_iterator lit = chamber->layers().begin(),
138  lend = chamber->layers().end();
139  lit != lend; ++lit )
140  {
141  const CSCLayer* layer = *lit;
142 
143  if( layer )
144  {
145  unsigned int rawid = layer->geographicalId();
146  unsigned int current = insert_id( rawid );
147  fillShapeAndPlacement( current, layer );
148 
149  const CSCStripTopology* stripTopology = layer->geometry()->topology();
150  m_fwGeometry->idToName[current].topology[0] = stripTopology->yAxisOrientation();
151  m_fwGeometry->idToName[current].topology[1] = stripTopology->centreToIntersection();
152  m_fwGeometry->idToName[current].topology[2] = stripTopology->yCentreOfStripPlane();
153  m_fwGeometry->idToName[current].topology[3] = stripTopology->phiOfOneEdge();
154  m_fwGeometry->idToName[current].topology[4] = stripTopology->stripOffset();
155  m_fwGeometry->idToName[current].topology[5] = stripTopology->angularWidth();
156 
157  const CSCWireTopology* wireTopology = layer->geometry()->wireTopology();
158  m_fwGeometry->idToName[current].topology[6] = wireTopology->wireSpacing();
159  m_fwGeometry->idToName[current].topology[7] = wireTopology->wireAngle();
160  }
161  }
162  }
163  }
164 }
165 
166 void
168 {
169  DetId detId( DetId::Muon, 1 );
170  const DTGeometry* dtGeometry = (const DTGeometry*) m_geomRecord->slaveGeometry( detId );
171 
172  //
173  // DT chambers geometry
174  //
175  for( auto it = dtGeometry->chambers().begin(),
176  end = dtGeometry->chambers().end();
177  it != end; ++it )
178  {
179  const DTChamber *chamber = *it;
180 
181  if( chamber )
182  {
183  unsigned int rawid = chamber->geographicalId().rawId();
184  unsigned int current = insert_id( rawid );
185  fillShapeAndPlacement( current, chamber );
186  }
187  }
188 
189  // Fill in DT layer parameters
190  for( auto it = dtGeometry->layers().begin(),
191  end = dtGeometry->layers().end();
192  it != end; ++it )
193  {
194  const DTLayer* layer = *it;
195 
196  if( layer )
197  {
198  unsigned int rawid = layer->id().rawId();
199  unsigned int current = insert_id( rawid );
200  fillShapeAndPlacement( current, layer );
201 
202  const DTTopology& topo = layer->specificTopology();
203  const BoundPlane& surf = layer->surface();
204  // Topology W/H/L:
205  m_fwGeometry->idToName[current].topology[0] = topo.cellWidth();
206  m_fwGeometry->idToName[current].topology[1] = topo.cellHeight();
207  m_fwGeometry->idToName[current].topology[2] = topo.cellLenght();
208  m_fwGeometry->idToName[current].topology[3] = topo.firstChannel();
209  m_fwGeometry->idToName[current].topology[4] = topo.lastChannel();
210  m_fwGeometry->idToName[current].topology[5] = topo.channels();
211 
212  // Bounds W/H/L:
213  m_fwGeometry->idToName[current].topology[6] = surf.bounds().width();
214  m_fwGeometry->idToName[current].topology[7] = surf.bounds().thickness();
215  m_fwGeometry->idToName[current].topology[8] = surf.bounds().length();
216  }
217  }
218 }
219 
220 void
222 {
223  //
224  // RPC rolls geometry
225  //
226  DetId detId( DetId::Muon, 3 );
227  const RPCGeometry* rpcGeom = (const RPCGeometry*) m_geomRecord->slaveGeometry( detId );
228  for( auto it = rpcGeom->rolls().begin(),
229  end = rpcGeom->rolls().end();
230  it != end; ++it )
231  {
232  const RPCRoll* roll = (*it);
233  if( roll )
234  {
235  unsigned int rawid = roll->geographicalId().rawId();
236  unsigned int current = insert_id( rawid );
237  fillShapeAndPlacement( current, roll );
238 
239  const StripTopology& topo = roll->specificTopology();
240  m_fwGeometry->idToName[current].topology[0] = topo.nstrips();
241  m_fwGeometry->idToName[current].topology[1] = topo.stripLength();
242  m_fwGeometry->idToName[current].topology[2] = topo.pitch();
243  }
244  }
245 }
246 
247 void
249 {
250  //
251  // GEM geometry
252  //
253  DetId detId( DetId::Muon, 4 );
254  const GEMGeometry* gemGeom = (const GEMGeometry*) m_geomRecord->slaveGeometry( detId );
255  for( auto it = gemGeom->etaPartitions().begin(),
256  end = gemGeom->etaPartitions().end();
257  it != end; ++it )
258  {
259  const GEMEtaPartition* roll = (*it);
260  if( roll )
261  {
262  unsigned int rawid = (*it)->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  }
272 }
273 
274 
275 void
277 {
278  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXB().begin(),
279  end = m_trackerGeom->detsPXB().end();
280  it != end; ++it)
281  {
282  const GeomDet *det = *it;
283 
284  if( det )
285  {
286  DetId detid = det->geographicalId();
287  unsigned int rawid = detid.rawId();
288  unsigned int current = insert_id( rawid );
289  fillShapeAndPlacement( current, det );
290 
291  ADD_PIXEL_TOPOLOGY( current, m_trackerGeom->idToDetUnit( detid ));
292  }
293  }
294 }
295 
296 void
298 {
299  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXF().begin(),
300  end = m_trackerGeom->detsPXF().end();
301  it != end; ++it )
302  {
303  const GeomDet *det = *it;
304 
305  if( det )
306  {
307  DetId detid = det->geographicalId();
308  unsigned int rawid = detid.rawId();
309  unsigned int current = insert_id( rawid );
310  fillShapeAndPlacement( current, det );
311 
312  ADD_PIXEL_TOPOLOGY( current, m_trackerGeom->idToDetUnit( detid ));
313  }
314  }
315 }
316 
317 void
319 {
320  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTIB().begin(),
321  end = m_trackerGeom->detsTIB().end();
322  it != end; ++it )
323  {
324  const GeomDet *det = *it;
325 
326  if( det )
327  {
328  DetId detid = det->geographicalId();
329  unsigned int rawid = detid.rawId();
330  unsigned int current = insert_id( rawid );
331  fillShapeAndPlacement( current, det );
332 
333  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
334  }
335  }
336 }
337 
338 void
340 {
341  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTOB().begin(),
342  end = m_trackerGeom->detsTOB().end();
343  it != end; ++it )
344  {
345  const GeomDet *det = *it;
346 
347  if( det )
348  {
349  DetId detid = det->geographicalId();
350  unsigned int rawid = detid.rawId();
351  unsigned int current = insert_id( rawid );
352  fillShapeAndPlacement( current, det );
353 
354  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
355  }
356  }
357 }
358 
359 void
361 {
362  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTID().begin(),
363  end = m_trackerGeom->detsTID().end();
364  it != end; ++it)
365  {
366  const GeomDet *det = *it;
367 
368  if( det )
369  {
370  DetId detid = det->geographicalId();
371  unsigned int rawid = detid.rawId();
372  unsigned int current = insert_id( rawid );
373  fillShapeAndPlacement( current, det );
374 
375  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
376  }
377  }
378 }
379 
380 void
382 {
383  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTEC().begin(),
384  end = m_trackerGeom->detsTEC().end();
385  it != end; ++it )
386  {
387  const GeomDet *det = *it;
388 
389  if( det )
390  {
391  DetId detid = det->geographicalId();
392  unsigned int rawid = detid.rawId();
393  unsigned int current = insert_id( rawid );
394  fillShapeAndPlacement( current, det );
395 
396  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
397  }
398  }
399 }
400 
401 void
403 {
404  std::vector<DetId> vid = m_caloGeom->getValidDetIds(); // Calo
405  for( std::vector<DetId>::const_iterator it = vid.begin(),
406  end = vid.end();
407  it != end; ++it )
408  {
409  const CaloCellGeometry::CornersVec& cor( m_caloGeom->getGeometry( *it )->getCorners());
410  unsigned int id = insert_id( it->rawId());
411  fillPoints( id, cor.begin(), cor.end());
412  }
413 }
414 
415 unsigned int
417 {
418  ++m_current;
419  m_fwGeometry->idToName.push_back(FWRecoGeom::Info());
420  m_fwGeometry->idToName.back().id = rawid;
421 
422  return m_current;
423 }
424 
425 void
426 FWRecoGeometryESProducer::fillPoints( unsigned int id, std::vector<GlobalPoint>::const_iterator begin, std::vector<GlobalPoint>::const_iterator end )
427 {
428  unsigned int index( 0 );
429  for( std::vector<GlobalPoint>::const_iterator i = begin; i != end; ++i )
430  {
431  assert( index < 23 );
432  m_fwGeometry->idToName[id].points[index] = i->x();
433  m_fwGeometry->idToName[id].points[++index] = i->y();
434  m_fwGeometry->idToName[id].points[++index] = i->z();
435  ++index;
436  }
437 }
438 
439 
441 void
443 {
444  // Trapezoidal
445  const Bounds *b = &((det->surface ()).bounds ());
446  if( const TrapezoidalPlaneBounds *b2 = dynamic_cast<const TrapezoidalPlaneBounds *> (b))
447  {
448  std::array< const float, 4 > const & par = b2->parameters ();
449 
450  // These parameters are half-lengths, as in CMSIM/GEANT3
451  m_fwGeometry->idToName[id].shape[0] = 1;
452  m_fwGeometry->idToName[id].shape[1] = par [0]; // hBottomEdge
453  m_fwGeometry->idToName[id].shape[2] = par [1]; // hTopEdge
454  m_fwGeometry->idToName[id].shape[3] = par [2]; // thickness
455  m_fwGeometry->idToName[id].shape[4] = par [3]; // apothem
456  }
457  if( const RectangularPlaneBounds *b2 = dynamic_cast<const RectangularPlaneBounds *> (b))
458  {
459  // Rectangular
460  m_fwGeometry->idToName[id].shape[0] = 2;
461  m_fwGeometry->idToName[id].shape[1] = b2->width() * 0.5; // half width
462  m_fwGeometry->idToName[id].shape[2] = b2->length() * 0.5; // half length
463  m_fwGeometry->idToName[id].shape[3] = b2->thickness() * 0.5; // half thickness
464  }
465 
466  // Position of the DetUnit's center
467  GlobalPoint pos = det->surface().position();
468  m_fwGeometry->idToName[id].translation[0] = pos.x();
469  m_fwGeometry->idToName[id].translation[1] = pos.y();
470  m_fwGeometry->idToName[id].translation[2] = pos.z();
471 
472  // Add the coeff of the rotation matrix
473  // with a projection on the basis vectors
474  TkRotation<float> detRot = det->surface().rotation();
475  m_fwGeometry->idToName[id].matrix[0] = detRot.xx();
476  m_fwGeometry->idToName[id].matrix[1] = detRot.yx();
477  m_fwGeometry->idToName[id].matrix[2] = detRot.zx();
478  m_fwGeometry->idToName[id].matrix[3] = detRot.xy();
479  m_fwGeometry->idToName[id].matrix[4] = detRot.yy();
480  m_fwGeometry->idToName[id].matrix[5] = detRot.zy();
481  m_fwGeometry->idToName[id].matrix[6] = detRot.xz();
482  m_fwGeometry->idToName[id].matrix[7] = detRot.yz();
483  m_fwGeometry->idToName[id].matrix[8] = detRot.zz();
484 }
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
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
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:35
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 chambers.
Definition: GEMGeometry.cc:57
const StripTopology & specificTopology() const
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
#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)
virtual const GeomDet * idToDet(DetId) const
unsigned int insert_id(unsigned int id)
const DetContainer & detsTIB() const
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
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
#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