13#include <TGeoManager.h>
22std::unique_ptr<o2::trk::GeometryTGeo> GeometryTGeo::sInstance;
47 LOGP(fatal,
"Invalid use of public constructor: o2::trk::GeometryTGeo instance exists");
64 LOGP(warning,
"Already built");
68 if (gGeoManager ==
nullptr) {
69 LOGP(fatal,
"Geometry is not loaded");
89 std::cout <<
"Layer MLOT: " <<
i << std::endl;
94 int numberOfChipsTotal = 0;
157 }
else if (subDetID == 1) {
174 }
else if (subDetID == 1) {
192 }
else if (subDetID == 1) {
225 }
else if (subDetID == 1) {
241 }
else if (subDetID == 1) {
268 int subDetID, petalcase, disk,
layer, stave, halfstave;
281 }
else if (
layer >= 0) {
287 }
else if (subDetID == 1) {
311 static TGeoHMatrix matTmp;
312 gGeoManager->PushPath();
314 if (!gGeoManager->cd(
path.Data())) {
315 gGeoManager->PopPath();
316 LOG(error) <<
"Error in cd-ing to " <<
path.Data();
320 matTmp = *gGeoManager->GetCurrentMatrix();
325 gGeoManager->PopPath();
327 static int chipInGlo{0};
349 LOG(warning) <<
"The method Build was not called yet";
357 LOGP(info,
"Loading {} L2G matrices from TGeo; there are {} matrices",
getName(),
mSize);
359 cacheL2G.setSize(
mSize);
363 cacheL2G.setMatrix(
Mat3D(*hm),
i);
372#ifdef ENABLE_UPGRADES
398 if (!nms.BeginsWith(prefix)) {
401 nms.Remove(0, strlen(prefix));
402 if (!isdigit(nms.Data()[0])) {
411 int numberOfLayers = 0;
413 if (trkV ==
nullptr) {
419 TObjArray*
nodes = trkV->GetNodes();
421 int nNodes =
nodes->GetEntriesFast();
422 for (
int j = 0;
j < nNodes;
j++) {
424 auto nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
425 const char*
name = nd->GetName();
429 LOG(fatal) <<
"Failed to extract layer ID from the " <<
name;
435 LOG(fatal) <<
"Failed to extract wrapper ID from the " <<
name;
437 TObjArray* nodesW = nd->GetNodes();
438 int nNodesW = nodesW->GetEntriesFast();
440 for (
int jw = 0; jw < nNodesW; jw++) {
441 auto ndW =
dynamic_cast<TGeoNode*
>(nodesW->At(jw))->GetName();
444 LOGP(fatal,
"Failed to extract layer ID from wrapper volume '{}' from one of its nodes '{}'",
name, ndW);
452 return numberOfLayers;
458 int numberOfPetals = 0;
466 TObjArray*
nodes = trkV->GetNodes();
472 LOGP(info,
"Searching for petal assemblies in {} (pattern: {})",
475 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
476 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
477 const char*
name = nd->GetName();
481 LOGP(info,
"Found petal assembly: {}",
name);
484 TGeoVolume* petalVol = nd->GetVolume();
486 TObjArray* petalNodes = petalVol->GetNodes();
488 LOGP(
debug,
"Petal {} contains {} child nodes",
name, petalNodes->GetEntriesFast());
490 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
491 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
492 LOGP(
debug,
" Node {}: {}", k, petalNode->GetName());
495 LOGP(warning,
"Petal {} has no child nodes",
name);
498 LOGP(warning,
"Petal {} has no volume",
name);
503 if (numberOfPetals == 0) {
504 LOGP(warning,
"No petal assemblies found in geometry");
506 LOGP(info,
"Found {} petal assemblies", numberOfPetals);
509 return numberOfPetals;
516 int numberOfParts = 0;
524 TObjArray*
nodes = vdV->GetNodes();
530 bool petalFound =
false;
532 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
533 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
534 const char*
name = nd->GetName();
540 LOGP(info,
"Counting active parts in petal: {}",
name);
543 TGeoVolume* petalVol = nd->GetVolume();
545 LOGP(warning,
"Petal {} has no volume",
name);
549 TObjArray* petalNodes = petalVol->GetNodes();
551 LOGP(warning,
"Petal {} has no child nodes",
name);
555 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
556 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
557 const char* nodeName = petalNode->GetName();
562 LOGP(
debug,
"Found active part in {}: {}",
name, nodeName);
574 if (numberOfParts == 0) {
575 LOGP(warning,
"No active parts (layers/disks) found in petal");
581 LOGP(info,
"Total number of active parts: {} ({}*{})",
590 int numberOfDisks = 0;
598 TObjArray*
nodes = vdV->GetNodes();
604 bool petalFound =
false;
606 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
607 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
613 LOGP(info,
"Counting disks in petal: {}", nd->GetName());
616 TGeoVolume* petalVol = nd->GetVolume();
618 LOGP(warning,
"Petal {} has no volume", nd->GetName());
622 TObjArray* petalNodes = petalVol->GetNodes();
624 LOGP(warning,
"Petal {} has no child nodes", nd->GetName());
628 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
629 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
632 LOGP(info,
"Found disk in {} : {}", nd->GetName(), petalNode->GetName());
643 if (numberOfDisks == 0) {
644 LOGP(warning,
"No disks found in VD geometry");
647 return numberOfDisks;
654 int numberOfLayers = 0;
662 TObjArray*
nodes = vdV->GetNodes();
668 bool petalFound =
false;
670 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
671 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
677 LOGP(info,
"Counting layers in petal: {}", nd->GetName());
680 TGeoVolume* petalVol = nd->GetVolume();
682 LOGP(warning,
"Petal {} has no volume", nd->GetName());
686 TObjArray* petalNodes = petalVol->GetNodes();
688 LOGP(warning,
"Petal {} has no child nodes", nd->GetName());
692 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
693 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
696 LOGP(info,
"Found layer in {} : {}", nd->GetName(), petalNode->GetName());
707 if (numberOfLayers == 0) {
708 LOGP(warning,
"No layers found in VD geometry");
711 return numberOfLayers;
718 int numberOfChips = 0;
726 TObjArray*
nodes = vdV->GetNodes();
732 bool petalFound =
false;
734 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
735 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
736 const char*
name = nd->GetName();
742 LOGP(info,
"Counting chips in petal: {}",
name);
745 TGeoVolume* petalVol = nd->GetVolume();
747 LOGP(warning,
"Petal {} has no volume",
name);
751 TObjArray* petalNodes = petalVol->GetNodes();
753 LOGP(warning,
"Petal {} has no child nodes",
name);
757 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
758 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
759 const char* nodeName = petalNode->GetName();
760 TGeoVolume* vol = petalNode->GetVolume();
763 LOGP(
debug,
"Node {} has no volume", nodeName);
768 TObjArray* subNodes = vol->GetNodes();
770 LOGP(
debug,
"Node {} has no sub-nodes", nodeName);
774 for (
int i = 0;
i < subNodes->GetEntriesFast();
i++) {
775 auto* subNode =
dynamic_cast<TGeoNode*
>(subNodes->At(
i));
778 LOGP(
debug,
"Found sensor in {}: {}", nodeName, subNode->GetName());
790 if (numberOfChips == 0) {
791 LOGP(warning,
"No chips/sensors found in VD petal");
794 LOGP(info,
"Number of chips per petal: {}", numberOfChips);
795 return numberOfChips;
801 int numberOfStaves = 0;
804 TGeoVolume* layV = gGeoManager->GetVolume(layName.c_str());
806 if (layV ==
nullptr) {
811 TObjArray*
nodes = layV->GetNodes();
814 int nNodes =
nodes->GetEntriesFast();
816 for (
int j = 0;
j < nNodes;
j++) {
818 auto nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
819 const char*
name = nd->GetName();
824 return numberOfStaves;
830 int numberOfHalfStaves = 0;
833 TGeoVolume* staveV = gGeoManager->GetVolume(staveName.c_str());
835 if (staveV ==
nullptr) {
840 TObjArray*
nodes = staveV->GetNodes();
843 int nNodes =
nodes->GetEntriesFast();
845 for (
int j = 0;
j < nNodes;
j++) {
846 auto nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
847 const char*
name = nd->GetName();
849 numberOfHalfStaves++;
852 return numberOfHalfStaves;
858 std::cout <<
"\nindex = " <<
index << std::endl;
859 std::cout <<
"subDetID = " << subDetID << std::endl;
860 std::cout <<
"petalcase = " << petalcase << std::endl;
861 std::cout <<
"layer = " << lay << std::endl;
862 std::cout <<
"disk = " << disk << std::endl;
863 std::cout <<
"first chip index = " <<
getFirstChipIndex(lay, petalcase, subDetID) << std::endl;
864 std::cout <<
"stave = " << stave << std::endl;
865 std::cout <<
"halfstave = " << halfstave << std::endl;
872 LOGF(info,
"Geometry not built yet!");
875 std::cout <<
"Detector ID: " << sInstance.get()->getDetID() << std::endl;
877 LOGF(info,
"Summary of GeometryTGeo: %s",
getName());
883 LOGF(info,
"Number of chips per petal VD: ");
887 LOGF(info,
"Number of staves and half staves per layer MLOT: ");
889 std::string mlot =
"";
890 mlot = (
i < 4) ?
"ML" :
"OT";
895 std::cout <<
"mLastChipIndex = [";
902 std::cout <<
"]" << std::endl;
903 std::cout <<
"mLastChipIndexVD = [";
910 std::cout <<
"]" << std::endl;
Definition of the SegmentationChipclass.
Static class with identifiers, bitmasks and names for ALICE detectors.
const char * getName() const
int mSize
prebooked number of sensors
const MatrixCache< Mat3D > & getCacheL2G() const
static const char * getTRKPetalDiskPattern()
static std::string sPetalAssemblyName
static const char * getTRKStavePattern()
int getPetalCase(int index) const
static const char * getTRKChipPattern()
std::vector< int > mNumberOfChipsPerLayerVD
number of chips per layer VD ( = number of petals)
static std::string sVolumeName
int getSubDetID(int index) const
std::array< char, MAXLAYERS > mLayerToWrapper
Layer to wrapper correspondence.
static std::string sPetalLayerName
static const char * getTRKSensorPattern()
static std::string sStaveName
std::vector< int > mNumberOfHalfStaves
Number Of Staves in each stave of the layer in ML/OT.
int extractNumberOfChipsPerPetalVD() const
int extractNumberOfHalfStavesMLOT(int lay) const
static const char * getTRKPetalLayerPattern()
int getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave) const
int extractNumberOfLayersMLOT()
Determines the number of active parts in the Geometry.
std::vector< int > mNumbersOfChipPerDiskVD
numbersOfChipPerDiskVD
std::vector< int > mNumberOfStaves
Number Of Staves per layer in ML/OT.
Int_t mNumberOfPetalsVD
number of Petals = chip in each VD layer
std::vector< int > mLastChipIndexVD
max ID of the detctor in the layer for the VD
static std::string sPetalName
int extractNumberOfStavesMLOT(int lay) const
static const char * composeSymNameChip(int d, int lr)
static std::string sPetalDiskName
void Print(Option_t *opt="") const
void PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int halfstave) const
int getLayer(int index) const
static const char * getTRKWrapVolPattern()
TString getMatrixPath(int index) const
static const char * getTRKPetalAssemblyPattern()
int getNumberOfChips() const
static const char * getTRKLayerPattern()
int getFirstChipIndex(int lay, int petalcase, int subDetID) const
o2::math_utils::Transform3D Mat3D
static std::string sWrapperVolumeName
Wrapper volume name.
int extractNumberOfLayersVD() const
std::vector< int > mNumberOfChipsPerPetalVD
numbersOfChipPerPetalVD
std::vector< int > mLastChipIndex
max ID of the detctor in the petal(VD) or layer(MLOT)
static std::string sChipName
static std::string sSensorName
bool getChipID(int index, int &subDetID, int &petalcase, int &disk, int &lay, int &stave, int &halfstave) const
std::vector< int > mLastChipIndexMLOT
max ID of the detctor in the layer for the MLOT
void fillMatrixCache(int mask)
static std::string sLayerName
int extractNumberOfActivePartsVD() const
static const char * composeSymNameSensor(int d, int layer)
int extractNumberOfDisksVD() const
static const char * getTRKPetalPattern()
Int_t mNumberOfActivePartsVD
number of layers
std::vector< int > mNumberOfChipsPerLayerMLOT
number of chips per layer MLOT ( = 1 for the moment)
Int_t mNumberOfDisksVD
number of Disks = 6
Int_t mNumberOfLayersMLOT
number of layers
static const char * composeSymNameLayer(int d, int layer)
int getStave(int index) const
static const char * getTRKVolPattern()
static const char * composeSymNameStave(int d, int layer)
int getDisk(int index) const
int extractNumberOfPetalsVD() const
int extractVolumeCopy(const char *name, const char *prefix) const
Extract number following the prefix in the name string.
void Build(int loadTrans)
Int_t mNumberOfLayersVD
number of layers
int getHalfStave(int index) const
GeometryTGeo(bool build=false, int loadTrans=0)
TGeoHMatrix * extractMatrixSensor(int index) const
GLuint const GLchar * name
GLsizei const GLchar *const * path
GLenum GLuint GLint GLint layer
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"