LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpSector.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 114 171 66.7 %
Date: 2016-06-14 17:26:59 Functions: 28 36 77.8 %

          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: AliMpSector.cxx,v 1.14 2006/05/24 13:58:46 ivana Exp $
      18             : // Category: sector
      19             : 
      20             : //-----------------------------------------------------------------------------
      21             : // Class AliMpSector
      22             : // -----------------
      23             : // Class describing the sector of the MUON chamber of station 1.
      24             : // Included in AliRoot: 2003/05/02
      25             : // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
      26             : //-----------------------------------------------------------------------------
      27             : 
      28             : #include "AliMpSector.h"
      29             : #include "AliMpSectorPadIterator.h"
      30             : #include "AliMpZone.h"
      31             : #include "AliMpRow.h"
      32             : #include "AliMpVRowSegment.h"
      33             : #include "AliMpVMotif.h"
      34             : #include "AliMpMotifMap.h"
      35             : #include "AliMpEncodePair.h"
      36             : #include "AliMpConstants.h"
      37             : 
      38             : #include "AliLog.h"
      39             : 
      40             : #include <Riostream.h>
      41             : 
      42             : using std::cout;
      43             : using std::endl;
      44             : /// \cond CLASSIMP
      45          18 : ClassImp(AliMpSector)
      46             : /// \endcond
      47             : 
      48             : //_____________________________________________________________________________
      49             : AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows, 
      50             :                          AliMp::Direction direction, 
      51             :                          Double_t offsetx, Double_t offsety) 
      52          12 :   : TNamed("Sector", ""),
      53          12 :     fID(id),
      54          12 :     fOffsetX(offsetx),
      55          12 :     fOffsetY(offsety),
      56          12 :     fDimensionX(0.),
      57          12 :     fDimensionY(0.),
      58          12 :     fZones(),
      59          12 :     fRows(),
      60          12 :     fMotifMap(0),
      61          12 :     fDirection(direction),
      62          12 :     fMinPadDimensionX(1.e6),
      63          12 :     fMinPadDimensionY(1.e6),
      64          12 :     fMaxPadDimensionX(0.),
      65          12 :     fMaxPadDimensionY(0.),
      66          12 :     fLMaxPadIndices(0),
      67          12 :     fNofPads(0)
      68          60 : {
      69             : /// Standard constructor
      70             : 
      71          60 :   AliDebugStream(1) << "this = " << this << endl;
      72             : 
      73          36 :   fMotifMap = new AliMpMotifMap;
      74             : 
      75         108 :   for (Int_t izone = 0; izone<nofZones; izone++) 
      76         126 :     fZones.Add(new AliMpZone(izone+1));
      77             :     
      78         330 :   for (Int_t irow = 0; irow<nofRows; irow++) 
      79         459 :     fRows.Add(new AliMpRow(irow, fMotifMap));
      80             :     
      81          24 : }
      82             : 
      83             : //_____________________________________________________________________________
      84             : AliMpSector::AliMpSector() 
      85           0 :   : TNamed(),
      86           0 :     fID(""),    
      87           0 :     fOffsetX(0.),
      88           0 :     fOffsetY(0.),
      89           0 :     fDimensionX(0.),
      90           0 :     fDimensionY(0.),
      91           0 :     fZones(),
      92           0 :     fRows(),
      93           0 :     fMotifMap(0),
      94           0 :     fDirection(AliMp::kX),
      95           0 :     fMinPadDimensionX(0.),
      96           0 :     fMinPadDimensionY(0.),
      97           0 :     fMaxPadDimensionX(0.),
      98           0 :     fMaxPadDimensionY(0.),
      99           0 :     fLMaxPadIndices(0),
     100           0 :     fNofPads(0)
     101           0 : {
     102             : /// Default constructor
     103             : 
     104           0 :   AliDebugStream(1) << "this = " << this << endl;
     105           0 : }
     106             : 
     107             : //_____________________________________________________________________________
     108             : AliMpSector::~AliMpSector() 
     109          48 : {
     110             : /// Destructor 
     111             : 
     112          40 :   AliDebugStream(1) << "this = " << this << endl;
     113             : 
     114             :   // deletes 
     115         108 :   for (Int_t izone = 0; izone<GetNofZones(); izone++) 
     116          84 :     delete fZones[izone];
     117             :     
     118         330 :   for (Int_t irow = 0; irow<GetNofRows(); irow++) 
     119         306 :     delete fRows[irow];
     120             : 
     121          16 :   delete fMotifMap;
     122          24 : }
     123             : 
     124             : //
     125             : // private methods
     126             : //
     127             : 
     128             : //_____________________________________________________________________________
     129             : AliMpRow* AliMpSector::FindRow(Double_t y) const
     130             : {
     131             : /// Find the row for the specified y position.                              \n
     132             : /// If y is on border the lowest row is returned.
     133             :   
     134       23957 :   for (Int_t i=0; i<GetNofRows(); i++) {
     135       21300 :     if ( y >= ((AliMpRow*)fRows[i])->LowBorderY() && 
     136       10650 :          y <= ((AliMpRow*)fRows[i])->UpperBorderY())
     137        2657 :       return (AliMpRow*)fRows[i];
     138             :   }    
     139             :   
     140           0 :   return 0;
     141        2657 : }
     142             : 
     143             : //_____________________________________________________________________________
     144             : Int_t AliMpSector::FindMotifPositionId(Double_t x, Double_t y) const
     145             : {
     146             : /// Find the motif position ID in the specified position.                   \n
     147             : /// Return 0 if no motif is found.
     148             :  
     149             :   // Find the row segment
     150        5314 :   AliMpVRowSegment* rowSegment = FindRowSegment(x,y);
     151             :   
     152        2657 :   if ( ! rowSegment ) return 0;
     153             :     
     154             :   // Find motif position ID
     155        2657 :   return rowSegment->FindMotifPositionId(x, y);  
     156        2657 : }
     157             : 
     158             : //_____________________________________________________________________________
     159             : AliMpVRowSegment* AliMpSector::FindRowSegment(Double_t x, Double_t y) const
     160             : {
     161             : /// Find the row segment in the specified position.                         \n
     162             : /// Return if no motif is found.
     163             :   
     164             :   // Find row
     165        5314 :   AliMpRow* row = FindRow(y);
     166             :   
     167        2657 :   if (!row) return 0;
     168             : 
     169             :   // Find the row segment and return its motif
     170        2657 :   AliMpVRowSegment* rowSegment = row->FindRowSegment(x);
     171             :   
     172             :   return rowSegment;
     173        2657 : }
     174             : 
     175             : //_____________________________________________________________________________
     176             : void  AliMpSector::SetRowOffsets()
     177             : {
     178             : /// For each row check consitency of the row segments
     179             : /// and calculate the row offset.
     180             : 
     181          24 :   Double_t offset = fOffsetY;
     182             :   
     183         330 :   for (Int_t irow=0; irow<GetNofRows(); irow++)
     184         153 :     offset = GetRow(irow)->SetOffsetY(offset);    
     185          12 : }
     186             : 
     187             : //_____________________________________________________________________________
     188             : void  AliMpSector::SetMotifPositions()
     189             : {
     190             : /// Create motif positions objects and fills them in the motif map.
     191             : 
     192         342 :   for (Int_t i=0; i<GetNofRows(); i++)
     193         153 :     GetRow(i)->SetMotifPositions();
     194          12 : }
     195             : 
     196             : //_____________________________________________________________________________
     197             : void  AliMpSector::SetGlobalIndices()
     198             : {
     199             : /// Set the indices limits to all indexed elements
     200             : /// (row, row segment, motif positions).
     201             : 
     202             :   AliMpRow* rowBefore=0;
     203         342 :   for (Int_t i=0; i<GetNofRows(); i++) {
     204         153 :     GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
     205         153 :     rowBefore = GetRow(i);
     206             :   }
     207          12 : }
     208             : 
     209             : //_____________________________________________________________________________
     210             : void  AliMpSector::SetMinMaxPadDimensions()
     211             : {
     212             : /// Set the minimal pad dimensions.
     213             : 
     214         120 :   for (Int_t i=1; i<GetNofZones()+1; i++) {
     215          42 :     Double_t dx = GetZone(i)->GetPadDimensionX();
     216          42 :     Double_t dy = GetZone(i)->GetPadDimensionY();
     217             :     
     218          78 :     if ( ( fDirection == AliMp::kX && dy > 0. && dy < fMinPadDimensionY ) ||
     219          54 :          ( fDirection == AliMp::kY && dx > 0. && dx < fMinPadDimensionX ) ) {
     220             :       
     221          12 :       fMinPadDimensionX = dx;
     222          12 :       fMinPadDimensionY = dy;
     223          12 :     }  
     224             : 
     225          78 :     if ( ( fDirection == AliMp::kX && dy > 0. && dy > fMaxPadDimensionY ) ||
     226          42 :          ( fDirection == AliMp::kY && dx > 0. && dx > fMinPadDimensionX ) ) {
     227             :       
     228          30 :       fMaxPadDimensionX = dx;
     229          30 :       fMaxPadDimensionY = dy;
     230          30 :     }  
     231             :   }
     232          12 : }
     233             : 
     234             : //_____________________________________________________________________________
     235             : void  AliMpSector::SetMaxPadIndices()
     236             : {
     237             : /// Set maximum pad indices in x, y
     238             : 
     239          24 :   if ( fLMaxPadIndices != 0 ) return;
     240             :   
     241             :   Int_t maxIndexInX = 0;
     242             :   Int_t maxIndexInY = 0;
     243         330 :   for (Int_t i=0; i<GetNofRows(); i++) {
     244             : 
     245         153 :     Int_t ixh = GetRow(i)->GetHighLimitIx();
     246         165 :     if ( ixh > maxIndexInX ) maxIndexInX = ixh;
     247             : 
     248         153 :     Int_t iyh = GetRow(i)->GetHighLimitIy();
     249         306 :     if ( iyh > maxIndexInY ) maxIndexInY = iyh;
     250             :   }  
     251             :   
     252          12 :   fLMaxPadIndices = AliMp::Pair(maxIndexInX, maxIndexInY);
     253          24 : }
     254             : 
     255             : 
     256             : //_____________________________________________________________________________
     257             : void  AliMpSector::SetNofPads()
     258             : {
     259             : /// Set the total number of pads
     260             : 
     261          24 :   fNofPads = fMotifMap->CalculateNofPads();
     262          12 : }
     263             : 
     264             : //_____________________________________________________________________________
     265             : void  AliMpSector::SetDimensions()
     266             : {
     267             : /// Set the maximum halflengths in x, y.
     268             : 
     269          24 :   fDimensionX = 0.;
     270          12 :   fDimensionY = 0.;
     271             :   
     272         330 :   for (Int_t i=0; i<GetNofRows(); i++) {
     273             : 
     274             :     // take the largest x row dimension
     275         153 :     if ( ((AliMpRow*)fRows[i])->GetDimensionX() > fDimensionX ) 
     276          45 :       fDimensionX = ((AliMpRow*)fRows[i])->GetDimensionX();
     277             :       
     278             :     // add all rows y dimensions  
     279         153 :     fDimensionY += ((AliMpRow*)fRows[i])->GetDimensionY();
     280             :   }
     281          12 : }  
     282             : 
     283             : //
     284             : // public methods
     285             : //
     286             : 
     287             : //_____________________________________________________________________________
     288             : AliMpVPadIterator* AliMpSector::CreateIterator() const
     289             : {
     290             : /// Create sector pad iterator
     291             : 
     292           0 :   return new AliMpSectorPadIterator(this);
     293           0 : }
     294             : 
     295             : 
     296             : //_____________________________________________________________________________
     297             : void  AliMpSector::SetRowSegmentOffsets()
     298             : {
     299             : /// For all rows set the offset to all row segments.
     300             : 
     301         342 :   for (Int_t irow=0; irow<GetNofRows(); irow++)
     302         153 :     GetRow(irow)->SetRowSegmentOffsets(fOffsetX);    
     303          12 : }
     304             : 
     305             : //_____________________________________________________________________________
     306             : void AliMpSector::Initialize() 
     307             : {
     308             : /// Make needed settings after sector is read from
     309             : /// data files.
     310             : 
     311          24 :   SetRowOffsets();
     312          12 :   SetMotifPositions();
     313          12 :   SetGlobalIndices();
     314          12 :   SetMinMaxPadDimensions();
     315          12 :   SetMaxPadIndices();
     316          12 :   SetNofPads();
     317          12 :   SetDimensions();
     318          12 : }  
     319             : 
     320             : //_____________________________________________________________________________
     321             : void AliMpSector::PrintGeometry()  const
     322             : {
     323             : /// Print the positions of rows, rows segments
     324             : 
     325           0 :   for (Int_t i=0; i<GetNofRows(); i++) {
     326           0 :     AliMpRow* row = GetRow(i);
     327             :     
     328           0 :     cout << "ROW " << row->GetID() 
     329           0 :          << "  center Y " << row->GetPositionY() << endl;
     330             : 
     331           0 :     for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
     332           0 :        AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
     333             :         
     334           0 :        cout << "   ROW Segment " << j 
     335           0 :             << "  borders " 
     336           0 :             << rowSegment->LeftBorderX() << "  "
     337           0 :             << rowSegment->RightBorderX()
     338           0 :             << "  x-size " 
     339           0 :             << 2*rowSegment->GetDimensionX() << "  "
     340           0 :             << endl;
     341             :     }
     342             :   }
     343           0 : }     
     344             :              
     345             : 
     346             : //_____________________________________________________________________________
     347             : AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
     348             : {
     349             : /// Find the row with the the specified motif position.                     \n
     350             : /// Return 0 if no row is found.
     351             : 
     352           0 :   AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
     353             :   
     354           0 :   if (segment) return segment->GetRow();
     355             :   
     356           0 :   return 0;  
     357           0 : }
     358             : 
     359             : //_____________________________________________________________________________
     360             : AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
     361             : {
     362             : /// Find the row segment with the the specified motif position.            \n
     363             : /// Return 0 if no row segment is found.
     364             : 
     365           0 :   for (Int_t irow=0; irow<GetNofRows(); irow++) {
     366             : 
     367           0 :     AliMpRow* row = (AliMpRow*)fRows[irow];
     368             : 
     369           0 :     for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
     370           0 :       AliMpVRowSegment* segment = row->GetRowSegment(iseg); 
     371           0 :       if (segment->HasMotifPosition(motifPositionId)) return segment;
     372           0 :     }
     373           0 :   }
     374             :   
     375           0 :   return 0;    
     376           0 : }
     377             : 
     378             : //_____________________________________________________________________________
     379             : Double_t AliMpSector::GetPositionX() const
     380             : {
     381             : /// Return the sector offset.
     382             : 
     383           4 :   return fOffsetX;
     384             : }  
     385             : 
     386             : 
     387             : //_____________________________________________________________________________
     388             : Double_t AliMpSector::GetPositionY() const
     389             : {
     390             : /// Return the sector offset.
     391             : 
     392           4 :   return fOffsetY;
     393             : }  
     394             : 
     395             : //_____________________________________________________________________________
     396             : Double_t  AliMpSector::GetDimensionX() const
     397             : {
     398             : /// Return the maximum halflengths in x.
     399             : 
     400          64 :   return fDimensionX;
     401             : }  
     402             : 
     403             : //_____________________________________________________________________________
     404             : Double_t  AliMpSector::GetDimensionY() const
     405             : {
     406             : /// Return the maximum halflengths in y.
     407             : 
     408          64 :   return fDimensionY;
     409             : }  
     410             : 
     411             : //_____________________________________________________________________________
     412             : Int_t AliMpSector::GetNofZones() const
     413             : {    
     414             : /// Return the number of zones.
     415             : 
     416        2520 :   return fZones.GetEntriesFast();
     417             : }  
     418             : 
     419             : //_____________________________________________________________________________
     420             : AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
     421             : {
     422             : /// Return zone with specified ID.
     423             : 
     424        2403 :   if (zoneID < 1 || zoneID > GetNofZones()) {
     425           0 :     AliWarningStream() << "Index outside range" << endl;
     426           0 :     return 0;
     427             :   }
     428             :   
     429         801 :   return (AliMpZone*)fZones[zoneID-1];
     430         801 : }  
     431             : 
     432             : //_____________________________________________________________________________
     433             : Int_t AliMpSector::GetNofRows() const
     434             : {
     435             : /// Return the number of rows.
     436             : 
     437       27094 :   return fRows.GetEntriesFast();
     438             : }  
     439             : 
     440             : //_____________________________________________________________________________
     441             : AliMpRow* AliMpSector::GetRow(Int_t rowID) const
     442             : {
     443             : /// Return row with specified ID.
     444             : 
     445        5223 :   if (rowID < 0 || rowID >= GetNofRows()) {
     446           0 :     AliWarningStream() << "Index outside range" << endl;
     447           0 :     return 0;
     448             :   }
     449             :   
     450        1741 :   return (AliMpRow*)fRows[rowID];
     451        1741 : }
     452             : 
     453             : //_____________________________________________________________________________
     454             : AliMp::PlaneType
     455             : AliMpSector::GetPlaneType() const
     456             : {
     457             : /// Return the plane type
     458             : 
     459         850 :   return GetDirection()==AliMp::kY ? AliMp::kBendingPlane : AliMp::kNonBendingPlane;
     460             : }
     461             : 
     462             : //_____________________________________________________________________________
     463             : Int_t 
     464             : AliMpSector::GetNofMotifPositions() const
     465             : {
     466             :   /// Return the number of manus
     467             :   
     468           0 :   return fMotifMap->GetNofMotifPositions();
     469             : }
     470             : 
     471             : //_____________________________________________________________________________
     472             : void 
     473             : AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const
     474             : {
     475             : /// Return the array of all motif positions IDs
     476             : 
     477         600 :   fMotifMap->GetAllMotifPositionsIDs(ecn);
     478         300 : }
     479             : 
     480             : //_____________________________________________________________________________
     481             : void
     482             : AliMpSector::Print(Option_t* opt) const
     483             : {
     484             : /// Print the map of motifs
     485             : 
     486           0 :   cout << "Sector," << PlaneTypeName(GetPlaneType()) << endl;
     487           0 :   fMotifMap->Print(opt);
     488           0 : }

Generated by: LCOV version 1.11