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():
36 // Default constructor
39 //_____________________________________________________________________________
40 AliTPCAltroMapping::AliTPCAltroMapping(const char *mappingFile):
41 AliAltroMapping(mappingFile),
52 //_____________________________________________________________________________
53 AliTPCAltroMapping::~AliTPCAltroMapping()
56 if (fInvMapping) delete [] fInvMapping;
59 //_____________________________________________________________________________
60 Bool_t AliTPCAltroMapping::ReadMapping()
62 // Initalizes the ALTRO mapping from a file
63 // Look at the TPC module for the format of
66 AliFatal("Mapping file has not been opened !");
70 fMinPadRow = 0x7fffffff;
73 fMappingSize = 2*(fMaxHWAddress+1);
74 fMapping = new Short_t[fMappingSize];
75 for (Int_t i = 0; i <= fMaxHWAddress; i++) {
76 fMapping[2*i] = fMapping[2*i+1] = -1;
79 for(Int_t i = 0; i < fNumberOfChannels ; i++) { //5504 is size of irorc mapping at ther moment only for irorc
81 if (!(*fIn >> hwAddress)) {
82 AliFatal("Syntax of the mapping file is wrong !");
85 if (hwAddress > fMaxHWAddress) {
86 AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
90 if (!(*fIn >> padrow >> pad)) {
91 AliFatal("Syntax of the mapping file is wrong !");
95 fMapping[2*hwAddress] = padrow;
96 fMapping[2*hwAddress+1] = pad;
98 if (padrow > fMaxPadRow) fMaxPadRow = padrow;
99 if (padrow < fMinPadRow) fMinPadRow = padrow;
100 if (pad > fMaxPad) fMaxPad = pad;
106 //_____________________________________________________________________________
107 Bool_t AliTPCAltroMapping::CreateInvMapping()
109 // Create the inverse mapping
110 // needed for the simulation of
112 if (fInvMapping) return kTRUE;
115 AliWarning("Mapping array was not initalized correctly ! Impossible to create the inverse mapping !");
119 Int_t nRows = fMaxPadRow - fMinPadRow + 1;
120 Int_t nPads = fMaxPad + 1;
121 Int_t invMappingSize = nRows*nPads;
123 fInvMapping = new Short_t[invMappingSize];
124 for (Int_t i = 0; i <= (fMaxPadRow - fMinPadRow); i++) {
125 for (Int_t j = 0; j <= fMaxPad; j++) fInvMapping[nPads*i+j] = -1;
128 for(Int_t i = 0; i <= fMaxHWAddress; i++) {
129 Int_t padrow = fMapping[2*i];
130 Int_t pad = fMapping[2*i+1];
131 if(padrow != -1 && pad != -1)
132 fInvMapping[nPads*(padrow-fMinPadRow)+pad] = i;
138 //_____________________________________________________________________________
139 Int_t AliTPCAltroMapping::GetHWAddress(Int_t padrow, Int_t pad, Int_t /* sector */)
141 // Get the content of the mapping array
142 // return -1 in case there is no hardware
143 // adress defined for these pad-row and pad
145 if (!CreateInvMapping()) return -1;
147 if (padrow < fMinPadRow || padrow > fMaxPadRow) {
148 AliWarning(Form("Index of pad-row (%d) outside the range (%d -> %d) !",padrow,fMinPadRow,fMaxPadRow));
152 AliWarning(Form("Index of pad (%d) outside the range (0 -> %d) !",pad,fMaxPad));
155 Int_t hwAddress = fInvMapping[(fMaxPad+1)*(padrow-fMinPadRow)+pad];
157 AliWarning(Form("Hardware (ALTRO) adress is not defined for these pad-row (%d) and pad (%d) !",padrow,pad));
162 //_____________________________________________________________________________
163 Int_t AliTPCAltroMapping::GetPadRow(Int_t hwAddress) const
166 AliWarning("Mapping array was not initalized correctly !");
169 if (hwAddress > fMaxHWAddress) {
170 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
173 Int_t padrow = fMapping[2*hwAddress];
175 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
180 //_____________________________________________________________________________
181 Int_t AliTPCAltroMapping::GetPad(Int_t hwAddress) const
184 AliWarning("Mapping array was not initalized correctly !");
187 if (hwAddress > fMaxHWAddress) {
188 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
191 Int_t pad = fMapping[2*hwAddress+1];
193 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
198 //_____________________________________________________________________________
199 Int_t AliTPCAltroMapping::GetSector(Int_t /* hwAddress */) const
201 AliWarning("Sector index is not contained in the TPC altro mapping !");