]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUGeomTGeo.h
1) Added classes for digitization
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUGeomTGeo.h
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                               */
5
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                                        //
10 //                                                                     //
11 //  author - cvetan.cheshkov@cern.ch                                   //
12 //  15/02/2007                                                         //
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.                                          //
18 //                                                                     //
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   //
31 //                                                                     //
32 //                                                                     //
33 /////////////////////////////////////////////////////////////////////////
34
35 #include <TObject.h>
36 #include <TGeoMatrix.h>
37 #include <TString.h>
38
39 class TGeoPNEntry;
40 class TDatime;
41
42 class AliITSUGeomTGeo : public TObject {
43
44  public:
45   enum {kITSVNA, kITSVUpg}; // ITS version
46   enum {kDetTypePixUpg=0, kNDetTypes, kMaxSegmPerDetType=10}; // defined detector types (each one can have different segmentations)
47   //
48   AliITSUGeomTGeo(Bool_t build = kFALSE);
49   virtual ~AliITSUGeomTGeo(); 
50   AliITSUGeomTGeo(const AliITSUGeomTGeo &src);
51   AliITSUGeomTGeo& operator=(const AliITSUGeomTGeo &geom);
52   //
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;}
57   
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;
64   //
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;}
67   //  
68   const char *GetSymName(Int_t index)                                     const;
69   const char *GetSymName(Int_t lay,Int_t lad,Int_t det)                   const;
70   //
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;
84   //
85   const TGeoHMatrix* GetTracking2LocalMatrix(Int_t index)                   const;
86   const TGeoHMatrix* GetTracking2LocalMatrix(Int_t lay,Int_t lad,Int_t det) const;
87   //
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;
90   //
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;
96   //
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;
99   //
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;
104   //
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);
114   //
115  private:
116 //
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;
123   void         BuildITS();
124   //
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
132   //
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
139   //
140   static TString      fgITSsegmFileName;         // file name for segmentations
141   //
142   ClassDef(AliITSUGeomTGeo, 1) // ITS geometry based on TGeo
143 };
144
145 //_____________________________________________________________________________________________
146 inline const char *AliITSUGeomTGeo::GetSymName(Int_t lay,Int_t lad,Int_t det) const    
147 {
148   // sym name
149   return GetSymName(GetModuleIndex(lay,lad,det));
150 }
151
152 //_____________________________________________________________________________________________
153 inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t lay,Int_t lad,Int_t det) const    
154 {
155   // module current matrix
156   return GetMatrix(GetModuleIndex(lay,lad,det));
157 }
158
159 //_____________________________________________________________________________________________
160 inline Bool_t AliITSUGeomTGeo::GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const    
161 {
162   // translation
163   return GetTranslation(GetModuleIndex(lay,lad,det),t); 
164 }
165
166 //_____________________________________________________________________________________________
167 inline Bool_t AliITSUGeomTGeo::GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const    
168 {
169   // rot
170   return GetRotation(GetModuleIndex(lay,lad,det),r); 
171 }
172
173 //_____________________________________________________________________________________________
174 inline Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const    
175 {
176   // orig matrix
177   return GetOrigMatrix(GetModuleIndex(lay,lad,det),m); 
178 }
179
180 //_____________________________________________________________________________________________
181 inline Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const    
182 {
183   // orig trans
184   return GetOrigTranslation(GetModuleIndex(lay,lad,det),t); 
185 }
186
187 //_____________________________________________________________________________________________
188 inline Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const    
189 {
190   // orig rot
191   return GetOrigRotation(GetModuleIndex(lay,lad,det),r); 
192 }
193
194 //_____________________________________________________________________________________________
195 inline const TGeoHMatrix* AliITSUGeomTGeo::GetTracking2LocalMatrix(Int_t lay,Int_t lad,Int_t det) const  
196 {
197   // t2l matrix
198   return GetTracking2LocalMatrix(GetModuleIndex(lay,lad,det)); 
199 }
200
201 //_____________________________________________________________________________________________
202 inline Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const    
203 {
204   // tracking mat
205   return GetTrackingMatrix(GetModuleIndex(lay,lad,det),m); 
206 }
207
208 //_____________________________________________________________________________________________
209 inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t index) const    
210 {
211   // semsor matrix
212   int lr,ld,dt; 
213   return GetModuleId(index,lr,ld,dt) ? GetMatrixSens(GetModuleIndex(lr,ld,dt)) : 0;
214 }
215
216 //_____________________________________________________________________________________________
217 inline Bool_t AliITSUGeomTGeo::LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob) const 
218 {
219   // Local2Master (sensor)
220   return LocalToGlobal(GetModuleIndex(lay,lad,det), loc, glob);
221 }
222
223 //_____________________________________________________________________________________________
224 inline Bool_t AliITSUGeomTGeo::GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc) const 
225 {
226   // master2local (sensor)
227   return GlobalToLocal(GetModuleIndex(lay,lad,det), glob, loc);
228 }
229
230 //_____________________________________________________________________________________________
231 inline Int_t  AliITSUGeomTGeo::GetLayerDetTypeID(Int_t lr) const  
232 {
233   // detector type ID of layer
234   return fLrDetType[lr];
235 }
236
237 //_____________________________________________________________________________________________
238 inline Int_t  AliITSUGeomTGeo::GetModuleDetTypeID(Int_t id) const  
239 {
240   // detector type ID of module
241   return GetLayerDetTypeID(GetLayer(id));
242
243
244
245 #endif