3 #include "TEveGeoNode.h"
4 #include "TEveGeoShape.h"
9 #include "TObjString.h"
41 if (gSystem->Getenv(
"CMSSW_SEARCH_PATH")) {
42 TString
paths = gSystem->Getenv(
"CMSSW_SEARCH_PATH");
44 TObjArray* tokens =
paths.Tokenize(
":");
45 for (
int i = 0;
i < tokens->GetEntries(); ++
i) {
46 TObjString*
path = (TObjString*)tokens->At(
i);
48 searchPath += static_cast<const char*>(
path->GetString());
49 if (gSystem->Getenv(
"CMSSW_VERSION"))
50 searchPath +=
"/Fireworks/Geometry/data/";
55 const char*
fp = gSystem->FindFile(searchPath.c_str(),
fn, kFileExists);
56 return fp ? TFile::Open(
fp) :
nullptr;
64 TPMERegexp year_re(
"^[^_]+_[a-zA-Z]*20(\\d\\d)_");
65 TPMERegexp run_re(
"^[^_]+_[a-zA-Z]*Run(\\d)_");
69 if (year_re.Match(
test)) {
70 TString
r = year_re[1];
71 int year = atoi(
r.Data());
74 }
else if (year < 21) {
79 }
else if (run_re.Match(
test)) {
80 TString rn = run_re[1];
84 }
else if (rn ==
"2") {
86 }
else if (rn ==
"4") {
93 fwLog(
fwlog::kWarning) <<
"Could not guess geometry from global tag. Using geometry scenario 2021.\n";
106 throw std::runtime_error(
"ERROR: failed to find geometry file. Initialization failed.");
110 TTree*
tree = static_cast<TTree*>(
file->Get(
"idToGeo"));
112 throw std::runtime_error(
"ERROR: cannot find detector id map in the file. Initialization failed.");
120 Float_t translation[3];
122 bool loadPoints =
tree->GetBranch(
"points") !=
nullptr;
123 bool loadParameters =
tree->GetBranch(
"topology") !=
nullptr;
124 bool loadShape =
tree->GetBranch(
"shape") !=
nullptr;
125 bool loadTranslation =
tree->GetBranch(
"translation") !=
nullptr;
126 bool loadMatrix =
tree->GetBranch(
"matrix") !=
nullptr;
127 tree->SetBranchAddress(
"id", &
id);
131 tree->SetBranchAddress(
"topology", &topology);
133 tree->SetBranchAddress(
"shape", &shape);
135 tree->SetBranchAddress(
"translation", &translation);
145 unsigned int treeSize =
tree->GetEntries();
148 for (
unsigned int i = 0;
i < treeSize; ++
i) {
153 for (
unsigned int j = 0;
j < 24; ++
j)
156 if (loadParameters) {
157 for (
unsigned int j = 0;
j < 9; ++
j)
161 for (
unsigned int j = 0;
j < 5; ++
j)
164 if (loadTranslation) {
165 for (
unsigned int j = 0;
j < 3; ++
j)
169 for (
unsigned int j = 0;
j < 9; ++
j)
179 if (
path.EndsWith(
":/"))
188 TNamed* producerInfo = static_cast<TNamed*>(
file->Get(
"PRODUCER_VERSION"));
193 TNamed* ttopology = static_cast<TNamed*>(
file->Get(
"TrackerTopology"));
206 unsigned int mapSize =
map.size();
212 for (
unsigned int j = 0;
j < 24; ++
j)
214 for (
unsigned int j = 0;
j < 9; ++
j)
216 for (
unsigned int j = 0;
j < 5; ++
j)
218 for (
unsigned int j = 0;
j < 3; ++
j)
220 for (
unsigned int j = 0;
j < 9; ++
j)
226 std::map<unsigned int, TGeoMatrix*>::iterator mit =
m_idToMatrix.find(
id);
236 TGeoTranslation trans(
info.translation[0],
info.translation[1],
info.translation[2]);
255 std::vector<unsigned int> ids;
256 unsigned int mask = (det << 4) | (subdet);
259 ids.push_back((*it).id);
266 std::vector<unsigned int> ids;
278 for (
const auto& id_it : ids) {
279 flag = (~0x3FF & it.id) == (~0x3FF & id_it);
288 ids.push_back(it.id);
304 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
305 TGeoShape* geoShape =
nullptr;
306 if (
info.shape[0] == 1) {
307 geoShape =
new TGeoTrap(
info.shape[3],
319 geoShape =
new TGeoBBox(
info.shape[1],
info.shape[2],
info.shape[3]);
347 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
348 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
350 shape->SetShape(geoShape);
352 shape->SetTransMatrix(
array);
359 const unsigned int type = (
id>>26)&0x3;
362 id |= (
type == 0) ? 0x16B : 0xE7;
364 float sideToSideWaferSize = 16.7441f;
365 float dx = sideToSideWaferSize / 2;
366 float sidey =
dx /
sqrt(3);
367 float dy = 2 * sidey;
369 int waferUint = (
id >> 10) & 0xF;
370 int waferVint = (
id >> 15) & 0xF;
371 float waferU = ((
id >> 14) & 0
x1) ? -sideToSideWaferSize * waferUint : sideToSideWaferSize * waferUint;
372 float waferV = ((
id >> 19) & 0
x1) ? -sideToSideWaferSize * waferVint : sideToSideWaferSize * waferVint;
385 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
386 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
388 float dz = fabs(
info.points[14] -
info.points[2]) * 0.5;
390 info.translation[2] = (
info.points[14] +
info.points[2]) / 2.0
f;
391 info.translation[0] = waferX * ((0 <
info.translation[2]) - (
info.translation[2] < 0));
392 info.translation[1] = waferY;
394 TGeoXtru* geoShape =
new TGeoXtru(2);
395 Double_t
x[6] = {-
dx, -
dx, 0.0,
dx,
dx, 0.0};
396 Double_t
y[6] = {-sidey, sidey,
dy, sidey, -sidey, -
dy};
397 geoShape->DefinePolygon(6,
x,
y);
398 geoShape->DefineSection(0, -
dz);
399 geoShape->DefineSection(1,
dz);
401 shape->SetShape(geoShape);
419 shape->SetTransMatrix(
array);
432 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
433 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
435 TGeoXtru* geoShape =
new TGeoXtru(2);
436 Double_t
x[4] = {
info.points[0],
info.points[3],
info.points[6],
info.points[9]};
437 Double_t
y[4] = {
info.points[1],
info.points[4],
info.points[7],
info.points[10]};
439 bool isNeg =
info.shape[3] < 0;
440 geoShape->DefinePolygon(4,
x,
y);
441 geoShape->DefineSection(0, isNeg *
info.shape[3]);
442 geoShape->DefineSection(1, !isNeg *
info.shape[3]);
443 info.translation[2] =
info.points[2];
445 shape->SetShape(geoShape);
463 shape->SetTransMatrix(
array);
485 return (*it).parameters;
510 unsigned int id,
const float* local1,
float* global1,
const float* local2,
float* global2,
bool translatep)
const {
527 for (
int i = 0;
i < 3; ++
i) {
528 global[
i] = translatep ?
info.translation[
i] : 0;