Project
Loading...
Searching...
No Matches
GeometryTGeo.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
15
16#ifndef ALICEO2_MFT_GEOMETRYTGEO_H_
17#define ALICEO2_MFT_GEOMETRYTGEO_H_
18
19#include <TGeoMatrix.h> // for TGeoHMatrix
20#include <TObject.h> // for TObject
21#include <array>
22#include <string>
23#include <vector>
27#include "MathUtils/Utils.h"
28#include "Rtypes.h" // for Int_t, Double_t, Bool_t, UInt_t, etc
29
30class TGeoPNEntry;
31
32namespace o2
33{
34namespace mft
35{
37{
38 public:
40 using DetMatrixCache::getMatrixL2G;
41 using DetMatrixCache::getMatrixT2G;
42 using DetMatrixCache::getMatrixT2L;
43
45 {
46 // get (create if needed) a unique instance of the object
47 if (!sInstance) {
48 sInstance = std::unique_ptr<GeometryTGeo>(new GeometryTGeo(true, 0));
49 }
50 return sInstance.get();
51 }
52
53 static bool instanceExist() { return sInstance.get() != nullptr; }
54
55 // Adopt the unique instance from external raw pointer (to be used only to read saved instance from file)
56 // When adopting an object owned by the CCDB cache we should not delete it
57 static void adopt(GeometryTGeo* raw, bool canDelete = false);
58
59 // constructor
60 // ATTENTION: this class is supposed to behave as a singleton, but to make it
61 // root-persistent we must define public default constructor.
62 // NEVER use it, it will throw exception if the class instance was already
63 // created. Use GeometryTGeo::Instance() instead
64 GeometryTGeo(Bool_t build = kFALSE, Int_t loadTrans = 0
65 /*o2::base::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, // default transformations to load
66 o2::math_utils::TransformType::T2G,
67 o2::math_utils::TransformType::L2G)*/
68 );
69
71 ~GeometryTGeo() override;
72
73 GeometryTGeo(const GeometryTGeo& src) = delete;
74 GeometryTGeo& operator=(const GeometryTGeo& geom) = delete;
75
76 void destroy() { sInstance.reset(); }
77
78 // implement filling of the matrix cache
80 void fillMatrixCache(Int_t mask) override;
81 void updateL2GMatrixCache(std::vector<int> chipIDs = {});
82
84 void Build(int loadTrans = 0) override;
85
86 static const Char_t* getMFTVolPattern() { return sVolumeName.c_str(); }
87 static const Char_t* getMFTHalfPattern() { return sHalfName.c_str(); }
88 static const Char_t* getMFTDiskPattern() { return sDiskName.c_str(); }
89 static const Char_t* getMFTLadderPattern() { return sLadderName.c_str(); }
90 static const Char_t* getMFTChipPattern() { return sChipName.c_str(); }
91 static const Char_t* getMFTSensorPattern() { return sSensorName.c_str(); }
95 Int_t getSensorIndex(Int_t half, Int_t disk, Int_t ladder, Int_t sensor) const;
96
98 Int_t getLayer(Int_t index) const;
99
107 Bool_t getSensorID(Int_t index, Int_t& half, Int_t& disk, Int_t& ladder, Int_t& sensor) const;
108
111 Int_t getNumberOfSensorsPerLadder(Int_t half, Int_t disk, Int_t ladder) const
112 {
113 return extractNumberOfSensorsPerLadder(half, disk, ladder);
114 }
116 Int_t getNumberOfLaddersPerDisk(Int_t half, Int_t disk, Int_t sensors) const
117 {
118 return extractNumberOfLadders(half, disk, sensors);
119 }
121 Int_t getNumberOfDisksPerHalf(Int_t half) const
122 {
123 return extractNumberOfDisks(half);
124 }
127 {
128 return extractNumberOfHalves();
129 }
130
133 {
134 return MinSensorsPerLadder;
135 }
136
139 {
140 return MaxSensorsPerLadder;
141 }
142
144 Int_t getLadderID(Int_t disk, Int_t ladder) const
145 {
146 return mLadderIndex2Id[disk][ladder];
147 }
148
151
153 static const char* composeSymNameHalf(int hf);
154
156 static const char* composeSymNameDisk(int hf, int dk);
157
159 static const char* composeSymNameLadder(int hf, int dk, int lr);
160
162 static const char* composeSymNameChip(int hf, int dk, int lr, int chip);
163
164 protected:
166 Int_t extractNumberOfHalves();
167
169 Int_t extractNumberOfDisks(Int_t half) const;
170
172 Int_t extractNumberOfLadders(Int_t half, Int_t disk, Int_t nsensors) const;
173
175 Int_t extractNumberOfLadders(Int_t half, Int_t disk, Int_t nsensors, Int_t& nL);
176
178 Int_t extractNumberOfSensorsPerLadder(Int_t half, Int_t disk, Int_t ladder) const;
179
181 Int_t extractVolumeCopy(const Char_t* name, const Char_t* prefix) const;
182
185 TGeoHMatrix* extractMatrixSensor(Int_t index) const;
186
187 // Create matrix for transformation from sensor local frame to global one
188 TGeoHMatrix& createT2LMatrix(Int_t isn);
189
192 void extractSensorXAlpha(int index, float& x, float& alp);
193
195 Int_t getHalf(Int_t index) const;
196
198 Int_t getDisk(Int_t index) const;
199
201 Int_t getLadder(Int_t index) const;
202
204 Int_t getFirstSensorIndex(Int_t disk) const { return (disk == 0) ? 0 : mLastSensorIndex[disk - 1] + 1; }
205
206 protected:
207 static constexpr Int_t MinSensorsPerLadder = 2;
208 static constexpr Int_t MaxSensorsPerLadder = 5;
209
212 std::vector<Int_t> mNumberOfDisks;
213 std::vector<std::vector<Int_t>> mNumberOfLadders;
214 std::vector<Int_t> mNumberOfLaddersPerDisk;
215
216 std::vector<std::vector<Int_t>> mLadderIndex2Id;
217 std::vector<std::vector<Int_t>> mLadderId2Index;
218
219 std::vector<Int_t> mLastSensorIndex;
220 std::vector<Int_t> mSensorIndexToLayer;
221 std::vector<Int_t> mNumberOfSensorsPerDisk;
222 std::vector<Float_t> mLayerMedianZ;
223
224 static std::string sVolumeName;
225 static std::string sHalfName;
226 static std::string sDiskName;
227 static std::string sLadderName;
228 static std::string sChipName;
229 static std::string sSensorName;
230
231 private:
232 static std::unique_ptr<o2::mft::GeometryTGeo> sInstance;
233
234 ClassDefOverride(GeometryTGeo, 1); // MFT geometry based on TGeo
235};
236} // namespace mft
237} // namespace o2
238
239#endif
General auxilliary methods.
Definition of the GeometryManager class.
Definition of the GeometryTGeo class : common part for ITS and MFT.
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static constexpr const char * getName(ID id)
names of defined detectors
Definition DetID.h:145
static constexpr ID MFT
Definition DetID.h:71
virtual void fillMatrixCache(int mask)=0
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
Int_t getMaxSensorsPerLadder()
Returns the max number of sensors per ladder.
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
Int_t getNumberOfLaddersPerDisk(Int_t half, Int_t disk, Int_t sensors) const
Returns the number of ladders in each disk of each half.
GeometryTGeo & operator=(const GeometryTGeo &geom)=delete
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()
GeometryTGeo(const GeometryTGeo &src)=delete
Int_t getMinSensorsPerLadder()
Returns the min number of sensors per ladder.
void Build(int loadTrans=0) override
Exract MFT parameters from TGeo.
Int_t getNumberOfHalfs()
Returns the number of halfs MFT.
void updateL2GMatrixCache(std::vector< int > chipIDs={})
Int_t getLadderID(Int_t disk, Int_t ladder) const
Returns the ladder geometry ID from the matrix ID.
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 getNumberOfDisksPerHalf(Int_t half) const
Returns the number of disks in each half.
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 GeometryTGeo * Instance()
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
Int_t getNumberOfSensorsPerLadder(Int_t half, Int_t disk, Int_t ladder) const
static const char * composeSymNameMFT()
sym name of the MFT
static bool instanceExist()
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
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
GLuint index
Definition glcorearb.h:781
GLuint const GLchar * name
Definition glcorearb.h:781
GLint GLuint mask
Definition glcorearb.h:291
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...