From 7c4d1228d66a865084e803ba071b5014092338b5 Mon Sep 17 00:00:00 2001 From: richterm Date: Sun, 26 Oct 2008 09:29:23 +0000 Subject: [PATCH] adding transparent access to AliDAQ, adding special HLTOUT kRawReader handler for detectors with less than 32 DDLs. In that case, data block specification is a bit pattern where every bit describes a DDL. --- HLT/BASE/AliHLTDAQ.cxx | 177 +++++++++++++++++++ HLT/BASE/AliHLTDAQ.h | 75 ++++++++ HLT/BASE/AliHLTOUTHandlerDetectorDDL.cxx | 97 ++++++++++ HLT/BASE/AliHLTOUTHandlerDetectorDDL.h | 73 ++++++++ HLT/libHLTbase.pkg | 2 + HLT/libHLTrec.pkg | 1 + HLT/rec/AliHLTDAQInterfaceImplementation.cxx | 116 ++++++++++++ HLT/rec/AliHLTDAQInterfaceImplementation.h | 65 +++++++ 8 files changed, 606 insertions(+) create mode 100644 HLT/BASE/AliHLTDAQ.cxx create mode 100644 HLT/BASE/AliHLTDAQ.h create mode 100644 HLT/BASE/AliHLTOUTHandlerDetectorDDL.cxx create mode 100644 HLT/BASE/AliHLTOUTHandlerDetectorDDL.h create mode 100644 HLT/rec/AliHLTDAQInterfaceImplementation.cxx create mode 100644 HLT/rec/AliHLTDAQInterfaceImplementation.h diff --git a/HLT/BASE/AliHLTDAQ.cxx b/HLT/BASE/AliHLTDAQ.cxx new file mode 100644 index 00000000000..ffcc96b52c4 --- /dev/null +++ b/HLT/BASE/AliHLTDAQ.cxx @@ -0,0 +1,177 @@ +// $Id$ + +//************************************************************************** +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* * +//* Primary Authors: Matthias Richter * +//* for The ALICE HLT Project. * +//* * +//* 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. * +//************************************************************************** + +/** @file AliHLTDAQ.cxx + @author Matthias Richter + @date 24.10.2008 + @brief Virtual Interface to the AliDAQ class. +*/ + +#include "AliHLTDAQ.h" +#include "AliHLTLogging.h" +#include "TClass.h" +#include "TSystem.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTDAQ) + +AliHLTDAQ::AliHLTDAQ() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTDAQ* AliHLTDAQ::fgpInstance=NULL; +const char* AliHLTDAQ::fgkImplName="AliHLTDAQInterfaceImplementation"; +const char* AliHLTDAQ::fgkImplLibrary="libHLTrec.so"; + +AliHLTDAQ::~AliHLTDAQ() +{ + // see header file for class documentation +} + +Int_t AliHLTDAQ::DetectorID(const char *detectorName) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDetectorID(detectorName); + return -1; +} + +const char *AliHLTDAQ::DetectorName(Int_t detectorID) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDetectorName(detectorID); + return NULL; +} + +Int_t AliHLTDAQ::DdlIDOffset(const char *detectorName) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorName); + return -1; +} + +Int_t AliHLTDAQ::DdlIDOffset(Int_t detectorID) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorID); + return -1; +} + +const char *AliHLTDAQ::DetectorNameFromDdlID(Int_t ddlID, Int_t &ddlIndex) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDetectorNameFromDdlID(ddlID, ddlIndex); + return NULL; +} + +Int_t AliHLTDAQ::DetectorIDFromDdlID(Int_t ddlID, Int_t &ddlIndex) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDetectorIDFromDdlID(ddlID, ddlIndex); + return -1; +} + +Int_t AliHLTDAQ::DdlID(const char *detectorName, Int_t ddlIndex) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDdlID(detectorName, ddlIndex); + return -1; +} + +Int_t AliHLTDAQ::DdlID(Int_t detectorID, Int_t ddlIndex) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDdlID(detectorID, ddlIndex); + return -1; +} + +const char *AliHLTDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorName, ddlIndex); + return NULL; +} + +const char *AliHLTDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorID, ddlIndex); + return NULL; +} + +Int_t AliHLTDAQ::NumberOfDdls(const char *detectorName) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorName); + return -1; +} + +Int_t AliHLTDAQ::NumberOfDdls(Int_t detectorID) +{ + // see header file for class documentation + if (!fgpInstance) GetInstance(); + if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorID); + return -1; +} + +AliHLTDAQ* AliHLTDAQ::GetInstance() +{ + // see header file for class documentation + int iLibResult=0; + if (!fgpInstance) { + AliHLTLogging log; + TClass* pCl=NULL; + ROOT::NewFunc_t pNewFunc=NULL; + do { + pCl=TClass::GetClass(fgkImplName); + } while (!pCl && (iLibResult=gSystem->Load(fgkImplLibrary))==0); + if (iLibResult>=0) { + if (pCl && (pNewFunc=pCl->GetNew())!=NULL) { + void* p=(*pNewFunc)(NULL); + if (p) { + fgpInstance=reinterpret_cast(p); + if (!fgpInstance) { + log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "type cast to AliHLTDAQ instance failed"); + } + } else { + log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "can not create AliHLTDAQ instance from class descriptor"); + } + } else { + log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "can not find AliHLTDAQ class descriptor"); + } + } else { + log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "can not load libHLTrec library"); + } + } + return fgpInstance; +} diff --git a/HLT/BASE/AliHLTDAQ.h b/HLT/BASE/AliHLTDAQ.h new file mode 100644 index 00000000000..3cf64d43418 --- /dev/null +++ b/HLT/BASE/AliHLTDAQ.h @@ -0,0 +1,75 @@ +//-*- Mode: C++ -*- +// $Id$ + +#ifndef ALIHLTDAQ_H +#define ALIHLTDAQ_H +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* See cxx source for full Copyright notice * + +/** @file AliHLTDAQ.h + @author Matthias Richter + @date 24.10.2008 + @brief Virtual Interface to the AliDAQ class. +*/ + +#include "Rtypes.h" + +/** + * Virtual interface to the AliDAQ class. + * In order to keep the libHLTbase free of AliRoot dependencies, the + * implementation has been separated from libHLTbase. + * Implementation in libHLTrec. + */ +class AliHLTDAQ { + public: + AliHLTDAQ(); + virtual ~AliHLTDAQ(); + static Int_t DetectorID(const char *detectorName); + static const char *DetectorName(Int_t detectorID); + + static Int_t DdlIDOffset(const char *detectorName); + static Int_t DdlIDOffset(Int_t detectorID); + + static const char *DetectorNameFromDdlID(Int_t ddlID, Int_t &ddlIndex); + static Int_t DetectorIDFromDdlID(Int_t ddlID, Int_t &ddlIndex); + + static Int_t DdlID(const char *detectorName, Int_t ddlIndex); + static Int_t DdlID(Int_t detectorID, Int_t ddlIndex); + static const char *DdlFileName(const char *detectorName, Int_t ddlIndex); + static const char *DdlFileName(Int_t detectorID, Int_t ddlIndex); + + static Int_t NumberOfDdls(const char *detectorName); + static Int_t NumberOfDdls(Int_t detectorID); + + static AliHLTDAQ* GetInstance(); + + private: + virtual Int_t VirtDetectorID(const char *detectorName)=0; + virtual const char *VirtDetectorName(Int_t detectorID)=0; + + virtual Int_t VirtDdlIDOffset(const char *detectorName)=0; + virtual Int_t VirtDdlIDOffset(Int_t detectorID)=0; + + virtual const char *VirtDetectorNameFromDdlID(Int_t ddlID, Int_t &ddlIndex)=0; + virtual Int_t VirtDetectorIDFromDdlID(Int_t ddlID, Int_t &ddlIndex)=0; + + virtual Int_t VirtDdlID(const char *detectorName, Int_t ddlIndex)=0; + virtual Int_t VirtDdlID(Int_t detectorID, Int_t ddlIndex)=0; + virtual const char *VirtDdlFileName(const char *detectorName, Int_t ddlIndex)=0; + virtual const char *VirtDdlFileName(Int_t detectorID, Int_t ddlIndex)=0; + + virtual Int_t VirtNumberOfDdls(const char *detectorName)=0; + virtual Int_t VirtNumberOfDdls(Int_t detectorID)=0; + + /** global instance */ + static AliHLTDAQ* fgpInstance; //! + + /** the name of the actual implementation */ + static const char* fgkImplName; //! + + /** the library of the implementation */ + static const char* fgkImplLibrary; //! +}; + +#endif //AliHLTDAQ diff --git a/HLT/BASE/AliHLTOUTHandlerDetectorDDL.cxx b/HLT/BASE/AliHLTOUTHandlerDetectorDDL.cxx new file mode 100644 index 00000000000..cb38b9e6131 --- /dev/null +++ b/HLT/BASE/AliHLTOUTHandlerDetectorDDL.cxx @@ -0,0 +1,97 @@ +// $Id$ + +//************************************************************************** +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* * +//* Primary Authors: Matthias Richter * +//* for The ALICE HLT Project. * +//* * +//* 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. * +//************************************************************************** + +/** @file AliHLTOUTHandlerDetectorDDL.cxx + @author Matthias Richter + @date 2008-09-09 + @brief HLTOUT handler returning equipment id from data type and spec. +*/ + +#include "AliHLTOUTHandlerDetectorDDL.h" +#include "AliHLTOUT.h" +#include "AliHLTDAQ.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTOUTHandlerDetectorDDL) + +AliHLTOUTHandlerDetectorDDL::AliHLTOUTHandlerDetectorDDL(const char* detector, AliHLTComponentDataType dt) + : + fDDLOffset(-1), + fNumberOfDDLs(-1), + fDt(dt) +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + + fDDLOffset=AliHLTDAQ::DdlIDOffset(detector); + fNumberOfDDLs=AliHLTDAQ::NumberOfDdls(detector); +} + +AliHLTOUTHandlerDetectorDDL::~AliHLTOUTHandlerDetectorDDL() +{ + // see header file for class documentation +} + +int AliHLTOUTHandlerDetectorDDL::ProcessData(AliHLTOUT* pData) +{ + // see header file for class documentation + if (!pData) return -EINVAL; + if (fDDLOffset<0 || fNumberOfDDLs<0) return -ENODEV; + + static int errorCount=0; + const int maxErrorCount=10; + AliHLTComponentDataType dt=kAliHLTVoidDataType; + AliHLTUInt32_t spec=kAliHLTVoidDataSpec; + int iResult=pData->GetDataBlockDescription(dt, spec); + if (iResult>=0 && dt!=kAliHLTVoidDataType && spec!=kAliHLTVoidDataSpec) { + if (dt==fDt) { + int ddlNo=0; + for (;ddlNo<32 && ddlNo=32 || ddlNo>=fNumberOfDDLs) { + HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str()); + iResult=-ENODEV; + } else if (spec^(0x1< * +//* for The ALICE HLT Project. * +//* * +//* 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. * +//************************************************************************** + +/** @file AliHLTDAQInterfaceImplementation.cxx + @author Matthias Richter + @date + @brief Interface to the AliDAQ class +*/ + +#include "AliHLTDAQInterfaceImplementation.h" +#include "AliDAQ.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTDAQInterfaceImplementation) + +AliHLTDAQInterfaceImplementation::AliHLTDAQInterfaceImplementation() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTDAQInterfaceImplementation::~AliHLTDAQInterfaceImplementation() +{ +} + // see header file for class documentation + +Int_t AliHLTDAQInterfaceImplementation::VirtDetectorID(const char *detectorName) +{ + // see header file for class documentation + return AliDAQ::DetectorID(detectorName); +} + +const char *AliHLTDAQInterfaceImplementation::VirtDetectorName(Int_t detectorID) +{ + // see header file for class documentation + return AliDAQ::DetectorName(detectorID); +} + + +Int_t AliHLTDAQInterfaceImplementation::VirtDdlIDOffset(const char *detectorName) +{ + // see header file for class documentation + return AliDAQ::DdlIDOffset(detectorName); +} + +Int_t AliHLTDAQInterfaceImplementation::VirtDdlIDOffset(Int_t detectorID) +{ + // see header file for class documentation + return AliDAQ::DdlIDOffset(detectorID); +} + +const char *AliHLTDAQInterfaceImplementation::VirtDetectorNameFromDdlID(Int_t ddlID, Int_t &ddlIndex) +{ + // see header file for class documentation + return AliDAQ::DetectorNameFromDdlID(ddlID, ddlIndex); +} + +Int_t AliHLTDAQInterfaceImplementation::VirtDetectorIDFromDdlID(Int_t ddlID, Int_t &ddlIndex) +{ + // see header file for class documentation + return AliDAQ::DetectorIDFromDdlID(ddlID, ddlIndex); +} + +Int_t AliHLTDAQInterfaceImplementation::VirtDdlID(const char *detectorName, Int_t ddlIndex) +{ + // see header file for class documentation + return AliDAQ::DdlID(detectorName, ddlIndex); +} + +Int_t AliHLTDAQInterfaceImplementation::VirtDdlID(Int_t detectorID, Int_t ddlIndex) +{ + // see header file for class documentation + return AliDAQ::DdlID(detectorID, ddlIndex); +} + +const char *AliHLTDAQInterfaceImplementation::VirtDdlFileName(const char *detectorName, Int_t ddlIndex) +{ + // see header file for class documentation + return AliDAQ::DdlFileName(detectorName, ddlIndex); +} + +const char *AliHLTDAQInterfaceImplementation::VirtDdlFileName(Int_t detectorID, Int_t ddlIndex) +{ + // see header file for class documentation + return AliDAQ::DdlFileName(detectorID, ddlIndex); +} + +Int_t AliHLTDAQInterfaceImplementation::VirtNumberOfDdls(const char *detectorName) +{ + // see header file for class documentation + return AliDAQ::NumberOfDdls(detectorName); +} + +Int_t AliHLTDAQInterfaceImplementation::VirtNumberOfDdls(Int_t detectorID) +{ + // see header file for class documentation + return AliDAQ::NumberOfDdls(detectorID); +} diff --git a/HLT/rec/AliHLTDAQInterfaceImplementation.h b/HLT/rec/AliHLTDAQInterfaceImplementation.h new file mode 100644 index 00000000000..7dfce00db56 --- /dev/null +++ b/HLT/rec/AliHLTDAQInterfaceImplementation.h @@ -0,0 +1,65 @@ +//-*- Mode: C++ -*- +// $Id$ + +#ifndef ALIHLTDAQINTERFACEIMPLEMENTATION_H +#define ALIHLTDAQINTERFACEIMPLEMENTATION_H +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* See cxx source for full Copyright notice * + +/** @file AliHLTDAQInterfaceImplementation.h + @author Matthias Richter + @date + @brief Implementation of the AliHLTDAQInterfaceImplementation +*/ + +#include "AliHLTDAQ.h" + +/** + * @class AliHLTDAQInterfaceImplementation + * Implementation of the AliHLTDAQVirtualInterface + * + * For the sake of library (in)dependencies, AliDAQ can not be used directly in + * libHLTbase as this would introduce dependencies to AliRoot libraries. + * The AliHLTDAQVirtualInterface provides a virtual interface to AliDAQ with + * the implementation in libHLTrec.so. + * See AliHLTDAQVirtualInterface for usage. + * + * @ingroup alihlt_aliroot_reconstruction + */ +class AliHLTDAQInterfaceImplementation : public AliHLTDAQ { + public: + /** constructor */ + AliHLTDAQInterfaceImplementation(); + /** destructor */ + virtual ~AliHLTDAQInterfaceImplementation(); + + Int_t VirtDetectorID(const char *detectorName); + const char *VirtDetectorName(Int_t detectorID); + + Int_t VirtDdlIDOffset(const char *detectorName); + Int_t VirtDdlIDOffset(Int_t detectorID); + + const char *VirtDetectorNameFromDdlID(Int_t ddlID, Int_t &ddlIndex); + Int_t VirtDetectorIDFromDdlID(Int_t ddlID, Int_t &ddlIndex); + + Int_t VirtDdlID(const char *detectorName, Int_t ddlIndex); + Int_t VirtDdlID(Int_t detectorID, Int_t ddlIndex); + const char *VirtDdlFileName(const char *detectorName, Int_t ddlIndex); + const char *VirtDdlFileName(Int_t detectorID, Int_t ddlIndex); + + Int_t VirtNumberOfDdls(const char *detectorName); + Int_t VirtNumberOfDdls(Int_t detectorID); + + protected: + + private: + /** copy constructor prohibited */ + AliHLTDAQInterfaceImplementation(const AliHLTDAQInterfaceImplementation&); + /** assignment operator prohibited */ + AliHLTDAQInterfaceImplementation& operator=(const AliHLTDAQInterfaceImplementation&); + + ClassDef(AliHLTDAQInterfaceImplementation, 0) +}; + +#endif -- 2.39.3