]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGeometryTransformer.h
- Added handling of tracks and file mask (used when merging different files).
[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);
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     // IO
45     //
46     Bool_t  ReadGeometryData(const TString& volPathFileName,
47                              const TString& transformFileName);
48     Bool_t  ReadGeometryData(const TString& volPathFileName,
49                              TGeoManager* geoManager);
50
51     Bool_t  WriteGeometryData(const TString& volPathFileName,
52                              const TString& transformFileName,
53                              const TString& misalignFileName = "") const;
54    
55     Bool_t  WriteVolumePaths(const TString& fileName) const;
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     // Get methods
76     //
77     Int_t GetNofModuleTransformers() const;
78     const AliMUONGeometryModuleTransformer* GetModuleTransformer(
79                                Int_t index, Bool_t warn = true) const;
80
81     const AliMUONGeometryModuleTransformer* GetModuleTransformerByDEId(
82                                Int_t detElemId, Bool_t warn = true) const;
83
84     const AliMUONGeometryDetElement* GetDetElement(
85                                Int_t detElemId, Bool_t warn = true) const;
86
87     const TClonesArray* GetMisAlignmentData() const;                           
88
89     Bool_t  HasDE(Int_t detElemId) const;
90
91   protected:
92     AliMUONGeometryTransformer(const AliMUONGeometryTransformer& right);
93     AliMUONGeometryTransformer&  operator = (const AliMUONGeometryTransformer& right);
94  
95   private:
96     // methods
97     AliMUONGeometryModuleTransformer* GetModuleTransformerNonConst(
98                                     Int_t index, Bool_t warn = true) const;
99
100     TGeoHMatrix GetTransform(
101                   Double_t x, Double_t y, Double_t z,
102                   Double_t a1, Double_t a2, Double_t a3, 
103                   Double_t a4, Double_t a5, Double_t a6) const;
104
105     void FillModuleVolPath(Int_t moduleId, const TString& volPath); 
106     void FillDetElemVolPath(Int_t detElemId, const TString& volPath); 
107
108     void FillModuleTransform(Int_t moduleId,
109                   Double_t x, Double_t y, Double_t z,
110                   Double_t a1, Double_t a2, Double_t a3, 
111                   Double_t a4, Double_t a5, Double_t a6); 
112     void FillDetElemTransform(Int_t id, 
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
117     Bool_t  ReadVolPaths(ifstream& in);
118     TString ReadModuleTransforms(ifstream& in);
119     TString ReadDetElemTransforms(ifstream& in);
120     Bool_t  LoadTransforms(TGeoManager* tgeoManager); 
121
122     Bool_t  ReadVolPaths(const TString& fileName);
123     Bool_t  ReadTransformations(const TString& fileName);
124     Bool_t  ReadTransformations2(const TString& fileName);
125
126     void    WriteTransform(ofstream& out, const TGeoMatrix* transform) const;
127     void    WriteModuleVolPaths(ofstream& out) const;
128     void    WriteDetElemVolPaths(ofstream& out) const;
129     void    WriteModuleTransforms(ofstream& out) const;
130     void    WriteDetElemTransforms(ofstream& out) const;
131
132     // data members
133     TObjArray*     fModuleTransformers; // arryy of module transformers
134     TClonesArray*  fMisAlignArray;      // array of misalignment data
135
136   ClassDef(AliMUONGeometryTransformer,2)  // Geometry parametrisation
137 };
138
139 // inline methods
140 inline Int_t AliMUONGeometryTransformer::GetNofModuleTransformers() const
141 { return fModuleTransformers->GetEntriesFast(); }
142
143 inline const TClonesArray* AliMUONGeometryTransformer::GetMisAlignmentData() const      
144 { return fMisAlignArray; }                     
145
146 #endif //ALI_MUON_GEOMETRY_TRANSFORMER_H
147
148
149
150
151
152
153