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