]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpFiles.cxx
Updated for replacement of AliMpReader with AliMpSectorReader
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpFiles.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // $Id$
17 // $MpId: AliMpFiles.cxx,v 1.4 2005/08/26 15:43:36 ivana Exp $
18 // Category: basic
19 //
20 // Class AliMpFiles
21 // ----------------
22 // Class for generating file names and paths.
23 // The input files:
24 // zones.dat, zones_special.dat - sector description
25 // motif*.dat   - motif description (generated from Exceed)
26 // padPos*.dat  - pad positions in motif
27 //
28 // Included in AliRoot: 2003/05/02
29 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
30
31 #include <stdlib.h>
32
33 #include "AliMpFiles.h"
34
35 ClassImp(AliMpFiles)
36
37 // static data members
38
39 AliMpFiles* AliMpFiles::fgInstance = 0;
40 const TString AliMpFiles::fgkDefaultTop = getenv("MINSTALL");    
41 const TString AliMpFiles::fgkDataDir = "/data";
42 const TString AliMpFiles::fgkStationDir = "/station";
43 const TString AliMpFiles::fgkBendingDir = "/bending_plane/";
44 const TString AliMpFiles::fgkNonBendingDir = "/non-bending_plane/";
45 const TString AliMpFiles::fgkSector  = "zones"; 
46 const TString AliMpFiles::fgkSectorSpecial = "zones_special";
47 const TString AliMpFiles::fgkSectorSpecial2 = "zones_special_outer";
48 const TString AliMpFiles::fgkMotifPrefix   = "motif";  
49 const TString AliMpFiles::fgkMotifSpecialPrefix ="motifSpecial";
50 const TString AliMpFiles::fgkPadPosPrefix  = "padPos"; 
51 const TString AliMpFiles::fgkDataExt = ".dat";      
52 const TString AliMpFiles::fgkBergToGCFileName = "/bergToGC";      
53
54 //______________________________________________________________________________
55 AliMpFiles::AliMpFiles()
56   : TObject(),
57     fTop(fgkDefaultTop)
58 {
59 /// Default constructor
60     
61   if (fgInstance) {
62     Fatal("AliMpFiles", 
63           "AliMpFiles: attempt to create two instances of singleton.");
64   }
65       
66   fgInstance = this;      
67 }
68   
69 //______________________________________________________________________________
70 AliMpFiles::AliMpFiles(const AliMpFiles& right)
71   : TObject(right) 
72 {
73 /// Protected copy constructor 
74
75   Fatal("AliMpFiles", "Attempt to copy AliMpFiles singleton.");
76 }
77
78
79 //______________________________________________________________________________
80 AliMpFiles::~AliMpFiles() 
81 {
82 /// Destructor
83
84   fgInstance = 0;      
85 }
86
87 // operators
88
89 //______________________________________________________________________________
90 AliMpFiles& AliMpFiles::operator=(const AliMpFiles& right)
91 {
92 /// Assignment operator
93
94   // check assignment to self
95   if (this == &right) return *this;
96
97   Fatal("operator=", "Attempt to assign AliMpFiles singleton.");
98     
99   return *this;  
100 }    
101           
102 //
103 // private methods
104 //
105
106 //______________________________________________________________________________
107 TString AliMpFiles::PlaneDataDir(AliMpStationType station, 
108                                  AliMpPlaneType plane) const
109 {
110 /// Returns path to data files with sector description
111 /// for a specified plane.
112
113   switch (station) {
114   case kStation1:
115   case kStation2:
116     switch (plane) {
117     case kBendingPlane:
118       return fTop + fgkDataDir + StationDataDir(station) + fgkBendingDir;
119       ;;
120     case kNonBendingPlane:   
121       return fTop + fgkDataDir + StationDataDir(station) + fgkNonBendingDir;
122       ;;
123     }   
124     break;
125   case kStation345:
126     return fTop + fgkDataDir + StationDataDir(station) + "/";
127     break;
128   }
129
130   Fatal("PlaneDataDir", "Incomplete switch on AliMpPlaneType");
131   return TString();
132 }
133
134 //______________________________________________________________________________
135 TString AliMpFiles::StationDataDir(AliMpStationType station) const
136 {
137 /// Returns the station directory name for the specified station number.
138
139   TString stationDataDir(fgkStationDir);
140   switch (station) {
141   case kStation1: 
142     stationDataDir += 1;
143     break;
144     ;;
145   case kStation2: 
146     stationDataDir += 2;
147     break;
148     ;;
149   case kStation345: 
150     stationDataDir += "345/";
151     break;
152     ;;      
153   }   
154   return stationDataDir;
155 }
156
157 //
158 // public methods
159 //
160
161 //______________________________________________________________________________
162 AliMpFiles* AliMpFiles::Instance() 
163
164 /// Return the singleton instance;
165 /// Creates it if it does not yet exist,
166
167   if (!fgInstance)  fgInstance = new AliMpFiles(); 
168   
169   return fgInstance; 
170 }
171
172
173 //_____________________________________________________________________________
174 TString AliMpFiles::SlatFilePath(const char* slatType,
175                                  AliMpPlaneType plane) const
176 {
177 /// \todo add ..
178
179   return TString(PlaneDataDir(kStation345,plane) + slatType + "." +
180                  ( plane == kNonBendingPlane ? "NonBending":"Bending" ) + ".slat");
181 }
182
183 //_____________________________________________________________________________
184 TString AliMpFiles::SlatPCBFilePath(const char* pcbType) const
185 {
186 /// Get the full path for a given PCB (only relevant to stations 3,
187 /// 4 and 5). The bending parameter below is of no use in this case, but
188 /// we use it to re-use the PlaneDataDir() method untouched.
189
190   return TString(PlaneDataDir(kStation345,kNonBendingPlane) + pcbType +
191                  ".pcb");
192 }
193
194 //_____________________________________________________________________________
195 TString 
196 AliMpFiles::DetElemIdToSlatTypeFilePath() const
197 {
198 /// Get the full path of the file containing the mapping detElemId <->
199 /// SlatType.
200 /// The bending parameter below is of no use in this case, but
201 /// we use it to re-use the PlaneDataDir() method untouched.
202
203   return TString(PlaneDataDir(kStation345,kNonBendingPlane) + 
204                  "DetElemIdToSlatType.dat");
205 }
206 //______________________________________________________________________________
207 TString AliMpFiles::SectorFilePath(AliMpStationType station, 
208                                    AliMpPlaneType plane) const
209 {
210 /// Return path to data file with sector description.
211  
212   return TString(PlaneDataDir(station, plane) + fgkSector + fgkDataExt);
213 }
214     
215 //______________________________________________________________________________
216 TString AliMpFiles::SectorSpecialFilePath(AliMpStationType station, 
217                                           AliMpPlaneType plane) const
218 {
219 /// Return path to data file with sector special description (irregular motifs).
220
221   return TString(PlaneDataDir(station, plane) + fgkSectorSpecial + fgkDataExt);
222 }
223     
224 //______________________________________________________________________________
225 TString AliMpFiles::SectorSpecialFilePath2(AliMpStationType station, 
226                                            AliMpPlaneType plane) const
227 {
228 /// Returns path to data file with sector special description (irregular motifs).
229
230   return TString(PlaneDataDir(station, plane) + fgkSectorSpecial2 + fgkDataExt);
231 }
232     
233 //______________________________________________________________________________
234 TString AliMpFiles::MotifFilePath(AliMpStationType station, 
235                                   AliMpPlaneType plane, 
236                                   const TString& motifTypeID) const
237 {
238 /// Returns path to data file for a given motif type.
239
240   return TString(PlaneDataDir(station, plane) 
241                  + fgkMotifPrefix +  motifTypeID + fgkDataExt);
242 }
243     
244 //______________________________________________________________________________
245 TString AliMpFiles::PadPosFilePath(AliMpStationType station, 
246                                    AliMpPlaneType plane, 
247                                    const TString& motifTypeID) const
248 {
249 /// Returns path to data file with pad positions for a given motif type.
250
251   return TString(PlaneDataDir(station, plane) 
252                  + fgkPadPosPrefix +  motifTypeID + fgkDataExt);
253 }
254
255 //______________________________________________________________________________ 
256 TString AliMpFiles::MotifSpecialFilePath(AliMpStationType station, 
257                                          AliMpPlaneType plane,
258                                          const TString& motifID) const
259 {
260 /// Returns path to data file with pad dimensions for a given motif ID.
261
262   return TString(PlaneDataDir(station, plane) 
263                  + fgkMotifSpecialPrefix + motifID + fgkDataExt);
264
265 }
266
267 //______________________________________________________________________________ 
268 TString AliMpFiles::BergToGCFilePath(AliMpStationType station) const
269 {
270 /// Returns the path of the file which describes the correspondance between
271 /// the berg number and the gassiplex channel.
272
273   return fTop + fgkDataDir + StationDataDir(station)
274               + fgkBergToGCFileName + fgkDataExt;
275 }