]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONRawData.cxx
Reverted direct flow parameters
[u/mrichter/AliRoot.git] / MUON / AliMUONRawData.cxx
index 8831c835f1aa72eb002d3e5e08c7d23c73a6118f..bc8b1bb1ceda2d17d50bb4c8b8ec00cd44364a89 100644 (file)
 //
 // MUON Raw Data generator in ALICE-MUON
 //
-// This class v-1:
-// * generates raw data for MUON tracker only (for the moment)
+// This class version 1 (further details could be found in Alice-note coming soon right in our direction)
+// Generates raw data for MUON tracker and finally for trigger
 // * a simple mapping is used (see below)
 // * the bus patch id is calculated with an absolute number 0 - 999
-// one DDL per 1/2 chamber is created for both cathode.
-//
+// * one DDL per 1/2 chamber is created for both cathode.
+// For trigger there is no mapping (mapping could be found in AliMUONTriggerCircuit)
+// don't need for digits2raw but needed in raw2Reco
+// the position are given per local card
 ////////////////////////////////////
+
 #include <TClonesArray.h>
 #include "AliMUONRawData.h"
 #include "AliMUONDigit.h"
-#include "AliMUONTriggerDecision.h"
+
+#include "AliMUON.h"
+#include "AliMUONChamber.h"
 #include "AliMUONConstants.h"
 #include "AliMUONData.h"
-#include "AliRun.h" 
-#include "AliRunLoader.h"
 #include "AliLoader.h"
 #include "AliBitPacking.h" 
+#include "AliRawReader.h"
+
+#include "AliMUONSubEventTrigger.h"
 #include "AliMUONDDLTracker.h"
 #include "AliMUONDDLTrigger.h"
 
-// #include "AliMUON.h"
-// #include "AliMUONLocalTrigger.h"
-// #include "AliMUONGlobalTrigger.h"
-// #include "AliMUONTriggerCircuit.h"
+#include "AliMUONLocalTrigger.h"
+#include "AliMUONGlobalTrigger.h"
+
+#include "AliMUONGeometrySegmentation.h"
+#include "AliLog.h"
+#include "AliRun.h"
 
-const Int_t AliMUONRawData::fgkDefaultPrintLevel = 0;
 
 ClassImp(AliMUONRawData) // Class implementation in ROOT context
 
 //__________________________________________________________________________
-AliMUONRawData::AliMUONRawData(AliLoader* loader)
-  : TObject(),
-    fDebug(0)
+  AliMUONRawData::AliMUONRawData(AliLoader* loader)
+  : TObject()
 {
   // Standard Constructor
  
-  fPrintLevel = fgkDefaultPrintLevel;
-
   // initialize loader's
   fLoader = loader;
 
   // initialize container
   fMUONData  = new AliMUONData(fLoader,"MUON","MUON");
 
-  // trigger decision, temp solution, local & global has to move to Digits Tree
-//   fTrigDec = new AliMUONTriggerDecision(fLoader);
-//   fTrigData = fTrigDec->GetMUONData();
-
   // initialize array
   fSubEventArray[0] = new TClonesArray("AliMUONSubEventTracker",1000);
   fSubEventArray[1] = new TClonesArray("AliMUONSubEventTracker",1000);
 
-  // initialize array
+  // initialize array not used for the moment
   fSubEventTrigArray[0] = new TClonesArray("AliMUONSubEventTrigger",1000);
   fSubEventTrigArray[1] = new TClonesArray("AliMUONSubEventTrigger",1000);
 
   // ddl pointer
   fDDLTracker = new AliMUONDDLTracker();
-  fDDLTrigger= new  AliMUONDDLTrigger();
+  fDDLTrigger = new  AliMUONDDLTrigger();
 }
 
 //__________________________________________________________________________
 AliMUONRawData::AliMUONRawData()
   : TObject(),
     fMUONData(0),
-    fPrintLevel(fgkDefaultPrintLevel),
-    fDebug(0),
     fLoader(0)
 {
   // Default Constructor
@@ -95,7 +93,7 @@ AliMUONRawData::AliMUONRawData (const AliMUONRawData& rhs)
 {
 // Protected copy constructor
 
-  Fatal("AliMUONRawData", "Not implemented.");
+  AliFatal("Not implemented.");
 }
 
 //_______________________________________________________________________
@@ -106,7 +104,7 @@ AliMUONRawData::operator=(const AliMUONRawData& rhs)
 
   if (this == &rhs) return *this;
 
-  Fatal("operator=", "Not implemented.");
+  AliFatal("Not implemented.");
     
   return *this;  
 }
