LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpRowSegmentRSpecial.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 68 88 77.3 %
Date: 2016-06-14 17:26:59 Functions: 12 17 70.6 %

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

Generated by: LCOV version 1.11