]>
Commit | Line | Data |
---|---|---|
dc43b139 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
7d855b04 | 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 | |
19 | /// | |
20 | /// \author C.Cheshkov | |
dc43b139 | 21 | |
22 | #include "AliTPCAltroMapping.h" | |
23 | #include "AliLog.h" | |
24 | #include <Riostream.h> | |
25 | //#include <stdlib.h> | |
26 | ||
27 | ||
7d855b04 | 28 | /// \cond CLASSIMP |
dc43b139 | 29 | ClassImp(AliTPCAltroMapping) |
7d855b04 | 30 | /// \endcond |
dc43b139 | 31 | |
44174d11 | 32 | //_____________________________________________________________________________ |
33 | AliTPCAltroMapping::AliTPCAltroMapping(): | |
34 | AliAltroMapping(), | |
35 | fMinPadRow(0), | |
36 | fMaxPadRow(0), | |
37 | fMaxPad(0), | |
44174d11 | 38 | fInvMapping(NULL) |
39 | { | |
40 | // Default constructor | |
41 | } | |
42 | ||
dc43b139 | 43 | //_____________________________________________________________________________ |
44 | AliTPCAltroMapping::AliTPCAltroMapping(const char *mappingFile): | |
45 | AliAltroMapping(mappingFile), | |
46 | fMinPadRow(0), | |
47 | fMaxPadRow(0), | |
48 | fMaxPad(0), | |
dc43b139 | 49 | fInvMapping(NULL) |
50 | { | |
7d855b04 | 51 | /// Constructor |
52 | ||
dc43b139 | 53 | ReadMapping(); |
54 | CloseMappingFile(); | |
55 | } | |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | AliTPCAltroMapping::~AliTPCAltroMapping() | |
59 | { | |
7d855b04 | 60 | /// destructor |
61 | ||
573322da | 62 | if (fInvMapping) delete [] fInvMapping; |
dc43b139 | 63 | } |
64 | ||
dc43b139 | 65 | //_____________________________________________________________________________ |
66 | Bool_t AliTPCAltroMapping::ReadMapping() | |
67 | { | |
7d855b04 | 68 | /// Initalizes the ALTRO mapping from a file |
69 | /// Look at the TPC module for the format of | |
70 | /// the mapping file | |
71 | ||
dc43b139 | 72 | if (!fIn) { |
73 | AliFatal("Mapping file has not been opened !"); | |
74 | return kFALSE; | |
75 | } | |
76 | ||
77 | fMinPadRow = 0x7fffffff; | |
78 | fMaxPadRow = 0; | |
79 | fMaxPad = 0; | |
44174d11 | 80 | fMappingSize = 2*(fMaxHWAddress+1); |
81 | fMapping = new Short_t[fMappingSize]; | |
d11035b8 | 82 | for (Int_t i = 0; i <= fMaxHWAddress; i++) { |
44174d11 | 83 | fMapping[2*i] = fMapping[2*i+1] = -1; |
dc43b139 | 84 | } |
85 | ||
86 | for(Int_t i = 0; i < fNumberOfChannels ; i++) { //5504 is size of irorc mapping at ther moment only for irorc | |
d11035b8 | 87 | Int_t hwAddress; |
88 | if (!(*fIn >> hwAddress)) { | |
dc43b139 | 89 | AliFatal("Syntax of the mapping file is wrong !"); |
90 | return kFALSE; | |
91 | } | |
d11035b8 | 92 | if (hwAddress > fMaxHWAddress) { |
93 | AliFatal(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress)); | |
dc43b139 | 94 | return kFALSE; |
95 | } | |
96 | Int_t padrow,pad; | |
97 | if (!(*fIn >> padrow >> pad)) { | |
98 | AliFatal("Syntax of the mapping file is wrong !"); | |
99 | return kFALSE; | |
100 | } | |
101 | ||
44174d11 | 102 | fMapping[2*hwAddress] = padrow; |
103 | fMapping[2*hwAddress+1] = pad; | |
dc43b139 | 104 | |
105 | if (padrow > fMaxPadRow) fMaxPadRow = padrow; | |
106 | if (padrow < fMinPadRow) fMinPadRow = padrow; | |
107 | if (pad > fMaxPad) fMaxPad = pad; | |
108 | } | |
109 | ||
573322da | 110 | return kTRUE; |
111 | } | |
112 | ||
113 | //_____________________________________________________________________________ | |
114 | Bool_t AliTPCAltroMapping::CreateInvMapping() | |
115 | { | |
7d855b04 | 116 | /// Create the inverse mapping |
117 | /// needed for the simulation of | |
118 | /// raw data | |
119 | ||
573322da | 120 | if (fInvMapping) return kTRUE; |
121 | ||
122 | if (!fMapping) { | |
123 | AliWarning("Mapping array was not initalized correctly ! Impossible to create the inverse mapping !"); | |
124 | return kFALSE; | |
125 | } | |
126 | ||
44174d11 | 127 | Int_t nRows = fMaxPadRow - fMinPadRow + 1; |
128 | Int_t nPads = fMaxPad + 1; | |
573322da | 129 | Int_t invMappingSize = nRows*nPads; |
44174d11 | 130 | |
573322da | 131 | fInvMapping = new Short_t[invMappingSize]; |
dc43b139 | 132 | for (Int_t i = 0; i <= (fMaxPadRow - fMinPadRow); i++) { |
44174d11 | 133 | for (Int_t j = 0; j <= fMaxPad; j++) fInvMapping[nPads*i+j] = -1; |
dc43b139 | 134 | } |
135 | ||
d11035b8 | 136 | for(Int_t i = 0; i <= fMaxHWAddress; i++) { |
44174d11 | 137 | Int_t padrow = fMapping[2*i]; |
138 | Int_t pad = fMapping[2*i+1]; | |
dc43b139 | 139 | if(padrow != -1 && pad != -1) |
44174d11 | 140 | fInvMapping[nPads*(padrow-fMinPadRow)+pad] = i; |
dc43b139 | 141 | } |
142 | ||
143 | return kTRUE; | |
144 | } | |
145 | ||
146 | //_____________________________________________________________________________ | |
573322da | 147 | Int_t AliTPCAltroMapping::GetHWAddress(Int_t padrow, Int_t pad, Int_t /* sector */) |
dc43b139 | 148 | { |
7d855b04 | 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 | |
152 | ||
dc43b139 | 153 | if (!fInvMapping) { |
573322da | 154 | if (!CreateInvMapping()) return -1; |
dc43b139 | 155 | } |
156 | if (padrow < fMinPadRow || padrow > fMaxPadRow) { | |
157 | AliWarning(Form("Index of pad-row (%d) outside the range (%d -> %d) !",padrow,fMinPadRow,fMaxPadRow)); | |
158 | return -1; | |
159 | } | |
160 | if (pad > fMaxPad) { | |
161 | AliWarning(Form("Index of pad (%d) outside the range (0 -> %d) !",pad,fMaxPad)); | |
162 | return -1; | |
163 | } | |
44174d11 | 164 | Int_t hwAddress = fInvMapping[(fMaxPad+1)*(padrow-fMinPadRow)+pad]; |
d11035b8 | 165 | if (hwAddress == -1) |
dc43b139 | 166 | AliWarning(Form("Hardware (ALTRO) adress is not defined for these pad-row (%d) and pad (%d) !",padrow,pad)); |
167 | ||
d11035b8 | 168 | return hwAddress; |
dc43b139 | 169 | } |
170 | ||
171 | //_____________________________________________________________________________ | |
d11035b8 | 172 | Int_t AliTPCAltroMapping::GetPadRow(Int_t hwAddress) const |
dc43b139 | 173 | { |
174 | if (!fMapping) { | |
175 | AliWarning("Mapping array was not initalized correctly !"); | |
176 | return -1; | |
177 | } | |
d11035b8 | 178 | if (hwAddress > fMaxHWAddress) { |
179 | AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress)); | |
dc43b139 | 180 | return -1; |
181 | } | |
44174d11 | 182 | Int_t padrow = fMapping[2*hwAddress]; |
dc43b139 | 183 | if (padrow == -1) |
d11035b8 | 184 | AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress)); |
dc43b139 | 185 | |
186 | return padrow; | |
187 | } | |
188 | ||
189 | //_____________________________________________________________________________ | |
d11035b8 | 190 | Int_t AliTPCAltroMapping::GetPad(Int_t hwAddress) const |
dc43b139 | 191 | { |
192 | if (!fMapping) { | |
193 | AliWarning("Mapping array was not initalized correctly !"); | |
194 | return -1; | |
195 | } | |
d11035b8 | 196 | if (hwAddress > fMaxHWAddress) { |
197 | AliWarning(Form("Hardware (ALTRO) adress (%d) outside the range (0 -> %d) !",hwAddress,fMaxHWAddress)); | |
dc43b139 | 198 | return -1; |
199 | } | |
44174d11 | 200 | Int_t pad = fMapping[2*hwAddress+1]; |
dc43b139 | 201 | if (pad == -1) |
d11035b8 | 202 | AliWarning(Form("Hardware (ALTRO) adress (%d) is not defined !",hwAddress)); |
dc43b139 | 203 | |
204 | return pad; | |
205 | } | |
206 | ||
207 | //_____________________________________________________________________________ | |
d11035b8 | 208 | Int_t AliTPCAltroMapping::GetSector(Int_t /* hwAddress */) const |
dc43b139 | 209 | { |
210 | AliWarning("Sector index is not contained in the TPC altro mapping !"); | |
211 | return -1; | |
212 | } |