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