@@ -131,32 +129,32 @@ AliMUONRawData::~AliMUONRawData(void)
   if (fDDLTrigger)
     delete fDDLTrigger;
 
-//   if (fTrigDec)
-//     delete fTrigDec;
   return;
 }
 //____________________________________________________________________
-Int_t AliMUONRawData::WriteRawData()
+Int_t AliMUONRawData::Digits2Raw()
 {
  // convert digits of the current event to raw data
 
-  Int_t DDLId;
+  Int_t idDDL;
   Char_t name[20];
 
   fLoader->LoadDigits("READ");
 
-  fMUONData->SetTreeAddress("D");
+  fMUONData->SetTreeAddress("D,GLT");
 
-  for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++) {
-  //  for (Int_t ich = 0; ich < 2; ich++) {
 
+  // tracking chambers
+
+  for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++) {
     // open files
-    DDLId = ich * 2  + 0x900;
-    sprintf(name, "MUON_%d.ddl",DDLId);
+    idDDL = ich * 2  + 0x900;
+    sprintf(name, "MUON_%d.ddl",idDDL);
     fFile1 = fopen(name,"w");
 
-    DDLId = (ich * 2) + 1 + 0x900;
-    sprintf(name, "MUON_%d.ddl",DDLId);
+    idDDL = (ich * 2) + 1 + 0x900;
+    sprintf(name, "MUON_%d.ddl",idDDL);
     fFile2 = fopen(name,"w");
 
     WriteTrackerDDL(ich);
@@ -168,23 +166,24 @@ Int_t AliMUONRawData::WriteRawData()
   }
  
   // trigger chambers
-
-  
   // open files
-//   DDLId = 0xA00;
-//   sprintf(name, "MUTR_%d.ddl",DDLId);
-//   fFile1 = fopen(name,"w");
+  idDDL = 0xA00;
+  sprintf(name, "MUTR_%d.ddl",idDDL);
+  fFile1 = fopen(name,"w");
 
-//   DDLId = 0xA00 + 1;
-//   sprintf(name, "MUTR_%d.ddl",DDLId);
-//   fFile2 = fopen(name,"w");
+  idDDL = 0xA00 + 1;
+  sprintf(name, "MUTR_%d.ddl",idDDL);
+  fFile2 = fopen(name,"w");
 
-//   WriteTriggerDDL();
+  WriteTriggerDDL();
+  
+  // reset and close
+  fclose(fFile1);
+  fclose(fFile2);
+  fMUONData->ResetTrigger();
   
-//   // reset and close
-//   fclose(fFile1);
-//   fclose(fFile2);
-   fLoader->UnloadDigits();
+  fLoader->UnloadDigits();
 
   return kTRUE;
 }
@@ -225,22 +224,33 @@ Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
   Int_t index;
   Int_t indexDsp;
   Int_t indexBlk;
-
+  Int_t padX;
+  Int_t padY;
+  Int_t cathode = 0;
+  Int_t detElemId;
   Int_t nDigits;
   const AliMUONDigit* digit;
 
-   if (fPrintLevel > 0)
-      printf("WriteDDL chamber %d\n", iCh+1);
+//   AliMUON *pMUON;
+//   AliMUONChamber* iChamber = 0x0;
+//   AliMUONGeometrySegmentation* segmentation2[2];
 
