#include <FWGeometry.h>
Classes | |
struct | GeomDetInfo |
struct | Range |
Public Types | |
enum | Detector { Tracker = 1, Muon = 2, Ecal = 3, Hcal = 4, Calo = 5 } |
typedef std::vector < FWGeometry::GeomDetInfo > | IdToInfo |
typedef std::vector < FWGeometry::GeomDetInfo > ::const_iterator | IdToInfoItr |
enum | SubDetector { PixelBarrel = 1, PixelEndcap = 2, TIB = 3, TID = 4, TOB = 5, TEC = 6, CSC = 7, DT = 8, RPCBarrel = 9, RPCEndcap = 10 } |
Public Member Functions | |
void | clear (void) |
bool | contains (unsigned int id) const |
IdToInfoItr | find (unsigned int) const |
FWGeometry (void) | |
const float * | getCorners (unsigned int id) const |
TEveGeoShape * | getEveShape (unsigned int id) const |
std::vector< unsigned int > | getMatchedIds (Detector det, SubDetector subdet) const |
const TGeoMatrix * | getMatrix (unsigned int id) const |
const float * | getParameters (unsigned int id) const |
TGeoShape * | getShape (unsigned int id) const |
const float * | getShapePars (unsigned int id) const |
void | initMap (const FWRecoGeom::InfoMap &map) |
void | loadMap (const char *fileName) |
void | localToGlobal (const GeomDetInfo &info, const float *local, float *global) const |
void | localToGlobal (unsigned int id, const float *local1, float *global1, const float *local2, float *global2) const |
void | localToGlobal (unsigned int id, const float *local, float *global) const |
bool | match_id (const GeomDetInfo &o, unsigned int mask) const |
~FWGeometry (void) | |
Static Public Member Functions | |
static TFile * | findFile (const char *fileName) |
Static Public Attributes | |
static const int | kDetOffset = 28 |
static const int | kSubdetOffset = 25 |
Private Member Functions | |
TGeoShape * | getShape (const GeomDetInfo &info) const |
Private Attributes | |
IdToInfo | m_idToInfo |
std::map< unsigned int, TGeoMatrix * > | m_idToMatrix |
Definition at line 23 of file FWGeometry.h.
typedef std::vector<FWGeometry::GeomDetInfo> FWGeometry::IdToInfo |
Definition at line 95 of file FWGeometry.h.
typedef std::vector<FWGeometry::GeomDetInfo>::const_iterator FWGeometry::IdToInfoItr |
Definition at line 96 of file FWGeometry.h.
enum FWGeometry::Detector |
Definition at line 30 of file FWGeometry.h.
{ PixelBarrel = 1, PixelEndcap = 2, TIB = 3, TID = 4, TOB = 5, TEC = 6, CSC = 7, DT = 8, RPCBarrel = 9, RPCEndcap = 10 };
FWGeometry::FWGeometry | ( | void | ) |
Definition at line 18 of file FWGeometry.cc.
{}
FWGeometry::~FWGeometry | ( | void | ) |
Definition at line 21 of file FWGeometry.cc.
{}
void FWGeometry::clear | ( | void | ) | [inline] |
Definition at line 102 of file FWGeometry.h.
References m_idToInfo, and m_idToMatrix.
{ m_idToInfo.clear(); m_idToMatrix.clear(); }
bool FWGeometry::contains | ( | unsigned int | id | ) | const [inline] |
Definition at line 98 of file FWGeometry.h.
References find(), and m_idToInfo.
Referenced by fireworks::addSiStripClusters(), FWSiStripDigiProxyBuilder::build(), FWCSCRecHitProxyBuilder::build(), FWSiPixelClusterProxyBuilder::build(), FWSiPixelClusterDetProxyBuilder::build(), FWCSCSegmentProxyBuilder::build(), FWPSimHitProxyBuilder::build(), FWCSCStripDigiProxyBuilder::build(), FWCSCWireDigiProxyBuilder::build(), FWSiPixelDigiProxyBuilder::build(), FWRPCDigiProxyBuilder::build(), FWTrackTrackingRecHitProxyBuilder::build(), FWDTSegmentProxyBuilder::build(), FWDTRecHitProxyBuilder::buildViewType(), FWDTDigiProxyBuilder::buildViewType(), FWRPCRecHitProxyBuilder::buildViewType(), fireworks::pushNearbyPixelHits(), and fireworks::pushPixelHits().
{ return FWGeometry::find( id ) != m_idToInfo.end(); }
FWGeometry::IdToInfoItr FWGeometry::find | ( | unsigned int | id | ) | const |
Definition at line 354 of file FWGeometry.cc.
References begin, end, and m_idToInfo.
Referenced by FWCSCRecHitProxyBuilder::build(), FWDTDigiProxyBuilder::buildViewType(), FWRPCRecHitProxyBuilder::buildViewType(), contains(), getCorners(), getEveShape(), getMatrix(), getParameters(), getShape(), getShapePars(), localToGlobal(), and FWRPZViewGeometry::makeMuonGeometryRhoZ().
{ FWGeometry::IdToInfoItr begin = m_idToInfo.begin(); FWGeometry::IdToInfoItr end = m_idToInfo.end(); return std::lower_bound( begin, end, id ); }
TFile * FWGeometry::findFile | ( | const char * | fileName | ) | [static] |
Definition at line 25 of file FWGeometry.cc.
References mergeVDriftHistosByStation::file, convertXMLtoSQLite_cfg::fileName, i, scaleCards::path, and EgammaValidation_cff::paths.
Referenced by loadMap(), and FWGeometryTableViewManager::setGeoManagerFromFile().
{ TString file; if( fileName[0] == '/' || ( fileName[0] == '.' && fileName[1] == '/' )) { file = fileName; } else { if( const char* cmspath = gSystem->Getenv( "CMSSW_BASE" )) { file += cmspath; file += "/"; } file += fileName; } if( !gSystem->AccessPathName( file.Data())) { return TFile::Open( file ); } const char* searchpath = gSystem->Getenv( "CMSSW_SEARCH_PATH" ); if( searchpath == 0 ) return 0; TString paths( searchpath ); TObjArray* tokens = paths.Tokenize( ":" ); for( int i = 0; i < tokens->GetEntries(); ++i ) { TObjString* path = (TObjString*)tokens->At( i ); TString fullFileName( path->GetString()); fullFileName += "/Fireworks/Geometry/data/"; fullFileName += fileName; if( !gSystem->AccessPathName( fullFileName.Data())) return TFile::Open( fullFileName.Data()); } return 0; }
const float * FWGeometry::getCorners | ( | unsigned int | id | ) | const |
Definition at line 277 of file FWGeometry.cc.
References find(), fwLog, fwlog::kWarning, and m_idToInfo.
Referenced by FWCaloClusterProxyBuilder::build(), FWCastorRecHitProxyBuilder::build(), FWPFEcalRecHitLegoProxyBuilder::build(), FWPRCaloTowerProxyBuilder::build(), FWZDCRecHitProxyBuilder::build(), FWPCaloHitProxyBuilder::build(), FWHBHERecHitProxyBuilder::build(), FWHFRecHitProxyBuilder::build(), FWPFEcalRecHitRPProxyBuilder::build(), FWEcalRecHitProxyBuilder::build(), FWHORecHitProxyBuilder::build(), FWPhotonProxyBuilder::buildViewType(), FWECALDetailViewBuilder::fillData(), FWHFTowerSliceSelector::findBinFromId(), fireworks::makeRhoPhiSuperCluster(), fireworks::makeRhoZSuperCluster(), FWEcalRecHitProxyBuilder::scaleProduct(), FWHBHERecHitProxyBuilder::scaleProduct(), and ValidateGeometry::validateCaloGeometry().
{ // reco geometry points IdToInfoItr it = FWGeometry::find( id ); if( it == m_idToInfo.end()) { fwLog( fwlog::kWarning ) << "no reco geometry found for id " << id << std::endl; return 0; } else { return ( *it ).points; } }
TEveGeoShape * FWGeometry::getEveShape | ( | unsigned int | id | ) | const |
Definition at line 250 of file FWGeometry.cc.
References find(), fwLog, getShape(), info, fwlog::kWarning, m_idToInfo, FWGeometry::GeomDetInfo::matrix, and FWGeometry::GeomDetInfo::translation.
Referenced by FWConvTrackHitsDetailView::addModules(), FWTrackHitsDetailView::addModules(), FWTracksModulesProxyBuilder::build(), FWSiPixelClusterDetProxyBuilder::build(), FWCSCSegmentProxyBuilder::build(), FWSiStripClusterProxyBuilder::build(), FWDTSegmentProxyBuilder::build(), FWRPCRecHitProxyBuilder::buildViewType(), FWRPZViewGeometry::makeMuonGeometryRhoPhi(), FW3DViewGeometry::showMuonBarrel(), FW3DViewGeometry::showMuonBarrelFull(), FW3DViewGeometry::showMuonEndcap(), FWRPZViewGeometry::showPixelBarrel(), FW3DViewGeometry::showPixelBarrel(), FWRPZViewGeometry::showPixelEndcap(), FW3DViewGeometry::showPixelEndcap(), FW3DViewGeometry::showTrackerBarrel(), FWRPZViewGeometry::showTrackerBarrel(), FW3DViewGeometry::showTrackerEndcap(), and FWRPZViewGeometry::showTrackerEndcap().
{ IdToInfoItr it = FWGeometry::find( id ); if( it == m_idToInfo.end()) { fwLog( fwlog::kWarning ) << "no reco geoemtry found for id " << id << std::endl; return 0; } else { const GeomDetInfo& info = *it; double array[16] = { info.matrix[0], info.matrix[3], info.matrix[6], 0., info.matrix[1], info.matrix[4], info.matrix[7], 0., info.matrix[2], info.matrix[5], info.matrix[8], 0., info.translation[0], info.translation[1], info.translation[2], 1. }; TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur()); TEveGeoShape* shape = new TEveGeoShape(TString::Format("RecoGeom Id=%u", id)); TGeoShape* geoShape = getShape( info ); shape->SetShape( geoShape ); // Set transformation matrix from a column-major array shape->SetTransMatrix( array ); return shape; } }
std::vector< unsigned int > FWGeometry::getMatchedIds | ( | Detector | det, |
SubDetector | subdet | ||
) | const |
Definition at line 194 of file FWGeometry.cc.
References m_idToInfo, and match_id().
Referenced by FWRPZViewGeometry::showPixelBarrel(), FW3DViewGeometry::showPixelBarrel(), FWRPZViewGeometry::showPixelEndcap(), FW3DViewGeometry::showPixelEndcap(), FW3DViewGeometry::showTrackerBarrel(), FWRPZViewGeometry::showTrackerBarrel(), FW3DViewGeometry::showTrackerEndcap(), and FWRPZViewGeometry::showTrackerEndcap().
{ std::vector<unsigned int> ids; unsigned int mask = ( det << 4 ) | ( subdet ); for( IdToInfoItr it = m_idToInfo.begin(), itEnd = m_idToInfo.end(); it != itEnd; ++it ) { if( FWGeometry::match_id( *it, mask )) ids.push_back(( *it ).id ); } return ids; }
const TGeoMatrix * FWGeometry::getMatrix | ( | unsigned int | id | ) | const |
Definition at line 166 of file FWGeometry.cc.
References find(), fwLog, errorMatrix2Lands_multiChannel::id, info, fwlog::kWarning, m_idToInfo, m_idToMatrix, FWGeometry::GeomDetInfo::matrix, makeMuonMisalignmentScenario::matrix, idealTransformation::rotation, and FWGeometry::GeomDetInfo::translation.
Referenced by FWTrackResidualDetailView::getSignedResidual(), ValidateGeometry::validateCSChamberGeometry(), ValidateGeometry::validateCSCLayerGeometry(), ValidateGeometry::validateDTChamberGeometry(), ValidateGeometry::validateDTLayerGeometry(), ValidateGeometry::validateRPCGeometry(), and ValidateGeometry::validateTrackerGeometry().
{ std::map<unsigned int, TGeoMatrix*>::iterator mit = m_idToMatrix.find( id ); if( mit != m_idToMatrix.end()) return mit->second; IdToInfoItr it = FWGeometry::find( id ); if( it == m_idToInfo.end()) { fwLog( fwlog::kWarning ) << "no reco geometry found for id " << id << std::endl; return 0; } else { const GeomDetInfo& info = *it; TGeoTranslation trans( info.translation[0], info.translation[1], info.translation[2] ); TGeoRotation rotation; const Double_t matrix[9] = { info.matrix[0], info.matrix[1], info.matrix[2], info.matrix[3], info.matrix[4], info.matrix[5], info.matrix[6], info.matrix[7], info.matrix[8] }; rotation.SetMatrix( matrix ); m_idToMatrix[id] = new TGeoCombiTrans( trans, rotation ); return m_idToMatrix[id]; } }
const float * FWGeometry::getParameters | ( | unsigned int | id | ) | const |
Definition at line 293 of file FWGeometry.cc.
References find(), fwLog, fwlog::kWarning, and m_idToInfo.
Referenced by fireworks::addSiStripClusters(), FWSiStripDigiProxyBuilder::build(), FWSiPixelClusterProxyBuilder::build(), FWCSCStripDigiProxyBuilder::build(), FWSiPixelDigiProxyBuilder::build(), FWRPCDigiProxyBuilder::build(), FWSiStripClusterProxyBuilder::build(), FWDTDigiProxyBuilder::buildViewType(), fireworks::pushNearbyPixelHits(), fireworks::pushPixelHits(), ValidateGeometry::validateCSCLayerGeometry(), ValidateGeometry::validateDTLayerGeometry(), ValidateGeometry::validatePixelTopology(), ValidateGeometry::validateRPCGeometry(), and ValidateGeometry::validateStripTopology().
{ // reco geometry parameters IdToInfoItr it = FWGeometry::find( id ); if( it == m_idToInfo.end()) { fwLog( fwlog::kWarning ) << "no reco geometry found for id " << id << std::endl; return 0; } else { return ( *it ).parameters; } }
TGeoShape * FWGeometry::getShape | ( | unsigned int | id | ) | const |
Definition at line 209 of file FWGeometry.cc.
References find(), fwLog, fwlog::kWarning, and m_idToInfo.
Referenced by getEveShape().
{ IdToInfoItr it = FWGeometry::find( id ); if( it == m_idToInfo.end()) { fwLog( fwlog::kWarning ) << "no reco geoemtry found for id " << id << std::endl; return 0; } else { return getShape( *it ); } }
TGeoShape * FWGeometry::getShape | ( | const GeomDetInfo & | info | ) | const [private] |
Definition at line 224 of file FWGeometry.cc.
References FWGeometry::GeomDetInfo::shape.
{ TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur()); TGeoShape* geoShape = 0; if( info.shape[0] == 1 ) { geoShape = new TGeoTrap( info.shape[3], //dz 0, //theta 0, //phi info.shape[4], //dy1 info.shape[1], //dx1 info.shape[2], //dx2 0, //alpha1 info.shape[4], //dy2 info.shape[1], //dx3 info.shape[2], //dx4 0); //alpha2 } else geoShape = new TGeoBBox( info.shape[1], info.shape[2], info.shape[3] ); return geoShape; }
const float * FWGeometry::getShapePars | ( | unsigned int | id | ) | const |
Definition at line 309 of file FWGeometry.cc.
References find(), fwLog, fwlog::kWarning, and m_idToInfo.
Referenced by FWCSCStripDigiProxyBuilder::build(), FWCSCWireDigiProxyBuilder::build(), ValidateGeometry::validateCSChamberGeometry(), ValidateGeometry::validateCSCLayerGeometry(), ValidateGeometry::validateDTChamberGeometry(), ValidateGeometry::validateDTLayerGeometry(), ValidateGeometry::validateRPCGeometry(), and ValidateGeometry::validateTrackerGeometry().
{ // reco geometry parameters IdToInfoItr it = FWGeometry::find( id ); if( it == m_idToInfo.end()) { fwLog( fwlog::kWarning ) << "no reco geometry found for id " << id << std::endl; return 0; } else { return ( *it ).shape; } }
void FWGeometry::initMap | ( | const FWRecoGeom::InfoMap & | map | ) |
Definition at line 140 of file FWGeometry.cc.
References begin, end, i, j, m_idToInfo, and makeMuonMisalignmentScenario::matrix.
Referenced by FWFFLooper::beginRun(), and FWFFService::postBeginRun().
{ FWRecoGeom::InfoMapItr begin = map.begin(); FWRecoGeom::InfoMapItr end = map.end(); unsigned int mapSize = map.size(); if( m_idToInfo.size() != mapSize ) m_idToInfo.resize( mapSize ); unsigned int i = 0; for( FWRecoGeom::InfoMapItr it = begin; it != end; ++it, ++i ) { m_idToInfo[i].id = it->id; for( unsigned int j = 0; j < 24; ++j ) m_idToInfo[i].points[j] = it->points[j]; for( unsigned int j = 0; j < 9; ++j ) m_idToInfo[i].parameters[j] = it->topology[j]; for( unsigned int j = 0; j < 5; ++j ) m_idToInfo[i].shape[j] = it->shape[j]; for( unsigned int j = 0; j < 3; ++j ) m_idToInfo[i].translation[j] = it->translation[j]; for( unsigned int j = 0; j < 9; ++j ) m_idToInfo[i].matrix[j] = it->matrix[j]; } }
void FWGeometry::loadMap | ( | const char * | fileName | ) |
Definition at line 64 of file FWGeometry.cc.
References mergeVDriftHistosByStation::file, findFile(), i, errorMatrix2Lands_multiChannel::id, j, PhysicsTools::loadMatrix(), m_idToInfo, makeMuonMisalignmentScenario::matrix, Parameters::parameters, and diffTreeTool::tree.
Referenced by CmsShowMainBase::loadGeometry(), and ValidateGeometry::ValidateGeometry().
{ TFile* file = findFile( fileName ); if( ! file ) { throw std::runtime_error( "ERROR: failed to find geometry file. Initialization failed." ); return; } TTree* tree = static_cast<TTree*>(file->Get( "idToGeo" )); if( ! tree ) { throw std::runtime_error( "ERROR: cannot find detector id map in the file. Initialization failed." ); return; } unsigned int id; Float_t points[24]; Float_t topology[9]; Float_t shape[5]; Float_t translation[3]; Float_t matrix[9]; bool loadPoints = tree->GetBranch( "points" ) != 0; bool loadParameters = tree->GetBranch( "topology" ) != 0; bool loadShape = tree->GetBranch( "shape" ) != 0; bool loadTranslation = tree->GetBranch( "translation" ) != 0; bool loadMatrix = tree->GetBranch( "matrix" ) != 0; tree->SetBranchAddress( "id", &id ); if( loadPoints ) tree->SetBranchAddress( "points", &points ); if( loadParameters ) tree->SetBranchAddress( "topology", &topology ); if( loadShape ) tree->SetBranchAddress( "shape", &shape ); if( loadTranslation ) tree->SetBranchAddress( "translation", &translation ); if( loadMatrix ) tree->SetBranchAddress( "matrix", &matrix ); unsigned int treeSize = tree->GetEntries(); if( m_idToInfo.size() != treeSize ) m_idToInfo.resize( treeSize ); for( unsigned int i = 0; i < treeSize; ++i ) { tree->GetEntry( i ); m_idToInfo[i].id = id; if( loadPoints ) { for( unsigned int j = 0; j < 24; ++j ) m_idToInfo[i].points[j] = points[j]; } if( loadParameters ) { for( unsigned int j = 0; j < 9; ++j ) m_idToInfo[i].parameters[j] = topology[j]; } if( loadShape ) { for( unsigned int j = 0; j < 5; ++j ) m_idToInfo[i].shape[j] = shape[j]; } if( loadTranslation ) { for( unsigned int j = 0; j < 3; ++j ) m_idToInfo[i].translation[j] = translation[j]; } if( loadMatrix ) { for( unsigned int j = 0; j < 9; ++j ) m_idToInfo[i].matrix[j] = matrix[j]; } } file->Close(); }
void FWGeometry::localToGlobal | ( | unsigned int | id, |
const float * | local, | ||
float * | global | ||
) | const |
Definition at line 325 of file FWGeometry.cc.
References find(), fwLog, fwlog::kWarning, and m_idToInfo.
Referenced by fireworks::addSiStripClusters(), FWSiStripDigiProxyBuilder::build(), FWCSCRecHitProxyBuilder::build(), FWSiPixelClusterProxyBuilder::build(), FWCSCSegmentProxyBuilder::build(), FWPSimHitProxyBuilder::build(), FWCSCStripDigiProxyBuilder::build(), FWCSCWireDigiProxyBuilder::build(), FWSiPixelDigiProxyBuilder::build(), FWTrackingParticleProxyBuilder::build(), FWRPCDigiProxyBuilder::build(), FWSiStripClusterProxyBuilder::build(), FWTrackTrackingRecHitProxyBuilder::build(), FWDTSegmentProxyBuilder::build(), FWDTRecHitProxyBuilder::buildViewType(), FWDTDigiProxyBuilder::buildViewType(), FWRPCRecHitProxyBuilder::buildViewType(), FWRPZViewGeometry::estimateProjectionSizeCSC(), FWRPZViewGeometry::estimateProjectionSizeDT(), localToGlobal(), and fireworks::pushPixelCluster().
{ IdToInfoItr it = FWGeometry::find( id ); if( it == m_idToInfo.end()) { fwLog( fwlog::kWarning ) << "no reco geometry found for id " << id << std::endl; } else { localToGlobal( *it, local, global ); } }
void FWGeometry::localToGlobal | ( | unsigned int | id, |
const float * | local1, | ||
float * | global1, | ||
const float * | local2, | ||
float * | global2 | ||
) | const |
Definition at line 339 of file FWGeometry.cc.
References find(), fwLog, fwlog::kWarning, localToGlobal(), and m_idToInfo.
{ IdToInfoItr it = FWGeometry::find( id ); if( it == m_idToInfo.end()) { fwLog( fwlog::kWarning ) << "no reco geometry found for id " << id << std::endl; } else { localToGlobal( *it, local1, global1 ); localToGlobal( *it, local2, global2 ); } }
void FWGeometry::localToGlobal | ( | const GeomDetInfo & | info, |
const float * | local, | ||
float * | global | ||
) | const |
Definition at line 362 of file FWGeometry.cc.
References i, FWGeometry::GeomDetInfo::matrix, and FWGeometry::GeomDetInfo::translation.
bool FWGeometry::match_id | ( | const GeomDetInfo & | o, |
unsigned int | mask | ||
) | const [inline] |
Definition at line 90 of file FWGeometry.h.
References FWGeometry::GeomDetInfo::id, kDetOffset, and kSubdetOffset.
Referenced by getMatchedIds().
{ unsigned int id = o.id; return ((((( id >> kDetOffset ) & 0xF ) << 4) | (( id >> kSubdetOffset ) & 0x7 )) == mask ); }
const int FWGeometry::kDetOffset = 28 [static] |
Definition at line 26 of file FWGeometry.h.
Referenced by match_id().
const int FWGeometry::kSubdetOffset = 25 [static] |
Definition at line 27 of file FWGeometry.h.
Referenced by match_id().
IdToInfo FWGeometry::m_idToInfo [private] |
Definition at line 109 of file FWGeometry.h.
Referenced by clear(), contains(), find(), getCorners(), getEveShape(), getMatchedIds(), getMatrix(), getParameters(), getShape(), getShapePars(), initMap(), loadMap(), and localToGlobal().
std::map<unsigned int, TGeoMatrix*> FWGeometry::m_idToMatrix [mutable, private] |
Definition at line 107 of file FWGeometry.h.
Referenced by clear(), and getMatrix().