]>
Commit | Line | Data |
---|---|---|
a09a2da4 | 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 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | /// | |
20 | /// This class provides access to PMD digits in raw data. | |
21 | /// | |
22 | /// It loops over all PMD digits in the raw data given by the AliRawReader. | |
23 | /// The Next method goes to the next digit. If there are no digits left | |
24 | /// it returns kFALSE. | |
25 | /// Several getters provide information about the current digit. | |
26 | /// | |
27 | /////////////////////////////////////////////////////////////////////////////// | |
28 | ||
34ab69dd | 29 | #include <Riostream.h> |
30 | #include <TObjArray.h> | |
31 | #include <TString.h> | |
32 | #include <TSystem.h> | |
33 | ||
ecee2a1a | 34 | #include "AliLog.h" |
34ab69dd | 35 | #include "AliPMDBlockHeader.h" |
36 | #include "AliPMDDspHeader.h" | |
37 | #include "AliPMDPatchBusHeader.h" | |
38 | #include "AliPMDddldata.h" | |
a09a2da4 | 39 | #include "AliPMDRawStream.h" |
3d8b8ac5 | 40 | #include "AliPMDMappingData.h" |
a09a2da4 | 41 | #include "AliRawReader.h" |
3d8b8ac5 | 42 | #include "AliCDBManager.h" |
43 | #include "AliCDBStorage.h" | |
44 | #include "AliCDBEntry.h" | |
a09a2da4 | 45 | |
46 | ClassImp(AliPMDRawStream) | |
47 | ||
48 | ||
49 | //_____________________________________________________________________________ | |
50 | AliPMDRawStream::AliPMDRawStream(AliRawReader* rawReader) : | |
722ccc67 | 51 | fRawReader(rawReader), |
52 | fData(NULL), | |
3d8b8ac5 | 53 | fPosition(-1), |
54 | fMapData(GetMappingData()) | |
a09a2da4 | 55 | { |
56 | // create an object to read PMD raw digits | |
57 | ||
722ccc67 | 58 | fRawReader->Reset(); |
362c9d61 | 59 | fRawReader->Select("PMD"); |
a09a2da4 | 60 | } |
61 | ||
62 | //_____________________________________________________________________________ | |
63 | AliPMDRawStream::AliPMDRawStream(const AliPMDRawStream& stream) : | |
64 | TObject(stream), | |
722ccc67 | 65 | fRawReader(NULL), |
66 | fData(NULL), | |
3d8b8ac5 | 67 | fPosition(-1), |
68 | fMapData(GetMappingData()) | |
a09a2da4 | 69 | { |
70 | // copy constructor | |
71 | ||
ecee2a1a | 72 | AliFatal("Copy constructor not implemented"); |
a09a2da4 | 73 | } |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | AliPMDRawStream& AliPMDRawStream::operator = (const AliPMDRawStream& | |
77 | /* stream */) | |
78 | { | |
79 | // assignment operator | |
80 | ||
ecee2a1a | 81 | AliFatal("operator = assignment operator not implemented"); |
a09a2da4 | 82 | return *this; |
83 | } | |
84 | ||
85 | //_____________________________________________________________________________ | |
86 | AliPMDRawStream::~AliPMDRawStream() | |
87 | { | |
88 | // destructor | |
89 | ||
90 | } | |
91 | ||
92 | ||
93 | //_____________________________________________________________________________ | |
34ab69dd | 94 | |
722ccc67 | 95 | Int_t AliPMDRawStream::DdlData(TObjArray *pmdddlcont) |
a09a2da4 | 96 | { |
08cf9354 | 97 | // read the next raw digit |
98 | // returns kFALSE if there is no digit left | |
99 | ||
6b1a10fc | 100 | Int_t iddl = -1; |
40f4a63f | 101 | |
34ab69dd | 102 | AliPMDddldata *pmdddldata; |
103 | ||
8c89425f | 104 | if (!fRawReader->ReadHeader()) return -1; |
722ccc67 | 105 | |
106 | iddl = fRawReader->GetDDLID(); | |
34ab69dd | 107 | Int_t dataSize = fRawReader->GetDataSize(); |
108 | Int_t totaldataword = dataSize/4; | |
9ac124a2 | 109 | |
08cf9354 | 110 | |
8c89425f | 111 | if (dataSize <= 0) return -1; |
a09a2da4 | 112 | |
113 | UInt_t data; | |
722ccc67 | 114 | |
115 | fRawReader->ReadNextData(fData); | |
116 | ||
117 | fPosition = 0; | |
a09a2da4 | 118 | |
a09a2da4 | 119 | |
89f0ae35 | 120 | Int_t ibus; |
34ab69dd | 121 | |
40f4a63f | 122 | const Int_t kNPatchBus = 51; |
89f0ae35 | 123 | |
34ab69dd | 124 | Int_t moduleNo[kNPatchBus], mcmperBus[kNPatchBus]; |
125 | Int_t startRowBus[kNPatchBus], endRowBus[kNPatchBus]; | |
126 | Int_t startColBus[kNPatchBus], endColBus[kNPatchBus]; | |
127 | ||
78fc1b96 | 128 | for (ibus = 0; ibus < kNPatchBus; ibus++) |
34ab69dd | 129 | { |
89f0ae35 | 130 | moduleNo[ibus] = -1; |
34ab69dd | 131 | mcmperBus[ibus] = -1; |
132 | startRowBus[ibus] = -1; | |
133 | endRowBus[ibus] = -1; | |
134 | startColBus[ibus] = -1; | |
135 | endColBus[ibus] = -1; | |
136 | } | |
3d8b8ac5 | 137 | |
89f0ae35 | 138 | if (iddl == 0) |
08cf9354 | 139 | { |
3d8b8ac5 | 140 | Ddl0Mapping(moduleNo, mcmperBus, startRowBus, |
89f0ae35 | 141 | endRowBus, startColBus, endColBus); |
08cf9354 | 142 | |
143 | } | |
89f0ae35 | 144 | else if (iddl == 1) |
08cf9354 | 145 | { |
3d8b8ac5 | 146 | Ddl1Mapping(moduleNo, mcmperBus, startRowBus, |
89f0ae35 | 147 | endRowBus, startColBus, endColBus); |
08cf9354 | 148 | |
149 | } | |
89f0ae35 | 150 | else if (iddl == 2) |
08cf9354 | 151 | { |
3d8b8ac5 | 152 | Ddl2Mapping(moduleNo, mcmperBus, startRowBus, |
89f0ae35 | 153 | endRowBus, startColBus, endColBus); |
08cf9354 | 154 | } |
89f0ae35 | 155 | else if (iddl == 3) |
08cf9354 | 156 | { |
3d8b8ac5 | 157 | Ddl3Mapping(moduleNo, mcmperBus, startRowBus, |
89f0ae35 | 158 | endRowBus, startColBus, endColBus); |
08cf9354 | 159 | } |
89f0ae35 | 160 | else if (iddl == 4) |
08cf9354 | 161 | { |
3d8b8ac5 | 162 | Ddl4Mapping(moduleNo, mcmperBus, startRowBus, |
89f0ae35 | 163 | endRowBus, startColBus, endColBus); |
08cf9354 | 164 | } |
89f0ae35 | 165 | else if (iddl == 5) |
08cf9354 | 166 | { |
3d8b8ac5 | 167 | Ddl5Mapping(moduleNo, mcmperBus, startRowBus, |
89f0ae35 | 168 | endRowBus, startColBus, endColBus); |
169 | } | |
34ab69dd | 170 | |
34ab69dd | 171 | |
34ab69dd | 172 | AliPMDBlockHeader blockHeader; |
173 | AliPMDDspHeader dspHeader; | |
174 | AliPMDPatchBusHeader pbusHeader; | |
175 | ||
0a666212 | 176 | const Int_t kblHLen = blockHeader.GetHeaderLength(); |
177 | const Int_t kdspHLen = dspHeader.GetHeaderLength(); | |
178 | const Int_t kpbusHLen = pbusHeader.GetHeaderLength(); | |
179 | ||
a98f9d26 | 180 | Int_t parity; |
34ab69dd | 181 | Int_t idet, ismn; |
182 | Int_t irow = -1; | |
183 | Int_t icol = -1; | |
184 | ||
0a666212 | 185 | Int_t blHeaderWord[8]; |
186 | Int_t dspHeaderWord[10]; | |
187 | Int_t pbusHeaderWord[4]; | |
34ab69dd | 188 | |
722ccc67 | 189 | Int_t blRawDataLength = 0; |
190 | Int_t dspRawDataLength = 0; | |
191 | Int_t iwordddl = 2; | |
9ac124a2 | 192 | |
91e6e2a0 | 193 | |
194 | ||
34ab69dd | 195 | for (Int_t iblock = 0; iblock < 2; iblock++) |
196 | { | |
8c89425f | 197 | for (Int_t i = 0; i < kblHLen; i++) |
34ab69dd | 198 | { |
722ccc67 | 199 | iwordddl++; |
200 | ||
8c89425f | 201 | blHeaderWord[i] = (Int_t) GetNextWord(); |
34ab69dd | 202 | } |
9ac124a2 | 203 | |
0a666212 | 204 | blockHeader.SetHeader(blHeaderWord); |
9ac124a2 | 205 | blRawDataLength = blockHeader.GetRawDataLength(); |
206 | ||
8c89425f | 207 | if (iwordddl == totaldataword) break; |
722ccc67 | 208 | |
209 | Int_t iwordblk = 0; | |
210 | ||
34ab69dd | 211 | for (Int_t idsp = 0; idsp < 5; idsp++) |
212 | { | |
8c89425f | 213 | for (Int_t i = 0; i < kdspHLen; i++) |
34ab69dd | 214 | { |
722ccc67 | 215 | iwordddl++; |
216 | iwordblk++; | |
8c89425f | 217 | dspHeaderWord[i] = (Int_t) GetNextWord(); |
34ab69dd | 218 | } |
0a666212 | 219 | dspHeader.SetHeader(dspHeaderWord); |
722ccc67 | 220 | dspRawDataLength = dspHeader.GetRawDataLength(); |
221 | ||
8c89425f | 222 | if (iwordddl == totaldataword) break; |
722ccc67 | 223 | |
224 | Int_t iworddsp = 0; | |
34ab69dd | 225 | |
78fc1b96 | 226 | for (ibus = 0; ibus < 5; ibus++) |
34ab69dd | 227 | { |
8c89425f | 228 | for (Int_t i = 0; i < kpbusHLen; i++) |
34ab69dd | 229 | { |
722ccc67 | 230 | iwordddl++; |
231 | iwordblk++; | |
232 | iworddsp++; | |
8c89425f | 233 | pbusHeaderWord[i] = (Int_t) GetNextWord(); |
34ab69dd | 234 | } |
722ccc67 | 235 | |
0a666212 | 236 | pbusHeader.SetHeader(pbusHeaderWord); |
34ab69dd | 237 | Int_t rawdatalength = pbusHeader.GetRawDataLength(); |
238 | Int_t pbusid = pbusHeader.GetPatchBusId(); | |
239 | ||
8c89425f | 240 | if (pbusid < 0 || pbusid > 50) return -1; |
34ab69dd | 241 | |
242 | Int_t imodule = moduleNo[pbusid]; | |
243 | ||
8c89425f | 244 | if (iwordddl == totaldataword) break; |
34ab69dd | 245 | |
8c89425f | 246 | for (Int_t iword = 0; iword < rawdatalength; iword++) |
34ab69dd | 247 | { |
722ccc67 | 248 | iwordddl++; |
249 | iwordblk++; | |
250 | iworddsp++; | |
251 | data = 0; | |
252 | data = GetNextWord(); | |
34ab69dd | 253 | |
254 | Int_t isig = data & 0x0FFF; | |
255 | Int_t ich = (data >> 12) & 0x003F; | |
256 | Int_t imcm = (data >> 18) & 0x07FF; | |
257 | Int_t ibit = (data >> 31) & 0x0001; | |
8c89425f | 258 | |
259 | if (imcm == 0) | |
260 | { | |
261 | AliWarning(Form("FEE address WRONG:: Module %d Patch Bus %d MCM %d",imodule,pbusid,imcm)); | |
262 | return -1; | |
263 | } | |
264 | ||
a98f9d26 | 265 | parity = ComputeParity(data); |
8c89425f | 266 | |
a98f9d26 | 267 | if (ibit != parity) |
268 | { | |
2c1131dd | 269 | AliWarning(Form("Parity Error:: Patch Bus %d Module %d",pbusid,imodule)); |
608c1f27 | 270 | fRawReader->AddMajorErrorLog(kParityError); |
8c89425f | 271 | return -1; |
a98f9d26 | 272 | } |
40f4a63f | 273 | |
274 | ConvertDDL2SMN(iddl, imodule, ismn, idet); | |
275 | ||
08cf9354 | 276 | GetRowCol(imodule, pbusid, imcm, ich, |
34ab69dd | 277 | startRowBus, endRowBus, |
278 | startColBus, endColBus, | |
279 | irow, icol); | |
280 | ||
08cf9354 | 281 | |
34ab69dd | 282 | TransformH2S(ismn, irow, icol); |
283 | ||
284 | pmdddldata = new AliPMDddldata(); | |
285 | ||
286 | pmdddldata->SetDetector(idet); | |
287 | pmdddldata->SetSMN(ismn); | |
288 | pmdddldata->SetModule(imodule); | |
289 | pmdddldata->SetPatchBusId(pbusid); | |
290 | pmdddldata->SetMCM(imcm); | |
291 | pmdddldata->SetChannel(ich); | |
292 | pmdddldata->SetRow(irow); | |
293 | pmdddldata->SetColumn(icol); | |
294 | pmdddldata->SetSignal(isig); | |
295 | pmdddldata->SetParityBit(ibit); | |
296 | ||
297 | pmdddlcont->Add(pmdddldata); | |
08cf9354 | 298 | |
0a666212 | 299 | } // data word loop |
9ac124a2 | 300 | |
08cf9354 | 301 | |
722ccc67 | 302 | if (iwordddl == totaldataword) break; |
303 | ||
8c89425f | 304 | if (dspHeader.GetPaddingWord() == 1) |
305 | { | |
306 | if (iworddsp == dspRawDataLength-1) break; // raw data | |
307 | } | |
308 | else | |
309 | { | |
310 | if (iworddsp == dspRawDataLength) break; // raw data | |
311 | } | |
08cf9354 | 312 | |
313 | ||
0a666212 | 314 | } // patch bus loop |
34ab69dd | 315 | |
08cf9354 | 316 | |
722ccc67 | 317 | if (dspHeader.GetPaddingWord() == 1) |
318 | { | |
722ccc67 | 319 | iwordddl++; |
320 | iwordblk++; | |
321 | iworddsp++; | |
322 | data = GetNextWord(); | |
323 | } | |
8c89425f | 324 | if (iwordddl == totaldataword) break; |
722ccc67 | 325 | |
326 | if (iwordblk == blRawDataLength) break; // for raw data | |
34ab69dd | 327 | |
08cf9354 | 328 | |
0a666212 | 329 | } // end of DSP |
34ab69dd | 330 | |
331 | } // end of BLOCK | |
34ab69dd | 332 | |
722ccc67 | 333 | return iddl; |
a09a2da4 | 334 | } |
a09a2da4 | 335 | //_____________________________________________________________________________ |
08cf9354 | 336 | void AliPMDRawStream::GetRowCol(Int_t imodule, Int_t pbusid, |
34ab69dd | 337 | UInt_t mcmno, UInt_t chno, |
338 | Int_t startRowBus[], Int_t endRowBus[], | |
339 | Int_t startColBus[], Int_t endColBus[], | |
340 | Int_t &row, Int_t &col) const | |
a09a2da4 | 341 | { |
08cf9354 | 342 | // decode: ddlno, patchbusid, mcmno, chno -> um, row, col |
a09a2da4 | 343 | |
40f4a63f | 344 | UInt_t iCh[64]; |
a09a2da4 | 345 | |
40f4a63f | 346 | static const UInt_t kChDdl01[64] = { 9, 6, 5, 10, 1, 2, 0, 3, |
347 | 13, 7, 4, 11, 8, 14, 12, 15, | |
348 | 16, 19, 17, 23, 20, 27, 24, 18, | |
349 | 28, 31, 29, 30, 21, 26, 25, 22, | |
350 | 41, 38, 37, 42, 33, 34, 32, 35, | |
351 | 45, 39, 36, 43, 40, 46, 44, 47, | |
352 | 48, 51, 49, 55, 52, 59, 56, 50, | |
353 | 60, 63, 61, 62, 53, 58, 57, 54 }; | |
354 | ||
355 | static const UInt_t kChDdl23[64] = { 54, 57, 58, 53, 62, 61, 63, 60, | |
356 | 50, 56, 59, 52, 55, 49, 51, 48, | |
357 | 47, 44, 46, 40, 43, 36, 39, 45, | |
358 | 35, 32, 34, 33, 42, 37, 38, 41, | |
359 | 22, 25, 26, 21, 30, 29, 31, 28, | |
360 | 18, 24, 27, 20, 23, 17, 19, 16, | |
361 | 15, 12, 14, 8, 11, 4, 7, 13, | |
362 | 3, 0, 2, 1, 10, 5, 6, 9 }; | |
363 | ||
364 | static const UInt_t kChDdl41[64] = { 53, 58, 57, 54, 61, 62, 60, 63, | |
365 | 49, 59, 56, 55, 52, 50, 48, 51, | |
366 | 44, 47, 45, 43, 40, 39, 36, 46, | |
367 | 32, 35, 33, 34, 41, 38, 37, 42, | |
368 | 21, 26, 25, 22, 29, 30, 28, 31, | |
369 | 17, 27, 24, 23, 20, 18, 16, 19, | |
370 | 12, 15, 13, 11, 8, 7, 4, 14, | |
371 | 0, 3, 1, 2, 9, 6, 5, 10 }; | |
372 | ||
373 | static const UInt_t kChDdl42[64] = { 10, 5, 6, 9, 2, 1, 3, 0, | |
374 | 14, 4, 7, 8, 11, 13, 15, 12, | |
375 | 19, 16, 18, 20, 23, 24, 27, 17, | |
376 | 31, 28, 30, 29, 22, 25, 26, 21, | |
377 | 42, 37, 38, 41, 34, 33, 35, 32, | |
378 | 46, 36, 39, 40, 43, 45, 47, 44, | |
379 | 51, 48, 50, 52, 55, 56, 59, 49, | |
380 | 63, 60, 62, 61, 54, 57, 58, 53 }; | |
381 | ||
382 | static const UInt_t kChDdl51[64] = { 10, 5, 6, 9, 2, 1, 3, 0, | |
383 | 14, 4, 7, 8, 11, 13, 15, 12, | |
384 | 19, 16, 18, 20, 23, 24, 27, 17, | |
385 | 31, 28, 30, 29, 22, 25, 26, 21, | |
386 | 42, 37, 38, 41, 34, 33, 35, 32, | |
387 | 46, 36, 39, 40, 43, 45, 47, 44, | |
388 | 51, 48, 50, 52, 55, 56, 59, 49, | |
389 | 63, 60, 62, 61, 54, 57, 58, 53 }; | |
390 | ||
391 | static const UInt_t kChDdl52[64] = { 53, 58, 57, 54, 61, 62, 60, 63, | |
392 | 49, 59, 56, 55, 52, 50, 48, 51, | |
393 | 44, 47, 45, 43, 40, 39, 36, 46, | |
394 | 32, 35, 33, 34, 41, 38, 37, 42, | |
395 | 21, 26, 25, 22, 29, 30, 28, 31, | |
396 | 17, 27, 24, 23, 20, 18, 16, 19, | |
397 | 12, 15, 13, 11, 8, 7, 4, 14, | |
398 | 0, 3, 1, 2, 9, 6, 5, 10 }; | |
399 | ||
400 | for (Int_t i = 0; i < 64; i++) | |
08cf9354 | 401 | { |
402 | if(imodule < 6) iCh[i] = kChDdl01[i]; | |
403 | if(imodule >= 6 && imodule <= 11) iCh[i] = kChDdl01[i]; | |
404 | if(imodule >= 12 && imodule <= 17) iCh[i] = kChDdl23[i]; | |
405 | if(imodule >= 18 && imodule <= 23) iCh[i] = kChDdl23[i]; | |
406 | if(imodule >= 24 && imodule <= 29) iCh[i] = kChDdl41[i]; | |
407 | if(imodule >= 42 && imodule <= 47) iCh[i] = kChDdl42[i]; | |
408 | if(imodule >= 36 && imodule <= 41) iCh[i] = kChDdl51[i]; | |
409 | if(imodule >= 30 && imodule <= 35) iCh[i] = kChDdl52[i]; | |
410 | } | |
40f4a63f | 411 | |
412 | ||
413 | Int_t rowcol = iCh[chno]; | |
34ab69dd | 414 | Int_t irownew = rowcol/4; |
415 | Int_t icolnew = rowcol%4; | |
a09a2da4 | 416 | |
08cf9354 | 417 | |
418 | if (imodule < 6 ) | |
a09a2da4 | 419 | { |
a0a6a406 | 420 | row = startRowBus[pbusid] + irownew; |
40f4a63f | 421 | col = startColBus[pbusid] + (mcmno-1)*4 + icolnew; |
a09a2da4 | 422 | } |
08cf9354 | 423 | else if (imodule >= 6 && imodule < 12) |
a09a2da4 | 424 | { |
08cf9354 | 425 | row = endRowBus[pbusid] - (15 - irownew); |
426 | col = startColBus[pbusid] + (mcmno-1)*4 + icolnew; | |
427 | ||
a09a2da4 | 428 | } |
08cf9354 | 429 | else if (imodule >= 12 && imodule < 18 ) |
e54787da | 430 | { |
34ab69dd | 431 | row = startRowBus[pbusid] + irownew; |
40f4a63f | 432 | col = endColBus[pbusid] - (mcmno-1)*4 - (3 - icolnew); |
34ab69dd | 433 | } |
08cf9354 | 434 | else if (imodule >= 18 && imodule < 24) |
34ab69dd | 435 | { |
08cf9354 | 436 | row = endRowBus[pbusid] - (15 - irownew); |
437 | col = endColBus[pbusid] - (mcmno-1)*4 - (3 - icolnew); | |
e54787da | 438 | } |
08cf9354 | 439 | else if (imodule >= 24 && imodule < 30) |
e54787da | 440 | { |
08cf9354 | 441 | Int_t rowdiff = endRowBus[pbusid] - startRowBus[pbusid]; |
442 | if(rowdiff > 16) | |
e54787da | 443 | { |
40f4a63f | 444 | if (mcmno <= 12) |
34ab69dd | 445 | { |
446 | // Add 16 to skip the 1st 15 rows | |
447 | row = startRowBus[pbusid] + irownew + 16; | |
40f4a63f | 448 | col = startColBus[pbusid] + (mcmno-1)*4 + icolnew; |
34ab69dd | 449 | } |
40f4a63f | 450 | else if(mcmno > 12) |
93622f4a | 451 | { |
452 | row = startRowBus[pbusid] + irownew; | |
40f4a63f | 453 | col = startColBus[pbusid] + (mcmno-12-1)*4 + icolnew; |
93622f4a | 454 | } |
e54787da | 455 | } |
08cf9354 | 456 | else if (rowdiff < 16) |
e54787da | 457 | { |
08cf9354 | 458 | row = startRowBus[pbusid] + irownew; |
459 | col = startColBus[pbusid] + (mcmno-1)*4 + icolnew; | |
e54787da | 460 | } |
e54787da | 461 | } |
08cf9354 | 462 | else if (imodule >= 42 && imodule < 48) |
e54787da | 463 | { |
08cf9354 | 464 | Int_t rowdiff = endRowBus[pbusid] - startRowBus[pbusid]; |
465 | ||
466 | if (mcmno <= 12) | |
34ab69dd | 467 | { |
08cf9354 | 468 | col = endColBus[pbusid] - (mcmno-1)*4 - (3 - icolnew); |
469 | ||
470 | if(rowdiff > 16) | |
471 | row = endRowBus[pbusid] - (15 - irownew) - 16 ; | |
34ab69dd | 472 | else |
08cf9354 | 473 | row = endRowBus[pbusid] - (15 - irownew) ; |
474 | } | |
475 | else if(mcmno > 12) | |
476 | { | |
477 | row = endRowBus[pbusid] - (15 - irownew) ; | |
478 | col = endColBus[pbusid] - (mcmno - 12 - 1)*4 - (3 - icolnew); | |
479 | } | |
480 | } | |
481 | ||
482 | ||
40f4a63f | 483 | |
08cf9354 | 484 | else if (imodule >= 30 && imodule < 36) |
485 | { | |
486 | if (mcmno > 12) | |
487 | { | |
488 | // Subtract 16 to skip the 1st 15 rows | |
489 | row = endRowBus[pbusid] - 16 -(15 - irownew); | |
490 | col = startColBus[pbusid] + (mcmno-12 -1)*4 + icolnew; | |
34ab69dd | 491 | } |
08cf9354 | 492 | else |
493 | { | |
494 | row = endRowBus[pbusid] - (15 - irownew) ; | |
495 | col = startColBus[pbusid] + (mcmno -1)*4 + icolnew; | |
496 | } | |
497 | ||
498 | } | |
a0a6a406 | 499 | |
08cf9354 | 500 | else if (imodule >= 36 && imodule < 42) |
501 | { | |
502 | if(mcmno > 12) | |
e54787da | 503 | { |
08cf9354 | 504 | // Add 16 to skip the 1st 15 rows |
505 | row = startRowBus[pbusid] + irownew + 16; | |
506 | col = endColBus[pbusid] - (mcmno - 12 - 1)*4 - (3 - icolnew); | |
507 | } | |
508 | else | |
509 | { | |
510 | row = startRowBus[pbusid] + irownew ; | |
511 | col = endColBus[pbusid] - (mcmno - 1)*4 - (3 - icolnew); | |
e54787da | 512 | } |
34ab69dd | 513 | } |
08cf9354 | 514 | |
515 | ||
34ab69dd | 516 | } |
517 | //_____________________________________________________________________________ | |
518 | void AliPMDRawStream::ConvertDDL2SMN(Int_t iddl, Int_t imodule, | |
519 | Int_t &smn, Int_t &detector) const | |
520 | { | |
521 | // This converts the DDL number (0 to 5), Module Number (0-47) | |
522 | // to Serial module number in one detector (SMN : 0-23) and | |
523 | // detector number (0:PRE plane, 1:CPV plane) | |
524 | if (iddl < 4) | |
525 | { | |
526 | smn = imodule; | |
527 | detector = 0; | |
528 | } | |
529 | else | |
530 | { | |
531 | smn = imodule - 24; | |
e54787da | 532 | detector = 1; |
533 | } | |
534 | } | |
535 | //_____________________________________________________________________________ | |
40f4a63f | 536 | |
e54787da | 537 | void AliPMDRawStream::TransformH2S(Int_t smn, Int_t &row, Int_t &col) const |
538 | { | |
34ab69dd | 539 | // This does the transformation of the hardware coordinate to |
540 | // software | |
541 | // i.e., For SuperModule 0 &1, instead of 96x48(hardware), | |
542 | // it is 48x96 (software) | |
e54787da | 543 | // For Supermodule 3 & 4, 48x96 |
544 | ||
e54787da | 545 | Int_t irownew = 0; |
546 | Int_t icolnew = 0; | |
34ab69dd | 547 | |
e54787da | 548 | if(smn < 12) |
549 | { | |
34ab69dd | 550 | irownew = col; |
551 | icolnew = row; | |
e54787da | 552 | } |
34ab69dd | 553 | else if(smn >= 12 && smn < 24) |
e54787da | 554 | { |
34ab69dd | 555 | irownew = row; |
556 | icolnew = col; | |
e54787da | 557 | } |
558 | ||
559 | row = irownew; | |
560 | col = icolnew; | |
561 | } | |
a98f9d26 | 562 | //_____________________________________________________________________________ |
722ccc67 | 563 | Int_t AliPMDRawStream::ComputeParity(UInt_t data) |
a98f9d26 | 564 | { |
565 | // Calculate the parity bit | |
566 | ||
567 | Int_t count = 0; | |
568 | for(Int_t j = 0; j<29; j++) | |
569 | { | |
570 | if (data & 0x01 ) count++; | |
571 | data >>= 1; | |
572 | } | |
573 | ||
574 | Int_t parity = count%2; | |
575 | ||
576 | return parity; | |
577 | } | |
578 | ||
e54787da | 579 | //_____________________________________________________________________________ |
722ccc67 | 580 | UInt_t AliPMDRawStream::GetNextWord() |
581 | { | |
582 | // Returns the next 32 bit word | |
583 | // inside the raw data payload. | |
584 | ||
585 | if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !"); | |
586 | ||
587 | UInt_t word = 0; | |
588 | word |= fData[fPosition++]; | |
589 | word |= fData[fPosition++] << 8; | |
590 | word |= fData[fPosition++] << 16; | |
591 | word |= fData[fPosition++] << 24; | |
592 | ||
593 | return word; | |
594 | } | |
595 | ||
89f0ae35 | 596 | //_____________________________________________________________________________ |
3d8b8ac5 | 597 | void AliPMDRawStream::Ddl0Mapping(Int_t moduleNo[], Int_t mcmperBus[], |
89f0ae35 | 598 | Int_t startRowBus[], Int_t endRowBus[], |
599 | Int_t startColBus[], Int_t endColBus[]) | |
600 | { | |
08cf9354 | 601 | // DDL0 Mapping |
89f0ae35 | 602 | |
3d8b8ac5 | 603 | Int_t iddl = 0; |
89f0ae35 | 604 | |
3d8b8ac5 | 605 | for(Int_t ibus = 1; ibus < 51; ibus++) |
89f0ae35 | 606 | { |
3d8b8ac5 | 607 | moduleNo[ibus] = fMapData->GetModuleNo(iddl,ibus); |
608 | mcmperBus[ibus] = fMapData->GetMcmperBus(iddl,ibus); | |
609 | startRowBus[ibus] = fMapData->GetStartRowBus(iddl,ibus); | |
610 | startColBus[ibus] = fMapData->GetStartColBus(iddl,ibus); | |
611 | endRowBus[ibus] = fMapData->GetEndRowBus(iddl,ibus); | |
612 | endColBus[ibus] = fMapData->GetEndColBus(iddl,ibus); | |
89f0ae35 | 613 | } |
08cf9354 | 614 | |
89f0ae35 | 615 | } |
616 | ||
617 | //_____________________________________________________________________________ | |
3d8b8ac5 | 618 | void AliPMDRawStream::Ddl1Mapping(Int_t moduleNo[], Int_t mcmperBus[], |
89f0ae35 | 619 | Int_t startRowBus[], Int_t endRowBus[], |
620 | Int_t startColBus[], Int_t endColBus[]) | |
621 | { | |
08cf9354 | 622 | // DDL1 Mapping |
89f0ae35 | 623 | |
3d8b8ac5 | 624 | Int_t iddl = 1; |
89f0ae35 | 625 | |
3d8b8ac5 | 626 | for(Int_t ibus = 1; ibus < 51; ibus++) |
89f0ae35 | 627 | { |
3d8b8ac5 | 628 | moduleNo[ibus] = fMapData->GetModuleNo(iddl,ibus); |
629 | mcmperBus[ibus] = fMapData->GetMcmperBus(iddl,ibus); | |
630 | startRowBus[ibus] = fMapData->GetStartRowBus(iddl,ibus); | |
631 | startColBus[ibus] = fMapData->GetStartColBus(iddl,ibus); | |
632 | endRowBus[ibus] = fMapData->GetEndRowBus(iddl,ibus); | |
633 | endColBus[ibus] = fMapData->GetEndColBus(iddl,ibus); | |
08cf9354 | 634 | |
89f0ae35 | 635 | } |
3d8b8ac5 | 636 | |
08cf9354 | 637 | |
89f0ae35 | 638 | } |
639 | ||
640 | //_____________________________________________________________________________ | |
3d8b8ac5 | 641 | void AliPMDRawStream::Ddl2Mapping(Int_t moduleNo[], Int_t mcmperBus[], |
89f0ae35 | 642 | Int_t startRowBus[], Int_t endRowBus[], |
643 | Int_t startColBus[], Int_t endColBus[]) | |
644 | { | |
08cf9354 | 645 | // DDL2 Mapping |
89f0ae35 | 646 | |
3d8b8ac5 | 647 | Int_t iddl = 2; |
08cf9354 | 648 | |
3d8b8ac5 | 649 | for(Int_t ibus = 1; ibus < 51; ibus++) |
89f0ae35 | 650 | { |
3d8b8ac5 | 651 | moduleNo[ibus] = fMapData->GetModuleNo(iddl,ibus); |
652 | mcmperBus[ibus] = fMapData->GetMcmperBus(iddl,ibus); | |
653 | startRowBus[ibus] = fMapData->GetStartRowBus(iddl,ibus); | |
654 | startColBus[ibus] = fMapData->GetStartColBus(iddl,ibus); | |
655 | endRowBus[ibus] = fMapData->GetEndRowBus(iddl,ibus); | |
656 | endColBus[ibus] = fMapData->GetEndColBus(iddl,ibus); | |
08cf9354 | 657 | |
89f0ae35 | 658 | } |
08cf9354 | 659 | |
89f0ae35 | 660 | } |
661 | ||
662 | //_____________________________________________________________________________ | |
3d8b8ac5 | 663 | void AliPMDRawStream::Ddl3Mapping(Int_t moduleNo[], Int_t mcmperBus[], |
89f0ae35 | 664 | Int_t startRowBus[], Int_t endRowBus[], |
665 | Int_t startColBus[], Int_t endColBus[]) | |
666 | { | |
08cf9354 | 667 | // DDL3 Mapping |
89f0ae35 | 668 | |
3d8b8ac5 | 669 | Int_t iddl = 3; |
08cf9354 | 670 | |
3d8b8ac5 | 671 | for(Int_t ibus = 1; ibus < 51; ibus++) |
89f0ae35 | 672 | { |
3d8b8ac5 | 673 | moduleNo[ibus] = fMapData->GetModuleNo(iddl,ibus); |
674 | mcmperBus[ibus] = fMapData->GetMcmperBus(iddl,ibus); | |
675 | startRowBus[ibus] = fMapData->GetStartRowBus(iddl,ibus); | |
676 | startColBus[ibus] = fMapData->GetStartColBus(iddl,ibus); | |
677 | endRowBus[ibus] = fMapData->GetEndRowBus(iddl,ibus); | |
678 | endColBus[ibus] = fMapData->GetEndColBus(iddl,ibus); | |
08cf9354 | 679 | |
89f0ae35 | 680 | } |
08cf9354 | 681 | |
89f0ae35 | 682 | } |
683 | ||
684 | //_____________________________________________________________________________ | |
3d8b8ac5 | 685 | void AliPMDRawStream::Ddl4Mapping(Int_t moduleNo[], Int_t mcmperBus[], |
89f0ae35 | 686 | Int_t startRowBus[], Int_t endRowBus[], |
687 | Int_t startColBus[], Int_t endColBus[]) | |
688 | { | |
08cf9354 | 689 | // DDL4 Mapping |
89f0ae35 | 690 | |
3d8b8ac5 | 691 | Int_t iddl = 4; |
89f0ae35 | 692 | |
3d8b8ac5 | 693 | for(Int_t ibus = 1; ibus < 51; ibus++) |
08cf9354 | 694 | { |
3d8b8ac5 | 695 | moduleNo[ibus] = fMapData->GetModuleNo(iddl,ibus); |
696 | mcmperBus[ibus] = fMapData->GetMcmperBus(iddl,ibus); | |
697 | startRowBus[ibus] = fMapData->GetStartRowBus(iddl,ibus); | |
698 | startColBus[ibus] = fMapData->GetStartColBus(iddl,ibus); | |
699 | endRowBus[ibus] = fMapData->GetEndRowBus(iddl,ibus); | |
700 | endColBus[ibus] = fMapData->GetEndColBus(iddl,ibus); | |
08cf9354 | 701 | |
89f0ae35 | 702 | } |
3d8b8ac5 | 703 | |
08cf9354 | 704 | |
89f0ae35 | 705 | } |
706 | ||
707 | //_____________________________________________________________________________ | |
3d8b8ac5 | 708 | void AliPMDRawStream::Ddl5Mapping(Int_t moduleNo[], Int_t mcmperBus[], |
89f0ae35 | 709 | Int_t startRowBus[], Int_t endRowBus[], |
710 | Int_t startColBus[], Int_t endColBus[]) | |
711 | { | |
08cf9354 | 712 | // DDL5 Mapping |
89f0ae35 | 713 | |
3d8b8ac5 | 714 | Int_t iddl = 5; |
89f0ae35 | 715 | |
3d8b8ac5 | 716 | for(Int_t ibus = 1; ibus < 51; ibus++) |
08cf9354 | 717 | { |
3d8b8ac5 | 718 | moduleNo[ibus] = fMapData->GetModuleNo(iddl,ibus); |
719 | mcmperBus[ibus] = fMapData->GetMcmperBus(iddl,ibus); | |
720 | startRowBus[ibus] = fMapData->GetStartRowBus(iddl,ibus); | |
721 | startColBus[ibus] = fMapData->GetStartColBus(iddl,ibus); | |
722 | endRowBus[ibus] = fMapData->GetEndRowBus(iddl,ibus); | |
723 | endColBus[ibus] = fMapData->GetEndColBus(iddl,ibus); | |
08cf9354 | 724 | |
89f0ae35 | 725 | } |
3d8b8ac5 | 726 | |
727 | } | |
728 | //_____________________________________________________________________________ | |
729 | ||
730 | AliPMDMappingData* AliPMDRawStream::GetMappingData() const | |
731 | { | |
732 | // Fetching the mapping data from CDB | |
733 | ||
734 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Mapping"); | |
735 | ||
736 | if(!entry) AliFatal("Mapping object retrieval failed!"); | |
08cf9354 | 737 | |
3d8b8ac5 | 738 | AliPMDMappingData *mapdata=0; |
739 | if (entry) mapdata = (AliPMDMappingData*) entry->GetObject(); | |
740 | ||
741 | if (!mapdata) AliFatal("No Mapping data from CDB !"); | |
742 | ||
743 | return mapdata; | |
89f0ae35 | 744 | } |
745 | ||
746 | ||
3d8b8ac5 | 747 | |
748 | //_____________________________________________________________________________ | |
749 |