]>
Commit | Line | Data |
---|---|---|
5802cf2d | 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 | // This class handles the mapping of the Altro channels | |
17 | // The mapping is read from an external mapping files | |
16e29964 | 18 | // The class is used as a base class by TPC,PHOS and FMD |
5802cf2d | 19 | // Author: C.Cheshkov |
20 | ||
21 | #include "AliAltroMapping.h" | |
22 | #include "AliLog.h" | |
23 | #include <Riostream.h> | |
5802cf2d | 24 | |
25 | ||
26 | ClassImp(AliAltroMapping) | |
27 | ||
cc934096 | 28 | //_____________________________________________________________________________ |
29 | AliAltroMapping::AliAltroMapping(): | |
30 | fIn(NULL), | |
31 | fNumberOfChannels(0), | |
44174d11 | 32 | fMaxHWAddress(0), |
33 | fMappingSize(0), | |
573322da | 34 | fMapping(NULL) |
cc934096 | 35 | { |
36 | // Default constructor | |
37 | } | |
38 | ||
5802cf2d | 39 | //_____________________________________________________________________________ |
40 | AliAltroMapping::AliAltroMapping(const char *mappingFile): | |
16e29964 | 41 | fIn(NULL), |
5802cf2d | 42 | fNumberOfChannels(0), |
44174d11 | 43 | fMaxHWAddress(0), |
44 | fMappingSize(0), | |
573322da | 45 | fMapping(NULL) |
5802cf2d | 46 | { |
47 | // Constructor | |
48 | // Reads the mapping from an external file | |
49 | if (mappingFile) | |
16e29964 | 50 | OpenMappingFile(mappingFile); |
5802cf2d | 51 | else |
52 | AliFatal("Mapping file not specified !"); | |
53 | } | |
54 | ||
55 | //_____________________________________________________________________________ | |
56 | AliAltroMapping::~AliAltroMapping() | |
57 | { | |
58 | // destructor | |
573322da | 59 | CloseMappingFile(); |
60 | ||
61 | if (fMapping) delete [] fMapping; | |
5802cf2d | 62 | } |
63 | ||
5802cf2d | 64 | //_____________________________________________________________________________ |
16e29964 | 65 | Bool_t AliAltroMapping::OpenMappingFile(const char *mappingFile) |
5802cf2d | 66 | { |
67 | // Initalizes the ALTRO mapping from a file | |
68 | // Look at the TPC module for the format of | |
69 | // the mapping file | |
16e29964 | 70 | fIn = new ifstream(mappingFile); |
71 | if (!*fIn) { | |
5802cf2d | 72 | AliFatal(Form("Missing mapping file (%s) !",mappingFile)); |
573322da | 73 | CloseMappingFile(); |
5802cf2d | 74 | return kFALSE; |
75 | } | |
16e29964 | 76 | if (!(*fIn >> fNumberOfChannels)) { |
5802cf2d | 77 | AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile)); |
573322da | 78 | CloseMappingFile(); |
5802cf2d | 79 | return kFALSE; |
80 | } | |
cc934096 | 81 | if (!(*fIn >> fMaxHWAddress)) { |
5802cf2d | 82 | AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile)); |
573322da | 83 | CloseMappingFile(); |
5802cf2d | 84 | return kFALSE; |
85 | } | |
5802cf2d | 86 | |
5802cf2d | 87 | return kTRUE; |
88 | } | |
89 | ||
90 | //_____________________________________________________________________________ | |
573322da | 91 | void AliAltroMapping::CloseMappingFile() |
5802cf2d | 92 | { |
16e29964 | 93 | // Closes the external mapping |
94 | // file | |
95 | if (fIn) { | |
96 | fIn->close(); | |
69776907 | 97 | delete fIn; |
16e29964 | 98 | fIn = NULL; |
5802cf2d | 99 | } |
5802cf2d | 100 | } |