--- /dev/null
+/**************************************************************************
+ * 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: AliCTPInputTimeParams.cxx 22322 2007-11-22 11:43:14Z cvetan $ */
+
+#include <Riostream.h>
+
+
+#include "TObject.h"
+#include "AliLog.h"
+#include "AliCTPInputTimeParams.h"
+
+ClassImp(AliCTPInputTimeParams)
+
+//_____________________________________________________________________________
+AliCTPInputTimeParams::AliCTPInputTimeParams():
+ fName(0),
+ fLevel(0),
+ fDelay(0),
+ fEdge(0)
+{
+ // Default constructor
+}
+
+//_____________________________________________________________________________
+AliCTPInputTimeParams::AliCTPInputTimeParams( TString& name, UInt_t& level, UInt_t delay, TString edge ):
+ fName(name),
+ fLevel(level),
+ fDelay( delay),
+ fEdge(edge)
+{
+}
+//_____________________________________________________________________________
+AliCTPInputTimeParams::AliCTPInputTimeParams(const AliCTPInputTimeParams &ctptime):
+ TObject(ctptime),
+ fName(ctptime.fName),
+ fLevel(ctptime.fLevel),
+ fDelay(ctptime.fDelay),
+ fEdge(ctptime.fEdge)
+{
+ // copy constructor
+}
+//_____________________________________________________________________________
+AliCTPInputTimeParams& AliCTPInputTimeParams::operator=(const AliCTPInputTimeParams &ctptime)
+{
+ //assignment operator
+ if(this==&ctptime) return *this;
+ ((TObject *)this)->operator=(ctptime);
+ fName=ctptime.fName;
+ fLevel=ctptime.fLevel;
+ fDelay=ctptime.fDelay;
+ fEdge=ctptime.fEdge;
+ return *this;
+}
+//_____________________________________________________________________________
+void AliCTPInputTimeParams::SetCTPInputTimeParams( TString name, UInt_t level, UInt_t delay, TString edge )
+{
+ fName = name;
+ fLevel = level;
+ fDelay = delay;
+ fEdge = edge;
+}
+
+//_____________________________________________________________________________
+void AliCTPInputTimeParams::Print( const Option_t* ) const
+{
+ // Print
+ cout << " CTP Input Time Params " << endl;
+ cout << " Input Name: " << fName << endl;
+ cout << " Level: " << fLevel << endl;
+ cout << " Delay: " << fDelay << endl;
+ cout << " Edge: " << fEdge << endl;
+}
--- /dev/null
+#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: AliCTPInputTimeParams.h 22322 2007-11-22 11:43:14Z cvetan $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+
+
+class TObject;
+
+class AliCTPInputTimeParams : public TObject {
+
+public:
+ AliCTPInputTimeParams();
+ AliCTPInputTimeParams( TString& name, UInt_t& level, UInt_t delay, TString edge );
+
+ virtual ~AliCTPInputTimeParams() {}
+ AliCTPInputTimeParams( const AliCTPInputTimeParams &ctptime );
+ AliCTPInputTimeParams& operator=(const AliCTPInputTimeParams& ctptime);
+
+ // Getters
+ TString GetInputName() const { return fName; }
+ UInt_t GetLevel() const { return fLevel; }
+ UInt_t GetDelay() const { return fDelay; }
+ TString GetEdge() const { return fEdge; }
+
+ // Setters
+ void SetCTPInputTimeParams( TString name, UInt_t level,
+ UInt_t delay, TString edge );
+
+ virtual void Print( const Option_t* opt ="" ) const;
+
+
+protected:
+ TString fName;
+ UInt_t fLevel;
+ UInt_t fDelay;
+ TString fEdge;
+
+private:
+
+ ClassDef( AliCTPInputTimeParams, 1 )
+};
+
+
+#endif
--- /dev/null
+#include <Riostream.h>
+
+#include <TObjArray.h>
+#include <TObjString.h>
+#include <TObject.h>
+#include <TString.h>
+#include <TSystem.h>
+#include <TFile.h>
+#include <TCint.h>
+#include <TROOT.h>
+
+#include "AliLog.h"
+#include "AliCTPTimeParams.h"
+#include "AliCTPInputTimeParams.h"
+
+ClassImp(AliCTPTimeParams)
+
+const TString AliCTPTimeParams::fgkCTPTimeParamsFileName("/data/CTPTimeParams.root");
+
+//______________________________________________________________________________
+AliCTPTimeParams::AliCTPTimeParams():
+TNamed(),
+fDelayL1L0(),
+fDelayL2L0(),
+fCTPInputTimeParams()
+{
+//Default constructor
+}
+
+//______________________________________________________________________________
+AliCTPTimeParams::AliCTPTimeParams(const AliCTPTimeParams &timeparams):
+ TNamed(),
+ fDelayL1L0(timeparams.fDelayL1L0),
+ fDelayL2L0(timeparams.fDelayL2L0)
+{
+ for (Int_t i = 0; i < timeparams.fCTPInputTimeParams.GetSize(); i++) {
+ if ( timeparams.fCTPInputTimeParams[i] ) fCTPInputTimeParams.Add(timeparams.fCTPInputTimeParams[i]->Clone());
+ }
+ // copy constructor
+}
+
+
+//______________________________________________________________________________
+AliCTPTimeParams& AliCTPTimeParams::operator=(const AliCTPTimeParams &timeparams)
+{
+ // assignment operator
+ if(this==&timeparams) return *this;
+ ((TNamed *)this)->operator=(timeparams);
+ fDelayL1L0=timeparams.fDelayL1L0;
+ fDelayL2L0=timeparams.fDelayL2L0;
+
+ for (Int_t i = 0; i < timeparams.fCTPInputTimeParams.GetSize(); i++) {
+ if ( timeparams.fCTPInputTimeParams[i] ) fCTPInputTimeParams.Add(timeparams.fCTPInputTimeParams[i]->Clone());
+ }
+
+ return *this;
+}
+
+//______________________________________________________________________________
+AliCTPTimeParams::~AliCTPTimeParams()
+{
+ //Destructor
+
+ fCTPInputTimeParams.SetOwner();
+ fCTPInputTimeParams.Delete();
+}
+
+//______________________________________________________________________________
+void AliCTPTimeParams::AddInput( TString& inputName, UInt_t& inputLevel, UInt_t inputDelay, TString inputEdge )
+{
+ fCTPInputTimeParams.AddLast( new AliCTPInputTimeParams(inputName, inputLevel, inputDelay, inputEdge ));
+}
+
+//______________________________________________________________________________
+void AliCTPTimeParams::AddDelayL0L1L2(UInt_t delayL1L0, UInt_t delayL2L0)
+{
+ fDelayL1L0 = delayL1L0;
+ fDelayL2L0 = delayL2L0;
+}
+//______________________________________________________________________________
+AliCTPTimeParams* AliCTPTimeParams::LoadCTPTimeParams(TString filename)
+{
+ // Load pre-created CTP time parameters from database/file
+ // By default files are stored in GRP/CTP folder
+ // The filename is constructed as GRP/CTP/<file>.cfg
+ 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) !", filename.Data()));
+ file->close();
+ delete file;
+ return NULL;
+ }
+
+ AliCTPTimeParams *ctptime = new AliCTPTimeParams();
+
+ TString strline;
+
+ while (strline.ReadLine(*file)) {
+ if (ctptime->ProcessCTPTimeParamsLine(strline) == kFALSE) {
+ delete ctptime;
+ break;
+ }
+ }
+
+ file->close();
+ delete file;
+
+ return ctptime;
+}
+
+//______________________________________________________________________________
+AliCTPTimeParams* AliCTPTimeParams::LoadCTPTimeParamsFromString(const char* timeparams)
+{
+
+ // Loads configuration from string
+
+ if (!timeparams)
+ return 0;
+
+ AliCTPTimeParams *ctptime = new AliCTPTimeParams();
+
+ TObjArray* tokens = TString(timeparams).Tokenize("\n");
+ for (Int_t i=0; i<tokens->GetEntries(); i++)
+ {
+ TObjString* string = dynamic_cast<TObjString*>(tokens->At(i));
+ if (!string)
+ continue;
+
+ if (ctptime->ProcessCTPTimeParamsLine(string->String()) == kFALSE)
+ {
+ delete ctptime;
+ break;
+ }
+ }
+
+ delete tokens;
+ return ctptime;
+}
+
+//______________________________________________________________________________
+Bool_t AliCTPTimeParams::ProcessCTPTimeParamsLine(const char* line)
+{
+ UInt_t level = 0;
+ TString strline(line);
+ if (strline.BeginsWith("L012")) {
+ strline.ReplaceAll("L012", "");
+ TObjArray *tokens = strline.Tokenize(" \t");
+
+
+ AddDelayL0L1L2(((TObjString*)tokens->At(0))->String().Atoi(),((TObjString*)tokens->At(1))->String().Atoi());
+ delete tokens;
+ }
+ else {
+ if (strline.BeginsWith("0")) { level = 0; } // determine the input level (0, 1 or 2)
+ else if (strline.BeginsWith("1")) { level = 1; }
+ else if (strline.BeginsWith("2")) { level = 2; }
+ else return 0; // file not in the right format!
+
+ TObjArray *tokens = strline.Tokenize(" \t");
+ AddInput(((TObjString*)tokens->At(0))->String(), level, ((TObjString*)tokens->At(2))->String().Atoi(), ((TObjString*)tokens->At(1))->String() );
+ }
+
+return kTRUE;
+}
+
+//______________________________________________________________________________
+Bool_t AliCTPTimeParams::GetCTPTimeParamsDAQLog()
+{
+
+}
+
+//______________________________________________________________________________
+Bool_t AliCTPTimeParams::WriteCTPTimeParamsOCDB()
+{
+
+}
+//______________________________________________________________________________
+void AliCTPTimeParams::Print(const Option_t*) const
+{
+ //Print
+ cout << "Delay L0 - L1 = " << fDelayL1L0 << endl;
+ cout << "Delay L0 - L2 = " << fDelayL2L0 << endl;
+ fCTPInputTimeParams.Print();
+ cout << ""<<endl;
+}
+//______________________________________________________________________________
--- /dev/null
+#ifndef ALICTPTIMEPARAMS_H
+#define ALICTPTIMEPARAMS_H
+
+
+#include<TNamed.h>
+#include<TObjArray.h>
+
+class TNamed;
+
+class AliCTPTimeParams : public TNamed {
+
+public:
+ AliCTPTimeParams();
+ virtual ~AliCTPTimeParams();
+
+ AliCTPTimeParams(const AliCTPTimeParams &timeparams);
+ AliCTPTimeParams& operator=(const AliCTPTimeParams& timeparams);
+
+
+ static AliCTPTimeParams* LoadCTPTimeParams(TString filename);
+ static AliCTPTimeParams* LoadCTPTimeParamsFromString(const char* timeparams);
+ Bool_t ProcessCTPTimeParamsLine(const char* line);
+ Bool_t WriteCTPTimeParamsOCDB();
+ Bool_t GetCTPTimeParamsDAQLog();
+ void AddInput( TString& inputName, UInt_t& inputLevel, UInt_t inputDelay, TString inputEdge );
+ void AddDelayL0L1L2(UInt_t delayL1L0, UInt_t delayL2L0);
+ virtual void Print(const Option_t* opt="") const;
+ //Setters
+
+ //Getters
+ UInt_t GetDelayL1L0() const { return fDelayL1L0; }
+ UInt_t GetDelayL2L0() const { return fDelayL2L0; }
+/* UInt_t* GetDelayInputs() { return fDelayInputs; }
+ Bool_t* GetInputIndex() { return fInputIndex; }
+ UInt_t* GetInputLevel() { return fInputLevel; }*/
+
+ enum {kNMaxInputs = 60}; //CTP can manage up to 60 trigger detector inputs
+private:
+ UInt_t fDelayL1L0;
+ UInt_t fDelayL2L0;
+ TObjArray fCTPInputTimeParams;
+/*
+ UInt_t fInputDelay[kNMaxInputs];
+ Bool_t fInputFlag[kNMaxInputs];
+ UInt_t fInputLevel[kNMaxInputs];
+ TString fInputName[kNMaxInputs];
+ Char_t fInputEdge[kNMaxInputs];
+*/
+ static const TString fgkCTPTimeParamsFileName; //Name of file containing the CTPTimeParams
+
+ ClassDef( AliCTPTimeParams, 1 )
+};
+
+#endif
#pragma link C++ class AliGRPManager+;
#pragma link C++ class AliDCSArray+;
#pragma link C++ class AliLHCReader+;
+#pragma link C++ class AliCTPTimeParams+;
+#pragma link C++ class AliCTPInputTimeParams+;
#endif
AliVectorSparse.cxx AliMatrixSparse.cxx \
AliSymMatrix.cxx AliRectMatrix.cxx AliMinResSolve.cxx \
AliGRPManager.cxx \
-AliDCSArray.cxx AliLHCReader.cxx
+AliDCSArray.cxx AliLHCReader.cxx \
+AliCTPTimeParams.cxx AliCTPInputTimeParams.cxx
HDRS:= $(SRCS:.cxx=.h)