]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONBusStruct.cxx
Fix histo name
[u/mrichter/AliRoot.git] / MUON / AliMUONBusStruct.cxx
index 6198bd4f30dc2a1bf065814f98211267c79ae75b..2ed5c2ef1ac9a277733368a1dd175ceabf20f0c0 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+
+/* $Id$ */
+
 #include "AliMUONBusStruct.h"
-#include "AliLog.h"
 
+#include "AliLog.h"
+#include <Riostream.h>
+#include <string.h>
 
-/// 
+//-----------------------------------------------------------------------------
+/// \class AliMUONBusStruct
 /// 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
 /// and data structure itself (11bits for manu id, 6 bits for channel id and
 /// 12 bits for charge)
 ///
+/// \author Christian Finck
+//-----------------------------------------------------------------------------
 
-
+/// \cond CLASSIMP
 ClassImp(AliMUONBusStruct)
+/// \endcond
 
- const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
+const Int_t  AliMUONBusStruct::fgkHeaderLength = 4;
+const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B;
+const Int_t  AliMUONBusStruct::fgkManuNofChannels(64);
 
 //___________________________________________
 AliMUONBusStruct::AliMUONBusStruct()
   :  TObject(),
+     fDataKey(0),
      fTotalLength(0),
      fLength(0),
      fBusPatchId(0),
