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