15#include <TGeoManager.h>
22std::unique_ptr<o2::iotof::GeometryTGeo> GeometryTGeo::sInstance;
55 LOGP(fatal,
"Invalid use of public constructor: o2::iotof::GeometryTGeo instance exists");
64 int numberOfStaves{0};
67 TGeoVolume* layV = gGeoManager->GetVolume(layName.c_str());
68 if (layV ==
nullptr) {
69 LOG(fatal) <<
"Can't find volume " << layName;
73 TObjArray*
nodes = layV->GetNodes();
74 int nNodes =
nodes->GetEntriesFast();
76 for (
int j{0};
j < nNodes; ++
j) {
82 return numberOfStaves;
91 int numberOfSubStaves{0};
94 TGeoVolume* staveV = gGeoManager->GetVolume(staveName.c_str());
95 if (staveV ==
nullptr) {
96 LOG(fatal) <<
"Can't find volume " << staveName;
100 TObjArray*
nodes = staveV->GetNodes();
101 int nNodes =
nodes->GetEntriesFast();
103 for (
int j{0};
j < nNodes; ++
j) {
109 return numberOfSubStaves;
114 int numberOfModules{0};
117 TGeoVolume* staveV = gGeoManager->GetVolume(staveName.c_str());
118 if (staveV ==
nullptr) {
119 LOG(fatal) <<
"Can't find volume " << staveName;
123 TObjArray*
nodes = staveV->GetNodes();
124 int nNodes =
nodes->GetEntriesFast();
126 for (
int j{0};
j < nNodes; ++
j) {
132 return numberOfModules;
137 int numberOfChips{0};
140 TGeoVolume* moduleV = gGeoManager->GetVolume(moduleName.c_str());
141 if (moduleV ==
nullptr) {
142 LOG(fatal) <<
"Can't find volume " << moduleName;
146 TObjArray*
nodes = moduleV->GetNodes();
147 int nNodes =
nodes->GetEntriesFast();
149 for (
int j{0};
j < nNodes; ++
j) {
155 return numberOfChips;
176 LOG(fatal) <<
"Invalid chip index " <<
index;
204 loc.SetCoordinates(0.5f * ((specs.ActiveMatrixSizeRows() - specs.PassiveEdgeTop + specs.PassiveEdgeReadOut) - specs.PitchRow) -
row * specs.PitchRow,
206 col * specs.PitchCol + 0.5f * (specs.PitchCol - specs.ActiveMatrixSizeCols()));
212 int lay, sta, substa, mod, chip;
255 static TGeoHMatrix matTmp;
256 gGeoManager->PushPath();
258 if (!gGeoManager->cd(
path.Data())) {
259 gGeoManager->PopPath();
260 LOG(error) <<
"Error in cd-ing to " <<
path.Data();
264 matTmp = *gGeoManager->GetCurrentMatrix();
268 gGeoManager->PopPath();
279 LOGP(warning,
"Already built");
284 LOGP(fatal,
"Geometry is not loaded");
288 if (!iotofPars.segmentedInnerTOF && !iotofPars.segmentedOuterTOF) {
293 for (
int j{0};
j < 2; ++
j) {
306 int numberOfChips{0};
307 for (
int j{0};
j < 2; ++
j) {
316 <<
mNumberOfChipsIOTOF[1] <<
", numberOfChips = " << numberOfChips <<
", mNumberOfChipsPerStaveITOF"
339 size_t newSize =
sensors.size();
342 for (
int i = 0;
i < newSize;
i++) {
352 LOG(warning) <<
"The method Build was not called yet";
361 LOG(info) <<
"Loading " <<
getName() <<
" L2G matrices from TGeo; there are " <<
mSize <<
" matrices";
363 cacheL2G.setSize(
mSize);
373 LOGP(info,
"Loading {} T2L matrices from TGeo for IOTOF",
getName());
377 cacheT2L.setSize(m_Size);
378 for (
int i = 0;
i < m_Size;
i++) {
381 cacheT2L.setMatrix(
Mat3D(hm),
i);
389 double locA[3] = {-100., 0., 0.}, locB[3] = {100., 0., 0.}, gloA[3], gloB[3];
393 matL2G->LocalToMaster(locA, gloA);
394 matL2G->LocalToMaster(locB, gloB);
395 double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
396 double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
397 xp = gloB[0] - dx * t;
398 yp = gloB[1] - dy * t;
400 alp = std::atan2(yp, xp);
401 x = std::hypot(xp, yp);
402 o2::math_utils::bringTo02Pi(alp);
407 static TGeoHMatrix t2l;
410 t2l.RotateZ(
alpha * TMath::RadToDeg());
412 const TGeoHMatrix& matL2Gi = matL2G->Inverse();
413 t2l.MultiplyLeft(&matL2Gi);
420 sInstance = std::unique_ptr<GeometryTGeo>(
new GeometryTGeo(
true, 0));
422 return sInstance.get();
General auxilliary methods.
static const IOTOFBaseParam & Instance()
const MatrixCache< Mat3D > & getCacheT2L() const
const char * getName() const
int mSize
prebooked number of sensors
o2::math_utils::Transform3D Mat3D
const MatrixCache< Mat3D > & getCacheL2G() const
int getIOTOFChipIndex(int lay, int sta, int substa, int mod, int chip) const
int extractNumberOfSubStavesIOTOF(int lay) const
static const char * getITOFChipPattern()
static std::string sFTOFSensorName
TString getMatrixPath(int index) const
static std::string sOTOFLayerName
static const char * getIOTOFVolPattern()
static const char * getOTOFLayerPattern()
int mNumberOfModulesIOTOF[2]
static const char * getOTOFSubStavePattern()
int mNumberOfChipsPerModuleIOTOF[2]
static const char * getOTOFModulePattern()
static std::string sOTOFSensorName
static std::string sIOTOFVolumeName
o2::math_utils::Point3D< float > detectorToLocal(int row, int col, int chipId) const
static const char * getITOFModulePattern()
void fillMatrixCache(int mask)
void extractSensorXAlpha(int, float &, float &)
static std::string sOTOFSubStaveName
bool isTrackingFrameCached() const
static const char * getOTOFSensorPattern()
static std::string sITOFStaveName
static std::string sFTOFChipName
int extractNumberOfModulesIOTOF(int lay) const
static std::string sOTOFChipName
void fillTrackingFramesCache()
int mNumberOfChipsPerSubStaveIOTOF[2]
static std::string sITOFModuleName
static const char * getITOFStavePattern()
static std::string sFTOFLayerName
int extractNumberOfChipsFTOF() const
static const char * getITOFSensorPattern()
static const char * getOTOFStavePattern()
int getIOTOFLayer(int index) const
int getIOTOFFirstChipIndex(int lay) const
int mNumberOfSubStavesIOTOF[2]
GeometryTGeo(bool build=false, int loadTrans=0)
static std::string sBTOFSensorName
static std::string sBTOFChipName
std::vector< float > mCacheRefAlpha
cache for X of IOTOF
static const char * getOTOFChipPattern()
static std::string sITOFChipName
int mNumberOfChipsPerStaveIOTOF[2]
int mNumberOfStavesIOTOF[2]
int extractNumberOfChipsPerModuleIOTOF(int lay) const
void Build(int loadTrans)
static std::string sOTOFModuleName
std::vector< float > mCacheRefX
int extractNumberOfStavesIOTOF(int lay) const
std::vector< int > sensors
TGeoHMatrix & createT2LMatrix(int)
static std::string sOTOFStaveName
static std::string sITOFSensorName
static GeometryTGeo * Instance()
static const char * getITOFLayerPattern()
TGeoHMatrix * extractMatrixSensor(int index) const
static std::string sITOFLayerName
int extractNumberOfChipsBTOF() const
static std::string sBTOFLayerName
bool getIOTOFChipId(int index, int &lay, int &sta, int &substa, int &mod, int &chip) const
int mNumberOfChipsIOTOF[2]
float getSensorRefAlpha(int chipId) const
GLfloat GLfloat GLfloat alpha
GLsizei const GLchar *const * path
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"