]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliAltroMapping.cxx
rlu_hijing has to be float to work correctly with gfortran (Fedora Core 7)
[u/mrichter/AliRoot.git] / RAW / AliAltroMapping.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 // This class handles the mapping of the Altro channels
17 // The mapping is read from an external mapping files
18 // The class is used as a base class by TPC,PHOS and FMD
19 // Author: C.Cheshkov
20
21 #include "AliAltroMapping.h"
22 #include "AliLog.h"
23 #include <Riostream.h>
24 //#include <stdlib.h>
25
26
27 ClassImp(AliAltroMapping)
28
29 //_____________________________________________________________________________
30 AliAltroMapping::AliAltroMapping():
31   fIn(NULL),
32   fNumberOfChannels(0),
33   fMaxHWAddress(0)
34 {
35   // Default constructor
36 }
37
38 //_____________________________________________________________________________
39 AliAltroMapping::AliAltroMapping(const char *mappingFile):
40   fIn(NULL),
41   fNumberOfChannels(0),
42   fMaxHWAddress(0)
43 {
44   // Constructor
45   // Reads the mapping from an external file
46   if (mappingFile)
47     OpenMappingFile(mappingFile);
48   else
49     AliFatal("Mapping file not specified !");
50 }
51
52 //_____________________________________________________________________________
53 AliAltroMapping::~AliAltroMapping()
54 {
55   CloseMappingFile();
56   // destructor
57 }
58
59 //_____________________________________________________________________________
60 AliAltroMapping::AliAltroMapping(const AliAltroMapping& mapping):
61   TObject(mapping),
62   fIn(mapping.fIn),
63   fNumberOfChannels(mapping.fNumberOfChannels),
64   fMaxHWAddress(mapping.fMaxHWAddress)
65 {
66 // Copy Constructor
67
68   Fatal("AliAltroMapping", "copy constructor not implemented");
69 }
70
71 //_____________________________________________________________________________
72 AliAltroMapping& AliAltroMapping::operator = (const AliAltroMapping& /*mapping*/)
73 {
74 //Assigment operator
75
76   Fatal("operator =", "assignment operator not implemented");
77   return *this;
78 }
79
80 //_____________________________________________________________________________
81 Bool_t AliAltroMapping::OpenMappingFile(const char *mappingFile)
82 {
83   // Initalizes the ALTRO mapping from a file
84   // Look at the TPC module for the format of
85   // the mapping file
86   fIn = new ifstream(mappingFile);
87   if (!*fIn) {
88     AliFatal(Form("Missing mapping file (%s) !",mappingFile));
89     return kFALSE;
90   }
91   if (!(*fIn >> fNumberOfChannels)) {
92     AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
93     return kFALSE;
94   }
95   if (!(*fIn >> fMaxHWAddress)) {
96     AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
97     return kFALSE;
98   }
99
100   return kTRUE;
101 }
102
103 //_____________________________________________________________________________
104 Bool_t AliAltroMapping::CloseMappingFile()
105 {
106   // Closes the external mapping
107   // file
108   if (fIn) {
109     fIn->close();
110     delete fIn;
111     fIn = NULL;
112   }
113
114   return kTRUE;
115 }