LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpSectorAreaHPadIterator.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 39 67 58.2 %
Date: 2016-06-14 17:26:59 Functions: 12 18 66.7 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : // $Id$
      17             : // $MpId: AliMpSectorAreaHPadIterator.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
      18             : // Category: sector
      19             : 
      20             : //-----------------------------------------------------------------------------
      21             : // Class AliMpSectorAreaHPadIterator
      22             : // ---------------------------------
      23             : // Class, which defines an iterator over the pads 
      24             : // inside a given area in a sector in horizontal direction.
      25             : // Included in AliRoot: 2003/05/02
      26             : // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
      27             : //-----------------------------------------------------------------------------
      28             : 
      29             : #include "AliMpSectorAreaHPadIterator.h"
      30             : #include "AliMpSectorSegmentation.h"
      31             : #include "AliMpConstants.h"
      32             : 
      33             : #include <Riostream.h>
      34             : 
      35             : /// \cond CLASSIMP
      36          18 : ClassImp(AliMpSectorAreaHPadIterator)
      37             : /// \endcond
      38             : 
      39             : //______________________________________________________________________________
      40             : AliMpSectorAreaHPadIterator::AliMpSectorAreaHPadIterator(
      41             :                                 const AliMpSectorSegmentation* segmentation,
      42             :                                 const AliMpArea& area) 
      43          32 :  : AliMpVPadIterator(),
      44          32 :    fkSegmentation(segmentation),
      45          32 :    fkArea(area),
      46          32 :    fCurrentPad(AliMpPad::Invalid()),
      47          32 :    fCurrentRowPosition(0.)
      48         160 : {
      49             : /// Standard constructor, start in invalid position
      50          64 : }
      51             : 
      52             : //______________________________________________________________________________
      53             : AliMpSectorAreaHPadIterator::AliMpSectorAreaHPadIterator(
      54             :                                 const AliMpSectorAreaHPadIterator& right)
      55           0 :   : AliMpVPadIterator(right),
      56           0 :     fkSegmentation(0),
      57           0 :     fkArea(AliMpArea()),
      58           0 :     fCurrentPad(AliMpPad::Invalid()),
      59           0 :     fCurrentRowPosition(0.)
      60           0 : {
      61             : /// Copy constructor
      62             :  
      63           0 :   *this = right;
      64           0 : }
      65             : 
      66             : //______________________________________________________________________________
      67             : AliMpSectorAreaHPadIterator::AliMpSectorAreaHPadIterator()
      68           0 :  : AliMpVPadIterator(),
      69           0 :    fkSegmentation(0),
      70           0 :    fkArea(AliMpArea()),
      71           0 :    fCurrentPad(AliMpPad::Invalid()),
      72           0 :    fCurrentRowPosition(0.)
      73           0 : {
      74             : /// Default constructor.
      75           0 : }
      76             : 
      77             : //______________________________________________________________________________
      78             : AliMpSectorAreaHPadIterator::~AliMpSectorAreaHPadIterator()
      79         192 : {
      80             : /// Destructor
      81          96 : }
      82             : 
      83             : //
      84             : // operators
      85             : //
      86             : 
      87             : //______________________________________________________________________________
      88             : AliMpSectorAreaHPadIterator& 
      89             : AliMpSectorAreaHPadIterator::operator = (const AliMpSectorAreaHPadIterator& right)
      90             : {
      91             : /// Assignment operator
      92             : 
      93             :   // check assignment to self
      94           0 :   if (this == &right) return *this;
      95             : 
      96             :   // base class assignment
      97           0 :   AliMpVPadIterator::operator=(right);
      98             : 
      99           0 :   fkSegmentation = right.fkSegmentation;
     100           0 :   fkArea         = right.fkArea;
     101           0 :   fCurrentPad    = right.fCurrentPad;
     102           0 :   fCurrentRowPosition = right.fCurrentRowPosition;
     103             : 
     104           0 :   return *this;
     105           0 : } 
     106             : 
     107             : // 
     108             : // private methods
     109             : //
     110             : 
     111             : //______________________________________________________________________________
     112             : Bool_t AliMpSectorAreaHPadIterator::IsValid() const
     113             : {
     114             : /// Is the iterator in a valid position?
     115             : 
     116        4440 :   return fCurrentPad.IsValid() ;
     117             : }
     118             : 
     119             : //______________________________________________________________________________
     120             : void AliMpSectorAreaHPadIterator::MoveUp()
     121             : {
     122             : /// Increase the current row position and searches the first valid pad.
     123             : 
     124         580 :   Double_t dy = fkSegmentation->GetMinPadDimensionY();
     125             : 
     126        1290 :   while ( ! fCurrentPad.IsValid() && 
     127         258 :             fCurrentRowPosition + dy < fkArea.UpBorder() )
     128             :   {
     129         226 :     fCurrentRowPosition += 2.*dy;
     130             :     
     131         226 :     fCurrentPad 
     132         452 :       = fkSegmentation->PadByDirection(fkArea.LeftBorder(), fCurrentRowPosition, 
     133         226 :                                        fkArea.RightBorder());
     134             :   } 
     135         290 : }
     136             : 
     137             : //
     138             : // public methods
     139             : //
     140             : 
     141             : //______________________________________________________________________________
     142             : void AliMpSectorAreaHPadIterator::First()
     143             : {
     144             : /// Reset the iterator, so that it points to the first available
     145             : /// pad in the area
     146             : 
     147          64 :   if ( ! fkSegmentation ) {
     148           0 :     Fatal("First", "Segmentation is not defined");
     149           0 :     return;
     150             :   }  
     151             : 
     152             :   // Start position = left down corner of the area
     153             :   //
     154             :   
     155          32 :   fCurrentRowPosition = fkArea.DownBorder();
     156             :    
     157          32 :   Double_t posx, posy;
     158          32 :   fkArea.LeftDownCorner(posx, posy); 
     159             : 
     160          64 :   fCurrentPad = fkSegmentation->PadByDirection(posx, posy, fkArea.RightBorder());
     161             : 
     162          32 :   MoveUp();
     163             :   
     164             :   // Set the row position to the center of pad
     165             :   //
     166          64 :   if (fCurrentPad.IsValid()) fCurrentRowPosition = fCurrentPad.GetPositionY();
     167          64 : }
     168             : 
     169             : //______________________________________________________________________________
     170             : void AliMpSectorAreaHPadIterator::Next()
     171             : {
     172             : /// Move the iterator to the next valid pad.
     173             : 
     174        2156 :   if ( ! IsValid() ) return;
     175             :   
     176             :   // Start position = right board of current pad + little step
     177             : 
     178        2156 :   fCurrentPad 
     179        2156 :     = fkSegmentation->PadByDirection(
     180        2156 :         fCurrentPad.GetPositionX() + fCurrentPad.GetDimensionX() + 
     181        1078 :           AliMpConstants::LengthStep(), 
     182        1078 :         fCurrentPad.GetPositionY(), 
     183        1078 :         fkArea.RightBorder());  
     184             : 
     185        1078 :   if ( fCurrentPad.IsValid() ) return;
     186             : 
     187         258 :   MoveUp();
     188        1336 : }
     189             : 
     190             : //______________________________________________________________________________
     191             : Bool_t AliMpSectorAreaHPadIterator::IsDone() const
     192             : {
     193             : /// Is the iterator in the end ?
     194             :  
     195        2284 :   return !IsValid();
     196             : }
     197             : 
     198             : //______________________________________________________________________________
     199             : AliMpPad AliMpSectorAreaHPadIterator::CurrentItem () const 
     200             : {
     201             : /// Return current pad.
     202             : 
     203        2156 :   return fCurrentPad;
     204             : }
     205             : //______________________________________________________________________________
     206             : void AliMpSectorAreaHPadIterator::Invalidate()
     207             : {
     208             : /// Let the iterator point to the invalid position
     209             : 
     210           0 :   fCurrentPad = AliMpPad::Invalid();
     211           0 :   fCurrentRowPosition = 0;
     212           0 : }
     213             : 
     214             : 
     215             : 

Generated by: LCOV version 1.11