LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpDetElement.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 87 121 71.9 %
Date: 2016-06-14 17:26:59 Functions: 20 24 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: AliMpDetElement.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
      18             : // Category: management
      19             : 
      20             : //-----------------------------------------------------------------------------
      21             : // Class AliMpDetElement
      22             : // --------------------
      23             : // The class defines the electronics properties of detection element
      24             : // Authors: Ivana Hrivnacova, IPN Orsay
      25             : //          Laurent Aphecetche, Christian Finck, SUBATECH Nantes
      26             : //-----------------------------------------------------------------------------
      27             : 
      28             : #include "AliMpDetElement.h"
      29             : 
      30             : #include "AliMpArrayI.h"
      31             : #include "AliMpConstants.h"
      32             : #include "AliMpDEManager.h"
      33             : #include "AliMpDCSNamer.h"
      34             : #include "AliMpHVUID.h"
      35             : #include "AliMpManuUID.h"
      36             : #include "AliMpPadUID.h"
      37             : #include "AliMpSegmentation.h"
      38             : #include "AliMpVSegmentation.h"
      39             : 
      40             : #include "AliCodeTimer.h"
      41             : #include "AliLog.h"
      42             : 
      43             : #include <Riostream.h>
      44             : 
      45             : using std::endl;
      46             : /// \cond CLASSIMP
      47          18 : ClassImp(AliMpDetElement)
      48             : /// \endcond
      49             : 
      50             : const char  AliMpDetElement::fgkNameSeparator = '_'; 
      51             : 
      52             : //______________________________________________________________________________
      53             : AliMpDetElement::AliMpDetElement(Int_t id, const TString& name,
      54             :                     const TString& segType, AliMp::PlaneType planeType)
      55         684 :   : TObject(),
      56         684 :     fId(id),
      57         684 :     fDdlId(-1),
      58         684 :     fName(name),
      59         684 :     fSegType(segType),
      60         684 :     fPlaneType(planeType),
      61         684 :     fBusPatchIds(false),
      62         684 :     fManuList(),
      63         684 :     fTrackerChannels(),
      64         684 :     fHVmanus(),
      65         684 :     fNofChannels(0)
      66        3420 : {
      67             : /// Standard constructor
      68        1368 : }
      69             : 
      70             : //______________________________________________________________________________
      71             : AliMpDetElement::AliMpDetElement(TRootIOCtor* ioCtor)
      72           0 :   : TObject(),
      73           0 :     fId(0),
      74           0 :     fDdlId(-1),
      75           0 :     fName(),
      76           0 :     fSegType(),
      77           0 :     fPlaneType(),
      78           0 :     fBusPatchIds(),
      79           0 :     fManuList(),
      80           0 :     fTrackerChannels(),
      81           0 :     fHVmanus(ioCtor),
      82           0 :     fNofChannels()
      83           0 : {
      84             : /// Root IO constructor
      85           0 : }
      86             : 
      87             : //______________________________________________________________________________
      88             : AliMpDetElement::~AliMpDetElement()
      89        2736 : {
      90             : /// Destructor
      91        1368 : }
      92             : 
      93             : 
      94             : //
      95             : // public methods
      96             : //
      97             : 
      98             : //______________________________________________________________________________
      99             : Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId)
     100             : {
     101             : /// Add bus patch Id if a bus patch with the same Id is not yet present;
     102             : /// return false if bus patch was not added
     103             : 
     104        5328 :   if ( HasBusPatchId(busPatchId) ) {
     105           0 :     AliWarningStream() 
     106           0 :       << "Bus patch Id = " << busPatchId << " already present."
     107           0 :       << endl;
     108           0 :     return false;
     109             :   } 
     110             : 
     111        2664 :   fBusPatchIds.Add(busPatchId); 
     112        2664 :   return true;
     113        2664 : }  
     114             :  
     115             : //______________________________________________________________________________
     116             : TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const
     117             : {
     118             : /// Return the segmentation name for the given catod type
     119             : 
     120     1193555 :   return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType));
     121           0 : }         
     122             : 
     123             : //______________________________________________________________________________
     124             : AliMp::PlaneType  AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const 
     125             : {
     126             : /// Return plane type                                                      \n
     127             : 
     128      633776 :   if ( cath == AliMp::kCath0 ) return fPlaneType;
     129       86839 :   else                         return AliMp::OtherPlaneType(fPlaneType); 
     130      240205 : }    
     131             : 
     132             : //______________________________________________________________________________
     133             : AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const
     134             : {
     135             : /// Return cathod type for given planeType
     136             : 
     137        1769 :   if ( fPlaneType == planeType ) return AliMp::kCath0;
     138         367 :   else                           return AliMp::kCath1;
     139         712 : }
     140             : 
     141             : //______________________________________________________________________________
     142             : AliMp::CathodType AliMpDetElement::GetCathodTypeFromManuId(Int_t manuId) const
     143             : {
     144             : /// Return cathod type for given manuId
     145             : 
     146             :   AliMp::PlaneType planeType = AliMp::kBendingPlane;
     147           0 :   if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) 
     148             :   {
     149             :     planeType = AliMp::kNonBendingPlane;
     150           0 :   }
     151           0 :   return GetCathodType(planeType);
     152             : }
     153             : 
     154             : //______________________________________________________________________________
     155             : AliMp::StationType AliMpDetElement::GetStationType() const
     156             : {
     157             : /// Return station type                                                      \n
     158             : /// Failure causes Fatal error - as AliMp::StationType has no possibility
     159             : /// to return undefined value
     160             : 
     161      667190 :   Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
     162      333595 :   if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
     163           0 :     AliFatal("Cannot return AliMp::StationType value.");
     164           0 :     return AliMp::kStation12;
     165             :   }  
     166             :   
     167      470887 :   if ( chamberId >=  0 && chamberId <=  3 )  return AliMp::kStation12;
     168      391558 :   if ( chamberId >=  4 && chamberId <=  9 )  return AliMp::kStation345;
     169        2096 :   if ( chamberId >= 10 && chamberId <= 13 )  return AliMp::kStationTrigger;
     170             : 
     171             :   // Should never get to this line
     172           0 :   AliFatal("Cannot return AliMp::StationType value.");
     173           0 :   return AliMp::kStation12;
     174      333595 : }
     175             : 
     176             : //______________________________________________________________________________
     177             : AliMq::Station12Type AliMpDetElement::GetStation12Type() const
     178             : {
     179             : /// Return station12 type                                                      \n
     180             : /// Failure causes Fatal error - as AliMp::Station12Type has no possibility
     181             : /// to return undefined value
     182             : 
     183       59256 :   Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
     184       29628 :   if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
     185           0 :     AliFatal("Cannot return AliMp::StationType value.");
     186           0 :     return AliMq::kNotSt12;
     187             :   }  
     188             :   
     189       41726 :   if ( chamberId ==  0 || chamberId ==  1 )  return AliMq::kStation1;
     190       30012 :   if ( chamberId ==  2 || chamberId ==  3 )  return AliMq::kStation2;
     191       10096 :   if ( chamberId >=  4 || chamberId <= 13 )  return AliMq::kNotSt12;
     192             : 
     193             :   // Should never get to this line
     194           0 :   AliFatal("Cannot return AliMp::StationType value.");
     195           0 :   return AliMq::kNotSt12;
     196       29628 : }
     197             : 
     198             : //______________________________________________________________________________
     199             : Int_t AliMpDetElement::GetNofBusPatches() const
     200             : {
     201             : /// Return the number of bus patches in this detection element
     202             : 
     203      782336 :   return fBusPatchIds.GetSize();
     204             : }  
     205             : 
     206             : //______________________________________________________________________________
     207             : Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
     208             : {
     209             : /// Return the index-th bus patch
     210             : 
     211      584088 :   if ( index < 0 || index >= GetNofBusPatches() ) {
     212           0 :     AliErrorStream()
     213           0 :       << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
     214           0 :     return 0;
     215             :   }     
     216             : 
     217      194696 :   return  fBusPatchIds.GetValue(index);
     218      194696 : }   
     219             : 
     220             : 
     221             : //______________________________________________________________________________
     222             : Bool_t  AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
     223             : {  
     224             : /// Return true if the bus patch Id is present
     225             : 
     226        5328 :   return fBusPatchIds.HasValue(busPatchId);; 
     227             : }
     228             : 
     229             : //______________________________________________________________________________
     230             : Int_t 
     231             : AliMpDetElement::NofChannelsInManu(Int_t manuId) const
     232             : {
     233             :   /// Return the number of channels in a given manu
     234             :   
     235      272080 :   Long_t uid = AliMpManuUID::BuildUniqueID(fId,manuId);
     236             :   
     237      136040 :   return (Int_t)(fManuList.GetValue(uid));
     238             : }
     239             : 
     240             : //______________________________________________________________________________
     241             : Bool_t 
     242             : AliMpDetElement::IsExistingChannel(Int_t manuId, Int_t manuChannel) const
     243             : {
     244             :   /// Whether or not the channel is a valid one (does not tell if it is
     245             :   /// connected or not
     246             :   
     247        5664 :   if ( NofChannelsInManu(manuId) > 0 && 
     248        1416 :        manuChannel >= 0 && 
     249        1416 :        manuChannel < AliMpConstants::ManuNofChannels() ) 
     250             :   {
     251        1416 :     return kTRUE;
     252             :   }
     253             :   else
     254             :   {
     255           0 :     return kFALSE;
     256             :   }
     257        1416 : }
     258             : 
     259             : //______________________________________________________________________________
     260             : Bool_t 
     261             : AliMpDetElement::IsConnectedChannel(Int_t manuId, Int_t manuChannel) const
     262             : {
     263             :   /// Whether or not the channel is a *connected* one (i.e. it is valid plus
     264             :   /// it corresponds to a real pad)
     265             :   
     266     8620184 :   return ( fTrackerChannels.GetValue(AliMpPadUID::BuildUniqueID(fId,manuId,manuChannel)) > 0 );
     267             : }
     268             : 
     269             : //______________________________________________________________________________
     270             : void
     271             : AliMpDetElement::AddManu(Int_t manuId)
     272             : {
     273             :   /// Fills the fManuList and fTrackerChannels
     274      100968 :   AliMp::StationType stationType = AliMpDEManager::GetStationType(fId);
     275             :   
     276       50484 :   if ( stationType == AliMp::kStationTrigger ) return;
     277             :     
     278       50484 :   AliCodeTimerAuto("",0)
     279             :   
     280      252420 :   AliDebug(1,Form("DE %4d Manu %4d",fId,manuId));
     281             : 
     282      353388 :   AliCodeTimerStart(Form("%s",AliMp::StationTypeName(stationType).Data()));
     283             :   
     284      100968 :   if ( fHVmanus.GetSize() == 0 ) 
     285             :   {
     286         468 :     fHVmanus.SetOwner(kTRUE); // to be 100% explicit
     287             :     
     288             :     // get the size, to avoid resizing when adding later on
     289             :     Int_t nmanus(0);
     290             :     
     291         468 :     AliMp::CathodType cathodes[] = { AliMp::kCath0, AliMp::kCath1 };
     292             :     
     293        2808 :     for ( Int_t i = 0; i < 2; ++i ) 
     294             :     {
     295             :       const AliMpVSegmentation* seg = 
     296        1872 :       AliMpSegmentation::Instance()->GetMpSegmentation(fId,cathodes[i]);
     297             :       
     298         936 :       TArrayI manus;
     299             :       
     300         936 :       seg->GetAllElectronicCardIDs(manus);
     301             : 
     302         936 :       nmanus += manus.GetSize();
     303         936 :     }
     304             :     
     305         468 :     fHVmanus.SetSize(nmanus);
     306         468 :   }
     307             :   
     308      100968 :   const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fId,manuId);
     309             :   
     310             :   Int_t n(0);
     311             :   
     312     6562920 :   for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) 
     313             :   {
     314     6461952 :     if ( seg->PadByLocation(manuId,i,kFALSE).IsValid() )
     315             :     {
     316     3192024 :       ++n;
     317     6384048 :       fTrackerChannels.Add((Long_t)AliMpPadUID::BuildUniqueID(fId,manuId,i),
     318             :                            (Long_t)1);
     319             :     }
     320             :   }
     321             :   
     322      100968 :   fManuList.Add(AliMpManuUID::BuildUniqueID(fId,manuId),(Long_t)n);
     323             : 
     324       50484 :   fNofChannels += n;
     325             :   
     326       50484 :   AliMpDCSNamer hvNamer("TRACKER");
     327             :   
     328       50484 :   Int_t index = hvNamer.ManuId2Index(fId,manuId);
     329             :                             
     330       50484 :   UInt_t hvuid = AliMpHVUID::BuildUniqueID(fId,index);
     331             :   
     332      100968 :   AliMpArrayI* hv = static_cast<AliMpArrayI*>(fHVmanus.GetValue(hvuid));
     333             :   
     334       50484 :   if (!hv)
     335             :   {
     336             :     Bool_t sort(kFALSE);
     337        3888 :     hv = new AliMpArrayI(sort);
     338        1944 :     fHVmanus.Add(hvuid,hv);
     339        1944 :   }
     340             :   
     341       50484 :   hv->Add(manuId,kFALSE);        
     342             :   
     343      353388 :   AliCodeTimerStop(Form("%s",AliMp::StationTypeName(stationType).Data()));
     344      100968 : }
     345             :   
     346             : //______________________________________________________________________________
     347             : const AliMpArrayI* 
     348             : AliMpDetElement::ManusForHV(Int_t hvIndex) const
     349             : {
     350             :   /// Return the list of manus sharing a hv channel
     351        2592 :   return static_cast<AliMpArrayI*>(fHVmanus.GetValue(AliMpHVUID::BuildUniqueID(fId,hvIndex)));
     352             : }
     353             : 
     354             : //______________________________________________________________________________
     355             : Int_t 
     356             : AliMpDetElement::NofManus() const
     357             : {
     358             :   /// Return the number of manus in this detection element
     359           0 :   return fManuList.GetSize();
     360             : }
     361             : 

Generated by: LCOV version 1.11