-  for (Int_t iCath = 0; iCath < 2; iCath++) {
+//   pMUON = (AliMUON*) gAlice->GetModule("MUON");
+//   iChamber =  &(pMUON->Chamber(iCh));
+
+//   segmentation2[0]=iChamber->SegmentationModel2(1); // cathode 0
+//   segmentation2[1]=iChamber->SegmentationModel2(2); // cathode 1
+
+   AliDebug(1, Form("WriteDDL chamber %d\n", iCh+1));
+
+   //  for (Int_t iCath = 0; iCath < 2; iCath++) {
 
     fMUONData->ResetDigits();
-    fMUONData->GetCathode(iCath);
+    fMUONData->GetDigits();
     muonDigits = fMUONData->Digits(iCh);
 
     nDigits = muonDigits->GetEntriesFast();
-    if (fPrintLevel == 2)
-      printf("ndigits = %d\n",nDigits);
+    AliDebug(2,Form("ndigits = %d\n",nDigits));
 
     // open DDL file, on per 1/2 chamber
  
@@ -248,9 +258,32 @@ Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
 
       digit = (AliMUONDigit*) muonDigits->UncheckedAt(idig);
 
-      // mapping
-      GetDummyMapping(iCh, iCath, digit, busPatchId, manuId, channelId, charge);
+      padX = digit->PadX();
+      padY = digit->PadY();
+      charge = digit->Signal();
+      charge &= 0xFFF;
+      cathode = digit->Cathode();
+      detElemId = digit->DetElemId();
 
+      // mapping
+//       if (detElemId == 0) {
+//     AliWarning("\ndetElemId = 0, old segmentation !\n");
+       GetDummyMapping(iCh, cathode, digit, busPatchId, manuId, channelId);
+//       } else {
+//       // mapping (not far from real one)
+//     AliMUONSegmentManuIndex* connect = segmentation2[iCath]->GetMpConnection(detElemId, padX, padY);
+//     if (connect != 0x0) {
+//       busPatchId = connect->GetBusPatchId(); 
+//       manuId     = connect->GetManuId();
+//       channelId  = connect->GetManuChannelId();
+//       AliDebug(3,Form("busPatchId %d, manuId: %d, channelId: %d\n", busPatchId, manuId, channelId));
+//     } else {
+//       busPatchId = 0; 
+//       manuId     = 0;
+//       channelId  = 0;
+//     }
+
+//       }
       //packing word
       AliBitPacking::PackWord((UInt_t)parity,word,29,31);
       AliBitPacking::PackWord((UInt_t)manuId,word,18,28);
@@ -270,7 +303,7 @@ Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
       }
       delete subEvent;
     }
-  }
+    //   }
   fSubEventArray[0]->Sort();
   fSubEventArray[1]->Sort();
 
@@ -292,7 +325,7 @@ Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
     }
     fSubEventArray[iDDL]->Compress();
 
