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 /// - 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.
17 /// \author Ivana Hrivnacova, IPN Orsay
19 #ifndef ALI_MUON_GEOMETRY_TRANSFORMER_H
20 #define ALI_MUON_GEOMETRY_TRANSFORMER_H
23 #include <TObjArray.h>
24 #include <TGeoMatrix.h>
26 class AliMUONGeometryModuleTransformer;
27 class AliMUONGeometryDetElement;
32 class AliMUONGeometryTransformer : public TObject
35 AliMUONGeometryTransformer(Bool_t isOwner, const TString& detName = "MUON");
36 AliMUONGeometryTransformer();
37 virtual ~AliMUONGeometryTransformer();
40 void AddModuleTransformer(AliMUONGeometryModuleTransformer* transformer);
41 void AddMisAlignModule(Int_t moduleId, const TGeoHMatrix& matrix);
42 void AddMisAlignDetElement(Int_t detElemId, const TGeoHMatrix& matrix);
44 void AddAlignableVolumes() const;
45 TClonesArray* CreateZeroAlignmentData() const;
46 void ClearMisAlignmentData();
50 Bool_t ReadGeometryData(const TString& volPathFileName,
51 const TString& transformFileName);
52 Bool_t ReadGeometryData(const TString& volPathFileName,
53 TGeoManager* geoManager);
55 Bool_t WriteGeometryData(const TString& volPathFileName,
56 const TString& transformFileName,
57 const TString& misalignFileName = "") const;
59 Bool_t WriteVolumePaths(const TString& fileName) const;
60 Bool_t WriteTransformations(const TString& fileName) const;
61 Bool_t WriteMisAlignmentData(const TString& fileName) const;
63 // Transformation methods
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;
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;
81 Int_t GetNofModuleTransformers() const;
82 const AliMUONGeometryModuleTransformer* GetModuleTransformer(
83 Int_t index, Bool_t warn = true) const;
85 const AliMUONGeometryModuleTransformer* GetModuleTransformerByDEId(
86 Int_t detElemId, Bool_t warn = true) const;
88 const AliMUONGeometryDetElement* GetDetElement(
89 Int_t detElemId, Bool_t warn = true) const;
91 const TClonesArray* GetMisAlignmentData() const;
93 Bool_t HasDE(Int_t detElemId) const;
97 AliMUONGeometryTransformer(const AliMUONGeometryTransformer& right);
99 AliMUONGeometryTransformer& operator = (const AliMUONGeometryTransformer& right);
103 AliMUONGeometryModuleTransformer* GetModuleTransformerNonConst(
104 Int_t index, Bool_t warn = true) const;
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;
111 void FillModuleVolPath(Int_t moduleId, const TString& volPath);
112 void FillDetElemVolPath(Int_t detElemId, const TString& volPath);
114 void FillModuleTransform(Int_t moduleId,
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);
118 void FillDetElemTransform(Int_t id,
119 Double_t x, Double_t y, Double_t z,
120 Double_t a1, Double_t a2, Double_t a3,
121 Double_t a4, Double_t a5, Double_t a6);
123 Bool_t ReadVolPaths(ifstream& in);
124 TString ReadModuleTransforms(ifstream& in);
125 TString ReadDetElemTransforms(ifstream& in);
126 Bool_t LoadTransforms(TGeoManager* tgeoManager);
128 Bool_t ReadVolPaths(const TString& fileName);
129 Bool_t ReadTransformations(const TString& fileName);
130 Bool_t ReadTransformations2(const TString& fileName);
132 void WriteTransform(ofstream& out, const TGeoMatrix* transform) const;
133 void WriteModuleVolPaths(ofstream& out) const;
134 void WriteDetElemVolPaths(ofstream& out) const;
135 void WriteModuleTransforms(ofstream& out) const;
136 void WriteDetElemTransforms(ofstream& out) const;
138 TString GetModuleSymName(Int_t moduleId) const;
139 TString GetDESymName(Int_t detElemId) const;
142 TString fDetectorName; ///< Detector name
143 TObjArray* fModuleTransformers; ///< array of module transformers
144 TClonesArray* fMisAlignArray; ///< array of misalignment data
146 ClassDef(AliMUONGeometryTransformer,2) // Geometry parametrisation
151 /// Return the number of contained module transformers
152 inline Int_t AliMUONGeometryTransformer::GetNofModuleTransformers() const
153 { return fModuleTransformers->GetEntriesFast(); }
155 /// Return the array of misalignment data
156 inline const TClonesArray* AliMUONGeometryTransformer::GetMisAlignmentData() const
157 { return fMisAlignArray; }
159 #endif //ALI_MUON_GEOMETRY_TRANSFORMER_H