1 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
2 * See cxx source for full Copyright notice */
7 /// \class AliMUONGeometryTransformer
8 /// \brief Top container class for geometry transformations
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
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
19 /// \author Ivana Hrivnacova, IPN Orsay
21 #ifndef ALI_MUON_GEOMETRY_TRANSFORMER_H
22 #define ALI_MUON_GEOMETRY_TRANSFORMER_H
25 #include <TObjArray.h>
26 #include <TGeoMatrix.h>
28 class AliMUONGeometryModuleTransformer;
29 class AliMUONGeometryDetElement;
36 class AliMUONGeometryTransformer : public TObject
39 AliMUONGeometryTransformer();
40 AliMUONGeometryTransformer(TRootIOCtor* /*ioCtor*/);
41 virtual ~AliMUONGeometryTransformer();
44 void AddModuleTransformer(AliMUONGeometryModuleTransformer* transformer);
45 void AddMisAlignModule(Int_t moduleId, const TGeoHMatrix& matrix, Bool_t bGlobal = kTRUE);
46 void AddMisAlignDetElement(Int_t detElemId, const TGeoHMatrix& matrix, Bool_t bGlobal = kTRUE);
49 void AddAlignableVolumes() const;
50 TClonesArray* CreateZeroAlignmentData() const;
51 void ClearMisAlignmentData();
55 Bool_t LoadTransformations();
56 Bool_t LoadGeometryData(const TString& fileName);
57 Bool_t LoadGeometryData();
59 Bool_t WriteTransformations(const TString& fileName) const;
60 Bool_t WriteMisAlignmentData(const TString& fileName) const;
62 // Transformation methods
64 void Global2Local(Int_t detElemId,
65 Float_t xg, Float_t yg, Float_t zg,
66 Float_t& xl, Float_t& yl, Float_t& zl) const;
67 void Global2Local(Int_t detElemId,
68 Double_t xg, Double_t yg, Double_t zg,
69 Double_t& xl, Double_t& yl, Double_t& zl) const;
71 void Local2Global(Int_t detElemId,
72 Float_t xl, Float_t yl, Float_t zl,
73 Float_t& xg, Float_t& yg, Float_t& zg) const;
74 void Local2Global(Int_t detElemId,
75 Double_t xl, Double_t yl, Double_t zl,
76 Double_t& xg, Double_t& yg, Double_t& zg) const;
79 void SetDetName(const TString& detName);
80 void SetOwner(Bool_t isOwner);
84 Int_t GetNofModuleTransformers() const;
85 const AliMUONGeometryModuleTransformer* GetModuleTransformer(
86 Int_t index, Bool_t warn = true) const;
88 const AliMUONGeometryModuleTransformer* GetModuleTransformerByDEId(
89 Int_t detElemId, Bool_t warn = true) const;
91 const AliMUONGeometryDetElement* GetDetElement(
92 Int_t detElemId, Bool_t warn = true) const;
94 const TClonesArray* GetMisAlignmentData() const;
96 Bool_t HasDE(Int_t detElemId) const;
98 AliMpArea* GetDEArea(Int_t detElemId) const;
102 AliMUONGeometryTransformer(const AliMUONGeometryTransformer& right);
104 AliMUONGeometryTransformer& operator = (const AliMUONGeometryTransformer& right);
109 void CreateDEAreas() const;
111 Bool_t LoadMapping() const;
112 AliMUONGeometryModuleTransformer* GetModuleTransformerNonConst(
113 Int_t index, Bool_t warn = true) const;
115 TGeoHMatrix GetTransform(
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) const;
120 void FillModuleTransform(Int_t moduleId,
121 Double_t x, Double_t y, Double_t z,
122 Double_t a1, Double_t a2, Double_t a3,
123 Double_t a4, Double_t a5, Double_t a6);
124 void FillDetElemTransform(Int_t id,
125 Double_t x, Double_t y, Double_t z,
126 Double_t a1, Double_t a2, Double_t a3,
127 Double_t a4, Double_t a5, Double_t a6);
129 TString ReadModuleTransforms(ifstream& in);
130 TString ReadDetElemTransforms(ifstream& in);
131 Bool_t ReadTransformations(const TString& fileName);
133 void WriteTransform(ofstream& out, const TGeoMatrix* transform) const;
134 void WriteModuleTransforms(ofstream& out) const;
135 void WriteDetElemTransforms(ofstream& out) const;
137 TString GetModuleSymName(Int_t moduleId) const;
138 TString GetDESymName(Int_t detElemId) const;
140 // static data members
141 static const TString fgkDefaultDetectorName; ///< Default detector name
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
150 ClassDef(AliMUONGeometryTransformer,4) // Geometry parametrisation
155 /// Return the number of contained module transformers
156 inline Int_t AliMUONGeometryTransformer::GetNofModuleTransformers() const
157 { return fModuleTransformers->GetEntriesFast(); }
159 /// Return the array of misalignment data
160 inline const TClonesArray* AliMUONGeometryTransformer::GetMisAlignmentData() const
161 { return fMisAlignArray; }
163 /// Set detector name
164 inline void AliMUONGeometryTransformer::SetDetName(const TString& detName)
165 { fDetectorName = detName; }
167 /// Set ownership of array module transformers
168 inline void AliMUONGeometryTransformer::SetOwner(Bool_t isOwner)
169 { fModuleTransformers->SetOwner(isOwner); }
171 #endif //ALI_MUON_GEOMETRY_TRANSFORMER_H