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;
267 std::set<unsigned int> cached_wafers;
274 auto key = ~0x3FF & it.id;
275 if (cached_wafers.find(
key) == cached_wafers.end()) {
276 cached_wafers.insert(
key);
277 ids.push_back(it.id);
282 ids.push_back(it.id);
298 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
299 TGeoShape* geoShape =
nullptr;
300 if (
info.shape[0] == 1) {
301 geoShape =
new TGeoTrap(
info.shape[3],
313 geoShape =
new TGeoBBox(
info.shape[1],
info.shape[2],
info.shape[3]);
341 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
342 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
344 shape->SetShape(geoShape);
346 shape->SetTransMatrix(
array);
353 const unsigned int type = (
id>>26)&0x3;
356 id |= (
type == 0) ? 0x16B : 0xE7;
358 float sideToSideWaferSize = 16.7441f;
359 float dx = sideToSideWaferSize / 2;
360 float sidey =
dx /
sqrt(3);
361 float dy = 2 * sidey;
363 int waferUint = (
id >> 10) & 0xF;
364 int waferVint = (
id >> 15) & 0xF;
365 float waferU = ((
id >> 14) & 0
x1) ? -sideToSideWaferSize * waferUint : sideToSideWaferSize * waferUint;
366 float waferV = ((
id >> 19) & 0
x1) ? -sideToSideWaferSize * waferVint : sideToSideWaferSize * waferVint;
379 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
380 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
382 float dz = fabs(
info.points[14] -
info.points[2]) * 0.5;
384 info.translation[2] = (
info.points[14] +
info.points[2]) / 2.0
f;
385 info.translation[0] = waferX * ((0 <
info.translation[2]) - (
info.translation[2] < 0));
386 info.translation[1] = waferY;
388 TGeoXtru* geoShape =
new TGeoXtru(2);
389 Double_t
x[6] = {-
dx, -
dx, 0.0,
dx,
dx, 0.0};
390 Double_t
y[6] = {-sidey, sidey,
dy, sidey, -sidey, -
dy};
391 geoShape->DefinePolygon(6,
x,
y);
392 geoShape->DefineSection(0, -
dz);
393 geoShape->DefineSection(1,
dz);
395 shape->SetShape(geoShape);
413 shape->SetTransMatrix(
array);
426 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
427 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
429 TGeoXtru* geoShape =
new TGeoXtru(2);
430 Double_t
x[4] = {
info.points[0],
info.points[3],
info.points[6],
info.points[9]};
431 Double_t
y[4] = {
info.points[1],
info.points[4],
info.points[7],
info.points[10]};
433 bool isNeg =
info.shape[3] < 0;
434 geoShape->DefinePolygon(4,
x,
y);
435 geoShape->DefineSection(0, isNeg *
info.shape[3]);
436 geoShape->DefineSection(1, !isNeg *
info.shape[3]);
437 info.translation[2] =
info.points[2];
439 shape->SetShape(geoShape);
457 shape->SetTransMatrix(
array);
479 return (*it).parameters;
504 unsigned int id,
const float* local1,
float* global1,
const float* local2,
float* global2,
bool translatep)
const {
521 for (
int i = 0;
i < 3; ++
i) {
522 global[
i] = translatep ?
info.translation[
i] : 0;
std::unique_ptr< TrackerTopology > m_trackerTopology
static TFile * findFile(const char *fileName)
std::vector< FWRecoGeom::Info >::const_iterator InfoMapItr
TObjArray * extraDetectors
void initMap(const FWRecoGeom::InfoMap &map)
std::vector< unsigned int > getMatchedIds(Detector det, SubDetector subdet) const
int32_t waferU(const int32_t index)
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
bool haveExtraDet(const char *) const
std::map< unsigned int, TGeoMatrix * > m_idToMatrix
IdToInfoItr find(unsigned int) const
TEveGeoShape * getHGCScintillatorEveShape(unsigned int id) const
VersionInfo m_versionInfo
const float * getCorners(unsigned int id) const
TEveGeoShape * getHGCSiliconEveShape(unsigned int id) const
void loadMap(const char *fileName)
std::vector< FWRecoGeom::Info > InfoMap
TEveGeoShape * getEveShape(unsigned int id) const
TGeoShape * getShape(unsigned int id) const
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
const float * getShapePars(unsigned int id) const
const float * getParameters(unsigned int id) const
const TGeoMatrix * getMatrix(unsigned int id) const
int32_t waferV(const int32_t index)
TrackerTopology fromTrackerParametersXMLString(const std::string &xmlContent)
void applyGlobalTag(const std::string >)
static const int kDetOffset
bool match_id(const GeomDetInfo &o, unsigned int mask) const
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr