]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDRawStream.cxx
In clustering code the method name is changed, Bug fixed in AliPMDrechit, Initializat...
[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   Int_t iddl = -1;
95
96   AliPMDddldata *pmdddldata;
97
98   if (!fRawReader->ReadHeader()) return -1;
99
100   iddl           = fRawReader->GetDDLID();
101   Int_t dataSize = fRawReader->GetDataSize();
102   Int_t totaldataword = dataSize/4;
103
104
105   if (dataSize <= 0) return -1;
106
107   UInt_t data;
108
109   fRawReader->ReadNextData(fData);
110
111   fPosition = 0;
112
113
114   Int_t ibus;
115
116   const Int_t kNPatchBus = 51;
117
118   Int_t moduleNo[kNPatchBus], mcmperBus[kNPatchBus];
119   Int_t startRowBus[kNPatchBus], endRowBus[kNPatchBus];
120   Int_t startColBus[kNPatchBus], endColBus[kNPatchBus];
121
122   for (ibus = 0; ibus < kNPatchBus; ibus++)
123     {
124       moduleNo[ibus]    = -1;
125       mcmperBus[ibus]   = -1;
126       startRowBus[ibus] = -1;
127       endRowBus[ibus]   = -1;
128       startColBus[ibus] = -1;
129       endColBus[ibus]   = -1;
130     }
131
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     }
157
158   infileddl.close();
159
160   if (iddl == 0)
161     {
162       modulePerDDL = moduleddl[iddl];
163       Ddl0Mapping(modulePerDDL, moduleNo, mcmperBus, startRowBus, 
164                   endRowBus, startColBus, endColBus);
165
166     }
167   else if (iddl == 1)
168     {
169       modulePerDDL = moduleddl[iddl];
170       Ddl1Mapping(modulePerDDL, moduleNo, mcmperBus, startRowBus, 
171                   endRowBus, startColBus, endColBus);
172       
173     }
174   else if (iddl == 2)
175     {
176       modulePerDDL = moduleddl[iddl];
177       Ddl2Mapping(modulePerDDL, moduleNo, mcmperBus, startRowBus, 
178                   endRowBus, startColBus, endColBus);
179     }
180   else if (iddl == 3)
181     {
182       modulePerDDL = moduleddl[iddl];
183       Ddl3Mapping(modulePerDDL, moduleNo, mcmperBus, startRowBus, 
184                   endRowBus, startColBus, endColBus);
185     }
186   else if (iddl == 4)
187     {
188       modulePerDDL = moduleddl[iddl];
189       Ddl4Mapping(modulePerDDL, moduleNo, mcmperBus, startRowBus, 
190                   endRowBus, startColBus, endColBus);
191     }
192   else if (iddl == 5)
193     {
194       modulePerDDL = moduleddl[iddl];
195       Ddl5Mapping(modulePerDDL, moduleNo, mcmperBus, startRowBus, 
196                   endRowBus, startColBus, endColBus);
197   }
198
199
200   AliPMDBlockHeader    blockHeader;
201   AliPMDDspHeader      dspHeader;
202   AliPMDPatchBusHeader pbusHeader;
203
204   const Int_t kblHLen   = blockHeader.GetHeaderLength();
205   const Int_t kdspHLen  = dspHeader.GetHeaderLength();
206   const Int_t kpbusHLen = pbusHeader.GetHeaderLength();
207   
208   Int_t parity;
209   Int_t idet, ismn;
210   Int_t irow = -1;
211   Int_t icol = -1;
212
213   Int_t blHeaderWord[8];
214   Int_t dspHeaderWord[10];
215   Int_t pbusHeaderWord[4];
216
217   Int_t blRawDataLength  = 0;
218   Int_t dspRawDataLength = 0;
219   Int_t iwordddl         = 2;
220
221
222
223   for (Int_t iblock = 0; iblock < 2; iblock++)
224     {
225       for (Int_t i = 0; i < kblHLen; i++)
226         {
227             iwordddl++;
228
229             blHeaderWord[i] = (Int_t) GetNextWord();
230         }
231
232       blockHeader.SetHeader(blHeaderWord);
233       blRawDataLength = blockHeader.GetRawDataLength();
234
235       if (iwordddl == totaldataword) break;
236
237       Int_t iwordblk = 0;
238
239       for (Int_t idsp = 0; idsp < 5; idsp++)
240         {
241           for (Int_t i = 0; i < kdspHLen; i++)
242             {
243                 iwordddl++;
244                 iwordblk++;
245                 dspHeaderWord[i] = (Int_t) GetNextWord();
246             }
247           dspHeader.SetHeader(dspHeaderWord);
248           dspRawDataLength = dspHeader.GetRawDataLength();
249
250           if (iwordddl == totaldataword) break;
251
252           Int_t iworddsp = 0;
253
254           for (ibus = 0; ibus < 5; ibus++)
255             {
256               for (Int_t i = 0; i < kpbusHLen; i++)
257                 {
258                     iwordddl++;
259                     iwordblk++;
260                     iworddsp++;
261                     pbusHeaderWord[i] = (Int_t) GetNextWord();
262                 }
263
264               pbusHeader.SetHeader(pbusHeaderWord);
265               Int_t rawdatalength = pbusHeader.GetRawDataLength();
266               Int_t pbusid = pbusHeader.GetPatchBusId();
267
268               if (pbusid < 0 || pbusid > 50) return -1;
269
270               Int_t imodule = moduleNo[pbusid];
271
272               if (iwordddl == totaldataword) break;
273
274               for (Int_t iword = 0; iword < rawdatalength; iword++)
275                 {
276                     iwordddl++;
277                     iwordblk++;
278                     iworddsp++;
279                     data = 0;
280                     data = GetNextWord();
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;
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
293                   parity = ComputeParity(data);
294
295                   if (ibit != parity)
296                     {
297                       AliWarning(Form("Parity Error:: Patch Bus %d Module %d",pbusid,imodule));
298                       fRawReader->AddMajorErrorLog(kParityError);
299                       return -1;
300                     }
301
302                   ConvertDDL2SMN(iddl, imodule, ismn, idet);
303
304                   GetRowCol(imodule, pbusid, imcm, ich, 
305                             startRowBus, endRowBus,
306                             startColBus, endColBus,
307                             irow, icol);
308
309
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);
326
327                 } // data word loop
328
329
330               if (iwordddl == totaldataword) break;
331
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               }
340
341
342             } // patch bus loop
343
344
345           if (dspHeader.GetPaddingWord() == 1)
346           {
347               iwordddl++;
348               iwordblk++;
349               iworddsp++;
350               data = GetNextWord();
351           }
352           if (iwordddl == totaldataword) break;
353
354           if (iwordblk == blRawDataLength) break; // for raw data
355
356
357         } // end of DSP
358
359     } // end of BLOCK
360   
361   return iddl;
362 }
363 //_____________________________________________________________________________
364 void AliPMDRawStream::GetRowCol(Int_t imodule, Int_t pbusid,
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
369 {
370   // decode: ddlno, patchbusid, mcmno, chno -> um, row, col
371
372   UInt_t iCh[64];
373
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++)
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     }
439   
440   
441   Int_t rowcol  = iCh[chno];
442   Int_t irownew = rowcol/4;
443   Int_t icolnew = rowcol%4;
444
445
446   if (imodule < 6 )
447     {
448       row = startRowBus[pbusid] + irownew;
449       col = startColBus[pbusid] + (mcmno-1)*4 + icolnew;
450     }
451   else if (imodule >= 6 && imodule < 12)
452     {
453       row = endRowBus[pbusid] - (15 - irownew);
454       col = startColBus[pbusid] + (mcmno-1)*4 + icolnew;
455       
456     }
457   else if (imodule >= 12 && imodule < 18 )
458     {
459       row = startRowBus[pbusid] + irownew;
460       col = endColBus[pbusid] - (mcmno-1)*4 - (3 - icolnew);
461     }
462   else if (imodule >= 18 && imodule < 24)
463     {
464       row = endRowBus[pbusid] - (15 - irownew);
465       col = endColBus[pbusid] - (mcmno-1)*4 - (3 - icolnew);
466     }
467   else if (imodule >= 24 && imodule < 30)
468     {
469       Int_t rowdiff = endRowBus[pbusid] - startRowBus[pbusid];
470       if(rowdiff > 16)
471         {
472           if (mcmno <= 12)
473             {
474               // Add 16 to skip the 1st 15 rows
475               row = startRowBus[pbusid] + irownew + 16;
476               col = startColBus[pbusid] + (mcmno-1)*4 + icolnew;
477             }
478           else if(mcmno > 12)
479             {
480               row = startRowBus[pbusid] + irownew;
481               col = startColBus[pbusid] + (mcmno-12-1)*4 + icolnew;
482             }
483         }
484       else if (rowdiff < 16)
485         {
486           row = startRowBus[pbusid] + irownew;
487           col = startColBus[pbusid] + (mcmno-1)*4 + icolnew;
488         }
489     }
490   else if (imodule >= 42 && imodule < 48)
491     {
492       Int_t rowdiff = endRowBus[pbusid] - startRowBus[pbusid];
493
494       if (mcmno <= 12)
495         {
496           col = endColBus[pbusid] - (mcmno-1)*4 - (3 - icolnew); 
497           
498           if(rowdiff > 16)
499             row = endRowBus[pbusid] - (15 - irownew) - 16 ;
500           else
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
511
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;
519         }
520       else
521         {
522           row = endRowBus[pbusid]  - (15 - irownew) ;
523           col = startColBus[pbusid] + (mcmno -1)*4 + icolnew;
524         }
525
526     }
527       
528   else if (imodule >= 36 && imodule < 42)
529     {
530       if(mcmno > 12)
531         {
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); 
540         }
541     }
542
543
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;
560       detector = 1;
561     }
562 }
563 //_____________________________________________________________________________
564
565 void AliPMDRawStream::TransformH2S(Int_t smn, Int_t &row, Int_t &col) const
566 {
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)
571   // For Supermodule 3 & 4, 48x96
572
573   Int_t irownew  = 0;
574   Int_t icolnew  = 0;
575
576   if(smn < 12)
577     {
578       irownew = col;
579       icolnew = row;
580     }
581   else if(smn >= 12 && smn < 24)
582     {
583       irownew = row;
584       icolnew = col;
585     }
586
587   row = irownew;
588   col = icolnew;
589 }
590 //_____________________________________________________________________________
591 Int_t AliPMDRawStream::ComputeParity(UInt_t data)
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
607 //_____________________________________________________________________________
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
624 //_____________________________________________________________________________
625 void AliPMDRawStream::Ddl0Mapping(Int_t modulePerDDL, 
626                                   Int_t moduleNo[],    Int_t mcmperBus[],
627                                   Int_t startRowBus[], Int_t endRowBus[],
628                                   Int_t startColBus[], Int_t endColBus[])
629 {
630   // DDL0 Mapping 
631
632   Int_t moduleno, totPatchBus, bPatchBus, ePatchBus;
633   Int_t ibus, totmcm, rows, rowe, cols, cole;
634
635   TString fileName(gSystem->Getenv("ALICE_ROOT"));
636   fileName += "/PMD/PMD_Mapping_ddl0.dat";
637
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");
642
643   for (Int_t im = 0; im < modulePerDDL; im++)
644     {
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       
663     }
664   
665   infile.close();
666
667 }
668
669 //_____________________________________________________________________________
670 void AliPMDRawStream::Ddl1Mapping(Int_t modulePerDDL,
671                                   Int_t moduleNo[],    Int_t mcmperBus[],
672                                   Int_t startRowBus[], Int_t endRowBus[],
673                                   Int_t startColBus[], Int_t endColBus[])
674 {
675   // DDL1 Mapping 
676
677   Int_t moduleno, totPatchBus, bPatchBus, ePatchBus;
678   Int_t ibus, totmcm, rows, rowe, cols, cole;
679
680   TString fileName(gSystem->Getenv("ALICE_ROOT"));
681   fileName += "/PMD/PMD_Mapping_ddl1.dat";
682
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");
687
688   for (Int_t im = 0; im < modulePerDDL; im++)
689     {
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       
708     }
709   
710   infile.close();
711
712 }
713
714 //_____________________________________________________________________________
715 void AliPMDRawStream::Ddl2Mapping(Int_t modulePerDDL,
716                                   Int_t moduleNo[],    Int_t mcmperBus[],
717                                   Int_t startRowBus[], Int_t endRowBus[],
718                                   Int_t startColBus[], Int_t endColBus[])
719 {
720   // DDL2 Mapping 
721
722   Int_t moduleno, totPatchBus, bPatchBus, ePatchBus;
723   Int_t ibus, totmcm, rows, rowe, cols, cole;
724
725
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++)
735     {
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       
754     }
755   
756   infile.close();
757
758 }
759
760 //_____________________________________________________________________________
761 void AliPMDRawStream::Ddl3Mapping(Int_t modulePerDDL,
762                                   Int_t moduleNo[],    Int_t mcmperBus[],
763                                   Int_t startRowBus[], Int_t endRowBus[],
764                                   Int_t startColBus[], Int_t endColBus[])
765 {
766   // DDL3 Mapping 
767
768   Int_t moduleno, totPatchBus, bPatchBus, ePatchBus;
769   Int_t ibus, totmcm, rows, rowe, cols, cole;
770
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++)
780     {
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       
799     }
800   
801   infile.close();
802
803 }
804
805 //_____________________________________________________________________________
806 void AliPMDRawStream::Ddl4Mapping(Int_t modulePerDDL,
807                                   Int_t moduleNo[],    Int_t mcmperBus[],
808                                   Int_t startRowBus[], Int_t endRowBus[],
809                                   Int_t startColBus[], Int_t endColBus[])
810 {
811   // DDL4 Mapping 
812
813   Int_t moduleno, totPatchBus, bPatchBus, ePatchBus;
814   Int_t ibus, totmcm, rows, rowe, cols, cole;
815
816   TString fileName(gSystem->Getenv("ALICE_ROOT"));
817   fileName += "/PMD/PMD_Mapping_ddl4.dat";
818
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");
823
824   for (Int_t im = 0; im < modulePerDDL; im++)
825     {
826       infile >> moduleno;
827       infile >> totPatchBus >> bPatchBus >> ePatchBus;
828
829       if (totPatchBus == 0) continue;
830
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       
844     }
845   
846   infile.close();
847         
848 }
849
850 //_____________________________________________________________________________
851 void AliPMDRawStream::Ddl5Mapping(Int_t modulePerDDL,
852                                   Int_t moduleNo[],    Int_t mcmperBus[],
853                                   Int_t startRowBus[], Int_t endRowBus[],
854                                   Int_t startColBus[], Int_t endColBus[])
855 {
856   // DDL5 Mapping 
857
858   Int_t moduleno, totPatchBus, bPatchBus, ePatchBus;
859   Int_t ibus, totmcm, rows, rowe, cols, cole;
860
861
862   TString fileName(gSystem->Getenv("ALICE_ROOT"));
863   fileName += "/PMD/PMD_Mapping_ddl5.dat";
864
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");
869
870   for (Int_t im = 0; im < modulePerDDL; im++)
871     {
872       infile >> moduleno;
873       infile >> totPatchBus >> bPatchBus >> ePatchBus;
874
875       if (totPatchBus == 0) continue;
876
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       
890     }
891   
892   infile.close();
893         
894 }
895
896