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():
37 // Default constructor
40 //_____________________________________________________________________________
41 AliTPCAltroMapping::AliTPCAltroMapping(const char *mappingFile):
42 AliAltroMapping(mappingFile),
54 //_____________________________________________________________________________
55 AliTPCAltroMapping::~AliTPCAltroMapping()
58 DeleteMappingArrays();
61 //_____________________________________________________________________________
62 Bool_t AliTPCAltroMapping::ReadMapping()
64 // Initalizes the ALTRO mapping from a file
65 // Look at the TPC module for the format of
68 AliFatal("Mapping file has not been opened !");
72 fMinPadRow = 0x7fffffff;
75 fMappingSize = 2*(fMaxHWAddress+1);
76 fMapping = new Short_t[fMappingSize];
77 for (Int_t i = 0; i <= fMaxHWAddress; i++) {
78 fMapping[2*i] = fMapping[2*i+1] = -1;
81 for(Int_t i = 0; i < fNumberOfChannels ; i++) { //5504 is size of irorc mapping at ther moment only for irorc
83 if (!(*fIn >> hwAddress)) {
84 AliFatal("Syntax of the mapping file is wrong !");
87 if (hwAddress > fMaxHWAddress) {
88 AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
92 if (!(*fIn >> padrow >> pad)) {
93 AliFatal("Syntax of the mapping file is wrong !");
97 fMapping[2*hwAddress] = padrow;
98 fMapping[2*hwAddress+1] = pad;
100 if (padrow > fMaxPadRow) fMaxPadRow = padrow;
101 if (padrow < fMinPadRow) fMinPadRow = padrow;
102 if (pad > fMaxPad) fMaxPad = pad;
105 Int_t nRows = fMaxPadRow - fMinPadRow + 1;
106 Int_t nPads = fMaxPad + 1;
107 fInvMappingSize = nRows*nPads;
109 fInvMapping = new Short_t[fInvMappingSize];
110 for (Int_t i = 0; i <= (fMaxPadRow - fMinPadRow); i++) {
111 for (Int_t j = 0; j <= fMaxPad; j++) fInvMapping[nPads*i+j] = -1;
114 for(Int_t i = 0; i <= fMaxHWAddress; i++) {
115 Int_t padrow = fMapping[2*i];
116 Int_t pad = fMapping[2*i+1];
117 if(padrow != -1 && pad != -1)
118 fInvMapping[nPads*(padrow-fMinPadRow)+pad] = i;
124 //_____________________________________________________________________________
125 Int_t AliTPCAltroMapping::GetHWAddress(Int_t padrow, Int_t pad, Int_t /* sector */) const
127 // Get the content of the mapping array
128 // return -1 in case there is no hardware
129 // adress defined for these pad-row and pad
131 AliWarning("Mapping array was not initalized correctly !");
134 if (padrow < fMinPadRow || padrow > fMaxPadRow) {
135 AliWarning(Form("Index of pad-row (%d) outside the range (%d -> %d) !",padrow,fMinPadRow,fMaxPadRow));
139 AliWarning(Form("Index of pad (%d) outside the range (0 -> %d) !",pad,fMaxPad));
142 Int_t hwAddress = fInvMapping[(fMaxPad+1)*(padrow-fMinPadRow)+pad];
144 AliWarning(Form("Hardware (ALTRO) adress is not defined for these pad-row (%d) and pad (%d) !",padrow,pad));
149 //_____________________________________________________________________________
150 Int_t AliTPCAltroMapping::GetPadRow(Int_t hwAddress) const
153 AliWarning("Mapping array was not initalized correctly !");
156 if (hwAddress > fMaxHWAddress) {
157 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
160 Int_t padrow = fMapping[2*hwAddress];
162 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
167 //_____________________________________________________________________________
168 Int_t AliTPCAltroMapping::GetPad(Int_t hwAddress) const
171 AliWarning("Mapping array was not initalized correctly !");
174 if (hwAddress > fMaxHWAddress) {
175 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
178 Int_t pad = fMapping[2*hwAddress+1];
180 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
185 //_____________________________________________________________________________
186 Int_t AliTPCAltroMapping::GetSector(Int_t /* hwAddress */) const
188 AliWarning("Sector index is not contained in the TPC altro mapping !");
192 //_____________________________________________________________________________
193 void AliTPCAltroMapping::DeleteMappingArrays()
195 // Deletes the arrays which have been
196 // allocated during the reading of the
198 if (fMapping) delete [] fMapping;
200 if (fInvMapping) delete [] fInvMapping;