LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpRegionalTrigger.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 83 127 65.4 %
Date: 2016-06-14 17:26:59 Functions: 12 22 54.5 %

          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: AliMpTrigger.cxx,v 1.4 2006/05/24 13:58:52 ivana Exp $
      18             : 
      19             : //-----------------------------------------------------------------------------
      20             : // Class AliMpRegionalTrigger
      21             : // --------------------
      22             : // The class defines the properties of regional trigger crate
      23             : // Author: Ch. Finck, Subatech Nantes
      24             : //-----------------------------------------------------------------------------
      25             : 
      26             : #include "AliMpRegionalTrigger.h"
      27             : #include "AliMpExMapIterator.h"
      28             : #include "AliMpTriggerCrate.h"
      29             : #include "AliMpLocalBoard.h"
      30             : #include "AliMpConstants.h"
      31             : #include "AliMpFiles.h"
      32             : #include "AliMpDataStreams.h"
      33             : #include "AliMpHelper.h"
      34             : 
      35             : #include "AliLog.h"
      36             : 
      37             : #include <TArrayI.h>
      38             : #include <Riostream.h>
      39             : #include <TClass.h>
      40             : #include <TSystem.h>
      41             : 
      42             : 
      43             : /// \cond CLASSIMP
      44          18 : ClassImp(AliMpRegionalTrigger)
      45             : /// \endcond
      46             : 
      47             : 
      48             : //______________________________________________________________________________
      49             : AliMpRegionalTrigger::AliMpRegionalTrigger()
      50           3 :   : TObject(),
      51           3 :     fTriggerCrates(),
      52           3 :     fLocalBoardMap(),
      53           3 :     fLocalBoardArray(AliMpConstants::TotalNofLocalBoards()+1) // included non-notified boards
      54          15 : {
      55             :       /// Standard constructor
      56             :   
      57           3 :     fTriggerCrates.SetOwner(true);
      58           3 :     fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels());
      59           6 : }
      60             : 
      61             : //______________________________________________________________________________
      62             : AliMpRegionalTrigger::AliMpRegionalTrigger(const AliMpRegionalTrigger& rhs)
      63           0 :   : TObject(rhs),
      64           0 :     fTriggerCrates(rhs.fTriggerCrates),
      65           0 :     fLocalBoardMap(rhs.fLocalBoardMap),
      66           0 :     fLocalBoardArray(rhs.fLocalBoardArray)
      67           0 : {
      68             : /// Copy constructor
      69           0 : }  
      70             : 
      71             : //______________________________________________________________________________
      72             : AliMpRegionalTrigger::AliMpRegionalTrigger(TRootIOCtor* ioCtor)
      73           0 :   : TObject(),
      74           0 :     fTriggerCrates(ioCtor),
      75           0 :     fLocalBoardMap(ioCtor),
      76           0 :     fLocalBoardArray()
      77           0 : {
      78             : /// Constructor for I0
      79           0 : }
      80             : 
      81             : //______________________________________________________________________________
      82             : AliMpRegionalTrigger& AliMpRegionalTrigger::operator=(const AliMpRegionalTrigger& rhs)
      83             : {
      84             : /// Assignment operator
      85             : 
      86             :   // check assignment to self
      87           0 :   if (this == &rhs) return *this;
      88             : 
      89             :   // base class assignment
      90           0 :   TObject::operator=(rhs);
      91             : 
      92             :   // assignment operator
      93           0 :   fTriggerCrates = rhs.fTriggerCrates;
      94           0 :   fLocalBoardArray = rhs.fLocalBoardArray;
      95             :   
      96           0 :   return *this;
      97           0 : }  
      98             : 
      99             : //______________________________________________________________________________
     100             : AliMpRegionalTrigger::~AliMpRegionalTrigger()
     101           8 : {
     102             : /// Destructor
     103           4 : }
     104             : 
     105             : 
     106             : //
     107             : // private methods
     108             : //
     109             : 
     110             : //______________________________________________________________________________
     111             : Bool_t AliMpRegionalTrigger::ReadData(istream& in)
     112             : {
     113             : /// Load the Regional trigger from ASCII data files
     114             : /// and fill objects. Return false if reading fails
     115             :   
     116           6 :   if ( !in.good() ) return kFALSE;
     117             :    
     118           3 :   Int_t localBoardId = 0;
     119           3 :   TArrayI listInt;
     120           3 :   UShort_t crateId;
     121           3 :   Int_t nofBoards;
     122             :   Int_t localBoardIndex(0);
     123           3 :   char line[80];
     124             :  
     125             :   // decode file and store in objects
     126         153 :   while (!in.eof())
     127             :   {
     128          51 :     in.getline(line,80);
     129         102 :     if (!strlen(line)) break;
     130          48 :     TString crateName(AliMpHelper::Normalize(line));
     131             :     
     132          48 :     in.getline(line,80);    
     133          48 :     sscanf(line,"%hx",&crateId);
     134             : 
     135             :     // skip data which are not stored in mapping object
     136             :     // (mode, coincidence, mask)
     137          48 :     in.getline(line,80);
     138          48 :     in.getline(line,80);
     139          48 :     in.getline(line,80);
     140             :     
     141             :     // read # local board
     142          48 :     in.getline(line,80);
     143          48 :     sscanf(line,"%d",&nofBoards);
     144             :     
     145             :     AliMpTriggerCrate* crate 
     146         192 :       = (AliMpTriggerCrate*)(fTriggerCrates.GetValue(crateName.Data()));
     147          48 :     if (!crate)  {
     148         144 :       crate = new AliMpTriggerCrate(crateName.Data(), crateId);
     149         192 :       fTriggerCrates.Add(crateName.Data(), crate);
     150          48 :     }
     151             : 
     152          48 :     Char_t localBoardName[20];
     153          48 :     Int_t slot;
     154          48 :     UInt_t switches;
     155             :     
     156        1548 :     for ( Int_t i = 0; i < nofBoards; ++i ) 
     157             :     {
     158         726 :         in.getline(line,80);
     159         726 :         sscanf(line,"%02d %19s %03d %03x",&slot,localBoardName,&localBoardId,&switches);
     160        1452 :         AliMpLocalBoard* board = new AliMpLocalBoard(localBoardId, localBoardName, slot); 
     161         726 :         board->SetSwitch(switches);
     162        2178 :         board->SetCrate(crateName);
     163             :         
     164         726 :         if (localBoardId > AliMpConstants::NofLocalBoards())
     165          24 :           board->SetNotified(false); // copy cards
     166             :         
     167         726 :         crate->AddLocalBoard(localBoardId);
     168             :         
     169             :         // add  list of DEs for local board
     170         726 :         listInt.Reset();
     171         726 :         in.getline(line,80);
     172         726 :         TString tmp(AliMpHelper::Normalize(line));
     173        1452 :         AliMpHelper::DecodeName(tmp,' ',listInt);
     174        7116 :         for (Int_t ii = 0; ii < listInt.GetSize(); ++ii) { 
     175       11280 :           if ( listInt[ii] ) board->AddDE(listInt[ii]);
     176             :         }  
     177             :          
     178             :         // set copy number and transverse connector
     179         726 :         in.getline(line,80);
     180         726 :         TString tmp1 = AliMpHelper::Normalize(line);
     181        1452 :         AliMpHelper::DecodeName(tmp1,' ',listInt);
     182             :         
     183        1452 :         board->SetInputXfrom(listInt[0]);
     184        1452 :         board->SetInputXto(listInt[1]);
     185             :         
     186        1452 :         board->SetInputYfrom(listInt[2]);
     187        1452 :         board->SetInputYto(listInt[3]);
     188             :         
     189        1452 :         board->SetTC(listInt[4]);
     190             :         
     191             :         // add local board into array
     192         726 :         fLocalBoardArray.AddAt(board,localBoardIndex);
     193         726 :         fLocalBoardMap.Add(board->GetId(),board);
     194             :       
     195         726 :       ++localBoardIndex;
     196         726 :     }
     197          48 :   }
     198             : 
     199          15 :   AliDebug(1,Form("%d trigger crate created",fTriggerCrates.GetSize()));
     200          15 :   AliDebug(1,Form("%d local board added to the map",fLocalBoardMap.GetSize()));
     201          15 :   AliDebug(1,Form("%d local board referenced from the array",fLocalBoardArray.GetLast()+1));
     202             :   
     203             :   return kTRUE;
     204           6 : }  
     205             : 
     206             : //
     207             : // public methods
     208             : //
     209             : 
     210             : //______________________________________________________________________________
     211             : Bool_t AliMpRegionalTrigger::ReadData(const TString& fileName)
     212             : {
     213             : /// Load the Regional trigger from ASCII data files
     214             : /// and return its instance
     215             :     
     216           0 :     AliDebugStream(2) << "Read data from file " << fileName.Data() << endl;
     217             :     
     218           0 :     TString inFileName(gSystem->ExpandPathName(fileName.Data()));
     219           0 :     ifstream inFile(inFileName.Data(), ios::in);
     220           0 :     if ( ! inFile.good() ) {
     221           0 :       AliErrorStream()
     222           0 :          << "Local Trigger Board Mapping File " << inFileName.Data() << " not found bordel de merde" << endl;
     223           0 :       return kFALSE;
     224             :     }
     225             :     
     226           0 :     return ReadData(inFile);  
     227           0 : }
     228             : 
     229             : //______________________________________________________________________________
     230             : Bool_t AliMpRegionalTrigger::ReadData(const AliMpDataStreams& dataStreams)
     231             : {
     232             : /// Load the Regional trigger from ASCII data files
     233             : /// and return its instance
     234             :     
     235           6 :     AliDebugStream(2) << "Read data from stream " << endl;
     236             :     istream& in
     237           6 :        = dataStreams.
     238           3 :            CreateDataStream(AliMpFiles::LocalTriggerBoardMapping());
     239             :            
     240           3 :     Bool_t result = ReadData(in);
     241             :     
     242           6 :     delete &in;
     243           3 :     return result;        
     244           0 : }
     245             : 
     246             : //______________________________________________________________________________
     247             : AliMpLocalBoard* AliMpRegionalTrigger::FindLocalBoard(Int_t localBoardId, 
     248             :                                                       Bool_t warn) const {
     249             :     /// Return local board with given Id
     250             : 
     251             :     AliMpLocalBoard* localBoard
     252      116441 :       = static_cast<AliMpLocalBoard*>(fLocalBoardMap.GetValue(localBoardId));
     253             :     
     254      116441 :     if ( ! localBoard && warn ) {
     255           0 :         AliErrorStream()
     256           0 :         << "Loacl board with localBoardId = " << localBoardId << " not found." << endl;
     257           0 :     }      
     258             : 
     259      116441 :     return localBoard;
     260             : }
     261             : 
     262             : //______________________________________________________________________________
     263             : AliMpTriggerCrate* AliMpRegionalTrigger::FindTriggerCrate(TString name, 
     264             :                                                           Bool_t warn) const  {
     265             :     /// Return trigger crate with given name
     266             : 
     267             :     AliMpTriggerCrate* crate
     268         256 :     = (AliMpTriggerCrate*) fTriggerCrates.GetValue(name.Data());
     269             : 
     270         128 :     if ( ! crate && warn ) {
     271           0 :         AliErrorStream()
     272           0 :         << "Trigger crate with name = " << name.Data() << " not defined." << endl;
     273           0 :     }
     274             : 
     275         128 :     return crate;
     276           0 : }
     277             : 
     278             : //______________________________________________________________________________
     279             : Int_t AliMpRegionalTrigger::GetNofTriggerCrates() const 
     280             : { 
     281             :     /// Return number of trigger crates
     282             : 
     283          16 :     return fTriggerCrates.GetSize(); 
     284             : }
     285             : 
     286             : //______________________________________________________________________________
     287             : Int_t AliMpRegionalTrigger::GetNofLocalBoards() const
     288             : { 
     289             :     /// Return number of local boards
     290             :     
     291           0 :     return fLocalBoardArray.GetLast()+1; 
     292             : }
     293             : 
     294             : //______________________________________________________________________________
     295             : TIterator* 
     296             : AliMpRegionalTrigger::CreateCrateIterator() const
     297             : {
     298             :   /// Create iterator over crates
     299             : 
     300          18 :   return fTriggerCrates.CreateIterator();
     301             : }
     302             : 
     303             : //______________________________________________________________________________
     304             : TIterator* 
     305             : AliMpRegionalTrigger::CreateLocalBoardIterator() const
     306             : {
     307             :   /// Create iterator over local boards
     308             : 
     309         864 :   return fLocalBoardArray.MakeIterator();
     310             : }
     311             : 
     312             : //______________________________________________________________________________
     313             : Int_t 
     314             : AliMpRegionalTrigger::LocalBoardId(Int_t index) const
     315             : {
     316             :   /// Return local board Id for the local boards with a given index
     317             : 
     318           0 :   AliMpLocalBoard* lb = static_cast<AliMpLocalBoard*>(fLocalBoardArray.At(index));
     319           0 :   if (lb)
     320             :   {
     321           0 :     return lb->GetId();
     322             :   }
     323           0 :   AliError(Form("Could not get local board at index %d",index));
     324           0 :   return -1;
     325           0 : }
     326             : 
     327             : //______________________________________________________________________________
     328             : void AliMpRegionalTrigger::SetTriggerCratesOwner(Bool_t owner)
     329             : {
     330             :   /// Set ownership to trigger crates
     331             : 
     332           0 :   fTriggerCrates.SetOwner(owner);
     333           0 : }  

Generated by: LCOV version 1.11