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