--- /dev/null
+/**************************************************************************
+ * 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. *
+ **************************************************************************/
+
+#include "AliMUONBlockHeader.h"
+#include "AliMUONDspHeader.h"
+
+
+///
+/// Block structure for tracker raw data
+/// each DDL contains two blocks,
+/// each block contains at most 5 dsp structure.
+/// Beside the total length and length of the below data
+/// the header of the block contains the front end DSP id, trigger words and paddind word
+///
+
+ClassImp(AliMUONBlockHeader)
+
+ const Int_t AliMUONBlockHeader::fgkHeaderLength = 7;
+
+//___________________________________________
+AliMUONBlockHeader::AliMUONBlockHeader()
+ : TObject(),
+ fTotalLength(0),
+ fLength(0),
+ fDspId(0),
+ fPadding(0x0DEADDEAD)
+{
+ //
+ // ctor
+ //
+ for (Int_t i = 0; i < 4; i++)
+ fTriggerWord[i] = 0;
+
+ fDspHeaderArray = new TClonesArray("AliMUONDspHeader", 5);
+
+}
+
+//___________________________________________
+AliMUONBlockHeader::~AliMUONBlockHeader()
+{
+ //
+ // dtor
+ //
+ fDspHeaderArray->Delete();
+ delete fDspHeaderArray;
+}
+
+//___________________________________________
+AliMUONBlockHeader::AliMUONBlockHeader(const AliMUONBlockHeader& event)
+ : TObject(event)
+{
+ //
+ // copy ctor
+ //
+ fTotalLength = event.fTotalLength;
+ fLength = event.fLength;
+ fDspId = event.fDspId;
+ fPadding = event.fPadding;
+
+ for (Int_t i = 0; i < 4; i++)
+ fTriggerWord[i] = event.fTriggerWord[i];
+
+ fDspHeaderArray = new TClonesArray("AliMUONDspHeader", 5);
+ for (Int_t index = 0; index < (event.fDspHeaderArray)->GetEntriesFast(); index++) {
+ {new ((*fDspHeaderArray)[fDspHeaderArray->GetEntriesFast()])
+ AliMUONDspHeader(*(AliMUONDspHeader*)(event.fDspHeaderArray)->At(index));}
+ }
+ // fDspHeaderArray->SetOwner();
+}
+
+//___________________________________________
+AliMUONBlockHeader&
+AliMUONBlockHeader::operator=(const AliMUONBlockHeader &event)
+{
+ //
+ // assignment operator
+ //
+ if (this == &event) return *this;
+
+ fTotalLength = event.fTotalLength;
+ fLength = event.fLength;
+ fDspId = event.fDspId;
+ fPadding = event.fPadding;
+
+ //copy ctor
+ for (Int_t i = 0; i < 4; i++)
+ fTriggerWord[i] = event.fTriggerWord[i];
+
+
+ fDspHeaderArray = new TClonesArray("AliMUONDspHeader", 5);
+ for (Int_t index = 0; index < (event.fDspHeaderArray)->GetEntriesFast(); index++) {
+ new ((*fDspHeaderArray)[fDspHeaderArray->GetEntriesFast()])
+ AliMUONDspHeader(*(AliMUONDspHeader*)(event.fDspHeaderArray)->At(index));
+ }
+
+ return *this;
+
+}
+//___________________________________________
+void AliMUONBlockHeader::AddDspHeader(const AliMUONDspHeader& dspHeader)
+{
+ //
+ // adding the dsp structure
+ // into the TClonesArray
+ //
+ TClonesArray &dspArray = *fDspHeaderArray;
+ new(dspArray[dspArray.GetEntriesFast()]) AliMUONDspHeader(dspHeader);
+
+}
+//___________________________________________
+void AliMUONBlockHeader::Clear(Option_t* )
+{
+ // Clear TClones arrays
+ // instead of deleting
+ //
+ fDspHeaderArray->Clear("C");
+
+}
--- /dev/null
+#ifndef ALIMUONBLOCKHEADER_H
+#define ALIMUONBLOCKHEADER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/*$Id$*/
+
+/// \ingroup raw
+/// \class AliMUONBlockHeader
+/// \brief MUON block header for tracker event
+///
+/// \author Christian Finck
+
+#include <TObject.h>
+#include <TClonesArray.h>
+
+class AliMUONDspHeader;
+
+class AliMUONBlockHeader : public TObject {
+
+public:
+ AliMUONBlockHeader();
+ AliMUONBlockHeader(const AliMUONBlockHeader &event);
+ AliMUONBlockHeader& operator=(const AliMUONBlockHeader &event);
+
+ virtual ~AliMUONBlockHeader();
+
+ // Block header
+ Int_t GetTotalLength() const {return fTotalLength;}
+ Int_t GetLength() const {return fLength;}
+ Int_t GetDspId() const {return fDspId;}
+ Int_t GetTriggerWord(Int_t n) const {return fTriggerWord[n];}
+ Int_t GetPadding() const {return fPadding;}
+ Int_t GetHeaderLength() const {return fgkHeaderLength;}
+
+ void SetTotalLength(Int_t l) {fTotalLength = l;}
+ void SetLength(Int_t l) {fLength = l;}
+ void SetDspId(Int_t d) {fDspId = d;}
+ void SetTriggerWord(Int_t w, Int_t n) {fTriggerWord[n] = w;}
+
+ Int_t* GetHeader() {return &fTotalLength;}
+
+ void AddDspHeader(const AliMUONDspHeader& dspHeader);
+
+ // get TClonesArray
+ TClonesArray* GetDspHeaderArray() const {return fDspHeaderArray;}
+
+ // get entries
+ Int_t GetDspHeaderEntries() const {return fDspHeaderArray->GetEntriesFast();}
+
+ // get entry
+ AliMUONDspHeader* GetDspHeaderEntry(Int_t i) const {
+ return (AliMUONDspHeader*)fDspHeaderArray->At(i);}
+
+ // clear
+ void Clear(Option_t* opt);
+
+ private:
+
+ // block header
+ Int_t fTotalLength; // total length of block structure (w/o padding word)
+ Int_t fLength; // length of raw data
+ Int_t fDspId; // Dsp id
+ Int_t fTriggerWord[4]; // counter trigger word
+ Int_t fPadding; // padding dummy word for 64 bits transfer
+
+ static const Int_t fgkHeaderLength; // header length in word
+
+ TClonesArray* fDspHeaderArray; // array of block header
+
+ ClassDef(AliMUONBlockHeader,1) // MUON block header for Tracker event
+};
+#endif
--- /dev/null
+/**************************************************************************
+ * 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. *
+ **************************************************************************/
+
+#include "AliMUONBusStruct.h"
+#include "AliLog.h"
+
+
+///
+/// Bus patch structure for tracker raw data
+/// each Dsp contains at most 5 bus patch structure
+/// Beside the total length and length of the below data
+/// the header of the block contains the bus patch id, trigger words
+/// and data structure itself (11bits for manu id, 6 bits for channel id and
+/// 12 bits for charge)
+///
+
+
+ClassImp(AliMUONBusStruct)
+
+ const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
+
+//___________________________________________
+AliMUONBusStruct::AliMUONBusStruct()
+ : TObject(),
+ fTotalLength(0),
+ fLength(0),
+ fBusPatchId(0),
+ fTriggerWord(0),
+ fBufSize(1024),
+ fDspId(0),
+ fBlkId(0)
+{
+ //
+ // ctor
+ //
+ fData = new UInt_t[fBufSize];
+}
+//___________________________________________
+AliMUONBusStruct::~AliMUONBusStruct()
+{
+ //
+ // dtor
+ //
+ delete[] fData;
+}
+
+//___________________________________________
+void AliMUONBusStruct::SetAlloc(Int_t size)
+{
+ //
+ // Allocate size per default 1024;
+ // return if size < 1024
+ //
+ if (size < fBufSize)
+ return;
+ else
+ ResizeData(size);
+}
+//___________________________________________
+void AliMUONBusStruct::AddData(UInt_t data)
+{
+ // could have used class from ROOT
+ // but the structure must be as simple as possible
+ // to be written on disc blockwise, not so sure ?
+ if (fLength == fBufSize)
+ ResizeData();
+ fData[fLength++] = data;
+ fTotalLength = fLength + fgkHeaderLength;
+}
+
+//___________________________________________
+void AliMUONBusStruct::ResizeData(Int_t size)
+{
+ // In case of resizing the vector
+ // the most simplest way to do it
+ //
+ if (size == 0)
+ fBufSize *= 2;
+ else
+ fBufSize = size;
+ UInt_t* newData = new UInt_t[fBufSize];
+ for (Int_t i = 0; i < fLength; i++)
+ newData[i] = fData[i];
+ delete[] fData;
+ fData = newData;
+}
+//___________________________________________
+AliMUONBusStruct::
+AliMUONBusStruct(const AliMUONBusStruct& event): TObject(event)
+{
+ //
+ // copy ctor
+ //
+ fTotalLength = event.fTotalLength;
+ fLength = event.fLength;
+ fBusPatchId = event.fBusPatchId;
+ fTriggerWord = event.fTriggerWord;
+ fBufSize = event.fBufSize;
+
+ fBlkId = event.fBlkId;
+ fDspId = event.fDspId;
+
+ fData = new UInt_t[event.fBufSize];
+ for (int i = 0; i < event.fBufSize; i++)
+ fData[i] = event.fData[i];
+}
+//___________________________________________
+AliMUONBusStruct&
+AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
+{
+ //
+ // assignment operator
+ //
+ if (this == &event) return *this;
+ fTotalLength = event.fTotalLength;
+ fLength = event.fLength;
+ fBusPatchId = event.fBusPatchId;
+ fTriggerWord = event.fTriggerWord;
+ fBufSize = event.fBufSize;
+
+ fBlkId = event.fBlkId;
+ fDspId = event.fDspId;
+
+ delete [] fData;
+ fData = new UInt_t[event.fBufSize];
+ for (int i = 0; i < event.fLength; i++)
+ fData[i] = event.fData[i];
+
+ return *this;
+}
+//___________________________________________
+Int_t AliMUONBusStruct::Compare(const TObject *obj) const
+{
+ //
+ // sort bus patch by bus patch number
+ // important for AliMUONRawWriter
+ //
+ AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
+ return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
+}
+
+//___________________________________________
+void AliMUONBusStruct::Clear(Option_t *)
+{
+ // clear
+ // delete the allocated memory
+ //
+
+ delete[] fData;
+}
+//___________________________________________
+UInt_t AliMUONBusStruct::GetData(Int_t n) const
+{
+ //
+ // get data
+ //
+ if ( n>=0 && n<fLength ) return fData[n];
+
+ AliError("Index outside limits.");
+ return 0;
+}
+
+//___________________________________________
+Char_t AliMUONBusStruct::GetParity(Int_t n) const
+{
+ //
+ // get parity
+ //
+ if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 29) & 0x7;
+
+ AliError("Index outside limits.");
+ return 0;
+}
+
+//___________________________________________
+UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
+{
+ //
+ // get manu Id
+ //
+ if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
+
+ AliError("Index outside limits.");
+ return 0;
+}
+
+//___________________________________________
+Char_t AliMUONBusStruct::GetChannelId(Int_t n) const
+{
+ //
+ // get channel Id
+ //
+ if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
+
+ AliError("Index outside limits.");
+ return 0;
+}
+
+//___________________________________________
+UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
+{
+ //
+ // get charge (in ADC)
+ //
+ if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
+
+ AliError("Index outside limits.");
+ return 0;
+}
--- /dev/null
+#ifndef ALIMUONBUSSTRUCT_H
+#define ALIMUONBUSSTRUCT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/*$Id$*/
+
+/// \ingroup raw
+/// \class AliMUONBusStruct
+/// \brief MUON buspatch structure for tracker
+///
+/// \author Christian Finck
+
+#include <TObject.h>
+
+class AliMUONBusStruct : public TObject {
+
+public:
+ AliMUONBusStruct ();
+ virtual ~AliMUONBusStruct ();
+ AliMUONBusStruct(const AliMUONBusStruct& rhs);
+ AliMUONBusStruct& operator=(const AliMUONBusStruct& rhs);
+
+ Int_t GetTotalLength() const {return fTotalLength;}
+ Int_t GetLength() const {return fLength;}
+ Int_t GetBufSize() const {return fBufSize;}
+ Int_t GetBusPatchId() const {return fBusPatchId;}
+ Int_t GetTriggerWord() const {return fTriggerWord;}
+ UInt_t* GetData() const {return fData;}
+ Int_t GetBlockId() const {return fBlkId;}
+ Int_t GetDspId() const {return fDspId;}
+
+
+ Char_t GetParity(Int_t n) const;
+ UShort_t GetManuId(Int_t n) const;
+ Char_t GetChannelId(Int_t n) const;
+ UShort_t GetCharge(Int_t n) const;
+ UInt_t GetData(Int_t n) const;
+
+ void SetTotalLength(Int_t l) {fTotalLength = l;}
+ void SetLength(Int_t l) {fLength = l;}
+ void SetBusPatchId(Int_t b) {fBusPatchId = b;}
+ void SetTriggerWord(Int_t w) {fTriggerWord = w;}
+ void SetData(UInt_t d, Int_t n) {fData[n] = d;}
+ void SetBlockId(Int_t b) {fBlkId = b;}
+ void SetDspId(Int_t d) {fDspId = d;}
+
+ void AddData(UInt_t d);
+ void SetAlloc(Int_t size);
+
+ Bool_t IsSortable() const {return kTRUE;}
+ Int_t Compare(const TObject *obj) const;
+ void Clear(Option_t* opt);
+
+ Int_t GetHeaderLength() const {return fgkHeaderLength;}
+
+ Int_t* GetBusPatchHeader() {return &fTotalLength;}
+
+ private:
+ Int_t fTotalLength; // total length of buspatch structure
+ Int_t fLength; // length of raw data
+ Int_t fBusPatchId; // bus patch id
+ Int_t fTriggerWord ; // counter trigger word
+
+ static const Int_t fgkHeaderLength; // header length in word
+
+ UInt_t* fData; // data
+
+ Int_t fBufSize; // initial size for data array
+
+ Int_t fDspId; // Dsp number for monitoring
+ Int_t fBlkId; // block numer for monitoring
+
+ void ResizeData(Int_t size = 0);
+
+ ClassDef(AliMUONBusStruct,1) // MUON DDL Tracker
+};
+#endif
--- /dev/null
+/**************************************************************************
+ * 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. *
+ **************************************************************************/
+
+#include "AliMUONDspHeader.h"
+#include "AliMUONBusStruct.h"
+
+
+///
+/// DSP structure for tracker raw data.
+/// Each block contains at most 5 Dsp structures.
+/// Beside the total length and length of the below data
+/// the header of the Dsp contains the front end DSP id, trigger words
+/// and event word (1 for nb of word is odd and 0 if not
+///
+
+ClassImp(AliMUONDspHeader)
+
+ const Int_t AliMUONDspHeader::fgkHeaderLength = 8;
+
+//___________________________________________
+AliMUONDspHeader::AliMUONDspHeader()
+ : TObject(),
+ fTotalLength(0),
+ fLength(0),
+ fDspId(0),
+ fEventWord(0)
+{
+ //
+ //ctor
+ //
+ for (Int_t i = 0; i < 4; i++)
+ fTriggerWord[i] = 0;
+
+ fBusPatchArray = new TClonesArray("AliMUONBusStruct",5);
+
+}
+
+//___________________________________________
+AliMUONDspHeader::~AliMUONDspHeader()
+{
+ //
+ // dtr
+ //
+ fBusPatchArray->Delete();
+ delete fBusPatchArray;
+}
+
+//___________________________________________
+AliMUONDspHeader::AliMUONDspHeader(const AliMUONDspHeader& event)
+ : TObject(event)
+{
+ //
+ // copy constructor
+ //
+ fTotalLength = event.fTotalLength;
+ fLength = event.fLength;
+ fDspId = event.fDspId;
+ fEventWord = event.fEventWord;
+
+ //ctor
+ for (Int_t i = 0; i < 4; i++)
+ fTriggerWord[i] = event.fTriggerWord[i];
+
+ fBusPatchArray = new TClonesArray("AliMUONBusStruct", 5);
+ for (Int_t index = 0; index < (event.fBusPatchArray)->GetEntriesFast(); index++) {
+ {new ((*fBusPatchArray)[fBusPatchArray->GetEntriesFast()])
+ AliMUONBusStruct(*(AliMUONBusStruct*)(event.fBusPatchArray)->At(index));}
+ }
+ // fBusPatchArray->SetOwner();
+
+}
+
+//___________________________________________
+AliMUONDspHeader& AliMUONDspHeader::operator=(const AliMUONDspHeader& event)
+{
+ //
+ // assignemnt constructor
+ //
+ if (this == &event) return *this;
+
+ fTotalLength = event.fTotalLength;
+ fLength = event.fLength;
+ fDspId = event.fDspId;
+ fEventWord = event.fEventWord;
+
+ //ctor
+ for (Int_t i = 0; i < 4; i++)
+ fTriggerWord[i] = event.fTriggerWord[i];
+
+ fBusPatchArray = new TClonesArray("AliMUONBusStruct", 5);
+ for (Int_t index = 0; index < (event.fBusPatchArray)->GetEntriesFast(); index++) {
+ {new ((*fBusPatchArray)[fBusPatchArray->GetEntriesFast()])
+ AliMUONBusStruct(*(AliMUONBusStruct*)(event.fBusPatchArray)->At(index));}
+ }
+ return *this;
+}
+//___________________________________________
+void AliMUONDspHeader::AddBusPatch(const AliMUONBusStruct& busPatch)
+{
+ //
+ // adding buspatch info
+ // into TClonesArray
+ //
+ TClonesArray &eventArray = *fBusPatchArray;
+ new(eventArray[eventArray.GetEntriesFast()]) AliMUONBusStruct(busPatch);
+}
+//___________________________________________
+void AliMUONDspHeader::Clear(Option_t* )
+{
+ // Clear TClones arrays
+ // instead of deleting
+ //
+ fBusPatchArray->Clear("C");
+
+}
--- /dev/null
+#ifndef ALIMUONDSPHEADER_H
+#define ALIMUONDSPHEADER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/*$Id$*/
+
+/// \ingroup raw
+/// \class AliMUONDspHeader
+/// \brief MUON DSP header for tracker event
+///
+/// \author Christian Finck
+
+#include <TObject.h>
+#include <TClonesArray.h>
+
+class AliMUONBusStruct;
+
+class AliMUONDspHeader : public TObject {
+
+public:
+ AliMUONDspHeader();
+ AliMUONDspHeader(const AliMUONDspHeader& event);
+ AliMUONDspHeader& operator=(const AliMUONDspHeader& event);
+
+ virtual ~AliMUONDspHeader();
+
+ // DSP header
+ Int_t GetTotalLength() const {return fTotalLength;}
+ Int_t GetLength() const {return fLength;}
+ Int_t GetDspId() const {return fDspId;}
+ Int_t GetTriggerWord(Int_t n) const {return fTriggerWord[n];}
+ Int_t GetEventWord() const {return fEventWord;}
+ Int_t GetHeaderLength() const {return fgkHeaderLength;}
+
+ void SetTotalLength(Int_t l) {fTotalLength = l;}
+ void SetLength(Int_t l) {fLength = l;}
+ void SetDspId(Int_t d) {fDspId = d;}
+ void SetTriggerWord(Int_t w, Int_t n) {fTriggerWord[n] = w;}
+ void SetEventWord(Int_t w) {fEventWord = w;}
+
+ Int_t* GetHeader() {return &fTotalLength;}
+
+ void AddBusPatch(const AliMUONBusStruct& busPatch);
+
+ // get TClonesArray
+ TClonesArray* GetBusPatchArray() const {return fBusPatchArray;}
+
+ // get entries
+ Int_t GetBusPatchEntries() const {return fBusPatchArray->GetEntriesFast();}
+
+ // get entry
+ AliMUONBusStruct* GetBusPatchEntry(Int_t i) const {
+ return (AliMUONBusStruct*)fBusPatchArray->At(i);}
+
+ // clear
+ void Clear(Option_t* opt);
+
+ private:
+
+ // Dsp header
+ Int_t fTotalLength; // total length of block structure
+ Int_t fLength; // length of raw data
+ Int_t fDspId; // Dsp id ??
+ Int_t fTriggerWord[4]; // counter trigger word ?
+ Int_t fEventWord; // nb word odd = 1, even = 0
+ static const Int_t fgkHeaderLength; // header length
+
+ TClonesArray* fBusPatchArray; // array of buspatch structure
+
+ ClassDef(AliMUONDspHeader,1) // MUON Dsp header for Tracker event
+};
+#endif