]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Presenting to the outside world a (x,y) reference located at the center of the slat...
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 Nov 2005 12:36:45 +0000 (12:36 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 Nov 2005 12:36:45 +0000 (12:36 +0000)
MUON/mapping/AliMpSlatPadIterator.h
MUON/mapping/AliMpSlatSegmentation.cxx
MUON/mapping/AliMpSlatSegmentation.h
MUON/mapping/AliMpSlatZonePadIterator.cxx

index b5911fbacc2351bb36d8560b084524177e3c438d..ddf8dddb03e1f6652460ca32748de45b07cd73a5 100644 (file)
@@ -23,6 +23,7 @@ class AliMpSlatPadIterator : public AliMpVPadIterator
 {
  public:
   AliMpSlatPadIterator(); 
+  // Area position must be relative to bottom-left of slat.
   AliMpSlatPadIterator(const AliMpSlat* slat, const AliMpArea& area);
   virtual ~AliMpSlatPadIterator();
 
index f67109aa72117b1a3980807a025b9d8fca735822..a6acbfca6308cdc3451ecba4c8a2c9b9f3bafe1a 100644 (file)
 // $Id$
 // $MpId: AliMpSlatSegmentation.cxx,v 1.5 2005/10/28 15:26:01 ivana Exp $
 
+// Caution !!
+// Implementation note.
+// The position(s) used in the interface are supposed to be relative
+// to the slat center (AliMpSlat::Position()), whereas internally
+// the x,y are relative to bottom-left corner.
+
 #include "AliMpSlatSegmentation.h"
 
 #include "AliLog.h"
+#include "AliMpArea.h"
 #include "AliMpConnection.h"
 #include "AliMpMotif.h"
 #include "AliMpMotifPosition.h"
@@ -68,8 +75,8 @@ AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
   //
   // Returns an iterator to loop over the pad contained within given area.
   //
-  
-  return new AliMpSlatPadIterator(fkSlat,area);
+  AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions());
+  return new AliMpSlatPadIterator(fkSlat,a);
 }
 
 //_____________________________________________________________________________
@@ -232,21 +239,26 @@ AliMpSlatSegmentation::PadByPosition(const TVector2& position,
   // AliMpPad::Invalid() is returned if there's no pad at the given location.
   //
   
-  AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(position.X(),position.Y());
+  TVector2 blPos(position+fkSlat->Position()); // position relative to 
+  // bottom-left of the slat.
+  
+  AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
        
   if (!motifPos)
        {
                if (warning) 
                {
-                       AliWarning(Form("Slat %s Position (%e,%e) mm outside limits",
-                      fkSlat->GetID(),position.X(),position.Y()));
+                       AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
+                      " outside limits",fkSlat->GetID(),
+                      position.X(),position.Y(),
+                      blPos.X(),blPos.Y()));
                }
                return AliMpPad::Invalid();
        }
        
   AliMpVMotif* motif =  motifPos->GetMotif();  
   AliMpIntPair localIndices 
-    = motif->PadIndicesLocal(position-motifPos->Position());
+    = motif->PadIndicesLocal(blPos-motifPos->Position());
        
   AliMpConnection* connect = 
     motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
index c748d394ef38e233f6a3fb24fc23e3a87290affd..b73ae74aeee93f97ae5bd7a22417adc0742bc28a 100644 (file)
@@ -8,6 +8,11 @@
 /// \class AliMpSlatSegmentation
 /// \brief Implementation of AliMpVSegmentation for St345 slats.
 /// 
+/// Note that integer indices start at (0,0) on the bottom-left of the slat,
+/// while floating point positions are relative to the center of the slat
+/// (where the slat is to be understood as N PCBs of fixed size = 40cm
+/// even if not all pads of a given PCBs are actually physically there).
+///
 /// Author: Laurent Aphecetche
 
 #ifndef ALI_MP_SLAT_SEGMENTATION_H
