]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGeometryTransformer.h
New default values for baselines (F.Prino)
[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 ///   (this way is used when running simulation and building geometry
13 ///    via VirtualMC)
14 /// - from Root geometry file (*.root) or ASCII file (*.dat) using
15 ///   the method LoadGeometryData(const TString& fileName)
16 /// - from geometry loaded in AliGeomManager using
17 ///   the method LoadGeometryData() without arguments
18 /// 
19 /// \author Ivana Hrivnacova, IPN Orsay
20
21 #ifndef ALI_MUON_GEOMETRY_TRANSFORMER_H
22 #define ALI_MUON_GEOMETRY_TRANSFORMER_H
23
24 #include <TObject.h>
25 #include <TObjArray.h>
26 #include <TGeoMatrix.h>
27
28 class AliMUONGeometryModuleTransformer;
29 class AliMUONGeometryDetElement;
30
31 class TGeoManager;
32 class TClonesArray;
33 class AliMpExMap;
34 class AliMpArea;
35
36 class AliMUONGeometryTransformer : public TObject
37 {
38   public:
39     AliMUONGeometryTransformer();
40     AliMUONGeometryTransformer(TRootIOCtor* /*ioCtor*/);
41     virtual  ~AliMUONGeometryTransformer();
42     
43     // methods
44     void  AddModuleTransformer(AliMUONGeometryModuleTransformer* transformer);
45     void  AddMisAlignModule(Int_t moduleId, const TGeoHMatrix& matrix);
46     void  AddMisAlignDetElement(Int_t detElemId, const TGeoHMatrix& matrix);
47     void  CreateModules();
48
49     void  AddAlignableVolumes() const; 
50     TClonesArray* CreateZeroAlignmentData() const;
51     void  ClearMisAlignmentData();      
52
53     // IO
54     //
55     Bool_t  LoadGeometryData(const TString& fileName);
56     Bool_t  LoadGeometryData();
57
58     Bool_t  WriteTransformations(const TString& fileName) const;
59     Bool_t  WriteMisAlignmentData(const TString& fileName) const;
60
61     // Transformation methods 
62     //
63     void Global2Local(Int_t detElemId,
64                  Float_t xg, Float_t yg, Float_t zg, 
65                  Float_t& xl, Float_t& yl, Float_t& zl) const;
66     void Global2Local(Int_t detElemId,
67                  Double_t xg, Double_t yg, Double_t zg, 
68                  Double_t& xl, Double_t& yl, Double_t& zl) const;
69
70     void Local2Global(Int_t detElemId,
71                  Float_t xl, Float_t yl, Float_t zl, 
72                  Float_t& xg, Float_t& yg, Float_t& zg) const;
73     void Local2Global(Int_t detElemId,
74                  Double_t xl, Double_t yl, Double_t zl, 
75                  Double_t& xg, Double_t& yg, Double_t& zg) const;
76                  
77     // Set methods
78     void SetDetName(const TString& detName);                 
79     void SetOwner(Bool_t isOwner);                 
80
81     // Get methods
82     //
83     Int_t GetNofModuleTransformers() const;
84     const AliMUONGeometryModuleTransformer* GetModuleTransformer(
85                                Int_t index, Bool_t warn = true) const;
86
87     const AliMUONGeometryModuleTransformer* GetModuleTransformerByDEId(
88                                Int_t detElemId, Bool_t warn = true) const;
89
90     const AliMUONGeometryDetElement* GetDetElement(
91                                Int_t detElemId, Bool_t warn = true) const;
92
93     const TClonesArray* GetMisAlignmentData() const;
94     
95     Bool_t  HasDE(Int_t detElemId) const;
96
97     AliMpArea* GetDEArea(Int_t detElemId) const;
98     
99   protected:
100     /// Not implemented
101     AliMUONGeometryTransformer(const AliMUONGeometryTransformer& right);
102     /// Not implemented
103     AliMUONGeometryTransformer&  operator = (const AliMUONGeometryTransformer& right);
104  
105   private:
106     // methods
107       
108       void CreateDEAreas() const;
109     
110     Bool_t LoadMapping() const;
111     AliMUONGeometryModuleTransformer* GetModuleTransformerNonConst(
112                                     Int_t index, Bool_t warn = true) const;
113
114     TGeoHMatrix GetTransform(
115                   Double_t x, Double_t y, Double_t z,
116                   Double_t a1, Double_t a2, Double_t a3, 
117                   Double_t a4, Double_t a5, Double_t a6) const;
118
119     void FillModuleTransform(Int_t moduleId,
120                   Double_t x, Double_t y, Double_t z,
121                   Double_t a1, Double_t a2, Double_t a3, 
122                   Double_t a4, Double_t a5, Double_t a6); 
123     void FillDetElemTransform(Int_t id, 
124                   Double_t x, Double_t y, Double_t z,
125                   Double_t a1, Double_t a2, Double_t a3, 
126                   Double_t a4, Double_t a5, Double_t a6);
127
128     TString ReadModuleTransforms(ifstream& in);
129     TString ReadDetElemTransforms(ifstream& in);
130     Bool_t  ReadTransformations(const TString& fileName);
131     Bool_t  LoadTransformations(); 
132
133     void    WriteTransform(ofstream& out, const TGeoMatrix* transform) const;
134     void    WriteModuleTransforms(ofstream& out) const;
135     void    WriteDetElemTransforms(ofstream& out) const;
136     
137     TString GetModuleSymName(Int_t moduleId) const;
138     TString GetDESymName(Int_t detElemId) const;
139     
140     // static data members
141     static const TString  fgkDefaultDetectorName; ///< Default detector name
142     
143
144     // data members
145     TString        fDetectorName;       ///< Detector name
146     TObjArray*     fModuleTransformers; ///< array of module transformers
147     TClonesArray*  fMisAlignArray;      ///< array of misalignment data
148     mutable AliMpExMap*    fDEAreas; ///< areas of detection elements in global coordinates
149     
150   ClassDef(AliMUONGeometryTransformer,4)  // Geometry parametrisation
151 };
152
153 // inline methods
154
155 /// Return the number of contained module transformers
156 inline Int_t AliMUONGeometryTransformer::GetNofModuleTransformers() const
157 { return fModuleTransformers->GetEntriesFast(); }
158
159 /// Return the array of misalignment data
160 inline const TClonesArray* AliMUONGeometryTransformer::GetMisAlignmentData() const      
161 { return fMisAlignArray; }                     
162                                
163 /// Set detector name
164 inline void AliMUONGeometryTransformer::SetDetName(const TString& detName)
165 {  fDetectorName = detName; }               
166
167 /// Set ownership of array module transformers
168 inline void AliMUONGeometryTransformer::SetOwner(Bool_t isOwner)
169 {  fModuleTransformers->SetOwner(isOwner); }               
170
171 #endif //ALI_MUON_GEOMETRY_TRANSFORMER_H
172
173
174
175
176
177
178