Classes in order to retrieve and manipulate the CTP scaler records (Ernesto)
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 29 Jan 2008 17:20:26 +0000 (17:20 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 29 Jan 2008 17:20:26 +0000 (17:20 +0000)
13 files changed:
GRP/CTP/xcounters.txt
STEER/AliTimeStamp.cxx [new file with mode: 0644]
STEER/AliTimeStamp.h [new file with mode: 0644]
STEER/AliTriggerRunScalers.cxx [new file with mode: 0644]
STEER/AliTriggerRunScalers.h [new file with mode: 0644]
STEER/AliTriggerScalers.cxx [new file with mode: 0644]
STEER/AliTriggerScalers.h [new file with mode: 0644]
STEER/AliTriggerScalersRecord.cxx [new file with mode: 0644]
STEER/AliTriggerScalersRecord.h [new file with mode: 0644]
STEER/STEERBaseLinkDef.h
STEER/STEERLinkDef.h
STEER/libSTEER.pkg
STEER/libSTEERBase.pkg

index e52fa1f..62fbc4e 100644 (file)
@@ -6,15 +6,15 @@
 #                        1st word =  ORBIT(24 bits)
 #                        2nd word = Period Counter (28 bit)
 #                        3rd word = seconds (32 bits) from epoch
-                         4th word = microsecs (32 bits)
+#                        4th word = microsecs (32 bits)
 #  other lines = 6 words of counters (L0 before,L0 after, ....)
-ver1.0
+1
 1111 3 1 3 5 
 1 1 16000  20 
 1000 100 100 100 100 100
 1000 100  50  50  50  50
 1000  88  88  60  60  30
-11363 16060 33 
+1 11363 16060 33 
 6000000 60000 60000 60000 60000 60000
 6000000 60000 30000 30000 30000 30000
 6000000 40000 40000 35000 35000 31000
diff --git a/STEER/AliTimeStamp.cxx b/STEER/AliTimeStamp.cxx
new file mode 100644 (file)
index 0000000..cd07903
--- /dev/null
@@ -0,0 +1,110 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id: AliTimeStamp.cxx 22322 2007-11-22 11:43:14Z cvetan $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//  Class to define Event Timestamp from : 
+//
+//               Orbit
+//               Period counter
+//               Seconds    |
+//                  +       |   <===> Bunch cross 
+//               Microsecs  | 
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
+
+
+#include "TObject.h"
+
+#include "AliLog.h"   
+#include "AliTimeStamp.h"
+
+ClassImp(AliTimeStamp)
+   
+//_____________________________________________________________________________
+   
+const Int_t AliTimeStamp::fNanosecPerBC = 25;   // nanosecs per bunch cross
+   
+//_____________________________________________________________________________
+AliTimeStamp::AliTimeStamp():
+  fOrbit(0),        
+  fPeriod(0),        
+  fBunchCross(0)
+{
+}     
+
+//_____________________________________________________________________________
+AliTimeStamp::AliTimeStamp( UInt_t orbit, UInt_t period, 
+                            ULong64_t bunchcross ):
+  fOrbit(orbit),        
+  fPeriod(period),        
+  fBunchCross( bunchcross )
+{
+}
+//_____________________________________________________________________________
+AliTimeStamp::AliTimeStamp( UInt_t orbit, UInt_t period, 
+                            UInt_t seconds, UInt_t microsecs):
+  fOrbit(orbit),        
+  fPeriod(period),        
+  fBunchCross( (ULong64_t)((seconds*1000000.+microsecs)*1000./fNanosecPerBC+0.5) )
+{
+}     
+//_____________________________________________________________________________
+void AliTimeStamp::SetTimeStamp( UInt_t orbit, UInt_t period, 
+                            ULong64_t bunchcross )
+{
+  fOrbit = orbit;        
+  fPeriod = period;  
+  fBunchCross = bunchcross;
+}
+//_____________________________________________________________________________
+void AliTimeStamp::SetTimeStamp( UInt_t orbit, UInt_t period, 
+                            UInt_t seconds, UInt_t microsecs )
+{
+  fOrbit = orbit;        
+  fPeriod = period;  
+  fBunchCross = (ULong64_t)((seconds*1000000.+microsecs)*1000./fNanosecPerBC+0.5);
+}
+                            
+     
+
+//_____________________________________________________________________________
+Int_t AliTimeStamp::Compare( const TObject* obj ) const
+{
+  // Compare 
+  
+  if( fOrbit < ((AliTimeStamp*)obj)->fOrbit ) return -1;
+  if( fOrbit > ((AliTimeStamp*)obj)->fOrbit ) return 1;
+  if( fPeriod < ((AliTimeStamp*)obj)->fPeriod ) return -1;
+  if( fPeriod > ((AliTimeStamp*)obj)->fPeriod ) return 1;
+  if( fBunchCross < ((AliTimeStamp*)obj)->fBunchCross ) return -1;
+  if( fBunchCross > ((AliTimeStamp*)obj)->fBunchCross ) return 1;
+  return 0;
+}
+
+//_____________________________________________________________________________
+void AliTimeStamp::Print( const Option_t* ) const
+{
+   // Print
+  cout << "Timestamp: " << endl;
+  cout << "  Orbit: " << fOrbit << " Period: " << fPeriod << endl;
+  cout << "  Bunch Cross: " << GetBunchCross() << endl;
+  cout << "  Seconds: " << GetSeconds() << " MicroSecs: " << GetMicroSecs() << endl;
+}
diff --git a/STEER/AliTimeStamp.h b/STEER/AliTimeStamp.h
new file mode 100644 (file)
index 0000000..b01d01f
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef ALITIMESTAMP_H
+#define ALITIMESTAMP_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliTimeStamp.h 22322 2007-11-22 11:43:14Z cvetan $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//  Class to define Event Timestamp from : 
+//
+//               Orbit
+//               Period counter
+//               Seconds    |
+//                  +       | ===> Bunch cross 
+//               Microsecs  | 
+//
+//////////////////////////////////////////////////////////////////////////////
+#include <cmath>
+
+class TObject;
+
+class AliTimeStamp : public TObject {
+
+public:
+                         AliTimeStamp();
+                         AliTimeStamp( UInt_t orbit, UInt_t period, ULong64_t bunchCross );   
+                         AliTimeStamp( UInt_t orbit, UInt_t period, 
+                                       UInt_t seconds, UInt_t microsecs );   
+              virtual   ~AliTimeStamp() {}
+              
+      // Getters
+               UInt_t    GetOrbit()      const { return fOrbit;     }        
+               UInt_t    GetPeriod()     const { return fPeriod;    }       
+            ULong64_t    GetBunchCross() const { return fBunchCross; }  
+               UInt_t    GetSeconds()    const { return (UInt_t)(fBunchCross/1000000000.*fNanosecPerBC);   }      
+               UInt_t    GetMicroSecs()  const { return (UInt_t)(fmod(fBunchCross *fNanosecPerBC, 1000000000.)/1000 ); }     
+       virtual Bool_t    IsSortable()    const { return kTRUE; }
+     // Setters
+                 void    SetTimeStamp( UInt_t orbit, UInt_t period, ULong64_t bunchcross );
+                 void    SetTimeStamp( UInt_t orbit, UInt_t period, 
+                                       UInt_t seconds, UInt_t microsecs );
+              
+              
+        virtual Int_t    Compare( const TObject* obj ) const;
+         virtual void    Print( const Option_t* opt ="" ) const;
+                               
+   static const Int_t    fNanosecPerBC;   //! nanosecs per bunch cross
+              
+protected:
+              UInt_t    fOrbit;         // Orbit
+              UInt_t    fPeriod;        // Period counter
+           ULong64_t    fBunchCross;    // Bunch Cross 
+//              UInt_t    fSeconds;       // Seconds 
+//              UInt_t    fMicroSecs;     // Microsecs  
+                         
+private:                         
+                         AliTimeStamp( const AliTimeStamp &timestamp );
+         AliTimeStamp&   operator=(const AliTimeStamp& clus);
+
+   ClassDef( AliTimeStamp, 1 )  // Define a timestamp
+};                                                                         
+
+
+#endif
diff --git a/STEER/AliTriggerRunScalers.cxx b/STEER/AliTriggerRunScalers.cxx
new file mode 100644 (file)
index 0000000..d5a9bb3
--- /dev/null
@@ -0,0 +1,231 @@
+ /**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id: AliTriggerRunScalers.cxx 22322 2007-11-22 11:43:14Z cvetan $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Class to define the ALICE Trigger Scalers Record per Run.
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
+#include <TObject.h>
+#include <TClass.h>
+#include <TArrayC.h>
+#include <TSystem.h>
+#include <TObjString.h>
+#include <TObjArray.h>
+#include <TSystem.h>
+#include <TFile.h>
+
+#include "AliLog.h"  
+#include "AliTimeStamp.h"
+#include "AliTriggerScalers.h"
+#include "AliTriggerScalersRecord.h"
+#include "AliTriggerRunScalers.h"
+
+ClassImp( AliTriggerRunScalers )
+
+//_____________________________________________________________________________
+AliTriggerRunScalers::AliTriggerRunScalers():
+  TObject(),
+  fVersion(0),
+  fRunNumber(0),
+  fnClasses(0),
+  fClassIndex(),                    
+  fScalersRecord()
+{
+  // Default constructor
+}
+
+//_____________________________________________________________________________
+void AliTriggerRunScalers::AddTriggerScalers( AliTriggerScalersRecord* scaler ) 
+{ 
+  //
+  fScalersRecord.AddLast( scaler ); 
+  fScalersRecord.Sort(); 
+}
+
+//_____________________________________________________________________________
+AliTriggerRunScalers* AliTriggerRunScalers::ReadScalers( TString & filename )
+{
+  
+  if( gSystem->AccessPathName( filename.Data() ) ) {
+     AliErrorClass( Form( "file (%s) not found", filename.Data() ) );
+     return NULL;
+  }
+
+  ifstream *file = new ifstream ( filename.Data() );
+  if (!*file) {
+    AliErrorClass(Form("Error opening file (%s) !\n",filename.Data()));
+    file->close();
+    delete file;
+    return NULL;
+  }
+  
+  AliTriggerRunScalers* rScaler = new AliTriggerRunScalers();
+  
+  TString strLine;
+  Bool_t verflag = kFALSE;
+  Bool_t classflag = kFALSE;
+  UChar_t nclass = 0;
+  while (strLine.ReadLine(*file)) {
+    if (strLine.BeginsWith("#")) continue;
+    
+    TObjArray *tokens = strLine.Tokenize(" \t");
+    Int_t ntokens = tokens->GetEntriesFast();
+    // 1st line, version, it is one number, 
+    if (!verflag) {
+      if (ntokens != 1) { 
+        AliErrorClass( Form( "Error reading version number from (%s), line :%s\n", 
+                              filename.Data() , strLine.Data() ) );  
+        return NULL;
+      }
+  //    cout << "Version "<< ((TObjString*)tokens->At(0))->String().Atoi() << endl;
+      rScaler->SetVersion( ((TObjString*)tokens->At(0))->String().Atoi() );
+      verflag = kTRUE;
+      delete tokens;
+      continue;
+    }
+   
+    // 2nd line, run number , number of classes, list of classes used in this partition
+
+    if (!classflag) {
+      if ( !((TObjString*)tokens->At(1))->String().IsDigit() ) {
+        AliErrorClass( Form( "Error reading Run number from (%s)\n", filename.Data() )); 
+      }
+  //    cout << "Run Number " << ((TObjString*)tokens->At(0))->String().Atoi() << endl;
+      rScaler->SetRunNumber( ((TObjString*)tokens->At(0))->String().Atoi() );
+      nclass = (UChar_t)((TObjString*)tokens->At(1))->String().Atoi();
+  //    cout << "Number of classes " << nclass << endl;
+      rScaler->SetNumClasses( nclass );
+      if ( nclass != ntokens - 2 ) {
+        AliErrorClass( Form( "Error reading number of classes from (%s)\n", filename.Data() )); 
+      }
+      for (UChar_t i=0; i<nclass; ++i) {
+        rScaler->SetClass( i, (Char_t)((TObjString*)tokens->At(2+i))->String().Atoi() );
+      }
+      classflag = kTRUE;
+      delete tokens;
+      continue;
+    }
+    
+    // Records
+    // Each record consists of 1+(number of classes in partition) lines
+    //  1st line of record = time stamp (4 words)
+    //                        1st word = ORBIT(24 bits)
+    //                        2nd word = Period Counter (28 bit)
+    //                        3rd word = seconds (32 bits) from epoch
+    //                        4th word = microsecs (32 bits)
+    //  other lines = 6 words of counters (L0 before,L0 after, ....)
+    if (ntokens != 4) { 
+      AliErrorClass( Form( "Error reading timestamp from (%s): line (%s)", 
+                            filename.Data(), strLine.Data() )); 
+      return NULL;
+    }
+    UInt_t orbit     = ((TObjString*)tokens->At(0))->String().Atoi();
+    UInt_t period    = ((TObjString*)tokens->At(1))->String().Atoi();
+    UInt_t seconds   = ((TObjString*)tokens->At(2))->String().Atoi();
+    UInt_t microSecs = ((TObjString*)tokens->At(3))->String().Atoi();
+    AliTriggerScalersRecord * rec = new AliTriggerScalersRecord();
+    rec->SetTimeStamp( orbit, period, seconds, microSecs );
+    
+    TString strLine1;
+    for (Int_t i=0; i<nclass; ++i) {
+      strLine1.ReadLine(*file);
+      if (strLine1.BeginsWith("#")) continue;
+      TObjArray *tokens1 = strLine1.Tokenize(" \t");
+      Int_t ntokens1 = tokens1->GetEntriesFast();
+      if( ntokens1 != 6 ) {
+        AliErrorClass( Form( "Error reading scalers from (%s): line (%s)\n", 
+                              filename.Data(), strLine1.Data() )); 
+      }
+      UInt_t LOCB = ((TObjString*)tokens1->At(0))->String().Atoi();
+      UInt_t LOCA = ((TObjString*)tokens1->At(1))->String().Atoi();
+      UInt_t L1CB = ((TObjString*)tokens1->At(2))->String().Atoi();
+      UInt_t L1CA = ((TObjString*)tokens1->At(3))->String().Atoi();
+      UInt_t L2CB = ((TObjString*)tokens1->At(4))->String().Atoi();
+      UInt_t L2CA = ((TObjString*)tokens1->At(5))->String().Atoi();
+      rScaler->GetClass(i);
+      rec->AddTriggerScalers( rScaler->GetClass(i),
+                              LOCB, LOCA, L1CB,
+                              L1CA, L2CB, L2CA );
+      delete tokens1;
+    } 
+    rScaler->AddTriggerScalers( rec );
+    
+    delete tokens;     
+  }
+  file->close();
+  delete file;
+
+  return  rScaler; 
+}
+  
+//_____________________________________________________________________________
+Int_t  AliTriggerRunScalers::FindNearestScalersRecord( AliTimeStamp * stamp )
+{
+   // Find Trigger scaler record with the closest timestamp <= "stamp"
+   // using a binary search. 
+   // return the index in the array of records, if the timestamp 
+   // is out of range return -1
+
+   Int_t   base, position=-1, last, result = 0;
+   AliTimeStamp *op2 = NULL;
+   
+   fScalersRecord.Sort();
+
+   base = 0;
+   last = fScalersRecord.GetEntriesFast();
+
+   while (last >= base) {
+      position = (base+last) / 2;
+      cout << "pos " <<   position<< " base " <<   base << "last " <<   last << endl;
+      AliTriggerScalersRecord* rec = (AliTriggerScalersRecord*)fScalersRecord.At(position);
+      if( rec ) op2 = rec->GetTimeStamp();
+      if( op2 && (result = stamp->Compare(op2)) == 0  )
+         return position;  // exact match
+      cout << "result " <<   result << " op2 " << op2 << " rec "<< rec << endl;
+      if (!op2 || result < 0)
+         last = position-1;
+      else
+         base = position+1;
+      op2 = NULL;  
+   }
+   if( (position == 0 && result < 0) || position >= fScalersRecord.GetEntriesFast() ) 
+    return -1;  // out of range
+   else 
+    return (result < 0 ) ? position-1 : position; // nearst < stamp   
+}
+
+//_____________________________________________________________________________
+void AliTriggerRunScalers::Print( const Option_t* ) const
+{
+   // Print
+  cout << "Trigger Scalers Record per Run: " << endl;
+  cout << "  File version :" <<  fVersion << endl;            
+  cout << "  Run Number :" <<  fRunNumber << endl;          
+  cout << "  Number of Classes :" <<  (Int_t)fnClasses << endl;          
+  cout << "    Classes ID:";
+  for( Int_t i=0; i<fnClasses; ++i ) 
+    cout << "  " << (Int_t)fClassIndex[i];       
+  cout << endl; 
+    
+  for( Int_t i=0; i<fScalersRecord.GetEntriesFast(); ++i ) 
+     ((AliTriggerScalersRecord*)fScalersRecord.At(i))->Print();
+}
+
diff --git a/STEER/AliTriggerRunScalers.h b/STEER/AliTriggerRunScalers.h
new file mode 100644 (file)
index 0000000..32f95ea
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef ALITRIGGERRUNSCALERS_H
+#define ALITRIGGERRUNSCALERS_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliTriggerRunScalers.h 22322 2007-11-22 11:43:14Z cvetan $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//  Class to define a collection scalers per Run  
+//
+// 
+//
+//////////////////////////////////////////////////////////////////////////////
+class TObject;
+
+class AliTimeStamp;
+class AliTriggerScalersRecord;
+
+#include "TArrayC.h"
+
+class AliTriggerRunScalers : public TObject {
+
+public:
+                         AliTriggerRunScalers();
+              virtual   ~AliTriggerRunScalers() { fScalersRecord.SetOwner(); fScalersRecord.Delete(); }
+
+  //  Getters
+                  Short_t    GetVersion()          const { return fVersion;       }            
+                  ULong_t    GetRunNumber()        const { return fRunNumber;     }
+                  UChar_t    GetNumClasses()       const { return fnClasses;      }
+                   Char_t    GetClass( Int_t i )   const { return fClassIndex[i]; }
+                TObjArray*   GetScalersRecords()   { return &fScalersRecord; } 
+  AliTriggerScalersRecord*   GetScalersRecord( Int_t index )         
+                                                { return (AliTriggerScalersRecord*)fScalersRecord.At(index); }
+                    Int_t    FindNearestScalersRecord( AliTimeStamp * stamp );
+        
+  //  Setters
+                     void    SetVersion( Short_t ver )       { fVersion = ver;   }            
+                     void    SetRunNumber( ULong_t run )     { fRunNumber = run; }
+                     void    SetNumClasses( UChar_t nclass ) { fnClasses = nclass; fClassIndex.Set(nclass); }
+                     void    SetClass( UChar_t i, UChar_t index ) { fClassIndex[i]=index; }
+                     void    AddTriggerScalers( AliTriggerScalersRecord* scal );
+             virtual void    Print( const Option_t* opt ="" ) const;
+
+                                        
+ static AliTriggerRunScalers*  ReadScalers( TString & filename );
+                                      
+
+private:
+                  Short_t    fVersion;            // Version
+                  ULong_t    fRunNumber;          // Run number
+                  UChar_t    fnClasses;           // Number of trigger classes
+                  TArrayC    fClassIndex;         // list of classes used in this partition
+                TObjArray    fScalersRecord;      // Array of records (AliTriggerScalersRecord)
+    
+                        //     AliTriggerRunScalers( const AliTriggerRunScalers &run );
+    AliTriggerRunScalers&    operator=(const AliTriggerRunScalers& run);
+
+   ClassDef( AliTriggerRunScalers, 1 )  // Define a Run Trigger Scalers (Scalers)
+};
+
+#endif
diff --git a/STEER/AliTriggerScalers.cxx b/STEER/AliTriggerScalers.cxx
new file mode 100644 (file)
index 0000000..4058705
--- /dev/null
@@ -0,0 +1,86 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id: AliTriggerScalers.cxx 22322 2007-11-22 11:43:14Z cvetan $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//  Class to define the ALICE Trigger Scalers  
+//
+//  For each trigger class there are six scalers:
+//
+//    LOCB       L0 triggers before any vetos 
+//    LOCA       L0 triggers after all vetos 
+//    L1CB       L1 triggers before any vetos 
+//    L1CA       L1 triggers after all vetos 
+//    L2CB       L2 triggers before any vetos 
+//    L2CA       L2 triggers after all vetos 
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
+
+#include "AliLog.h"
+#include "AliTriggerScalers.h"
+
+ClassImp( AliTriggerScalers )
+
+//_____________________________________________________________________________
+AliTriggerScalers::AliTriggerScalers(): 
+  TObject(),
+  fClassIndex(0),
+  fLOCB(0),     
+  fLOCA(0),     
+  fL1CB(0),     
+  fL1CA(0),     
+  fL2CB(0),     
+  fL2CA(0)      
+{
+  // Default constructor
+}
+
+//_____________________________________________________________________________
+AliTriggerScalers::AliTriggerScalers( UChar_t classIndex, UInt_t LOCB, UInt_t LOCA,        
+                                      UInt_t L1CB, UInt_t L1CA, UInt_t L2CB, UInt_t L2CA ):   
+  TObject(),
+  fClassIndex( classIndex ),
+  fLOCB(LOCB),     
+  fLOCA(LOCA),     
+  fL1CB(L1CB),     
+  fL1CA(L1CA),     
+  fL2CB(L2CB),     
+  fL2CA(L2CA)      
+{
+  // Default constructor
+}
+
+//_____________________________________________________________________________
+Int_t  AliTriggerScalers::Compare( const TObject* obj ) const
+{
+  // Compare Scaler by class index (to sort in Scaler Record by class index)
+  if( fClassIndex < ((AliTriggerScalers*)obj)->fClassIndex ) return -1;
+  if( fClassIndex > ((AliTriggerScalers*)obj)->fClassIndex ) return 1;
+  return 0;
+}
+
+//_____________________________________________________________________________
+void AliTriggerScalers::Print( const Option_t* ) const
+{
+   // Print
+  cout << "Trigger Scalers for Class: " << (Int_t)fClassIndex << endl;
+  cout << "  LOCB: " << fLOCB << " LOCA: " << fLOCA; //<< endl;
+  cout << "  L1CB: " << fL1CB << " L1CA: " << fL1CA; //<< endl;
+  cout << "  L2CB: " << fL2CB << " L2CA: " << fL2CA << endl;
+}
diff --git a/STEER/AliTriggerScalers.h b/STEER/AliTriggerScalers.h
new file mode 100644 (file)
index 0000000..04579f0
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef ALITRIGGERSCALERS_H
+#define ALITRIGGERSCALERS_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliTriggerScalers.h 22322 2007-11-22 11:43:14Z cvetan $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//  Class to define the ALICE Trigger Scalers  
+//
+//  For each trigger class there are six scalers:
+//
+//    LOCB       L0 triggers before any vetos 
+//    LOCA       L0 triggers after all vetos 
+//    L1CB       L1 triggers before any vetos 
+//    L1CA       L1 triggers after all vetos 
+//    L2CB       L2 triggers before any vetos 
+//    L2CA       L2 triggers after all vetos 
+//
+//////////////////////////////////////////////////////////////////////////////
+
+class AliTriggerScalers : public TObject {
+
+public:
+                         AliTriggerScalers();
+                         AliTriggerScalers(
+                              UChar_t    classIndex, 
+                               UInt_t    LOCB,        
+                               UInt_t    LOCA,        
+                               UInt_t    L1CB,        
+                               UInt_t    L1CA,        
+                               UInt_t    L2CB,        
+                               UInt_t    L2CA       
+                         );   
+              virtual   ~AliTriggerScalers() {}
+              
+       virtual Bool_t    IsSortable() const { return kTRUE; }
+        virtual Int_t    Compare( const TObject* obj ) const;
+         virtual void    Print( const Option_t* opt ="" ) const;
+        
+              UChar_t    fClassIndex;      // class index 
+               UInt_t    fLOCB;            //  L0 triggers before any vetos  (32 bits)
+               UInt_t    fLOCA;            //  L0 triggers after all vetos   (32 bits)
+               UInt_t    fL1CB;            //  L1 triggers before any vetos  (32 bits)
+               UInt_t    fL1CA;            //  L1 triggers after all vetos   (32 bits)
+               UInt_t    fL2CB;            //  L2 triggers before any vetos  (32 bits)
+               UInt_t    fL2CA;            //  L2 triggers after all vetos   (32 bits)
+    
+private:    
+                         AliTriggerScalers( const AliTriggerScalers &run );
+    AliTriggerScalers&   operator=(const AliTriggerScalers& clus);
+
+   ClassDef( AliTriggerScalers, 1 )  // Define a Run Trigger Scalers (Scalers)
+};
+
+#endif
diff --git a/STEER/AliTriggerScalersRecord.cxx b/STEER/AliTriggerScalersRecord.cxx
new file mode 100644 (file)
index 0000000..d7897d7
--- /dev/null
@@ -0,0 +1,111 @@
+ /**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id: AliTriggerScalersRecord.cxx 22322 2007-11-22 11:43:14Z cvetan $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Class to define the ALICE Trigger Scalers Record 
+//
+// Each record consists of 1 time stamp (4 words)  (AliTimeStamp)
+// and an array with the scalers (AliTriggerScalers) for each trigger class 
+// in partition  
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
+
+#include "AliLog.h"  
+#include "AliTimeStamp.h"
+#include "AliTriggerScalers.h"
+#include "AliTriggerScalersRecord.h"
+
+ClassImp( AliTriggerScalersRecord )
+//_____________________________________________________________________________
+AliTriggerScalersRecord::AliTriggerScalersRecord():
+  fTimestamp(),
+  fScalers(60)
+{
+}
+
+//_____________________________________________________________________________
+void AliTriggerScalersRecord::SetTimeStamp( UInt_t orbit, UInt_t period, 
+                                            UInt_t seconds, UInt_t microsecs )
+{
+   fTimestamp.SetTimeStamp( orbit, period, seconds, microsecs );
+}
+
+//_____________________________________________________________________________
+void AliTriggerScalersRecord::AddTriggerScalers( AliTriggerScalers* scaler ) 
+{ 
+  fScalers.AddLast( scaler ); 
+  fScalers.Sort(); 
+}
+
+//_____________________________________________________________________________
+void AliTriggerScalersRecord::AddTriggerScalers( UChar_t classIndex, UInt_t LOCB, UInt_t LOCA,        
+                                         UInt_t L1CB, UInt_t L1CA, UInt_t L2CB, UInt_t L2CA )
+{
+    AddTriggerScalers( new AliTriggerScalers( classIndex, LOCB, LOCA, L1CB, L1CA, L2CB, L2CA ) );
+} 
+
+//_____________________________________________________________________________
+Int_t AliTriggerScalersRecord::Compare( const TObject* obj ) const
+{
+  // Compare  timestamps
+  
+  return fTimestamp.Compare( &(((AliTriggerScalersRecord*)obj)->fTimestamp) );
+}
+
+//_____________________________________________________________________________
+AliTriggerScalers* AliTriggerScalersRecord::GetTriggerScalersForClass( Int_t classmask )
+{
+   // Find Trigger scaler with class ID = classmask using a binary search. 
+
+   Int_t   base, position, last, result = 0;
+   AliTriggerScalers *op2 = NULL;
+   
+   fScalers.Sort();
+   
+   base = 0;
+   last = fScalers.GetEntriesFast();
+
+   while (last >= base) {
+      result = 0;
+      position = (base+last) / 2;
+      op2 = (AliTriggerScalers *)fScalers.At(position);
+      if( op2 && op2->fClassIndex > classmask ) result = -1;
+      if( op2 && op2->fClassIndex < classmask ) result = 1;
+  
+      if (op2 && result == 0)
+         return op2;
+      if (!op2 || result < 0)
+         last = position-1;
+      else
+         base = position+1;
+      op2 = NULL;   
+   }
+   return op2;   
+}
+                                      
+//_____________________________________________________________________________
+void AliTriggerScalersRecord::Print( const Option_t* ) const
+{
+   // Print
+  cout << "Trigger Scalers Record: " << endl;
+  fTimestamp.Print();
+  for( Int_t i=0; i<fScalers.GetEntriesFast(); ++i ) 
+     ((AliTriggerScalers*)fScalers.At(i))->Print();
+}
diff --git a/STEER/AliTriggerScalersRecord.h b/STEER/AliTriggerScalersRecord.h
new file mode 100644 (file)
index 0000000..64aea18
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef ALITRIGGERSCALERSRECORD_H
+#define ALITRIGGERSCALERSRECORD_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliTriggerScalersRecord.h 22322 2007-11-22 11:43:14Z cvetan $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Class to define the ALICE Trigger Scalers Record 
+//
+// Each record consists of 1 time stamp (4 words)  (AliTimeStamp)
+// and an array with the scalers (AliTriggerScalers) for each trigger class 
+// in partition  
+//
+//////////////////////////////////////////////////////////////////////////////
+
+class  AliTimeStamp;
+
+class AliTriggerScalersRecord : public TObject {
+
+public:
+                            AliTriggerScalersRecord();
+                 virtual   ~AliTriggerScalersRecord() { fScalers.SetOwner(); fScalers.Delete(); }
+                 
+                 
+                    void    SetTimeStamp( UInt_t orbit, UInt_t period, UInt_t seconds, UInt_t microsecs );
+                    void    AddTriggerScalers( AliTriggerScalers* scaler );
+                    void    AddTriggerScalers( UChar_t classIndex, UInt_t LOCB, UInt_t LOCA,        
+                                              UInt_t L1CB, UInt_t L1CA, UInt_t L2CB, UInt_t L2CA );
+                            
+            AliTimeStamp*   GetTimeStamp() { return &fTimestamp; }
+               TObjArray*   GetTriggerScalers()  { return  &fScalers; }
+       AliTriggerScalers*   GetTriggerScalersForClass( Int_t classmask );       
+          virtual Bool_t    IsSortable() const { return kTRUE; }
+                                
+           virtual Int_t    Compare( const TObject* obj ) const;
+            virtual void    Print( const Option_t* opt ="" ) const;
+
+       
+            AliTimeStamp    fTimestamp;    // record timestamp
+               TObjArray    fScalers;      // Array of scalers (AliTriggerScalers)  
+     
+private:  
+
+                            AliTriggerScalersRecord( const AliTriggerScalersRecord &rec );
+ AliTriggerScalersRecord&   operator=(const AliTriggerScalersRecord& rec);
+
+   ClassDef( AliTriggerScalersRecord, 1 )  // Define a Record of Trigger Scalers 
+};
+
+#endif
index f5900b5..44cd1f6 100644 (file)
@@ -55,4 +55,8 @@
 
 #pragma link C++ class AliQA+;
 
+#pragma link C++ class AliTimeStamp+;
+#pragma link C++ class AliTriggerScalers+;
+#pragma link C++ class AliTriggerScalersRecord+;
+
 #endif
index 4c6b87c..eb5211c 100644 (file)
 #pragma link C++ class AliRecoParam+;
 #pragma link C++ class AliPlaneEff+;
 
+#pragma link C++ class AliTriggerRunScalers+;
+
 #endif
index 3d30168..d59123f 100644 (file)
@@ -57,7 +57,8 @@ AliQACheckerBase.cxx \
 AliMillepede.cxx \
 AliRecoParam.cxx \
 AliDetectorRecoParam.cxx \
-AliPlaneEff.cxx
+AliPlaneEff.cxx \
+AliTriggerRunScalers.cxx
 
 
 HDRS:= $(SRCS:.cxx=.h) 
index 57ff41f..9aaafa8 100644 (file)
@@ -15,7 +15,8 @@ SRCS = AliVParticle.cxx \
        AliMCEvent.cxx AliMCParticle.cxx \
        AliMagF.cxx \
        AliCodeTimer.cxx \
-       AliQA.cxx                       
+       AliQA.cxx \
+       AliTimeStamp.cxx AliTriggerScalers.cxx AliTriggerScalersRecord.cxx
 
 HDRS:= $(SRCS:.cxx=.h)