]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGeometryTransformer.h
Corrected some manu Id's in mapping for slat and updated the serial manu numbers
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryTransformer.h
1 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
2  * See cxx source for full Copyright notice                               */
3
4 // $Id$
5
6 /// \ingroup geometry
7 /// \class AliMUONGeometryTransformer
8 /// \brief Top container class for geometry transformations
9 ///
10 /// Geometry transformations can be filled in these ways:
11 /// - by geometry builder when geometry is built via builders
12 /// - from Root geometry file (*.root) or Root geometry manager
13 /// - from ASCII file (*.dat)
14 /// If geometry is loaded from a file, the list of aligned volume paths
15 /// has to be read first from volpaths.dat file.
16 /// 
17 /// \author Ivana Hrivnacova, IPN Orsay
18
19 #ifndef ALI_MUON_GEOMETRY_TRANSFORMER_H
20 #define ALI_MUON_GEOMETRY_TRANSFORMER_H
21
22 #include <TObject.h>
23 #include <TObjArray.h>
24 #include <TGeoMatrix.h>
25
26 class AliMUONGeometryModuleTransformer;
27 class AliMUONGeometryDetElement;
28
29 class TGeoManager;
30 class TClonesArray;
31
32 class AliMUONGeometryTransformer : public TObject
33 {
34   public:
35     AliMUONGeometryTransformer(Bool_t isOwner, const TString& detName = "MUON");
36     AliMUONGeometryTransformer();
37     virtual  ~AliMUONGeometryTransformer();
38     
39     // methods
40     void  AddModuleTransformer(AliMUONGeometryModuleTransformer* transformer);
41     void  AddMisAlignModule(Int_t moduleId, const TGeoHMatrix& matrix);
42     void  AddMisAlignDetElement(Int_t detElemId, const TGeoHMatrix& matrix);
43
44     void  AddAlignableVolumes() const; 
45     TClonesArray* CreateZeroAlignmentData() const;
46     void  ClearMisAlignmentData();                             
47
48     // IO
49     //
50     Bool_t  ReadGeometryData(const TString& volPathFileName,
51                              const TString& transformFileName);
52     Bool_t  ReadGeometryData(const TString& volPathFileName,
53                              TGeoManager* geoManager);
54
55     Bool_t  WriteGeometryData(const TString& volPathFileName,
56                              const TString& transformFileName,
57                              const TString& misalignFileName = "") const;
58    
59     Bool_t  WriteVolumePaths(const TString& fileName) const;
60     Bool_t  WriteTransformations(const TString& fileName) const;
61     Bool_t  WriteMisAlignmentData(const TString& fileName) const;
62
63     // Transformation methods 
64     //
65     void Global2Local(Int_t detElemId,
66                  Float_t xg, Float_t yg, Float_t zg, 
67                  Float_t& xl, Float_t& yl, Float_t& zl) const;
68     void Global2Local(Int_t detElemId,
69                  Double_t xg, Double_t yg, Double_t zg, 
70                  Double_t& xl, Double_t& yl, Double_t& zl) const;
71
72     void Local2Global(Int_t detElemId,
73                  Float_t xl, Float_t yl, Float_t zl, 
74                  Float_t& xg, Float_t& yg, Float_t& zg) const;
75     void Local2Global(Int_t detElemId,
76                  Double_t xl, Double_t yl, Double_t zl, 
77                  Double_t& xg, Double_t& yg, Double_t& zg) const;
78
79     // Get methods
80     //
81     Int_t GetNofModuleTransformers() const;
82     const AliMUONGeometryModuleTransformer* GetModuleTransformer(
83                                Int_t index, Bool_t warn = true) const;
84
85     const AliMUONGeometryModuleTransformer* GetModuleTransformerByDEId(
86                                Int_t detElemId, Bool_t warn = true) const;
87
88     const AliMUONGeometryDetElement* GetDetElement(
89                                Int_t detElemId, Bool_t warn = true) const;
90
91     const TClonesArray* GetMisAlignmentData() const;
92     
93     Bool_t  HasDE(Int_t detElemId) const;
94
95   protected:
96     AliMUONGeometryTransformer(const AliMUONGeometryTransformer& right);
97     AliMUONGeometryTransformer&  operator = (const AliMUONGeometryTransformer& right);
98  
99   private:
100     // methods
101     AliMUONGeometryModuleTransformer* GetModuleTransformerNonConst(
102                                     Int_t index, Bool_t warn = true) const;
103
104     TGeoHMatrix GetTransform(
105                   Double_t x, Double_t y, Double_t z,
106                   Double_t a1, Double_t a2, Double_t a3, 
107                   Double_t a4, Double_t a5, Double_t a6) const;
108
109     void FillModuleVolPath(Int_t moduleId, const TString& volPath); 
110     void FillDetElemVolPath(Int_t detElemId, const TString& volPath); 
111
112     void FillModuleTransform(Int_t moduleId,
113                   Double_t x, Double_t y, Double_t z,
114                   Double_t a1, Double_t a2, Double_t a3, 
115                   Double_t a4, Double_t a5, Double_t a6); 
116     void FillDetElemTransform(Int_t id, 
117                   Double_t x, Double_t y, Double_t z,
118                   Double_t a1, Double_t a2, Double_t a3, 
119                   Double_t a4, Double_t a5, Double_t a6);
120
121     Bool_t  ReadVolPaths(ifstream& in);
122     TString ReadModuleTransforms(ifstream& in);
123     TString ReadDetElemTransforms(ifstream& in);
124     Bool_t  LoadTransforms(TGeoManager* tgeoManager); 
125
126     Bool_t  ReadVolPaths(const TString& fileName);
127     Bool_t  ReadTransformations(const TString& fileName);
128     Bool_t  ReadTransformations2(const TString& fileName);
129
130     void    WriteTransform(ofstream& out, const TGeoMatrix* transform) const;
131     void    WriteModuleVolPaths(ofstream& out) const;
132     void    WriteDetElemVolPaths(ofstream& out) const;
133     void    WriteModuleTransforms(ofstream& out) const;
134     void    WriteDetElemTransforms(ofstream& out) const;
135     
136     TString GetModuleSymName(Int_t moduleId) const;
137     TString GetDESymName(Int_t detElemId) const;
138
139     // data members
140     TString        fDetectorName;       ///< Detector name
141     TObjArray*     fModuleTransformers; ///< array of module transformers
142     TClonesArray*  fMisAlignArray;      ///< array of misalignment data
143
144   ClassDef(AliMUONGeometryTransformer,2)  // Geometry parametrisation
145 };
146
147 // inline methods
148
149 /// Return the number of contained module transformers
150 inline Int_t AliMUONGeometryTransformer::GetNofModuleTransformers() const
151 { return fModuleTransformers->GetEntriesFast(); }
152
153 /// Return the array of misalignment data
154 inline const TClonesArray* AliMUONGeometryTransformer::GetMisAlignmentData() const      
155 { return fMisAlignArray; }                     
156
157 #endif //ALI_MUON_GEOMETRY_TRANSFORMER_H
158
159
160
161
162
163
164