LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpTrigger.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 50 106 47.2 %
Date: 2016-06-14 17:26:59 Functions: 16 23 69.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 purpeateose. It is      *
      13             : * provided "as is" without express or implied warranty.                  *
      14             : **************************************************************************/
      15             : 
      16             : // $Id$
      17             : // $MpId: AliMpTrigger.cxx,v 1.4 2006/05/24 13:58:52 ivana Exp $
      18             : 
      19             : #include "AliMpTrigger.h"
      20             : #include "AliMpSlatSegmentation.h"
      21             : #include "AliMpConstants.h"
      22             : #include "AliLog.h"
      23             : #include "AliMpSlat.h"
      24             : 
      25             : #include "Riostream.h"
      26             : #include "TArrayI.h"
      27             : #include "TObjArray.h"
      28             : 
      29             : //-----------------------------------------------------------------------------
      30             : /// \class AliMpTrigger
      31             : /// 
      32             : /// A trigger 'slat' object. 
      33             : /// It is to be viewed as a superposition of  
      34             : /// virtual layers of AliMpSlat objects. The need for more than one layer  
      35             : /// arise from the fact that a given local board deals with strips  
      36             : /// located in different detelem. So a given strip (pad) can have several  
      37             : /// "locations".
      38             : ///
      39             : /// \author Laurent Aphecetche
      40             : //-----------------------------------------------------------------------------
      41             : 
      42             : using std::cout;
      43             : using std::endl;
      44             : /// \cond CLASSIMP
      45          18 : ClassImp(AliMpTrigger)
      46             : /// \endcond
      47             : 
      48             : namespace
      49             : {
      50             :   Bool_t IsEqual(Double_t a, Double_t b, Double_t precision)
      51             : {
      52        1248 :     if (b)
      53             :     {
      54         624 :       Double_t diff = TMath::Abs(b-a)/TMath::Abs(b);
      55         624 :       if ( diff < precision ) 
      56             :       {
      57         624 :         return kTRUE;
      58             :       }
      59           0 :     }
      60             :     else
      61             :     {
      62           0 :       if ( !a ) return kTRUE;
      63             :     }
      64           0 :     return kFALSE;
      65         624 : }
      66             : }
      67             : 
      68             : //_____________________________________________________________________________
      69             : AliMpTrigger::AliMpTrigger()
      70           0 : : TObject(), 
      71           0 :   fId(""), 
      72           0 :   fPlaneType(AliMp::kNonBendingPlane), 
      73           0 :   fSlats(0),
      74           0 :   fSlatSegmentations(0),
      75           0 :   fMaxNofPadsY(0),
      76           0 :   fDX(0), 
      77           0 :   fDY(0)
      78           0 : {
      79             :   /// default ctor
      80             : 
      81           0 :   AliDebugStream(1) << "this = " << this << endl;
      82             : 
      83           0 :   fSlats.SetOwner(kFALSE);
      84           0 :   fSlatSegmentations.SetOwner(kTRUE);
      85           0 : }
      86             : 
      87             : //_____________________________________________________________________________
      88             : AliMpTrigger::AliMpTrigger(const char* slatType, AliMp::PlaneType bendingOrNot)
      89         432 :     :  TObject(), 
      90         432 :        fId(slatType), 
      91         432 :        fPlaneType(bendingOrNot), 
      92         432 :        fSlats(0),
      93         432 :        fSlatSegmentations(0),
      94         432 :        fMaxNofPadsY(0), 
      95         432 :        fDX(0), 
      96         432 :        fDY(0)
      97        2160 : {
      98             :   /// normal ctor
      99             : 
     100        2160 :   AliDebugStream(1) << "this = " << this << endl;
     101             : 
     102         432 :   fSlats.SetOwner(kFALSE);
     103         432 :   fSlatSegmentations.SetOwner(kTRUE);
     104         864 : }
     105             : 
     106             : //_____________________________________________________________________________
     107             : AliMpTrigger::~AliMpTrigger()
     108        1728 : {
     109             :   /// dtor
     110        1440 :   AliDebugStream(1) << "this = " << this << endl;
     111             : 
     112         288 :   fSlatSegmentations.Delete();
     113         864 : }
     114             : 
     115             : //_____________________________________________________________________________
     116             : Bool_t
     117             : AliMpTrigger::AdoptLayer(AliMpSlat* slat)
     118             : {
     119             :   /// Adopt (i.e. we become owner of that pointer) a slat, as 
     120             :   /// a layer of this trigger slat.
     121             : 
     122        2976 :   AliDebug(2,Form("%s is adopting %s ",
     123             :                   GetID(),slat->GetID()));
     124             : 
     125             :   // Check that we keep our size constant.
     126             :     
     127        1056 :   if ( GetSize() > 0 && 
     128         312 :        ( !::IsEqual(slat->DX(),fDX,AliMpConstants::LengthTolerance()) || 
     129         312 :          !::IsEqual(slat->DY(),fDY,AliMpConstants::LengthTolerance()) )
     130             :      )
     131             :   {
     132           0 :     AliError(Form("In %s trying to add a layer (%e,%e) (layer #%d) "
     133             :                   "of a different size than mine (%e,%e)",
     134             :                   GetID(),slat->DX(),slat->DY(),fSlats.GetEntries(),
     135             :                   fDX,fDY));
     136           0 :     return kFALSE;
     137             :   }
     138         744 :   fSlats.Add(slat);
     139             :   Bool_t owner(kTRUE);
     140             :   // the slat segmentation will be the owner of the slat, and will delete
     141             :   // it when it'll be deleted itself
     142        1488 :   fSlatSegmentations.Add(new AliMpSlatSegmentation(slat,owner));
     143         744 :   fMaxNofPadsY = TMath::Max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
     144         744 :   fDX = TMath::Max(fDX,slat->DX());
     145         744 :   fDY = TMath::Max(fDY,slat->DY());
     146             :   return kTRUE;
     147         744 : }
     148             : 
     149             : //_____________________________________________________________________________
     150             : Double_t
     151             : AliMpTrigger::DX() const
     152             : {
     153             :   /// Returns the half-size in X (cm)
     154         288 :   return fDX;
     155             : }
     156             : 
     157             : //_____________________________________________________________________________
     158             : Double_t
     159             : AliMpTrigger::DY() const
     160             : {
     161             :   /// Returns the half-size in Y (cm)
     162         288 :   return fDY;
     163             : }
     164             : 
     165             : //_____________________________________________________________________________
     166             : void 
     167             : AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
     168             : {
     169             :   /// Fills lbn with the local board numbers we're dealing with
     170             :   Int_t n(0);
     171           0 :   for ( Int_t i = 0; i < GetSize(); ++i )
     172             :   {
     173           0 :     n += GetLayer(i)->GetNofElectronicCards();
     174             :   }
     175             :   
     176           0 :   lbn.Set(n);
     177             : 
     178             :   Int_t index(0);
     179             :   
     180           0 :   for ( Int_t i = 0; i < GetSize(); ++i )
     181             :   {
     182           0 :     TArrayI slbn;
     183           0 :     GetLayer(i)->GetAllMotifPositionsIDs(slbn);
     184           0 :     for ( Int_t j = 0; j < slbn.GetSize(); ++j )
     185             :     {
     186           0 :       lbn[index] = slbn[j];
     187           0 :       ++index;
     188             :     }
     189           0 :   }
     190           0 : }
     191             : 
     192             : //_____________________________________________________________________________
     193             : const char*
     194             : AliMpTrigger::GetID() const
     195             : {
     196             :   /// returns the id of this slat
     197           0 :   return fId.Data();
     198             : }
     199             : 
     200             : //_____________________________________________________________________________
     201             : const char*
     202             : AliMpTrigger::GetName() const
     203             : {
     204             :   /// returns the name (=id+bending/non-bending) of this slat
     205           0 :   TString name(GetID());
     206           0 :   if ( fPlaneType == AliMp::kBendingPlane )
     207             :   {
     208           0 :     name += ".Bending";
     209             :   }
     210           0 :   else if ( fPlaneType == AliMp::kNonBendingPlane )
     211             :   {
     212           0 :     name += ".NonBending";
     213             :   }
     214             :   else
     215             :   {
     216           0 :     name += ".Invalid";
     217             :   }
     218           0 :   return name.Data();
     219           0 : }
     220             : 
     221             : //_____________________________________________________________________________
     222             : AliMpSlat*
     223             : AliMpTrigger::GetLayer(int layer) const
     224             : {
     225             :   /// Returns a given layer
     226       81240 :   if ( IsLayerValid(layer) )
     227             :   {
     228       40620 :     return (AliMpSlat*)fSlats.At(layer);
     229             :   }
     230           0 :   return 0;
     231       40620 : }
     232             : 
     233             : //_____________________________________________________________________________
     234             : AliMpVSegmentation*
     235             : AliMpTrigger::GetLayerSegmentation(int layer) const
     236             : {
     237             :   /// Returns a given layer
     238     2562286 :   if ( IsLayerValid(layer) )
     239             :   {
     240     1281143 :     return (AliMpSlatSegmentation*)fSlatSegmentations.At(layer);
     241             :   }
     242           0 :   return 0;
     243     1281143 : }
     244             : 
     245             : //_____________________________________________________________________________
     246             : Int_t
     247             : AliMpTrigger::GetNofPadsX() const
     248             : {
     249             :   /// Returns the number of pad in x direction
     250       39936 :   if ( !GetSize() ) return -1;
     251       19968 :   if ( GetLayer(0) )
     252             :   {
     253       19968 :     return GetLayer(0)->GetNofPadsX();
     254             :   }
     255           0 :   return -1;
     256       19968 : }
     257             : 
     258             : //_____________________________________________________________________________
     259             : Int_t
     260             : AliMpTrigger::GetMaxNofPadsY() const
     261             : {
     262             :   /// Maximum number of pads in y direction
     263      190368 :   return fMaxNofPadsY;
     264             : }
     265             : 
     266             : //_____________________________________________________________________________
     267             : Int_t
     268             : AliMpTrigger::GetSize() const
     269             : {
     270             :   /// Number of layers
     271     6394162 :   return fSlats.GetEntriesFast();
     272             : }
     273             : 
     274             : //_____________________________________________________________________________
     275             : Bool_t
     276             : AliMpTrigger::IsLayerValid(int layer) const
     277             : {
     278             :   /// Whether a given layer index is valid or not
     279     3965289 :   if ( layer >= 0 && layer < GetSize() )
     280             :   {
     281     1321763 :     return kTRUE;
     282             :   }
     283           0 :   return kFALSE;
     284     1321763 : }
     285             : 
     286             : //_____________________________________________________________________________
     287             : AliMp::PlaneType
     288             : AliMpTrigger::PlaneType() const
     289             : {
     290             :   /// Bending or not
     291           0 :   return fPlaneType;
     292             : }
     293             : 
     294             : //_____________________________________________________________________________
     295             : void
     296             : AliMpTrigger::Print(Option_t* opt) const
     297             : {
     298             :   /// Dump on screen
     299           0 :   cout << "AliMpTrigger::" << GetID();
     300           0 :   if ( GetSize() == 0 )
     301             :   {
     302           0 :     cout << " Empty";
     303           0 :   }
     304           0 :   else if ( GetSize() > 1 )
     305             :   {
     306           0 :     cout << " Number of layers : " << GetSize();
     307           0 :   }
     308             :   else 
     309             :   {
     310           0 :     cout << " One layer";
     311             :   }
     312           0 :   cout << endl;
     313           0 :   for ( Int_t i = 0; i < GetSize(); ++i ) 
     314             :   {
     315           0 :     cout << "   ";
     316           0 :     GetLayer(i)->Print(opt);
     317             :   }
     318           0 : }
     319             : 
     320             : //_____________________________________________________________________________
     321             : //_____________________________________________________________________________
     322             : //_____________________________________________________________________________
     323             : //_____________________________________________________________________________

Generated by: LCOV version 1.11