]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawData.cxx
Update raw2digits framework (Ch.Finck)
[u/mrichter/AliRoot.git] / MUON / AliMUONRawData.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 ////////////////////////////////////
17 //
18 // MUON Raw Data generator in ALICE-MUON
19 //
20 // This class version 1 (further details could be found in Alice-note coming soon right in our direction)
21 // Generates raw data for MUON tracker and finally for trigger
22 // * a simple mapping is used (see below)
23 // * the bus patch id is calculated with an absolute number 0 - 999
24 // * one DDL per 1/2 chamber is created for both cathode.
25 // For trigger there is no mapping (mapping could be found in AliMUONTriggerCircuit)
26 // don't need for digits2raw but needed in raw2Reco
27 // the position are given per local card
28 ////////////////////////////////////
29
30 #include <TClonesArray.h>
31 #include "AliMUONRawData.h"
32 #include "AliMUONDigit.h"
33
34 #include "AliMUON.h"
35 #include "AliMUONChamber.h"
36 #include "AliMUONConstants.h"
37 #include "AliMUONData.h"
38 #include "AliLoader.h"
39 #include "AliBitPacking.h" 
40 #include "AliRawReader.h"
41
42 #include "AliMUONSubEventTrigger.h"
43 #include "AliMUONDDLTracker.h"
44 #include "AliMUONDDLTrigger.h"
45
46 #include "AliMUONLocalTrigger.h"
47 #include "AliMUONGlobalTrigger.h"
48
49 #include "AliMUONGeometrySegmentation.h"
50 #include "AliLog.h"
51 #include "AliRun.h"
52
53
54 ClassImp(AliMUONRawData) // Class implementation in ROOT context
55
56 //__________________________________________________________________________
57   AliMUONRawData::AliMUONRawData(AliLoader* loader)
58   : TObject()
59 {
60   // Standard Constructor
61  
62   // initialize loader's
63   fLoader = loader;
64
65   // initialize container
66   fMUONData  = new AliMUONData(fLoader,"MUON","MUON");
67
68   // initialize array
69   fSubEventArray[0] = new TClonesArray("AliMUONSubEventTracker",1000);
70   fSubEventArray[1] = new TClonesArray("AliMUONSubEventTracker",1000);
71
72   // initialize array not used for the moment
73   fSubEventTrigArray[0] = new TClonesArray("AliMUONSubEventTrigger",1000);
74   fSubEventTrigArray[1] = new TClonesArray("AliMUONSubEventTrigger",1000);
75
76   // ddl pointer
77   fDDLTracker = new AliMUONDDLTracker();
78   fDDLTrigger = new  AliMUONDDLTrigger();
79 }
80
81 //__________________________________________________________________________
82 AliMUONRawData::AliMUONRawData()
83   : TObject(),
84     fMUONData(0),
85     fLoader(0)
86 {
87   // Default Constructor
88 }
89
90 //_______________________________________________________________________
91 AliMUONRawData::AliMUONRawData (const AliMUONRawData& rhs)
92   : TObject(rhs)
93 {
94 // Protected copy constructor
95
96   AliFatal("Not implemented.");
97 }
98
99 //_______________________________________________________________________
100 AliMUONRawData & 
101 AliMUONRawData::operator=(const AliMUONRawData& rhs)
102 {
103 // Protected assignement operator
104
105   if (this == &rhs) return *this;
106
107   AliFatal("Not implemented.");
108     
109   return *this;  
110 }
111
112 //__________________________________________________________________________
113 AliMUONRawData::~AliMUONRawData(void)
114 {
115   if (fMUONData)
116     delete fMUONData;
117   if (fSubEventArray[0])
118     fSubEventArray[0]->Delete(); //using delete cos allocating memory in copy ctor.
119   if (fSubEventArray[1])
120     fSubEventArray[1]->Delete();
121
122   if (fSubEventTrigArray[0])
123     fSubEventTrigArray[0]->Delete();
124   if (fSubEventTrigArray[1])
125     fSubEventTrigArray[1]->Delete();
126
127   if (fDDLTracker)
128     delete fDDLTracker;
129   if (fDDLTrigger)
130     delete fDDLTrigger;
131
132   return;
133 }
134 //____________________________________________________________________
135 Int_t AliMUONRawData::Digits2Raw()
136 {
137  // convert digits of the current event to raw data
138
139   Int_t idDDL;
140   Char_t name[20];
141
142   fLoader->LoadDigits("READ");
143
144   fMUONData->SetTreeAddress("D,GLT");
145
146
147   // tracking chambers
148
149   for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++) {
150  
151     // open files
152     idDDL = ich * 2  + 0x900;
153     sprintf(name, "MUON_%d.ddl",idDDL);
154     fFile1 = fopen(name,"w");
155
156     idDDL = (ich * 2) + 1 + 0x900;
157     sprintf(name, "MUON_%d.ddl",idDDL);
158     fFile2 = fopen(name,"w");
159
160     WriteTrackerDDL(ich);
161   
162     // reset and close
163     fclose(fFile1);
164     fclose(fFile2);
165     fMUONData->ResetDigits();
166   }
167  
168   // trigger chambers
169  
170   // open files
171   idDDL = 0xA00;
172   sprintf(name, "MUTR_%d.ddl",idDDL);
173   fFile1 = fopen(name,"w");
174
175   idDDL = 0xA00 + 1;
176   sprintf(name, "MUTR_%d.ddl",idDDL);
177   fFile2 = fopen(name,"w");
178
179   WriteTriggerDDL();
180   
181   // reset and close
182   fclose(fFile1);
183   fclose(fFile2);
184   fMUONData->ResetTrigger();
185   
186   fLoader->UnloadDigits();
187
188   return kTRUE;
189 }
190 //____________________________________________________________________
191 Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
192 {
193   // resets
194   TClonesArray* muonDigits = 0;
195   fSubEventArray[0]->Clear();
196   fSubEventArray[1]->Clear();
197
198   //
199   TArrayI nbInBus[2];
200
201   nbInBus[0].Set(5000);
202   nbInBus[1].Set(5000);
203
204   nbInBus[0].Reset();
205   nbInBus[1].Reset();
206
207   // DDL header
208   AliRawDataHeader header = fDDLTracker->GetHeader();
209   Int_t headerSize = fDDLTracker->GetHeaderSize();
210
211   // DDL event one per half chamber
212   AliMUONSubEventTracker* subEvent;
213
214   // data format
215   Char_t parity = 0x4;
216   UShort_t manuId = 0;
217   UChar_t channelId = 0;
218   UShort_t charge = 0;
219   Int_t busPatchId = 0;
220
221   UInt_t word;
222   Int_t nEntries = 0;
223   Int_t* buffer = 0;
224   Int_t index;
225   Int_t indexDsp;
226   Int_t indexBlk;
227   Int_t padX;
228   Int_t padY;
229   Int_t cathode = 0;
230   Int_t detElemId;
231   Int_t nDigits;
232   const AliMUONDigit* digit;
233
234 //   AliMUON *pMUON;
235 //   AliMUONChamber* iChamber = 0x0;
236 //   AliMUONGeometrySegmentation* segmentation2[2];
237
238 //   pMUON = (AliMUON*) gAlice->GetModule("MUON");
239 //   iChamber =  &(pMUON->Chamber(iCh));
240
241 //   segmentation2[0]=iChamber->SegmentationModel2(1); // cathode 0
242 //   segmentation2[1]=iChamber->SegmentationModel2(2); // cathode 1
243
244    AliDebug(1, Form("WriteDDL chamber %d\n", iCh+1));
245
246    //  for (Int_t iCath = 0; iCath < 2; iCath++) {
247
248     fMUONData->ResetDigits();
249     fMUONData->GetDigits();
250     muonDigits = fMUONData->Digits(iCh);
251
252     nDigits = muonDigits->GetEntriesFast();
253     AliDebug(2,Form("ndigits = %d\n",nDigits));
254
255     // open DDL file, on per 1/2 chamber
256  
257     for (Int_t idig = 0; idig < nDigits; idig++) {
258
259       digit = (AliMUONDigit*) muonDigits->UncheckedAt(idig);
260
261       padX = digit->PadX();
262       padY = digit->PadY();
263       charge = digit->Signal();
264       charge &= 0xFFF;
265       cathode = digit->Cathode();
266       detElemId = digit->DetElemId();
267
268       // mapping
269 //       if (detElemId == 0) {
270 //      AliWarning("\ndetElemId = 0, old segmentation !\n");
271         GetDummyMapping(iCh, cathode, digit, busPatchId, manuId, channelId);
272 //       } else {
273 //       // mapping (not far from real one)
274 //      AliMUONSegmentManuIndex* connect = segmentation2[iCath]->GetMpConnection(detElemId, padX, padY);
275 //      if (connect != 0x0) {
276 //        busPatchId = connect->GetBusPatchId(); 
277 //        manuId     = connect->GetManuId();
278 //        channelId  = connect->GetManuChannelId();
279 //        AliDebug(3,Form("busPatchId %d, manuId: %d, channelId: %d\n", busPatchId, manuId, channelId));
280 //      } else {
281 //        busPatchId = 0; 
282 //        manuId     = 0;
283 //        channelId  = 0;
284 //      }
285
286 //       }
287       //packing word
288       AliBitPacking::PackWord((UInt_t)parity,word,29,31);
289       AliBitPacking::PackWord((UInt_t)manuId,word,18,28);
290       AliBitPacking::PackWord((UInt_t)channelId,word,12,17);
291       AliBitPacking::PackWord((UInt_t)charge,word,0,11);
292
293       // set sub Event
294       subEvent = new AliMUONSubEventTracker();
295       subEvent->AddData(word);
296       subEvent->SetBusPatchId(busPatchId);
297       if (digit->PadX() > 0) {
298         nbInBus[0][busPatchId]++;
299         AddData1(subEvent);
300       } else {
301         nbInBus[1][busPatchId]++;
302         AddData2(subEvent);
303       }
304       delete subEvent;
305     }
306     //   }
307   fSubEventArray[0]->Sort();
308   fSubEventArray[1]->Sort();
309
310   // gather datas from same bus patch
311    for (Int_t iDDL = 0; iDDL < 2; iDDL++) {
312     nEntries = fSubEventArray[iDDL]->GetEntriesFast();
313
314     for (Int_t i = 0; i < nEntries; i++) {
315       AliMUONSubEventTracker* temp = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(i);
316       busPatchId = temp->GetBusPatchId();
317
318       // add bus patch header, length and total length managed by subevent class
319       temp->SetTriggerWord(0xdeadbeef);
320       for (Int_t j = 0; j < nbInBus[iDDL][busPatchId]-1; j++) {
321         AliMUONSubEventTracker* temp1 =  (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(++i);
322         temp->AddData(temp1->GetData(0));
323         fSubEventArray[iDDL]->RemoveAt(i) ;
324       }
325     }
326     fSubEventArray[iDDL]->Compress();
327
328     if (AliLog::GetGlobalDebugLevel() == 3) {
329       nEntries = fSubEventArray[iDDL]->GetEntriesFast();
330       for (Int_t i = 0; i < nEntries; i++) {
331         AliMUONSubEventTracker* temp =  (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(i);
332         printf("busPatchid back %d\n",temp->GetBusPatchId());
333         for (Int_t j = 0; j < temp->GetLength(); j++) {
334           printf("manuId back %d, ",temp->GetManuId(j));
335           printf("channelId back %d, ",temp->GetChannelId(j));
336           printf("charge back %d\n",temp->GetCharge(j));
337         }
338       }
339       printf("\n");
340     }
341   
342    }
343   
344   Int_t iBusPatch;
345   Int_t iEntries;
346   Int_t length;
347
348   for (Int_t iDDL = 0; iDDL < 2; iDDL++) {
349  
350
351     // filling buffer
352     nEntries = fSubEventArray[iDDL]->GetEntriesFast();
353     buffer = new Int_t [(2048+24)*50]; // 24 words in average for one buspatch and 2048 manu info at most
354
355     indexBlk = 0;
356     indexDsp = 0;
357     index = 0;
358     iBusPatch = 0;
359     iEntries = 0;
360
361     for (Int_t iBlock = 0; iBlock < 2; iBlock++) {
362
363       // block header
364       //    fDDLTracker->SetTotalBlkLength(0xFFFFFFFF);
365       length = fDDLTracker->GetBlkHeaderLength();
366       memcpy(&buffer[index],fDDLTracker->GetBlkHeader(),length*4);
367       indexBlk = index;
368       index += length; 
369
370       for (Int_t iDsp = 0; iDsp < 5; iDsp++) {
371
372         // DSP header
373         //      fDDLTracker->SetTotalDspLength(0xEEEEEEEE);
374         length = fDDLTracker->GetDspHeaderLength();
375         memcpy(&buffer[index],fDDLTracker->GetDspHeader(),length*4);
376         indexDsp = index;
377         index += length; 
378
379         for (Int_t i = 0; i < 5; i++) {
380
381           iBusPatch = i + iBlock*25 + iDsp*5 + 50*(2*iCh + iDDL);
382
383           AliMUONSubEventTracker* temp = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(iEntries);
384           if (nEntries > 0) 
385             busPatchId = temp->GetBusPatchId();
386            else
387             busPatchId = -1;
388
389           if (busPatchId == iBusPatch) {
390             // add bus patch structure
391             length = temp->GetHeaderLength();
392             memcpy(&buffer[index],temp->GetAddress(),length*4);
393             index += length;
394             for (Int_t j = 0; j < temp->GetLength(); j++) 
395               buffer[index++] =  temp->GetData(j);
396             if (iEntries < nEntries-1)
397               iEntries++;
398           } else {
399             buffer[index++] = 4; // total length
400             buffer[index++] = 0; // raw data length
401             buffer[index++] = iBusPatch; // bus patch
402             buffer[index++] = 0xdeadbeef; // trigger word
403           }
404         } // bus patch
405         buffer[indexDsp] = index - indexDsp; // dsp length
406         buffer[indexDsp+1] = index - indexDsp - fDDLTracker->GetDspHeaderLength();
407         if ((index - indexDsp) % 2 == 0)
408           buffer[indexDsp+7] = 0;
409         else
410           buffer[indexDsp+7] = 1;
411       } // dsp
412       buffer[indexBlk] = index - indexBlk; // block length
413       buffer[indexBlk+1] = index - indexBlk - fDDLTracker->GetBlkHeaderLength();
414     }
415     if (iDDL == 0) {
416       // write DDL 1
417       header.fSize = (index + headerSize) * 4;// total length in bytes
418       fwrite((char*)(&header),headerSize*4,1,fFile1);
419       fwrite(buffer,sizeof(int),index,fFile1);
420     } 
421     if (iDDL == 1) {
422       // write DDL 2
423       header.fSize = (index + headerSize) * 4;// total length in bytes
424       fwrite((char*)(&header),headerSize*4,1,fFile2);
425       fwrite(buffer,sizeof(int),index,fFile2);
426     }
427     delete[] buffer;
428   }
429
430   return kTRUE;
431 }
432 //____________________________________________________________________
433 Int_t AliMUONRawData::WriteTriggerDDL()
434 {
435
436  // DDL event one per half chamber
437   AliMUONSubEventTrigger* subEvent = 0x0;
438
439
440   // stored local id number 
441   TArrayI isFired(256);
442   isFired.Reset();
443
444
445  // DDL header
446   AliRawDataHeader header = fDDLTrigger->GetHeader();
447   Int_t headerSize = fDDLTrigger->GetHeaderSize();
448   Int_t length;
449   TClonesArray* localTrigger;
450   TClonesArray* globalTrigger;
451   AliMUONGlobalTrigger* gloTrg;
452   AliMUONLocalTrigger* locTrg = 0x0;
453
454   fMUONData->GetTriggerD();
455
456   // global trigger for trigger pattern
457   globalTrigger = fMUONData->GlobalTrigger(); 
458   gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0);
459   Int_t gloTrigPat = GetGlobalTriggerPattern(gloTrg);
460
461   // local trigger 
462   localTrigger = fMUONData->LocalTrigger();    
463
464   UInt_t word;
465   Int_t* buffer = 0;
466   Int_t index;
467   Int_t iEntries = 0;
468   Int_t iLocCard, locCard;
469   Char_t locDec, trigY, posY, devX, posX,regOut;
470   Int_t version = 1; // software version
471   Int_t eventType = 1; // trigger type: 1 for physics ?
472   Int_t serialNb = 0xF; // serial nb of card: all bits on for the moment
473   Int_t globalFlag = 1; // set to 2 if global info present in DDL else set to 1
474
475   Int_t nEntries = (Int_t) (localTrigger->GetEntries());// 234 local cards
476   // stored the local card id that's fired
477   for (Int_t i = 0; i <  nEntries; i++) {
478     locTrg = (AliMUONLocalTrigger*)localTrigger->At(i);
479     isFired[locTrg->LoCircuit()] = 1;
480   }
481
482   if (!nEntries)
483     AliError("No Trigger information available");
484
485   buffer = new Int_t [672]; // [16(local)*5 words + 3 words]*8(reg) + 8 words = 672
486
487   for (Int_t iDDL = 0; iDDL < 2; iDDL++) {
488     
489     index = 0; 
490
491     // DDL enhanced header
492     word = 0;
493     AliBitPacking::PackWord((UInt_t)iDDL+1,word,28,31); //see AliMUONDDLTrigger.h for details
494     AliBitPacking::PackWord((UInt_t)serialNb,word,24,27);
495     AliBitPacking::PackWord((UInt_t)version,word,16,23);
496     AliBitPacking::PackWord((UInt_t)eventType,word,12,15);
497
498     if (iDDL == 0) // suppose global info in DDL one
499       globalFlag = 2;
500     else 
501       globalFlag = 1;
502     AliBitPacking::PackWord((UInt_t)globalFlag,word,8,11);
503     fDDLTrigger->SetDDLWord(word);
504
505     if (iDDL == 0)
506       fDDLTrigger->SetGlobalOutput(gloTrigPat);// no global input for the moment....
507     else 
508       fDDLTrigger->SetGlobalOutput(0);
509     length = fDDLTrigger->GetHeaderLength(); 
510     memcpy(&buffer[index],fDDLTrigger->GetEnhancedHeader(),length*4);
511     index += length; 
512
513     for (Int_t iReg = 0; iReg < 8; iReg++) {
514
515       subEvent = new AliMUONSubEventTrigger();
516
517       // Regional card header
518       word = 0;
519       regOut  = 0;
520       AliBitPacking::PackWord((UInt_t)serialNb,word,24,28); //see  AliMUONSubEventTrigger.h for details
521       AliBitPacking::PackWord((UInt_t)version,word,16,23);
522       AliBitPacking::PackWord((UInt_t)iReg,word,12,15);
523       AliBitPacking::PackWord((UInt_t)regOut,word,0,7); // whenever regional output will be implemented
524
525       subEvent->SetRegWord(word);
526       memcpy(&buffer[index++],subEvent->GetAddress(),4);
527
528       buffer[index++] = 0;// 2 words of regional input
529       buffer[index++] = 0;
530
531       for (Int_t iLoc = 0; iLoc < 16; iLoc++) {
532
533         iLocCard = iLoc + iReg*16 + iDDL*128;
534
535         if (isFired[iLocCard]) {
536           locTrg = (AliMUONLocalTrigger*)localTrigger->At(iEntries);
537           locCard = locTrg->LoCircuit();
538           locDec = locTrg->GetLoDecision();
539           trigY = 0;
540           posY = locTrg->LoStripY();
541           posX = locTrg->LoStripX();
542           devX = locTrg->LoDev();
543           AliDebug(4,Form("loctrg %d, posX %d, posY %d, devX %d\n", 
544                           locTrg-> LoCircuit(),locTrg->LoStripX(),locTrg->LoStripY(),locTrg->LoDev()));
545         } else { //no trigger (see PRR chpt 3.4)
546           locCard = -1;
547           locDec = 0;
548           trigY = 1;
549           posY = 15;
550           posX = 0;
551           devX = 0x8000;
552         }
553
554         //packing word
555         word = 0;
556         AliBitPacking::PackWord((UInt_t)(iLocCard % 16),word,19,22); //card id number in crate
557         AliBitPacking::PackWord((UInt_t)locDec,word,15,18);
558         AliBitPacking::PackWord((UInt_t)trigY,word,14,14);
559         AliBitPacking::PackWord((UInt_t)posY,word,10,13);
560         AliBitPacking::PackWord((UInt_t)devX,word,5,9);
561         AliBitPacking::PackWord((UInt_t)posX,word,0,4);
562
563         if (locCard == iLocCard) {
564           // add local cards structure
565           buffer[index++] = (locTrg->GetX1Pattern() | (locTrg->GetX2Pattern() << 16));
566           buffer[index++] = (locTrg->GetX3Pattern() | (locTrg->GetX4Pattern() << 16));
567           buffer[index++] = (locTrg->GetY1Pattern() | (locTrg->GetY2Pattern() << 16));
568           buffer[index++] = (locTrg->GetY3Pattern() | (locTrg->GetY4Pattern() << 16));
569           buffer[index++] = (Int_t)word; // data word
570           if (iEntries < nEntries-1)
571             iEntries++;
572         } else {
573           buffer[index++] = 0; // 4 words for x1, x2, y1, y2
574           buffer[index++] = 0; 
575           buffer[index++] = 0; 
576           buffer[index++] = 0; 
577           buffer[index++] = (Int_t)word; // data word
578
579         }
580       } // local card 
581
582       delete subEvent;  
583
584     } // Regional card
585     
586     buffer[index++] = fDDLTrigger->GetEoD(); // End of DDL word
587     buffer[index++] = fDDLTrigger->GetEoD(); // End of DDL word for 64 bits transfer purpose
588
589     
590     if (iDDL == 0) {
591       // write DDL 1
592       header.fSize = (index + headerSize) * 4;// total length in bytes
593       fwrite((char*)(&header),headerSize*4,1,fFile1);
594       fwrite(buffer,sizeof(int),index,fFile1);
595     } 
596     if (iDDL == 1) {
597       // write DDL 2
598       header.fSize = (index + headerSize) * 4;// total length in bytes
599       fwrite((char*)(&header),headerSize*4,1,fFile2);
600       fwrite(buffer,sizeof(int),index,fFile2);
601     }
602   }
603   delete[] buffer;
604
605   return kTRUE;
606 }
607 //____________________________________________________________________
608 void AliMUONRawData::GetDummyMapping(Int_t iCh, Int_t iCath, const AliMUONDigit* digit,
609                                      Int_t &busPatchId, UShort_t &manuId, UChar_t &channelId)
610 {
611 // Dummy mapping for tracker
612
613   Int_t offsetX = 0; // offet row
614   Int_t offsetY = 0; // offset columns
615   Int_t offsetCath = 0; //offset from one cathod to the other
616   Int_t maxChannel = 0; // maximum nb of channel in 1/2 chamber
617   Int_t id;
618       switch (iCh+1) {
619       case 1:
620       case 2:
621       case 3:
622       case 4:
623         offsetX = 512;
624         offsetY = 256;
625         offsetCath = 65536;
626         maxChannel = (offsetY * offsetX + 2* offsetY + offsetCath);
627         break;
628       case 5:
629       case 6:
630       case 7:
631       case 8:
632       case 9:
633       case 10:
634         offsetX = 1024;
635         offsetY = 0;
636         offsetCath = 65536;
637         maxChannel = (256 * offsetX + offsetX + offsetCath);
638         break;
639       }
640       // dummy mapping
641       // manu Id directly from a matrix 8*8, same segmentation for B and NB
642       // 50 buspatches for 1/2 chamber
643
644       id =  (TMath::Abs(digit->PadX()) * offsetX + digit->PadY() + offsetY +
645              offsetCath * iCath);
646       Int_t chPerBus = maxChannel/50;
647       busPatchId = id/chPerBus; // start at zero 
648       if (digit->PadX() > 0)
649         busPatchId += 50*iCh*2;
650       else 
651         busPatchId += 50*(2*iCh+1);
652       // 64 manu cards for one buspatch
653       manuId = (id % chPerBus)/64; //start at zero 
654       manuId &= 0x7FF; // 11 bits 
655
656       // channel id
657       channelId = (id % chPerBus) % 64; //start at zero 
658       channelId &= 0x3F; // 6 bits
659
660      
661       AliDebug(2,Form("id: %d, busPatchId %d, manuId: %d, channelId: %d, maxchannel: %d, chPerBus %d\n",
662                       id, busPatchId, manuId, channelId, maxChannel, chPerBus));
663
664       AliDebug(2,Form("id: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d, charge %d\n",
665                       id, busPatchId, manuId, channelId, digit->PadX(), digit->PadY(), digit->Signal()));
666
667 }
668
669 //____________________________________________________________________
670 Int_t AliMUONRawData::GetGlobalTriggerPattern(const AliMUONGlobalTrigger* gloTrg)
671 {
672   // global trigger pattern calculation
673
674   Int_t gloTrigPat = 0;
675
676   if (gloTrg->SinglePlusLpt())  gloTrigPat|= 0x1;
677   if (gloTrg->SinglePlusHpt())  gloTrigPat|= 0x2;
678   if (gloTrg->SinglePlusApt())  gloTrigPat|= 0x4;
679  
680   if (gloTrg->SingleMinusLpt()) gloTrigPat|= 0x8;
681   if (gloTrg->SingleMinusHpt()) gloTrigPat|= 0x10;
682   if (gloTrg->SingleMinusApt()) gloTrigPat|= 0x20;
683  
684   if (gloTrg->SingleUndefLpt()) gloTrigPat|= 0x40;
685   if (gloTrg->SingleUndefHpt()) gloTrigPat|= 0x80;
686   if (gloTrg->SingleUndefApt()) gloTrigPat|= 0x100;
687  
688   if (gloTrg->PairUnlikeLpt())  gloTrigPat|= 0x200;
689   if (gloTrg->PairUnlikeHpt())  gloTrigPat|= 0x400;
690   if (gloTrg->PairUnlikeApt())  gloTrigPat|= 0x800;
691
692   if (gloTrg->PairLikeLpt())    gloTrigPat|= 0x1000;
693   if (gloTrg->PairLikeHpt())    gloTrigPat|= 0x2000;
694   if (gloTrg->PairLikeApt())    gloTrigPat|= 0x4000;
695
696   return gloTrigPat;
697 }
698
699 //____________________________________________________________________
700 Int_t AliMUONRawData::Raw2Digits(AliRawReader* /*rawReader*/)
701 {
702   return kFALSE;
703
704 }
705
706 //____________________________________________________________________
707 Int_t AliMUONRawData::ReadTrackerDDL(AliRawReader* /*rawReader*/)
708 {
709   return kFALSE;
710
711 }
712
713 //____________________________________________________________________
714 void AliMUONRawData:: GetInvDummyMapping(Int_t /*iCh*/, Int_t /*buspatchId*/, UShort_t /*manuId*/, 
715                                          UChar_t /*channelId*/, AliMUONDigit* /*digit*/ )
716 {
717   return;
718 }
719
720 //____________________________________________________________________
721 Int_t AliMUONRawData::ReadTriggerDDL(AliRawReader* /*rawReader*/)
722 {
723   return kFALSE;
724
725 }