]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUGeomTGeo.h
std::cout
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUGeomTGeo.h
CommitLineData
451f5018 1#ifndef ALIITSUGEOMTGEO_H
2#define ALIITSUGEOMTGEO_H
a11ef2e4 3
451f5018 4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/////////////////////////////////////////////////////////////////////////
8// AliITSUGeomTGeo is a simple interface class to TGeoManager //
9// It is used in the simulation and reconstruction in order to //
10// query the TGeo ITS geometry //
11// //
12// author - cvetan.cheshkov@cern.ch //
13// 15/02/2007 //
14// adapted to ITSupg 18/07/2012 - ruben.shahoyan@cern.ch //
15// RS: in order to preserve the static character of the class but //
16// make it dynamically access geometry, we need to check in every //
17// method if the structures are initialized. To be converted to //
18// singleton at later stage. //
19// //
20// Note on the upgrade detector types: //
21// The coarse type defines detectors served by different classes, //
75875328 22// like Pix. Each such a detector type can have kMaxSegmPerDetType //
451f5018 23// segmentations (pitch etc.) whose parameteres are stored in the //
75875328 24// AliITSsegmentation derived class (like AliITSUSegmentationPix) //
451f5018 25// This allows to have in the setup modules served by the same //
26// classes but with different segmentations. //
27// The full detector type is composed as: //
28// CoarseType*kMaxSegmPerDetType + segmentationType //
29// The only requirement on the segmentationType that should be //
30// < kMaxSegmPerDetType. //
31// The methods like GetLayerDetTypeID return the full detector type //
32// //
33// //
34/////////////////////////////////////////////////////////////////////////
35
36#include <TObject.h>
37#include <TGeoMatrix.h>
38#include <TString.h>
a11ef2e4 39#include <TObjArray.h>
451f5018 40
41class TGeoPNEntry;
42class TDatime;
43
44class AliITSUGeomTGeo : public TObject {
45
46 public:
47 enum {kITSVNA, kITSVUpg}; // ITS version
02d6eccc 48 enum {kDetTypePix=0, kNDetTypes, kMaxSegmPerDetType=10}; // defined detector types (each one can have different segmentations)
451f5018 49 //
50 AliITSUGeomTGeo(Bool_t build = kFALSE);
51 virtual ~AliITSUGeomTGeo();
52 AliITSUGeomTGeo(const AliITSUGeomTGeo &src);
53 AliITSUGeomTGeo& operator=(const AliITSUGeomTGeo &geom);
54 //
02d6eccc 55 Int_t GetNModules() const {return fNModules;}
56 Int_t GetNDetectors(Int_t lay) const {return fNDetectors[lay];}
57 Int_t GetNLadders(Int_t lay) const {return fNLadders[lay];}
58 Int_t GetNLayers() const {return fNLayers;}
451f5018 59
02d6eccc 60 Int_t GetModuleIndex(Int_t lay,int detInLay) const {return GetFirstModIndex(lay)+detInLay;}
451f5018 61 Int_t GetModuleIndex(Int_t lay,Int_t lad,Int_t det) const;
62 Bool_t GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det) const;
63 Int_t GetLayer(Int_t index) const;
64 Int_t GetLadder(Int_t index) const;
65 Int_t GetModIdInLayer(Int_t index) const;
66 Int_t GetModIdInLadder(Int_t index) const;
67 //
68 Int_t GetLastModIndex(Int_t lay) const {return fLastModIndex[lay];}
69 Int_t GetFirstModIndex(Int_t lay) const {return (lay==0) ? 0:fLastModIndex[lay-1]+1;}
70 //
71 const char *GetSymName(Int_t index) const;
72 const char *GetSymName(Int_t lay,Int_t lad,Int_t det) const;
73 //
74 // Attention: these are the matrices for the alignable volumes of the modules, i.e. not necessarily the sensors
75 TGeoHMatrix* GetMatrix(Int_t index) const;
76 TGeoHMatrix* GetMatrix(Int_t lay,Int_t lad,Int_t det) const;
77 Bool_t GetTranslation(Int_t index, Double_t t[3]) const;
78 Bool_t GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const;
79 Bool_t GetRotation(Int_t index, Double_t r[9]) const;
80 Bool_t GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const;
81 Bool_t GetOrigMatrix(Int_t index, TGeoHMatrix &m) const;
82 Bool_t GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const;
83 Bool_t GetOrigTranslation(Int_t index, Double_t t[3]) const;
84 Bool_t GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const;
85 Bool_t GetOrigRotation(Int_t index, Double_t r[9]) const;
86 Bool_t GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const;
87 //
cf457606 88 const TGeoHMatrix* GetMatrixT2L(Int_t index);
89 const TGeoHMatrix* GetMatrixT2L(Int_t lay,Int_t lad,Int_t det) {return GetMatrixT2L( GetModuleIndex(lay,lad,det) );}
90 const TGeoHMatrix* GetMatrixSens(Int_t index);
91 const TGeoHMatrix* GetMatrixSens(Int_t lay,Int_t lad,Int_t det) {return GetMatrixSens( GetModuleIndex(lay,lad,det) );}
451f5018 92 //
cf457606 93 Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m);
94 Bool_t GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m);
451f5018 95 //
96 // Attention: these are transformations wrt sensitive volume!
cf457606 97 void LocalToGlobal(Int_t index, const Double_t *loc, Double_t *glob);
98 void LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob);
451f5018 99 //
cf457606 100 void GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc);
101 void GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc);
451f5018 102 //
cf457606 103 void LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob);
104 void GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc);
451f5018 105 Int_t GetLayerDetTypeID(Int_t lr) const;
106 Int_t GetModuleDetTypeID(Int_t id) const;
107 //
02d6eccc 108 virtual void Print(Option_t *opt="") const;
109
cf457606 110 static const char* GetITSVolPattern() {return fgkITSVolName;}
111 static const char* GetITSLayerPattern() {return fgkITSLrName;}
112 static const char* GetITSLadderPattern() {return fgkITSLadName;}
113 static const char* GetITSModulePattern() {return fgkITSModName;}
114 static const char* GetITSSensorPattern() {return fgkITSSensName;}
cf457606 115 static const char* GetITSsegmentationFileName() {return fgITSsegmFileName.Data();}
75875328 116 static const char* GetDetTypeName(Int_t i);
cf457606 117 static void SetITSsegmentationFileName(const char* nm) {fgITSsegmFileName = nm;}
451f5018 118 static UInt_t ComposeDetTypeID(UInt_t segmId);
119 //
02d6eccc 120 // hack to avoid using AliGeomManager
cf457606 121 Int_t LayerToVolUID(Int_t lay,int detInLay) const {return GetModuleIndex(lay,detInLay);}
122 static Int_t ModuleVolUID(Int_t mod) {return mod;}
123 //
124 protected:
125 void FetchMatrices();
126 TGeoHMatrix* ExtractMatrixT2L(Int_t index) const;
127 TGeoHMatrix* ExtractMatrixSens(Int_t index) const;
128 Bool_t GetLayer(Int_t index,Int_t &lay,Int_t &index2) const;
129 TGeoPNEntry* GetPNEntry(Int_t index) const;
130 Int_t ExtractNumberOfDetectors(Int_t lay) const;
131 Int_t ExtractNumberOfLadders(Int_t lay) const;
132 Int_t ExtractLayerDetType(Int_t lay) const;
133 Int_t ExtractNumberOfLayers() const;
134 void BuildITS();
02d6eccc 135 //
451f5018 136 private:
137//
451f5018 138 //
139 Int_t fVersion; // ITS Version
140 Int_t fNLayers; // number of layers
141 Int_t fNModules; //[fNLayers] The total number of modules
142 Int_t *fNLadders; //[fNLayers] Array of the number of ladders/layer(layer)
143 Int_t *fLrDetType; //[fNLayers] Array of layer detector types
144 Int_t *fNDetectors; //[fNLayers] Array of the number of detector/ladder(layer)
145 Int_t *fLastModIndex; //[fNLayers] max ID of the detctor in the layer
146 //
cf457606 147 TObjArray* fMatSens; // Sensor's matrices pointers in the geometry
148 TObjArray* fMatT2L; // Tracking to Local matrices pointers in the geometry
149 //
451f5018 150 static const char* fgkITSVolName; // ITS mother volume name
151 static const char* fgkITSLrName; // ITS Layer name
152 static const char* fgkITSLadName; // ITS Ladder name
153 static const char* fgkITSModName; // ITS Module name
154 static const char* fgkITSSensName; // ITS Sensor name
155 static const char* fgkITSDetTypeName[kNDetTypes]; // ITS upg detType Names
156 //
157 static TString fgITSsegmFileName; // file name for segmentations
158 //
159 ClassDef(AliITSUGeomTGeo, 1) // ITS geometry based on TGeo
160};
161
162//_____________________________________________________________________________________________
163inline const char *AliITSUGeomTGeo::GetSymName(Int_t lay,Int_t lad,Int_t det) const
164{
165 // sym name
166 return GetSymName(GetModuleIndex(lay,lad,det));
167}
168
169//_____________________________________________________________________________________________
170inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t lay,Int_t lad,Int_t det) const
171{
172 // module current matrix
173 return GetMatrix(GetModuleIndex(lay,lad,det));
174}
175
176//_____________________________________________________________________________________________
177inline Bool_t AliITSUGeomTGeo::GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const
178{
179 // translation
180 return GetTranslation(GetModuleIndex(lay,lad,det),t);
181}
182
183//_____________________________________________________________________________________________
184inline Bool_t AliITSUGeomTGeo::GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const
185{
186 // rot
187 return GetRotation(GetModuleIndex(lay,lad,det),r);
188}
189
190//_____________________________________________________________________________________________
191inline Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const
192{
193 // orig matrix
194 return GetOrigMatrix(GetModuleIndex(lay,lad,det),m);
195}
196
197//_____________________________________________________________________________________________
198inline Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const
199{
200 // orig trans
201 return GetOrigTranslation(GetModuleIndex(lay,lad,det),t);
202}
203
204//_____________________________________________________________________________________________
205inline Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const
206{
207 // orig rot
208 return GetOrigRotation(GetModuleIndex(lay,lad,det),r);
209}
210
211//_____________________________________________________________________________________________
cf457606 212inline Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m)
451f5018 213{
cf457606 214 // tracking mat
215 return GetTrackingMatrix(GetModuleIndex(lay,lad,det),m);
451f5018 216}
217
218//_____________________________________________________________________________________________
cf457606 219inline Int_t AliITSUGeomTGeo::GetLayerDetTypeID(Int_t lr) const
451f5018 220{
cf457606 221 // detector type ID of layer
222 return fLrDetType[lr];
451f5018 223}
224
225//_____________________________________________________________________________________________
cf457606 226inline Int_t AliITSUGeomTGeo::GetModuleDetTypeID(Int_t id) const
451f5018 227{
cf457606 228 // detector type ID of module
229 return GetLayerDetTypeID(GetLayer(id));
230}
451f5018 231
232//_____________________________________________________________________________________________
cf457606 233inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t index)
451f5018 234{
cf457606 235 // access global to sensor matrix
236 if (!fMatSens) FetchMatrices();
237 return (TGeoHMatrix*)fMatSens->At(index);
451f5018 238}
239
240//_____________________________________________________________________________________________
cf457606 241inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixT2L(Int_t index)
451f5018 242{
cf457606 243 // access tracking to local matrix
244 if (!fMatT2L) FetchMatrices();
245 return (TGeoHMatrix*)fMatT2L->At(index);
246}
247
248//______________________________________________________________________
249inline void AliITSUGeomTGeo::LocalToGlobal(Int_t index,const Double_t *loc, Double_t *glob)
250{
251 // sensor local to global
252 GetMatrixSens(index)->LocalToMaster(loc,glob);
253}
254
255//______________________________________________________________________
256inline void AliITSUGeomTGeo::GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc)
257{
258 // global to sensor local
259 GetMatrixSens(index)->MasterToLocal(glob,loc);
260}
261
262//______________________________________________________________________
263inline void AliITSUGeomTGeo::LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob)
264{
265 // sensor local to global
266 GetMatrixSens(index)->LocalToMasterVect(loc,glob);
267}
268
269//______________________________________________________________________
270inline void AliITSUGeomTGeo::GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc)
271{
272 // global to sensor local
273 GetMatrixSens(index)->MasterToLocalVect(glob,loc);
451f5018 274}
275
276//_____________________________________________________________________________________________
cf457606 277inline void AliITSUGeomTGeo::LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob)
451f5018 278{
cf457606 279 // Local2Master (sensor)
280 LocalToGlobal(GetModuleIndex(lay,lad,det), loc, glob);
451f5018 281}
282
283//_____________________________________________________________________________________________
cf457606 284inline void AliITSUGeomTGeo::GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc)
451f5018 285{
cf457606 286 // master2local (sensor)
287 GlobalToLocal(GetModuleIndex(lay,lad,det), glob, loc);
288}
451f5018 289
75875328 290//_____________________________________________________________________________________________
291inline const char* AliITSUGeomTGeo::GetDetTypeName(Int_t i)
292{
293 if (i>=kNDetTypes) i/=kMaxSegmPerDetType; // full type is provided
294 return fgkITSDetTypeName[i];
295}
451f5018 296
297#endif