3 #include "TEveGeoNode.h" 30 if (gSystem->Getenv(
"CMSSW_SEARCH_PATH" ))
33 TString paths = gSystem->Getenv(
"CMSSW_SEARCH_PATH" );
35 TObjArray* tokens = paths.Tokenize(
":" );
36 for(
int i = 0;
i < tokens->GetEntries(); ++
i )
38 TObjString*
path = (TObjString*)tokens->At(
i );
40 searchPath +=
static_cast<const char *
>(path->GetString());
41 if (gSystem->Getenv(
"CMSSW_VERSION"))
42 searchPath +=
"/Fireworks/Geometry/data/";
47 const char* fp = gSystem->FindFile(searchPath.c_str(), fn, kFileExists);
48 return fp ? TFile::Open( fp) :
nullptr;
57 throw std::runtime_error(
"ERROR: failed to find geometry file. Initialization failed." );
61 TTree*
tree =
static_cast<TTree*
>(file->Get(
"idToGeo" ));
64 throw std::runtime_error(
"ERROR: cannot find detector id map in the file. Initialization failed." );
72 Float_t translation[3];
74 bool loadPoints = tree->GetBranch(
"points" ) !=
nullptr;
75 bool loadParameters = tree->GetBranch(
"topology" ) !=
nullptr;
76 bool loadShape = tree->GetBranch(
"shape" ) !=
nullptr;
77 bool loadTranslation = tree->GetBranch(
"translation" ) !=
nullptr;
78 bool loadMatrix = tree->GetBranch(
"matrix" ) !=
nullptr;
79 tree->SetBranchAddress(
"id", &
id );
81 tree->SetBranchAddress(
"points", &points );
83 tree->SetBranchAddress(
"topology", &topology );
85 tree->SetBranchAddress(
"shape", &shape );
87 tree->SetBranchAddress(
"translation", &translation );
89 tree->SetBranchAddress(
"matrix", &matrix );
91 unsigned int treeSize = tree->GetEntries();
94 for(
unsigned int i = 0;
i < treeSize; ++
i )
101 for(
unsigned int j = 0; j < 24; ++j )
106 for(
unsigned int j = 0; j < 9; ++j )
111 for(
unsigned int j = 0; j < 5; ++j )
114 if( loadTranslation )
116 for(
unsigned int j = 0; j < 3; ++j )
121 for(
unsigned int j = 0; j < 9; ++j )
132 TString
path = file->GetPath();
133 if (path.EndsWith(
":/")) path.Resize(path.Length() -2);
138 fwLog(
fwlog::kInfo ) << Form(
"Load %s from %s\n", tree->GetName(), path.Data());
141 TNamed* producerInfo =
static_cast<TNamed*
>(file->Get(
"PRODUCER_VERSION" ));
153 unsigned int mapSize = map.size();
158 it !=
end; ++it, ++
i )
161 for(
unsigned int j = 0; j < 24; ++j )
163 for(
unsigned int j = 0; j < 9; ++j )
165 for(
unsigned int j = 0; j < 5; ++j )
167 for(
unsigned int j = 0; j < 3; ++j )
169 for(
unsigned int j = 0; j < 9; ++j )
177 std::map<unsigned int, TGeoMatrix*>::iterator mit =
m_idToMatrix.find(
id );
195 rotation.SetMatrix( matrix );
202 std::vector<unsigned int>
205 std::vector<unsigned int>
ids;
206 unsigned int mask = ( det << 4 ) | ( subdet );
211 ids.push_back(( *it ).id );
235 TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
236 TGeoShape* geoShape =
nullptr;
237 if( info.
shape[0] == 1 )
239 geoShape =
new TGeoTrap(
253 geoShape =
new TGeoBBox( info.
shape[1], info.
shape[2], info.
shape[3] );
275 TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
276 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
277 TGeoShape* geoShape =
getShape( info );
278 shape->SetShape( geoShape );
280 shape->SetTransMatrix( array );
297 return ( *it ).points;
313 return ( *it ).parameters;
329 return ( *it ).shape;
349 const float* local2,
float* global2,
bool translatep )
const 368 return std::lower_bound( begin, end,
id );
374 for(
int i = 0;
i < 3; ++
i )
377 global[
i] += local[0] * info.
matrix[3 *
i]
378 + local[1] * info.
matrix[3 *
i + 1]
379 + local[2] * info.
matrix[3 *
i + 2];
388 return (extraDetectors && extraDetectors->FindObject(det)) ?
true :
false;
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
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr