LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpRowSegmentLSpecial.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 74 88 84.1 %
Date: 2016-06-14 17:26:59 Functions: 13 17 76.5 %

          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: AliMpRowSegmentLSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
      18             : // Category: sector
      19             : 
      20             : //-----------------------------------------------------------------------------
      21             : // Class AliMpRowSegmentLSpecial
      22             : // -----------------------------
      23             : // Class describing a special inner row segment composed of the 
      24             : // pad rows.
      25             : // Included in AliRoot: 2003/05/02
      26             : // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
      27             : //-----------------------------------------------------------------------------
      28             : 
      29             : #include <Riostream.h>
      30             : #include <TMath.h>
      31             : 
      32             : #include "AliMpRowSegmentLSpecial.h"
      33             : #include "AliMpRow.h"
      34             : #include "AliMpPadRow.h"
      35             : #include "AliMpVPadRowSegment.h"
      36             : #include "AliMpMotif.h"
      37             : #include "AliMpMotifType.h"
      38             : #include "AliMpMotifMap.h"
      39             : #include "AliMpMotifPosition.h"
      40             : #include "AliMpConstants.h"
      41             : #include "AliMpEncodePair.h"
      42             : 
      43             : #include "AliLog.h"
      44             : 
      45             : using std::endl;
      46             : /// \cond CLASSIMP
      47          18 : ClassImp(AliMpRowSegmentLSpecial)
      48             : /// \endcond
      49             : 
      50             : //______________________________________________________________________________
      51             : AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
      52          36 :   : AliMpVRowSegmentSpecial(row, offsetX)
      53         180 : {
      54             : /// Standard constructor
      55          72 : }
      56             : 
      57             : //______________________________________________________________________________
      58             : AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial() 
      59           0 :   : AliMpVRowSegmentSpecial()
      60           0 : {
      61             : /// Default constructor
      62           0 : }
      63             : 
      64             : //______________________________________________________________________________
      65             : AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial() 
      66          96 : {
      67             : /// Destructor  
      68          96 : }
      69             : 
      70             : //
      71             : // private methods  
      72             : //
      73             : 
      74             : //______________________________________________________________________________
      75             : AliMpVPadRowSegment*  
      76             : AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
      77             : {
      78             : /// Find the most right pad row segment with this motifPositionId.
      79             : 
      80             :   AliMpVPadRowSegment* found = 0;
      81             : 
      82        2880 :   for (Int_t i=0; i<GetNofPadRows(); i++) {
      83        1314 :     AliMpPadRow* padRow = GetPadRow(i);    
      84             : 
      85       11964 :     for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { 
      86        4668 :       AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
      87             : 
      88        5796 :       if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
      89        2340 :            (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
      90             :            
      91         111 :         found = padRowSegment;  
      92             :     }
      93             :   }
      94             : 
      95          84 :   return found;         
      96             : }
      97             : 
      98             : //
      99             : // protected methods  
     100             : //
     101             : 
     102             : //______________________________________________________________________________
     103             : void AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId,
     104             :                                               Double_t& x, Double_t& y) const
     105             : {
     106             : /// Fill the coordinates of the motif specified with
     107             : /// the given position identifier.                                           \n
     108             : /// !! Applicable only for motifs that have their most down pad in
     109             : /// this row segment.
     110             : 
     111             :   // Find the first (left, down) pad row segment with this motifPositionId.
     112             :   AliMpVPadRowSegment* downPadRowSegment 
     113         168 :     = FindPadRowSegment(motifPositionId);
     114             :   AliMpVPadRowSegment* rightPadRowSegment 
     115          84 :     = FindMostRightPadRowSegment(motifPositionId);
     116             :   
     117             :   // Check if the motifPositionId is present 
     118          84 :   if (!downPadRowSegment || !rightPadRowSegment) {
     119           0 :     AliErrorStream() << "Outside row segment region" << endl;
     120           0 :     return;
     121             :   }
     122             : 
     123             :   // Check if both pad row segments have the same motif 
     124          84 :   if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
     125           0 :     AliFatal("Outside row segment region");
     126           0 :     return;
     127             :   }
     128             : 
     129             :   // Get position of found row segment
     130          84 :   x = rightPadRowSegment->RightBorderX();       
     131          84 :   y = GetRow()->LowBorderY()  ;   
     132             :   
     133         372 :   for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
     134         102 :     y += GetPadRow(i)->HalfSizeY()*2.;
     135             :     
     136             :   // Add motifs dimensions
     137          84 :   x -= downPadRowSegment->GetMotif()->DimensionX();
     138          84 :   y += downPadRowSegment->GetMotif()->DimensionY();
     139         168 : }
     140             : 
     141             : //
     142             : // public methods  
     143             : //
     144             : 
     145             : //______________________________________________________________________________
     146             : void AliMpRowSegmentLSpecial::UpdatePadsOffset()
     147             : {
     148             : /// Set low indices limit to the pad offset calculated
     149             : /// from the neighbour normal segment.
     150             : 
     151             :   // Get the neighbour row segment
     152             :   // (the first normal segment)
     153          72 :   AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
     154             : 
     155             :   // Get the the pads offset of the neighbour row segment
     156             :   // (the first normal segment)
     157          36 :   MpPair_t offset = neighbour->GetLowIndicesLimit();
     158             :   
     159             :   // Find max nof pads in a row
     160          36 :   Int_t maxNofPads = MaxNofPadsInRow();
     161             : 
     162             :   // Set limits
     163          36 :   SetLowIndicesLimit(offset - AliMp::Pair(maxNofPads, 0));
     164             : 
     165             :   // Reset limits in the neighbour row segment
     166             :   // (pad offset is now included in the special segment)  
     167          36 :   neighbour->SetLowIndicesLimit(0, neighbour->GetLowLimitIy());
     168          36 : }
     169             : 
     170             : //______________________________________________________________________________
     171             : Double_t  AliMpRowSegmentLSpecial::LeftBorderX() const
     172             : {
     173             : /// Return the x coordinate of the left row segment border
     174             : /// in the global coordinate system.
     175             : 
     176             :   Double_t leftBorder = DBL_MAX;
     177       38015 :   for (Int_t i=0; i<GetNofPadRows(); i++) {
     178       17377 :     AliMpPadRow* padRow = GetPadRow(i);
     179             :     Double_t border 
     180       17377 :       = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
     181             :       
     182       24288 :     if (border < leftBorder) leftBorder =  border;
     183             :   }  
     184             :   
     185        1087 :   return leftBorder;
     186             : }
     187             : 
     188             : //______________________________________________________________________________
     189             : Double_t  AliMpRowSegmentLSpecial::RightBorderX() const
     190             : {
     191             : /// Returns the x coordinate of the right row segment border
     192             : /// in the global coordinate system.
     193             : 
     194        2036 :   Double_t sameBorder = GetOffsetX();
     195             : 
     196             :   // Consistence check  
     197             :   Double_t rightBorder = -DBL_MAX;
     198       34612 :   for (Int_t i=0; i<GetNofPadRows(); i++) {
     199       16288 :     AliMpPadRow* padRow = GetPadRow(i);
     200       16288 :     Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
     201       17306 :     if (border > rightBorder) rightBorder =  border;
     202             :   }  
     203             : 
     204        1018 :   if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04)  {
     205           0 :     AliErrorStream() << "WrongBorder" << endl;
     206           0 :     return sameBorder;
     207             :   }  
     208             :   
     209        1018 :   return rightBorder;
     210        1018 : }
     211             : 
     212             : //______________________________________________________________________________
     213             : Double_t AliMpRowSegmentLSpecial::GetPositionX() const
     214             : {
     215             : /// Return the x position of the row segment centre.
     216             : /// The centre is defined as the centre of the rectangular
     217             : /// row segment envelope.
     218             : 
     219           0 :   return GetOffsetX() - GetDimensionX();                    
     220             : }
     221             : 
     222             : //______________________________________________________________________________
     223             : Double_t AliMpRowSegmentLSpecial::GetPositionY() const
     224             : {
     225             : /// Return the y position of the row segment centre.
     226             : /// The centre is defined as the centre of the rectangular
     227             : /// row segment envelope.
     228             : 
     229           0 :   return GetRow()->GetPositionY();  
     230             : }
     231             : 
     232             : #include <Riostream.h>
     233             : //______________________________________________________________________________
     234             : Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i, MpPair_t indices)
     235             : {
     236             : /// Set global indices to i-th motif position and returns next index in x.
     237             : 
     238             :   // Get motif position
     239             :   AliMpMotifPosition* motifPosition
     240         192 :     = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
     241             : 
     242             :   // Low limit
     243             :   MpPair_t low 
     244         192 :     = AliMp::Pair(GetLowLimitIx() + AliMpConstants::StartPadIndex(), 
     245          96 :                   AliMp::PairSecond(indices))
     246          96 :       + FindRelativeLowIndicesOf(GetMotifPositionId(i));
     247             :             
     248          96 :   if (! motifPosition->IsHighLimitValid()) {   
     249          84 :      motifPosition->SetLowIndicesLimit(low);
     250          84 :   } 
     251             :   else {
     252          12 :     if ( motifPosition->GetLowLimitIx() > AliMp::PairFirst(low) )
     253           3 :       motifPosition->SetLowIndicesLimit(
     254           3 :                                  AliMp::PairFirst(low),
     255           3 :                                  motifPosition->GetLowLimitIy());
     256             : 
     257          12 :     if ( motifPosition->GetLowLimitIy() > AliMp::PairSecond(low) )
     258           0 :        motifPosition->SetLowIndicesLimit(
     259           0 :                                  motifPosition->GetLowLimitIx(),
     260           0 :                                  AliMp::PairSecond(low) );
     261             :   }
     262             :              
     263             :   // High limit      
     264          96 :   AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();  
     265             :   MpPair_t high 
     266          96 :     = motifPosition->GetLowIndicesLimit()
     267          96 :       + AliMp::Pair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);  
     268             :                 
     269          96 :   motifPosition->SetHighIndicesLimit(high);
     270             : 
     271             :   // Increment index only if last motif position is processed 
     272         192 :   if ( i != GetNofMotifs()-1 ) 
     273         156 :     return AliMp::PairFirst(indices);
     274             :     //return 0;
     275             :   else
     276          36 :     return AliMp::PairFirst(indices) + MaxNofPadsInRow();  
     277             :     //return MaxNofPadsInRow();  
     278          96 : }
     279             : //______________________________________________________________________________
     280             : void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
     281             : {
     282             : /// Set indices limits
     283             : /// The limits are defined as the limits of the smallest rectangle which
     284             : /// includes all pads of this special row segment.
     285             : 
     286             :   // Low ix
     287          72 :   Int_t ixl = GetLowLimitIx() + AliMpConstants::StartPadIndex();
     288             :       // the pads offset was already defined by Reader
     289             : 
     290             :   // High ix
     291          36 :   Int_t ixh = ixl + MaxNofPadsInRow() - 1;
     292             : 
     293             :   // Low iy
     294          36 :   Int_t iyl = AliMpConstants::StartPadIndex();
     295          36 :   if (rowBefore) {
     296             :     //if (constPadSizeDirection == kY) {
     297          27 :       iyl = rowBefore->GetHighLimitIy()+1;
     298             :     //} 
     299             :     /*
     300             :     else {
     301             :       AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);        
     302             :       AliMpMotifPosition* motPos =  rowBefore->FindMotifPosition(seg, ixl);
     303             :       if (!motPos) 
     304             :         Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
     305             :       iyl = motPos->GetHighLimitIy()+1;
     306             :     }
     307             :     */
     308          27 :   }  
     309             : 
     310             :   // High iy
     311          36 :   Int_t iyh = iyl + GetNofPadRows() - 1;
     312             :   
     313          36 :   SetLowIndicesLimit(ixl, iyl);
     314          36 :   SetHighIndicesLimit(ixh, iyh);
     315          36 : }  
     316             : 
     317             : 
     318             : 
     319             : 

Generated by: LCOV version 1.11