]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Replace remaining STL remnants with TObjArray, and change internal use of AliMpSlatZo...
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Jan 2007 11:28:57 +0000 (11:28 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Jan 2007 11:28:57 +0000 (11:28 +0000)
MUON/mapping/AliMpSlatPadIterator.cxx
MUON/mapping/AliMpSlatPadIterator.h

index 2fd6c6446599d38f4543425383e3b4ad15efc329..4e146f3415bd451199ad8bd2f2b7bda827fa1e74 100644 (file)
 #include "AliMpArea.h"
 #include "AliMpPCB.h"
 #include "AliMpSlat.h"
-#include "AliMpSlatZonePadIterator.h"
-
-#include <algorithm>
-#include <limits>
-#include <cassert>
+#include "AliMpPCBPadIterator.h"
 
 ///
 /// \class AliMpSlatPadIterator
@@ -45,9 +41,6 @@
 ClassImp(AliMpSlatPadIterator)
 /// \endcond
 
-//const Double_t
-//AliMpSlatPadIterator::fgkDmax = std::numeric_limits<Double_t>::max();
-
 //_____________________________________________________________________________
 AliMpSlatPadIterator::AliMpSlatPadIterator()
 : AliMpVPadIterator(),
@@ -74,11 +67,14 @@ fCurrentDelegateIndex(0)
   // Normal ctor.
   // The iteration will occur on the given slat over the specified area.
   //
-  AliDebug(1,Form("this=%p ctor",this));
+  AliDebug(1,Form("this=%p ctor area=(%e,%e,%e,%e)",this,
+                                                                       area.LeftBorder(),area.DownBorder(),
+                  area.RightBorder(),area.UpBorder()));
   if (!Prepare(area)) 
        {
                AliError("Iterator invalidated by improper initialization (e.g. incorrect area given ?)");
        }
+  fDelegates.SetOwner(kTRUE);
 }
 
 //_____________________________________________________________________________
@@ -125,8 +121,7 @@ AliMpSlatPadIterator::Prepare(const AliMpArea& area)
   for ( AliMpSlat::Size_t i = 0; i < fkSlat->GetSize(); ++i )
        {
                const AliMpPCB* pcb = fkSlat->GetPCB(i);
-               AliMpArea pcbArea( TVector2( (pcb->Xmin()+pcb->Xmax())/2.0,fkSlat->DY()),
-                                                                                        TVector2( pcb->DX(), pcb->DY() ) );
+               AliMpArea pcbArea(pcb->Area());
                AliMpArea zone = Intersect(pcbArea,area);
                AliDebug(3,Form("i=%2d zone is %7.2f,%7.2f->%7.2f,%7.2f %d",i,
                                                                                zone.LeftBorder(),zone.DownBorder(),
@@ -134,10 +129,12 @@ AliMpSlatPadIterator::Prepare(const AliMpArea& area)
                                                                                zone.IsValid()));
                if ( zone.IsValid() )
                {
-                       fDelegates.push_back(new AliMpSlatZonePadIterator(fkSlat,zone));
+                       fDelegates.AddLast(new AliMpPCBPadIterator(fkSlat,zone));
                }
        }
-  return !fDelegates.empty();
+  AliDebug(3,Form("Number of delegates = %d",fDelegates.GetEntries()));
+  StdoutToAliDebug(3,fDelegates.Print(););
+  return fDelegates.GetLast()>=0;
 }
 
 //_____________________________________________________________________________
@@ -164,14 +161,14 @@ AliMpSlatPadIterator::First()
   //
   // (Re)starts the iteration.
   //
-  if ( fDelegates.empty() )
+  if ( fDelegates.GetLast() < 0 )
        {
                AliError("Iterator is not valid, as it gets no delegates at all !");
        }
   else
        {
                fCurrentDelegateIndex = 0;
-               fCurrentDelegate = fDelegates[0];
+               fCurrentDelegate = static_cast<AliMpVPadIterator*>(fDelegates.At(0));
                fCurrentDelegate->First();
        }
 }
@@ -183,12 +180,7 @@ AliMpSlatPadIterator::Invalidate()
   //
   // Make the iterator invalid.
   //
-  for ( size_t i = 0; i < fDelegates.size(); ++i )
-       {
-               delete fDelegates[i];
-               fDelegates[i] = 0;
-       }
-  fDelegates.clear();
+  fDelegates.Delete();
   fCurrentDelegate = 0;
   fCurrentDelegateIndex = 0;
 }
@@ -201,7 +193,7 @@ AliMpSlatPadIterator::IsDone() const
   // Returns whether the iteration is ended or not.
   //
   return ( !fCurrentDelegate ||
-                                        ( fCurrentDelegateIndex >= fDelegates.size() && 
+                                        ( fCurrentDelegateIndex > fDelegates.GetLast() && 
                                                 fCurrentDelegate->IsDone() ) );
 }
 
@@ -220,9 +212,9 @@ AliMpSlatPadIterator::Next()
        {
                AliDebug(3,"Moving to next delegate");
                ++fCurrentDelegateIndex;
-               if ( fCurrentDelegateIndex < fDelegates.size() )
+               if ( fCurrentDelegateIndex <= fDelegates.GetLast() )
                {
-                       fCurrentDelegate = fDelegates[fCurrentDelegateIndex];
+                       fCurrentDelegate = static_cast<AliMpVPadIterator*>(fDelegates.At(fCurrentDelegateIndex));
                        fCurrentDelegate->First();
                }
        }
index 5a080238473bae55ec6b7e6ba57098acd274d85f..a02b2cb60a5b93ea56d8b9be4b54e628d68e63bf 100644 (file)
@@ -14,7 +14,7 @@
 #define ALI_MP_SLAT_PAD_ITERATOR_H
 
 #include "AliMpVPadIterator.h"
-#include <vector>
+#include "TObjArray.h"
 
 class AliMpSlat;
 class AliMpArea;
@@ -41,11 +41,11 @@ class AliMpSlatPadIterator : public AliMpVPadIterator
 
  private:
   const AliMpSlat* fkSlat; ///< pointer to the slat being iterated over
-  std::vector<AliMpVPadIterator*> fDelegates; ///< iterators we do use
+  TObjArray fDelegates; ///< iterators we do use (array of AliMpVPadIterator*)
   AliMpVPadIterator* fCurrentDelegate; ///< current iterator
-  UInt_t fCurrentDelegateIndex; ///< current iterator index
+  Int_t fCurrentDelegateIndex; ///< current iterator index
 
-  ClassDef(AliMpSlatPadIterator,1) // Pad iterator for St 345 Slats
+  ClassDef(AliMpSlatPadIterator,2) // Pad iterator for St 345 Slats
 };
 
 #endif