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