LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpBusPatch.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 61 107 57.0 %
Date: 2016-06-14 17:26:59 Functions: 14 21 66.7 %

          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: AliMpBusPatch.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
      18             : 
      19             : //-----------------------------------------------------------------------------
      20             : // Class AliMpBusPatch
      21             : // --------------------
      22             : // The class defines the properties of BusPatch
      23             : // Author: Ivana Hrivnacova, IPN Orsay
      24             : //-----------------------------------------------------------------------------
      25             : 
      26             : #include "AliMpBusPatch.h"
      27             : 
      28             : #include "AliDAQ.h"
      29             : #include "AliMpConstants.h"
      30             : #include "AliMpDEManager.h"
      31             : #include "AliMpSegmentation.h"
      32             : #include "AliMpSlat.h"
      33             : #include "AliMpPCB.h"
      34             : #include "AliMpMotifPosition.h"
      35             : 
      36             : #include "AliLog.h"
      37             : 
      38             : #include <Riostream.h>
      39             : 
      40             : using std::cout;
      41             : using std::endl;
      42             : /// \cond CLASSIMP
      43          18 : ClassImp(AliMpBusPatch)
      44             : /// \endcond
      45             : 
      46             : const Int_t  AliMpBusPatch::fgkOffset = 100;
      47             : //
      48             : // static methods
      49             : //
      50             : 
      51             : //____________________________________________________________________
      52             : Int_t AliMpBusPatch::GetGlobalBusID(Int_t localID, Int_t ddlID)
      53             : {
      54             :   /// return global bus id from local bus and ddl id
      55             : 
      56         384 :   return ddlID*fgkOffset + localID;
      57             : 
      58             : }
      59             : //____________________________________________________________________
      60             : Int_t AliMpBusPatch::GetLocalBusID(Int_t globalID, Int_t ddlID)
      61             : {
      62             :   /// return local bus id from local bus id
      63             : 
      64           0 :   return globalID - ddlID*fgkOffset;
      65             : 
      66             : }
      67             : 
      68             : //______________________________________________________________________________
      69             : AliMpBusPatch::AliMpBusPatch(Int_t id, Int_t detElemId, Int_t ddlId)
      70        2664 :   : TObject(),
      71        2664 :     fId(id),
      72        2664 :     fDEId(detElemId),
      73        2664 :     fDdlId(ddlId),
      74        2664 :     fManus(false),
      75        2664 :     fNofManusPerModule(false),
      76        2664 :     fCableLength(-1),
      77        2664 :     fCableLabel(),
      78        2664 :     fTranslatorLabel(),
      79        2664 :     fFrtId(0)
      80       13320 : {
      81             : /// Standard constructor
      82        5328 : }
      83             : 
      84             : //______________________________________________________________________________
      85             : AliMpBusPatch::AliMpBusPatch(TRootIOCtor* /*ioCtor*/)
      86           0 :   : TObject(),
      87           0 :     fId(),
      88           0 :     fDEId(),
      89           0 :     fDdlId(),
      90           0 :     fManus(false),
      91           0 :     fNofManusPerModule(false),
      92           0 :     fCableLength(-1),
      93           0 :     fCableLabel(),
      94           0 :     fTranslatorLabel(),
      95           0 :     fFrtId(0)
      96           0 : {
      97             : /// Root IO constructor
      98           0 : }
      99             : 
     100             : //______________________________________________________________________________
     101             : AliMpBusPatch::~AliMpBusPatch()
     102       10656 : {
     103             : /// Destructor
     104        5328 : }
     105             : 
     106             : //
     107             : // public methods
     108             : //
     109             : 
     110             : //______________________________________________________________________________
     111             : Bool_t AliMpBusPatch::AddManu(Int_t manuId)
     112             : {
     113             : /// Add detection element with given detElemId.
     114             : /// Return true if the detection element was added
     115             : 
     116      101544 :   if ( HasManu(manuId) ) {
     117           0 :     AliWarningStream() 
     118           0 :       << "Manu with manuId=" << manuId << " already present."
     119           0 :       << endl;
     120           0 :     return false;
     121             :   }    
     122             : 
     123       50772 :   fManus.Add(manuId);
     124       50772 :   return true;
     125       50772 : }   
     126             : 
     127             : //______________________________________________________________________________
     128             : Bool_t AliMpBusPatch::SetNofManusPerModule(Int_t manuNumber)
     129             : {
     130             : /// Set the number of manus per patch module (PCB):
     131             : /// - for stations 1 all manus are connected to one PCB,
     132             : /// - for stations 2 there maximum two PCBs per buspatch,
     133             : /// - for slat stations there are maximum three PCBs per buspatch
     134             : 
     135        5328 :   if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation1) {
     136             : 
     137             :     // simply fill the number of manus, no bridge for station 1
     138             :        
     139         576 :     fNofManusPerModule.Add(GetNofManus());
     140         576 :     return true;
     141             :   }
     142             : 
     143        2088 :  if ( AliMpDEManager::GetStation12Type(fDEId) == AliMq::kStation2) {
     144             : 
     145             :     // there is max two patch modules per buspatch
     146             :        
     147         576 :     fNofManusPerModule.Add(manuNumber);
     148         576 :     if (manuNumber != GetNofManus())
     149         528 :         fNofManusPerModule.Add(GetNofManus() - manuNumber);
     150             : 
     151         576 :     return true;
     152             :   }
     153             : 
     154        1512 :   if ( AliMpDEManager::GetStationType(fDEId) == AliMp::kStation345 ) {
     155             :   
     156             :     const AliMpSlat* kSlat0 
     157        1512 :         = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath0);
     158             : 
     159             :     const AliMpSlat* kSlat1 
     160        1512 :         = AliMpSegmentation::Instance()->GetSlat(fDEId, AliMp::kCath1);
     161             :        
     162             :     Int_t iPcb = 0;
     163             :     Int_t iPcbPrev = -1;
     164             :     Int_t manuPerPcb = 0;
     165             : 
     166             :     Double_t x = 0.;
     167             :     Double_t length = 0.;
     168             : 
     169             :     // Loop over manu
     170       62592 :     for (Int_t iManu = 0; iManu < GetNofManus(); ++iManu) {
     171       29028 :       Int_t manuId = GetManuId(iManu);
     172       29028 :       AliMpMotifPosition* motifPos0 = kSlat0->FindMotifPosition(manuId);
     173       29028 :       AliMpMotifPosition* motifPos1 = kSlat1->FindMotifPosition(manuId);       
     174             :       
     175       29028 :       if ( !motifPos0 && !motifPos1 ) {
     176             :         // should never happen
     177           0 :         AliErrorStream() 
     178           0 :           << "Motif position for manuId = " << manuId << "not found" << endl;
     179           0 :         return false;
     180             :       }
     181             : 
     182             :       // find PCB id
     183       29028 :       if ( motifPos0 ) {
     184       14514 :         x = motifPos0->GetPositionX();
     185       14514 :         length = kSlat0->GetPCB(0)->DX()*2.;
     186       14514 :       }
     187       29028 :       if ( motifPos1 ) {
     188       14514 :         x = motifPos1->GetPositionX();
     189       14514 :         length = kSlat1->GetPCB(0)->DX()*2.;
     190       14514 :       }
     191             :       
     192       29028 :       iPcb = Int_t(x/length + AliMpConstants::LengthTolerance());
     193             : 
     194             :       // check when going to next PCB
     195       29028 :       if ( iPcb == iPcbPrev )
     196       25356 :         manuPerPcb++;
     197        3672 :       else if ( iPcbPrev != -1 ) {
     198             :         //vec.Set(vec.GetSize()+1);
     199             :         //vec[vec.GetSize()-1] = manuPerPcb+1;
     200        2160 :         fNofManusPerModule.Add(manuPerPcb+1);
     201             :         manuPerPcb = 0;
     202        2160 :       }
     203             :       iPcbPrev = iPcb;
     204       29028 :     }
     205             :    
     206             :     // store last PCB
     207             :     //vec.Set(vec.GetSize()+1);
     208             :     //vec[vec.GetSize()-1] = manuPerPcb+1;
     209        1512 :     fNofManusPerModule.Add(manuPerPcb+1);
     210        1512 :     return true;  
     211             :   } 
     212             :   
     213           0 :   return false; 
     214        2664 : }     
     215             : 
     216             : //______________________________________________________________________________
     217             : void  AliMpBusPatch::RevertReadout()
     218             : {
     219             : /// Revert order of manus
     220             : 
     221         336 :   fManus.Revert();
     222         168 : }
     223             : 
     224             : //______________________________________________________________________________
     225             : void  AliMpBusPatch::ResetReadout()
     226             : {
     227             : /// Revert order of manus
     228             : 
     229          48 :   fManus.Reset();
     230          24 : }
     231             : 
     232             : //______________________________________________________________________________
     233             : Int_t AliMpBusPatch::GetNofManus() const
     234             : {  
     235             : /// Return the number of detection elements connected to this DDL
     236             : 
     237      418760 :   return fManus.GetSize(); 
     238             : }
     239             : 
     240             : //______________________________________________________________________________
     241             : Int_t  AliMpBusPatch::GetManuId(Int_t index) const
     242             : {  
     243             : /// Return the detection element by index (in loop)
     244             : 
     245      394616 :   return fManus.GetValue(index); 
     246             : }
     247             : 
     248             : //______________________________________________________________________________
     249             : Bool_t  AliMpBusPatch::HasManu(Int_t manuId) const
     250             : {  
     251             : /// Return true if bus patch has manu with given manuId
     252             : 
     253      101544 :   return fManus.HasValue(manuId); 
     254             : }
     255             : 
     256             : //______________________________________________________________________________
     257             : Int_t  AliMpBusPatch::GetNofPatchModules() const
     258             : {
     259             : /// Return the number of patch modules (PCB) connected to this bus patch.
     260             : 
     261           0 :   return fNofManusPerModule.GetSize();
     262             : }  
     263             :   
     264             : //______________________________________________________________________________
     265             : TString
     266             : AliMpBusPatch::GetFRTPosition() const
     267             : {
     268             :   /// Return CRXX-Y-Z where XX is the Crocus number, Y the FRT number
     269             :   /// and Z the local bus patch number.
     270           0 :   return Form("CR%2d-%d-%d",fDdlId,fFrtId+1,GetLocalBusID(fId,fDdlId));
     271             : }
     272             : 
     273             : //______________________________________________________________________________
     274             : Int_t  AliMpBusPatch::GetNofManusPerModule(Int_t patchModule) const
     275             : {
     276             : /// Return the number of manus per patch module (PCB)
     277             : 
     278           0 :   if ( patchModule < 0 || patchModule >= GetNofPatchModules() ) {
     279           0 :     AliErrorStream() << "Invalid patch module number = " << patchModule << endl;
     280           0 :     return 0;
     281             :   }
     282             :   
     283           0 :   return fNofManusPerModule.GetValue(patchModule);
     284           0 : }     
     285             : 
     286             : //______________________________________________________________________________
     287             : void 
     288             : AliMpBusPatch::Print(Option_t* opt) const
     289             : {
     290             :   /// Printout
     291             :   
     292           0 :   cout << Form("BusPatch %04d DDL %d : %s <> %s / %s",
     293           0 :                fId,
     294           0 :                AliDAQ::DdlID("MUONTRK",fDdlId),
     295           0 :                GetFRTPosition().Data(),
     296           0 :                fCableLabel.Data(),
     297           0 :                fTranslatorLabel.Data()) << endl;
     298             : 
     299           0 :   TString sopt(opt);
     300           0 :   sopt.ToUpper();
     301             :   
     302           0 :   if ( sopt.Contains("FULL") ) 
     303             :   {
     304           0 :     cout << Form("Nof of PCBs (i.e. patch modules) = %d",fNofManusPerModule.GetSize()) << endl;
     305             :     
     306           0 :     for ( Int_t i = 0; i < fNofManusPerModule.GetSize(); ++i ) 
     307             :     {
     308           0 :       cout << Form("\t\t %d manus in patch module %d",fNofManusPerModule.GetValue(i),i) << endl;
     309             :     }
     310             :     
     311           0 :     if ( sopt.Contains("MANU") )
     312             :     {
     313           0 :       cout << "Manus of that buspatch=" << endl;
     314             :       
     315           0 :       for ( Int_t i = 0; i < fManus.GetSize(); ++i ) 
     316             :       {
     317           0 :         cout << Form("%4d,",fManus.GetValue(i));
     318             :       }
     319           0 :       cout << endl;
     320             :     }
     321             :   }
     322             :   
     323             : //  Int_t        fId;     ///< Identifier (unique)
     324             : //  Int_t        fDEId;   ///< Detection element to which this bus patch is connected
     325             : //  Int_t        fDdlId;  ///< DDL to which this bus patch is connected
     326             : //  AliMpArrayI  fManus;  ///< Manu Ids connected to this bus patch
     327             : //  AliMpArrayI  fNofManusPerModule; ///< Nof Manus per patch modules (PCBs)
     328             : //  Float_t      fCableLength;       ///< length of the buspatch cable
     329             : //  TString      fCableLabel;        ///< label of the buspatch cable
     330             : //  TString      fTranslatorLabel;   ///< label of the translator board
     331             : //  Int_t        fFrtId;               ///< FRT Ids connected to this bus patch
     332             :   
     333           0 : }

Generated by: LCOV version 1.11