-     fTriggerWord(0),
-     fBufSize(1024),
+fBufSize(43*fgkManuNofChannels), 
+  /* assuming 43 manus max per bustpatch.
+  Anyway fData is resized where needed (though it makes it slower) */
+     fData(new UInt_t[fBufSize]),
      fDspId(0),
      fBlkId(0)
 {
-  //
-  // ctor
-  // 
-  fData = new UInt_t[fBufSize];
+  ///
+  /// ctor
+  /// 
+
 }
 //___________________________________________
 AliMUONBusStruct::~AliMUONBusStruct()
 {
-  //
-  // dtor
-  //
+  ///
+  /// dtor
+  ///
   delete[] fData;
 }
 
 //___________________________________________
 void AliMUONBusStruct::SetAlloc(Int_t size)
 {
-  //
-  // Allocate size per default 1024;
-  // return if size < 1024
-  //
+  ///
+  /// Allocate size 
+  /// return if size < fBufSize 
+  ///
   if (size < fBufSize) 
     return;
   else 
@@ -71,9 +84,9 @@ void AliMUONBusStruct::SetAlloc(Int_t 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 ?
+  /// 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;
@@ -83,9 +96,9 @@ void AliMUONBusStruct::AddData(UInt_t data)
 //___________________________________________
 void AliMUONBusStruct::ResizeData(Int_t size)
 {
-  // In case of resizing the vector
-  // the most simplest way to do it
-  //
+  /// In case of resizing the vector
+  /// the most simplest way to do it
+  ///
   if (size == 0)
     fBufSize *= 2;
   else
@@ -98,21 +111,21 @@ void AliMUONBusStruct::ResizeData(Int_t size)
 }
 //___________________________________________
 AliMUONBusStruct::
-AliMUONBusStruct(const AliMUONBusStruct& event): TObject(event)
+AliMUONBusStruct(const AliMUONBusStruct& event)
+  : TObject(event),
+    fDataKey(event.fDataKey),
+    fTotalLength(event.fTotalLength),
+    fLength(event.fLength),
+    fBusPatchId(event.fBusPatchId),
+    fBufSize(event.fBufSize),
+    fData(new UInt_t[event.fBufSize]),
+    fDspId(event.fDspId),
+    fBlkId(event.fBlkId)
 {
-  //
-  // copy ctor
-  //
-  fTotalLength = event.fTotalLength;
-  fLength      = event.fLength;
-  fBusPatchId  = event.fBusPatchId;
-  fTriggerWord = event.fTriggerWord;
-  fBufSize     = event.fBufSize;
+  ///
+  /// copy ctor
+  ///
 
-  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];
 }
@@ -120,14 +133,14 @@ AliMUONBusStruct(const AliMUONBusStruct& event): TObject(event)
 AliMUONBusStruct&
 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
 {
-  //
-  // assignment operator
-  //
+  ///
+  /// assignment operator
+  ///
   if (this == &event) return *this;
+  fDataKey     = event.fDataKey;
   fTotalLength = event.fTotalLength;
   fLength      = event.fLength;
   fBusPatchId  = event.fBusPatchId;
-  fTriggerWord = event.fTriggerWord;
   fBufSize     = event.fBufSize;
 
   fBlkId = event.fBlkId;
@@ -143,10 +156,10 @@ AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
 //___________________________________________
 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
 {
-  // 
-  // sort bus patch by bus patch number
-  // important for AliMUONRawWriter
-  //
+  /// 
+  /// sort bus patch by bus patch number
+  /// important for AliMUONRawWriter
+  ///
   AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
   return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
 }
@@ -154,18 +167,17 @@ Int_t AliMUONBusStruct::Compare(const TObject *obj) const
 //___________________________________________
 void AliMUONBusStruct::Clear(Option_t *)
 {
-  // clear
-  // delete the allocated memory 
-  //
-
+  /// clear
+  /// delete the allocated memory 
+  ///
   delete[] fData;
 }
 //___________________________________________
 UInt_t AliMUONBusStruct::GetData(Int_t n) const 
 {
-  //
-  // get data
-  //
+  ///
+  /// get data
+  ///
   if ( n>=0 && n<fLength ) return fData[n];
 
   AliError("Index outside limits."); 
@@ -175,10 +187,10 @@ UInt_t AliMUONBusStruct::GetData(Int_t n) const
 //___________________________________________
 Char_t AliMUONBusStruct::GetParity(Int_t n) const   
 {
-  //
-  // get parity
-  //
-  if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 29) &  0x7;
+  ///
+  /// get parity
+  ///
+  if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) &  0x1;
 
   AliError("Index outside limits."); 
   return 0; 
@@ -187,9 +199,9 @@ Char_t AliMUONBusStruct::GetParity(Int_t n) const
 //___________________________________________
 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const     
 {
-  //
-  // get manu Id
-  //
+  ///
+  /// get manu Id
+  ///
   if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) &  0x7FF;
 
   AliError("Index outside limits."); 
@@ -197,11 +209,11 @@ UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
 }
 
 //___________________________________________
-Char_t AliMUONBusStruct::GetChannelId(Int_t n) const  
+UChar_t AliMUONBusStruct::GetChannelId(Int_t n) const  
 {
-  // 
-  // get channel Id
-  //
+  /// 
+  /// get channel Id
+  ///
   if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
 
   AliError("Index outside limits."); 
@@ -211,11 +223,31 @@ Char_t AliMUONBusStruct::GetChannelId(Int_t n) const
 //___________________________________________
 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const     
 {
-  //
-  // get charge (in ADC)
-  //
+  ///
+  /// get charge (in ADC)
+  ///
   if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
 
   AliError("Index outside limits."); 
   return 0; 
 }
+
+//___________________________________________
+void AliMUONBusStruct::Print(Option_t* opt) const
+{
+  /// print out
+
+  cout << "Bus patch info" << endl;
+  cout << "DataKey: "      << fDataKey << endl;
+  cout << "fTotalLength: " << fTotalLength << endl;
+  cout << "fLength: "      << fLength << endl;
+  cout << "fBusPatchId: "  << fBusPatchId << endl;
+  cout << "fBufSize: "     << fBufSize << endl;
+
+  if (strstr(opt, "all")) {
+  for (Int_t i = 0; i <fLength; ++i)
+      cout << "Data["<< i << "] = " << fData[i] << endl;
+  }
+}
+
+