]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpFiles.cxx
Updates to AddTask macro from Chris
[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 using std::endl;
43 /// \cond CLASSIMP
44 ClassImp(AliMpFiles)
45 /// \endcond
46
47 //
48 // static private methods
49 //
50
51 //______________________________________________________________________________
52 const TString& AliMpFiles::GetDataDir() 
53 {
54   /// data directory
55   static const TString kDataDir = "/data";
56   return kDataDir;
57 }  
58   
59 //______________________________________________________________________________
60 const TString& AliMpFiles::GetDataRunDir() 
61 {
62   /// directory for run dependent data
63   static const TString kDataRunDir = "/data_run";
64   return kDataRunDir;
65 }
66
67 //______________________________________________________________________________
68 const TString& AliMpFiles::GetStationDir() 
69 {
70   /// station directory
71   static const TString kStationDir = "/station";
72   return kStationDir;
73 }  
74   
75 //______________________________________________________________________________
76 const TString& AliMpFiles::GetBendingDir() 
77 {
78   /// bending plane directory
79   static const TString kBendingDir = "bending_plane/";
80   return kBendingDir;
81 }  
82   
83 //______________________________________________________________________________
84 const TString& AliMpFiles::GetNonBendingDir() 
85 {
86   /// non-bending plane directory
87   static const TString kNonBendingDir = "non-bending_plane/";
88   return kNonBendingDir;
89 }  
90
91 //______________________________________________________________________________
92 const TString& AliMpFiles::GetDENames() 
93 {
94   /// DE names data file name
95   static const TString kDENames = "denames"; 
96   return kDENames;
97 }  
98   
99 //______________________________________________________________________________
100 const TString& AliMpFiles::GetSector() 
101 {
102   /// sector data file name
103   static const TString kSector  = "zones"; 
104   return kSector;
105 }  
106   
107 //______________________________________________________________________________
108 const TString& AliMpFiles::GetSectorSpecial() 
109 {
110   /// sector special data file name
111   static const TString kSectorSpecial = "zones_special";
112   return kSectorSpecial;
113 }  
114   
115 //______________________________________________________________________________
116 const TString& AliMpFiles::GetSectorSpecial2() 
117 {
118   /// sector special data file name
119   static const TString kSectorSpecial2 = "zones_special_outer";
120   return kSectorSpecial2;
121 }  
122
123 //______________________________________________________________________________
124 const TString& AliMpFiles::GetMotifPrefix() 
125 {
126   /// motif data file name
127   static const TString kMotifPrefix   = "motif"; 
128   return kMotifPrefix;
129 }   
130     
131
132 //______________________________________________________________________________
133 const TString& AliMpFiles::GetMotifSpecialPrefix() 
134 {
135   /// special motif data file name 
136   static const TString kMotifSpecialPrefix ="motifSpecial";
137   return kMotifSpecialPrefix;
138 }  
139
140 //______________________________________________________________________________
141 const TString& AliMpFiles::GetManuToSerial() 
142 {
143   /// manu to serial file name suffix
144   static const TString kManuToSerial ="_manu";
145   return kManuToSerial;
146 }  
147
148 //______________________________________________________________________________
149 const TString& AliMpFiles::GetPadPosPrefix() 
150 {  
151   /// pad position data file name
152   static const TString kPadPosPrefix  = "padPos"; 
153   return kPadPosPrefix;
154 }  
155
156 //______________________________________________________________________________
157 const TString& AliMpFiles::GetDataExt() 
158 {
159   /// file extension
160   static const TString kDataExt = ".dat"; 
161   return kDataExt;
162 }
163        
164 //______________________________________________________________________________
165 const TString& AliMpFiles::GetBergToGCFileName() 
166 {
167   /// BergToGC mapping file name
168   static const TString kBergToGCFileName = "bergToGC"; 
169   return kBergToGCFileName;
170 }  
171
172 //______________________________________________________________________________
173 const TString& AliMpFiles::GetTriggerLocalBoards() 
174 {
175   ///  local board name to id mapping
176   static const TString kTriggerLocalBoards = "RegionalCrate";
177   return kTriggerLocalBoards;
178 }  
179
180 //______________________________________________________________________________
181 const TString& AliMpFiles::GetTriggerGlobalBoards() 
182 {
183   ///  global board name to id mapping
184   static const TString kTriggerGlobalBoards = "GlobalCrate";
185   return kTriggerGlobalBoards;
186 }  
187   
188 //______________________________________________________________________________
189 const TString& AliMpFiles::GetBusPatchFileName() 
190 {
191   /// DetElemIdToBusPatch file name
192   static const TString kBusPatchFileName = "DetElemIdToBusPatch";
193   return kBusPatchFileName;
194 }  
195   
196 //______________________________________________________________________________
197 const TString& AliMpFiles::GetBusPatchInfoFileName() 
198 {
199   /// BusPatch length file name
200   static const TString kBusPatchInfoFileName = "BusPatchInfo";
201   return kBusPatchInfoFileName;
202 }  
203   
204 //______________________________________________________________________________
205 const TString& AliMpFiles::GetBusPatchSpecialFileName() 
206 {
207   /// BusPatch special file name
208   static const TString kBusPatchSpecialFileName = "BusPatchSpecial";
209   return kBusPatchSpecialFileName;
210 }  
211   
212 //______________________________________________________________________________
213 const TString& AliMpFiles::GetSerialToBinFileName() 
214 {
215   /// serial to bin  number file name
216   static const TString kSerialToBinFileName = "ManuSerialToBin";
217   return kSerialToBinFileName;
218 }  
219   
220 //
221 // static public methods
222 //
223
224 //______________________________________________________________________________
225 TString AliMpFiles::PlaneDataDir(AliMp::StationType station, 
226                                  AliMq::Station12Type station12Type,
227                                  AliMp::PlaneType plane)
228 {
229 /// Returns path to data files with sector description
230 /// for a specified plane.
231
232   switch (station) {
233   case AliMp::kStation12:
234     switch (plane) {
235     case AliMp::kBendingPlane:
236       return GetTop() + GetDataDir() + StationDataDir(station, station12Type) + GetBendingDir();
237       ;;
238     case AliMp::kNonBendingPlane:   
239       return GetTop() + GetDataDir() + StationDataDir(station, station12Type) + GetNonBendingDir();
240       ;;
241     }   
242     break;
243   case AliMp::kStation345:
244   case AliMp::kStationTrigger:  
245     return GetTop() + GetDataDir() + StationDataDir(station, AliMq::kNotSt12);
246     break;
247   default:  
248     AliFatalClass("Incomplete switch on AliMp::PlaneType");
249     break;
250   }
251   return TString();
252 }
253
254 //______________________________________________________________________________
255 TString AliMpFiles::StationDataDir(AliMp::StationType station,
256                                    AliMq::Station12Type station12Type)
257 {
258 /// Returns the station directory name for the specified station number.
259
260   TString stationDataDir(GetStationDir());
261   switch (station) {
262   case AliMp::kStation12: 
263     switch (station12Type) {
264     case AliMq::kStation1:
265       stationDataDir += "1/";
266       break;
267       ;;
268     case AliMq::kStation2:   
269       stationDataDir += "2/";
270       break;
271       ;;
272     case AliMq::kNotSt12:   
273       AliFatalClass("Incorrect switch on AliMq::Station12Type");
274       break;
275     }   
276     break;
277     ;;
278   case AliMp::kStation345: 
279     stationDataDir += "345/";
280     break;
281     ;;      
282   case AliMp::kStationTrigger:
283     stationDataDir += "Trigger/";
284     break;
285     ;;
286   default:
287     stationDataDir += "Invalid/";
288     break;
289   }   
290   return stationDataDir;
291 }
292
293 //______________________________________________________________________________
294 TString AliMpFiles::BusPatchFilePath()
295 {
296 /// Return path to data file with bus patch mapping.
297
298   return GetTop() + GetDataDir() + "/" + GetBusPatchFileName() + GetDataExt();
299 }  
300
301 //______________________________________________________________________________
302 TString AliMpFiles::BusPatchInfoFilePath()
303 {
304 /// Return path to data file with bus patch mapping.
305
306   return GetTop() + GetDataDir() + "/" + GetBusPatchInfoFileName() + GetDataExt();
307 }  
308
309 //______________________________________________________________________________
310 TString AliMpFiles::BusPatchSpecialFilePath()
311 {
312 /// Return path to data file with special bus patch mapping.
313
314   return GetTop() + GetDataDir() + "/" + GetBusPatchSpecialFileName() + GetDataExt();
315 }  
316
317 //______________________________________________________________________________
318 TString AliMpFiles::SerialToBinFilePath()
319 {
320 /// Return path to data file containing manu serial numbers with their bin.
321
322   return GetTop() + GetDataDir() + "/" + GetSerialToBinFileName() + GetDataExt();
323 }  
324
325
326 //______________________________________________________________________________
327 TString AliMpFiles::DENamesFilePath(AliMp::StationType station,
328                                     AliMq::Station12Type station12Type)
329 {
330 /// Return path to data file with DE names for given station.
331  
332   return GetTop() + GetDataDir() + StationDataDir(station, station12Type) 
333            + GetDENames() + GetDataExt();
334 }
335
336 //______________________________________________________________________________
337 TString AliMpFiles::LocalTriggerBoardMapping()
338 {
339 /// Return path to data file with local trigger board mapping.
340
341   return GetTop() + GetDataDir() 
342           + StationDataDir(AliMp::kStationTrigger, AliMq::kNotSt12) 
343           + GetTriggerLocalBoards() + GetDataExt();;
344 }
345
346 //______________________________________________________________________________
347 TString AliMpFiles::GlobalTriggerBoardMapping()
348 {
349 /// Return path to data file with local trigger board mapping.
350
351   return GetTop() + GetDataDir() 
352       + StationDataDir(AliMp::kStationTrigger, AliMq::kNotSt12) 
353       + GetTriggerGlobalBoards() + GetDataExt();;
354 }
355
356 //_____________________________________________________________________________
357 TString AliMpFiles::SlatFilePath(AliMp::StationType stationType,
358                                  const char* slatType,
359                                  AliMp::PlaneType plane)
360 {
361 /// \todo add ..
362
363   return TString(PlaneDataDir(stationType, AliMq::kNotSt12, plane) 
364                  + slatType + "." +
365                  ( plane == AliMp::kNonBendingPlane ? "NonBending":"Bending" ) + ".slat");
366 }
367
368 //_____________________________________________________________________________
369 TString AliMpFiles::SlatPCBFilePath(AliMp::StationType stationType,
370                                     const char* pcbType)
371 {
372 /// Get the full path for a given PCB (only relevant to stations 3,
373 /// 4, 5 and trigger). The bending parameter below is of no use in this case, but
374 /// we use it to re-use the PlaneDataDir() method untouched.
375
376   return TString(PlaneDataDir(stationType, AliMq::kNotSt12, AliMp::kNonBendingPlane) 
377                  + pcbType + ".pcb");
378 }
379
380 //______________________________________________________________________________
381 TString AliMpFiles::SectorFilePath(AliMq::Station12Type station12Type, 
382                                    AliMp::PlaneType plane)
383 {
384 /// Return path to data file with sector description.
385  
386   return TString(PlaneDataDir(AliMp::kStation12, station12Type, plane) 
387                  + GetSector() + GetDataExt());
388 }
389     
390 //______________________________________________________________________________
391 TString AliMpFiles::SectorSpecialFilePath(AliMq::Station12Type station12Type,
392                                           AliMp::PlaneType plane)
393 {
394 /// Return path to data file with sector special description (irregular motifs).
395
396   return TString(PlaneDataDir(AliMp::kStation12, station12Type, plane) 
397                  + GetSectorSpecial() + GetDataExt());
398 }
399     
400 //______________________________________________________________________________
401 TString AliMpFiles::SectorSpecialFilePath2(AliMq::Station12Type station12Type, 
402                                            AliMp::PlaneType plane)
403 {
404 /// Returns path to data file with sector special description (irregular motifs).
405
406   return TString(PlaneDataDir(AliMp::kStation12, station12Type, plane) 
407                  + GetSectorSpecial2() + GetDataExt());
408 }
409
410 //______________________________________________________________________________
411 TString AliMpFiles::MotifFileName(const TString& motifTypeID)
412 {
413   /// Returns name of data file for a given motif type.
414   
415   return TString(GetMotifPrefix() +  motifTypeID + GetDataExt());
416 }
417
418 //______________________________________________________________________________
419 TString AliMpFiles::MotifFilePath(AliMp::StationType station, 
420                                   AliMq::Station12Type station12Type,
421                                   AliMp::PlaneType plane, 
422                                   const TString& motifTypeID)
423 {
424 /// Returns path to data file for a given motif type.
425
426   return TString(PlaneDataDir(station, station12Type, plane) 
427                  + MotifFileName(motifTypeID));
428 }
429
430 //______________________________________________________________________________
431 TString AliMpFiles::PadPosFileName(const TString& motifTypeID)
432 {
433   /// Returns name of data file with pad positions for a given motif type.
434   
435   return TString(GetPadPosPrefix() +  motifTypeID + GetDataExt());
436 }
437
438 //______________________________________________________________________________
439 TString AliMpFiles::PadPosFilePath(AliMp::StationType station, 
440                                    AliMq::Station12Type station12Type,
441                                    AliMp::PlaneType plane, 
442                                    const TString& motifTypeID)
443 {
444 /// Returns path to data file with pad positions for a given motif type.
445
446   return TString(PlaneDataDir(station, station12Type, plane) 
447                  + PadPosFileName(motifTypeID));
448 }
449
450 //______________________________________________________________________________ 
451 TString AliMpFiles::MotifSpecialFileName(const TString& motifID)
452 {
453   /// Returns name of data file with pad dimensions for a given motif ID.
454   
455   return TString(GetMotifSpecialPrefix() + motifID + GetDataExt());
456   
457 }
458
459 //______________________________________________________________________________ 
460 TString AliMpFiles::MotifSpecialFilePath(AliMp::StationType station, 
461                                          AliMq::Station12Type station12Type,
462                                          AliMp::PlaneType plane,
463                                          const TString& motifID)
464 {
465 /// Returns path to data file with pad dimensions for a given motif ID.
466
467   return TString(PlaneDataDir(station, station12Type, plane) 
468                  + MotifSpecialFileName(motifID));
469 }
470
471 //______________________________________________________________________________ 
472 TString AliMpFiles::BergToGCFilePath(AliMp::StationType station,
473                                      AliMq::Station12Type station12Type)
474 {
475 /// Returns the path of the file which describes the correspondance between
476 /// the berg number and the gassiplex channel.
477
478   return GetTop() + GetDataDir() + StationDataDir(station, station12Type)
479               + GetBergToGCFileName() + GetDataExt();
480 }
481
482 //______________________________________________________________________________ 
483 TString AliMpFiles::ManuToSerialPath(const TString& deName, 
484                                      AliMp::StationType station,
485                                      AliMq::Station12Type station12Type)
486 {
487 /// Returns the path of the file for the manu id to their serial number
488
489   return  GetTop() + GetDataRunDir() + StationDataDir(station, station12Type)
490               + deName + GetManuToSerial() + GetDataExt(); 
491 }
492
493
494 //______________________________________________________________________________ 
495 void 
496 AliMpFiles::SetTopPath(const TString& topPath)
497
498 /// Set top file path
499
500   GetTop() = topPath; 
501 }
502
503 //______________________________________________________________________________
504 TString AliMpFiles::GetTop()
505 {
506 /// Return top path to mapping data defined either via MINSTALL
507 /// or ALICE_ROOT environment variable.                                      \n
508 /// If both variables are defined, MINSTALL is used.
509
510   TString top = getenv("MINSTALL");    
511   if ( ! top.IsNull() ) return top;
512
513   TString ntop = getenv("ALICE_ROOT");
514   if ( ntop.IsNull() ) {
515     AliErrorClassStream() << "Cannot find path to mapping data." << endl;
516     return ntop;
517   }  
518   ntop += "/MUON/mapping";
519   return ntop;
520 }
521
522 //
523 // ctors, dtor
524 //
525
526 //______________________________________________________________________________
527 AliMpFiles::~AliMpFiles() 
528 {
529 /// Destructor
530 }
531