index a906f560c5678a574d6a9dc918f62fad191d1ccf..4be00663d351ca94e020360283f4d81100cf713a 100644 (file)
@@ -113,7 +113,8 @@ AliMpSlatZonePadIterator::CropArea()
   // and (xmax,ymax).
 
   AliMpPad bottomLeft 
-    = fSlatSegmentation->PadByPosition(TVector2(xmin,ymin),kFALSE);
+    = fSlatSegmentation->PadByPosition(TVector2(xmin,ymin)-fkSlat->Position(),
+                                       kFALSE);
   if ( bottomLeft.IsValid() )
     {
       xmin = std::min(xmin,fkSlat->DX() + 
@@ -123,7 +124,8 @@ AliMpSlatZonePadIterator::CropArea()
     }
 
   AliMpPad topRight 
-    = fSlatSegmentation->PadByPosition(TVector2(xmax,ymax),kFALSE);
+    = fSlatSegmentation->PadByPosition(TVector2(xmax,ymax)-fkSlat->Position(),
+                                       kFALSE);
   if ( topRight.IsValid() )
     {
       xmax = std::max(xmax,fkSlat->DX() + 
@@ -172,7 +174,7 @@ AliMpSlatZonePadIterator::GetNextPosition(Double_t& x, Double_t& y)
 
   if ( x > fArea.Dimensions().X() ) 
     {
-      AliDebug(3,"Going back left");
+      AliDebug(3,"Going back left and one step upper");
       // Go back leftmost position...
       x = -1.0*fArea.Dimensions().X();
       // ... and up
@@ -180,9 +182,9 @@ AliMpSlatZonePadIterator::GetNextPosition(Double_t& x, Double_t& y)
       // Update y offset
       fOffset.Set(fOffset.X(),y);
       if ( y > fArea.Dimensions().Y() )
-       {
-         return false;
-       }
+      {
+        return false;
+      }
     }
   AliDebug(3,Form("output (x,y)=(%7.2f,%7.2f",x,y));
   return true;
@@ -205,7 +207,13 @@ AliMpSlatZonePadIterator::First()
     {
       // did not find any valid pad in there, bailing out.
       fIsDone = kTRUE;
-      AliError("Could not initiate iterator. Please check the area you gave.");
+      AliError(Form("Could not initiate iterator for slat %s. "
+                    " Please check the area you gave : %e,%e +- %e,%e",
+                    fkSlat->GetName(),
+                    fArea.Position().X(),
+                    fArea.Position().Y(),
+                    fArea.Dimensions().X(),
+                    fArea.Dimensions().Y()));
       return;
     }
   else
@@ -270,15 +278,15 @@ AliMpSlatZonePadIterator::Next()
   Double_t y(fOffset.Y());
 
   while ( ( pad == fCurrentPad || !pad.IsValid() ) && n<100 )
+  {
+    ++n;
+    if (GetNextPosition(x,y)==kFALSE) 
     {
-      ++n;
-      if (GetNextPosition(x,y)==kFALSE) 
-       {
-         Invalidate();
-         return;
-       } 
-      SetPad(pad,fArea.Position()+TVector2(x,y));
-    }
+      Invalidate();
+      return;
+    } 
+    SetPad(pad,fArea.Position()+TVector2(x,y));
+  }
   fCurrentPad = pad;
 }
 
@@ -289,11 +297,15 @@ AliMpSlatZonePadIterator::SetPad(AliMpPad& pad, const TVector2& pos)
   //
   // Sets the current pad.
   //
-  pad = fSlatSegmentation->PadByPosition(pos,kFALSE);
+  pad = fSlatSegmentation->PadByPosition(pos-fkSlat->Position(),kFALSE);
   if ( pad.IsValid() )
     {
       // Reposition fOffset to pad center (only in x-direction).
       fOffset.Set(pad.Position().X()+fkSlat->DX()-fArea.Position().X(),
-                 fOffset.Y());
+                  fOffset.Y());
     }
+  else
+  {
+    AliDebug(3,Form("No pad at pos=%e,%e",pos.X(),pos.Y()));
+  }
 }