1 #ifndef ALIITSUGEOMTGEO_H
2 #define ALIITSUGEOMTGEO_H
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
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 //
12 // author - cvetan.cheshkov@cern.ch //
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. //
20 // Note on the upgrade detector types: //
21 // The coarse type defines detectors served by different classes, //
22 // like Pix. Each such a detector type can have kMaxSegmPerDetType //
23 // segmentations (pitch etc.) whose parameteres are stored in the //
24 // AliITSsegmentation derived class (like AliITSUSegmentationPix) //
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 //
34 /////////////////////////////////////////////////////////////////////////
37 #include <TGeoMatrix.h>
39 #include <TObjArray.h>
44 class AliITSUGeomTGeo : public TObject {
47 enum {kITSVNA, kITSVUpg}; // ITS version
48 enum {kDetTypePix=0, kNDetTypes, kMaxSegmPerDetType=10}; // defined detector types (each one can have different segmentations)
50 AliITSUGeomTGeo(Bool_t build = kFALSE);
51 virtual ~AliITSUGeomTGeo();
52 AliITSUGeomTGeo(const AliITSUGeomTGeo &src);
53 AliITSUGeomTGeo& operator=(const AliITSUGeomTGeo &geom);
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;}
60 Int_t GetModuleIndex(Int_t lay,int detInLay) const {return GetFirstModIndex(lay)+detInLay;}
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;
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;}
71 const char *GetSymName(Int_t index) const;
72 const char *GetSymName(Int_t lay,Int_t lad,Int_t det) const;
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;
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) );}
93 Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m);
94 Bool_t GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m);
96 // Attention: these are transformations wrt sensitive volume!
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);
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);
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);
105 Int_t GetLayerDetTypeID(Int_t lr) const;
106 Int_t GetModuleDetTypeID(Int_t id) const;
108 virtual void Print(Option_t *opt="") const;
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;}
115 static const char* GetITSsegmentationFileName() {return fgITSsegmFileName.Data();}
116 static const char* GetDetTypeName(Int_t i);
117 static void SetITSsegmentationFileName(const char* nm) {fgITSsegmFileName = nm;}
118 static UInt_t ComposeDetTypeID(UInt_t segmId);
120 static const char *ComposeSymNameITS();
121 static const char *ComposeSymNameLayer(Int_t lr);
122 static const char *ComposeSymNameLadder(Int_t lr, Int_t lad);
123 static const char *ComposeSymNameModule(Int_t lr, Int_t lad, int det);
125 // hack to avoid using AliGeomManager
126 Int_t LayerToVolUID(Int_t lay,int detInLay) const {return GetModuleIndex(lay,detInLay);}
127 static Int_t ModuleVolUID(Int_t mod) {return mod;}
130 void FetchMatrices();
131 void CreateT2LMatrices();
132 TGeoHMatrix* ExtractMatrixT2L(Int_t index) const;
133 TGeoHMatrix* ExtractMatrixSens(Int_t index) const;
134 Bool_t GetLayer(Int_t index,Int_t &lay,Int_t &index2) const;
135 TGeoPNEntry* GetPNEntry(Int_t index) const;
136 Int_t ExtractNumberOfDetectors(Int_t lay) const;
137 Int_t ExtractNumberOfLadders(Int_t lay) const;
138 Int_t ExtractLayerDetType(Int_t lay) const;
139 Int_t ExtractNumberOfLayers() const;
145 Int_t fVersion; // ITS Version
146 Int_t fNLayers; // number of layers
147 Int_t fNModules; // The total number of modules
148 Int_t *fNLadders; //[fNLayers] Array of the number of ladders/layer(layer)
149 Int_t *fLrDetType; //[fNLayers] Array of layer detector types
150 Int_t *fNDetectors; //[fNLayers] Array of the number of detector/ladder(layer)
151 Int_t *fLastModIndex; //[fNLayers] max ID of the detctor in the layer
153 TObjArray* fMatSens; // Sensor's matrices pointers in the geometry
154 TObjArray* fMatT2L; // Tracking to Local matrices pointers in the geometry
156 static const char* fgkITSVolName; // ITS mother volume name
157 static const char* fgkITSLrName; // ITS Layer name
158 static const char* fgkITSLadName; // ITS Ladder name
159 static const char* fgkITSModName; // ITS Module name
160 static const char* fgkITSSensName; // ITS Sensor name
161 static const char* fgkITSDetTypeName[kNDetTypes]; // ITS upg detType Names
163 static TString fgITSsegmFileName; // file name for segmentations
165 ClassDef(AliITSUGeomTGeo, 1) // ITS geometry based on TGeo
168 //_____________________________________________________________________________________________
169 inline const char *AliITSUGeomTGeo::GetSymName(Int_t lay,Int_t lad,Int_t det) const
172 return GetSymName(GetModuleIndex(lay,lad,det));
175 //_____________________________________________________________________________________________
176 inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t lay,Int_t lad,Int_t det) const
178 // module current matrix
179 return GetMatrix(GetModuleIndex(lay,lad,det));
182 //_____________________________________________________________________________________________
183 inline Bool_t AliITSUGeomTGeo::GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const
186 return GetTranslation(GetModuleIndex(lay,lad,det),t);
189 //_____________________________________________________________________________________________
190 inline Bool_t AliITSUGeomTGeo::GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const
193 return GetRotation(GetModuleIndex(lay,lad,det),r);
196 //_____________________________________________________________________________________________
197 inline Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const
200 return GetOrigMatrix(GetModuleIndex(lay,lad,det),m);
203 //_____________________________________________________________________________________________
204 inline Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const
207 return GetOrigTranslation(GetModuleIndex(lay,lad,det),t);
210 //_____________________________________________________________________________________________
211 inline Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const
214 return GetOrigRotation(GetModuleIndex(lay,lad,det),r);
217 //_____________________________________________________________________________________________
218 inline Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m)
221 return GetTrackingMatrix(GetModuleIndex(lay,lad,det),m);
224 //_____________________________________________________________________________________________
225 inline Int_t AliITSUGeomTGeo::GetLayerDetTypeID(Int_t lr) const
227 // detector type ID of layer
228 return fLrDetType[lr];
231 //_____________________________________________________________________________________________
232 inline Int_t AliITSUGeomTGeo::GetModuleDetTypeID(Int_t id) const
234 // detector type ID of module
235 return GetLayerDetTypeID(GetLayer(id));
238 //_____________________________________________________________________________________________
239 inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t index)
241 // access global to sensor matrix
242 if (!fMatSens) FetchMatrices();
243 return (TGeoHMatrix*)fMatSens->At(index);
246 //_____________________________________________________________________________________________
247 inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixT2L(Int_t index)
249 // access tracking to local matrix
250 if (!fMatT2L) FetchMatrices();
251 return (TGeoHMatrix*)fMatT2L->At(index);
254 //______________________________________________________________________
255 inline void AliITSUGeomTGeo::LocalToGlobal(Int_t index,const Double_t *loc, Double_t *glob)
257 // sensor local to global
258 GetMatrixSens(index)->LocalToMaster(loc,glob);
261 //______________________________________________________________________
262 inline void AliITSUGeomTGeo::GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc)
264 // global to sensor local
265 GetMatrixSens(index)->MasterToLocal(glob,loc);
268 //______________________________________________________________________
269 inline void AliITSUGeomTGeo::LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob)
271 // sensor local to global
272 GetMatrixSens(index)->LocalToMasterVect(loc,glob);
275 //______________________________________________________________________
276 inline void AliITSUGeomTGeo::GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc)
278 // global to sensor local
279 GetMatrixSens(index)->MasterToLocalVect(glob,loc);
282 //_____________________________________________________________________________________________
283 inline void AliITSUGeomTGeo::LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob)
285 // Local2Master (sensor)
286 LocalToGlobal(GetModuleIndex(lay,lad,det), loc, glob);
289 //_____________________________________________________________________________________________
290 inline void AliITSUGeomTGeo::GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc)
292 // master2local (sensor)
293 GlobalToLocal(GetModuleIndex(lay,lad,det), glob, loc);
296 //_____________________________________________________________________________________________
297 inline const char* AliITSUGeomTGeo::GetDetTypeName(Int_t i)
299 if (i>=kNDetTypes) i/=kMaxSegmPerDetType; // full type is provided
300 return fgkITSDetTypeName[i];