LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpPadRow.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 38 55 69.1 %
Date: 2016-06-14 17:26:59 Functions: 15 18 83.3 %

          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: AliMpPadRow.cxx,v 1.8 2006/05/24 13:58:46 ivana Exp $
      18             : // Category: sector
      19             : 
      20             : //-----------------------------------------------------------------------------
      21             : // Class AliMpPadRow
      22             : // ------------------
      23             : // Class describing a pad row composed of the pad row segments.
      24             : // Included in AliRoot: 2003/05/02
      25             : // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
      26             : //-----------------------------------------------------------------------------
      27             : 
      28             : #include "AliMpPadRow.h"
      29             : #include "AliMpPadRowLSegment.h"
      30             : #include "AliMpPadRowRSegment.h"
      31             : 
      32             : #include "AliLog.h"
      33             : 
      34             : #include <Riostream.h>
      35             : 
      36             : using std::endl;
      37             : /// \cond CLASSIMP
      38          18 : ClassImp(AliMpPadRow)
      39             : /// \endcond
      40             : 
      41             : //_____________________________________________________________________________
      42             : AliMpPadRow::AliMpPadRow(AliMp::XDirection direction) 
      43        1266 :   : TObject(),
      44        1266 :     fDirection(direction), 
      45        1266 :     fID(0),
      46        1266 :     fOffsetX(0),
      47        1266 :     fSegments() 
      48        6330 : {
      49             : /// Standard constructor
      50        2532 : }
      51             : 
      52             : //_____________________________________________________________________________
      53             : AliMpPadRow::AliMpPadRow() 
      54           0 :   : TObject(),
      55           0 :     fDirection(AliMp::kLeft), 
      56           0 :     fID(0),
      57           0 :     fOffsetX(0),
      58           0 :     fSegments() 
      59           0 : {
      60             : /// Default constructor
      61           0 : }
      62             : 
      63             : //_____________________________________________________________________________
      64             : AliMpPadRow::~AliMpPadRow() 
      65        5064 : {
      66             : /// Destructor  
      67             : 
      68        6870 :   for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
      69        4338 :     delete fSegments[i];
      70        2532 : }
      71             : 
      72             : //
      73             : // private methods
      74             : //
      75             : 
      76             : //_____________________________________________________________________________
      77             : Double_t AliMpPadRow::CurrentBorderX() const
      78             : {
      79             : /// Return the left/right x border 
      80             : /// (depending on the direction which the row segments are filled in).
      81             : 
      82        4338 :   if (GetNofPadRowSegments() == 0)
      83        1266 :       return fOffsetX;
      84             :   else 
      85        1806 :     if (fDirection == AliMp::kLeft)
      86        1584 :       return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
      87             :     else  
      88         222 :       return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
      89        2169 : }
      90             : 
      91             : //
      92             : // public methods
      93             : //
      94             : 
      95             : //_____________________________________________________________________________
      96             : AliMpVPadRowSegment* 
      97             : AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
      98             :                               Int_t nofPads)
      99             : {
     100             : /// Add a pad row segment.
     101             : 
     102             :   AliMpVPadRowSegment* padRowSegment = 0;
     103             : 
     104        6507 :   if (fDirection == AliMp::kLeft) {
     105             :     padRowSegment 
     106        4653 :       = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
     107        1242 :   }    
     108             :   else  {
     109             :     padRowSegment 
     110        1854 :       = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
     111             :   }     
     112             : 
     113             :   // Set pad row segment offset
     114        2169 :   padRowSegment->SetOffsetX(CurrentBorderX());
     115             : 
     116             :   // Adds the pad row segment
     117        2169 :   fSegments.Add(padRowSegment);
     118             :   
     119        2169 :   return padRowSegment;
     120           0 : }  
     121             :   
     122             : //_____________________________________________________________________________
     123             : AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
     124             : {
     125             : /// Find the row segment for the specified x position;
     126             : /// return 0 if no row segment is found.
     127             : 
     128           0 :   for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
     129           0 :     AliMpVPadRowSegment* rs = GetPadRowSegment(i);
     130           0 :     if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
     131           0 :       return rs;
     132           0 :   }
     133             :   
     134           0 :   return 0;    
     135           0 : }    
     136             : 
     137             : //_____________________________________________________________________________
     138             : Double_t  AliMpPadRow::HalfSizeY() const
     139             : {
     140             : /// Return the half size in y
     141             : 
     142      369838 :   return GetPadRowSegment(0)->HalfSizeY();
     143             : }
     144             : 
     145             : //_____________________________________________________________________________
     146             : void  AliMpPadRow::SetID(Int_t id)
     147             : {
     148             : /// Set the ID.
     149             : 
     150        2532 :   fID = id;
     151        1266 : }    
     152             : 
     153             : //_____________________________________________________________________________
     154             : void  AliMpPadRow::SetOffsetX(Double_t offsetX)
     155             : {
     156             : /// Set the x offset.
     157             : 
     158        2532 :   fOffsetX = offsetX;
     159        1266 : }    
     160             : 
     161             : //_____________________________________________________________________________
     162             : Int_t AliMpPadRow::GetID() const 
     163             : {
     164             : /// Return the pad row ID.
     165             : 
     166         660 :   return fID;
     167             : }  
     168             : 
     169             : //_____________________________________________________________________________
     170             : Int_t AliMpPadRow::GetNofPadRowSegments() const 
     171             : {
     172             : /// Return the number of pad row segments.
     173             : 
     174      580782 :   return fSegments.GetEntriesFast();
     175             : }  
     176             : 
     177             : //_____________________________________________________________________________
     178             : AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const 
     179             : {
     180             : /// Return the pad row segment with the specified number.
     181             : 
     182      719796 :   if (i<0 || i>=GetNofPadRowSegments()) {
     183           0 :     AliWarningStream() << "Index outside range" << endl;
     184           0 :     return 0;
     185             :   }
     186             :   
     187      239932 :   return (AliMpVPadRowSegment*)fSegments[i];  
     188      239932 : }
     189             : 
     190             : //_____________________________________________________________________________
     191             : Int_t AliMpPadRow::GetNofPads() const 
     192             : {
     193             : /// Return the number of pads in this pad row.
     194             : 
     195             :   Int_t nofPads=0;
     196       16470 :   for (Int_t i=0; i<GetNofPadRowSegments(); i++)
     197        4653 :     nofPads += GetPadRowSegment(i)->GetNofPads();
     198             : 
     199        2388 :   return nofPads;
     200             : }  
     201             : 

Generated by: LCOV version 1.11