Replacement of AliMpIntPair object with algoritmic
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpFiles.cxx
CommitLineData
dee1d5f1 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
5f91c9e8 16// $Id$
f023e45b 17// $MpId: AliMpFiles.cxx,v 1.12 2006/05/23 13:09:54 ivana Exp $
dee1d5f1 18// Category: basic
3d1463c8 19
20//-----------------------------------------------------------------------------
5f91c9e8 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//
dbe945cc 29// Included in AliRoot: 2003/05/02
5f91c9e8 30// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
3d1463c8 31//-----------------------------------------------------------------------------
5f91c9e8 32
5f91c9e8 33#include "AliMpFiles.h"
2c605e66 34
7f54909e 35#include "AliLog.h"
2c605e66 36
37#include <TClass.h>
38#include <Riostream.h>
39
40#include <stdlib.h>
5f91c9e8 41
13985652 42/// \cond CLASSIMP
43ClassImp(AliMpFiles)
44/// \endcond
7f54909e 45
13985652 46//
f023e45b 47// static
48
5f91c9e8 49// static data members
50
be2a6782 51const TString AliMpFiles::fgkDataDir = "/data";
ab167304 52const TString AliMpFiles::fgkDataRunDir = "/data_run";
be2a6782 53const TString AliMpFiles::fgkStationDir = "/station";
228fd720 54const TString AliMpFiles::fgkBendingDir = "bending_plane/";
55const TString AliMpFiles::fgkNonBendingDir = "non-bending_plane/";
0025a53e 56const TString AliMpFiles::fgkDENames = "denames";
5f91c9e8 57const TString AliMpFiles::fgkSector = "zones";
58const TString AliMpFiles::fgkSectorSpecial = "zones_special";
be2a6782 59const TString AliMpFiles::fgkSectorSpecial2 = "zones_special_outer";
5f91c9e8 60const TString AliMpFiles::fgkMotifPrefix = "motif";
61const TString AliMpFiles::fgkMotifSpecialPrefix ="motifSpecial";
ec5079b1 62const TString AliMpFiles::fgkManuToSerial ="_manu";
5f91c9e8 63const TString AliMpFiles::fgkPadPosPrefix = "padPos";
64const TString AliMpFiles::fgkDataExt = ".dat";
228fd720 65const TString AliMpFiles::fgkBergToGCFileName = "bergToGC";
40c8e44b 66const TString AliMpFiles::fgkTriggerLocalBoards = "RegionalCrate";
67const TString AliMpFiles::fgkTriggerGlobalBoards = "GlobalCrate";
4df2ac68 68const TString AliMpFiles::fgkBusPatchFileName = "DetElemIdToBusPatch";
59754717 69const TString AliMpFiles::fgkBusPatchInfoFileName = "BusPatchInfo";
ae649dcb 70const TString AliMpFiles::fgkBusPatchSpecialFileName = "BusPatchSpecial";
8b68068b 71const TString AliMpFiles::fgkSerialToBinFileName = "ManuSerialToBin";
72
5f91c9e8 73//______________________________________________________________________________
dee1d5f1 74AliMpFiles::~AliMpFiles()
75{
76/// Destructor
5f91c9e8 77}
78
5f91c9e8 79//
4e51cfd2 80// public methods
5f91c9e8 81//
82
83//______________________________________________________________________________
cddd101e 84TString AliMpFiles::PlaneDataDir(AliMp::StationType station,
4e51cfd2 85 AliMq::Station12Type station12Type,
cddd101e 86 AliMp::PlaneType plane)
5f91c9e8 87{
dee1d5f1 88/// Returns path to data files with sector description
89/// for a specified plane.
5f91c9e8 90
dee1d5f1 91 switch (station) {
4e51cfd2 92 case AliMp::kStation12:
dee1d5f1 93 switch (plane) {
cddd101e 94 case AliMp::kBendingPlane:
4e51cfd2 95 return GetTop() + fgkDataDir + StationDataDir(station, station12Type) + fgkBendingDir;
dee1d5f1 96 ;;
cddd101e 97 case AliMp::kNonBendingPlane:
4e51cfd2 98 return GetTop() + fgkDataDir + StationDataDir(station, station12Type) + fgkNonBendingDir;
dee1d5f1 99 ;;
100 }
101 break;
cddd101e 102 case AliMp::kStation345:
103 case AliMp::kStationTrigger:
4e51cfd2 104 return GetTop() + fgkDataDir + StationDataDir(station, AliMq::kNotSt12);
7f54909e 105 break;
106 default:
cddd101e 107 AliFatalClass("Incomplete switch on AliMp::PlaneType");
dee1d5f1 108 break;
109 }
5f91c9e8 110 return TString();
111}
112
be2a6782 113//______________________________________________________________________________
4e51cfd2 114TString AliMpFiles::StationDataDir(AliMp::StationType station,
115 AliMq::Station12Type station12Type)
be2a6782 116{
dee1d5f1 117/// Returns the station directory name for the specified station number.
be2a6782 118
119 TString stationDataDir(fgkStationDir);
120 switch (station) {
4e51cfd2 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 }
dee1d5f1 135 break;
136 ;;
cddd101e 137 case AliMp::kStation345:
dee1d5f1 138 stationDataDir += "345/";
139 break;
140 ;;
cddd101e 141 case AliMp::kStationTrigger:
7f54909e 142 stationDataDir += "Trigger/";
143 break;
144 ;;
145 default:
146 stationDataDir += "Invalid/";
147 break;
be2a6782 148 }
149 return stationDataDir;
150}
151
4df2ac68 152//______________________________________________________________________________
153TString AliMpFiles::BusPatchFilePath()
154{
155/// Return path to data file with bus patch mapping.
156
d9100e8b 157 return GetTop() + fgkDataDir + "/" + fgkBusPatchFileName + fgkDataExt;
4df2ac68 158}
159
160//______________________________________________________________________________
59754717 161TString AliMpFiles::BusPatchInfoFilePath()
0b121e9e 162{
163/// Return path to data file with bus patch mapping.
164
59754717 165 return GetTop() + fgkDataDir + "/" + fgkBusPatchInfoFileName + fgkDataExt;
0b121e9e 166}
167
168//______________________________________________________________________________
ae649dcb 169TString AliMpFiles::BusPatchSpecialFilePath()
170{
171/// Return path to data file with special bus patch mapping.
172
173 return GetTop() + fgkDataDir + "/" + fgkBusPatchSpecialFileName + fgkDataExt;
174}
175
176//______________________________________________________________________________
8b68068b 177TString 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//______________________________________________________________________________
4e51cfd2 186TString AliMpFiles::DENamesFilePath(AliMp::StationType station,
187 AliMq::Station12Type station12Type)
0025a53e 188{
189/// Return path to data file with DE names for given station.
190
4e51cfd2 191 return GetTop() + fgkDataDir + StationDataDir(station, station12Type)
192 + fgkDENames + fgkDataExt;
0025a53e 193}
194
195//______________________________________________________________________________
4df2ac68 196TString AliMpFiles::LocalTriggerBoardMapping()
197{
f023e45b 198/// Return path to data file with local trigger board mapping.
490da820 199
4e51cfd2 200 return GetTop() + fgkDataDir
201 + StationDataDir(AliMp::kStationTrigger, AliMq::kNotSt12)
f023e45b 202 + fgkTriggerLocalBoards + fgkDataExt;;
4df2ac68 203}
204
40c8e44b 205//______________________________________________________________________________
206TString AliMpFiles::GlobalTriggerBoardMapping()
207{
208/// Return path to data file with local trigger board mapping.
209
4e51cfd2 210 return GetTop() + fgkDataDir
211 + StationDataDir(AliMp::kStationTrigger, AliMq::kNotSt12)
40c8e44b 212 + fgkTriggerGlobalBoards + fgkDataExt;;
213}
214
dee1d5f1 215//_____________________________________________________________________________
cddd101e 216TString AliMpFiles::SlatFilePath(AliMp::StationType stationType,
7f54909e 217 const char* slatType,
cddd101e 218 AliMp::PlaneType plane)
dee1d5f1 219{
220/// \todo add ..
221
4e51cfd2 222 return TString(PlaneDataDir(stationType, AliMq::kNotSt12, plane)
223 + slatType + "." +
cddd101e 224 ( plane == AliMp::kNonBendingPlane ? "NonBending":"Bending" ) + ".slat");
dee1d5f1 225}
226
227//_____________________________________________________________________________
cddd101e 228TString AliMpFiles::SlatPCBFilePath(AliMp::StationType stationType,
7f54909e 229 const char* pcbType)
dee1d5f1 230{
231/// Get the full path for a given PCB (only relevant to stations 3,
7f54909e 232/// 4, 5 and trigger). The bending parameter below is of no use in this case, but
dee1d5f1 233/// we use it to re-use the PlaneDataDir() method untouched.
234
4e51cfd2 235 return TString(PlaneDataDir(stationType, AliMq::kNotSt12, AliMp::kNonBendingPlane)
236 + pcbType + ".pcb");
dee1d5f1 237}
238
7f54909e 239//______________________________________________________________________________
4e51cfd2 240TString AliMpFiles::SectorFilePath(AliMq::Station12Type station12Type,
cddd101e 241 AliMp::PlaneType plane)
5f91c9e8 242{
dee1d5f1 243/// Return path to data file with sector description.
5f91c9e8 244
4e51cfd2 245 return TString(PlaneDataDir(AliMp::kStation12, station12Type, plane)
246 + fgkSector + fgkDataExt);
be2a6782 247}
248
249//______________________________________________________________________________
4e51cfd2 250TString AliMpFiles::SectorSpecialFilePath(AliMq::Station12Type station12Type,
cddd101e 251 AliMp::PlaneType plane)
be2a6782 252{
dee1d5f1 253/// Return path to data file with sector special description (irregular motifs).
be2a6782 254
4e51cfd2 255 return TString(PlaneDataDir(AliMp::kStation12, station12Type, plane)
256 + fgkSectorSpecial + fgkDataExt);
5f91c9e8 257}
258
259//______________________________________________________________________________
4e51cfd2 260TString AliMpFiles::SectorSpecialFilePath2(AliMq::Station12Type station12Type,
cddd101e 261 AliMp::PlaneType plane)
5f91c9e8 262{
dee1d5f1 263/// Returns path to data file with sector special description (irregular motifs).
5f91c9e8 264
4e51cfd2 265 return TString(PlaneDataDir(AliMp::kStation12, station12Type, plane)
266 + fgkSectorSpecial2 + fgkDataExt);
5f91c9e8 267}
82915841 268
269//______________________________________________________________________________
270TString 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
5f91c9e8 277//______________________________________________________________________________
cddd101e 278TString AliMpFiles::MotifFilePath(AliMp::StationType station,
4e51cfd2 279 AliMq::Station12Type station12Type,
cddd101e 280 AliMp::PlaneType plane,
7f54909e 281 const TString& motifTypeID)
5f91c9e8 282{
dee1d5f1 283/// Returns path to data file for a given motif type.
5f91c9e8 284
4e51cfd2 285 return TString(PlaneDataDir(station, station12Type, plane)
286 + MotifFileName(motifTypeID));
5f91c9e8 287}
82915841 288
289//______________________________________________________________________________
290TString 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
5f91c9e8 297//______________________________________________________________________________
cddd101e 298TString AliMpFiles::PadPosFilePath(AliMp::StationType station,
4e51cfd2 299 AliMq::Station12Type station12Type,
cddd101e 300 AliMp::PlaneType plane,
7f54909e 301 const TString& motifTypeID)
5f91c9e8 302{
dee1d5f1 303/// Returns path to data file with pad positions for a given motif type.
5f91c9e8 304
4e51cfd2 305 return TString(PlaneDataDir(station, station12Type, plane)
306 + PadPosFileName(motifTypeID));
82915841 307}
308
309//______________________________________________________________________________
310TString 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
5f91c9e8 316}
317
318//______________________________________________________________________________
cddd101e 319TString AliMpFiles::MotifSpecialFilePath(AliMp::StationType station,
4e51cfd2 320 AliMq::Station12Type station12Type,
cddd101e 321 AliMp::PlaneType plane,
7f54909e 322 const TString& motifID)
5f91c9e8 323{
dee1d5f1 324/// Returns path to data file with pad dimensions for a given motif ID.
5f91c9e8 325
4e51cfd2 326 return TString(PlaneDataDir(station, station12Type, plane)
327 + MotifSpecialFileName(motifID));
5f91c9e8 328}
329
330//______________________________________________________________________________
4e51cfd2 331TString AliMpFiles::BergToGCFilePath(AliMp::StationType station,
332 AliMq::Station12Type station12Type)
5f91c9e8 333{
dee1d5f1 334/// Returns the path of the file which describes the correspondance between
335/// the berg number and the gassiplex channel.
5f91c9e8 336
4e51cfd2 337 return GetTop() + fgkDataDir + StationDataDir(station, station12Type)
be2a6782 338 + fgkBergToGCFileName + fgkDataExt;
5f91c9e8 339}
7f54909e 340
341//______________________________________________________________________________
4e51cfd2 342TString AliMpFiles::ManuToSerialPath(const TString& deName,
343 AliMp::StationType station,
344 AliMq::Station12Type station12Type)
ec5079b1 345{
346/// Returns the path of the file for the manu id to their serial number
347
4e51cfd2 348 return GetTop() + fgkDataRunDir + StationDataDir(station, station12Type)
ab167304 349 + deName + fgkManuToSerial + fgkDataExt;
ec5079b1 350}
351
352
353//______________________________________________________________________________
7f54909e 354void
355AliMpFiles::SetTopPath(const TString& topPath)
356{
71a2d3aa 357/// Set top file path
358
d9100e8b 359 GetTop() = topPath;
7f54909e 360}
361
228fd720 362//______________________________________________________________________________
363TString 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