From fabd1b29b19f5e55c55ae47ba229604864b8b388 Mon Sep 17 00:00:00 2001 From: lietava Date: Sun, 11 Oct 2009 08:23:16 +0000 Subject: [PATCH] Classes for CTP time parameters added (Plamen) --- STEER/AliCTPInputTimeParams.cxx | 85 ++++++++++++++ STEER/AliCTPInputTimeParams.h | 50 +++++++++ STEER/AliCTPTimeParams.cxx | 191 ++++++++++++++++++++++++++++++++ STEER/AliCTPTimeParams.h | 54 +++++++++ STEER/STEERLinkDef.h | 2 + STEER/libSTEER.pkg | 3 +- 6 files changed, 384 insertions(+), 1 deletion(-) create mode 100644 STEER/AliCTPInputTimeParams.cxx create mode 100644 STEER/AliCTPInputTimeParams.h create mode 100644 STEER/AliCTPTimeParams.cxx create mode 100644 STEER/AliCTPTimeParams.h diff --git a/STEER/AliCTPInputTimeParams.cxx b/STEER/AliCTPInputTimeParams.cxx new file mode 100644 index 00000000000..fa0c124e86f --- /dev/null +++ b/STEER/AliCTPInputTimeParams.cxx @@ -0,0 +1,85 @@ +/************************************************************************** + * 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 + + +#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; +} diff --git a/STEER/AliCTPInputTimeParams.h b/STEER/AliCTPInputTimeParams.h new file mode 100644 index 00000000000..5ce18894aa8 --- /dev/null +++ b/STEER/AliCTPInputTimeParams.h @@ -0,0 +1,50 @@ +#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 diff --git a/STEER/AliCTPTimeParams.cxx b/STEER/AliCTPTimeParams.cxx new file mode 100644 index 00000000000..c50bb99a7ad --- /dev/null +++ b/STEER/AliCTPTimeParams.cxx @@ -0,0 +1,191 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#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/.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; iGetEntries(); i++) + { + TObjString* string = dynamic_cast(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 << ""< +#include + +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 diff --git a/STEER/STEERLinkDef.h b/STEER/STEERLinkDef.h index 144a71310e9..d6f58ed8a04 100644 --- a/STEER/STEERLinkDef.h +++ b/STEER/STEERLinkDef.h @@ -161,5 +161,7 @@ #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 diff --git a/STEER/libSTEER.pkg b/STEER/libSTEER.pkg index 93402b88d18..e572d63dc04 100644 --- a/STEER/libSTEER.pkg +++ b/STEER/libSTEER.pkg @@ -72,7 +72,8 @@ AliMillePedeRecord.cxx AliMillePede2.cxx AliMatrixSq.cxx \ 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) -- 2.39.3