3 #include "TEveGeoNode.h"
8 #include "TObjString.h"
38 if (gSystem->Getenv(
"CMSSW_SEARCH_PATH")) {
39 TString
paths = gSystem->Getenv(
"CMSSW_SEARCH_PATH");
41 TObjArray* tokens =
paths.Tokenize(
":");
42 for (
int i = 0;
i < tokens->GetEntries(); ++
i) {
43 TObjString*
path = (TObjString*)tokens->At(
i);
45 searchPath += static_cast<const char*>(
path->GetString());
46 if (gSystem->Getenv(
"CMSSW_VERSION"))
47 searchPath +=
"/Fireworks/Geometry/data/";
52 const char*
fp = gSystem->FindFile(searchPath.c_str(),
fn, kFileExists);
53 return fp ? TFile::Open(
fp) :
nullptr;
61 TPMERegexp year_re(
"^[^_]+_[a-zA-Z]*20(\\d\\d)_");
62 TPMERegexp run_re(
"^[^_]+_[a-zA-Z]*Run(\\d)_");
66 if (year_re.Match(
test)) {
67 TString
r = year_re[1];
68 int year = atoi(
r.Data());
71 }
else if (year < 21) {
76 }
else if (run_re.Match(
test)) {
77 TString rn = run_re[1];
81 }
else if (rn ==
"2") {
83 }
else if (rn ==
"4") {
90 fwLog(
fwlog::kWarning) <<
"Could not guess geometry from global tag. Using geometry scenario 2021.\n";
103 throw std::runtime_error(
"ERROR: failed to find geometry file. Initialization failed.");
107 TTree*
tree = static_cast<TTree*>(
file->Get(
"idToGeo"));
109 throw std::runtime_error(
"ERROR: cannot find detector id map in the file. Initialization failed.");
117 Float_t translation[3];
119 bool loadPoints =
tree->GetBranch(
"points") !=
nullptr;
120 bool loadParameters =
tree->GetBranch(
"topology") !=
nullptr;
121 bool loadShape =
tree->GetBranch(
"shape") !=
nullptr;
122 bool loadTranslation =
tree->GetBranch(
"translation") !=
nullptr;
123 bool loadMatrix =
tree->GetBranch(
"matrix") !=
nullptr;
124 tree->SetBranchAddress(
"id", &
id);
130 tree->SetBranchAddress(
"shape", &shape);
132 tree->SetBranchAddress(
"translation", &translation);
142 unsigned int treeSize =
tree->GetEntries();
145 for (
unsigned int i = 0;
i < treeSize; ++
i) {
150 for (
unsigned int j = 0;
j < 24; ++
j)
153 if (loadParameters) {
154 for (
unsigned int j = 0;
j < 9; ++
j)
158 for (
unsigned int j = 0;
j < 5; ++
j)
161 if (loadTranslation) {
162 for (
unsigned int j = 0;
j < 3; ++
j)
166 for (
unsigned int j = 0;
j < 9; ++
j)
176 if (
path.EndsWith(
":/"))
185 TNamed* producerInfo = static_cast<TNamed*>(
file->Get(
"PRODUCER_VERSION"));
190 TNamed* ttopology = static_cast<TNamed*>(
file->Get(
"TrackerTopology"));
203 unsigned int mapSize =
map.size();
209 for (
unsigned int j = 0;
j < 24; ++
j)
211 for (
unsigned int j = 0;
j < 9; ++
j)
213 for (
unsigned int j = 0;
j < 5; ++
j)
215 for (
unsigned int j = 0;
j < 3; ++
j)
217 for (
unsigned int j = 0;
j < 9; ++
j)
223 std::map<unsigned int, TGeoMatrix*>::iterator mit =
m_idToMatrix.find(
id);
233 TGeoTranslation trans(
info.translation[0],
info.translation[1],
info.translation[2]);
252 std::vector<unsigned int> ids;
253 unsigned int mask = (det << 4) | (subdet);
256 ids.push_back((*it).id);
263 std::vector<unsigned int> ids;
275 for (
const auto& id_it : ids) {
276 flag = (~0x3FF & it.id) == (~0x3FF & id_it);
285 ids.push_back(it.id);
301 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
302 TGeoShape* geoShape =
nullptr;
303 if (
info.shape[0] == 1) {
304 geoShape =
new TGeoTrap(
info.shape[3],
316 geoShape =
new TGeoBBox(
info.shape[1],
info.shape[2],
info.shape[3]);
344 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
345 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
347 shape->SetShape(geoShape);
349 shape->SetTransMatrix(
array);
356 const unsigned int type = (
id>>26)&0x3;
359 id |= (
type == 0) ? 0x16B : 0xE7;
361 float sideToSideWaferSize = 16.7441f;
362 float dx = sideToSideWaferSize / 2;
363 float sidey =
dx /
sqrt(3);
364 float dy = 2 * sidey;
366 int waferUint = (
id >> 10) & 0xF;
367 int waferVint = (
id >> 15) & 0xF;
368 float waferU = ((
id >> 14) & 0
x1) ? -sideToSideWaferSize * waferUint : sideToSideWaferSize * waferUint;
369 float waferV = ((
id >> 19) & 0
x1) ? -sideToSideWaferSize * waferVint : sideToSideWaferSize * waferVint;
371 float waferX = (-2 * waferU + waferV) / 2;
372 float waferY = waferV *
sqrt(3) / 2;
382 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
383 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
385 float dz = fabs(
info.points[14] -
info.points[2]) * 0.5;
387 info.translation[2] = (
info.points[14] +
info.points[2]) / 2.0
f;
388 info.translation[0] = waferX * ((0 <
info.translation[2]) - (
info.translation[2] < 0));
389 info.translation[1] = waferY;
391 TGeoXtru* geoShape =
new TGeoXtru(2);
392 Double_t
x[6] = {-
dx, -
dx, 0.0,
dx,
dx, 0.0};
393 Double_t
y[6] = {-sidey, sidey,
dy, sidey, -sidey, -
dy};
394 geoShape->DefinePolygon(6,
x,
y);
395 geoShape->DefineSection(0, -
dz);
396 geoShape->DefineSection(1,
dz);
398 shape->SetShape(geoShape);
416 shape->SetTransMatrix(
array);
429 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
430 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
432 TGeoXtru* geoShape =
new TGeoXtru(2);
433 Double_t
x[4] = {
info.points[0],
info.points[3],
info.points[6],
info.points[9]};
434 Double_t
y[4] = {
info.points[1],
info.points[4],
info.points[7],
info.points[10]};
436 bool isNeg =
info.shape[3] < 0;
437 geoShape->DefinePolygon(4,
x,
y);
438 geoShape->DefineSection(0, isNeg *
info.shape[3]);
439 geoShape->DefineSection(1, !isNeg *
info.shape[3]);
440 info.translation[2] =
info.points[2];
442 shape->SetShape(geoShape);
460 shape->SetTransMatrix(
array);
482 return (*it).parameters;
507 unsigned int id,
const float* local1,
float* global1,
const float* local2,
float* global2,
bool translatep)
const {
524 for (
int i = 0;
i < 3; ++
i) {
525 global[
i] = translatep ?
info.translation[
i] : 0;