]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGeometryTransformer.h
7274c2dab462d6eed6560259ae3cc8a90531347f
[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
34 class AliMUONGeometryTransformer : public TObject
35 {
36   public:
37     AliMUONGeometryTransformer();
38     AliMUONGeometryTransformer(TRootIOCtor* /*ioCtor*/);
39     virtual  ~AliMUONGeometryTransformer();
40     
41     // methods
42     void  AddModuleTransformer(AliMUONGeometryModuleTransformer* transformer);
43     void  AddMisAlignModule(Int_t moduleId, const TGeoHMatrix& matrix);
44     void  AddMisAlignDetElement(Int_t detElemId, const TGeoHMatrix& matrix);
45     void  CreateModules();
46
47     void  AddAlignableVolumes() const; 
48     TClonesArray* CreateZeroAlignmentData() const;
49     void  ClearMisAlignmentData();      
50
51     // IO
52     //
53     Bool_t  LoadGeometryData(const TString& fileName);
54     Bool_t  LoadGeometryData();
55
56     Bool_t  WriteTransformations(const TString& fileName) const;
57     Bool_t  WriteMisAlignmentData(const TString& fileName) const;
58
59     // Transformation methods 
60     //
61     void Global2Local(Int_t detElemId,
62                  Float_t xg, Float_t yg, Float_t zg, 
63                  Float_t& xl, Float_t& yl, Float_t& zl) const;
64     void Global2Local(Int_t detElemId,
65                  Double_t xg, Double_t yg, Double_t zg, 
66                  Double_t& xl, Double_t& yl, Double_t& zl) const;
67
68     void Local2Global(Int_t detElemId,
69                  Float_t xl, Float_t yl, Float_t zl, 
70                  Float_t& xg, Float_t& yg, Float_t& zg) const;
71     void Local2Global(Int_t detElemId,
72                  Double_t xl, Double_t yl, Double_t zl, 
73                  Double_t& xg, Double_t& yg, Double_t& zg) const;
74                  
75     // Set methods
76     void SetDetName(const TString& detName);                 
77     void SetOwner(Bool_t isOwner);                 
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     /// Not implemented
97     AliMUONGeometryTransformer(const AliMUONGeometryTransformer& right);
98     /// Not implemented
99     AliMUONGeometryTransformer&  operator = (const AliMUONGeometryTransformer& right);
100  
101   private:
102     // methods
103     AliMUONGeometryModuleTransformer* GetModuleTransformerNonConst(
104                                     Int_t index, Bool_t warn = true) const;
105
106     TGeoHMatrix GetTransform(
107                   Double_t x, Double_t y, Double_t z,
108                   Double_t a1, Double_t a2, Double_t a3, 
109                   Double_t a4, Double_t a5, Double_t a6) const;
110
111     void FillModuleTransform(Int_t moduleId,
112                   Double_t x, Double_t y, Double_t z,
113                   Double_t a1, Double_t a2, Double_t a3, 
114                   Double_t a4, Double_t a5, Double_t a6); 
115     void FillDetElemTransform(Int_t id, 
116                   Double_t x, Double_t y, Double_t z,
117                   Double_t a1, Double_t a2, Double_t a3, 
118                   Double_t a4, Double_t a5, Double_t a6);
119
120     TString ReadModuleTransforms(ifstream& in);
121     TString ReadDetElemTransforms(ifstream& in);
122     Bool_t  ReadTransformations(const TString& fileName);
123     Bool_t  LoadTransformations(); 
124
125     void    WriteTransform(ofstream& out, const TGeoMatrix* transform) const;
126     void    WriteModuleTransforms(ofstream& out) const;
127     void    WriteDetElemTransforms(ofstream& out) const;
128     
129     TString GetModuleSymName(Int_t moduleId) const;
130     TString GetDESymName(Int_t detElemId) const;
131     
132     // static data members
133     static const TString  fgkDefaultDetectorName; ///< Default detector name
134     
135
136     // data members
137     TString        fDetectorName;       ///< Detector name
138     TObjArray*     fModuleTransformers; ///< array of module transformers
139     TClonesArray*  fMisAlignArray;      ///< array of misalignment data
140
141   ClassDef(AliMUONGeometryTransformer,3)  // Geometry parametrisation
142 };
143
144 // inline methods
145
146 /// Return the number of contained module transformers
147 inline Int_t AliMUONGeometryTransformer::GetNofModuleTransformers() const
148 { return fModuleTransformers->GetEntriesFast(); }
149
150 /// Return the array of misalignment data
151 inline const TClonesArray* AliMUONGeometryTransformer::GetMisAlignmentData() const      
152 { return fMisAlignArray; }                     
153                                
154 /// Set detector name
155 inline void AliMUONGeometryTransformer::SetDetName(const TString& detName)
156 {  fDetectorName = detName; }               
157
158 /// Set ownership of array module transformers
159 inline void AliMUONGeometryTransformer::SetOwner(Bool_t isOwner)
160 {  fModuleTransformers->SetOwner(isOwner); }               
161
162 #endif //ALI_MUON_GEOMETRY_TRANSFORMER_H
163
164
165
166
167
168
169