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