13#include <TGeoManager.h>
26std::unique_ptr<o2::trk::GeometryTGeo> GeometryTGeo::sInstance;
56 LOGP(fatal,
"Invalid use of public constructor: o2::trk::GeometryTGeo instance exists");
73 LOGP(warning,
"Already built");
77 if (gGeoManager ==
nullptr) {
78 LOGP(fatal,
"Geometry is not loaded");
122 int numberOfChipsTotal = 0;
201 }
else if (subDetID == 1) {
227 }
else if (subDetID == 1) {
236 int chipsPerModule = Nchip;
237 int chipsPerHalfStave = Nmod * chipsPerModule;
238 int chipsPerStave = Nhs * chipsPerHalfStave;
239 return index / chipsPerStave;
240 }
else if (Nhs == 1) {
241 int chipsPerModule = Nchip;
242 int chipsPerStave = Nmod * chipsPerModule;
243 return index / chipsPerStave;
258 }
else if (subDetID == 1) {
266 int chipsPerModule = Nchip;
267 int chipsPerHalfStave = Nmod * chipsPerModule;
268 int chipsPerStave = Nhs * chipsPerHalfStave;
270 int rem =
index % chipsPerStave;
271 return rem / chipsPerHalfStave;
285 }
else if (subDetID == 1) {
294 int chipsPerModule = Nchip;
295 int chipsPerHalfStave = Nmod * chipsPerModule;
296 int rem =
index % (Nhs * chipsPerHalfStave);
297 rem = rem % chipsPerHalfStave;
298 return rem / chipsPerModule;
299 }
else if (Nhs == 1) {
300 int chipsPerModule = Nchip;
301 int rem =
index % (Nmod * chipsPerModule);
302 return rem / chipsPerModule;
317 }
else if (subDetID == 1) {
326 int chipsPerModule = Nchip;
327 return index % chipsPerModule;
328 }
else if (Nhs == 1) {
329 int chipsPerModule = Nchip;
330 return index % chipsPerModule;
345 }
else if (subDetID == 1) {
351 int chipsPerModule = Nchip;
352 int chipsPerHalfStave = Nmod * chipsPerModule;
353 int chipsPerStave = Nhs * chipsPerHalfStave;
354 return getFirstChipIndex(lay, petalcase, subDetID) + stave * chipsPerStave + halfstave * chipsPerHalfStave + mod * chipsPerModule + chip;
355 }
else if (Nhs == 1) {
356 int chipsPerModule = Nchip;
357 int chipsPerStave = Nmod * chipsPerModule;
358 return getFirstChipIndex(lay, petalcase, subDetID) + stave * chipsPerStave + mod * chipsPerModule + chip;
362 LOGP(warning,
"Chip index not found for subDetID %d, petalcase %d, disk %d, layer %d, stave %d, halfstave %d, module %d, chip %d, returning numeric limit", subDetID, petalcase, disk, lay, stave, halfstave, mod, chip);
363 return std::numeric_limits<unsigned short>::max();
372 }
else if (subDetID == 1) {
378 int chipsPerModule = Nchip;
379 int chipsPerHalfStave = Nmod * chipsPerModule;
380 int chipsPerStave = Nhs * chipsPerHalfStave;
381 return getFirstChipIndex(lay, -1, subDetID) + stave * chipsPerStave + halfstave * chipsPerHalfStave + mod * chipsPerModule + chip;
382 }
else if (Nhs == 1) {
383 int chipsPerModule = Nchip;
384 int chipsPerStave = Nmod * chipsPerModule;
385 return getFirstChipIndex(lay, -1, subDetID) + stave * chipsPerStave + mod * chipsPerModule + chip;
389 LOGP(warning,
"Chip index not found for subDetID %d, volume %d, layer %d, stave %d, halfstave %d, module %d, chip %d, returning numeric limit", subDetID, volume, lay, stave, halfstave, mod, chip);
390 return std::numeric_limits<unsigned short>::max();
417 int subDetID, petalcase, disk,
layer, stave, halfstave, mod, chip;
431 }
else if (
layer >= 0) {
438 }
else if (subDetID == 1) {
466 static TGeoHMatrix matTmp;
467 gGeoManager->PushPath();
469 if (!gGeoManager->cd(
path.Data())) {
470 gGeoManager->PopPath();
475 matTmp = *gGeoManager->GetCurrentMatrix();
480 gGeoManager->PopPath();
482 static int chipInGlo{0};
519 for (
int i = 0;
i < newSize;
i++) {
530 LOG(warning) <<
"The method Build was not called yet";
536 if ((
mask & o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G)) && !
getCacheL2G().isFilled()) {
538 LOGP(info,
"Loading {} L2G matrices from TGeo; there are {} matrices",
getName(),
mSize);
540 cacheL2G.setSize(
mSize);
544 cacheL2G.setMatrix(
Mat3D(*hm),
i);
549 if ((
mask & o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L)) && !
getCacheT2L().isFilled()) {
550 LOGP(info,
"Loading {} T2L matrices from TGeo for ML & OT",
getName());
554 cacheT2L.setSize(m_Size);
555 for (
int i = 0;
i < m_Size;
i++) {
558 cacheT2L.setMatrix(
Mat3D(hm),
i);
568#ifdef ENABLE_UPGRADES
599 if (!nms.BeginsWith(prefix)) {
602 nms.Remove(0, strlen(prefix));
603 if (!isdigit(nms.Data()[0])) {
612 int numberOfLayers = 0;
614 if (trkV ==
nullptr) {
620 TObjArray*
nodes = trkV->GetNodes();
622 int nNodes =
nodes->GetEntriesFast();
623 for (
int j = 0;
j < nNodes;
j++) {
625 auto nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
626 const char*
name = nd->GetName();
630 LOG(fatal) <<
"Failed to extract layer ID from the " <<
name;
636 LOG(fatal) <<
"Failed to extract wrapper ID from the " <<
name;
638 TObjArray* nodesW = nd->GetNodes();
639 int nNodesW = nodesW->GetEntriesFast();
641 for (
int jw = 0; jw < nNodesW; jw++) {
642 auto ndW =
dynamic_cast<TGeoNode*
>(nodesW->At(jw))->GetName();
645 LOGP(fatal,
"Failed to extract layer ID from wrapper volume '{}' from one of its nodes '{}'",
name, ndW);
653 return numberOfLayers;
659 int numberOfPetals = 0;
667 TObjArray*
nodes = trkV->GetNodes();
673 LOGP(info,
"Searching for petal assemblies in {} (pattern: {})",
676 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
677 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
678 const char*
name = nd->GetName();
682 LOGP(info,
"Found petal assembly: {}",
name);
685 TGeoVolume* petalVol = nd->GetVolume();
687 TObjArray* petalNodes = petalVol->GetNodes();
689 LOGP(
debug,
"Petal {} contains {} child nodes",
name, petalNodes->GetEntriesFast());
691 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
692 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
693 LOGP(
debug,
" Node {}: {}", k, petalNode->GetName());
696 LOGP(warning,
"Petal {} has no child nodes",
name);
699 LOGP(warning,
"Petal {} has no volume",
name);
704 if (numberOfPetals == 0) {
705 LOGP(warning,
"No petal assemblies found in geometry");
707 LOGP(info,
"Found {} petal assemblies", numberOfPetals);
710 return numberOfPetals;
717 int numberOfParts = 0;
725 TObjArray*
nodes = vdV->GetNodes();
731 bool petalFound =
false;
733 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
734 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
735 const char*
name = nd->GetName();
741 LOGP(info,
"Counting active parts in petal: {}",
name);
744 TGeoVolume* petalVol = nd->GetVolume();
746 LOGP(warning,
"Petal {} has no volume",
name);
750 TObjArray* petalNodes = petalVol->GetNodes();
752 LOGP(warning,
"Petal {} has no child nodes",
name);
756 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
757 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
758 const char* nodeName = petalNode->GetName();
763 LOGP(
debug,
"Found active part in {}: {}",
name, nodeName);
775 if (numberOfParts == 0) {
776 LOGP(warning,
"No active parts (layers/disks) found in petal");
782 LOGP(info,
"Total number of active parts: {} ({}*{})",
791 int numberOfDisks = 0;
799 TObjArray*
nodes = vdV->GetNodes();
805 bool petalFound =
false;
807 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
808 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
814 LOGP(info,
"Counting disks in petal: {}", nd->GetName());
817 TGeoVolume* petalVol = nd->GetVolume();
819 LOGP(warning,
"Petal {} has no volume", nd->GetName());
823 TObjArray* petalNodes = petalVol->GetNodes();
825 LOGP(warning,
"Petal {} has no child nodes", nd->GetName());
829 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
830 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
833 LOGP(info,
"Found disk in {} : {}", nd->GetName(), petalNode->GetName());
844 if (numberOfDisks == 0) {
845 LOGP(warning,
"No disks found in VD geometry");
848 return numberOfDisks;
855 int numberOfLayers = 0;
863 TObjArray*
nodes = vdV->GetNodes();
869 bool petalFound =
false;
871 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
872 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
878 LOGP(info,
"Counting layers in petal: {}", nd->GetName());
881 TGeoVolume* petalVol = nd->GetVolume();
883 LOGP(warning,
"Petal {} has no volume", nd->GetName());
887 TObjArray* petalNodes = petalVol->GetNodes();
889 LOGP(warning,
"Petal {} has no child nodes", nd->GetName());
893 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
894 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
897 LOGP(info,
"Found layer in {} : {}", nd->GetName(), petalNode->GetName());
908 if (numberOfLayers == 0) {
909 LOGP(warning,
"No layers found in VD geometry");
912 return numberOfLayers;
919 int numberOfChips = 0;
927 TObjArray*
nodes = vdV->GetNodes();
933 bool petalFound =
false;
935 for (
int j = 0;
j <
nodes->GetEntriesFast();
j++) {
936 auto* nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
937 const char*
name = nd->GetName();
943 LOGP(info,
"Counting chips in petal: {}",
name);
946 TGeoVolume* petalVol = nd->GetVolume();
948 LOGP(warning,
"Petal {} has no volume",
name);
952 TObjArray* petalNodes = petalVol->GetNodes();
954 LOGP(warning,
"Petal {} has no child nodes",
name);
958 for (
int k = 0; k < petalNodes->GetEntriesFast(); k++) {
959 auto* petalNode =
dynamic_cast<TGeoNode*
>(petalNodes->At(k));
960 const char* nodeName = petalNode->GetName();
961 TGeoVolume* vol = petalNode->GetVolume();
964 LOGP(
debug,
"Node {} has no volume", nodeName);
969 TObjArray* subNodes = vol->GetNodes();
971 LOGP(
debug,
"Node {} has no sub-nodes", nodeName);
975 for (
int i = 0;
i < subNodes->GetEntriesFast();
i++) {
976 auto* subNode =
dynamic_cast<TGeoNode*
>(subNodes->At(
i));
979 LOGP(
debug,
"Found chip in {}: {}", nodeName, subNode->GetName());
991 if (numberOfChips == 0) {
992 LOGP(warning,
"No chips/sensors found in VD petal");
995 LOGP(info,
"Number of chips per petal: {}", numberOfChips);
996 return numberOfChips;
1002 int numberOfStaves = 0;
1005 TGeoVolume* layV = gGeoManager->GetVolume(layName.c_str());
1007 if (layV ==
nullptr) {
1012 TObjArray*
nodes = layV->GetNodes();
1015 int nNodes =
nodes->GetEntriesFast();
1017 for (
int j = 0;
j < nNodes;
j++) {
1019 auto nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
1020 const char*
name = nd->GetName();
1025 return numberOfStaves;
1031 int numberOfHalfStaves = 0;
1034 TGeoVolume* staveV = gGeoManager->GetVolume(staveName.c_str());
1036 if (staveV ==
nullptr) {
1041 TObjArray*
nodes = staveV->GetNodes();
1044 int nNodes =
nodes->GetEntriesFast();
1046 for (
int j = 0;
j < nNodes;
j++) {
1047 auto nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
1048 const char*
name = nd->GetName();
1050 numberOfHalfStaves++;
1054 if (numberOfHalfStaves == 0) {
1055 numberOfHalfStaves = 1;
1057 return numberOfHalfStaves;
1063 int numberOfModules = 0;
1066 TGeoVolume* staveV = gGeoManager->GetVolume(staveName.c_str());
1068 if (staveV ==
nullptr) {
1073 TObjArray*
nodes = staveV->GetNodes();
1074 int nNodes =
nodes->GetEntriesFast();
1076 for (
int j = 0;
j < nNodes;
j++) {
1077 auto nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
1078 const char*
name = nd->GetName();
1083 return numberOfModules;
1089 int numberOfChips = 0;
1092 TGeoVolume* moduleV = gGeoManager->GetVolume(moduleName.c_str());
1094 if (moduleV ==
nullptr) {
1099 TObjArray*
nodes = moduleV->GetNodes();
1100 int nNodes =
nodes->GetEntriesFast();
1102 for (
int j = 0;
j < nNodes;
j++) {
1103 auto nd =
dynamic_cast<TGeoNode*
>(
nodes->At(
j));
1104 const char*
name = nd->GetName();
1109 return numberOfChips;
1115 std::cout <<
"\nindex = " <<
index << std::endl;
1116 std::cout <<
"subDetID = " << subDetID << std::endl;
1117 std::cout <<
"petalcase = " << petalcase << std::endl;
1118 std::cout <<
"layer = " << lay << std::endl;
1119 std::cout <<
"disk = " << disk << std::endl;
1120 std::cout <<
"first chip index = " <<
getFirstChipIndex(lay, petalcase, subDetID) << std::endl;
1121 std::cout <<
"stave = " << stave << std::endl;
1122 std::cout <<
"halfstave = " << halfstave << std::endl;
1123 std::cout <<
"module = " << mod << std::endl;
1124 std::cout <<
"chip = " << chip << std::endl;
1131 LOGF(info,
"Geometry not built yet!");
1134 std::cout <<
"Detector ID: " << sInstance.get()->getDetID() << std::endl;
1136 LOGF(info,
"Summary of GeometryTGeo: %s",
getName());
1142 LOGF(info,
"Number of chips per petal VD: ");
1146 LOGF(info,
"Number of staves and half staves per layer MLOT: ");
1148 std::string mlot =
"";
1152 LOGF(info,
"Number of modules per stave (half stave) in each ML(OT) layer: ");
1156 LOGF(info,
"Number of chips per module MLOT: ");
1160 LOGF(info,
"Number of chips per layer MLOT: ");
1166 std::cout <<
"mLastChipIndex = [";
1173 std::cout <<
"]" << std::endl;
1174 std::cout <<
"mLastChipIndexVD = [";
1181 std::cout <<
"]" << std::endl;
1195 if (subDetID < 0 || subDetID > 1) {
1196 LOG(
error) <<
"getBarrelLayer(): Invalid subDetID for barrel: " << subDetID
1197 <<
". Expected values are 0 or 1.";
1201 if (subLayerID < 0 || subLayerID > 7) {
1202 LOG(
error) <<
"getBarrelLayer(): Invalid subLayerID for barrel: " << subDetID
1203 <<
". Expected values are between 0 and 7.";
1207 const int baseOffsets[] = {0, 3};
1209 return baseOffsets[subDetID] + subLayerID;
1216 double locA[3] = {-100., 0., 0.}, locB[3] = {100., 0., 0.}, gloA[3], gloB[3];
1217 double xp{0}, yp{0};
1221 LOG(
error) <<
"extractSensorXAlphaMLOT(): VD layers are not supported yet! chipID = " << chipID;
1226 matL2G->LocalToMaster(locA, gloA);
1227 matL2G->LocalToMaster(locB, gloB);
1228 double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
1229 double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
1230 xp = gloB[0] - dx *
t;
1231 yp = gloB[1] - dy *
t;
1234 alp = std::atan2(yp, xp);
1235 x = std::hypot(xp, yp);
1236 o2::math_utils::bringTo02Pi(alp);
1249 LOG(
error) <<
"createT2LMatrixMLOT(): VD layers are not supported yet! chipID = " << chipID
1250 <<
"returning dummy values! ";
1251 static TGeoHMatrix dummy;
1255 static TGeoHMatrix t2l;
1258 t2l.RotateZ(
alpha * TMath::RadToDeg());
1260 const TGeoHMatrix& matL2Gi = matL2G->Inverse();
1261 t2l.MultiplyLeft(&matL2Gi);
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
char error[CURL_ERROR_SIZE]
Definition of the SegmentationChipclass.
static const TRKBaseParam & Instance()
Static class with identifiers, bitmasks and names for ALICE detectors.
const MatrixCache< Mat3D > & getCacheT2L() const
const char * getName() const
int mSize
prebooked number of sensors
const MatrixCache< Mat3D > & getCacheL2G() const
static const char * composeSymNameModule(int d, int layer)
static const char * getTRKPetalDiskPattern()
int getModule(int index) const
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, not implemented yet.
static const char * composeSymNameChip(int d, int layer)
static std::string sPetalLayerName
static const char * getTRKSensorPattern()
static std::string sStaveName
bool getChipID(int index, int &subDetID, int &petalcase, int &disk, int &lay, int &stave, int &halfstave, int &mod, int &chip) const
std::vector< int > mNumberOfHalfStaves
Number Of Half staves in each stave of the layer in ML/OT.
int extractNumberOfChipsPerPetalVD() const
bool isTrackingFrameCachedMLOT() const
int extractNumberOfHalfStavesMLOT(int lay) const
static const char * getTRKPetalLayerPattern()
int getChip(int index) const
int extractNumberOfLayersMLOT()
Determines the number of active parts in the Geometry.
int extractNumberOfChipsMLOT(int lay) const
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 > mNumberOfModules
Number Of Modules per stave (half stave) in ML/OT.
static std::string sPetalName
void fillTrackingFramesCacheMLOT()
int extractNumberOfStavesMLOT(int lay) const
static std::string sPetalDiskName
void Print(Option_t *opt="") const
float getSensorRefAlphaMLOT(int chipId) const
int getLayer(int index) const
local layer index within the sub-detector (0-based per VD/MLOT)
std::vector< unsigned short > mLastChipIndexVD
max ID of the detctor in the layer for the VD
static const char * getTRKWrapVolPattern()
std::vector< float > mCacheRefXMLOT
TString getMatrixPath(int index) const
static const char * getTRKPetalAssemblyPattern()
int getNumberOfChips() const
static const char * getTRKLayerPattern()
static std::string sHalfStaveName
unsigned short getFirstChipIndex(int lay, int petalcase, int subDetID) const
std::vector< int > mNumberOfChips
number of chips per module in ML/OT
o2::math_utils::Transform3D Mat3D
static std::string sWrapperVolumeName
Wrapper volume name, not implemented at the moment.
static std::string sServiceVolName
TGeoHMatrix & createT2LMatrixMLOT(int)
std::vector< float > mCacheRefAlphaMLOT
cache for X of ML and OT
static const char * getTRKHalfStavePattern()
int extractNumberOfLayersVD() const
std::vector< int > mNumberOfChipsPerPetalVD
numbersOfChipPerPetalVD
static std::string sMetalStackName
static std::string sChipName
static std::string sSensorName
void fillMatrixCache(int mask)
std::vector< int > sensorsMLOT
is it owned by the singleton?
static std::string sDeadzoneName
static std::string sLayerName
unsigned short getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int mod, int chip) const
int extractNumberOfActivePartsVD() const
void PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int mod, int chip) const
static const char * composeSymNameSensor(int d, int layer)
int extractNumberOfModulesMLOT(int lay) const
int extractNumberOfDisksVD() const
int getLayerTRK(int index) const
global layer index across the full TRK (VD layers 0..nVD-1, MLOT layers nVD..nTotal-1)
static const char * getTRKPetalPattern()
Int_t mNumberOfActivePartsVD
number of layers
std::vector< int > mNumberOfChipsPerLayerMLOT
number of chips per layer MLOT
Int_t mNumberOfDisksVD
number of Disks = 6
std::vector< unsigned short > mLastChipIndexMLOT
max ID of the detctor in the layer for the MLOT
Int_t mNumberOfLayersMLOT
number of layers
static const char * composeSymNameLayer(int d, int layer)
int getStave(int index) const
int getBarrelLayer(int) const
static const char * getTRKVolPattern()
static const char * getTRKModulePattern()
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.
std::vector< unsigned short > mLastChipIndex
max ID of the detctor in the petal(VD) or layer(MLOT)
void extractSensorXAlphaMLOT(int, float &, float &)
void Build(int loadTrans)
eMLOTLayout mLayoutMLOT
cache for sensor ref alpha ML and OT
Int_t mNumberOfLayersVD
number of layers
int getHalfStave(int index) const
GeometryTGeo(bool build=false, int loadTrans=0)
TGeoHMatrix * extractMatrixSensor(int index) const
static std::string sModuleName
static void setNumberOfPetalsVD(int n)
GLfloat GLfloat GLfloat alpha
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"