]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpFiles.cxx
Coding conventions corrections only
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpFiles.cxx
1 // $Id$
2 // Category: sector
3 //
4 // Class AliMpFiles
5 // ----------------
6 // Class for generating file names and paths.
7 // The input files:
8 // zones.dat, zones_special.dat - sector description
9 // motif*.dat   - motif description (generated from Exceed)
10 // padPos*.dat  - pad positions in motif
11 //
12 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
13
14 #include <stdlib.h>
15
16 #include "AliMpFiles.h"
17
18 ClassImp(AliMpFiles)
19
20 // static data members
21
22 AliMpFiles* AliMpFiles::fgInstance = 0;
23 const TString AliMpFiles::fgkDefaultTop = getenv("MINSTALL");    
24 const TString AliMpFiles::fgkDataDir = "/data";
25 const TString AliMpFiles::fgkStationDir = "/station";
26 const TString AliMpFiles::fgkBendingDir = "/bending_plane/";
27 const TString AliMpFiles::fgkNonBendingDir = "/non-bending_plane/";
28 const TString AliMpFiles::fgkSector  = "zones"; 
29 const TString AliMpFiles::fgkSectorSpecial = "zones_special";
30 const TString AliMpFiles::fgkSectorSpecial2 = "zones_special_outer";
31 const TString AliMpFiles::fgkMotifPrefix   = "motif";  
32 const TString AliMpFiles::fgkMotifSpecialPrefix ="motifSpecial";
33 const TString AliMpFiles::fgkPadPosPrefix  = "padPos"; 
34 const TString AliMpFiles::fgkDataExt = ".dat";      
35 const TString AliMpFiles::fgkBergToGCFileName = "/bergToGC";      
36
37 //______________________________________________________________________________
38 AliMpFiles::AliMpFiles()
39   : TObject(),
40     fTop(fgkDefaultTop)
41 {
42 //    
43   if (fgInstance) {
44     Fatal("AliMpFiles", 
45           "AliMpFiles: attempt to create two instances of singleton.");
46   }
47       
48   fgInstance = this;      
49 }
50   
51 //______________________________________________________________________________
52 AliMpFiles::AliMpFiles(const AliMpFiles& right)
53   : TObject(right) 
54 {
55 // 
56   Fatal("AliMpFiles", "Attempt to copy AliMpFiles singleton.");
57 }
58
59
60 //______________________________________________________________________________
61 AliMpFiles::~AliMpFiles() {
62 //
63
64   fgInstance = 0;      
65 }
66
67 // operators
68
69 //______________________________________________________________________________
70 AliMpFiles& AliMpFiles::operator=(const AliMpFiles& right)
71 {
72   // check assignement to self
73   if (this == &right) return *this;
74
75   Fatal("operator=", "Attempt to assign AliMpFiles singleton.");
76     
77   return *this;  
78 }    
79           
80 //
81 // private methods
82 //
83
84 //______________________________________________________________________________
85 TString AliMpFiles::PlaneDataDir(AliMpStationType station, 
86                                  AliMpPlaneType plane) const
87 {
88 // Returns path to data files with sector description
89 // for a specified plane.
90 // ---
91
92   switch (plane) {
93     case kBendingPlane:
94        return fTop + fgkDataDir + StationDataDir(station) + fgkBendingDir;
95        ;;
96     case kNonBendingPlane:   
97        return fTop + fgkDataDir + StationDataDir(station) + fgkNonBendingDir;
98        ;;
99   }   
100   
101   Fatal("PlaneDataDir", "Incomplete switch on AliMpPlaneType");
102   return TString();
103 }
104
105 //______________________________________________________________________________
106 TString AliMpFiles::StationDataDir(AliMpStationType station) const
107 {
108 // Returns the station directory name for the specified station number.
109 // ---
110
111   TString stationDataDir(fgkStationDir);
112   switch (station) {
113     case kStation1: 
114       stationDataDir += 1;
115       break;
116       ;;
117     case kStation2: 
118       stationDataDir += 2;
119       break;
120       ;;
121   }   
122   return stationDataDir;
123 }
124
125 //
126 // public methods
127 //
128
129 //______________________________________________________________________________
130 AliMpFiles* AliMpFiles::Instance() 
131
132 // Return the singleton instance;
133 // Creates it if it does not yet exist,
134 //
135 // ---
136
137   if (!fgInstance)  fgInstance = new AliMpFiles(); 
138   
139   return fgInstance; 
140 }
141
142 //______________________________________________________________________________
143 TString AliMpFiles::SectorFilePath(AliMpStationType station, 
144                                    AliMpPlaneType plane) const
145 {
146 // Returns path to data file with sector description.
147 // ---
148  
149   return TString(PlaneDataDir(station, plane) + fgkSector + fgkDataExt);
150 }
151     
152 //______________________________________________________________________________
153 TString AliMpFiles::SectorSpecialFilePath(AliMpStationType station, 
154                                           AliMpPlaneType plane) const
155 {
156 // Returns path to data file with sector special description (irregular motifs).
157 // ---
158
159   return TString(PlaneDataDir(station, plane) + fgkSectorSpecial + fgkDataExt);
160 }
161     
162 //______________________________________________________________________________
163 TString AliMpFiles::SectorSpecialFilePath2(AliMpStationType station, 
164                                            AliMpPlaneType plane) const
165 {
166 // Returns path to data file with sector special description (irregular motifs).
167 // ---
168
169   return TString(PlaneDataDir(station, plane) + fgkSectorSpecial2 + fgkDataExt);
170 }
171     
172 //______________________________________________________________________________
173 TString AliMpFiles::MotifFilePath(AliMpStationType station, 
174                                   AliMpPlaneType plane, 
175                                   const TString& motifTypeID) const
176 {
177 // Returns path to data file for a given motif type.
178 // ---
179
180   return TString(PlaneDataDir(station, plane) 
181                  + fgkMotifPrefix +  motifTypeID + fgkDataExt);
182 }
183     
184 //______________________________________________________________________________
185 TString AliMpFiles::PadPosFilePath(AliMpStationType station, 
186                                    AliMpPlaneType plane, 
187                                    const TString& motifTypeID) const
188 {
189 // Returns path to data file with pad positions for a given motif type.
190 // ---
191
192   return TString(PlaneDataDir(station, plane) 
193                  + fgkPadPosPrefix +  motifTypeID + fgkDataExt);
194 }
195
196 //______________________________________________________________________________ 
197 TString AliMpFiles::MotifSpecialFilePath(AliMpStationType station, 
198                                          AliMpPlaneType plane,
199                                          const TString& motifID) const
200 {
201 // Returns path to data file with pad dimensions for a given motif ID.
202 // ---
203
204   return TString(PlaneDataDir(station, plane) 
205                  + fgkMotifSpecialPrefix + motifID + fgkDataExt);
206
207 }
208
209 //______________________________________________________________________________ 
210 TString AliMpFiles::BergToGCFilePath(AliMpStationType station) const
211 {
212 // Returns the path of the file which describes the correspondance between
213 // the berg number and the gassiplex channel.
214 // ---
215
216   return fTop + fgkDataDir + StationDataDir(station)
217               + fgkBergToGCFileName + fgkDataExt;
218 }