]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDrawStream.cxx
Remove old tracking code
[u/mrichter/AliRoot.git] / TRD / AliTRDrawStream.cxx
index 9ada058dabcc1eecdfb5a7e68341e780484631e7..826a707b23622fdccdd167cb8b22eb96a5389505 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliTRDarrayDictionary.h"
 #include "AliTRDSignalIndex.h"
 #include "AliTRDtrackletWord.h"
+#include "AliESDTrdTrack.h"
 #include "AliTreeLoader.h"
 
 #include "AliTRDrawStream.h"
@@ -172,7 +173,10 @@ AliTRDrawStream::AliTRDrawStream(AliRawReader *rawReader) :
   fTrackletArray(0x0),
   fAdcArray(0x0),
   fSignalIndex(0x0),
-  fTrackletTree(0x0)
+  fTrackletTree(0x0),
+  fTracklets(0x0),
+  fTracks(0x0),
+  fMarkers(0x0)
 {
   // default constructor
 
@@ -186,6 +190,8 @@ AliTRDrawStream::AliTRDrawStream(AliRawReader *rawReader) :
   fCurrLinkMonitorFlags   = new UInt_t[fgkNstacks * fgkNlinks];
   fCurrLinkDataTypeFlags  = new UInt_t[fgkNstacks * fgkNlinks];
   fCurrLinkDebugFlags     = new UInt_t[fgkNstacks * fgkNlinks];
+  for (Int_t i = 0; i < 100; i++)
+    fDumpMCM[i] = 0;
 
   // preparing TClonesArray
   fTrackletArray = new TClonesArray("AliTRDtrackletWord", 256);
@@ -193,8 +199,12 @@ AliTRDrawStream::AliTRDrawStream(AliRawReader *rawReader) :
   // setting up the error tree
   fErrors = new TTree("errorStats", "Error statistics");
   fErrors->SetDirectory(0x0);
-  fErrors->Branch("error", &fLastError, "sector/I:stack:link:error:rob:mcm");
+  fErrors->Branch("error", &fLastError);
   fErrors->SetCircular(1000);
+  for (Int_t i = 0; i < 100; i++) {
+    fErrorBuffer[i] = 0;
+  }
+
 }
 
 AliTRDrawStream::~AliTRDrawStream()
