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 );
228 std::vector<unsigned int>
231 std::vector<unsigned int> ids;
235 if( (( it.id >>
kDetOffset ) & 0xF) != det )
continue;
243 for(
const auto& id_it : ids) {
244 flag = (~0x3FF & it.id) == (~0x3FF & id_it);
251 ids.push_back( it.id );
274 TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
275 TGeoShape* geoShape =
nullptr;
276 if( info.
shape[0] == 1 )
278 geoShape =
new TGeoTrap(
292 geoShape =
new TGeoBBox( info.
shape[1], info.
shape[2], info.
shape[3] );
314 TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
315 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
316 TGeoShape* geoShape =
getShape( info );
317 shape->SetShape( geoShape );
319 shape->SetTransMatrix( array );
328 const unsigned int type = (
id>>26)&0x3;
331 id |= (type == 0) ? 0x16B : 0xE7;
333 float sideToSideWaferSize = 16.7441f;
334 float dx = sideToSideWaferSize/2;
335 float sidey = dx/
sqrt(3);
338 int waferUint = (
id >> 10) & 0xF;
339 int waferVint = (
id >> 15) & 0xF;
340 float waferU = ((
id>>14) & 0
x1) ? -sideToSideWaferSize*waferUint : sideToSideWaferSize*waferUint;
341 float waferV = ((
id>>19) & 0
x1) ? -sideToSideWaferSize*waferVint : sideToSideWaferSize*waferVint;
343 float waferX = (-2*waferU+waferV)/2;
344 float waferY = waferV*
sqrt(3)/2;
354 TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
355 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
363 TGeoXtru* geoShape =
new TGeoXtru(2);
375 geoShape->DefinePolygon(6,x,y);
376 geoShape->DefineSection(0, -dz);
377 geoShape->DefineSection(1, dz);
379 shape->SetShape( geoShape );
386 shape->SetTransMatrix( array );
401 TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
402 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
404 TGeoXtru* geoShape =
new TGeoXtru(2);
412 bool isNeg = info.
shape[3] < 0;
413 geoShape->DefinePolygon(4,x,y);
414 geoShape->DefineSection(0, isNeg*info.
shape[3]);
415 geoShape->DefineSection(1, !isNeg*info.
shape[3]);
418 shape->SetShape( geoShape );
425 shape->SetTransMatrix( array );
441 return ( *it ).points;
457 return ( *it ).parameters;
473 return ( *it ).shape;
493 const float* local2,
float* global2,
bool translatep )
const 518 for(
int i = 0;
i < 3; ++
i )
521 global[
i] += local[0] * info.
matrix[3 *
i]
522 + local[1] * info.
matrix[3 *
i + 1]
523 + local[2] * info.
matrix[3 *
i + 2];
532 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
TEveGeoShape * getHGCSiliconEveShape(unsigned int id) const
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)
static const int kDetOffset
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
TEveGeoShape * getHGCScintillatorEveShape(unsigned int id) const