]>
Commit | Line | Data |
---|---|---|
28328eeb | 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 | #include <Riostream.h> | |
17 | #include <TClonesArray.h> | |
18 | #include <TTree.h> | |
19 | #include <TBranch.h> | |
20 | #include <TMath.h> | |
95ec17e6 | 21 | #include <TString.h> |
22 | #include <TSystem.h> | |
28328eeb | 23 | |
ecee2a1a | 24 | #include "AliLog.h" |
f7ee745b | 25 | #include "AliRawDataHeaderSim.h" |
cff75ba7 | 26 | #include "AliBitPacking.h" |
28328eeb | 27 | #include "AliPMDdigit.h" |
0a666212 | 28 | #include "AliPMDBlockHeader.h" |
29 | #include "AliPMDDspHeader.h" | |
30 | #include "AliPMDPatchBusHeader.h" | |
a4e4efaa | 31 | #include "AliPMDRawStream.h" |
28328eeb | 32 | #include "AliPMDDDLRawData.h" |
362c9d61 | 33 | #include "AliDAQ.h" |
08f92f14 | 34 | #include "AliFstream.h" |
28328eeb | 35 | |
36 | ClassImp(AliPMDDDLRawData) | |
37 | ||
38 | AliPMDDDLRawData::AliPMDDDLRawData(): | |
39 | fDigits(new TClonesArray("AliPMDdigit", 1000)) | |
40 | { | |
41 | // Default Constructor | |
42 | // | |
a4e4efaa | 43 | |
28328eeb | 44 | } |
a48edddd | 45 | //____________________________________________________________________________ |
46 | AliPMDDDLRawData::AliPMDDDLRawData(const AliPMDDDLRawData& ddlraw): | |
47 | TObject(ddlraw), | |
48 | fDigits(ddlraw.fDigits) | |
49 | { | |
50 | //Copy Constructor | |
51 | } | |
52 | //____________________________________________________________________________ | |
53 | AliPMDDDLRawData & AliPMDDDLRawData::operator=(const AliPMDDDLRawData& ddlraw) | |
54 | { | |
55 | //Assignment operator | |
56 | if(this != &ddlraw) | |
57 | { | |
58 | fDigits = ddlraw.fDigits; | |
59 | } | |
60 | return *this; | |
61 | } | |
28328eeb | 62 | //____________________________________________________________________________ |
63 | ||
64 | AliPMDDDLRawData::~AliPMDDDLRawData() | |
65 | { | |
66 | // Default Destructor | |
67 | // | |
68 | ||
69 | } | |
70 | ||
71 | //____________________________________________________________________________ | |
a4e4efaa | 72 | void AliPMDDDLRawData::WritePMDRawData(TTree *treeD) |
28328eeb | 73 | { |
74 | // write digits into raw data format | |
75 | ||
08f92f14 | 76 | AliFstream *outfile; |
28328eeb | 77 | |
78 | TBranch *branch = treeD->GetBranch("PMDDigit"); | |
ecee2a1a | 79 | if (!branch) |
80 | { | |
81 | AliError("PMD Digit branch not found"); | |
82 | return; | |
83 | } | |
28328eeb | 84 | branch->SetAddress(&fDigits); |
85 | ||
ecee2a1a | 86 | Int_t nmodules = (Int_t) treeD->GetEntries(); |
87 | AliDebug(1,Form("Number of modules inside treeD = %d",nmodules)); | |
28328eeb | 88 | |
362c9d61 | 89 | const Int_t kDDL = AliDAQ::NumberOfDdls("PMD"); |
28328eeb | 90 | Int_t modulePerDDL = 0; |
91 | ||
92 | ||
f7ee745b | 93 | AliRawDataHeaderSim header; |
28328eeb | 94 | UInt_t sizeRawData = 0; |
95ec17e6 | 95 | |
40f4a63f | 96 | const Int_t kbusSize = 51; |
95ec17e6 | 97 | const Int_t kSize = 1536; |
28328eeb | 98 | UInt_t buffer[kSize]; |
99 | ||
40f4a63f | 100 | UInt_t busPatch[kbusSize][1536]; |
95ec17e6 | 101 | |
40f4a63f | 102 | Int_t contentsBus[kbusSize]; |
95ec17e6 | 103 | |
28328eeb | 104 | Char_t filename[80]; |
105 | ||
95ec17e6 | 106 | |
28328eeb | 107 | Int_t mmodule = 0; |
108 | for(Int_t iddl = 0; iddl < kDDL; iddl++) | |
109 | { | |
362c9d61 | 110 | strcpy(filename,AliDAQ::DdlFileName("PMD",iddl)); |
08f92f14 | 111 | |
112 | outfile = new AliFstream(filename); | |
28328eeb | 113 | |
114 | if (iddl < 4) | |
115 | { | |
116 | modulePerDDL = 6; | |
117 | mmodule = 6*iddl; | |
28328eeb | 118 | } |
119 | else if (iddl == 4) | |
120 | { | |
121 | modulePerDDL = 12; | |
122 | mmodule = 24; | |
28328eeb | 123 | } |
124 | else if (iddl == 5) | |
125 | { | |
126 | modulePerDDL = 12; | |
a4e4efaa | 127 | mmodule = 30; |
28328eeb | 128 | } |
129 | ||
28328eeb | 130 | |
95ec17e6 | 131 | |
a4e4efaa | 132 | // Write the Dummy Data Header into the file |
08f92f14 | 133 | Int_t bHPosition = outfile->Tellp(); |
134 | outfile->WriteBuffer((char*)(&header),sizeof(header)); | |
28328eeb | 135 | |
40f4a63f | 136 | for (Int_t ibus = 0; ibus < kbusSize; ibus++) |
95ec17e6 | 137 | { |
138 | contentsBus[ibus] = 0; | |
40f4a63f | 139 | for (Int_t ich = 0; ich < kSize; ich++) |
95ec17e6 | 140 | { |
141 | busPatch[ibus][ich] = 0; | |
142 | } | |
143 | } | |
28328eeb | 144 | |
145 | for(Int_t ium = 0; ium < modulePerDDL; ium++) | |
146 | { | |
95ec17e6 | 147 | if (iddl == 4 && ium == 6) mmodule = 42; |
a4e4efaa | 148 | |
28328eeb | 149 | // Extract energy deposition per cell and pack it |
150 | // in a 32-bit word and returns all the total words | |
151 | // per one unit-module | |
152 | ||
95ec17e6 | 153 | GetUMDigitsData(treeD, mmodule, iddl, contentsBus, busPatch); |
28328eeb | 154 | mmodule++; |
95ec17e6 | 155 | } |
28328eeb | 156 | |
95ec17e6 | 157 | |
158 | ||
159 | Int_t ij = 0; | |
160 | Int_t dsp[10]; | |
161 | Int_t dspBus[10]; | |
162 | for (Int_t i = 0; i < 10; i++) | |
163 | { | |
164 | dsp[i] = 0; | |
165 | dspBus[i] = 0; | |
166 | for (Int_t ibus=0; ibus < 5; ibus++) | |
167 | { | |
40f4a63f | 168 | ij++; |
95ec17e6 | 169 | if (contentsBus[ij] > 0) |
170 | { | |
171 | dsp[i] += contentsBus[ij]; | |
172 | dspBus[i]++; | |
173 | } | |
40f4a63f | 174 | //ij++; |
95ec17e6 | 175 | } |
176 | // Add the patch Bus header to the DSP contents | |
177 | dsp[i] += 4*dspBus[i]; | |
178 | } | |
179 | ||
0a666212 | 180 | Int_t dspBlockARDL = 0; |
181 | Int_t dspBlockBRDL = 0; | |
182 | ||
95ec17e6 | 183 | for (Int_t i = 0; i < 5; i++) |
184 | { | |
185 | Int_t ieven = 2*i; | |
186 | Int_t iodd = 2*i + 1; | |
187 | if (dsp[ieven] > 0) | |
188 | { | |
189 | dspBlockARDL += dsp[ieven]; | |
0a666212 | 190 | Int_t remainder = dsp[ieven]%2; |
191 | if (remainder == 1) | |
192 | { | |
193 | dspBlockARDL++; | |
194 | } | |
95ec17e6 | 195 | } |
196 | if (dsp[iodd] > 0) | |
197 | { | |
198 | dspBlockBRDL += dsp[iodd]; | |
0a666212 | 199 | Int_t remainder = dsp[ieven]%2; |
200 | if (remainder == 1) | |
201 | { | |
202 | dspBlockARDL++; | |
203 | } | |
95ec17e6 | 204 | } |
28328eeb | 205 | } |
95ec17e6 | 206 | |
207 | // Start writing the DDL file | |
0a666212 | 208 | |
209 | AliPMDBlockHeader blHeader; | |
210 | AliPMDDspHeader dspHeader; | |
211 | AliPMDPatchBusHeader pbusHeader; | |
212 | ||
213 | const Int_t kblHLen = blHeader.GetHeaderLength(); | |
214 | const Int_t kdspHLen = dspHeader.GetHeaderLength(); | |
215 | const Int_t kpbusHLen = pbusHeader.GetHeaderLength(); | |
216 | ||
95ec17e6 | 217 | UInt_t dspRDL = 0; |
0a666212 | 218 | UInt_t dspBlockHeaderWord[8]; |
219 | UInt_t dspHeaderWord[10]; | |
220 | UInt_t patchBusHeaderWord[4]; | |
40f4a63f | 221 | Int_t iskip[5]; |
95ec17e6 | 222 | |
0a666212 | 223 | |
95ec17e6 | 224 | for (Int_t iblock = 0; iblock < 2; iblock++) |
225 | { | |
226 | // DSP Block Header | |
227 | ||
0a666212 | 228 | for (Int_t i=0; i<kblHLen; i++) |
95ec17e6 | 229 | { |
0a666212 | 230 | dspBlockHeaderWord[i] = 0; |
231 | } | |
232 | if (iblock == 0) | |
233 | { | |
234 | dspBlockHeaderWord[1] = (UInt_t) (dspBlockARDL + kblHLen); | |
235 | dspBlockHeaderWord[2] = (UInt_t) dspBlockARDL; | |
236 | } | |
237 | else if (iblock == 1) | |
238 | { | |
239 | dspBlockHeaderWord[1] = (UInt_t) (dspBlockBRDL + kblHLen); | |
240 | dspBlockHeaderWord[2] = (UInt_t) dspBlockBRDL; | |
95ec17e6 | 241 | } |
242 | ||
08f92f14 | 243 | outfile->WriteBuffer((char*)dspBlockHeaderWord,kblHLen*sizeof(UInt_t)); |
95ec17e6 | 244 | |
245 | if (iblock == 0) | |
246 | { | |
247 | iskip[0] = 0; | |
248 | iskip[1] = 10; | |
249 | iskip[2] = 20; | |
250 | iskip[3] = 30; | |
251 | iskip[4] = 40; | |
252 | } | |
253 | else if (iblock == 1) | |
254 | { | |
255 | iskip[0] = 5; | |
256 | iskip[1] = 15; | |
257 | iskip[2] = 25; | |
258 | iskip[3] = 35; | |
259 | iskip[4] = 45; | |
260 | } | |
28328eeb | 261 | |
95ec17e6 | 262 | for (Int_t idsp = 0; idsp < 5; idsp++) |
263 | { | |
264 | // DSP Header | |
265 | Int_t dspno = 0; | |
266 | if (iblock == 0) | |
267 | { | |
268 | dspno = 2*idsp; | |
269 | dspRDL = (UInt_t) dsp[dspno]; | |
270 | } | |
271 | else if (iblock == 1) | |
272 | { | |
273 | dspno = 2*idsp + 1; | |
274 | dspRDL = (UInt_t) dsp[dspno]; | |
275 | } | |
276 | ||
0a666212 | 277 | for (Int_t i=0; i<kdspHLen; i++) |
95ec17e6 | 278 | { |
0a666212 | 279 | dspHeaderWord[i] = 0; |
95ec17e6 | 280 | } |
0a666212 | 281 | Int_t remainder = dspRDL%2; |
282 | if (remainder == 1) dspRDL++; | |
283 | ||
284 | dspHeaderWord[1] = dspRDL + kdspHLen; | |
285 | dspHeaderWord[2] = dspRDL; | |
286 | dspHeaderWord[3] = dspno; | |
287 | if (remainder == 1) dspHeaderWord[8] = 1; // setting the padding word | |
08f92f14 | 288 | outfile->WriteBuffer((char*)dspHeaderWord,kdspHLen*sizeof(UInt_t)); |
0a666212 | 289 | |
95ec17e6 | 290 | for (Int_t ibus = 0; ibus < 5; ibus++) |
291 | { | |
292 | // Patch Bus Header | |
40f4a63f | 293 | // BKN - just added 1 |
294 | Int_t busno = iskip[idsp] + ibus + 1; | |
95ec17e6 | 295 | Int_t patchbusRDL = contentsBus[busno]; |
0a666212 | 296 | |
297 | if (patchbusRDL > 0) | |
95ec17e6 | 298 | { |
0a666212 | 299 | patchBusHeaderWord[0] = 0; |
300 | patchBusHeaderWord[1] = (UInt_t) (patchbusRDL + kpbusHLen); | |
301 | patchBusHeaderWord[2] = (UInt_t) patchbusRDL; | |
302 | patchBusHeaderWord[3] = (UInt_t) busno; | |
95ec17e6 | 303 | } |
0a666212 | 304 | else if (patchbusRDL == 0) |
305 | { | |
306 | patchBusHeaderWord[0] = 0; | |
307 | patchBusHeaderWord[1] = (UInt_t) kpbusHLen; | |
308 | patchBusHeaderWord[2] = (UInt_t) 0; | |
309 | patchBusHeaderWord[3] = (UInt_t) busno; | |
310 | } | |
311 | ||
312 | ||
08f92f14 | 313 | outfile->WriteBuffer((char*)patchBusHeaderWord,4*sizeof(UInt_t)); |
95ec17e6 | 314 | |
95ec17e6 | 315 | |
316 | for (Int_t iword = 0; iword < patchbusRDL; iword++) | |
317 | { | |
318 | buffer[iword] = busPatch[busno][iword]; | |
319 | } | |
320 | ||
08f92f14 | 321 | outfile->WriteBuffer((char*)buffer,patchbusRDL*sizeof(UInt_t)); |
0a666212 | 322 | |
323 | } // End of patch bus loop | |
324 | ||
325 | ||
326 | // Adding a padding word if the total words odd | |
327 | if (remainder == 1) | |
328 | { | |
329 | UInt_t paddingWord = dspHeader.GetDefaultPaddingWord(); | |
08f92f14 | 330 | outfile->WriteBuffer((char*)(&paddingWord),sizeof(UInt_t)); |
95ec17e6 | 331 | } |
332 | } | |
333 | } | |
0a666212 | 334 | |
a4e4efaa | 335 | // Write real data header |
336 | // take the pointer to the beginning of the data header | |
28328eeb | 337 | // write the total number of words per ddl and bring the |
338 | // pointer to the current file position and close it | |
08f92f14 | 339 | UInt_t cFPosition = outfile->Tellp(); |
a4e4efaa | 340 | sizeRawData = cFPosition - bHPosition - sizeof(header); |
95ec17e6 | 341 | |
a4e4efaa | 342 | header.fSize = cFPosition - bHPosition; |
343 | header.SetAttribute(0); // valid data | |
08f92f14 | 344 | outfile->Seekp(bHPosition); |
345 | outfile->WriteBuffer((char*)(&header),sizeof(header)); | |
346 | outfile->Seekp(cFPosition); | |
28328eeb | 347 | |
08f92f14 | 348 | delete outfile; |
28328eeb | 349 | } // DDL Loop over |
350 | ||
351 | ||
352 | } | |
353 | //____________________________________________________________________________ | |
95ec17e6 | 354 | void AliPMDDDLRawData::GetUMDigitsData(TTree *treeD, Int_t imodule, |
355 | Int_t ddlno, Int_t *contentsBus, | |
356 | UInt_t busPatch[][1536]) | |
28328eeb | 357 | { |
e54787da | 358 | // Retrives digits data UnitModule by UnitModule |
93622f4a | 359 | |
cff75ba7 | 360 | UInt_t baseword; |
28328eeb | 361 | UInt_t mcmno, chno; |
362 | UInt_t adc; | |
28328eeb | 363 | Int_t det, smn, irow, icol; |
a98f9d26 | 364 | Int_t parity; |
a0a6a406 | 365 | |
40f4a63f | 366 | const Int_t kMaxBus = 51; // BKN |
95ec17e6 | 367 | Int_t totPatchBus, bPatchBus, ePatchBus; |
368 | Int_t ibus, totmcm, rows, cols, rowe, cole; | |
369 | Int_t moduleno; | |
370 | Int_t busno = 0; | |
371 | Int_t patchBusNo[kMaxBus], mcmperBus[kMaxBus]; | |
372 | Int_t startRowBus[kMaxBus], startColBus[kMaxBus]; | |
373 | Int_t endRowBus[kMaxBus], endColBus[kMaxBus]; | |
374 | ||
375 | Int_t beginPatchBus = -1; | |
376 | Int_t endPatchBus = -1; | |
377 | for(Int_t i = 0; i < kMaxBus; i++) | |
378 | { | |
379 | patchBusNo[i] = -1; | |
380 | mcmperBus[i] = -1; | |
381 | startRowBus[i] = -1; | |
382 | startColBus[i] = -1; | |
383 | endRowBus[i] = -1; | |
384 | endColBus[i] = -1; | |
385 | } | |
386 | Int_t modulePerDDL = 0; | |
387 | if (ddlno < 4) | |
388 | { | |
389 | modulePerDDL = 6; | |
390 | } | |
391 | else if (ddlno == 4 || ddlno == 5) | |
392 | { | |
393 | modulePerDDL = 12; | |
394 | } | |
395 | ||
95ec17e6 | 396 | TString fileName(gSystem->Getenv("ALICE_ROOT")); |
397 | ||
398 | if(ddlno == 0) | |
399 | { | |
400 | fileName += "/PMD/PMD_Mapping_ddl0.dat"; | |
401 | } | |
402 | else if(ddlno == 1) | |
403 | { | |
404 | fileName += "/PMD/PMD_Mapping_ddl1.dat"; | |
405 | } | |
406 | else if(ddlno == 2) | |
407 | { | |
408 | fileName += "/PMD/PMD_Mapping_ddl2.dat"; | |
409 | } | |
410 | else if(ddlno == 3) | |
411 | { | |
412 | fileName += "/PMD/PMD_Mapping_ddl3.dat"; | |
413 | } | |
414 | else if(ddlno == 4) | |
415 | { | |
416 | fileName += "/PMD/PMD_Mapping_ddl4.dat"; | |
417 | } | |
418 | else if(ddlno == 5) | |
419 | { | |
420 | fileName += "/PMD/PMD_Mapping_ddl5.dat"; | |
421 | } | |
422 | ||
423 | ifstream infile; | |
424 | infile.open(fileName.Data(), ios::in); // ascii file | |
425 | if(!infile) | |
426 | AliError(Form("Could not read the mapping file for DDL No = %d",ddlno)); | |
427 | ||
428 | for (Int_t im = 0; im < modulePerDDL; im++) | |
429 | { | |
430 | infile >> moduleno; | |
431 | infile >> totPatchBus >> bPatchBus >> ePatchBus; | |
432 | ||
433 | if (moduleno == imodule) | |
434 | { | |
435 | beginPatchBus = bPatchBus; | |
436 | endPatchBus = ePatchBus; | |
437 | } | |
438 | ||
439 | for(Int_t i=0; i<totPatchBus; i++) | |
440 | { | |
441 | infile >> ibus >> totmcm >> rows >> rowe >> cols >> cole; | |
442 | ||
443 | if (moduleno == imodule) | |
444 | { | |
445 | patchBusNo[ibus] = ibus; | |
446 | mcmperBus[ibus] = totmcm; | |
447 | startRowBus[ibus] = rows; | |
448 | startColBus[ibus] = cols; | |
449 | endRowBus[ibus] = rowe; | |
450 | endColBus[ibus] = cole; | |
451 | } | |
452 | } | |
453 | ||
454 | } | |
455 | ||
456 | infile.close(); | |
457 | ||
28328eeb | 458 | treeD->GetEntry(imodule); |
459 | Int_t nentries = fDigits->GetLast(); | |
95ec17e6 | 460 | Int_t totword = nentries+1; |
28328eeb | 461 | |
0a666212 | 462 | AliPMDdigit *pmddigit; |
a48edddd | 463 | |
28328eeb | 464 | for (Int_t ient = 0; ient < totword; ient++) |
465 | { | |
0a666212 | 466 | pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient); |
28328eeb | 467 | |
0a666212 | 468 | det = pmddigit->GetDetector(); |
469 | smn = pmddigit->GetSMNumber(); | |
470 | irow = pmddigit->GetRow(); | |
471 | icol = pmddigit->GetColumn(); | |
472 | adc = (UInt_t) pmddigit->GetADC(); | |
28328eeb | 473 | |
e54787da | 474 | TransformS2H(smn,irow,icol); |
95ec17e6 | 475 | |
40f4a63f | 476 | GetMCMCh(ddlno, smn, irow, icol, beginPatchBus, endPatchBus, |
95ec17e6 | 477 | mcmperBus, startRowBus, startColBus, |
478 | endRowBus, endColBus, busno, mcmno, chno); | |
28328eeb | 479 | |
28328eeb | 480 | baseword = 0; |
cff75ba7 | 481 | AliBitPacking::PackWord(adc,baseword,0,11); |
482 | AliBitPacking::PackWord(chno,baseword,12,17); | |
483 | AliBitPacking::PackWord(mcmno,baseword,18,28); | |
484 | AliBitPacking::PackWord(0,baseword,29,30); | |
a98f9d26 | 485 | parity = ComputeParity(baseword); // generate the parity bit |
486 | AliBitPacking::PackWord(parity,baseword,31,31); | |
95ec17e6 | 487 | |
488 | Int_t jj = contentsBus[busno]; | |
489 | busPatch[busno][jj] = baseword; | |
490 | ||
491 | contentsBus[busno]++; | |
28328eeb | 492 | } |
493 | ||
e54787da | 494 | } |
95ec17e6 | 495 | |
e54787da | 496 | //____________________________________________________________________________ |
497 | void AliPMDDDLRawData::TransformS2H(Int_t smn, Int_t &irow, Int_t &icol) | |
498 | { | |
499 | // Does the Software to Hardware coordinate transformation | |
500 | // | |
95ec17e6 | 501 | |
e54787da | 502 | Int_t irownew = 0; |
503 | Int_t icolnew = 0; | |
e54787da | 504 | |
505 | // First in digits we have all dimension 48x96 | |
95ec17e6 | 506 | // Transform into the realistic one, i.e, For SM 0&1 96(row)x48(col) |
507 | // and for SM 2&3 48(row)x96(col) | |
e54787da | 508 | // |
509 | if(smn < 12) | |
510 | { | |
95ec17e6 | 511 | irownew = icol; |
512 | icolnew = irow; | |
e54787da | 513 | } |
514 | else if( smn >= 12 && smn < 24) | |
515 | { | |
95ec17e6 | 516 | irownew = irow; |
517 | icolnew = icol; | |
e54787da | 518 | } |
519 | ||
520 | irow = irownew; | |
521 | icol = icolnew; | |
28328eeb | 522 | |
523 | } | |
e54787da | 524 | |
525 | ||
28328eeb | 526 | //____________________________________________________________________________ |
e54787da | 527 | |
40f4a63f | 528 | void AliPMDDDLRawData::GetMCMCh(Int_t ddlno, Int_t smn, Int_t row, Int_t col, |
95ec17e6 | 529 | Int_t beginPatchBus, Int_t endPatchBus, |
530 | Int_t *mcmperBus, | |
531 | Int_t *startRowBus, Int_t *startColBus, | |
532 | Int_t *endRowBus, Int_t *endColBus, | |
533 | Int_t & busno, UInt_t &mcmno, UInt_t &chno) | |
28328eeb | 534 | { |
9ac124a2 | 535 | // This converts row col to hardware channel number |
536 | // This is the final version of mapping supplied by Mriganka | |
537 | ||
40f4a63f | 538 | UInt_t iCh[16][4]; |
539 | ||
40f4a63f | 540 | static const UInt_t kChDdl01[16][4] = { {6, 4, 5, 7}, |
541 | {10, 2, 1, 9}, | |
542 | {12, 0, 3, 11}, | |
543 | {14, 8, 13, 15}, | |
544 | {16, 18, 23, 17}, | |
545 | {20, 28, 31, 19}, | |
546 | {22, 30, 29, 21}, | |
547 | {24, 26, 27, 25}, | |
548 | {38, 36, 37, 39}, | |
549 | {42, 34, 33, 41}, | |
550 | {44, 32, 35, 43}, | |
551 | {46, 40, 45, 47}, | |
552 | {48, 50, 55, 49}, | |
553 | {52, 60, 63, 51}, | |
554 | {54, 62, 61, 53}, | |
555 | {56, 58, 59, 57} }; | |
556 | ||
557 | ||
558 | static const UInt_t kChDdl23[16][4] = { {57, 59, 58, 56}, | |
559 | {53, 61, 62, 54}, | |
560 | {51, 63, 60, 52}, | |
561 | {49, 55, 50, 48}, | |
562 | {47, 45, 40, 46}, | |
563 | {43, 35, 32, 44}, | |
564 | {41, 33, 34, 42}, | |
565 | {39, 37, 36, 38}, | |
566 | {25, 27, 26, 24}, | |
567 | {21, 29, 30, 22}, | |
568 | {19, 31, 28, 20}, | |
569 | {17, 23, 18, 16}, | |
570 | {15, 13, 8, 14}, | |
571 | {11, 3, 0, 12}, | |
572 | {9, 1, 2, 10}, | |
573 | {7, 5, 4, 6} }; | |
574 | ||
575 | ||
576 | static const UInt_t kChDdl41[16][4] = { {56, 58, 59, 57}, | |
577 | {54, 62, 61, 53}, | |
578 | {52, 60, 63, 51}, | |
579 | {48, 50, 55, 49}, | |
580 | {46, 40, 45, 47}, | |
581 | {44, 32, 35, 43}, | |
582 | {42, 34, 33, 41}, | |
583 | {38, 36, 37, 39}, | |
584 | {24, 26, 27, 25}, | |
585 | {22, 30, 29, 21}, | |
586 | {20, 28, 31, 19}, | |
587 | {16, 18, 23, 17}, | |
588 | {14, 8, 13, 15}, | |
589 | {12, 0, 3, 11}, | |
590 | {10, 2, 1, 9}, | |
591 | {6, 4, 5, 7} }; | |
592 | ||
593 | ||
594 | static const UInt_t kChDdl42[16][4] = { {7, 5, 4, 6}, | |
595 | {9, 1, 2, 10}, | |
596 | {11, 3, 0, 12}, | |
597 | {15, 13, 8, 14}, | |
598 | {17, 23, 18, 16}, | |
599 | {19, 31, 28, 20}, | |
600 | {21, 29, 30, 22}, | |
601 | {25, 27, 26, 24}, | |
602 | {39, 37, 36, 38}, | |
603 | {41, 33, 34, 42}, | |
604 | {43, 35, 32, 44}, | |
605 | {47, 45, 40, 46}, | |
606 | {49, 55, 50, 48}, | |
607 | {51, 63, 60, 52}, | |
608 | {53, 61, 62, 54}, | |
609 | {57, 59, 58, 56} }; | |
610 | ||
611 | ||
612 | static const UInt_t kChDdl51[16][4] = { {7, 5, 4, 6}, | |
613 | {9, 1, 2, 10}, | |
614 | {11, 3, 0, 12}, | |
615 | {15, 13, 8, 14}, | |
616 | {17, 23, 18, 16}, | |
617 | {19, 31, 28, 20}, | |
618 | {21, 29, 30, 22}, | |
619 | {25, 27, 26, 24}, | |
620 | {39, 37, 36, 38}, | |
621 | {41, 33, 34, 42}, | |
622 | {43, 35, 32, 44}, | |
623 | {47, 45, 40, 46}, | |
624 | {49, 55, 50, 48}, | |
625 | {51, 63, 60, 52}, | |
626 | {53, 61, 62, 54}, | |
627 | {57, 59, 58, 56} }; | |
628 | ||
629 | ||
630 | ||
631 | static const UInt_t kChDdl52[16][4] = { {56, 58, 59, 57}, | |
632 | {54, 62, 61, 53}, | |
633 | {52, 60, 63, 51}, | |
634 | {48, 50, 55, 49}, | |
635 | {46, 40, 45, 47}, | |
636 | {44, 32, 35, 43}, | |
637 | {42, 34, 33, 41}, | |
638 | {38, 36, 37, 39}, | |
639 | {24, 26, 27, 25}, | |
640 | {22, 30, 29, 21}, | |
641 | {20, 28, 31, 19}, | |
642 | {16, 18, 23, 17}, | |
643 | {14, 8, 13, 15}, | |
644 | {12, 0, 3, 11}, | |
645 | {10, 2, 1, 9}, | |
646 | {6, 4, 5, 7} }; | |
647 | ||
648 | ||
649 | for (Int_t i = 0; i < 16; i++) | |
650 | { | |
651 | for (Int_t j = 0; j < 4; j++) | |
652 | { | |
653 | if (ddlno == 0 || ddlno == 1) iCh[i][j] = kChDdl01[i][j]; | |
654 | if (ddlno == 2 || ddlno == 3) iCh[i][j] = kChDdl23[i][j]; | |
655 | ||
656 | if (ddlno == 4 && smn < 6) iCh[i][j] = kChDdl41[i][j]; | |
657 | if (ddlno == 4 && (smn >= 18 && smn < 24))iCh[i][j] = kChDdl42[i][j]; | |
658 | if (ddlno == 5 && (smn >= 12 && smn < 18))iCh[i][j] = kChDdl51[i][j]; | |
659 | if (ddlno == 5 && (smn >= 6 && smn < 12))iCh[i][j] = kChDdl52[i][j]; | |
660 | } | |
661 | } | |
662 | ||
663 | ||
95ec17e6 | 664 | Int_t irownew = row%16; |
665 | Int_t icolnew = col%4; | |
666 | ||
40f4a63f | 667 | chno = iCh[irownew][icolnew]; |
a0a6a406 | 668 | |
669 | ||
95ec17e6 | 670 | for (Int_t ibus = beginPatchBus; ibus <= endPatchBus; ibus++) |
671 | { | |
672 | Int_t srow = startRowBus[ibus]; | |
673 | Int_t erow = endRowBus[ibus]; | |
674 | Int_t scol = startColBus[ibus]; | |
675 | Int_t ecol = endColBus[ibus]; | |
676 | Int_t tmcm = mcmperBus[ibus]; | |
677 | if ((row >= srow && row <= erow) && (col >= scol && col <= ecol)) | |
a4e4efaa | 678 | { |
95ec17e6 | 679 | busno = ibus; |
a0a6a406 | 680 | |
95ec17e6 | 681 | // Find out the MCM Number |
682 | // | |
a0a6a406 | 683 | |
95ec17e6 | 684 | if (ddlno == 0 || ddlno == 1) |
685 | { | |
686 | // PRE plane, SU Mod = 0, 1 | |
40f4a63f | 687 | mcmno = (col-scol)/4 + 1; |
a0a6a406 | 688 | |
93622f4a | 689 | } |
a0a6a406 | 690 | else if (ddlno == 2 || ddlno == 3) |
95ec17e6 | 691 | { |
a0a6a406 | 692 | // PRE plane, SU Mod = 2, 3 |
00284d65 | 693 | icolnew = (col - scol)/4; |
40f4a63f | 694 | mcmno = tmcm - icolnew; |
93622f4a | 695 | } |
696 | else if (ddlno == 4 ) | |
95ec17e6 | 697 | { |
698 | // CPV plane, SU Mod = 0, 3 : ddl = 4 | |
699 | ||
40f4a63f | 700 | if(ibus <= 18) |
95ec17e6 | 701 | { |
a0a6a406 | 702 | Int_t midrow = srow + 16; |
703 | if(row >= srow && row < midrow) | |
95ec17e6 | 704 | { |
40f4a63f | 705 | mcmno = 12 + (col-scol)/4 + 1; |
95ec17e6 | 706 | } |
93622f4a | 707 | else if(row >= midrow && row <= erow) |
708 | ||
95ec17e6 | 709 | { |
40f4a63f | 710 | mcmno = (col-scol)/4 + 1; |
95ec17e6 | 711 | } |
712 | } | |
95ec17e6 | 713 | |
40f4a63f | 714 | else if (ibus > 18) |
95ec17e6 | 715 | { |
716 | Int_t rowdiff = endRowBus[ibus] - startRowBus[ibus]; | |
717 | if(rowdiff > 16) | |
718 | { | |
719 | Int_t midrow = srow + 16; | |
93622f4a | 720 | if (row >= midrow && row <= erow) |
95ec17e6 | 721 | { |
40f4a63f | 722 | mcmno = 12 + (ecol -col)/4 + 1; |
95ec17e6 | 723 | } |
a0a6a406 | 724 | else if (row >= srow && row < midrow) |
95ec17e6 | 725 | { |
40f4a63f | 726 | mcmno = (ecol - col)/4 + 1; |
95ec17e6 | 727 | } |
728 | } | |
40f4a63f | 729 | else if (rowdiff < 16) |
95ec17e6 | 730 | { |
40f4a63f | 731 | mcmno = (ecol - col)/4 + 1; |
732 | } | |
95ec17e6 | 733 | } |
734 | } | |
93622f4a | 735 | else if ( ddlno == 5) |
736 | { | |
40f4a63f | 737 | // CPV plane, SU Mod = 1, 2 : ddl = 5 |
93622f4a | 738 | |
40f4a63f | 739 | if(ibus <= 18) |
93622f4a | 740 | { |
741 | Int_t midrow = srow + 16; | |
742 | if(row >= srow && row < midrow) | |
743 | { | |
40f4a63f | 744 | mcmno = 12 + (col-scol)/4 + 1; |
93622f4a | 745 | } |
746 | else if(row >= midrow && row <= erow) | |
747 | { | |
40f4a63f | 748 | mcmno = (col-scol)/4 + 1; |
93622f4a | 749 | } |
750 | } | |
751 | ||
40f4a63f | 752 | else if (ibus > 18) |
93622f4a | 753 | { |
754 | Int_t rowdiff = endRowBus[ibus] - startRowBus[ibus]; | |
755 | if(rowdiff > 16) | |
756 | { | |
757 | Int_t midrow = srow + 16; | |
758 | if (row >= midrow && row <= erow) | |
759 | { | |
40f4a63f | 760 | mcmno = 12 + (ecol - col)/4 + 1; |
93622f4a | 761 | } |
762 | else if (row >= srow && row < midrow) | |
763 | { | |
40f4a63f | 764 | mcmno = (ecol - col)/4 + 1; |
93622f4a | 765 | } |
766 | } | |
40f4a63f | 767 | else if (rowdiff < 16) |
93622f4a | 768 | { |
40f4a63f | 769 | mcmno = (ecol - col)/4 + 1; |
770 | } | |
93622f4a | 771 | } |
772 | } | |
773 | } | |
95ec17e6 | 774 | } |
a0a6a406 | 775 | } |
776 | ||
28328eeb | 777 | //____________________________________________________________________________ |
778 | ||
a98f9d26 | 779 | Int_t AliPMDDDLRawData::ComputeParity(UInt_t baseword) |
780 | { | |
781 | // Generate the parity bit | |
782 | ||
783 | Int_t count = 0; | |
784 | for(Int_t j=0; j<29; j++) | |
785 | { | |
786 | if (baseword & 0x01 ) count++; | |
787 | baseword >>= 1; | |
788 | } | |
789 | Int_t parity = count%2; | |
790 | return parity; | |
791 | } | |
792 | ||
793 | //____________________________________________________________________________ |