@@ -270,7 +280,7 @@ Bool_t AliTRDrawStream::ReadEvent(TTree *trackletTree)
       AliDebug(2, Form("Stack %i, Link mask: 0x%02x", fCurrSlot, fCurrLinkMask[fCurrSlot]));
       for (Int_t iLink = 0; iLink < 12; iLink++) {
        fCurrLink = iLink;
-       fCurrHC   = fCurrSm * 60 + fCurrSlot * 12 + iLink;
+       fCurrHC   = (fCurrEquipmentId - 1024) * 60 + fCurrSlot * 12 + iLink;
        if ((fCurrLinkMask[fCurrSlot] & (1 << fCurrLink)) == 0)
          continue;
        
@@ -370,11 +380,20 @@ Int_t AliTRDrawStream::NextChamber(AliTRDdigitsManager *digMgr, UInt_t ** /* tra
     return -1;
   }
 
-  if (fCurrSlot < 0 || fCurrSlot >= 5) {
+  while (fCurrSlot < 0 || fCurrSlot >= 5) {
     if (!NextDDL()) {
       fCurrSlot = -1;
       return -1;
     }
+    while ((fCurrSlot < 5) &&
+          (((fCurrStackMask & (1 << fCurrSlot)) == 0) ||
+           ((fCurrLinkMask[fCurrSlot] & (1 << fCurrLink))) == 0)) {
+      fCurrLink++;
+      if (fCurrLink > 11) {
+       fCurrLink = 0;
+       fCurrSlot++;
+      }
+    }
   }
 
   AliDebug(2, Form("Stack %i, Link %i, mask: 0x%02x", fCurrSlot, fCurrLink, fCurrLinkMask[fCurrSlot]));
@@ -410,7 +429,12 @@ Int_t AliTRDrawStream::NextChamber(AliTRDdigitsManager *digMgr, UInt_t ** /* tra
           (((fCurrStackMask & (1 << fCurrSlot)) == 0) || 
            ((fCurrLinkMask[fCurrSlot] & (1 << fCurrLink))) == 0));
 
-  return (fCurrSm * 30 + fCurrStack * 6 + fCurrLayer);
+  // return chamber information from HC if it is valid
+  // otherwise return information from link position
+  if (fCurrSm < 0 || fCurrSm > 17 || fCurrStack < 0 || fCurrStack > 4 || fCurrLayer < 0 || fCurrLayer > 5)
+    return ((fCurrEquipmentId-1024) + fCurrSlot * 6 + fCurrLink/2);
+  else
+    return (fCurrSm * 30 + fCurrStack * 6 + fCurrLayer);
 }
 
 
@@ -426,6 +450,8 @@ Int_t AliTRDrawStream::ReadSmHeader()
 
   fCurrSmuIndexHeaderSize     = ((*fPayloadCurr) >> 16) & 0xffff;
   fCurrSmuIndexHeaderVersion  = ((*fPayloadCurr) >> 12) &    0xf;
+  //  fCurrSmuIndexHeaderTrgAvail = ((*fPayloadCurr) >>  9) &    0x1;
+  //  fCurrSmuIndexHeaderEvType   = ((*fPayloadCurr) >>  7) &    0x3;
   fCurrTrackEnable            = ((*fPayloadCurr) >>  6) &    0x1;
   fCurrTrackletEnable         = ((*fPayloadCurr) >>  5) &    0x1;
   fCurrStackMask              = ((*fPayloadCurr)      ) &   0x1f;
@@ -436,7 +462,35 @@ Int_t AliTRDrawStream::ReadSmHeader()
                   fCurrTrackEnable, 
                   fCurrTrackletEnable,
                   fCurrStackMask));
-  
+
+  // decode GTU track words
+  UInt_t trackWord[2] = { 0, 0 };
+  Int_t stack = 0;
+  Int_t idx = 0;
+  for (UInt_t iWord = 4; iWord < fCurrSmuIndexHeaderSize; iWord++) {
+    if (fPayloadCurr[iWord] == 0x10000000) {
+      stack++;
+      idx = 0;
+    }
+    else {
+      if ((idx == 0) &&
+         ((fPayloadCurr[iWord] & 0xfffff0f0) == 0x13370000)) {
+       AliDebug(1,Form("stack %i: fast trigger word: 0x%08x", stack, fPayloadCurr[iWord]));
+       continue;
+      }
+      else if ((idx & 0x1)==0x1) {
+       trackWord[idx&0x1] = fPayloadCurr[iWord];
+       AliDebug(1,Form("track debug word: 0x%08x%08x", trackWord[1], trackWord[0]));
+//     if (fTracks)
+//       new ((*fTracks)[fTracks->GetEntriesFast()]) AliESDTrdTrack(0, 0, trackWord[0], trackWord[1], fCurrEquipmentId-1024);
+      }
+      else {
+       trackWord[idx&0x1] = fPayloadCurr[iWord];
+      }
+      idx++;
+    }
+  }
+
   fPayloadCurr += fCurrSmuIndexHeaderSize + 1;
 
   return fCurrSmuIndexHeaderSize + 1;
@@ -503,6 +557,10 @@ Int_t AliTRDrawStream::ReadLinkData()
 //        fPayloadCurr[i*4+0], fPayloadCurr[i*4+1], fPayloadCurr[i*4+2], fPayloadCurr[i*4+3]);
 //  }
 
+  if (fMarkers)
+    new ((*fMarkers)[fMarkers->GetEntriesFast()])
+      AliTRDrawStreamError(-kHCactive, fCurrSm, fCurrStack, fCurrLink);
+
   if (fErrorFlags & kDiscardHC)
     return count;
 
@@ -586,11 +644,13 @@ Int_t AliTRDrawStream::ReadLinkData()
           *fPayloadCurr != fgkDataEndmarker)
       fPayloadCurr++;
   }
-  
-  fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytes     += (fPayloadCurr - startPosLink) * sizeof(UInt_t);
-  fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytesRead += count * sizeof(UInt_t);
-  fStats.fStatsSector[fCurrSm].fBytesRead                      += count * sizeof(UInt_t);
-  fStats.fBytesRead                                            += count * sizeof(UInt_t);
+
+  if (fCurrSm > -1 && fCurrSm < 18) {
+    fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytes     += (fPayloadCurr - startPosLink) * sizeof(UInt_t);
+    fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytesRead += count * sizeof(UInt_t);
+    fStats.fStatsSector[fCurrSm].fBytesRead                      += count * sizeof(UInt_t);
+    fStats.fBytesRead                                            += count * sizeof(UInt_t);
+  }
 
   return count;
 }
@@ -605,18 +665,24 @@ Int_t AliTRDrawStream::ReadTracklets()
   while (*(fPayloadCurr) != fgkTrackletEndmarker && 
         fPayloadCurr - fPayloadStart < fPayloadSize) {
 
-    new ((*fTrackletArray)[fTrackletArray->GetEntriesFast()]) AliTRDtrackletWord(*(fPayloadCurr));
+    new ((*fTrackletArray)[fTrackletArray->GetEntriesFast()]) AliTRDtrackletWord(*(fPayloadCurr), fCurrHC);
 
     fPayloadCurr++;
   }
 
   if (fTrackletArray->GetEntriesFast() > 0) {
     AliDebug(1, Form("Found %i tracklets in %i %i %i (ev. %i)", fTrackletArray->GetEntriesFast(), 
-                    fCurrSm, fCurrSlot, fCurrLink, fRawReader->GetEventIndex()));
-    fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNTracklets += fTrackletArray->GetEntriesFast();
-    fStats.fStatsSector[fCurrSm].fNTracklets                      += fTrackletArray->GetEntriesFast();
+                    (fCurrEquipmentId-1024), fCurrSlot, fCurrLink, fRawReader->GetEventIndex()));
+    if (fCurrSm > -1 && fCurrSm < 18) {
+      fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNTracklets += fTrackletArray->GetEntriesFast();
+      fStats.fStatsSector[fCurrSm].fNTracklets                      += fTrackletArray->GetEntriesFast();
+    }
     if (fTrackletTree)
       fTrackletTree->Fill();
+    if (fTracklets)
+      for (Int_t iTracklet = 0; iTracklet < fTrackletArray->GetEntriesFast(); iTracklet++) {
+       new ((*fTracklets)[fTracklets->GetEntriesFast()]) AliTRDtrackletWord(*((AliTRDtrackletWord*)(*fTrackletArray)[iTracklet]));
+      }
   }
 
   // loop over remaining tracklet endmarkers
@@ -669,7 +735,7 @@ Int_t AliTRDrawStream::ReadHcHeader()
   
   fPayloadCurr += 1 + fCurrAddHcWords;
   
-  return (fPayloadCurr - start) / sizeof(UInt_t);
+  return (fPayloadCurr - start);
 }
 
 Int_t AliTRDrawStream::ReadTPData(Int_t mode)
@@ -946,14 +1012,18 @@ Int_t AliTRDrawStream::ReadZSData()
       channelcount++;
     }
 
-    fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNChannels += channelcount;
-    fStats.fStatsSector[fCurrSm].fNChannels                      += channelcount;
+    if (fCurrSm > -1 && fCurrSm < 18) {
+      fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNChannels += channelcount;
+      fStats.fStatsSector[fCurrSm].fNChannels                      += channelcount;
+    }
     if (channelcount != channelcountExp)
       MCMError(kAdcChannelsMiss);
     
     mcmcount++;
-    fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNMCMs++;
-    fStats.fStatsSector[fCurrSm].fNMCMs++;
+    if (fCurrSm > -1 && fCurrSm < 18) {
+      fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNMCMs++;
+      fStats.fStatsSector[fCurrSm].fNMCMs++;
+    }
 
     if (IsDumping() && DumpingMCM(fCurrHC/2, fCurrRobPos, fCurrMcmPos)) {
       DumpRaw(Form("Event %i: Det %3i ROB %i MCM %2i", fRawReader->GetEventIndex(), fCurrHC/2, fCurrRobPos, fCurrMcmPos),