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