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>
30class TGeoHMatrix; // lines 11-11
31class TGeoManager; // lines 9-9
32class TGeoNavigator;
33
34namespace o2
35{
36namespace detectors
37{
38class AlignParam;
39}
40
41namespace base
42{
46enum class MatbudGeomBackend : int { ROOT = 0,
47 VECGEOM = 1 };
48
56{
57 public:
61 static void loadGeometry(std::string_view geomFilePath = "", bool applyMisalignment = false, bool preferAlignedFile = true);
62 static bool isGeometryLoaded() { return gGeoManager != nullptr; }
63 static void applyMisalignent(bool applyMisalignment = true);
64
69 static Bool_t getOriginalMatrix(o2::detectors::DetID detid, int sensid, TGeoHMatrix& m);
70 static Bool_t getOriginalMatrix(const char* symname, TGeoHMatrix& m);
71 static TGeoHMatrix* getMatrix(const char* symname);
72 static const char* getSymbolicName(o2::detectors::DetID detid, int sensid);
73 static TGeoPNEntry* getPNEntry(o2::detectors::DetID detid, Int_t sensid);
74 static TGeoHMatrix* getMatrix(o2::detectors::DetID detid, Int_t sensid);
75
76 static int getSensID(o2::detectors::DetID detid, int sensid)
77 {
79 return detid <= o2::detectors::DetID::FOC ? ((detid << sDetOffset) | (sensid & sSensorMask)) : ((detid << sDetOffsetLarge) | (sensid & sSensorMaskLarge));
80 }
81
83 ~GeometryManager() override = default;
84
86 static bool applyAlignment(const std::vector<o2::detectors::AlignParam>& algPars);
87 static bool applyAlignment(const std::vector<const std::vector<o2::detectors::AlignParam>*> algPars);
88
89 struct MatBudgetExt {
90 double meanRho = 0.; // mean density: sum(x_i*rho_i)/sum(x_i) [g/cm3]
91 double meanX2X0 = 0.; // equivalent rad length fraction: sum(x_i/X0_i) [adimensional]
92 double meanA = 0.; // mean A: sum(x_i*A_i)/sum(x_i) [adimensional]
93 double meanZ = 0.; // mean Z: sum(x_i*Z_i)/sum(x_i) [adimensional]
94 double meanZ2A = 0.; // Z/A mean: sum(x_i*Z_i/A_i)/sum(x_i) [adimensional]
95 double length = -1.; // length: sum(x_i) [cm]
96 int nCross = 0; // number of boundary crosses
97
98 MatBudgetExt() = default;
99 ~MatBudgetExt() = default;
100 MatBudgetExt(const MatBudgetExt& src) = default;
102 void normalize(double nrm);
104 };
105
109 static o2::base::MatBudget meanMaterialBudget(float x0, float y0, float z0, float x1, float y1, float z1,
110 TGeoNavigator* nav = nullptr);
112 {
113 return meanMaterialBudget(start.X(), start.Y(), start.Z(), end.X(), end.Y(), end.Z(), nav);
114 }
116 {
117 return meanMaterialBudget(start.X(), start.Y(), start.Z(), end.X(), end.Y(), end.Z(), nav);
118 }
119
120 static MatBudgetExt meanMaterialBudgetExt(float x0, float y0, float z0, float x1, float y1, float z1);
129
132#ifdef O2_WITH_VECGEOM
133 static constexpr bool isVecGeomAvailable() { return true; }
136 static o2::base::MatBudget vecGeomMaterialBudget(float x0, float y0, float z0, float x1, float y1, float z1);
137#else
138 static constexpr bool isVecGeomAvailable() { return false; }
139#endif
140
141 private:
143 GeometryManager() = default;
144 static TGeoHMatrix* getMatrix(TGeoPNEntry* pne);
145 static void accountMaterial(const TGeoMaterial* material, MatBudgetExt& bd);
146 static void accountMaterial(const TGeoMaterial* material, o2::base::MatBudget& bd)
147 {
148 bd.meanRho = material->GetDensity();
149 bd.meanX2X0 = material->GetRadLen();
150 }
151
155 static Bool_t getOriginalMatrixFromPath(const char* path, TGeoHMatrix& m);
156
157 private:
159 static constexpr UInt_t sDetOffset = 15;
160 static constexpr UInt_t sSensorMask = (0x1 << sDetOffset) - 1;
161 static constexpr UInt_t sDetOffsetLarge = 17;
162 static constexpr UInt_t sSensorMaskLarge = (0x1 << sDetOffsetLarge) - 1;
163 static std::mutex sTGMutex;
164
165 ClassDefOverride(GeometryManager, 0); // Manager of geometry information for alignment
166};
167} // namespace base
168} // namespace o2
169
170#endif
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 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:58
static constexpr ID FOC
Definition DetID.h:80
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
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