]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliGeomManager.h
Change according to Federico's suggestions (Massimo)
[u/mrichter/AliRoot.git] / STEER / AliGeomManager.h
1 #ifndef ALI_GEOM_MANAGER_H
2 #define ALI_GEOM_MANAGER_H
3
4 //
5 // Class for interfacing to the geometry; it also builds and manages two
6 // look-up tables for fast access to volumes :
7 // 1) the look-up table mapping unique volume ids to symbolic volume names
8 // 2) the look-up table mapping unique volume ids to TGeoPNEntries
9 // this allows to access directly the functionality of the physical node
10 // associated to a given alignable volume by means of its index
11 //
12
13 #include <TObject.h>
14
15 class TGeoManager;
16 class TGeoPNEntry;
17 class TGeoHMatrix;
18
19 class TObjArray;
20
21 class AliAlignObj;
22 class AliCDBId;
23 class AliCDBParam;
24
25 class AliGeomManager: public TObject {
26
27 public:
28   enum ELayerID{kInvalidLayer=0,
29                 kFirstLayer=1,
30                 kSPD1=1, kSPD2=2,
31                 kSDD1=3, kSDD2=4,
32                 kSSD1=5, kSSD2=6,
33                 kTPC1=7, kTPC2=8,
34                 kTRD1=9, kTRD2=10, kTRD3=11, kTRD4=12, kTRD5=13, kTRD6=14,
35                 kTOF=15,
36                 kPHOS1=16, kPHOS2=17,
37                 kHMPID=18,
38                 kMUON=19,
39                 kEMCAL=20,
40                 kLastLayer=21};
41
42   static TGeoManager* GetGeometry() { return fgGeometry; }
43
44   static Int_t       LayerSize(Int_t layerId);
45   static const char* LayerName(Int_t layerId);
46   static UShort_t LayerToVolUID(ELayerID layerId, Int_t modId);
47   static UShort_t LayerToVolUID(Int_t    layerId, Int_t modId);
48   static ELayerID VolUIDToLayer(UShort_t voluid, Int_t &modId);
49   static ELayerID VolUIDToLayer(UShort_t voluid);
50   static UShort_t LayerToVolUIDSafe(ELayerID layerId, Int_t modId);
51   static UShort_t LayerToVolUIDSafe(Int_t    layerId, Int_t modId);
52   static ELayerID VolUIDToLayerSafe(UShort_t voluid, Int_t &modId);
53   static ELayerID VolUIDToLayerSafe(UShort_t voluid);
54
55   static const char* SymName(UShort_t voluid);
56   static const char* SymName(ELayerID layerId, Int_t modId);
57
58   static Bool_t   GetFromGeometry(const char *symname, AliAlignObj &alobj);
59   static AliAlignObj* GetAlignObj(UShort_t voluid);
60   static AliAlignObj* GetAlignObj(ELayerID layerId, Int_t modId);
61
62   //to be used making a copy of the returned pointer to TGeoHMatrix!!
63   static TGeoHMatrix* GetMatrix(Int_t index);
64   static TGeoHMatrix* GetMatrix(const char *symname);
65   static Bool_t GetTranslation(Int_t index, Double_t t[3]);
66   static Bool_t GetRotation(Int_t index, Double_t r[9]);
67
68   static Bool_t GetDeltaForBranch(AliAlignObj& aao, TGeoHMatrix &inclusiveD);
69   static Bool_t GetDeltaForBranch(Int_t index, TGeoHMatrix &inclusiveD);
70   static TGeoHMatrix* GetOrigGlobalMatrix(Int_t index);
71   static Bool_t GetOrigGlobalMatrix(const char *symname, TGeoHMatrix &m);
72   static Bool_t GetOrigTranslation(Int_t index, Double_t t[3]);
73   static Bool_t GetOrigRotation(Int_t index, Double_t r[9]);
74
75   static const TGeoHMatrix* GetTracking2LocalMatrix(Int_t index);
76   static Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m);
77
78   static void        LoadGeometry(const char *geomFileName = NULL);
79   static void        SetGeometry(TGeoManager *geom);
80   static void        CheckOverlapsOverPNs(Double_t threshold);  
81
82   static Bool_t         ApplyAlignObjsToGeom(TObjArray& alObjArray, Bool_t ovlpcheck=kFALSE);
83
84   static Bool_t         ApplyAlignObjsToGeom(const char* fileName,
85                                       const char* clArrayName);
86   static Bool_t         ApplyAlignObjsToGeom(AliCDBParam* param,
87                                       AliCDBId& Id);
88   static Bool_t         ApplyAlignObjsToGeom(const char* uri, const char* path,
89                                       Int_t runnum, Int_t version,
90                                       Int_t sversion);
91   static Bool_t         ApplyAlignObjsToGeom(const char* detName, Int_t runnum, Int_t version,
92                                       Int_t sversion);
93   static Bool_t         ApplyAlignObjsFromCDB(const char* AlDetsList);
94   static Bool_t         LoadAlignObjsFromCDBSingleDet(const char* detName, TObjArray& alignObjArray);
95
96   ~AliGeomManager();
97
98  private:
99   AliGeomManager();
100   AliGeomManager(const AliGeomManager&);
101   AliGeomManager& operator=(const AliGeomManager&);
102
103   static TGeoHMatrix* GetMatrix(TGeoPNEntry* pne);
104   static TGeoHMatrix* GetOrigGlobalMatrix(TGeoPNEntry* pne);
105   static Bool_t       GetOrigGlobalMatrixFromPath(const char *path, TGeoHMatrix &m);
106
107   static TGeoPNEntry* GetPNEntry(Int_t index);
108   static TGeoPNEntry* GetPNEntry(ELayerID layerId, Int_t modId);
109
110   static void        InitAlignObjFromGeometry();
111   static void        InitSymNamesLUT();
112   static void        InitPNEntriesLUT();
113   static void        InitOrigMatricesLUT();
114
115   static TGeoManager* fgGeometry;
116
117   static Int_t       fgLayerSize[kLastLayer - kFirstLayer]; // Size of layers
118   static const char* fgLayerName[kLastLayer - kFirstLayer]; // Name of layers
119   static TString*    fgSymName[kLastLayer - kFirstLayer]; // Symbolic volume names
120   static TGeoPNEntry** fgPNEntry[kLastLayer - kFirstLayer]; // TGeoPNEntries
121   static TGeoHMatrix** fgOrigMatrix[kLastLayer - kFirstLayer]; // Original matrices before misalignment
122   static AliAlignObj** fgAlignObjs[kLastLayer - kFirstLayer]; // Alignment objects
123
124   ClassDef(AliGeomManager, 0);
125 };
126
127 #endif