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 /// \class AliTPCAltroMapping
17 /// This class handles the mapping of the Altro channels in the TPC
18 /// The mapping is read from an external mapping files
20 /// \author C.Cheshkov
22 #include "AliTPCAltroMapping.h"
24 #include <Riostream.h>
29 ClassImp(AliTPCAltroMapping)
32 //_____________________________________________________________________________
33 AliTPCAltroMapping::AliTPCAltroMapping():
40 // Default constructor
43 //_____________________________________________________________________________
44 AliTPCAltroMapping::AliTPCAltroMapping(const char *mappingFile):
45 AliAltroMapping(mappingFile),
57 //_____________________________________________________________________________
58 AliTPCAltroMapping::~AliTPCAltroMapping()
62 if (fInvMapping) delete [] fInvMapping;
65 //_____________________________________________________________________________
66 Bool_t AliTPCAltroMapping::ReadMapping()
68 /// Initalizes the ALTRO mapping from a file
69 /// Look at the TPC module for the format of
73 AliFatal("Mapping file has not been opened !");
77 fMinPadRow = 0x7fffffff;
80 fMappingSize = 2*(fMaxHWAddress+1);
81 fMapping = new Short_t[fMappingSize];
82 for (Int_t i = 0; i <= fMaxHWAddress; i++) {
83 fMapping[2*i] = fMapping[2*i+1] = -1;
86 for(Int_t i = 0; i < fNumberOfChannels ; i++) { //5504 is size of irorc mapping at ther moment only for irorc
88 if (!(*fIn >> hwAddress)) {
89 AliFatal("Syntax of the mapping file is wrong !");
92 if (hwAddress > fMaxHWAddress) {
93 AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
97 if (!(*fIn >> padrow >> pad)) {
98 AliFatal("Syntax of the mapping file is wrong !");
102 fMapping[2*hwAddress] = padrow;
103 fMapping[2*hwAddress+1] = pad;
105 if (padrow > fMaxPadRow) fMaxPadRow = padrow;
106 if (padrow < fMinPadRow) fMinPadRow = padrow;
107 if (pad > fMaxPad) fMaxPad = pad;
113 //_____________________________________________________________________________
114 Bool_t AliTPCAltroMapping::CreateInvMapping()
116 /// Create the inverse mapping
117 /// needed for the simulation of
120 if (fInvMapping) return kTRUE;
123 AliWarning("Mapping array was not initalized correctly ! Impossible to create the inverse mapping !");
127 Int_t nRows = fMaxPadRow - fMinPadRow + 1;
128 Int_t nPads = fMaxPad + 1;
129 Int_t invMappingSize = nRows*nPads;
131 fInvMapping = new Short_t[invMappingSize];
132 for (Int_t i = 0; i <= (fMaxPadRow - fMinPadRow); i++) {
133 for (Int_t j = 0; j <= fMaxPad; j++) fInvMapping[nPads*i+j] = -1;
136 for(Int_t i = 0; i <= fMaxHWAddress; i++) {
137 Int_t padrow = fMapping[2*i];
138 Int_t pad = fMapping[2*i+1];
139 if(padrow != -1 && pad != -1)
140 fInvMapping[nPads*(padrow-fMinPadRow)+pad] = i;
146 //_____________________________________________________________________________
147 Int_t AliTPCAltroMapping::GetHWAddress(Int_t padrow, Int_t pad, Int_t /* sector */)
149 /// Get the content of the mapping array
150 /// return -1 in case there is no hardware
151 /// adress defined for these pad-row and pad
154 if (!CreateInvMapping()) return -1;
156 if (padrow < fMinPadRow || padrow > fMaxPadRow) {
157 AliWarning(Form("Index of pad-row (%d) outside the range (%d -> %d) !",padrow,fMinPadRow,fMaxPadRow));
161 AliWarning(Form("Index of pad (%d) outside the range (0 -> %d) !",pad,fMaxPad));
164 Int_t hwAddress = fInvMapping[(fMaxPad+1)*(padrow-fMinPadRow)+pad];
166 AliWarning(Form("Hardware (ALTRO) adress is not defined for these pad-row (%d) and pad (%d) !",padrow,pad));
171 //_____________________________________________________________________________
172 Int_t AliTPCAltroMapping::GetPadRow(Int_t hwAddress) const
175 AliWarning("Mapping array was not initalized correctly !");
178 if (hwAddress > fMaxHWAddress) {
179 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
182 Int_t padrow = fMapping[2*hwAddress];
184 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
189 //_____________________________________________________________________________
190 Int_t AliTPCAltroMapping::GetPad(Int_t hwAddress) const
193 AliWarning("Mapping array was not initalized correctly !");
196 if (hwAddress > fMaxHWAddress) {
197 AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress));
200 Int_t pad = fMapping[2*hwAddress+1];
202 AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress));
207 //_____________________________________________________________________________
208 Int_t AliTPCAltroMapping::GetSector(Int_t /* hwAddress */) const
210 AliWarning("Sector index is not contained in the TPC altro mapping !");