1 #ifndef ALIITSUGEOMTGEO_H
2 #define ALIITSUGEOMTGEO_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6 /////////////////////////////////////////////////////////////////////////
7 // AliITSUGeomTGeo is a simple interface class to TGeoManager //
8 // It is used in the simulation and reconstruction in order to //
9 // query the TGeo ITS geometry //
11 // author - cvetan.cheshkov@cern.ch //
13 // adapted to ITSupg 18/07/2012 - ruben.shahoyan@cern.ch //
14 // RS: in order to preserve the static character of the class but //
15 // make it dynamically access geometry, we need to check in every //
16 // method if the structures are initialized. To be converted to //
17 // singleton at later stage. //
19 // Note on the upgrade detector types: //
20 // The coarse type defines detectors served by different classes, //
21 // like PixUpg. Each such a detector type can have kMaxSegmPerDetType //
22 // segmentations (pitch etc.) whose parameteres are stored in the //
23 // AliITSsegmentation derived class (like AliITSUSegmentationPix) //
24 // This allows to have in the setup modules served by the same //
25 // classes but with different segmentations. //
26 // The full detector type is composed as: //
27 // CoarseType*kMaxSegmPerDetType + segmentationType //
28 // The only requirement on the segmentationType that should be //
29 // < kMaxSegmPerDetType. //
30 // The methods like GetLayerDetTypeID return the full detector type //
33 /////////////////////////////////////////////////////////////////////////
36 #include <TGeoMatrix.h>
42 class AliITSUGeomTGeo : public TObject {
45 enum {kITSVNA, kITSVUpg}; // ITS version
46 enum {kDetTypePixUpg=0, kNDetTypes, kMaxSegmPerDetType=10}; // defined detector types (each one can have different segmentations)
48 AliITSUGeomTGeo(Bool_t build = kFALSE);
49 virtual ~AliITSUGeomTGeo();
50 AliITSUGeomTGeo(const AliITSUGeomTGeo &src);
51 AliITSUGeomTGeo& operator=(const AliITSUGeomTGeo &geom);
53 Int_t GetNModules() const {return fNModules;}
54 Int_t GetNDetectors(Int_t lay) const {return fNDetectors[lay];}
55 Int_t GetNLadders(Int_t lay) const {return fNLadders[lay];}
56 Int_t GetNLayers() const {return fNLayers;}
58 Int_t GetModuleIndex(Int_t lay,Int_t lad,Int_t det) const;
59 Bool_t GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det) const;
60 Int_t GetLayer(Int_t index) const;
61 Int_t GetLadder(Int_t index) const;
62 Int_t GetModIdInLayer(Int_t index) const;
63 Int_t GetModIdInLadder(Int_t index) const;
65 Int_t GetLastModIndex(Int_t lay) const {return fLastModIndex[lay];}
66 Int_t GetFirstModIndex(Int_t lay) const {return (lay==0) ? 0:fLastModIndex[lay-1]+1;}
68 const char *GetSymName(Int_t index) const;
69 const char *GetSymName(Int_t lay,Int_t lad,Int_t det) const;
71 // Attention: these are the matrices for the alignable volumes of the modules, i.e. not necessarily the sensors
72 TGeoHMatrix* GetMatrix(Int_t index) const;
73 TGeoHMatrix* GetMatrix(Int_t lay,Int_t lad,Int_t det) const;
74 Bool_t GetTranslation(Int_t index, Double_t t[3]) const;
75 Bool_t GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const;
76 Bool_t GetRotation(Int_t index, Double_t r[9]) const;
77 Bool_t GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const;
78 Bool_t GetOrigMatrix(Int_t index, TGeoHMatrix &m) const;
79 Bool_t GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const;
80 Bool_t GetOrigTranslation(Int_t index, Double_t t[3]) const;
81 Bool_t GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const;
82 Bool_t GetOrigRotation(Int_t index, Double_t r[9]) const;
83 Bool_t GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const;
85 const TGeoHMatrix* GetTracking2LocalMatrix(Int_t index) const;
86 const TGeoHMatrix* GetTracking2LocalMatrix(Int_t lay,Int_t lad,Int_t det) const;
88 Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m) const;
89 Bool_t GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const;
91 // Attention: these are transformations wrt sensitive volume!
92 TGeoHMatrix* GetMatrixSens(Int_t index) const;
93 TGeoHMatrix* GetMatrixSens(Int_t lay,Int_t lad,Int_t det) const;
94 Bool_t LocalToGlobal(Int_t index, const Double_t *loc, Double_t *glob) const;
95 Bool_t LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob) const;
97 Bool_t GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc) const;
98 Bool_t GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc) const;
100 Bool_t LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob) const;
101 Bool_t GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc) const;
102 Int_t GetLayerDetTypeID(Int_t lr) const;
103 Int_t GetModuleDetTypeID(Int_t id) const;
105 static const char* GetITSVolPattern() {return fgkITSVolName;}
106 static const char* GetITSLayerPattern() {return fgkITSLrName;}
107 static const char* GetITSLadderPattern() {return fgkITSLadName;}
108 static const char* GetITSModulePattern() {return fgkITSModName;}
109 static const char* GetITSSensorPattern() {return fgkITSSensName;}
110 static const char* GetDetTypeName(Int_t i) {return (i<0||i>=kNDetTypes) ? 0 : fgkITSDetTypeName[i];}
111 static const char* GetITSsegmentationFileName() {return fgITSsegmFileName.Data();}
112 static void SetITSsegmentationFileName(const char* nm) {fgITSsegmFileName = nm;}
113 static UInt_t ComposeDetTypeID(UInt_t segmId);
117 Bool_t GetLayer(Int_t index,Int_t &lay,Int_t &index2) const;
118 TGeoPNEntry* GetPNEntry(Int_t index) const;
119 Int_t ExtractNumberOfDetectors(Int_t lay) const;
120 Int_t ExtractNumberOfLadders(Int_t lay) const;
121 Int_t ExtractLayerDetType(Int_t lay) const;
122 Int_t ExtractNumberOfLayers() const;
125 Int_t fVersion; // ITS Version
126 Int_t fNLayers; // number of layers
127 Int_t fNModules; //[fNLayers] The total number of modules
128 Int_t *fNLadders; //[fNLayers] Array of the number of ladders/layer(layer)
129 Int_t *fLrDetType; //[fNLayers] Array of layer detector types
130 Int_t *fNDetectors; //[fNLayers] Array of the number of detector/ladder(layer)
131 Int_t *fLastModIndex; //[fNLayers] max ID of the detctor in the layer
133 static const char* fgkITSVolName; // ITS mother volume name
134 static const char* fgkITSLrName; // ITS Layer name
135 static const char* fgkITSLadName; // ITS Ladder name
136 static const char* fgkITSModName; // ITS Module name
137 static const char* fgkITSSensName; // ITS Sensor name
138 static const char* fgkITSDetTypeName[kNDetTypes]; // ITS upg detType Names
140 static TString fgITSsegmFileName; // file name for segmentations
142 ClassDef(AliITSUGeomTGeo, 1) // ITS geometry based on TGeo
145 //_____________________________________________________________________________________________
146 inline const char *AliITSUGeomTGeo::GetSymName(Int_t lay,Int_t lad,Int_t det) const
149 return GetSymName(GetModuleIndex(lay,lad,det));
152 //_____________________________________________________________________________________________
153 inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t lay,Int_t lad,Int_t det) const
155 // module current matrix
156 return GetMatrix(GetModuleIndex(lay,lad,det));
159 //_____________________________________________________________________________________________
160 inline Bool_t AliITSUGeomTGeo::GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const
163 return GetTranslation(GetModuleIndex(lay,lad,det),t);
166 //_____________________________________________________________________________________________
167 inline Bool_t AliITSUGeomTGeo::GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const
170 return GetRotation(GetModuleIndex(lay,lad,det),r);
173 //_____________________________________________________________________________________________
174 inline Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const
177 return GetOrigMatrix(GetModuleIndex(lay,lad,det),m);
180 //_____________________________________________________________________________________________
181 inline Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const
184 return GetOrigTranslation(GetModuleIndex(lay,lad,det),t);
187 //_____________________________________________________________________________________________
188 inline Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const
191 return GetOrigRotation(GetModuleIndex(lay,lad,det),r);
194 //_____________________________________________________________________________________________
195 inline const TGeoHMatrix* AliITSUGeomTGeo::GetTracking2LocalMatrix(Int_t lay,Int_t lad,Int_t det) const
198 return GetTracking2LocalMatrix(GetModuleIndex(lay,lad,det));
201 //_____________________________________________________________________________________________
202 inline Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const
205 return GetTrackingMatrix(GetModuleIndex(lay,lad,det),m);
208 //_____________________________________________________________________________________________
209 inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t index) const
213 return GetModuleId(index,lr,ld,dt) ? GetMatrixSens(GetModuleIndex(lr,ld,dt)) : 0;
216 //_____________________________________________________________________________________________
217 inline Bool_t AliITSUGeomTGeo::LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob) const
219 // Local2Master (sensor)
220 return LocalToGlobal(GetModuleIndex(lay,lad,det), loc, glob);
223 //_____________________________________________________________________________________________
224 inline Bool_t AliITSUGeomTGeo::GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc) const
226 // master2local (sensor)
227 return GlobalToLocal(GetModuleIndex(lay,lad,det), glob, loc);
230 //_____________________________________________________________________________________________
231 inline Int_t AliITSUGeomTGeo::GetLayerDetTypeID(Int_t lr) const
233 // detector type ID of layer
234 return fLrDetType[lr];
237 //_____________________________________________________________________________________________
238 inline Int_t AliITSUGeomTGeo::GetModuleDetTypeID(Int_t id) const
240 // detector type ID of module
241 return GetLayerDetTypeID(GetLayer(id));