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)_");
67 TString
test = globalTag.c_str();
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";
97 fwLog(
fwlog::kInfo) <<
"Guessed geometry " << cfn <<
" from global tag " << globalTag << std::endl;
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);
129 tree->SetBranchAddress(
"points", &points);
131 tree->SetBranchAddress(
"topology", &topology);
133 tree->SetBranchAddress(
"shape", &shape);
135 tree->SetBranchAddress(
"translation", &translation);
137 tree->SetBranchAddress(
"matrix", &matrix);
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)
178 TString
path = file->GetPath();
179 if (path.EndsWith(
":/"))
180 path.Resize(path.Length() - 2);
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);
247 rotation.SetMatrix(matrix);
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],
341 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
342 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
343 TGeoShape* geoShape =
getShape(info);
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) & 0x1) ? -sideToSideWaferSize * waferUint : sideToSideWaferSize * waferUint;
366 float waferV = ((
id >> 19) & 0x1) ? -sideToSideWaferSize * waferVint : sideToSideWaferSize * waferVint;
368 float waferX = (-2 * waferU +
waferV) / 2;
369 float waferY = waferV *
sqrt(3) / 2;
379 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
380 TEveGeoShape* shape =
new TEveGeoShape(TString::Format(
"RecoGeom Id=%u",
id));
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);
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]);
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) {
523 global[
i] += local[0] * info.
matrix[3 *
i] + local[1] * info.
matrix[3 *
i + 1] + local[2] * info.
matrix[3 *
i + 2];
std::unique_ptr< TrackerTopology > m_trackerTopology
static TFile * findFile(const char *fileName)
std::vector< FWRecoGeom::Info >::const_iterator InfoMapItr
TObjArray * extraDetectors
uint16_t *__restrict__ id
TEveGeoShape * getHGCSiliconEveShape(unsigned int id) const
void initMap(const FWRecoGeom::InfoMap &map)
int32_t waferU(const int32_t index)
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
tuple key
prepare the HTCondor submission files and eventually submit them
std::vector< FWRecoGeom::Info > InfoMap
for(Iditer=Id.begin();Iditer!=Id.end();Iditer++)
const float * getCorners(unsigned int id) const
std::vector< unsigned int > getMatchedIds(Detector det, SubDetector subdet) const
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
int32_t waferV(const int32_t index)
TrackerTopology fromTrackerParametersXMLString(const std::string &xmlContent)
void applyGlobalTag(const std::string >)
static const int kDetOffset
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
TEveGeoShape * getHGCScintillatorEveShape(unsigned int id) const