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