From 1964cd2ef81e244bbad56e8c02ff9dc25de35970 Mon Sep 17 00:00:00 2001 From: martinez Date: Fri, 4 Nov 2005 12:36:45 +0000 Subject: [PATCH] Presenting to the outside world a (x,y) reference located at the center of the slat, and not on the lower-left (which is BTW still used as the implementation of AliMpSlat) (Laurent) --- MUON/mapping/AliMpSlatPadIterator.h | 1 + MUON/mapping/AliMpSlatSegmentation.cxx | 24 +++++++++--- MUON/mapping/AliMpSlatSegmentation.h | 5 +++ MUON/mapping/AliMpSlatZonePadIterator.cxx | 46 ++++++++++++++--------- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/MUON/mapping/AliMpSlatPadIterator.h b/MUON/mapping/AliMpSlatPadIterator.h index b5911fbacc2..ddf8dddb03e 100644 --- a/MUON/mapping/AliMpSlatPadIterator.h +++ b/MUON/mapping/AliMpSlatPadIterator.h @@ -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(); diff --git a/MUON/mapping/AliMpSlatSegmentation.cxx b/MUON/mapping/AliMpSlatSegmentation.cxx index f67109aa721..a6acbfca630 100644 --- a/MUON/mapping/AliMpSlatSegmentation.cxx +++ b/MUON/mapping/AliMpSlatSegmentation.cxx @@ -16,9 +16,16 @@ // $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); diff --git a/MUON/mapping/AliMpSlatSegmentation.h b/MUON/mapping/AliMpSlatSegmentation.h index c748d394ef3..b73ae74aeee 100644 --- a/MUON/mapping/AliMpSlatSegmentation.h +++ b/MUON/mapping/AliMpSlatSegmentation.h @@ -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 diff --git a/MUON/mapping/AliMpSlatZonePadIterator.cxx b/MUON/mapping/AliMpSlatZonePadIterator.cxx index a906f560c56..4be00663d35 100644 --- a/MUON/mapping/AliMpSlatZonePadIterator.cxx +++ b/MUON/mapping/AliMpSlatZonePadIterator.cxx @@ -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())); + } } -- 2.39.3