]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- Corrected copy constructor,
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 5 Apr 2006 08:41:17 +0000 (08:41 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 5 Apr 2006 08:41:17 +0000 (08:41 +0000)
- adding checking of limits for getters
- coding conventions
(Ivana, Christian)

MUON/AliMUONSubEventTracker.cxx
MUON/AliMUONSubEventTracker.h

index 7a1fabedf468555f371dd7891206664d5214ac41..0b9ce8d420be846899cfdb05d25efbf1d6df4b77 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+
+// $Id$
  
 #include "AliMUONSubEventTracker.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)
+///
+
+
 const Int_t AliMUONSubEventTracker::fgkHeaderLength = 4;
 
 ClassImp(AliMUONSubEventTracker)
@@ -28,18 +42,27 @@ AliMUONSubEventTracker::AliMUONSubEventTracker()
      fTriggerWord(0),
      fBufSize(1024)
 {
+  //
   //ctor
+  //
   fData = new UInt_t[fBufSize];
 }
 //___________________________________________
 AliMUONSubEventTracker::~AliMUONSubEventTracker()
 {
+  //
+  // dtor
+  //
   delete[] fData;
 }
 
 //___________________________________________
 void AliMUONSubEventTracker::SetAlloc(Int_t size)
 {
+  //
+  // Allocate size per default 1024;
+  // return if size < 1024
+  //
   if (size < fBufSize) 
     return;
   else 
@@ -60,6 +83,9 @@ void AliMUONSubEventTracker::AddData(UInt_t data)
 //___________________________________________
 void AliMUONSubEventTracker::ResizeData(Int_t size)
 {
+  // In case of resizing the vector
+  // the most simplest way to do it
+  //
   if (size == 0)
     fBufSize *= 2;
   else
@@ -74,10 +100,14 @@ void AliMUONSubEventTracker::ResizeData(Int_t size)
 AliMUONSubEventTracker::
 AliMUONSubEventTracker(const AliMUONSubEventTracker& event): TObject(event)
 {
+  //
+  // copy ctor
+  //
   fTotalLength = event.fTotalLength;
-  fLength = event.fLength;
-  fBusPatchId = event.fBusPatchId;
+  fLength      = event.fLength;
+  fBusPatchId  = event.fBusPatchId;
   fTriggerWord = event.fTriggerWord;
+  fBufSize     = event.fBufSize;
 
   fData =  new UInt_t[event.fBufSize];
   for (int i = 0; i < event.fBufSize; i++)
@@ -87,13 +117,19 @@ AliMUONSubEventTracker(const AliMUONSubEventTracker& event): TObject(event)
 AliMUONSubEventTracker&
 AliMUONSubEventTracker::operator=(const AliMUONSubEventTracker& event)
 {
+  //
+  // assignment operator
+  //
   if (this == &event) return *this;
   fTotalLength = event.fTotalLength;
-  fLength = event.fLength;
-  fBusPatchId = event.fBusPatchId;
+  fLength      = event.fLength;
+  fBusPatchId  = event.fBusPatchId;
   fTriggerWord = event.fTriggerWord;
-  
-  for (int i = 0; i < event.fLength; i++)
+  fBufSize     = event.fBufSize;
+
+  delete [] fData;  
+  fData =  new UInt_t[event.fBufSize];
+  for (int i = 0; i < event.fBufSize; i++)
     fData[i] = event.fData[i];
 
   return *this;
@@ -101,6 +137,70 @@ AliMUONSubEventTracker::operator=(const AliMUONSubEventTracker& event)
 //___________________________________________
 Int_t AliMUONSubEventTracker::Compare(const TObject *obj) const
 {
+  // 
+  // sort bus patch by bus patch number
+  // important for AliMUONRawWriter
+  //
   AliMUONSubEventTracker* event = (AliMUONSubEventTracker*) obj;
   return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
 }
+
+//___________________________________________
+UInt_t  AliMUONSubEventTracker::GetData(Int_t n) const 
+{
+  //
+  // get data
+  //
+  if ( n>=0 && n<fLength ) return fData[n];
+
+  AliError("Index outside limits."); 
+  return 0; 
+}
+
+//___________________________________________
+Char_t   AliMUONSubEventTracker::GetParity(Int_t n) const   
+{
+  //
+  // get pariry
+  //
+  if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 29) &  0x7;
+
+  AliError("Index outside limits."); 
+  return 0; 
+}
+
+//___________________________________________
+UShort_t AliMUONSubEventTracker::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   AliMUONSubEventTracker::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 AliMUONSubEventTracker::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; 
+}
index 5b681f7bd9a30f84f7e122218288904445ec0cb3..48008bc98fb96d5352c696ff2dc568915567c419 100644 (file)
@@ -8,6 +8,15 @@
 /// \ingroup rec
 /// \class AliMUONSubEventTracker
 /// \brief MUON subevent tracker
+///
+/// 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)
+///
+/// \author Christian Finck
 
 #include <TObject.h>
 
@@ -23,19 +32,16 @@ public:
    Int_t   GetLength()      const {return fLength;}
    Int_t   GetBusPatchId()  const {return fBusPatchId;}
    Int_t   GetTriggerWord() const {return fTriggerWord;}
-   UInt_t  GetData(Int_t n) const {return fData[n];}
+   UInt_t  GetData(Int_t n) const;
    UInt_t* GetData()        const {return fData;}
 
-   Char_t   GetParity(Int_t n)    {return (Char_t)(fData[n] >> 29) &  0x7;}
-   UShort_t GetManuId(Int_t n)    {return (UShort_t)(fData[n] >> 18) &  0x7FF;}
-   Char_t   GetChannelId(Int_t n) {return (Char_t)(fData[n] >> 12) & 0x3F;}
-   UShort_t GetCharge(Int_t n)    {return (UShort_t)(fData[n] & 0xFFF);}
+   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;
 
-   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    AddData(UInt_t d);
    void    SetAlloc(Int_t size);