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