Go to the documentation of this file.00001 #include "Fireworks/Geometry/interface/FWRecoGeometryESProducer.h"
00002 #include "Fireworks/Geometry/interface/FWRecoGeometry.h"
00003 #include "Fireworks/Geometry/interface/FWRecoGeometryRecord.h"
00004
00005 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
00006 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
00007 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00008 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00009 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00010 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00011 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00012 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
00013 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
00014 #include "Geometry/DTGeometry/interface/DTChamber.h"
00015 #include "Geometry/DTGeometry/interface/DTLayer.h"
00016 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00017 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00018 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00019 #include "Geometry/TrackerGeometryBuilder/interface/RectangularPixelTopology.h"
00020 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00021 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00022 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
00023 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00024 #include "Geometry/CommonTopologies/interface/RectangularStripTopology.h"
00025 #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h"
00026
00027 # define ADD_PIXEL_TOPOLOGY( rawid, detUnit ) \
00028 const PixelGeomDetUnit* det = dynamic_cast<const PixelGeomDetUnit*>( detUnit ); \
00029 if( det ) \
00030 { \
00031 const PixelTopology* topo = &det->specificTopology(); \
00032 m_fwGeometry->idToName[rawid].topology[0] = topo->nrows(); \
00033 m_fwGeometry->idToName[rawid].topology[1] = topo->ncolumns(); \
00034 } \
00035
00036 # define ADD_SISTRIP_TOPOLOGY( rawid, detUnit ) \
00037 const StripGeomDetUnit* det = dynamic_cast<const StripGeomDetUnit*>( detUnit ); \
00038 if( det ) \
00039 { \
00040 const StripTopology* topo = dynamic_cast<const StripTopology*>( &det->specificTopology() ); \
00041 m_fwGeometry->idToName[rawid].topology[0] = 0; \
00042 m_fwGeometry->idToName[rawid].topology[1] = topo->nstrips(); \
00043 m_fwGeometry->idToName[rawid].topology[2] = topo->stripLength(); \
00044 if( const RadialStripTopology* rtop = dynamic_cast<const RadialStripTopology*>( &(det->specificType().specificTopology()) ) ) \
00045 { \
00046 m_fwGeometry->idToName[rawid].topology[0] = 1; \
00047 m_fwGeometry->idToName[rawid].topology[3] = rtop->yAxisOrientation(); \
00048 m_fwGeometry->idToName[rawid].topology[4] = rtop->originToIntersection(); \
00049 m_fwGeometry->idToName[rawid].topology[5] = rtop->phiOfOneEdge(); \
00050 m_fwGeometry->idToName[rawid].topology[6] = rtop->angularWidth(); \
00051 } \
00052 else if( dynamic_cast<const RectangularStripTopology*>( &(det->specificType().specificTopology()) ) ) \
00053 { \
00054 m_fwGeometry->idToName[rawid].topology[0] = 2; \
00055 m_fwGeometry->idToName[rawid].topology[3] = topo->pitch(); \
00056 } \
00057 else if( dynamic_cast<const TrapezoidalStripTopology*>( &(det->specificType().specificTopology()) ) ) \
00058 { \
00059 m_fwGeometry->idToName[rawid].topology[0] = 3; \
00060 m_fwGeometry->idToName[rawid].topology[3] = topo->pitch(); \
00061 } \
00062 } \
00063
00064 FWRecoGeometryESProducer::FWRecoGeometryESProducer( const edm::ParameterSet& )
00065 : m_current( -1 )
00066 {
00067 setWhatProduced( this );
00068 }
00069
00070 FWRecoGeometryESProducer::~FWRecoGeometryESProducer( void )
00071 {}
00072
00073 boost::shared_ptr<FWRecoGeometry>
00074 FWRecoGeometryESProducer::produce( const FWRecoGeometryRecord& record )
00075 {
00076 using namespace edm;
00077
00078 m_fwGeometry = boost::shared_ptr<FWRecoGeometry>( new FWRecoGeometry );
00079
00080 record.getRecord<GlobalTrackingGeometryRecord>().get( m_geomRecord );
00081
00082 DetId detId( DetId::Tracker, 0 );
00083 m_trackerGeom = (const TrackerGeometry*) m_geomRecord->slaveGeometry( detId );
00084
00085 record.getRecord<CaloGeometryRecord>().get( m_caloGeom );
00086
00087 addPixelBarrelGeometry( );
00088 addPixelForwardGeometry();
00089 addTIBGeometry();
00090 addTIDGeometry();
00091 addTOBGeometry();
00092 addTECGeometry();
00093 addDTGeometry();
00094 addCSCGeometry();
00095 addRPCGeometry();
00096 addCaloGeometry();
00097
00098 m_fwGeometry->idToName.resize( m_current + 1 );
00099 std::vector<FWRecoGeom::Info>( m_fwGeometry->idToName ).swap( m_fwGeometry->idToName );
00100 std::sort( m_fwGeometry->idToName.begin(), m_fwGeometry->idToName.end());
00101
00102 return m_fwGeometry;
00103 }
00104
00105 void
00106 FWRecoGeometryESProducer::addCSCGeometry( void )
00107 {
00108 DetId detId( DetId::Muon, 2 );
00109 const CSCGeometry* cscGeometry = (const CSCGeometry*) m_geomRecord->slaveGeometry( detId );
00110 for( std::vector<CSCChamber*>::const_iterator it = cscGeometry->chambers().begin(),
00111 end = cscGeometry->chambers().end();
00112 it != end; ++it )
00113 {
00114 const CSCChamber *chamber = *it;
00115
00116 if( chamber )
00117 {
00118 unsigned int rawid = chamber->geographicalId();
00119 unsigned int current = insert_id( rawid );
00120 fillShapeAndPlacement( current, chamber );
00121
00122
00123
00124 for( std::vector< const CSCLayer* >::const_iterator lit = chamber->layers().begin(),
00125 lend = chamber->layers().end();
00126 lit != lend; ++lit )
00127 {
00128 const CSCLayer* layer = *lit;
00129
00130 if( layer )
00131 {
00132 unsigned int rawid = layer->geographicalId();
00133 unsigned int current = insert_id( rawid );
00134 fillShapeAndPlacement( current, layer );
00135
00136 const CSCStripTopology* stripTopology = layer->geometry()->topology();
00137 m_fwGeometry->idToName[current].topology[0] = stripTopology->yAxisOrientation();
00138 m_fwGeometry->idToName[current].topology[1] = stripTopology->centreToIntersection();
00139 m_fwGeometry->idToName[current].topology[2] = stripTopology->yCentreOfStripPlane();
00140 m_fwGeometry->idToName[current].topology[3] = stripTopology->phiOfOneEdge();
00141 m_fwGeometry->idToName[current].topology[4] = stripTopology->stripOffset();
00142 m_fwGeometry->idToName[current].topology[5] = stripTopology->angularWidth();
00143
00144 const CSCWireTopology* wireTopology = layer->geometry()->wireTopology();
00145 m_fwGeometry->idToName[current].topology[6] = wireTopology->wireSpacing();
00146 m_fwGeometry->idToName[current].topology[7] = wireTopology->wireAngle();
00147 }
00148 }
00149 }
00150 }
00151 }
00152
00153 void
00154 FWRecoGeometryESProducer::addDTGeometry( void )
00155 {
00156 DetId detId( DetId::Muon, 1 );
00157 const DTGeometry* dtGeometry = (const DTGeometry*) m_geomRecord->slaveGeometry( detId );
00158
00159
00160
00161
00162 for( std::vector<DTChamber *>::const_iterator it = dtGeometry->chambers().begin(),
00163 end = dtGeometry->chambers().end();
00164 it != end; ++it )
00165 {
00166 const DTChamber *chamber = *it;
00167
00168 if( chamber )
00169 {
00170 unsigned int rawid = chamber->geographicalId().rawId();
00171 unsigned int current = insert_id( rawid );
00172 fillShapeAndPlacement( current, chamber );
00173 }
00174 }
00175
00176
00177 for( std::vector<DTLayer*>::const_iterator it = dtGeometry->layers().begin(),
00178 end = dtGeometry->layers().end();
00179 it != end; ++it )
00180 {
00181 const DTLayer* layer = *it;
00182
00183 if( layer )
00184 {
00185 unsigned int rawid = layer->id().rawId();
00186 unsigned int current = insert_id( rawid );
00187 fillShapeAndPlacement( current, layer );
00188
00189 const DTTopology& topo = layer->specificTopology();
00190 const BoundPlane& surf = layer->surface();
00191
00192 m_fwGeometry->idToName[current].topology[0] = topo.cellWidth();
00193 m_fwGeometry->idToName[current].topology[1] = topo.cellHeight();
00194 m_fwGeometry->idToName[current].topology[2] = topo.cellLenght();
00195 m_fwGeometry->idToName[current].topology[3] = topo.firstChannel();
00196 m_fwGeometry->idToName[current].topology[4] = topo.lastChannel();
00197 m_fwGeometry->idToName[current].topology[5] = topo.channels();
00198
00199
00200 m_fwGeometry->idToName[current].topology[6] = surf.bounds().width();
00201 m_fwGeometry->idToName[current].topology[7] = surf.bounds().thickness();
00202 m_fwGeometry->idToName[current].topology[8] = surf.bounds().length();
00203 }
00204 }
00205 }
00206
00207 void
00208 FWRecoGeometryESProducer::addRPCGeometry( void )
00209 {
00210
00211
00212
00213 DetId detId( DetId::Muon, 3 );
00214 const RPCGeometry* rpcGeom = (const RPCGeometry*) m_geomRecord->slaveGeometry( detId );
00215 for( std::vector<RPCRoll *>::const_iterator it = rpcGeom->rolls().begin(),
00216 end = rpcGeom->rolls().end();
00217 it != end; ++it )
00218 {
00219 RPCRoll* roll = (*it);
00220 if( roll )
00221 {
00222 unsigned int rawid = roll->geographicalId().rawId();
00223 unsigned int current = insert_id( rawid );
00224 fillShapeAndPlacement( current, roll );
00225
00226 const StripTopology& topo = roll->specificTopology();
00227 m_fwGeometry->idToName[current].topology[0] = roll->nstrips();
00228 m_fwGeometry->idToName[current].topology[1] = topo.stripLength();
00229 m_fwGeometry->idToName[current].topology[2] = topo.pitch();
00230 }
00231 }
00232 }
00233
00234 void
00235 FWRecoGeometryESProducer::addPixelBarrelGeometry( void )
00236 {
00237 for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXB().begin(),
00238 end = m_trackerGeom->detsPXB().end();
00239 it != end; ++it)
00240 {
00241 const GeomDet *det = *it;
00242
00243 if( det )
00244 {
00245 DetId detid = det->geographicalId();
00246 unsigned int rawid = detid.rawId();
00247 unsigned int current = insert_id( rawid );
00248 fillShapeAndPlacement( current, det );
00249
00250 ADD_PIXEL_TOPOLOGY( current, m_trackerGeom->idToDetUnit( detid ));
00251 }
00252 }
00253 }
00254
00255 void
00256 FWRecoGeometryESProducer::addPixelForwardGeometry( void )
00257 {
00258 for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXF().begin(),
00259 end = m_trackerGeom->detsPXF().end();
00260 it != end; ++it )
00261 {
00262 const GeomDet *det = *it;
00263
00264 if( det )
00265 {
00266 DetId detid = det->geographicalId();
00267 unsigned int rawid = detid.rawId();
00268 unsigned int current = insert_id( rawid );
00269 fillShapeAndPlacement( current, det );
00270
00271 ADD_PIXEL_TOPOLOGY( current, m_trackerGeom->idToDetUnit( detid ));
00272 }
00273 }
00274 }
00275
00276 void
00277 FWRecoGeometryESProducer::addTIBGeometry( void )
00278 {
00279 for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTIB().begin(),
00280 end = m_trackerGeom->detsTIB().end();
00281 it != end; ++it )
00282 {
00283 const GeomDet *det = *it;
00284
00285 if( det )
00286 {
00287 DetId detid = det->geographicalId();
00288 unsigned int rawid = detid.rawId();
00289 unsigned int current = insert_id( rawid );
00290 fillShapeAndPlacement( current, det );
00291
00292 ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
00293 }
00294 }
00295 }
00296
00297 void
00298 FWRecoGeometryESProducer::addTOBGeometry( void )
00299 {
00300 for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTOB().begin(),
00301 end = m_trackerGeom->detsTOB().end();
00302 it != end; ++it )
00303 {
00304 const GeomDet *det = *it;
00305
00306 if( det )
00307 {
00308 DetId detid = det->geographicalId();
00309 unsigned int rawid = detid.rawId();
00310 unsigned int current = insert_id( rawid );
00311 fillShapeAndPlacement( current, det );
00312
00313 ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
00314 }
00315 }
00316 }
00317
00318 void
00319 FWRecoGeometryESProducer::addTIDGeometry( void )
00320 {
00321 for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTID().begin(),
00322 end = m_trackerGeom->detsTID().end();
00323 it != end; ++it)
00324 {
00325 const GeomDet *det = *it;
00326
00327 if( det )
00328 {
00329 DetId detid = det->geographicalId();
00330 unsigned int rawid = detid.rawId();
00331 unsigned int current = insert_id( rawid );
00332 fillShapeAndPlacement( current, det );
00333
00334 ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
00335 }
00336 }
00337 }
00338
00339 void
00340 FWRecoGeometryESProducer::addTECGeometry( void )
00341 {
00342 for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTEC().begin(),
00343 end = m_trackerGeom->detsTEC().end();
00344 it != end; ++it )
00345 {
00346 const GeomDet *det = *it;
00347
00348 if( det )
00349 {
00350 DetId detid = det->geographicalId();
00351 unsigned int rawid = detid.rawId();
00352 unsigned int current = insert_id( rawid );
00353 fillShapeAndPlacement( current, det );
00354
00355 ADD_SISTRIP_TOPOLOGY( current, m_trackerGeom->idToDet( detid ));
00356 }
00357 }
00358 }
00359
00360 void
00361 FWRecoGeometryESProducer::addCaloGeometry( void )
00362 {
00363 std::vector<DetId> vid = m_caloGeom->getValidDetIds();
00364 for( std::vector<DetId>::const_iterator it = vid.begin(),
00365 end = vid.end();
00366 it != end; ++it )
00367 {
00368 const CaloCellGeometry::CornersVec& cor( m_caloGeom->getGeometry( *it )->getCorners());
00369 unsigned int id = insert_id( it->rawId());
00370 fillPoints( id, cor.begin(), cor.end());
00371 }
00372 }
00373
00374 unsigned int
00375 FWRecoGeometryESProducer::insert_id( unsigned int rawid )
00376 {
00377 ++m_current;
00378 m_fwGeometry->idToName[m_current].id = rawid;
00379
00380 assert( m_current < 260000 );
00381
00382 return m_current;
00383 }
00384
00385 void
00386 FWRecoGeometryESProducer::fillPoints( unsigned int id, std::vector<GlobalPoint>::const_iterator begin, std::vector<GlobalPoint>::const_iterator end )
00387 {
00388 unsigned int index( 0 );
00389 for( std::vector<GlobalPoint>::const_iterator i = begin; i != end; ++i )
00390 {
00391 assert( index < 24 );
00392 m_fwGeometry->idToName[id].points[index] = i->x();
00393 m_fwGeometry->idToName[id].points[++index] = i->y();
00394 m_fwGeometry->idToName[id].points[++index] = i->z();
00395 ++index;
00396 }
00397 }
00398
00399
00401 void
00402 FWRecoGeometryESProducer::fillShapeAndPlacement( unsigned int id, const GeomDet *det )
00403 {
00404
00405 const Bounds *b = &((det->surface ()).bounds ());
00406 if( const TrapezoidalPlaneBounds *b2 = dynamic_cast<const TrapezoidalPlaneBounds *> (b))
00407 {
00408 std::vector< float > par = b2->parameters ();
00409
00410
00411 m_fwGeometry->idToName[id].shape[0] = 1;
00412 m_fwGeometry->idToName[id].shape[1] = par [0];
00413 m_fwGeometry->idToName[id].shape[2] = par [1];
00414 m_fwGeometry->idToName[id].shape[3] = par [2];
00415 m_fwGeometry->idToName[id].shape[4] = par [3];
00416 }
00417 if( const RectangularPlaneBounds *b2 = dynamic_cast<const RectangularPlaneBounds *> (b))
00418 {
00419
00420 m_fwGeometry->idToName[id].shape[0] = 2;
00421 m_fwGeometry->idToName[id].shape[1] = b2->width() * 0.5;
00422 m_fwGeometry->idToName[id].shape[2] = b2->length() * 0.5;
00423 m_fwGeometry->idToName[id].shape[3] = b2->thickness() * 0.5;
00424 }
00425
00426
00427 GlobalPoint pos = det->surface().position();
00428 m_fwGeometry->idToName[id].translation[0] = pos.x();
00429 m_fwGeometry->idToName[id].translation[1] = pos.y();
00430 m_fwGeometry->idToName[id].translation[2] = pos.z();
00431
00432
00433
00434 TkRotation<float> detRot = det->surface().rotation();
00435 m_fwGeometry->idToName[id].matrix[0] = detRot.xx();
00436 m_fwGeometry->idToName[id].matrix[1] = detRot.yx();
00437 m_fwGeometry->idToName[id].matrix[2] = detRot.zx();
00438 m_fwGeometry->idToName[id].matrix[3] = detRot.xy();
00439 m_fwGeometry->idToName[id].matrix[4] = detRot.yy();
00440 m_fwGeometry->idToName[id].matrix[5] = detRot.zy();
00441 m_fwGeometry->idToName[id].matrix[6] = detRot.xz();
00442 m_fwGeometry->idToName[id].matrix[7] = detRot.yz();
00443 m_fwGeometry->idToName[id].matrix[8] = detRot.zz();
00444 }