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