3 #include "TEveGeoNode.h" 29 if (gSystem->Getenv(
"CMSSW_SEARCH_PATH")) {
30 TString
paths = gSystem->Getenv(
"CMSSW_SEARCH_PATH");
32 TObjArray* tokens = paths.Tokenize(
":");
33 for (
int i = 0;
i < tokens->GetEntries(); ++
i) {
34 TObjString*
path = (TObjString*)tokens->At(
i);
36 searchPath +=
static_cast<const char*
>(path->GetString());
37 if (gSystem->Getenv(
"CMSSW_VERSION"))
38 searchPath +=
"/Fireworks/Geometry/data/";
43 const char*
fp = gSystem->FindFile(searchPath.c_str(),
fn, kFileExists);
44 return fp ? TFile::Open(fp) :
nullptr;
50 throw std::runtime_error(
"ERROR: failed to find geometry file. Initialization failed.");
54 TTree*
tree =
static_cast<TTree*
>(file->Get(
"idToGeo"));
56 throw std::runtime_error(
"ERROR: cannot find detector id map in the file. Initialization failed.");
64 Float_t translation[3];
66 bool loadPoints = tree->GetBranch(
"points") !=
nullptr;
67 bool loadParameters = tree->GetBranch(
"topology") !=
nullptr;
68 bool loadShape = tree->GetBranch(
"shape") !=
nullptr;
69 bool loadTranslation = tree->GetBranch(
"translation") !=
nullptr;
70 bool loadMatrix = tree->GetBranch(
"matrix") !=
nullptr;
71 tree->SetBranchAddress(
"id", &
id);
73 tree->SetBranchAddress(
"points", &points);
75 tree->SetBranchAddress(
"topology", &topology);
77 tree->SetBranchAddress(
"shape", &shape);
79 tree->SetBranchAddress(
"translation", &translation);
81 tree->SetBranchAddress(
"matrix", &matrix);
83 unsigned int treeSize = tree->GetEntries();
86 for (
unsigned int i = 0;
i < treeSize; ++
i) {
91 for (
unsigned int j = 0;
j < 24; ++
j)
95 for (
unsigned int j = 0;
j < 9; ++
j)
99 for (
unsigned int j = 0;
j < 5; ++
j)
102 if (loadTranslation) {
103 for (
unsigned int j = 0;
j < 3; ++
j)
107 for (
unsigned int j = 0;
j < 9; ++
j)
116 TString
path = file->GetPath();
117 if (path.EndsWith(
":/"))
118 path.Resize(path.Length() - 2);
126 TNamed* producerInfo =
static_cast<TNamed*
>(file->Get(
"PRODUCER_VERSION"));
131 TNamed* ttopology =
static_cast<TNamed*
>(file->Get(
"TrackerTopology"));
144 unsigned int mapSize = map.size();
150 for (
unsigned int j = 0;
j < 24; ++
j)
152 for (
unsigned int j = 0;
j < 9; ++
j)
154 for (
unsigned int j = 0;
j < 5; ++
j)
156 for (
unsigned int j = 0;
j < 3; ++
j)
158 for (
unsigned int j = 0;
j < 9; ++
j)
164 std::map<unsigned int, TGeoMatrix*>::iterator mit =
m_idToMatrix.find(
id);
185 rotation.SetMatrix(matrix);
193 std::vector<unsigned int>
ids;
194 unsigned int mask = (det << 4) | (subdet);
197 ids.push_back((*it).id);
204 std::vector<unsigned int>
ids;
216 for (
const auto& id_it : ids) {
217 flag = (~0x3FF & it.id) == (~0x3FF & id_it);
226 ids.push_back(it.id);
242 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
243 TGeoShape* geoShape =
nullptr;
244 if (info.
shape[0] == 1) {
245 geoShape =
new TGeoTrap(info.
shape[3],
285 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
286 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
287 TGeoShape* geoShape =
getShape(info);
288 shape->SetShape(geoShape);
290 shape->SetTransMatrix(array);
297 const unsigned int type = (
id>>26)&0x3;
300 id |= (type == 0) ? 0x16B : 0xE7;
302 float sideToSideWaferSize = 16.7441f;
303 float dx = sideToSideWaferSize / 2;
304 float sidey = dx /
sqrt(3);
305 float dy = 2 * sidey;
307 int waferUint = (
id >> 10) & 0xF;
308 int waferVint = (
id >> 15) & 0xF;
309 float waferU = ((
id >> 14) & 0
x1) ? -sideToSideWaferSize * waferUint : sideToSideWaferSize * waferUint;
310 float waferV = ((
id >> 19) & 0
x1) ? -sideToSideWaferSize * waferVint : sideToSideWaferSize * waferVint;
312 float waferX = (-2 * waferU + waferV) / 2;
313 float waferY = waferV *
sqrt(3) / 2;
323 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
324 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
332 TGeoXtru* geoShape =
new TGeoXtru(2);
333 Double_t
x[6] = {-
dx, -
dx, 0.0,
dx,
dx, 0.0};
334 Double_t
y[6] = {-sidey, sidey,
dy, sidey, -sidey, -dy};
335 geoShape->DefinePolygon(6, x, y);
336 geoShape->DefineSection(0, -dz);
337 geoShape->DefineSection(1, dz);
339 shape->SetShape(geoShape);
357 shape->SetTransMatrix(array);
370 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
371 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
373 TGeoXtru* geoShape =
new TGeoXtru(2);
377 bool isNeg = info.
shape[3] < 0;
378 geoShape->DefinePolygon(4, x, y);
379 geoShape->DefineSection(0, isNeg * info.
shape[3]);
380 geoShape->DefineSection(1, !isNeg * info.
shape[3]);
383 shape->SetShape(geoShape);
401 shape->SetTransMatrix(array);
423 return (*it).parameters;
448 unsigned int id,
const float* local1,
float* global1,
const float* local2,
float* global2,
bool translatep)
const {
461 return std::lower_bound(begin, end,
id);
465 for (
int i = 0;
i < 3; ++
i) {
467 global[
i] += local[0] * info.
matrix[3 *
i] + local[1] * info.
matrix[3 *
i + 1] + local[2] * info.
matrix[3 *
i + 2];
474 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