LCOV - code coverage report
Current view: top level - STEER/STEERBase - AliTriggerScalersRecord.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 44 15.9 %
Date: 2016-06-14 17:26:59 Functions: 3 11 27.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: AliTriggerScalersRecord.cxx 22322 2007-11-22 11:43:14Z cvetan $ */
      17             : 
      18             : ///////////////////////////////////////////////////////////////////////////////
      19             : //
      20             : // Class to define the ALICE Trigger Scalers Record 
      21             : //
      22             : // Each record consists of 1 time stamp (4 words)  (AliTimeStamp)
      23             : // and an array with the scalers (AliTriggerScalers) for each trigger class 
      24             : // in partition  
      25             : //
      26             : //////////////////////////////////////////////////////////////////////////////
      27             : 
      28             : #include <Riostream.h>
      29             : #include <TObjArray.h>
      30             : #include "AliLog.h"  
      31             : #include "AliTriggerScalers.h"
      32             : #include "AliTriggerScalersRecord.h"
      33             : 
      34             : using std::endl;
      35             : using std::cout;
      36         176 : ClassImp( AliTriggerScalersRecord )
      37             : //_____________________________________________________________________________
      38           2 : AliTriggerScalersRecord::AliTriggerScalersRecord():
      39           2 :   fTimestamp(),
      40           2 :   fScalers(),
      41           2 :   fTimeGroup(0)
      42          10 : {
      43             :  //Default constructor
      44           4 : }
      45             : 
      46             : //_____________________________________________________________________________
      47             : void AliTriggerScalersRecord::SetTimeStamp( UInt_t orbit, UInt_t period, 
      48             :                                             UInt_t seconds, UInt_t microsecs )
      49             : {
      50           0 :    fTimestamp.SetTimeStamp( orbit, period, seconds, microsecs );
      51           0 : }
      52             : 
      53             : //_____________________________________________________________________________
      54             : void AliTriggerScalersRecord::AddTriggerScalers( AliTriggerScalers* scaler ) 
      55             : { 
      56           0 :   fScalers.AddLast( scaler ); 
      57           0 :   fScalers.Sort(); 
      58           0 : }
      59             : 
      60             : //_____________________________________________________________________________
      61             : void AliTriggerScalersRecord::AddTriggerScalers( UChar_t classIndex, UInt_t LOCB, UInt_t LOCA,        
      62             :                                          UInt_t L1CB, UInt_t L1CA, UInt_t L2CB, UInt_t L2CA )
      63             : {
      64           0 :     AddTriggerScalers( new AliTriggerScalers( classIndex, LOCB, LOCA, L1CB, L1CA, L2CB, L2CA ) );
      65           0 :     fScalers.Sort();
      66           0 : } 
      67             : //_____________________________________________________________________________
      68             : void AliTriggerScalersRecord::AddTriggerScalers( UChar_t classIndex, UInt_t LOCB, UInt_t LOCA,        
      69             :                                          UInt_t L1CB, UInt_t L1CA, UInt_t L2CB, UInt_t L2CA,
      70             :                                          UInt_t LMCB, UInt_t LMCA)
      71             : {
      72           0 :     AddTriggerScalers( new AliTriggerScalers( classIndex, LOCB, LOCA, L1CB, L1CA, L2CB, L2CA, LMCB, LMCA ) );
      73           0 :     fScalers.Sort();
      74           0 : } 
      75             : 
      76             : //_____________________________________________________________________________
      77             : Int_t AliTriggerScalersRecord::Compare( const TObject* obj ) const
      78             : {
      79             :   // Compare  timestamps
      80             :   
      81           0 :   return fTimestamp.Compare( &(((AliTriggerScalersRecord*)obj)->fTimestamp) );
      82             : }
      83             : //_____________________________________________________________________________
      84             : const AliTriggerScalers* AliTriggerScalersRecord::GetTriggerScalersForClass( const Int_t classindex ) const
      85             : {
      86             :    // Find Trigger scaler with class ID = classindex using a brutal force 
      87             : 
      88             :    Int_t   position, last;
      89             :    AliTriggerScalers *op2 = 0;
      90             :    position = 0;
      91           0 :    last = fScalers.GetEntriesFast();
      92           0 :    while (position < last) {
      93           0 :       op2 = (AliTriggerScalers *)fScalers.At(position);
      94           0 :       if( op2 && (op2->GetClassIndex() == classindex )) break;
      95             :       op2=0;
      96           0 :       position++;
      97             :    }
      98           0 :    return op2;   
      99             : }
     100             : 
     101             : //_____________________________________________________________________________
     102             : AliTriggerScalers* AliTriggerScalersRecord::GetTriggerScalersForClassBinary( const Int_t classindex )
     103             : {
     104             :    // Find Trigger scaler with class ID = classindex using a binary search. 
     105             : 
     106             :    Int_t   base, position, last, result = 0;
     107             :    AliTriggerScalers *op2 = NULL;
     108             :    
     109           0 :    fScalers.Sort(); 
     110             :    
     111             :    base = 0;
     112           0 :    last = fScalers.GetEntriesFast();
     113             : 
     114           0 :    while (last >= base) {
     115             :       result = 0;
     116           0 :       position = (base+last) / 2;
     117           0 :       op2 = (AliTriggerScalers *)fScalers.At(position);
     118           0 :       if( op2 && op2->GetClassIndex() > classindex ) result = -1;
     119           0 :       if( op2 && op2->GetClassIndex() < classindex ) result = 1;
     120             :   
     121           0 :       if (op2 && result == 0)
     122           0 :          return op2;
     123           0 :       if (!op2 || result < 0)
     124           0 :          last = position-1;
     125             :       else
     126           0 :          base = position+1;
     127             :       op2 = NULL;   
     128             :    }
     129           0 :    return op2;   
     130           0 : }
     131             :                                       
     132             : //_____________________________________________________________________________
     133             : void AliTriggerScalersRecord::Print( const Option_t* ) const
     134             : {
     135             :    // Print
     136           0 :   cout << "Trigger Scalers Record, time group: "<< fTimeGroup << endl;
     137           0 :   fTimestamp.Print();
     138           0 :   for( Int_t i=0; i<fScalers.GetEntriesFast(); ++i ) 
     139           0 :      ((AliTriggerScalers*)fScalers.At(i))->Print();
     140           0 : }

Generated by: LCOV version 1.11