container for TOF raw data
authorarcelli <arcelli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 27 Apr 2007 11:03:13 +0000 (11:03 +0000)
committerarcelli <arcelli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 27 Apr 2007 11:03:13 +0000 (11:03 +0000)
TOF/AliTOFHitDataBuffer.cxx [new file with mode: 0644]
TOF/AliTOFHitDataBuffer.h [new file with mode: 0644]

diff --git a/TOF/AliTOFHitDataBuffer.cxx b/TOF/AliTOFHitDataBuffer.cxx
new file mode 100644 (file)
index 0000000..1edefe3
--- /dev/null
@@ -0,0 +1,86 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*
+$Log$
+ authors: Roberto Preghenella, preghenella@bo.infn.it
+          with contribution from Chiara Zampolli, zampolli@bo.infn.it 
+*/
+
+
+////////////////////////////////////////////////////////////////////////
+//                                                                    //
+//     This class provides access to TOF raw data in DDL files.       //
+//                                                                    //
+//      It loops over all TOF raw data given by the AliRawReader.     //
+//                                                                    //
+////////////////////////////////////////////////////////////////////////
+
+#include <stdlib.h>
+#include "AliTOFHitDataBuffer.h"
+
+ClassImp(AliTOFHitDataBuffer)
+
+AliTOFHitDataBuffer::AliTOFHitDataBuffer(Int_t BufferSize = 1000) :
+  TObject(),
+  fBufferSize(BufferSize),
+  fBuffer(0x0),
+  fEntries(0)
+{
+  fBuffer = new AliTOFHitData[BufferSize];
+}
+//-----------------------------------------------------------------------------
+AliTOFHitDataBuffer::AliTOFHitDataBuffer(const AliTOFHitDataBuffer &source):
+  TObject(),
+  fBufferSize(0),
+  fBuffer(0x0),
+  fEntries(source.fEntries)
+{
+  // copy ctr
+  this->fBufferSize = source.fBufferSize;
+  this->fBuffer = new AliTOFHitData[this->fBufferSize];
+  this->fEntries = source.fEntries;
+  for (Int_t i = 0; i < this->fEntries; i++)
+    this->fBuffer[i] = source.fBuffer[i];
+}
+
+//-----------------------------------------------------------------------------
+AliTOFHitDataBuffer& AliTOFHitDataBuffer::operator=(const AliTOFHitDataBuffer & source) 
+{ 
+  // ass operator
+  this->fEntries = source.fEntries < this->fBufferSize ? source.fEntries : this->fBufferSize;
+  for (Int_t i = 0; i < this->fEntries; i++)
+    this->fBuffer[i] = source.fBuffer[i];
+  return *this;
+}
+
+//-----------------------------------------------------------------------------
+AliTOFHitDataBuffer::~AliTOFHitDataBuffer()
+{
+  delete [] fBuffer;
+}
+
+//-----------------------------------------------------------------------------
+Bool_t AliTOFHitDataBuffer::Add(AliTOFHitData &HitData) {
+  // adding a new entry 
+  if (fEntries >= fBufferSize){
+    printf("buffer limit: current entries = %d\n", fEntries);
+    return kTRUE;
+  }
+  fBuffer[fEntries++] = HitData;
+  return kFALSE;
+}
+
+
diff --git a/TOF/AliTOFHitDataBuffer.h b/TOF/AliTOFHitDataBuffer.h
new file mode 100644 (file)
index 0000000..79165ba
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef ALITOFHITDATABUFFER_H
+#define ALITOFHITDATABUFFER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+///////////////////////////////////////////////////////////////
+//                                                           //
+//   This class provides the key-reading for TOF raw data.   //
+//                                                           //
+///////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+#include "AliTOFHitData.h"
+
+class AliTOFHitDataBuffer : public TObject{
+  
+ public:
+
+  AliTOFHitDataBuffer(Int_t BufferSize);
+  ~AliTOFHitDataBuffer();  
+  AliTOFHitDataBuffer(const AliTOFHitDataBuffer &source);
+  AliTOFHitDataBuffer& operator=(const AliTOFHitDataBuffer & source); 
+  void           Reset() {fEntries = 0;};
+  Bool_t         Add(AliTOFHitData &HitData);
+  
+  AliTOFHitData *GetBuffer() {return fBuffer;};
+  AliTOFHitData *GetHit(Int_t Hit) const {return (Hit < fBufferSize ? &fBuffer[Hit] : 0x0);};
+  Int_t          GetEntries() const {return fEntries;};
+  
+ private:
+  Int_t          fBufferSize; // buffer size
+  AliTOFHitData *fBuffer;     // buffer
+  Int_t          fEntries;    // entries
+
+  ClassDef(AliTOFHitDataBuffer, 1);
+};
+
+#endif
+