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();
99 
100  m_fwGeometry->idToName.resize( m_current + 1 );
101  std::vector<FWRecoGeom::Info>( m_fwGeometry->idToName ).swap( m_fwGeometry->idToName );
102  std::sort( m_fwGeometry->idToName.begin(), m_fwGeometry->idToName.end());
103 
104  return m_fwGeometry;
105 }
106 
107 void
109 {
110  DetId detId( DetId::Muon, 2 );
111  const CSCGeometry* cscGeometry = (const CSCGeometry*) m_geomRecord->slaveGeometry( detId );
112  for( std::vector<CSCChamber*>::const_iterator it = cscGeometry->chambers().begin(),
113  end = cscGeometry->chambers().end();
114  it != end; ++it )
115  {
116  const CSCChamber *chamber = *it;
117 
118  if( chamber )
119  {
120  unsigned int rawid = chamber->geographicalId();
121  unsigned int current = insert_id( rawid );
122  fillShapeAndPlacement( current, chamber );
123  //
124  // CSC layers geometry
125  //
126  for( std::vector< const CSCLayer* >::const_iterator lit = chamber->layers().begin(),
127  lend = chamber->layers().end();
128  lit != lend; ++lit )
129  {
130  const CSCLayer* layer = *lit;
131 
132  if( layer )
133  {
134  unsigned int rawid = layer->geographicalId();
135  unsigned int current = insert_id( rawid );
136  fillShapeAndPlacement( current, layer );
137 
138  const CSCStripTopology* stripTopology = layer->geometry()->topology();
139  m_fwGeometry->idToName[current].topology[0] = stripTopology->yAxisOrientation();
140  m_fwGeometry->idToName[current].topology[1] = stripTopology->centreToIntersection();
141  m_fwGeometry->idToName[current].topology[2] = stripTopology->yCentreOfStripPlane();
142  m_fwGeometry->idToName[current].topology[3] = stripTopology->phiOfOneEdge();
143  m_fwGeometry->idToName[current].topology[4] = stripTopology->stripOffset();
144  m_fwGeometry->idToName[current].topology[5] = stripTopology->angularWidth();
145 
146  const CSCWireTopology* wireTopology = layer->geometry()->wireTopology();
147  m_fwGeometry->idToName[current].topology[6] = wireTopology->wireSpacing();
148  m_fwGeometry->idToName[current].topology[7] = wireTopology->wireAngle();
149  }
150  }
151  }
152  }
153 }
154 
155 void
157 {
158  DetId detId( DetId::Muon, 1 );
159  const DTGeometry* dtGeometry = (const DTGeometry*) m_geomRecord->slaveGeometry( detId );
160 
161  //
162  // DT chambers geometry
163  //
164  for( std::vector<DTChamber *>::const_iterator it = dtGeometry->chambers().begin(),
165  end = dtGeometry->chambers().end();
166  it != end; ++it )
167  {
168  const DTChamber *chamber = *it;
169 
170  if( chamber )
171  {
172  unsigned int rawid = chamber->geographicalId().rawId();
173  unsigned int current = insert_id( rawid );
174  fillShapeAndPlacement( current, chamber );
175  }
176  }
177 
178  // Fill in DT layer parameters
179  for( std::vector<DTLayer*>::const_iterator it = dtGeometry->layers().begin(),
180  end = dtGeometry->layers().end();
181  it != end; ++it )
182  {
183  const DTLayer* layer = *it;
184 
185  if( layer )
186  {
187  unsigned int rawid = layer->id().rawId();
188  unsigned int current = insert_id( rawid );
189  fillShapeAndPlacement( current, layer );
190 
191  const DTTopology& topo = layer->specificTopology();
192  const BoundPlane& surf = layer->surface();
193  // Topology W/H/L:
194  m_fwGeometry->idToName[current].topology[0] = topo.cellWidth();
195  m_fwGeometry->idToName[current].topology[1] = topo.cellHeight();
196  m_fwGeometry->idToName[current].topology[2] = topo.cellLenght();
197  m_fwGeometry->idToName[current].topology[3] = topo.firstChannel();
198  m_fwGeometry->idToName[current].topology[4] = topo.lastChannel();
199  m_fwGeometry->idToName[current].topology[5] = topo.channels();
200 
201  // Bounds W/H/L:
202  m_fwGeometry->idToName[current].topology[6] = surf.bounds().width();
203  m_fwGeometry->idToName[current].topology[7] = surf.bounds().thickness();
204  m_fwGeometry->idToName[current].topology[8] = surf.bounds().length();
205  }
206  }
207 }
208 
209 void
211 {
212  //
213  // RPC rolls geometry
214  //
215  DetId detId( DetId::Muon, 3 );
216  const RPCGeometry* rpcGeom = (const RPCGeometry*) m_geomRecord->slaveGeometry( detId );
217  for( std::vector<RPCRoll *>::const_iterator it = rpcGeom->rolls().begin(),
218  end = rpcGeom->rolls().end();
219  it != end; ++it )
220  {
221  RPCRoll* roll = (*it);
222  if( roll )
223  {
224  unsigned int rawid = roll->geographicalId().rawId();
225  unsigned int current = insert_id( rawid );
226  fillShapeAndPlacement( current, roll );
227 
228  const StripTopology& topo = roll->specificTopology();
229  m_fwGeometry->idToName[current].topology[0] = topo.nstrips();
230  m_fwGeometry->idToName[current].topology[1] = topo.stripLength();
231  m_fwGeometry->idToName[current].topology[2] = topo.pitch();
232  }
233  }
234 }
235 
236 void
238 {
239  //
240  // GEM geometry
241  //
242  DetId detId( DetId::Muon, 4 );
243  const GEMGeometry* gemGeom = (const GEMGeometry*) m_geomRecord->slaveGeometry( detId );
244  for( std::vector<GEMEtaPartition *>::const_iterator it = gemGeom->etaPartitions().begin(),
245  end = gemGeom->etaPartitions().end();
246  it != end; ++it )
247  {
248  GEMEtaPartition* roll = (*it);
249  if( roll )
250  {
251  unsigned int rawid = (*it)->geographicalId().rawId();
252  unsigned int current = insert_id( rawid );
253  fillShapeAndPlacement( current, roll );
254 
255  const StripTopology& topo = roll->specificTopology();
256  m_fwGeometry->idToName[current].topology[0] = topo.nstrips();
257  m_fwGeometry->idToName[current].topology[1] = topo.stripLength();
258  m_fwGeometry->idToName[current].topology[2] = topo.pitch();
259  }
260  }
261 }
262 
263 
264 void
266 {
267  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXB().begin(),
268  end = m_trackerGeom->detsPXB().end();
269  it != end; ++it)
270  {
271  const GeomDet *det = *it;
272 
273  if( det )
274  {
275  DetId detid = det->geographicalId();
276  unsigned int rawid = detid.rawId();
277  unsigned int current = insert_id( rawid );
278  fillShapeAndPlacement( current, det );
279 
280  ADD_PIXEL_TOPOLOGY( current, m_trackerGeom->idToDetUnit( detid ));
281  }
282  }
283 }
284 
285 void
287 {
288  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXF().begin(),
289  end = m_trackerGeom->detsPXF().end();
290  it != end; ++it )
291  {
292  const GeomDet *det = *it;
293 
294  if( det )
295  {
296  DetId detid = det->geographicalId();
297  unsigned int rawid = detid.rawId();
298  unsigned int current = insert_id( rawid );
299  fillShapeAndPlacement( current, det );
300 
301  ADD_PIXEL_TOPOLOGY( current, m_trackerGeom->idToDetUnit( detid ));
302  }
303  }
304 }
305 
306 void
308 {
309  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTIB().begin(),
310  end = m_trackerGeom->detsTIB().end();
311  it != end; ++it )
312  {
313  const GeomDet *det = *it;
314 
315  if( det )
316  {
317  DetId detid = det->geographicalId();
318  unsigned int rawid = detid.rawId();
319  unsigned int current = insert_id( rawid );
320  fillShapeAndPlacement( current, det );
321 
322  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
323  }
324  }
325 }
326 
327 void
329 {
330  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTOB().begin(),
331  end = m_trackerGeom->detsTOB().end();
332  it != end; ++it )
333  {
334  const GeomDet *det = *it;
335 
336  if( det )
337  {
338  DetId detid = det->geographicalId();
339  unsigned int rawid = detid.rawId();
340  unsigned int current = insert_id( rawid );
341  fillShapeAndPlacement( current, det );
342 
343  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
344  }
345  }
346 }
347 
348 void
350 {
351  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTID().begin(),
352  end = m_trackerGeom->detsTID().end();
353  it != end; ++it)
354  {
355  const GeomDet *det = *it;
356 
357  if( det )
358  {
359  DetId detid = det->geographicalId();
360  unsigned int rawid = detid.rawId();
361  unsigned int current = insert_id( rawid );
362  fillShapeAndPlacement( current, det );
363 
364  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
365  }
366  }
367 }
368 
369 void
371 {
372  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTEC().begin(),
373  end = m_trackerGeom->detsTEC().end();
374  it != end; ++it )
375  {
376  const GeomDet *det = *it;
377 
378  if( det )
379  {
380  DetId detid = det->geographicalId();
381  unsigned int rawid = detid.rawId();
382  unsigned int current = insert_id( rawid );
383  fillShapeAndPlacement( current, det );
384 
385  ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
386  }
387  }
388 }
389 
390 void
392 {
393  std::vector<DetId> vid = m_caloGeom->getValidDetIds(); // Calo
394  for( std::vector<DetId>::const_iterator it = vid.begin(),
395  end = vid.end();
396  it != end; ++it )
397  {
398  const CaloCellGeometry::CornersVec& cor( m_caloGeom->getGeometry( *it )->getCorners());
399  unsigned int id = insert_id( it->rawId());
400  fillPoints( id, cor.begin(), cor.end());
401  }
402 }
403 
404 unsigned int
406 {
407  ++m_current;
408  m_fwGeometry->idToName.push_back(FWRecoGeom::Info());
409  m_fwGeometry->idToName.back().id = rawid;
410 
411  return m_current;
412 }
413 
414 void
415 FWRecoGeometryESProducer::fillPoints( unsigned int id, std::vector<GlobalPoint>::const_iterator begin, std::vector<GlobalPoint>::const_iterator end )
416 {
417  unsigned int index( 0 );
418  for( std::vector<GlobalPoint>::const_iterator i = begin; i != end; ++i )
419  {
420  assert( index < 23 );
421  m_fwGeometry->idToName[id].points[index] = i->x();
422  m_fwGeometry->idToName[id].points[++index] = i->y();
423  m_fwGeometry->idToName[id].points[++index] = i->z();
424  ++index;
425  }
426 }
427 
428 
430 void
432 {
433  // Trapezoidal
434  const Bounds *b = &((det->surface ()).bounds ());
435  if( const TrapezoidalPlaneBounds *b2 = dynamic_cast<const TrapezoidalPlaneBounds *> (b))
436  {
437  std::array< const float, 4 > const & par = b2->parameters ();
438 
439  // These parameters are half-lengths, as in CMSIM/GEANT3
440  m_fwGeometry->idToName[id].shape[0] = 1;
441  m_fwGeometry->idToName[id].shape[1] = par [0]; // hBottomEdge
442  m_fwGeometry->idToName[id].shape[2] = par [1]; // hTopEdge
443  m_fwGeometry->idToName[id].shape[3] = par [2]; // thickness
444  m_fwGeometry->idToName[id].shape[4] = par [3]; // apothem
445  }
446  if( const RectangularPlaneBounds *b2 = dynamic_cast<const RectangularPlaneBounds *> (b))
447  {
448  // Rectangular
449  m_fwGeometry->idToName[id].shape[0] = 2;
450  m_fwGeometry->idToName[id].shape[1] = b2->width() * 0.5; // half width
451  m_fwGeometry->idToName[id].shape[2] = b2->length() * 0.5; // half length
452  m_fwGeometry->idToName[id].shape[3] = b2->thickness() * 0.5; // half thickness
453  }
454 
455  // Position of the DetUnit's center
456  GlobalPoint pos = det->surface().position();
457  m_fwGeometry->idToName[id].translation[0] = pos.x();
458  m_fwGeometry->idToName[id].translation[1] = pos.y();
459  m_fwGeometry->idToName[id].translation[2] = pos.z();
460 
461  // Add the coeff of the rotation matrix
462  // with a projection on the basis vectors
463  TkRotation<float> detRot = det->surface().rotation();
464  m_fwGeometry->idToName[id].matrix[0] = detRot.xx();
465  m_fwGeometry->idToName[id].matrix[1] = detRot.yx();
466  m_fwGeometry->idToName[id].matrix[2] = detRot.zx();
467  m_fwGeometry->idToName[id].matrix[3] = detRot.xy();
468  m_fwGeometry->idToName[id].matrix[4] = detRot.yy();
469  m_fwGeometry->idToName[id].matrix[5] = detRot.zy();
470  m_fwGeometry->idToName[id].matrix[6] = detRot.xz();
471  m_fwGeometry->idToName[id].matrix[7] = detRot.yz();
472  m_fwGeometry->idToName[id].matrix[8] = detRot.zz();
473 }
T xx() const
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 CSCWireTopology * wireTopology() const
FWRecoGeometryESProducer(const edm::ParameterSet &)
DTLayerId id() const
Return the DetId of this SL.
Definition: DTLayer.cc:46
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 std::vector< DTLayer * > & layers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:95
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 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
const std::vector< DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:85
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
#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 std::vector< RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:67
const DetContainer & detsTID() const
const std::vector< GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:57