3 #include "TEveGeoNode.h" 34 if (gSystem->Getenv(
"CMSSW_SEARCH_PATH" ))
37 TString paths = gSystem->Getenv(
"CMSSW_SEARCH_PATH" );
39 TObjArray* tokens = paths.Tokenize(
":" );
40 for(
int i = 0;
i < tokens->GetEntries(); ++
i )
42 TObjString*
path = (TObjString*)tokens->At(
i );
44 searchPath +=
static_cast<const char *
>(path->GetString());
45 if (gSystem->Getenv(
"CMSSW_VERSION"))
46 searchPath +=
"/Fireworks/Geometry/data/";
51 const char* fp = gSystem->FindFile(searchPath.c_str(), fn, kFileExists);
52 return fp ? TFile::Open( fp) :
nullptr;
61 throw std::runtime_error(
"ERROR: failed to find geometry file. Initialization failed." );
65 TTree*
tree =
static_cast<TTree*
>(file->Get(
"idToGeo" ));
68 throw std::runtime_error(
"ERROR: cannot find detector id map in the file. Initialization failed." );
76 Float_t translation[3];
78 bool loadPoints = tree->GetBranch(
"points" ) !=
nullptr;
79 bool loadParameters = tree->GetBranch(
"topology" ) !=
nullptr;
80 bool loadShape = tree->GetBranch(
"shape" ) !=
nullptr;
81 bool loadTranslation = tree->GetBranch(
"translation" ) !=
nullptr;
82 bool loadMatrix = tree->GetBranch(
"matrix" ) !=
nullptr;
83 tree->SetBranchAddress(
"id", &
id );
85 tree->SetBranchAddress(
"points", &points );
87 tree->SetBranchAddress(
"topology", &topology );
89 tree->SetBranchAddress(
"shape", &shape );
91 tree->SetBranchAddress(
"translation", &translation );
93 tree->SetBranchAddress(
"matrix", &matrix );
95 unsigned int treeSize = tree->GetEntries();
98 for(
unsigned int i = 0;
i < treeSize; ++
i )
105 for(
unsigned int j = 0; j < 24; ++j )
110 for(
unsigned int j = 0; j < 9; ++j )
115 for(
unsigned int j = 0; j < 5; ++j )
118 if( loadTranslation )
120 for(
unsigned int j = 0; j < 3; ++j )
125 for(
unsigned int j = 0; j < 9; ++j )
136 TString
path = file->GetPath();
137 if (path.EndsWith(
":/")) path.Resize(path.Length() -2);
142 fwLog(
fwlog::kInfo ) << Form(
"Load %s from %s\n", tree->GetName(), path.Data());
145 TNamed* producerInfo =
static_cast<TNamed*
>(file->Get(
"PRODUCER_VERSION" ));
150 TNamed* ttopology =
static_cast<TNamed*
>(file->Get(
"TrackerTopology" ));
164 unsigned int mapSize = map.size();
169 it !=
end; ++it, ++
i )
172 for(
unsigned int j = 0; j < 24; ++j )
174 for(
unsigned int j = 0; j < 9; ++j )
176 for(
unsigned int j = 0; j < 5; ++j )
178 for(
unsigned int j = 0; j < 3; ++j )
180 for(
unsigned int j = 0; j < 9; ++j )
188 std::map<unsigned int, TGeoMatrix*>::iterator mit =
m_idToMatrix.find(
id );
206 rotation.SetMatrix( matrix );
213 std::vector<unsigned int>
216 std::vector<unsigned int>
ids;
217 unsigned int mask = ( det << 4 ) | ( subdet );
222 ids.push_back(( *it ).id );
246 TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
247 TGeoShape* geoShape =
nullptr;
248 if( info.
shape[0] == 1 )
250 geoShape =
new TGeoTrap(
264 geoShape =
new TGeoBBox( info.
shape[1], info.
shape[2], info.
shape[3] );
286 TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
287 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
288 TGeoShape* geoShape =
getShape( info );
289 shape->SetShape( geoShape );
291 shape->SetTransMatrix( array );
308 return ( *it ).points;
324 return ( *it ).parameters;
340 return ( *it ).shape;
360 const float* local2,
float* global2,
bool translatep )
const 379 return std::lower_bound( begin, end,
id );
385 for(
int i = 0;
i < 3; ++
i )
388 global[
i] += local[0] * info.
matrix[3 *
i]
389 + local[1] * info.
matrix[3 *
i + 1]
390 + local[2] * info.
matrix[3 *
i + 2];
399 return (extraDetectors && extraDetectors->FindObject(det)) ?
true :
false;
std::unique_ptr< TrackerTopology > m_trackerTopology
static TFile * findFile(const char *fileName)
std::vector< FWRecoGeom::Info >::const_iterator InfoMapItr
TObjArray * extraDetectors
void initMap(const FWRecoGeom::InfoMap &map)
CaloTopology const * topology(0)
IdToInfoItr find(unsigned int) const
const float * getParameters(unsigned int id) const
bool match_id(const GeomDetInfo &o, unsigned int mask) const
TGeoShape * getShape(unsigned int id) const
const TGeoMatrix * getMatrix(unsigned int id) const
std::map< unsigned int, TGeoMatrix * > m_idToMatrix
const float * getShapePars(unsigned int id) const
bool haveExtraDet(const char *) const
VersionInfo m_versionInfo
TEveGeoShape * getEveShape(unsigned int id) const
void loadMap(const char *fileName)
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
std::vector< FWRecoGeom::Info > InfoMap
const float * getCorners(unsigned int id) const
std::vector< unsigned int > getMatchedIds(Detector det, SubDetector subdet) const
TrackerTopology fromTrackerParametersXMLString(const std::string &xmlContent)
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr