]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliTriggerScalersRecord.cxx
Added methods for finding a given module in the DDL map (F. Prino)
[u/mrichter/AliRoot.git] / STEER / AliTriggerScalersRecord.cxx
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
30 #include "AliLog.h"  
31 #include "AliTimeStamp.h"
32 #include "AliTriggerScalers.h"
33 #include "AliTriggerScalersRecord.h"
34
35 ClassImp( AliTriggerScalersRecord )
36 //_____________________________________________________________________________
37 AliTriggerScalersRecord::AliTriggerScalersRecord():
38   fTimestamp(),
39   fScalers(60)
40 {
41 }
42
43 //_____________________________________________________________________________
44 void AliTriggerScalersRecord::SetTimeStamp( UInt_t orbit, UInt_t period, 
45                                             UInt_t seconds, UInt_t microsecs )
46 {
47    fTimestamp.SetTimeStamp( orbit, period, seconds, microsecs );
48 }
49
50 //_____________________________________________________________________________
51 void AliTriggerScalersRecord::AddTriggerScalers( AliTriggerScalers* scaler ) 
52
53   fScalers.AddLast( scaler ); 
54   fScalers.Sort(); 
55 }
56
57 //_____________________________________________________________________________
58 void AliTriggerScalersRecord::AddTriggerScalers( UChar_t classIndex, UInt_t LOCB, UInt_t LOCA,        
59                                          UInt_t L1CB, UInt_t L1CA, UInt_t L2CB, UInt_t L2CA )
60 {
61     AddTriggerScalers( new AliTriggerScalers( classIndex, LOCB, LOCA, L1CB, L1CA, L2CB, L2CA ) );
62
63
64 //_____________________________________________________________________________
65 Int_t AliTriggerScalersRecord::Compare( const TObject* obj ) const
66 {
67   // Compare  timestamps
68   
69   return fTimestamp.Compare( &(((AliTriggerScalersRecord*)obj)->fTimestamp) );
70 }
71
72 //_____________________________________________________________________________
73 AliTriggerScalers* AliTriggerScalersRecord::GetTriggerScalersForClass( Int_t classmask )
74 {
75    // Find Trigger scaler with class ID = classmask using a binary search. 
76
77    Int_t   base, position, last, result = 0;
78    AliTriggerScalers *op2 = NULL;
79    
80    fScalers.Sort();
81    
82    base = 0;
83    last = fScalers.GetEntriesFast();
84
85    while (last >= base) {
86       result = 0;
87       position = (base+last) / 2;
88       op2 = (AliTriggerScalers *)fScalers.At(position);
89       if( op2 && op2->fClassIndex > classmask ) result = -1;
90       if( op2 && op2->fClassIndex < classmask ) result = 1;
91   
92       if (op2 && result == 0)
93          return op2;
94       if (!op2 || result < 0)
95          last = position-1;
96       else
97          base = position+1;
98       op2 = NULL;   
99    }
100    return op2;   
101 }
102                                       
103 //_____________________________________________________________________________
104 void AliTriggerScalersRecord::Print( const Option_t* ) const
105 {
106    // Print
107   cout << "Trigger Scalers Record: " << endl;
108   fTimestamp.Print();
109   for( Int_t i=0; i<fScalers.GetEntriesFast(); ++i ) 
110      ((AliTriggerScalers*)fScalers.At(i))->Print();
111 }