Implementation of TIterator for DigitStoreV1 (Laurent)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 17 Jun 2007 20:30:31 +0000 (20:30 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 17 Jun 2007 20:30:31 +0000 (20:30 +0000)
MUON/AliMUONDigitStoreV1Iterator.cxx [new file with mode: 0644]
MUON/AliMUONDigitStoreV1Iterator.h [new file with mode: 0644]

diff --git a/MUON/AliMUONDigitStoreV1Iterator.cxx b/MUON/AliMUONDigitStoreV1Iterator.cxx
new file mode 100644 (file)
index 0000000..70d940e
--- /dev/null
@@ -0,0 +1,132 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+
+// $Id$
+
+/// \class AliMUONDigitStoreV1Iterator
+///
+/// Implementation of TIteraor for AliMUONVDigitStoreV1
+/// Reuses the AliMUONTOTCAStoreIterator iterator
+///
+/// \author Laurent Aphecetche, Subatech
+
+#include "AliMUONDigitStoreV1Iterator.h"
+
+#include "AliMpDEManager.h"
+#include "AliMUONVDigit.h"
+
+/// \cond CLASSIMP
+ClassImp(AliMUONDigitStoreV1Iterator)
+/// \endcond
+
+//_____________________________________________________________________________
+AliMUONDigitStoreV1Iterator::AliMUONDigitStoreV1Iterator(TObjArray* a,
+                                                         Int_t firstDetElemId,
+                                                         Int_t lastDetElemId,
+                                                         Int_t cathode)
+: AliMUONTOTCAStoreIterator(a,AliMpDEManager::GetChamberId(firstDetElemId),
+                            AliMpDEManager::GetChamberId(lastDetElemId)),
+fArray(a),
+fFirstDetElemId(firstDetElemId),
+fLastDetElemId(lastDetElemId),
+fCathode(cathode)
+{
+  /// ctor
+}
+
+//_____________________________________________________________________________
+AliMUONDigitStoreV1Iterator::AliMUONDigitStoreV1Iterator(const AliMUONDigitStoreV1Iterator& rhs)
+: AliMUONTOTCAStoreIterator(rhs),
+  fArray(rhs.fArray),
+  fFirstDetElemId(rhs.fFirstDetElemId),
+  fLastDetElemId(rhs.fLastDetElemId),
+  fCathode(rhs.fCathode)
+{
+    /// copy ctor
+}
+
+//_____________________________________________________________________________
+TIterator& 
+AliMUONDigitStoreV1Iterator::operator=(const TIterator& rhs)
+{
+  /// overriden assignment operator (imposed by Root's definition of TIterator ?)
+  if ( this != &rhs && rhs.IsA() == AliMUONDigitStoreV1Iterator::Class()) 
+  {
+    const AliMUONDigitStoreV1Iterator& rhs1 = 
+    static_cast<const AliMUONDigitStoreV1Iterator&>(rhs);
+    
+    fArray = rhs1.fArray;
+    fFirstDetElemId = rhs1.fFirstDetElemId;
+    fLastDetElemId = rhs1.fLastDetElemId;
+    fCathode = rhs1.fCathode;
+  }
+  return *this;
+}
+
+//_____________________________________________________________________________
+AliMUONDigitStoreV1Iterator& 
+AliMUONDigitStoreV1Iterator::operator=(const AliMUONDigitStoreV1Iterator& rhs)
+{
+  /// assignement operator
+  if ( this != &rhs ) 
+  {
+    fArray = rhs.fArray;
+    fFirstDetElemId = rhs.fFirstDetElemId;
+    fLastDetElemId = rhs.fLastDetElemId;
+    fCathode = rhs.fCathode;
+  }
+  return *this;
+}
+
+//_____________________________________________________________________________
+AliMUONDigitStoreV1Iterator::~AliMUONDigitStoreV1Iterator()
+{
+  /// dtor
+}
+
+//_____________________________________________________________________________
+const TCollection* 
+AliMUONDigitStoreV1Iterator::GetCollection() const
+{
+  /// Return the TObjArray we're iterating upon
+  return fArray;
+}
+
+//_____________________________________________________________________________
+TObject*
+AliMUONDigitStoreV1Iterator::Next()
+{
+  /// Return the next digit (with its DE in [fFirstDetElemId,fLastDetElemId],
+  /// and its cathode == fCathode (or any cathode if fCathode==2)
+  /// in the store.
+  
+  TObject* object = 0x0;
+  
+  while ( (object = static_cast<AliMUONVDigit*>(AliMUONTOTCAStoreIterator::Next()) ) )
+  {  
+    AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(object);
+
+    if ( digit->DetElemId() >= fFirstDetElemId &&
+         digit->DetElemId() <= fLastDetElemId ) 
+    {
+      if ( fCathode == 2 || digit->Cathode() == fCathode ) 
+      {
+        return digit;
+      }
+    }
+  }
+  
+  return 0x0;
+}
diff --git a/MUON/AliMUONDigitStoreV1Iterator.h b/MUON/AliMUONDigitStoreV1Iterator.h
new file mode 100644 (file)
index 0000000..11edff9
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef ALIMUONDIGITSTOREV1ITERATOR_H
+#define ALIMUONDIGITSTOREV1ITERATOR_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+/// \ingroup base
+/// \class AliMUONDigitStoreV1Iterator
+///
+/// \brief Implementation of TIterator for AliMUONDigitStoreV1
+/// 
+// Author Laurent Aphecetche
+
+#ifndef ALIMUONTOTCASTOREITERATOR_H
+#  include "AliMUONTOTCAStoreIterator.h"
+#endif
+
+class AliMUONDigitStoreV1Iterator : public AliMUONTOTCAStoreIterator
+{
+public:
+  AliMUONDigitStoreV1Iterator(const AliMUONDigitStoreV1Iterator& rhs);
+  TIterator& operator=(const TIterator& rhs);
+  AliMUONDigitStoreV1Iterator& operator=(const AliMUONDigitStoreV1Iterator& rhs);
+  AliMUONDigitStoreV1Iterator(TObjArray* a,
+                              Int_t firstDetElemId,
+                              Int_t lastDetElemId,
+                              Int_t cathode=2);
+  
+  virtual ~AliMUONDigitStoreV1Iterator();
+  
+  virtual TObject* Next();
+
+  virtual const TCollection* GetCollection() const;
+  
+private:
+  TObjArray* fArray; ///< array we iterate upon
+  Int_t fFirstDetElemId; ///< first detection element to iterate upon
+  Int_t fLastDetElemId; ///< last detection element to iterate upon
+  Int_t fCathode; ///< cathode to iterate upon
+  
+  ClassDef(AliMUONDigitStoreV1Iterator,1) // Implementation of TIterator
+};
+
+#endif