]>
Commit | Line | Data |
---|---|---|
dc43b139 | 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 in the TPC | |
17 | // The mapping is read from an external mapping files | |
18 | // Author: C.Cheshkov | |
19 | ||
20 | #include "AliTPCAltroMapping.h" | |
21 | #include "AliLog.h" | |
22 | #include <Riostream.h> | |
23 | //#include <stdlib.h> | |
24 | ||
25 | ||
26 | ClassImp(AliTPCAltroMapping) | |
27 | ||
28 | //_____________________________________________________________________________ | |
29 | AliTPCAltroMapping::AliTPCAltroMapping(const char *mappingFile): | |
30 | AliAltroMapping(mappingFile), | |
31 | fMinPadRow(0), | |
32 | fMaxPadRow(0), | |
33 | fMaxPad(0), | |
34 | fMapping(NULL), | |
35 | fInvMapping(NULL) | |
36 | { | |
37 | // Constructor | |
38 | ReadMapping(); | |
39 | CloseMappingFile(); | |
40 | } | |
41 | ||
42 | //_____________________________________________________________________________ | |
43 | AliTPCAltroMapping::~AliTPCAltroMapping() | |
44 | { | |
45 | // destructor | |
46 | DeleteMappingArrays(); | |
47 | } | |
48 | ||
49 | //_____________________________________________________________________________ | |
50 | AliTPCAltroMapping::AliTPCAltroMapping(const AliTPCAltroMapping& mapping): | |
51 | AliAltroMapping(mapping), | |
52 | fMinPadRow(mapping.fMinPadRow), | |
53 | fMaxPadRow(mapping.fMaxPadRow), | |
54 | fMaxPad(mapping.fMaxPad), | |
55 | fMapping(mapping.fMapping), | |
56 | fInvMapping(mapping.fInvMapping) | |
57 | { | |
58 | // Copy Constructor | |
59 | ||
60 | Fatal("AliTPCAltroMapping", "copy constructor not implemented"); | |
61 | } | |
62 | ||
63 | //_____________________________________________________________________________ | |
64 | AliTPCAltroMapping& AliTPCAltroMapping::operator = (const AliTPCAltroMapping& /*mapping*/) | |
65 | { | |
66 | //Assigment operator | |
67 | ||
68 | Fatal("operator =", "assignment operator not implemented"); | |
69 | return *this; | |
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | Bool_t AliTPCAltroMapping::ReadMapping() | |
74 | { | |
75 | // Initalizes the ALTRO mapping from a file | |
76 | // Look at the TPC module for the format of | |
77 | // the mapping file | |
78 | if (!fIn) { | |
79 | AliFatal("Mapping file has not been opened !"); | |
80 | return kFALSE; | |
81 | } | |
82 | ||
83 | fMinPadRow = 0x7fffffff; | |
84 | fMaxPadRow = 0; | |
85 | fMaxPad = 0; | |
d11035b8 | 86 | fMapping = new Short_t*[fMaxHWAddress+1]; |
87 | for (Int_t i = 0; i <= fMaxHWAddress; i++) { | |
dc43b139 | 88 | fMapping[i] = new Short_t[2]; |
89 | fMapping[i][0] = fMapping[i][1] = -1; | |
90 | } | |
91 | ||
92 | for(Int_t i = 0; i < fNumberOfChannels ; i++) { //5504 is size of irorc mapping at ther moment only for irorc | |
d11035b8 | 93 | Int_t hwAddress; |
94 | if (!(*fIn >> hwAddress)) { | |
dc43b139 | 95 | AliFatal("Syntax of the mapping file is wrong !"); |
96 | return kFALSE; | |
97 | } | |
d11035b8 | 98 | if (hwAddress > fMaxHWAddress) { |
99 | AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress)); | |
dc43b139 | 100 | return kFALSE; |
101 | } | |
102 | Int_t padrow,pad; | |
103 | if (!(*fIn >> padrow >> pad)) { | |
104 | AliFatal("Syntax of the mapping file is wrong !"); | |
105 | return kFALSE; | |
106 | } | |
107 | ||
d11035b8 | 108 | fMapping[hwAddress][0] = padrow; |
109 | fMapping[hwAddress][1] = pad; | |
dc43b139 | 110 | |
111 | if (padrow > fMaxPadRow) fMaxPadRow = padrow; | |
112 | if (padrow < fMinPadRow) fMinPadRow = padrow; | |
113 | if (pad > fMaxPad) fMaxPad = pad; | |
114 | } | |
115 | ||
116 | fInvMapping = new Short_t*[fMaxPadRow - fMinPadRow + 1]; | |
117 | for (Int_t i = 0; i <= (fMaxPadRow - fMinPadRow); i++) { | |
118 | fInvMapping[i] = new Short_t[fMaxPad + 1]; | |
119 | for (Int_t j = 0; j <= fMaxPad; j++) fInvMapping[i][j] = -1; | |
120 | } | |
121 | ||
d11035b8 | 122 | for(Int_t i = 0; i <= fMaxHWAddress; i++) { |
dc43b139 | 123 | Int_t padrow = fMapping[i][0]; |
124 | Int_t pad = fMapping[i][1]; | |
125 | if(padrow != -1 && pad != -1) | |
126 | fInvMapping[padrow-fMinPadRow][pad] = i; | |
127 | } | |
128 | ||
129 | return kTRUE; | |
130 | } | |
131 | ||
132 | //_____________________________________________________________________________ | |
d11035b8 | 133 | Int_t AliTPCAltroMapping::GetHWAddress(Int_t padrow, Int_t pad, Int_t /* sector */) const |
dc43b139 | 134 | { |
135 | // Get the content of the mapping array | |
136 | // return -1 in case there is no hardware | |
137 | // adress defined for these pad-row and pad | |
138 | if (!fInvMapping) { | |
139 | AliWarning("Mapping array was not initalized correctly !"); | |
140 | return -1; | |
141 | } | |
142 | if (padrow < fMinPadRow || padrow > fMaxPadRow) { | |
143 | AliWarning(Form("Index of pad-row (%d) outside the range (%d -> %d) !",padrow,fMinPadRow,fMaxPadRow)); | |
144 | return -1; | |
145 | } | |
146 | if (pad > fMaxPad) { | |
147 | AliWarning(Form("Index of pad (%d) outside the range (0 -> %d) !",pad,fMaxPad)); | |
148 | return -1; | |
149 | } | |
d11035b8 | 150 | Int_t hwAddress = fInvMapping[padrow-fMinPadRow][pad]; |
151 | if (hwAddress == -1) | |
dc43b139 | 152 | AliWarning(Form("Hardware (ALTRO) adress is not defined for these pad-row (%d) and pad (%d) !",padrow,pad)); |
153 | ||
d11035b8 | 154 | return hwAddress; |
dc43b139 | 155 | } |
156 | ||
157 | //_____________________________________________________________________________ | |
d11035b8 | 158 | Int_t AliTPCAltroMapping::GetPadRow(Int_t hwAddress) const |
dc43b139 | 159 | { |
160 | if (!fMapping) { | |
161 | AliWarning("Mapping array was not initalized correctly !"); | |
162 | return -1; | |
163 | } | |
d11035b8 | 164 | if (hwAddress > fMaxHWAddress) { |
165 | AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress)); | |
dc43b139 | 166 | return -1; |
167 | } | |
d11035b8 | 168 | Int_t padrow = fMapping[hwAddress][0]; |
dc43b139 | 169 | if (padrow == -1) |
d11035b8 | 170 | AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress)); |
dc43b139 | 171 | |
172 | return padrow; | |
173 | } | |
174 | ||
175 | //_____________________________________________________________________________ | |
d11035b8 | 176 | Int_t AliTPCAltroMapping::GetPad(Int_t hwAddress) const |
dc43b139 | 177 | { |
178 | if (!fMapping) { | |
179 | AliWarning("Mapping array was not initalized correctly !"); | |
180 | return -1; | |
181 | } | |
d11035b8 | 182 | if (hwAddress > fMaxHWAddress) { |
183 | AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress)); | |
dc43b139 | 184 | return -1; |
185 | } | |
d11035b8 | 186 | Int_t pad = fMapping[hwAddress][1]; |
dc43b139 | 187 | if (pad == -1) |
d11035b8 | 188 | AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress)); |
dc43b139 | 189 | |
190 | return pad; | |
191 | } | |
192 | ||
193 | //_____________________________________________________________________________ | |
d11035b8 | 194 | Int_t AliTPCAltroMapping::GetSector(Int_t /* hwAddress */) const |
dc43b139 | 195 | { |
196 | AliWarning("Sector index is not contained in the TPC altro mapping !"); | |
197 | return -1; | |
198 | } | |
199 | ||
200 | //_____________________________________________________________________________ | |
201 | void AliTPCAltroMapping::DeleteMappingArrays() | |
202 | { | |
203 | // Deletes the arrays which have been | |
204 | // allocated during the reading of the | |
205 | // mapping file | |
206 | if (fMapping) { | |
d11035b8 | 207 | for (Int_t i = 0; i <= fMaxHWAddress; i++) delete [] fMapping[i]; |
dc43b139 | 208 | delete [] fMapping; |
209 | } | |
210 | ||
211 | if (fInvMapping) { | |
212 | for (Int_t i = 0; i <= (fMaxPadRow - fMinPadRow); i++) | |
213 | delete [] fInvMapping[i]; | |
214 | delete [] fInvMapping; | |
215 | } | |
216 | } |