15#include <TGeoManager.h>
22std::unique_ptr<o2::iotof::GeometryTGeo> GeometryTGeo::sInstance;
54 LOGP(fatal,
"Invalid use of public constructor: o2::iotof::GeometryTGeo instance exists");
63 int numberOfStaves{0};
66 TGeoVolume* layV = gGeoManager->GetVolume(layName.c_str());
67 if (layV ==
nullptr) {
68 LOG(fatal) <<
"Can't find volume " << layName;
72 TObjArray*
nodes = layV->GetNodes();
73 int nNodes =
nodes->GetEntriesFast();
75 for (
int j{0};
j < nNodes; ++
j) {
81 return numberOfStaves;
86 int numberOfModules{0};
89 TGeoVolume* staveV = gGeoManager->GetVolume(staveName.c_str());
90 if (staveV ==
nullptr) {
91 LOG(fatal) <<
"Can't find volume " << staveName;
95 TObjArray*
nodes = staveV->GetNodes();
96 int nNodes =
nodes->GetEntriesFast();
98 for (
int j{0};
j < nNodes; ++
j) {
104 return numberOfModules;
109 int numberOfChips{0};
112 TGeoVolume* moduleV = gGeoManager->GetVolume(moduleName.c_str());
113 if (moduleV ==
nullptr) {
114 LOG(fatal) <<
"Can't find volume " << moduleName;
118 TObjArray*
nodes = moduleV->GetNodes();
119 int nNodes =
nodes->GetEntriesFast();
121 for (
int j{0};
j < nNodes; ++
j) {
127 return numberOfChips;
148 LOG(fatal) <<
"Invalid chip index " <<
index;
172 if (iotofLayer == 0) {
182 loc.SetCoordinates(0.5f * ((specs.ActiveMatrixSizeRows() - specs.PassiveEdgeTop + specs.PassiveEdgeReadOut) - specs.PitchRow) -
row * specs.PitchRow,
184 col * specs.PitchCol + 0.5f * (specs.PitchCol - specs.ActiveMatrixSizeCols()));
190 int lay, sta, mod, chip;
229 static TGeoHMatrix matTmp;
230 gGeoManager->PushPath();
232 if (!gGeoManager->cd(
path.Data())) {
233 gGeoManager->PopPath();
234 LOG(error) <<
"Error in cd-ing to " <<
path.Data();
238 matTmp = *gGeoManager->GetCurrentMatrix();
242 gGeoManager->PopPath();
253 LOGP(warning,
"Already built");
258 LOGP(fatal,
"Geometry is not loaded");
262 if (!iotofPars.segmentedInnerTOF && !iotofPars.segmentedOuterTOF) {
267 for (
int j{0};
j < 2; ++
j) {
279 int numberOfChips{0};
280 for (
int j{0};
j < 2; ++
j) {
309 size_t newSize =
sensors.size();
312 for (
int i = 0;
i < newSize;
i++) {
322 LOG(warning) <<
"The method Build was not called yet";
331 LOG(info) <<
"Loading " <<
getName() <<
" L2G matrices from TGeo; there are " <<
mSize <<
" matrices";
333 cacheL2G.setSize(
mSize);
343 LOGP(info,
"Loading {} T2L matrices from TGeo for IOTOF",
getName());
347 cacheT2L.setSize(m_Size);
348 for (
int i = 0;
i < m_Size;
i++) {
351 cacheT2L.setMatrix(
Mat3D(hm),
i);
359 double locA[3] = {-100., 0., 0.}, locB[3] = {100., 0., 0.}, gloA[3], gloB[3];
363 matL2G->LocalToMaster(locA, gloA);
364 matL2G->LocalToMaster(locB, gloB);
365 double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
366 double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
367 xp = gloB[0] - dx * t;
368 yp = gloB[1] - dy * t;
370 alp = std::atan2(yp, xp);
371 x = std::hypot(xp, yp);
372 o2::math_utils::bringTo02Pi(alp);
377 static TGeoHMatrix t2l;
380 t2l.RotateZ(
alpha * TMath::RadToDeg());
382 const TGeoHMatrix& matL2Gi = matL2G->Inverse();
383 t2l.MultiplyLeft(&matL2Gi);
390 sInstance = std::unique_ptr<GeometryTGeo>(
new GeometryTGeo(
true, 0));
392 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
static const char * getITOFChipPattern()
static std::string sFTOFSensorName
TString getMatrixPath(int index) const
static std::string sOTOFLayerName
static const char * getIOTOFVolPattern()
static const ChipSpecifics & getChipSpecifics(int iotofLayer)
static const char * getOTOFLayerPattern()
bool getIOTOFChipId(int index, int &lay, int &sta, int &mod, int &chip) const
int mNumberOfModulesIOTOF[2]
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 &)
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()
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
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 getIOTOFChipIndex(int lay, int sta, int mod, int chip) const
int extractNumberOfChipsBTOF() const
static std::string sBTOFLayerName
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"