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