]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONVGeometryBuilder.h
0a9de7fbe96f51b666d65806a7813c170802d606
[u/mrichter/AliRoot.git] / MUON / AliMUONVGeometryBuilder.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 // Revision of includes 07/05/2004
6
7 /// \ingroup geometry
8 /// \class AliMUONVGeometryBuilder
9 /// \brief Abstract base class for geometry construction per module(s)
10 ///
11 /// Author: Ivana Hrivnacova, IPN Orsay
12
13 #ifndef ALI_MUON_V_GEOMETRY_BUILDER_H
14 #define ALI_MUON_V_GEOMETRY_BUILDER_H
15
16 #include <fstream>
17
18 #include <TObject.h>
19 #include <TObjArray.h>
20 #include <TGeoMatrix.h>
21
22 class TGeoTranslation;
23 class TGeoRotation;
24 class TGeoCombiTrans;
25
26 class AliMUONGeometryModule;
27 class AliMUONGeometryEnvelopeStore;
28 class AliMUONGeometryStore;
29 class AliMUONGeometrySVMap;
30
31 class AliMUONVGeometryBuilder : public TObject
32 {
33   public:
34     AliMUONVGeometryBuilder(const TString& fileName,
35                             AliMUONGeometryModule* mg1,
36                             AliMUONGeometryModule* mg2 = 0,
37                             AliMUONGeometryModule* mg3 = 0,
38                             AliMUONGeometryModule* mg4 = 0,
39                             AliMUONGeometryModule* mg5 = 0,
40                             AliMUONGeometryModule* mg6 = 0);
41     AliMUONVGeometryBuilder();
42     virtual ~AliMUONVGeometryBuilder();
43   
44     // methods
45             void  SetReferenceFrame(const TGeoCombiTrans& referenceFrame);
46     virtual void  FillTransformations() const;
47     virtual void  RebuildSVMaps() const;
48     virtual Bool_t  ReadTransformations() const;
49     virtual Bool_t  ReadSVMap() const;
50     virtual Bool_t  WriteTransformations() const;
51     virtual Bool_t  WriteSVMap(Bool_t rebuild) const;
52
53     virtual void CreateMaterials() {}  // make = 0; ?
54                   // Function to be overriden in a concrete chamber/station
55                   // geometry builder class.
56                   // Only materials that are not defined in the common
57                   // functions should be defined here.
58     virtual void CreateGeometry() = 0;
59                   // Function to be overriden in a concrete chamber/station
60                   // geometry builder class.
61                   // The geometry built there should not be placed
62                   // in ALIC; but all volumes going to ALIC
63                   // have to be added as envelopes to the chamber
64                   // geometries
65                   // (They will be then placed automatically 
66                   // usind the provided transformation.
67     virtual void SetTransformations() = 0;
68                   // Function to be overriden in a concrete chamber/station
69                   // geometry class.
70                   // The transformation of each chamber(s) wrt ALICE
71                   // should be defined and set to its geometry class. 
72     virtual void SetSensitiveVolumes() = 0;
73                   // Function to be overriden in a concrete chamber/station
74                   // geometry class.
75                   // The sensitive volumes Ids for each chamber
76                   // should be defined and set to its geometry class. 
77     virtual bool ApplyGlobalTransformation() { return true; }
78                   // Function to be overriden (and return false) 
79                   // in the concrete geometry builder classes 
80                   // which are already defined in the new ALICE
81                   // coordinate frame
82
83     // access to module geometries
84     Int_t  NofGeometries() const;
85     AliMUONGeometryModule* Geometry(Int_t i) const;
86                   // In difference from protected GetGeometry()
87                   // this function access geometry via index and not
88                   // via moduleId
89
90
91   protected:
92     AliMUONVGeometryBuilder(const AliMUONVGeometryBuilder& rhs);
93
94     // operators  
95     AliMUONVGeometryBuilder& operator = (const AliMUONVGeometryBuilder& rhs);
96
97     // methods
98     AliMUONGeometryModule*         GetGeometry(Int_t moduleId) const;
99     AliMUONGeometryEnvelopeStore*  GetEnvelopes(Int_t moduleId) const;
100     AliMUONGeometryStore*          GetDetElements(Int_t moduleId) const;
101     AliMUONGeometrySVMap*          GetSVMap(Int_t moduleId) const;
102     
103   private:
104     //methods
105     TString  ComposePath(const TString& volName, Int_t copyNo) const; 
106     void     MapSV(const TString&path, const TString& volName, 
107                   Int_t detElemId) const;
108
109     TGeoHMatrix GetTransform(
110                   Double_t x, Double_t y, Double_t z,
111                   Double_t a1, Double_t a2, Double_t a3, 
112                   Double_t a4, Double_t a5, Double_t a6) const;
113     void FillData(Int_t moduleId, Int_t nofDetElements, 
114                   Double_t x, Double_t y, Double_t z,
115                   Double_t a1, Double_t a2, Double_t a3, 
116                   Double_t a4, Double_t a5, Double_t a6) const; 
117     void FillData(Int_t id, const TString& volName, Int_t copyNo,
118                   Double_t x, Double_t y, Double_t z,
119                   Double_t a1, Double_t a2, Double_t a3, 
120                   Double_t a4, Double_t a5, Double_t a6) const;
121     void FillData(const TString& sensVolumePath, Int_t detElemId) const;                   
122
123     TString ReadData1(ifstream& in) const;
124     TString ReadData2(ifstream& in) const;
125     TString ReadData3(ifstream& in) const;
126
127     void WriteTransform(ofstream& out, const TGeoCombiTrans* transform) const;
128     void WriteData1(ofstream& out) const;
129     void WriteData2(ofstream& out) const;
130     void WriteData3(ofstream& out) const;
131
132     // static data members
133     static const TString fgkTransformFileNamePrefix; // the prefix for the name 
134                                                  // of file with transformations
135     static const TString fgkSVMapFileNamePrefix; // the prefix for the name of file 
136                                                  // with sensitive volume map
137     static const TString fgkOutFileNameSuffix;   // the suffix for the name of 
138                                                  // generated files
139     
140     // data members
141     TString     fTransformFileName; // the name file with transformations 
142     TString     fSVMapFileName;     // the name file with sensitive volume map 
143     TObjArray*  fModuleGeometries;  // the modules geometries that will be built
144                                     // by this builder                              
145     TGeoCombiTrans fReferenceFrame; // the transformation from the builder 
146                                     // reference frame to that of the transform 
147                                     // data files
148                                         
149   ClassDef(AliMUONVGeometryBuilder,4) // MUON chamber geometry base class
150 };
151
152 // inline functions
153
154 inline Int_t  AliMUONVGeometryBuilder::NofGeometries() const
155 { return fModuleGeometries->GetEntriesFast(); }
156
157 inline AliMUONGeometryModule* AliMUONVGeometryBuilder::Geometry(Int_t i) const
158 { return (AliMUONGeometryModule*)fModuleGeometries->At(i); }
159
160 inline void 
161 AliMUONVGeometryBuilder::SetReferenceFrame(const TGeoCombiTrans& referenceFrame)
162 { fReferenceFrame = referenceFrame; 
163   //fReferenceFrame = new TGeoCombiTrans(referenceFrame);
164 }
165
166 #endif //ALI_MUON_V_GEOMETRY_BUILDER_H