19#include "MFTBase/GeometryTGeo.h"
24#include <fairlogger/Logger.h>
28#include <TGeoManager.h>
29#include <TGeoMatrix.h>
31#include <TGeoPhysicalNode.h>
33#include <TGeoVolume.h>
52std::unique_ptr<o2::mft::GeometryTGeo> GeometryTGeo::sInstance;
63 LOGP(info,
"~GeometryTGeo");
76 LOG(fatal) <<
"Invalid use of public constructor: o2::mft::GeometryTGeo instance exists";
91 LOG(fatal) <<
"No adoption: o2::mft::GeometryTGeo instance exists";
93 sInstance = std::unique_ptr<o2::mft::GeometryTGeo>(raw);
94 sInstance->mOwner = canDelete;
101 LOG(warning) <<
"Already built";
107 LOG(fatal) <<
"Geometry is not loaded";
135 Int_t numberOfLadders = 0;
179 Double_t* trans = hm->GetTranslation();
181 zLay1[disk] = std::min(zLay1[disk], trans[2]);
182 zLay0[disk] = std::max(zLay0[disk], trans[2]);
190 Double_t* trans = hm->GetTranslation();
237 Int_t numberOfSensors = 0;
238 Char_t laddername[30];
240 TGeoVolume* volLadder = gGeoManager->GetVolume(laddername);
242 LOG(fatal) <<
"can't find volume " << laddername;
245 Int_t nNodes = volLadder->GetNodes()->GetEntries();
246 for (
int j = 0;
j < nNodes;
j++) {
254 return numberOfSensors;
260 Int_t numberOfLadders = 0;
263 TGeoVolume* volDisk = gGeoManager->GetVolume(diskname);
265 LOG(fatal) <<
"can't find volume " << diskname;
268 TObjArray*
nodes = volDisk->GetNodes();
269 Int_t nNodes =
nodes->GetEntries();
271 for (
int j = 0;
j < nNodes;
j++) {
272 TGeoNode* nd = (TGeoNode*)
nodes->At(
j);
273 const Char_t*
name = nd->GetName();
282 return numberOfLadders;
288 Int_t numberOfLadders = 0;
291 TGeoVolume* volDisk = gGeoManager->GetVolume(diskname);
293 LOG(fatal) <<
"can't find volume " << diskname;
296 TObjArray*
nodes = volDisk->GetNodes();
297 Int_t nNodes =
nodes->GetEntries();
299 for (
int j = 0;
j < nNodes;
j++) {
300 TGeoNode* nd = (TGeoNode*)
nodes->At(
j);
301 const Char_t*
name = nd->GetName();
317 return numberOfLadders;
323 Int_t numberOfDisks = 0;
326 TGeoVolume* volHalf = gGeoManager->GetVolume(halfname);
328 LOG(fatal) <<
"can't find " << halfname <<
" volume";
333 Int_t nNodes = volHalf->GetNodes()->GetEntries();
334 for (Int_t
j = 0;
j < nNodes;
j++) {
340 return numberOfDisks;
346 Int_t numberOfHalves = 0;
354 TObjArray*
nodes = volMFT->GetNodes();
355 int nNodes =
nodes->GetEntriesFast();
357 for (
int j = 0;
j < nNodes;
j++) {
359 TGeoNode* nd = (TGeoNode*)
nodes->At(
j);
360 const Char_t*
name = nd->GetName();
365 LOG(fatal) <<
"Failed to extract half ID from the " <<
name;
371 return numberOfHalves;
378 if (!nms.BeginsWith(prefix)) {
381 nms.Remove(0, strlen(prefix) + 1);
382 if (!isdigit(nms.Data()[0])) {
392 Int_t half, disk, ladder, sensor, ladderID;
399 path += Form(
"%s_%d_%d/%s_%d_%d_%d/%s_%d_%d_%d_%d/%s_%d_%d_%d_%d/%s_1",
getMFTHalfPattern(), half, half,
404 static TGeoHMatrix matTmp;
405 gGeoManager->PushPath();
407 if (!gGeoManager->cd(
path.Data())) {
408 gGeoManager->PopPath();
409 LOG(error) <<
"Error in cd-ing to " <<
path.Data();
413 matTmp = *gGeoManager->GetCurrentMatrix();
416 gGeoManager->PopPath();
432 LOG(warning) <<
"The method Build was not called yet";
440 LOG(info) <<
"Loading MFT L2G matrices from TGeo";
442 cacheL2G.setSize(
mSize);
451 LOG(info) <<
"Loading MFT T2L matrices from TGeo";
453 cacheT2L.setSize(
mSize);
456 cacheT2L.setMatrix(
Mat3D(hm),
i);
462 LOG(info) <<
"Loading MFT T2G matrices from TGeo";
464 cacheT2G.setSize(
mSize);
468 cacheT2G.setMatrix(
Mat3D(mat),
i);
479 LOG(fatal) <<
"Matrices must be filled beforehand.";
485 cacheL2G.setSize(
mSize);
486 auto setMatrix = [
this](
auto chipID,
auto& cacheL2G) {
488 cacheL2G.setMatrix(hm ?
Mat3D(*hm) :
Mat3D(), chipID);
491 if (chipIDs.size()) {
492 for (
auto&
i : chipIDs) {
493 setMatrix(
i, cacheL2G);
497 setMatrix(
i, cacheL2G);
506 static TGeoHMatrix t2l;
537 Int_t nFirstSensorIndex = 0, nFirstSensorIndexSave = 0;
541 nFirstSensorIndexSave = nFirstSensorIndex;
544 index -= nFirstSensorIndexSave;
545 ladder +=
index / nSensor;
546 sensor =
index % nSensor;
583 Int_t ladder = 0, nFirstSensorIndex = 0, nFirstSensorIndexSave = 0;
586 nFirstSensorIndexSave = nFirstSensorIndex;
589 index -= nFirstSensorIndexSave;
590 ladder +=
index / nSensor;
609 index += ladder * nS;
Definition of the GeometryManager class.
Class handling both virtual segmentation and real volumes.
ClassImp(o2::mft::GeometryTGeo)
Definition of the SegmentationAlpide class.
Static class with identifiers, bitmasks and names for ALICE detectors.
const MatrixCache< Mat3D > & getCacheT2L() const
const MatrixCache< Mat3D > & getCacheT2G() const
int mSize
prebooked number of sensors
const MatrixCache< Mat3D > & getCacheL2G() const
static constexpr float SensorLayerThickness
static constexpr float SensorLayerThicknessEff
static const char * composeSymNameHalf(int hf)
sym name of the half
static std::string sLadderName
static constexpr Int_t MaxSensorsPerLadder
static std::string sDiskName
Int_t getFirstSensorIndex(Int_t disk) const
In a disk start numbering the sensors from zero.
static const Char_t * getMFTSensorPattern()
static const Char_t * getMFTHalfPattern()
Int_t getHalf(Int_t index) const
From matrix index to half ID.
std::vector< std::vector< Int_t > > mLadderId2Index
from to geometry index to matrix index
o2::math_utils::Transform3D Mat3D
static const char * composeSymNameChip(int hf, int dk, int lr, int chip)
Sym name of the chip in the given half/disk/ladder.
std::vector< std::vector< Int_t > > mLadderIndex2Id
from matrix index to geometry index
std::vector< Int_t > mNumberOfDisks
disks/half
static constexpr Int_t MinSensorsPerLadder
void fillMatrixCache(Int_t mask) override
Int_t getDisk(Int_t index) const
From matrix index to disk ID.
std::vector< Int_t > mLastSensorIndex
last sensor index in a layer
static const Char_t * getMFTChipPattern()
void Build(int loadTrans=0) override
Exract MFT parameters from TGeo.
void updateL2GMatrixCache(std::vector< int > chipIDs={})
std::vector< Int_t > mNumberOfSensorsPerDisk
get from sensor index the lay er
Int_t extractNumberOfDisks(Int_t half) const
Determines the number of disks in each detector half.
Int_t extractNumberOfLadders(Int_t half, Int_t disk, Int_t nsensors) const
Determines the number of ladders in each disk of each half.
std::vector< Int_t > mSensorIndexToLayer
get from sensor index the layer
static std::string sHalfName
Int_t mTotalNumberOfSensors
total number of sensors in the detector
static const char * composeSymNameLadder(int hf, int dk, int lr)
Sym name of the ladder at given half/disk.
Int_t getSensorIndex(Int_t half, Int_t disk, Int_t ladder, Int_t sensor) const
static const Char_t * getMFTLadderPattern()
std::vector< Float_t > mLayerMedianZ
z median value between the two planes of a disk
Int_t extractNumberOfHalves()
Determines the number of detector halves in the Geometry.
Int_t getLadder(Int_t index) const
From matrix index to ladder ID (matrix)
static const Char_t * getMFTVolPattern()
std::vector< std::vector< Int_t > > mNumberOfLadders
ladders[nsensor]/halfdisk
Int_t extractNumberOfSensorsPerLadder(Int_t half, Int_t disk, Int_t ladder) const
Determines the number of sensors in each ladder of each disk of each half.
std::vector< Int_t > mNumberOfLaddersPerDisk
ladders/halfdisk
Int_t getLayer(Int_t index) const
get layer index (0:9) from the chip index
TGeoHMatrix * extractMatrixSensor(Int_t index) const
static void adopt(GeometryTGeo *raw, bool canDelete=false)
Bool_t getSensorID(Int_t index, Int_t &half, Int_t &disk, Int_t &ladder, Int_t &sensor) const
~GeometryTGeo() override
Default destructor, don't use.
void extractSensorXAlpha(int index, float &x, float &alp)
TGeoHMatrix & createT2LMatrix(Int_t isn)
static const Char_t * getMFTDiskPattern()
static std::string sSensorName
Int_t extractVolumeCopy(const Char_t *name, const Char_t *prefix) const
Extract number following the prefix in the name string.
static std::string sChipName
static const char * composeSymNameMFT()
sym name of the MFT
static std::string sVolumeName
static const char * composeSymNameDisk(int hf, int dk)
Sym name of the disk at given half.
Int_t mNumberOfHalves
number of detector halves
GLfloat GLfloat GLfloat alpha
GLuint const GLchar * name
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"