-    if (fPrintLevel == 3) {
+    if (AliLog::GetGlobalDebugLevel() == 3) {
       nEntries = fSubEventArray[iDDL]->GetEntriesFast();
       for (Int_t i = 0; i < nEntries; i++) {
        AliMUONSubEventTracker* temp =  (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(i);
@@ -306,10 +339,11 @@ Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
       printf("\n");
     }
   
-  }
+   }
   
   Int_t iBusPatch;
   Int_t iEntries;
+  Int_t length;
 
   for (Int_t iDDL = 0; iDDL < 2; iDDL++) {
  
@@ -327,18 +361,20 @@ Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
     for (Int_t iBlock = 0; iBlock < 2; iBlock++) {
 
       // block header
-      fDDLTracker->SetTotalBlkLength(0xFFFFFFFF);
-      memcpy(&buffer[index],fDDLTracker->GetBlkHeader(),32);
+      //    fDDLTracker->SetTotalBlkLength(0xFFFFFFFF);
+      length = fDDLTracker->GetBlkHeaderLength();
+      memcpy(&buffer[index],fDDLTracker->GetBlkHeader(),length*4);
       indexBlk = index;
-      index += 8
+      index += length
 
       for (Int_t iDsp = 0; iDsp < 5; iDsp++) {
 
        // DSP header
-       fDDLTracker->SetTotalDspLength(0xEEEEEEEE);
-       memcpy(&buffer[index],fDDLTracker->GetDspHeader(),32);
+       //      fDDLTracker->SetTotalDspLength(0xEEEEEEEE);
+       length = fDDLTracker->GetDspHeaderLength();
+       memcpy(&buffer[index],fDDLTracker->GetDspHeader(),length*4);
        indexDsp = index;
-       index += 8
+       index += length
 
        for (Int_t i = 0; i < 5; i++) {
 
@@ -352,8 +388,9 @@ Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
 
          if (busPatchId == iBusPatch) {
            // add bus patch structure
-           memcpy(&buffer[index],temp->GetAddress(),16);
-           index+= 4;
+           length = temp->GetHeaderLength();
+           memcpy(&buffer[index],temp->GetAddress(),length*4);
+           index += length;
            for (Int_t j = 0; j < temp->GetLength(); j++) 
              buffer[index++] =  temp->GetData(j);
            if (iEntries < nEntries-1)
@@ -365,25 +402,25 @@ Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
            buffer[index++] = 0xdeadbeef; // trigger word
          }
        } // bus patch
-       buffer[indexDsp] = index - indexDsp;
-       buffer[indexDsp+1] = index - indexDsp -8;
+       buffer[indexDsp] = index - indexDsp; // dsp length
+       buffer[indexDsp+1] = index - indexDsp - fDDLTracker->GetDspHeaderLength();
        if ((index - indexDsp) % 2 == 0)
          buffer[indexDsp+7] = 0;
        else
          buffer[indexDsp+7] = 1;
       } // dsp
-      buffer[indexBlk] = index - indexBlk;
-      buffer[indexBlk+1] = index - indexBlk -8;
+      buffer[indexBlk] = index - indexBlk; // block length
+      buffer[indexBlk+1] = index - indexBlk - fDDLTracker->GetBlkHeaderLength();
     }
     if (iDDL == 0) {
       // write DDL 1
-      header.fSize = index + headerSize;// total length in word
+      header.fSize = (index + headerSize) * 4;// total length in bytes
       fwrite((char*)(&header),headerSize*4,1,fFile1);
       fwrite(buffer,sizeof(int),index,fFile1);
     } 
     if (iDDL == 1) {
       // write DDL 2
-      header.fSize = index + headerSize;// total length in word
+      header.fSize = (index + headerSize) * 4;// total length in bytes
       fwrite((char*)(&header),headerSize*4,1,fFile2);
       fwrite(buffer,sizeof(int),index,fFile2);
     }
@@ -396,68 +433,182 @@ Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh)
 Int_t AliMUONRawData::WriteTriggerDDL()
 {
 
-//   Long_t gloTrigPat;
-//   TClonesArray *localTrigger;
-//   TClonesArray *globalTrigger;
-//   AliMUONLocalTrigger *locTrg;
-//   AliMUONGlobalTrigger *gloTrg;
-//   AliMUONTriggerCircuit *circuit;
+ // DDL event one per half chamber
+  AliMUONSubEventTrigger* subEvent = 0x0;
 
-//   fTrigData->SetTreeAddress("D,GLT");
-//   fTrigDec->Digits2Trigger(); 
-  
 
-//   AliMUON * pMUON = (AliMUON *) gAlice->GetDetector("MUON");
+  // stored local id number 
+  TArrayI isFired(256);
+  isFired.Reset();
 
-//   // global trigger for trigger pattern
-//   gloTrigPat = 0;
-//   globalTrigger = fMUONData->GlobalTrigger(); 
 
-//   gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0);
-//   if (gloTrg->SinglePlusLpt())  gloTrigPat|= 0x1;
-//   if (gloTrg->SinglePlusHpt())  gloTrigPat|= 0x2;
-//   if (gloTrg->SinglePlusApt())  gloTrigPat|= 0x4;
-//   if (gloTrg->SingleMinusLpt()) gloTrigPat|= 0x8;
-//   if (gloTrg->SingleMinusHpt()) gloTrigPat|= 0x10;
-//   if (gloTrg->SingleMinusApt()) gloTrigPat|= 0x20;
-//   if (gloTrg->SingleUndefLpt()) gloTrigPat|= 0x40;
-//   if (gloTrg->SingleUndefHpt()) gloTrigPat|= 0x80;
-//   if (gloTrg->SingleUndefApt()) gloTrigPat|= 0x100;
-//   if (gloTrg->PairUnlikeLpt())  gloTrigPat|= 0x200;
-//   if (gloTrg->PairUnlikeHpt())  gloTrigPat|= 0x400;
-//   if (gloTrg->PairUnlikeApt())  gloTrigPat|= 0x800;
-
-//   if (gloTrg->PairLikeLpt())    gloTrigPat|= 0x1000;
-//   if (gloTrg->PairLikeHpt())    gloTrigPat|= 0x2000;
-//   if (gloTrg->PairLikeApt())    gloTrigPat|= 0x4000;
-
-//   // local trigger 
-//   localTrigger = fMUONData->LocalTrigger();    
-//   Int_t nlocals = (Int_t) (localTrigger->GetEntries());// 234 local cards
-
-//   for (Int_t i=0; i<nlocals; i++) { // loop on Local Trigger
-//     locTrg = (AliMUONLocalTrigger*)localTrigger->UncheckedAt(i);    
-//     circuit = &(pMUON->TriggerCircuit(locTrg->LoCircuit()));
-//     Float_t y11 = circuit->GetY11Pos(locTrg->LoStripX()); 
-//     Int_t stripX21 = locTrg->LoStripX()+locTrg->LoDev()+1;
-//     Float_t y21 = circuit->GetY21Pos(stripX21);     
-//     Float_t x11 = circuit->GetX11Pos(locTrg->LoStripY());
-//     y11 = y21 = x11 = 0.;
-//   }
-
-//   fTrigData->ResetTrigger();
-//   fTrigData->ResetDigits();
+ // DDL header
+  AliRawDataHeader header = fDDLTrigger->GetHeader();
+  Int_t headerSize = fDDLTrigger->GetHeaderSize();
+  Int_t length;
+  TClonesArray* localTrigger;
+  TClonesArray* globalTrigger;
+  AliMUONGlobalTrigger* gloTrg;
+  AliMUONLocalTrigger* locTrg = 0x0;
+
+  fMUONData->GetTriggerD();
+
+  // global trigger for trigger pattern
+  globalTrigger = fMUONData->GlobalTrigger(); 
+  gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0);
+  Int_t gloTrigPat = GetGlobalTriggerPattern(gloTrg);
+
+  // local trigger 
+  localTrigger = fMUONData->LocalTrigger();    
+
+  UInt_t word;
+  Int_t* buffer = 0;
+  Int_t index;
+  Int_t iEntries = 0;
+  Int_t iLocCard, locCard;
+  Char_t locDec, trigY, posY, devX, posX,regOut;
+  Int_t version = 1; // software version
+  Int_t eventType = 1; // trigger type: 1 for physics ?
+  Int_t serialNb = 0xF; // serial nb of card: all bits on for the moment
+  Int_t globalFlag = 1; // set to 2 if global info present in DDL else set to 1
+
+  Int_t nEntries = (Int_t) (localTrigger->GetEntries());// 234 local cards
+  // stored the local card id that's fired
+  for (Int_t i = 0; i <  nEntries; i++) {
+    locTrg = (AliMUONLocalTrigger*)localTrigger->At(i);
+    isFired[locTrg->LoCircuit()] = 1;
+  }
+
+  if (!nEntries)
+    AliError("No Trigger information available");
+
+  buffer = new Int_t [672]; // [16(local)*5 words + 3 words]*8(reg) + 8 words = 672
+
+  for (Int_t iDDL = 0; iDDL < 2; iDDL++) {
+    
+    index = 0; 
+
+    // DDL enhanced header
+    word = 0;
+    AliBitPacking::PackWord((UInt_t)iDDL+1,word,28,31); //see AliMUONDDLTrigger.h for details
+    AliBitPacking::PackWord((UInt_t)serialNb,word,24,27);
+    AliBitPacking::PackWord((UInt_t)version,word,16,23);
+    AliBitPacking::PackWord((UInt_t)eventType,word,12,15);
+
+    if (iDDL == 0) // suppose global info in DDL one
+      globalFlag = 2;
+    else 
+      globalFlag = 1;
+    AliBitPacking::PackWord((UInt_t)globalFlag,word,8,11);
+    fDDLTrigger->SetDDLWord(word);
+
+    if (iDDL == 0)
+      fDDLTrigger->SetGlobalOutput(gloTrigPat);// no global input for the moment....
+    else 
+      fDDLTrigger->SetGlobalOutput(0);
+    length = fDDLTrigger->GetHeaderLength(); 
+    memcpy(&buffer[index],fDDLTrigger->GetEnhancedHeader(),length*4);
+    index += length; 
+
+    for (Int_t iReg = 0; iReg < 8; iReg++) {
+
+      subEvent = new AliMUONSubEventTrigger();
+
+      // Regional card header
+      word = 0;
+      regOut  = 0;
+      AliBitPacking::PackWord((UInt_t)serialNb,word,24,28); //see  AliMUONSubEventTrigger.h for details
+      AliBitPacking::PackWord((UInt_t)version,word,16,23);
+      AliBitPacking::PackWord((UInt_t)iReg,word,12,15);
+      AliBitPacking::PackWord((UInt_t)regOut,word,0,7); // whenever regional output will be implemented
+
+      subEvent->SetRegWord(word);
+      memcpy(&buffer[index++],subEvent->GetAddress(),4);
+
+      buffer[index++] = 0;// 2 words of regional input
+      buffer[index++] = 0;
+
+      for (Int_t iLoc = 0; iLoc < 16; iLoc++) {
+
+       iLocCard = iLoc + iReg*16 + iDDL*128;
+
+       if (isFired[iLocCard]) {
+         locTrg = (AliMUONLocalTrigger*)localTrigger->At(iEntries);
+         locCard = locTrg->LoCircuit();
+         locDec = locTrg->GetLoDecision();
+         trigY = 0;
+         posY = locTrg->LoStripY();
+         posX = locTrg->LoStripX();
+         devX = locTrg->LoDev();
+         AliDebug(4,Form("loctrg %d, posX %d, posY %d, devX %d\n", 
+                         locTrg-> LoCircuit(),locTrg->LoStripX(),locTrg->LoStripY(),locTrg->LoDev()));
+       } else { //no trigger (see PRR chpt 3.4)
+         locCard = -1;
+         locDec = 0;
+         trigY = 1;
+         posY = 15;
+         posX = 0;
+         devX = 0x8000;
+       }
+
+       //packing word
+       word = 0;
+       AliBitPacking::PackWord((UInt_t)(iLocCard % 16),word,19,22); //card id number in crate
+       AliBitPacking::PackWord((UInt_t)locDec,word,15,18);
+       AliBitPacking::PackWord((UInt_t)trigY,word,14,14);
+       AliBitPacking::PackWord((UInt_t)posY,word,10,13);
+       AliBitPacking::PackWord((UInt_t)devX,word,5,9);
+       AliBitPacking::PackWord((UInt_t)posX,word,0,4);
+
+       if (locCard == iLocCard) {
+         // add local cards structure
+         buffer[index++] = (locTrg->GetX1Pattern() | (locTrg->GetX2Pattern() << 16));
+         buffer[index++] = (locTrg->GetX3Pattern() | (locTrg->GetX4Pattern() << 16));
+         buffer[index++] = (locTrg->GetY1Pattern() | (locTrg->GetY2Pattern() << 16));
+         buffer[index++] = (locTrg->GetY3Pattern() | (locTrg->GetY4Pattern() << 16));
+         buffer[index++] = (Int_t)word; // data word
+         if (iEntries < nEntries-1)
+           iEntries++;
+       } else {
+         buffer[index++] = 0; // 4 words for x1, x2, y1, y2
+         buffer[index++] = 0; 
+         buffer[index++] = 0; 
+         buffer[index++] = 0; 
+         buffer[index++] = (Int_t)word; // data word
+
+       }
+      } // local card 
+
+      delete subEvent; 
+
+    } // Regional card
+    
+    buffer[index++] = fDDLTrigger->GetEoD(); // End of DDL word
+    buffer[index++] = fDDLTrigger->GetEoD(); // End of DDL word for 64 bits transfer purpose
+
+    
+    if (iDDL == 0) {
+      // write DDL 1
+      header.fSize = (index + headerSize) * 4;// total length in bytes
+      fwrite((char*)(&header),headerSize*4,1,fFile1);
+      fwrite(buffer,sizeof(int),index,fFile1);
+    } 
+    if (iDDL == 1) {
+      // write DDL 2
+      header.fSize = (index + headerSize) * 4;// total length in bytes
+      fwrite((char*)(&header),headerSize*4,1,fFile2);
+      fwrite(buffer,sizeof(int),index,fFile2);
+    }
+  }
+  delete[] buffer;
 
   return kTRUE;
 }
 //____________________________________________________________________
 void AliMUONRawData::GetDummyMapping(Int_t iCh, Int_t iCath, const AliMUONDigit* digit,
-                                    Int_t &busPatchId, UShort_t &manuId, UChar_t &channelId, UShort_t &charge)
+                                    Int_t &busPatchId, UShort_t &manuId, UChar_t &channelId)
 {
+// Dummy mapping for tracker
 
   Int_t offsetX = 0; // offet row
   Int_t offsetY = 0; // offset columns
@@ -506,30 +657,69 @@ void AliMUONRawData::GetDummyMapping(Int_t iCh, Int_t iCath, const AliMUONDigit*
       channelId = (id % chPerBus) % 64; //start at zero 
       channelId &= 0x3F; // 6 bits
 
-//       id =  (TMath::Abs(digit->PadX()) * offsetX + digit->PadY() + offsetY +
-//          offsetCath * iCath);
-//       busPatchId = id/50;
+     
+      AliDebug(2,Form("id: %d, busPatchId %d, manuId: %d, channelId: %d, maxchannel: %d, chPerBus %d\n",
+                     id, busPatchId, manuId, channelId, maxChannel, chPerBus));
 
-//       Int_t inBusId = id - (maxChannel/50 * busPatchId);// id channel in buspatch
-//       Int_t manuPerBus = (maxChannel/(50*64)); // number of manus per buspatch
+      AliDebug(2,Form("id: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d, charge %d\n",
+                     id, busPatchId, manuId, channelId, digit->PadX(), digit->PadY(), digit->Signal()));
 
-//       // 64 manu cards for one buspatch
-//       manuId = inBusId/manuPerBus;
-//       manuId &= 0x7FF; // 11 bits 
+}
 
-//       // channel id
-//       channelId = (inBusId % manuPerBus);
-//       channelId &= 0x3F; // 6 bits
+//____________________________________________________________________
+Int_t AliMUONRawData::GetGlobalTriggerPattern(const AliMUONGlobalTrigger* gloTrg)
+{
+  // global trigger pattern calculation
 
-      if (fPrintLevel == 2)
-       printf("id: %d, busPatchId %d, manuId: %d, channelId: %d, maxchannel: %d, chPerBus %d\n",
-              id, busPatchId, manuId, channelId, maxChannel, chPerBus);
-      // charge
-      charge = digit->Signal();
-      charge &= 0xFFF;
+  Int_t gloTrigPat = 0;
 
-      if (fPrintLevel == 2)
-       printf("id: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d, charge %d\n",
-              id, busPatchId, manuId, channelId, digit->PadX(), digit->PadY(), digit->Signal());
+  if (gloTrg->SinglePlusLpt())  gloTrigPat|= 0x1;
+  if (gloTrg->SinglePlusHpt())  gloTrigPat|= 0x2;
+  if (gloTrg->SinglePlusApt())  gloTrigPat|= 0x4;
+  if (gloTrg->SingleMinusLpt()) gloTrigPat|= 0x8;
+  if (gloTrg->SingleMinusHpt()) gloTrigPat|= 0x10;
+  if (gloTrg->SingleMinusApt()) gloTrigPat|= 0x20;
+  if (gloTrg->SingleUndefLpt()) gloTrigPat|= 0x40;
+  if (gloTrg->SingleUndefHpt()) gloTrigPat|= 0x80;
+  if (gloTrg->SingleUndefApt()) gloTrigPat|= 0x100;
+  if (gloTrg->PairUnlikeLpt())  gloTrigPat|= 0x200;
+  if (gloTrg->PairUnlikeHpt())  gloTrigPat|= 0x400;
+  if (gloTrg->PairUnlikeApt())  gloTrigPat|= 0x800;
+
+  if (gloTrg->PairLikeLpt())    gloTrigPat|= 0x1000;
+  if (gloTrg->PairLikeHpt())    gloTrigPat|= 0x2000;
+  if (gloTrg->PairLikeApt())    gloTrigPat|= 0x4000;
+
+  return gloTrigPat;
+}
+
+//____________________________________________________________________
+Int_t AliMUONRawData::Raw2Digits(AliRawReader* /*rawReader*/)
+{
+  return kFALSE;
+
+}
+
+//____________________________________________________________________
+Int_t AliMUONRawData::ReadTrackerDDL(AliRawReader* /*rawReader*/)
+{
+  return kFALSE;
+
+}
+
+//____________________________________________________________________
+void AliMUONRawData:: GetInvDummyMapping(Int_t /*iCh*/, Int_t /*buspatchId*/, UShort_t /*manuId*/, 
+                                        UChar_t /*channelId*/, AliMUONDigit* /*digit*/ )
+{
+  return;
+}
+
+//____________________________________________________________________
+Int_t AliMUONRawData::ReadTriggerDDL(AliRawReader* /*rawReader*/)
+{
+  return kFALSE;
 
 }