]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpFiles.cxx
3b50c213d0d42f91e07cff5e04098d791f6a992e
[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.12 2006/05/23 13:09:54 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 "AliMpFiles.h"
32
33 #include "AliLog.h"
34
35 #include <TClass.h>
36 #include <Riostream.h>
37
38 #include <stdlib.h>
39
40 /// \cond CLASSIMP
41 ClassImp(AliMpFiles)
42 /// \endcond
43
44 //
45 // static
46
47 // static data members
48
49 const TString AliMpFiles::fgkDataDir = "/data";
50 const TString AliMpFiles::fgkStationDir = "/station";
51 const TString AliMpFiles::fgkBendingDir = "/bending_plane/";
52 const TString AliMpFiles::fgkNonBendingDir = "/non-bending_plane/";
53 const TString AliMpFiles::fgkDENames = "denames"; 
54 const TString AliMpFiles::fgkSector  = "zones"; 
55 const TString AliMpFiles::fgkSectorSpecial = "zones_special";
56 const TString AliMpFiles::fgkSectorSpecial2 = "zones_special_outer";
57 const TString AliMpFiles::fgkMotifPrefix   = "motif";  
58 const TString AliMpFiles::fgkMotifSpecialPrefix ="motifSpecial";
59 const TString AliMpFiles::fgkManuToSerialDir ="manu_serial/";
60 const TString AliMpFiles::fgkManuToSerial ="_manu";
61 const TString AliMpFiles::fgkPadPosPrefix  = "padPos"; 
62 const TString AliMpFiles::fgkDataExt = ".dat";      
63 const TString AliMpFiles::fgkBergToGCFileName = "/bergToGC"; 
64 const TString AliMpFiles::fgkTriggerLocalBoards = "crate";
65 const TString AliMpFiles::fgkBusPatchFileName = "DetElemIdToBusPatch";
66
67 //______________________________________________________________________________
68 AliMpFiles::~AliMpFiles() 
69 {
70 /// Destructor
71 }
72
73 //
74 // private methods
75 //
76
77 //______________________________________________________________________________
78 TString AliMpFiles::GetTop()
79 {
80 /// Return top path to mapping data defined either via MINSTALL
81 /// or ALICE_ROOT environment variable.                                      \n
82 /// If both variables are defined, MINSTALL is used.
83
84   TString top = getenv("MINSTALL");    
85   if ( ! top.IsNull() ) return top;
86
87   TString ntop = getenv("ALICE_ROOT");
88   if ( ntop.IsNull() ) {
89     AliErrorClassStream() << "Cannot find path to mapping data." << endl;
90     return ntop;
91   }  
92   ntop += "/MUON/mapping";
93   return ntop;
94 }
95
96 //______________________________________________________________________________
97 TString AliMpFiles::PlaneDataDir(AliMpStationType station, 
98                                  AliMpPlaneType plane)
99 {
100 /// Returns path to data files with sector description
101 /// for a specified plane.
102
103   switch (station) {
104   case kStation1:
105   case kStation2:
106     switch (plane) {
107     case kBendingPlane:
108       return GetTop() + fgkDataDir + StationDataDir(station) + fgkBendingDir;
109       ;;
110     case kNonBendingPlane:   
111       return GetTop() + fgkDataDir + StationDataDir(station) + fgkNonBendingDir;
112       ;;
113     }   
114     break;
115   case kStation345:
116   case kStationTrigger:  
117     return GetTop() + fgkDataDir + StationDataDir(station) + "/";
118     break;
119   default:  
120     AliFatalClass("Incomplete switch on AliMpPlaneType");
121     break;
122   }
123   return TString();
124 }
125
126 //______________________________________________________________________________
127 TString AliMpFiles::StationDataDir(AliMpStationType station)
128 {
129 /// Returns the station directory name for the specified station number.
130
131   TString stationDataDir(fgkStationDir);
132   switch (station) {
133   case kStation1: 
134     stationDataDir += "1/";
135     break;
136     ;;
137   case kStation2: 
138     stationDataDir += "2/";
139     break;
140     ;;
141   case kStation345: 
142     stationDataDir += "345/";
143     break;
144     ;;      
145   case kStationTrigger:
146     stationDataDir += "Trigger/";
147     break;
148     ;;
149   default:
150     stationDataDir += "Invalid/";
151     break;
152   }   
153   return stationDataDir;
154 }
155
156 //
157 // public methods
158 //
159
160 //______________________________________________________________________________
161 TString AliMpFiles::BusPatchFilePath()
162 {
163 /// Return path to data file with bus patch mapping.
164
165   return GetTop() + fgkDataDir + "/" + fgkBusPatchFileName + fgkDataExt;
166 }  
167
168 //______________________________________________________________________________
169 TString AliMpFiles::DENamesFilePath(AliMpStationType station)
170 {
171 /// Return path to data file with DE names for given station.
172  
173   return GetTop() + fgkDataDir + StationDataDir(station) + fgkDENames + fgkDataExt;
174 }
175
176 //______________________________________________________________________________
177 TString AliMpFiles::LocalTriggerBoardMapping()
178 {
179 /// Return path to data file with local trigger board mapping.
180
181   return GetTop() + fgkDataDir + StationDataDir(kStationTrigger) 
182           + fgkTriggerLocalBoards + fgkDataExt;;
183 }
184
185 //_____________________________________________________________________________
186 TString AliMpFiles::SlatFilePath(AliMpStationType stationType,
187                                  const char* slatType,
188                                  AliMpPlaneType plane)
189 {
190 /// \todo add ..
191
192   return TString(PlaneDataDir(stationType,plane) + slatType + "." +
193                  ( plane == kNonBendingPlane ? "NonBending":"Bending" ) + ".slat");
194 }
195
196 //_____________________________________________________________________________
197 TString AliMpFiles::SlatPCBFilePath(AliMpStationType stationType,
198                                     const char* pcbType)
199 {
200 /// Get the full path for a given PCB (only relevant to stations 3,
201 /// 4, 5 and trigger). The bending parameter below is of no use in this case, but
202 /// we use it to re-use the PlaneDataDir() method untouched.
203
204   return TString(PlaneDataDir(stationType,kNonBendingPlane) + pcbType +
205                  ".pcb");
206 }
207
208 //______________________________________________________________________________
209 TString AliMpFiles::SectorFilePath(AliMpStationType station, 
210                                    AliMpPlaneType plane)
211 {
212 /// Return path to data file with sector description.
213  
214   return TString(PlaneDataDir(station, plane) + fgkSector + fgkDataExt);
215 }
216     
217 //______________________________________________________________________________
218 TString AliMpFiles::SectorSpecialFilePath(AliMpStationType station, 
219                                           AliMpPlaneType plane)
220 {
221 /// Return path to data file with sector special description (irregular motifs).
222
223   return TString(PlaneDataDir(station, plane) + fgkSectorSpecial + fgkDataExt);
224 }
225     
226 //______________________________________________________________________________
227 TString AliMpFiles::SectorSpecialFilePath2(AliMpStationType station, 
228                                            AliMpPlaneType plane)
229 {
230 /// Returns path to data file with sector special description (irregular motifs).
231
232   return TString(PlaneDataDir(station, plane) + fgkSectorSpecial2 + fgkDataExt);
233 }
234
235 //______________________________________________________________________________
236 TString AliMpFiles::MotifFileName(const TString& motifTypeID)
237 {
238   /// Returns name of data file for a given motif type.
239   
240   return TString(fgkMotifPrefix +  motifTypeID + fgkDataExt);
241 }
242
243 //______________________________________________________________________________
244 TString AliMpFiles::MotifFilePath(AliMpStationType station, 
245                                   AliMpPlaneType plane, 
246                                   const TString& motifTypeID)
247 {
248 /// Returns path to data file for a given motif type.
249
250   return TString(PlaneDataDir(station, plane) + MotifFileName(motifTypeID));
251 }
252
253 //______________________________________________________________________________
254 TString AliMpFiles::PadPosFileName(const TString& motifTypeID)
255 {
256   /// Returns name of data file with pad positions for a given motif type.
257   
258   return TString(fgkPadPosPrefix +  motifTypeID + fgkDataExt);
259 }
260
261 //______________________________________________________________________________
262 TString AliMpFiles::PadPosFilePath(AliMpStationType station, 
263                                    AliMpPlaneType plane, 
264                                    const TString& motifTypeID)
265 {
266 /// Returns path to data file with pad positions for a given motif type.
267
268   return TString(PlaneDataDir(station, plane) + PadPosFileName(motifTypeID));
269 }
270
271 //______________________________________________________________________________ 
272 TString AliMpFiles::MotifSpecialFileName(const TString& motifID)
273 {
274   /// Returns name of data file with pad dimensions for a given motif ID.
275   
276   return TString(fgkMotifSpecialPrefix + motifID + fgkDataExt);
277   
278 }
279
280 //______________________________________________________________________________ 
281 TString AliMpFiles::MotifSpecialFilePath(AliMpStationType station, 
282                                          AliMpPlaneType plane,
283                                          const TString& motifID)
284 {
285 /// Returns path to data file with pad dimensions for a given motif ID.
286
287   return TString(PlaneDataDir(station, plane) + MotifSpecialFileName(motifID));
288 }
289
290 //______________________________________________________________________________ 
291 TString AliMpFiles::BergToGCFilePath(AliMpStationType station)
292 {
293 /// Returns the path of the file which describes the correspondance between
294 /// the berg number and the gassiplex channel.
295
296   return GetTop() + fgkDataDir + StationDataDir(station)
297               + fgkBergToGCFileName + fgkDataExt;
298 }
299
300 //______________________________________________________________________________ 
301 TString AliMpFiles::ManuToSerialPath(const TString& deName, AliMpStationType station)
302 {
303 /// Returns the path of the file for the manu id to their serial number
304
305   return  GetTop() + fgkDataDir + StationDataDir(station)
306               + fgkManuToSerialDir + deName + fgkManuToSerial + fgkDataExt; 
307 }
308
309
310 //______________________________________________________________________________ 
311 void 
312 AliMpFiles::SetTopPath(const TString& topPath)
313
314   GetTop() = topPath; 
315 }
316