]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding CreateIterator(void) and GetNeighbours() pure virtual methods,
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Feb 2007 15:29:25 +0000 (15:29 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Feb 2007 15:29:25 +0000 (15:29 +0000)
but with some default implementation
(Laurent)

MUON/mapping/AliMpVSegmentation.cxx
MUON/mapping/AliMpVSegmentation.h

index 37cc74e0004f37060a6dd071e55612de01e4fd9a..4b070c3d79d2a75e3200beda2138c14989771f14 100644 (file)
 //
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+//         Laurent Aphecetche, SUBATECH
 
 #include "AliMpVSegmentation.h"
+#include "AliMpArea.h"
 #include "AliMpConstants.h"
 
+#include "AliLog.h"
+
+#include "TVector2.h"
+#include "TObjArray.h"
+
 /// \cond CLASSIMP
 ClassImp(AliMpVSegmentation)
 /// \endcond
@@ -47,9 +54,17 @@ AliMpVSegmentation::~AliMpVSegmentation()
 /// Destructor 
 }
 
-//
-// private methods
-//
+//_____________________________________________________________________________
+AliMpVPadIterator* 
+AliMpVSegmentation::CreateIterator() const
+{
+  /// This is a default implementation, that *might* be used
+  /// by child classes. But if they come up with better options,
+  /// let it be ;-)
+  
+  AliMpArea area(TVector2(0.0,0.0),Dimensions());
+  return CreateIterator(area);
+}
 
 //_____________________________________________________________________________
 AliMpPadPair AliMpVSegmentation::FindPads(const TVector2& position1, 
@@ -66,6 +81,114 @@ AliMpPadPair AliMpVSegmentation::FindPads(const TVector2& position1,
   return AliMpPadPair(pad1, pad2);
 }  
 
+//_____________________________________________________________________________
+Int_t 
+AliMpVSegmentation::GetNeighbours(const AliMpPad& pad, 
+                                  TObjArray& neighbours,
+                                  Bool_t includeSelf,
+                                  Bool_t includeVoid) const
+{
+  /// Returns the list of neighbours of pad
+  static TVector2* testPositions(0x0);
+  static const Int_t kNofTestPositions(11);
+  static const Double_t kEpsilon(AliMpConstants::LengthTolerance()*2.0);
+  static Int_t centerIndex(-1);
+  
+  // testPositions are the positions (L,T,R,B) relative to pad's center (O)
+  // were we'll try to get a neighbouring pad, by getting a little
+  // bit outside the pad itself.
+  // Note that it's not symmetric as we assume that pad density
+  // can always decrease when going from left to right.
+  //
+  // L-T-T-R
+  // |     |
+  // L     |
+  // |  O  R
+  // L     |
+  // |     |
+  // L--B--R
+  //
+  // The order in which we actually test the positions has some importance,
+  // i.e. when using this information to compute status map later on. Here's
+  // the sequence :
+  //
+  // 4-5-6- 7
+  // |      |
+  // 3      |
+  // |  0   8
+  // 2      |
+  // |      |
+  // 1--10--9
+  
+  neighbours.Delete();
+  neighbours.SetOwner(kTRUE);
+  
+  if (!pad.IsValid()) return 0;
+  
+  if (!testPositions)
+  {
+    testPositions = new TVector2[kNofTestPositions];
+    Int_t n(0); 
+    // starting center
+    centerIndex = 0;
+    testPositions[n++] = TVector2(0,0); // O (pad center)
+    // then left column (L), starting from bottom
+    testPositions[n++] = TVector2(-1,-1);
+    testPositions[n++] = TVector2(-1,-1/3.0);
+    testPositions[n++] = TVector2(-1,1/3.0);
+    testPositions[n++] = TVector2(-1,1);
+    // top (T), starting from left
+    testPositions[n++] = TVector2(-1/3.0,1);
+    testPositions[n++] = TVector2(1/3.0,1);
+    // right column (R), starting from top
+    testPositions[n++] = TVector2(1,1);
+    testPositions[n++] = TVector2(1,0);
+    testPositions[n++] = TVector2(1,-1);
+    // bottom (B)
+    testPositions[n++] = TVector2(0,-1);
+    // pad center
+    if ( n != kNofTestPositions ) {
+      AliError("Test on number of test positions failed.");
+    }  
+  }
+  
+  Int_t n(0);
+  
+  AliMpPad previous(AliMpPad::Invalid());
+  
+  for ( Int_t i = 0; i < kNofTestPositions; ++i ) 
+  {
+    if ( i == centerIndex && !includeSelf )
+    {
+      if ( includeVoid ) 
+      {
+        previous = AliMpPad::Invalid();
+        neighbours.Add(new AliMpPad(previous));
+        ++n;
+      }
+      continue;
+    }
+    
+    TVector2 shift = testPositions[i];
+    TVector2 pos = pad.Position();
+    pos += TVector2((pad.Dimensions().X()+kEpsilon)*shift.X(),
+                    (pad.Dimensions().Y()+kEpsilon)*shift.Y());
+
+    
+    AliMpPad p = PadByPosition(pos,kFALSE);
+    
+    if ( !p.IsValid() && !includeVoid ) continue;
+    
+    if ( p != previous || !previous.IsValid() ) 
+    {
+      previous = p;
+      neighbours.Add(new AliMpPad(p));
+      ++n;
+    }
+  }
+  return n;
+}
+
 //
 // public methods
 //
index f51b0780d03507a0632feedfc03718aebbf34160..6ec6a6bfaf4b8a2c136d660dbe8100827aff2643 100644 (file)
@@ -12,7 +12,8 @@
 /// conversion between pad indices, pad location, pad position;
 /// finding pad neighbour.
 ///
-/// \author David Guez, Ivana Hrivnacova; IPN Orsay
+/// \author David Guez, Ivana Hrivnacova, IPN Orsay;
+///         Laurent Aphecetche, SUBATECH
 
 #ifndef ALI_MP_V_SEGMENTATION_H
 #define ALI_MP_V_SEGMENTATION_H
@@ -29,6 +30,7 @@ class AliMpArea;
 
 class TArrayI;
 class TVector2;
+class TObjArray;
 
 class AliMpVSegmentation : public TObject
 {
@@ -36,8 +38,18 @@ class AliMpVSegmentation : public TObject
     AliMpVSegmentation();
     virtual ~AliMpVSegmentation();
   
-    // factory method 
+    // factory methods
+    /// Create a pad iterator over the given area
     virtual AliMpVPadIterator* CreateIterator(const AliMpArea& area) const = 0;
+    
+    /// Create a pad iterator over the whole area
+    virtual AliMpVPadIterator* CreateIterator() const = 0;
+    
+    /** Fills the array with the pads that are neighbours of pad. Returns
+        the number of neighbours. */
+    virtual Int_t GetNeighbours(const AliMpPad& pad, TObjArray& neighbours,
+                                Bool_t includeSelf=kFALSE,
+                                Bool_t includeVoid=kFALSE) const = 0;
 
     // methods  
     virtual AliMpPad PadByLocation(const AliMpIntPair& location,