Project
Loading...
Searching...
No Matches
GeometryManager.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef ALICEO2_BASE_GEOMETRYMANAGER_H_
16#define ALICEO2_BASE_GEOMETRYMANAGER_H_
17
18#include <TGeoManager.h> // for TGeoManager
19#include <TGeoMaterial.h>
20#include <TGeoPhysicalNode.h> // for TGeoPNEntry
21#include <TGeoShape.h>
22#include <TMath.h>
23#include <TObject.h> // for TObject
24#include <string_view>
26#include "GPUCommonLogger.h" // for LOG
27#include "MathUtils/Cartesian.h"
29#include <mutex>
30#include <vector>
31class TGeoHMatrix; // lines 11-11
32class TGeoManager; // lines 9-9
33class TGeoNavigator;
34
35namespace o2
36{
37namespace detectors
38{
39class AlignParam;
40}
41
42namespace base
43{
47enum class MatbudGeomBackend : int { ROOT = 0,
48 VECGEOM = 1 };
49
57{
58 public:
62 static void loadGeometry(std::string_view geomFilePath = "", bool applyMisalignment = false, bool preferAlignedFile = true);
63 static bool isGeometryLoaded() { return gGeoManager != nullptr; }
64 static void applyMisalignent(bool applyMisalignment = true);
65
70 static Bool_t getOriginalMatrix(o2::detectors::DetID detid, int sensid, TGeoHMatrix& m);
71 static Bool_t getOriginalMatrix(const char* symname, TGeoHMatrix& m);
72 static TGeoHMatrix* getMatrix(const char* symname);
73 static const char* getSymbolicName(o2::detectors::DetID detid, int sensid);
74 static TGeoPNEntry* getPNEntry(o2::detectors::DetID detid, Int_t sensid);
75 static TGeoHMatrix* getMatrix(o2::detectors::DetID detid, Int_t sensid);
76
77 static int getSensID(o2::detectors::DetID detid, int sensid)
78 {
80 return detid <= o2::detectors::DetID::FOC ? ((detid << sDetOffset) | (sensid & sSensorMask)) : ((detid << sDetOffsetLarge) | (sensid & sSensorMaskLarge));
81 }
82
84 ~GeometryManager() override = default;
85
87 static bool applyAlignment(const std::vector<o2::detectors::AlignParam>& algPars);
88 static bool applyAlignment(const std::vector<const std::vector<o2::detectors::AlignParam>*> algPars);
89
90 struct MatBudgetExt {
91 double meanRho = 0.; // mean density: sum(x_i*rho_i)/sum(x_i) [g/cm3]
92 double meanX2X0 = 0.; // equivalent rad length fraction: sum(x_i/X0_i) [adimensional]
93 double meanA = 0.; // mean A: sum(x_i*A_i)/sum(x_i) [adimensional]
94 double meanZ = 0.; // mean Z: sum(x_i*Z_i)/sum(x_i) [adimensional]
95 double meanZ2A = 0.; // Z/A mean: sum(x_i*Z_i/A_i)/sum(x_i) [adimensional]
96 double length = -1.; // length: sum(x_i) [cm]
97 int nCross = 0; // number of boundary crosses
98
99 MatBudgetExt() = default;
100 ~MatBudgetExt() = default;
101 MatBudgetExt(const MatBudgetExt& src) = default;
103 void normalize(double nrm);
105 };
106
110 static o2::base::MatBudget meanMaterialBudget(float x0, float y0, float z0, float x1, float y1, float z1,
111 TGeoNavigator* nav = nullptr);
113 {
114 return meanMaterialBudget(start.X(), start.Y(), start.Z(), end.X(), end.Y(), end.Z(), nav);
115 }
117 {
118 return meanMaterialBudget(start.X(), start.Y(), start.Z(), end.X(), end.Y(), end.Z(), nav);
119 }
120
121 static MatBudgetExt meanMaterialBudgetExt(float x0, float y0, float z0, float x1, float y1, float z1);
130
133#ifdef O2_WITH_VECGEOM
134 static constexpr bool isVecGeomAvailable() { return true; }
137 static o2::base::MatBudget vecGeomMaterialBudget(float x0, float y0, float z0, float x1, float y1, float z1);
138#else
139 static constexpr bool isVecGeomAvailable() { return false; }
140#endif
141
146 static bool ensureVecGeomWorld();
147
152 static bool vecGeomLocate(double x, double y, double z, std::vector<TGeoNode*>& chain);
153
154 private:
156 GeometryManager() = default;
157 static TGeoHMatrix* getMatrix(TGeoPNEntry* pne);
158 static void accountMaterial(const TGeoMaterial* material, MatBudgetExt& bd);
159 static void accountMaterial(const TGeoMaterial* material, o2::base::MatBudget& bd)
160 {
161 bd.meanRho = material->GetDensity();
162 bd.meanX2X0 = material->GetRadLen();
163 }
164
168 static Bool_t getOriginalMatrixFromPath(const char* path, TGeoHMatrix& m);
169
170 private:
172 static constexpr UInt_t sDetOffset = 15;
173 static constexpr UInt_t sSensorMask = (0x1 << sDetOffset) - 1;
174 static constexpr UInt_t sDetOffsetLarge = 17;
175 static constexpr UInt_t sSensorMaskLarge = (0x1 << sDetOffsetLarge) - 1;
176 static std::mutex sTGMutex;
177
178 ClassDefOverride(GeometryManager, 0); // Manager of geometry information for alignment
179};
180} // namespace base
181} // namespace o2
182
183#endif
GPUChain * chain
Declarations for material properties of the cell (voxel)
~GeometryManager() override=default
Default destructor.
static constexpr bool isVecGeomAvailable()
static const char * getSymbolicName(o2::detectors::DetID detid, int sensid)
static TGeoHMatrix * getMatrix(o2::detectors::DetID detid, Int_t sensid)
static Bool_t getOriginalMatrix(o2::detectors::DetID detid, int sensid, TGeoHMatrix &m)
static void loadGeometry(std::string_view geomFilePath="", bool applyMisalignment=false, bool preferAlignedFile=true)
static MatBudgetExt meanMaterialBudgetExt(const math_utils::Point3D< float > &start, const math_utils::Point3D< float > &end)
static o2::base::MatBudget meanMaterialBudget(const math_utils::Point3D< double > &start, const math_utils::Point3D< double > &end, TGeoNavigator *nav=nullptr)
static bool applyAlignment(const std::vector< o2::detectors::AlignParam > &algPars)
misalign geometry with alignment objects from the array, optionaly check overlaps
static o2::base::MatBudget meanMaterialBudget(float x0, float y0, float z0, float x1, float y1, float z1, TGeoNavigator *nav=nullptr)
static MatBudgetExt meanMaterialBudgetExt(float x0, float y0, float z0, float x1, float y1, float z1)
static int getSensID(o2::detectors::DetID detid, int sensid)
static bool vecGeomLocate(double x, double y, double z, std::vector< TGeoNode * > &chain)
static TGeoHMatrix * getMatrix(const char *symname)
static MatBudgetExt meanMaterialBudgetExt(const math_utils::Point3D< double > &start, const math_utils::Point3D< double > &end)
static TGeoPNEntry * getPNEntry(o2::detectors::DetID detid, Int_t sensid)
static void applyMisalignent(bool applyMisalignment=true)
static o2::base::MatBudget meanMaterialBudget(const math_utils::Point3D< float > &start, const math_utils::Point3D< float > &end, TGeoNavigator *nav=nullptr)
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:60
GLint GLenum GLint x
Definition glcorearb.h:403
const GLfloat * m
Definition glcorearb.h:4066
GLenum src
Definition glcorearb.h:1767
GLuint GLfloat GLfloat GLfloat GLfloat y1
Definition glcorearb.h:5034
GLuint GLuint end
Definition glcorearb.h:469
GLuint GLfloat GLfloat GLfloat x1
Definition glcorearb.h:5034
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
GLuint GLfloat x0
Definition glcorearb.h:5034
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLuint start
Definition glcorearb.h:469
GLuint GLfloat GLfloat y0
Definition glcorearb.h:5034
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
std::string detectors(const std::vector< std::string > &det, unsigned mask)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
MatBudgetExt(const MatBudgetExt &src)=default
MatBudgetExt & operator=(const MatBudgetExt &src)=default
float meanRho
mean density, g/cm^3
Definition MatCell.h:30
float meanX2X0
fraction of radiaton lenght
Definition MatCell.h:31