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 TPC
17 // The mapping is read from an external mapping files
20 #include "AliTPCAltroMapping.h"
22 #include <Riostream.h>
26 ClassImp(AliTPCAltroMapping)
28 //_____________________________________________________________________________
29 AliTPCAltroMapping::AliTPCAltroMapping(const char *mappingFile):
30 AliAltroMapping(mappingFile),
42 //_____________________________________________________________________________
43 AliTPCAltroMapping::~AliTPCAltroMapping()
46 DeleteMappingArrays();
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)
60 Fatal("AliTPCAltroMapping", "copy constructor not implemented");
63 //_____________________________________________________________________________
64 AliTPCAltroMapping& AliTPCAltroMapping::operator = (const AliTPCAltroMapping& /*mapping*/)
68 Fatal("operator =", "assignment operator not implemented");
72 //_____________________________________________________________________________
73 Bool_t AliTPCAltroMapping::ReadMapping()
75 // Initalizes the ALTRO mapping from a file
76 // Look at the TPC module for the format of
79 AliFatal("Mapping file has not been opened !");
83 fMinPadRow = 0x7fffffff;
86 fMapping = new Short_t*[fMaxHWAddress+1];
87 for (Int_t i = 0; i <= fMaxHWAddress; i++) {
88 fMapping[i] = new Short_t[2];
89 fMapping[i][0] = fMapping[i][1] = -1;
92 for(Int_t i = 0; i < fNumberOfChannels ; i++) { //5504 is size of irorc mapping at ther moment only for irorc
94 if (!(*fIn >> hwAddress)) {
95 AliFatal("Syntax of the mapping file is wrong !");
98 if (hwAddress > fMaxHWAddress) {
99 AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
103 if (!(*fIn >> padrow >> pad)) {
104 AliFatal("Syntax of the mapping file is wrong !");
108 fMapping[hwAddress][0] = padrow;
109 fMapping[hwAddress][1] = pad;
111 if (padrow > fMaxPadRow) fMaxPadRow = padrow;
112 if (padrow < fMinPadRow) fMinPadRow = padrow;
113 if (pad > fMaxPad) fMaxPad = pad;
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;
122 for(Int_t i = 0; i <= fMaxHWAddress; i++) {
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;
132 //_____________________________________________________________________________
133 Int_t AliTPCAltroMapping::GetHWAddress(Int_t padrow, Int_t pad, Int_t /* sector */) const
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
139 AliWarning("Mapping array was not initalized correctly !");
142 if (padrow < fMinPadRow || padrow > fMaxPadRow) {
143 AliWarning(Form("Index of pad-row (%d) outside the range (%d -> %d) !",padrow,fMinPadRow,fMaxPadRow));
147 AliWarning(Form("Index of pad (%d) outside the range (0 -> %d) !",pad,fMaxPad));
150 Int_t hwAddress = fInvMapping[padrow-fMinPadRow][pad];
152 AliWarning(Form("Hardware (ALTRO) adress is not defined for these pad-row (%d) and pad (%d) !",padrow,pad));
157 //_____________________________________________________________________________
158 Int_t AliTPCAltroMapping::GetPadRow(Int_t hwAddress) const
161 AliWarning("Mapping array was not initalized correctly !");
164 if (hwAddress > fMaxHWAddress) {
165 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
168 Int_t padrow = fMapping[hwAddress][0];
170 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
175 //_____________________________________________________________________________
176 Int_t AliTPCAltroMapping::GetPad(Int_t hwAddress) const
179 AliWarning("Mapping array was not initalized correctly !");
182 if (hwAddress > fMaxHWAddress) {
183 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
186 Int_t pad = fMapping[hwAddress][1];
188 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
193 //_____________________________________________________________________________
194 Int_t AliTPCAltroMapping::GetSector(Int_t /* hwAddress */) const
196 AliWarning("Sector index is not contained in the TPC altro mapping !");
200 //_____________________________________________________________________________
201 void AliTPCAltroMapping::DeleteMappingArrays()
203 // Deletes the arrays which have been
204 // allocated during the reading of the
207 for (Int_t i = 0; i <= fMaxHWAddress; i++) delete [] fMapping[i];
212 for (Int_t i = 0; i <= (fMaxPadRow - fMinPadRow); i++)
213 delete [] fInvMapping[i];
214 delete [] fInvMapping;