]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Class for decoding rawdata for tracker, add padding word
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 9 May 2006 15:18:46 +0000 (15:18 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 9 May 2006 15:18:46 +0000 (15:18 +0000)
(Christian)

MUON/AliMUONRawStreamTracker.cxx [new file with mode: 0644]
MUON/AliMUONRawStreamTracker.h [new file with mode: 0644]

diff --git a/MUON/AliMUONRawStreamTracker.cxx b/MUON/AliMUONRawStreamTracker.cxx
new file mode 100644 (file)
index 0000000..5fc444d
--- /dev/null
@@ -0,0 +1,379 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+
+///////////////////////////////////////////////////////////////////////////////
+///
+/// This class provides access to MUON digits in raw data.
+///
+/// It loops over all MUON digits in the raw data given by the AliRawReader.
+/// The Next method goes to the next digit. If there are no digits left
+/// it returns kFALSE (under develpment)
+/// It can loop also over DDL and store the decoded rawdata in TClonesArray.
+/// 
+/// First version implement for Tracker
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliMUONRawStreamTracker.h"
+
+#include "AliRawReader.h"
+#include "AliRawDataHeader.h"
+#include "AliLog.h"
+
+#include "AliMUONDspHeader.h"
+#include "AliMUONBlockHeader.h"
+#include "AliMUONBusStruct.h"
+#include "AliMUONDDLTracker.h"
+
+ClassImp(AliMUONRawStreamTracker)
+
+AliMUONRawStreamTracker::AliMUONRawStreamTracker()
+  : TObject(),
+    fRawReader(0x0),
+    fDDL(0),
+    fBusPatchId(0),
+    fDspId(0),
+    fBlkId(0),
+    fNextDDL(kTRUE),
+    fMaxDDL(20),
+    fMaxBlock(2),
+    fMaxDsp(5),
+    fMaxBus(5)
+{
+  //
+  // create an object to read MUON raw digits
+  // Default ctor for monitoring purposes
+  //
+  fBusPatchManager = new AliMpBusPatch();
+  fBusPatchManager->ReadBusPatchFile();
+
+  fDDLTracker      = new AliMUONDDLTracker();
+  fBusStruct       = new AliMUONBusStruct();
+  fBlockHeader     = new AliMUONBlockHeader();
+  fDspHeader       = new AliMUONDspHeader();
+}
+
+//_________________________________________________________________
+AliMUONRawStreamTracker::AliMUONRawStreamTracker(AliRawReader* rawReader)
+  : TObject(),
+    fDDL(0),
+    fBusPatchId(0),
+    fDspId(0),
+    fBlkId(0),
+    fNextDDL(kTRUE),
+    fMaxDDL(20),
+    fMaxBlock(2),
+    fMaxDsp(5),
+    fMaxBus(5)
+{
+  //
+  // ctor with AliRawReader as argument
+  // for reconstruction purpose
+  //
+
+  fRawReader       = rawReader;
+
+  fBusPatchManager = new AliMpBusPatch();
+  fBusPatchManager->ReadBusPatchFile();
+
+  fDDLTracker      = new AliMUONDDLTracker();
+  fBusStruct       = new AliMUONBusStruct();
+  fBlockHeader     = new AliMUONBlockHeader();
+  fDspHeader       = new AliMUONDspHeader();
+}
+
+//_________________________________________________________________
+AliMUONRawStreamTracker::AliMUONRawStreamTracker(const AliMUONRawStreamTracker& stream) :
+  TObject(stream)
+{ 
+  //
+  // copy ctor
+  //
+  AliFatal("copy constructor not implemented");
+}
+
+//______________________________________________________________________
+AliMUONRawStreamTracker& AliMUONRawStreamTracker::operator = (const AliMUONRawStreamTracker& 
+                                             /* stream */)
+{
+  // 
+  // assignment operator
+  //
+  AliFatal("assignment operator not implemented");
+  return *this;
+}
+
+
+//___________________________________
+AliMUONRawStreamTracker::~AliMUONRawStreamTracker()
+{
+  //
+  // clean up
+  //
+  delete fBusPatchManager;
+  delete fDDLTracker;
+  delete fBusStruct;
+  delete fBlockHeader;
+  delete fDspHeader;
+}
+
+//_____________________________________________________________
+Bool_t AliMUONRawStreamTracker::Next()
+{
+  //
+  // read the next raw digit (buspatch structure)
+  // returns kFALSE if there is no digit left
+  // (under development)
+
+     AliMUONDDLTracker*       ddlTracker = 0x0;
+     AliMUONBlockHeader*      blkHeader  = 0x0;
+     AliMUONDspHeader*        dspHeader  = 0x0;
+     Int_t nBusPatch;
+     Int_t nDsp;
+     Int_t nBlock;
+
+ next:  
+     if (fNextDDL){
+       printf("iDDL %d\n", fDDL+1);
+       fBlkId = 0;
+       fDspId = 0;
+       fBusPatchId = 0;
+       if(!NextDDL()) 
+        return kFALSE;
+     }
+     fNextDDL = kFALSE;
+
+     ddlTracker = GetDDLTracker();
+
+     nBlock = ddlTracker->GetBlkHeaderEntries();
+     if (fBlkId <  nBlock) {
+
+       blkHeader = ddlTracker->GetBlkHeaderEntry(fBlkId);
+       nDsp      = blkHeader->GetDspHeaderEntries();
+
+       if( fDspId < nDsp) {
+        dspHeader = blkHeader->GetDspHeaderEntry(fDspId);
+        nBusPatch = dspHeader->GetBusPatchEntries();
+
+        if (fBusPatchId < nBusPatch) {
+          fBusStructPtr = dspHeader->GetBusPatchEntry(fBusPatchId++);
+          return kTRUE;
+
+        } else {// iBusPatch
+          fDspId++;
+          fBusPatchId = 0;
+          goto next;
+          //   Next();
+        }
+
+       } else {// iDsp
+        fBlkId++;
+        fDspId = 0;
+        fBusPatchId = 0;
+        goto next;
+        //      Next();
+       }
+
+     } else {// iBlock
+       fBlkId = 0;
+       fDspId = 0;
+       fBusPatchId = 0;
+       fNextDDL = kTRUE;
+       //return kTRUE;
+       goto next; 
+     }
+
+     return kFALSE;
+}
+
+//______________________________________________________
+Bool_t AliMUONRawStreamTracker::NextDDL()
+{
+  // reading tracker DDL
+  // store buspatch info into Array
+  // store only non-empty structures (buspatch info with datalength !=0)
+
+  fDDLTracker->GetBlkHeaderArray()->Delete();
+  // fDDLTracker->GetBlkHeaderArray()->Clear("C");
+
+  //Read Header Size of DDL,Block,DSP and BusPatch
+
+  Int_t kDDLHeaderSize      = sizeof(AliRawDataHeader)/4;;
+  Int_t kBlockHeaderSize    = fBlockHeader->GetHeaderLength();
+  Int_t kDspHeaderSize      = fDspHeader->GetHeaderLength();
+  Int_t kBusPatchHeaderSize = fBusStruct->GetHeaderLength();
+
+  Int_t totalDDLSize, totalBlockSize, totalDspSize , totalBusPatchSize, dataSize; 
+
+
+  Int_t iBusPerDSP[5]; // number of bus patches per DSP
+  Int_t iDspMax;       // number max of DSP per block
+
+  // minimum data size (only header's)
+  Int_t blankDDLSize;
+  Int_t blankBlockSize;
+  Int_t blankDspSize; 
+
+  if (fDDL >= 20) {
+    fDDL = 0;
+    return kFALSE;
+  }
+  AliDebug(3, Form("DDL Number %d\n", fDDL ));
+
+  // getting DSP info
+  fBusPatchManager->GetDspInfo(fDDL/2, iDspMax, iBusPerDSP);
+
+  // Each DDL is made with 2 Blocks each of which consists of 5 DSP's at most 
+  // and each of DSP has at most 5 buspatches.
+  // This information is used to calculate the size of headers (DDL,Block and DSP) 
+  // which has no interesting data.
+  blankDDLSize   = kDDLHeaderSize + 2*kBlockHeaderSize + 2*iDspMax*kDspHeaderSize;
+  blankBlockSize = kBlockHeaderSize + iDspMax*kDspHeaderSize;
+
+  for (Int_t i = 0; i < iDspMax; i++) {
+    blankDDLSize   += 2*iBusPerDSP[i]*kBusPatchHeaderSize;
+    blankBlockSize +=   iBusPerDSP[i]*kBusPatchHeaderSize;
+  }
+  fRawReader->Reset();
+  fRawReader->Select(0X9, fDDL, fDDL);  //Select the DDL file to be read  
+
+  fRawReader->ReadHeader();
+
+  // 4 is multiplied to convert 2 bytes words
+  totalDDLSize = (fRawReader->GetDataSize() + sizeof(AliRawDataHeader))/4; 
+
+  // Compare the DDL header with an empty DDL header size to read the file
+  if(totalDDLSize > blankDDLSize) {      
+
+    Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes
+    UInt_t *buffer = new UInt_t[totalDataWord/4];
+  
+    fRawReader->ReadNext((UChar_t*)buffer, totalDataWord); 
+    // indexes
+    Int_t indexDsp;
+    Int_t indexBusPatch;
+    Int_t index = 0;
+
+    for(Int_t iBlock = 0; iBlock < 2 ;iBlock++){  // loop over 2 blocks
+
+      // copy within padding words
+      memcpy(fBlockHeader->GetHeader(),&buffer[index], (kBlockHeaderSize+1)*4);
+
+      totalBlockSize = fBlockHeader->GetTotalLength();
+
+      fDDLTracker->AddBlkHeader(*fBlockHeader);
+
+      if (fBlockHeader->GetPadding() == 0xDEAD) // skipping padding word
+       index++;
+
+      if(totalBlockSize > blankBlockSize) {        // compare block header
+       index += kBlockHeaderSize;
+
+       for(Int_t iDsp = 0; iDsp < iDspMax ;iDsp++){   //DSP loop
+
+         if (iDsp > fMaxDsp) break;
+         
+         memcpy(fDspHeader->GetHeader(),&buffer[index], kDspHeaderSize*4);
+
+         totalDspSize = fDspHeader->GetTotalLength();
+         indexDsp = index;
+
+         blankDspSize =  kDspHeaderSize + iBusPerDSP[iDsp]*kBusPatchHeaderSize; // no data just header
+
+         fDDLTracker->AddDspHeader(*fDspHeader, iBlock);
+
+         if(totalDspSize > blankDspSize) {       // Compare DSP Header
+           index += kDspHeaderSize;
+               
+           for(Int_t iBusPatch = 0; iBusPatch < iBusPerDSP[iDsp]; iBusPatch++) {  
+
+             if (iBusPatch > fMaxBus) break; 
+
+             //copy buffer into header structure
+             memcpy(fBusStruct->GetBusPatchHeader(), &buffer[index], kBusPatchHeaderSize*4);
+
+             totalBusPatchSize = fBusStruct->GetTotalLength();
+             indexBusPatch     = index;
+               
+             //Check Buspatch header, not empty events
+             if(totalBusPatchSize > kBusPatchHeaderSize) {    
+
+               index   += kBusPatchHeaderSize;
+               dataSize = fBusStruct->GetLength();
+               Int_t bufSize = fBusStruct->GetBufSize();
+
+               if(dataSize > 0) { // check data present
+                 if (dataSize > bufSize) fBusStruct->SetAlloc(dataSize);
+
+                 //copy buffer into data structure
+                 memcpy(fBusStruct->GetData(), &buffer[index], dataSize*4);
+                 fBusStruct->SetBlockId(iBlock); // could be usefull in future applications ?
+                 fBusStruct->SetDspId(iDsp);
+                 fDDLTracker->AddBusPatch(*fBusStruct, iBlock, iDsp);
+
+               } // dataSize test
+
+             } // testing buspatch
+
+             index = indexBusPatch + totalBusPatchSize;
+
+           }  //buspatch loop
+               
+         }  // dsp test
+
+         index = indexDsp + totalDspSize;
+             
+       }  // dsp loop
+
+      }   //block test
+
+      index = totalBlockSize;
+
+    }  //block loop
+
+    delete[] buffer;
+  } //loop checking the header size of DDL
+
+
+  fDDL++;
+
+  return kTRUE;
+}
+//______________________________________________________
+void AliMUONRawStreamTracker::ResetDDL()
+{
+  // reseting TClonesArray
+  // after each DDL
+  //
+  fDDLTracker->GetBlkHeaderArray()->Clear("C");
+}
+
+//______________________________________________________
+void AliMUONRawStreamTracker::SetMaxDDL(Int_t ddl) 
+{
+  // set DDL number
+  if (ddl > 20) ddl = 20;
+  fMaxDDL = ddl;
+}
+
+//______________________________________________________
+void AliMUONRawStreamTracker::SetMaxBlock(Int_t blk) 
+{
+  // set regional card number
+  if (blk > 2) blk = 2;
+  fMaxBlock = blk;
+}
diff --git a/MUON/AliMUONRawStreamTracker.h b/MUON/AliMUONRawStreamTracker.h
new file mode 100644 (file)
index 0000000..2333970
--- /dev/null
@@ -0,0 +1,91 @@
+#ifndef ALIMUONRAWSTREAMTRACKER_H
+#define ALIMUONRAWSTREAMTRACKER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/*$Id$*/
+
+/// \ingroup raw
+/// \class AliMUONRawStreamTracker
+/// \brief Class for reading MUON raw digits
+///
+/// \author Christian Finck
+///
+///////////////////////////////////////////////////////////////////////////////
+///
+/// This class provides access to MUON digits in raw data.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+#include <TClonesArray.h>
+#include "AliMpBusPatch.h"
+
+class AliRawReader;
+class AliMUONDDLTracker;
+class AliMUONBusStruct;
+class AliMUONDspHeader;
+class AliMUONBlockHeader;
+
+class AliMUONRawStreamTracker: public TObject {
+  public :
+    AliMUONRawStreamTracker();
+    AliMUONRawStreamTracker(AliRawReader* rawReader);
+    AliMUONRawStreamTracker(const AliMUONRawStreamTracker& stream);
+    AliMUONRawStreamTracker& operator = (const AliMUONRawStreamTracker& stream);
+    virtual ~AliMUONRawStreamTracker();
+
+    virtual Bool_t   Next();
+    virtual Bool_t   NextDDL();
+    virtual void     ResetDDL();
+
+    Int_t GetMaxDDL()   const {return fMaxDDL;}
+    Int_t GetMaxBlock() const {return fMaxBlock;}
+    Int_t GetMaxDsp()   const {return fMaxDsp;}
+    Int_t GetMaxBus()   const {return fMaxBus;}
+
+    // check input before assigment
+    void SetMaxDDL(Int_t ddl);
+    void SetMaxBlock(Int_t blk);
+
+    // does not check, done via BusPatchManager
+    void SetMaxDsp(Int_t dsp) {fMaxDsp = dsp;}
+    void SetMaxBus(Int_t bus) {fMaxBus = bus;}
+
+
+    void SetReader(AliRawReader* rawReader) {fRawReader = rawReader;}
+
+    AliMUONBusStruct*       GetBusPatchInfo() const {return fBusStructPtr;}
+    AliMUONDDLTracker*      GetDDLTracker()   const {return fDDLTracker;}
+    Int_t                   GetDDL()          const {return fDDL - 1;}
+
+  protected :
+
+    AliRawReader*    fRawReader;    // object for reading the raw data
+    Int_t  fDDL;          // number of DDL
+    Int_t  fBusPatchId;   // entry of buspatch structure
+    Int_t  fDspId;        // entry of Dsp header
+    Int_t  fBlkId;        // entry of Block header
+
+    Bool_t fNextDDL;      // flag for next DDL to be read
+
+    Int_t fMaxDDL;        // maximum number of DDL in DATE file
+    Int_t fMaxBlock;      // maximum number of block per DDL in DATE file
+    Int_t fMaxDsp;        // maximum number of Dsp per block in DATE file
+    Int_t fMaxBus;        // maximum number of Buspatch per Dsp in DATE file
+
+
+    AliMpBusPatch* fBusPatchManager; //! buspatch versus DE's & DDL
+
+    AliMUONDDLTracker*      fDDLTracker;      //! pointer for buspatch structure
+    AliMUONBusStruct*       fBusStruct;       //! pointer for local structure
+    AliMUONBlockHeader*     fBlockHeader;     //! pointer for block structure 
+    AliMUONDspHeader*       fDspHeader;       //! pointer for dsp structure 
+
+    AliMUONBusStruct*       fBusStructPtr;       //! pointer for local structure
+
+    ClassDef(AliMUONRawStreamTracker, 1)    // base class for reading MUON raw digits
+};
+
+#endif