forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeometryTGeo.h
More file actions
239 lines (192 loc) · 9.11 KB
/
GeometryTGeo.h
File metadata and controls
239 lines (192 loc) · 9.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file GeometryTGeo.h
/// \brief Definition of the GeometryTGeo class
/// \author bogdan.vulpescu@clermont.in2p3.fr - adapted from ITS, 21.09.2017
#ifndef ALICEO2_MFT_GEOMETRYTGEO_H_
#define ALICEO2_MFT_GEOMETRYTGEO_H_
#include <TGeoMatrix.h> // for TGeoHMatrix
#include <TObject.h> // for TObject
#include <array>
#include <string>
#include <vector>
#include "DetectorsBase/GeometryManager.h"
#include "DetectorsCommonDataFormats/DetID.h"
#include "ITSMFTBase/GeometryTGeo.h"
#include "MathUtils/Utils.h"
#include "Rtypes.h" // for Int_t, Double_t, Bool_t, UInt_t, etc
class TGeoPNEntry;
namespace o2
{
namespace mft
{
class GeometryTGeo : public o2::itsmft::GeometryTGeo
{
public:
typedef o2::math_utils::Transform3D Mat3D;
using DetMatrixCache::getMatrixL2G;
using DetMatrixCache::getMatrixT2G;
using DetMatrixCache::getMatrixT2L;
static GeometryTGeo* Instance()
{
// get (create if needed) a unique instance of the object
if (!sInstance) {
sInstance = std::unique_ptr<GeometryTGeo>(new GeometryTGeo(true, 0));
}
return sInstance.get();
}
static bool instanceExist() { return sInstance.get() != nullptr; }
// Adopt the unique instance from external raw pointer (to be used only to read saved instance from file)
// When adopting an object owned by the CCDB cache we should not delete it
static void adopt(GeometryTGeo* raw, bool canDelete = false);
// constructor
// ATTENTION: this class is supposed to behave as a singleton, but to make it
// root-persistent we must define public default constructor.
// NEVER use it, it will throw exception if the class instance was already
// created. Use GeometryTGeo::Instance() instead
GeometryTGeo(Bool_t build = kFALSE, Int_t loadTrans = 0
/*o2::base::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, // default transformations to load
o2::math_utils::TransformType::T2G,
o2::math_utils::TransformType::L2G)*/
);
/// Default destructor, don't use
~GeometryTGeo() override;
GeometryTGeo(const GeometryTGeo& src) = delete;
GeometryTGeo& operator=(const GeometryTGeo& geom) = delete;
void destroy() { sInstance.reset(); }
// implement filling of the matrix cache
using o2::itsmft::GeometryTGeo::fillMatrixCache;
void fillMatrixCache(Int_t mask) override;
void updateL2GMatrixCache(std::vector<int> chipIDs = {});
/// Exract MFT parameters from TGeo
void Build(int loadTrans = 0) override;
static const Char_t* getMFTVolPattern() { return sVolumeName.c_str(); }
static const Char_t* getMFTHalfPattern() { return sHalfName.c_str(); }
static const Char_t* getMFTDiskPattern() { return sDiskName.c_str(); }
static const Char_t* getMFTLadderPattern() { return sLadderName.c_str(); }
static const Char_t* getMFTChipPattern() { return sChipName.c_str(); }
static const Char_t* getMFTSensorPattern() { return sSensorName.c_str(); }
/// This routine computes the sensor index (as it is used in the list of
/// transformations) from the detector half, disk, ladder and position
/// of the sensor in the ladder
Int_t getSensorIndex(Int_t half, Int_t disk, Int_t ladder, Int_t sensor) const;
/// get layer index (0:9) from the chip index
Int_t getLayer(Int_t index) const final;
/// This routine computes the half, disk, ladder and sensor number
/// given the sensor index number
/// \param int index The sensor index number, starting from zero.
/// \param int half The half number. Starting from 0
/// \param int disk The disk number in a half. Starting from 0
/// \param int ladder The ladder number in a disk. Starting from 0
/// \param int sensor The sensor number in a ladder. Starting from 0
Bool_t getSensorID(Int_t index, Int_t& half, Int_t& disk, Int_t& ladder, Int_t& sensor) const;
/// Returns the number of sensors in each ladder of each disk of each half
/// ladder is the matrix ID and is converted to geometry ID
Int_t getNumberOfSensorsPerLadder(Int_t half, Int_t disk, Int_t ladder) const
{
return extractNumberOfSensorsPerLadder(half, disk, ladder);
}
/// Returns the number of ladders in each disk of each half
Int_t getNumberOfLaddersPerDisk(Int_t half, Int_t disk, Int_t sensors) const
{
return extractNumberOfLadders(half, disk, sensors);
}
/// Returns the number of disks in each half
Int_t getNumberOfDisksPerHalf(Int_t half) const
{
return extractNumberOfDisks(half);
}
/// Returns the number of halves MFT
Int_t getNumberOfHalfs()
{
return extractNumberOfHalves();
}
/// Returns the min number of sensors per ladder
Int_t getMinSensorsPerLadder()
{
return MinSensorsPerLadder;
}
/// Returns the max number of sensors per ladder
Int_t getMaxSensorsPerLadder()
{
return MaxSensorsPerLadder;
}
/// Returns the ladder geometry ID from the matrix ID
Int_t getLadderID(Int_t disk, Int_t ladder) const
{
return mLadderIndex2Id[disk][ladder];
}
/// sym name of the MFT
static const char* composeSymNameMFT() { return o2::detectors::DetID(o2::detectors::DetID::MFT).getName(); }
/// sym name of the half
static const char* composeSymNameHalf(int hf);
/// Sym name of the disk at given half
static const char* composeSymNameDisk(int hf, int dk);
/// Sym name of the ladder at given half/disk
static const char* composeSymNameLadder(int hf, int dk, int lr);
/// Sym name of the chip in the given half/disk/ladder
static const char* composeSymNameChip(int hf, int dk, int lr, int chip);
protected:
/// Determines the number of detector halves in the Geometry
Int_t extractNumberOfHalves();
/// Determines the number of disks in each detector half
Int_t extractNumberOfDisks(Int_t half) const;
/// Determines the number of ladders in each disk of each half
Int_t extractNumberOfLadders(Int_t half, Int_t disk, Int_t nsensors) const;
/// Maps the internal matrix index to the geometry index from the XML file
Int_t extractNumberOfLadders(Int_t half, Int_t disk, Int_t nsensors, Int_t& nL);
/// Determines the number of sensors in each ladder of each disk of each half
Int_t extractNumberOfSensorsPerLadder(Int_t half, Int_t disk, Int_t ladder) const;
/// Extract number following the prefix in the name string
Int_t extractVolumeCopy(const Char_t* name, const Char_t* prefix) const;
/// Get the transformation matrix of the sensor [...]
/// for a given sensor 'index' by querying the TGeoManager
TGeoHMatrix* extractMatrixSensor(Int_t index) const;
// Create matrix for transformation from sensor local frame to global one
TGeoHMatrix& createT2LMatrix(Int_t isn);
/// Get sensor tracking frame alpha and x (ITS), where the normal to the sensor
/// intersects the sensor surface
void extractSensorXAlpha(int index, float& x, float& alp);
/// From matrix index to half ID
Int_t getHalf(Int_t index) const;
/// From matrix index to disk ID
Int_t getDisk(Int_t index) const;
/// From matrix index to ladder ID (matrix)
Int_t getLadder(Int_t index) const;
/// In a disk start numbering the sensors from zero
Int_t getFirstSensorIndex(Int_t disk) const { return (disk == 0) ? 0 : mLastSensorIndex[disk - 1] + 1; }
protected:
static constexpr Int_t MinSensorsPerLadder = 2;
static constexpr Int_t MaxSensorsPerLadder = 5;
Int_t mTotalNumberOfSensors; ///< total number of sensors in the detector
Int_t mNumberOfHalves; ///< number of detector halves
std::vector<Int_t> mNumberOfDisks; ///< disks/half
std::vector<std::vector<Int_t>> mNumberOfLadders; ///< ladders[nsensor]/halfdisk
std::vector<Int_t> mNumberOfLaddersPerDisk; ///< ladders/halfdisk
std::vector<std::vector<Int_t>> mLadderIndex2Id; ///< from matrix index to geometry index
std::vector<std::vector<Int_t>> mLadderId2Index; ///< from to geometry index to matrix index
std::vector<Int_t> mLastSensorIndex; ///< last sensor index in a layer
std::vector<Int_t> mSensorIndexToLayer; ///< get from sensor index the layer
std::vector<Int_t> mNumberOfSensorsPerDisk; ///< get from sensor index the lay er
std::vector<Float_t> mLayerMedianZ; ///< z median value between the two planes of a disk
static std::string sVolumeName; ///<
static std::string sHalfName; ///<
static std::string sDiskName; ///<
static std::string sLadderName; ///<
static std::string sChipName; ///<
static std::string sSensorName; ///<
private:
static std::unique_ptr<o2::mft::GeometryTGeo> sInstance; ///< singleton instance
ClassDefOverride(GeometryTGeo, 1); // MFT geometry based on TGeo
};
} // namespace mft
} // namespace o2
#endif