1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // This class handles the mapping of the Altro channels in the PHOS
17 // The mapping is read from an external mapping files
20 #include "AliPHOSAltroMapping.h"
22 #include <Riostream.h>
26 ClassImp(AliPHOSAltroMapping)
28 //_____________________________________________________________________________
29 AliPHOSAltroMapping::AliPHOSAltroMapping(const char *mappingFile):
30 AliAltroMapping(mappingFile),
44 //_____________________________________________________________________________
45 AliPHOSAltroMapping::~AliPHOSAltroMapping()
48 DeleteMappingArrays();
51 //_____________________________________________________________________________
52 AliPHOSAltroMapping::AliPHOSAltroMapping(const AliPHOSAltroMapping& mapping):
53 AliAltroMapping(mapping),
54 fMinRow(mapping.fMinRow),
55 fMaxRow(mapping.fMaxRow),
56 fMinCol(mapping.fMinCol),
57 fMaxCol(mapping.fMaxCol),
58 fMapping(mapping.fMapping),
59 fInvMappingLow(mapping.fInvMappingLow),
60 fInvMappingHigh(mapping.fInvMappingHigh)
64 Fatal("AliPHOSAltroMapping", "copy constructor not implemented");
67 //_____________________________________________________________________________
68 AliPHOSAltroMapping& AliPHOSAltroMapping::operator = (const AliPHOSAltroMapping& /*mapping*/)
72 Fatal("operator =", "assignment operator not implemented");
76 //_____________________________________________________________________________
77 Bool_t AliPHOSAltroMapping::ReadMapping()
79 // Initalizes the ALTRO mapping from a file
80 // Look at the PHOS module for the format of
83 AliFatal("Mapping file has not been opened !");
91 fMapping = new Short_t*[fMaxHWAddress+1];
92 for (Int_t i = 0; i <= fMaxHWAddress; i++) {
93 fMapping[i] = new Short_t[3];
94 fMapping[i][0] = fMapping[i][1] = fMapping[i][2] = -1;
97 for(Int_t i = 0; i < fNumberOfChannels ; i++) { // 1792 = 2*896 channels connected to each RCU
99 if (!(*fIn >> hwAddress)) {
100 AliFatal("Syntax of the mapping file is wrong !");
103 if (hwAddress > fMaxHWAddress) {
104 AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
108 if (!(*fIn >> row >> col >> gain)) {
109 AliFatal("Syntax of the mapping file is wrong !");
113 if (gain < 0 || gain > 1) {
114 AliFatal(Form("Wrong gain value found (%d)! Should be 0 or 1 !",gain));
118 fMapping[hwAddress][0] = row;
119 fMapping[hwAddress][1] = col;
120 fMapping[hwAddress][2] = gain;
122 if (row > fMaxRow) fMaxRow = row;
123 if (row < fMinRow) fMinRow = row;
124 if (col > fMaxCol) fMaxCol = col;
125 if (col < fMinCol) fMinCol = col;
129 fInvMappingLow = new Short_t*[fMaxRow - fMinRow + 1];
130 fInvMappingHigh = new Short_t*[fMaxRow - fMinRow + 1];
131 for (Int_t i = 0; i <= (fMaxRow - fMinRow); i++) {
132 fInvMappingLow[i] = new Short_t[fMaxCol - fMinCol + 1];
133 fInvMappingHigh[i] = new Short_t[fMaxCol - fMinCol + 1];
134 for (Int_t j = 0; j <= (fMaxCol - fMinCol); j++) {
135 fInvMappingLow[i][j] = -1;
136 fInvMappingHigh[i][j] = -1;
140 for(Int_t i = 0; i <= fMaxHWAddress; i++) {
141 Int_t row = fMapping[i][0];
142 Int_t col = fMapping[i][1];
143 Int_t gain = fMapping[i][2];
144 if(row != -1 && col != -1) {
146 fInvMappingLow[row-fMinRow][col-fMinCol] = i;
148 fInvMappingHigh[row-fMinRow][col-fMinCol] = i;
155 //_____________________________________________________________________________
156 Int_t AliPHOSAltroMapping::GetHWAddress(Int_t row, Int_t col, Int_t gain) const
158 // Get the content of the mapping array
159 // return -1 in case there is no hardware
160 // adress defined for these row-column-gain
161 if (!fInvMappingLow || !fInvMappingHigh) {
162 AliWarning("Mapping array was not initalized correctly !");
165 if (row < fMinRow || row > fMaxRow) {
166 AliWarning(Form("Index of row (%d) outside the range (%d -> %d) !",row,fMinRow,fMaxRow));
169 if (col < fMinCol || col > fMaxCol) {
170 AliWarning(Form("Index of column (%d) outside the range (0 -> %d) !",col,fMinCol,fMaxCol));
173 if (gain < 0 || gain > 1) {
174 AliWarning(Form("Invalid gain (%d)! Should be 0 or 1 !",gain));
177 Int_t hwAddress = -1;
179 hwAddress = fInvMappingLow[row-fMinRow][col-fMinCol];
181 hwAddress = fInvMappingHigh[row-fMinRow][col-fMinCol];
184 AliWarning(Form("Hardware (ALTRO) adress is not defined for these row (%d), column (%d) and gain (%d) !",row,col,gain));
189 //_____________________________________________________________________________
190 Int_t AliPHOSAltroMapping::GetPadRow(Int_t hwAddress) const
192 // Return the row index
193 // Note the difference w.r.t to the base class notation
195 AliWarning("Mapping array was not initalized correctly !");
198 if (hwAddress > fMaxHWAddress) {
199 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
202 Int_t row = fMapping[hwAddress][0];
204 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
209 //_____________________________________________________________________________
210 Int_t AliPHOSAltroMapping::GetPad(Int_t hwAddress) const
212 // Return the column index
213 // Note the difference w.r.t to the base class notation
215 AliWarning("Mapping array was not initalized correctly !");
218 if (hwAddress > fMaxHWAddress) {
219 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
222 Int_t col = fMapping[hwAddress][1];
224 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
229 //_____________________________________________________________________________
230 Int_t AliPHOSAltroMapping::GetSector(Int_t hwAddress) const
232 // Return the gain factor (0/1)
233 // Note the difference w.r.t to the base class notation
235 AliWarning("Mapping array was not initalized correctly !");
238 if (hwAddress > fMaxHWAddress) {
239 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
242 Int_t gain = fMapping[hwAddress][2];
244 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
249 //_____________________________________________________________________________
250 void AliPHOSAltroMapping::DeleteMappingArrays()
252 // Deletes the arrays which have been
253 // allocated during the reading of the
256 for (Int_t i = 0; i <= fMaxHWAddress; i++) delete [] fMapping[i];
260 if (fInvMappingLow) {
261 for (Int_t i = 0; i <= (fMaxRow - fMinRow); i++)
262 delete [] fInvMappingLow[i];
263 delete [] fInvMappingLow;
266 if (fInvMappingHigh) {
267 for (Int_t i = 0; i <= (fMaxRow - fMinRow); i++)
268 delete [] fInvMappingHigh[i];
269 delete [] fInvMappingHigh;