From 155ff173a11d86d42ddec4962d9abd179a1419ec Mon Sep 17 00:00:00 2001 From: richterm Date: Mon, 19 Nov 2007 10:12:16 +0000 Subject: [PATCH] added HOMER block and source descriptor classes --- HLT/BASE/AliHLTHOMERBlockDesc.cxx | 254 +++++++++++++++++++++++++++++ HLT/BASE/AliHLTHOMERBlockDesc.h | 221 +++++++++++++++++++++++++ HLT/BASE/AliHLTHOMERSourceDesc.cxx | 78 +++++++++ HLT/BASE/AliHLTHOMERSourceDesc.h | 185 +++++++++++++++++++++ HLT/libHLTbase.pkg | 2 + 5 files changed, 740 insertions(+) create mode 100644 HLT/BASE/AliHLTHOMERBlockDesc.cxx create mode 100644 HLT/BASE/AliHLTHOMERBlockDesc.h create mode 100644 HLT/BASE/AliHLTHOMERSourceDesc.cxx create mode 100644 HLT/BASE/AliHLTHOMERSourceDesc.h diff --git a/HLT/BASE/AliHLTHOMERBlockDesc.cxx b/HLT/BASE/AliHLTHOMERBlockDesc.cxx new file mode 100644 index 00000000000..d311d5dbe14 --- /dev/null +++ b/HLT/BASE/AliHLTHOMERBlockDesc.cxx @@ -0,0 +1,254 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Jochen Thaeder * + * 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 AliHLTHOMERBlockDesc.cxx + @author Jochen Thaeder + @date + @brief Container for HOMER Blocks +*/ + +// see header file for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + +#if __GNUC__>= 3 + using namespace std; +#endif + +#include "AliHLTHOMERBlockDesc.h" +#include "AliHLTMessage.h" + +#include "TMath.h" +#include "TClass.h" + + +ClassImp(AliHLTHOMERBlockDesc) + +//################################################################################## +AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() : + fData(NULL), + fSize(0), + fIsTObject(kFALSE), + fIsRawData(kFALSE), + fMessage(NULL), + fClassName(), + fDetector(), + fSubDetector(), + fSubSubDetector(), + fSpecification(0), + fDataType(), + fHasSubDetectorRange(kFALSE), + fHasSubSubDetectorRange(kFALSE) { + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +//################################################################################## +AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc( void * data, ULong_t size, TString origin, + TString dataType, ULong_t specification ) : + fData(data), + fSize(size), + fIsTObject(kFALSE), + fIsRawData(kFALSE), + fMessage(NULL), + fClassName(), + fDetector(origin), + fSubDetector(), + fSubSubDetector(), + fSpecification(specification), + fDataType(dataType), + fHasSubDetectorRange(kFALSE), + fHasSubSubDetectorRange(kFALSE) { + // see header file for class documentation + + // -- Set block parameters + SetBlockParameters(); + +} + +//################################################################################## +AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() { + // see header file for class documentation + + if ( fMessage != NULL ) + delete fMessage; + fMessage = NULL; +} + +//################################################################################## +void AliHLTHOMERBlockDesc::SetBlock( void * data, ULong_t size, TString origin, + TString dataType, ULong_t specification ) { + // see header file for class documentation + + fData = data; + fSize = size; + fDetector = origin; + fDataType = dataType; + fSpecification = specification; + + // -- Set block parameters + SetBlockParameters(); + + return; +} + +//################################################################################## +void AliHLTHOMERBlockDesc::SetBlockParameters() { + // see header file for class documentation + + Int_t iError = 0; + + // ---- SET CLASS NAME, DATA CONTENTS ---- + + // -- Check if block contains raw data + if ( ! CheckIfRawData() ) { + + // -- Check if block contains TObject + if ( ! CheckIfTObject() ) { + + // -- Contains arbitrary data type + + // **** TPC **** + if ( ! fDetector.CompareTo("TPC") ) { + + if ( ! fDataType.CompareTo("CLUSTERS") ) + fClassName = "AliHLTTPCSpacePoints"; + else + iError = 1; + } + + // **** TRD **** + + else if ( ! fDetector.CompareTo("TRD") ) { + iError = 1; + } + + // **** PHOS **** + + else if ( ! fDetector.CompareTo("PHOS") ) { + iError = 1; + } + + // **** MUON **** + + else if ( ! fDetector.CompareTo("MUON") ) { + iError = 1; + } + + // **** OTHER **** + + else { + iError = 1; + } + } + } // if ( ! CheckIfRawData() ) { + + // -- Check if Data Type has been defined + if ( iError ) { + //AliError( Form("The data type %s for the detector %s has not been defined yet.", + // fDataType.Data(), fDetector.Data()) ); + } + + // ---- SET SPECIFICATIONS ---- + // -- Convert Specification to "SubDetector/SubSubDetector" + + // **** TPC **** ( has special treatment ) + + if ( ! fDetector.CompareTo("TPC") ) { + + Int_t minPatch = (fSpecification & 0x000000FF); + Int_t maxPatch = (fSpecification & 0x0000FF00) >> 8; + Int_t minSector = (fSpecification & 0x00FF0000) >> 16 ; + Int_t maxSector = (fSpecification & 0xFF000000) >> 24; + + fSubDetector += minSector; + fSubSubDetector += minPatch; + + // -- check for ranges + if ( minSector != maxSector ) + fHasSubDetectorRange = kTRUE; + + if ( minPatch != maxPatch ) + fHasSubSubDetectorRange = kTRUE; + } + + // **** OTHER DETECTORS **** + + else { + + if ( fSpecification ) { + // find the max bin which is set to 1 + fSubDetector += TMath::FloorNint( TMath::Log2(fSpecification) ); + + // -- check for ranges + if ( TMath::Log2(fSpecification) != ( (Double_t) TMath::FloorNint( TMath::Log2(fSpecification) ) ) ) + fHasSubDetectorRange = kTRUE; + + } + } + + return; +} + +//################################################################################## +Bool_t AliHLTHOMERBlockDesc::CheckIfTObject() { + // see header file for class documentation + + // -- Check Length - First 32 bit word of payload contains the length + UInt_t len = *( (UInt_t*) fData ); + + if ( len != ( fSize - sizeof(UInt_t) ) ) + return fIsTObject; + + // -- set AliHLTMessage + if ( fMessage ) + delete fMessage; + fMessage = NULL; + + fMessage = new AliHLTMessage( fData, fSize ); + + // -- Check if TMessage payload is TObject + if ( fMessage->What() == kMESS_OBJECT ) { + fClassName = fMessage->GetClass()->GetName(); + fIsTObject = kTRUE; + } + + return fIsTObject; +} + +//################################################################################## +Bool_t AliHLTHOMERBlockDesc::CheckIfRawData() { + // see header file for class documentation + + if ( ! fDataType.CompareTo("DDL_RAW") ) + fIsRawData = kTRUE; + + return fIsRawData; +} + +//################################################################################## +TObject* AliHLTHOMERBlockDesc::GetTObject() { + // see header file for class documentation + + if ( fMessage ) + return (TObject*) fMessage->ReadObject( fMessage->GetClass() ); + else + return NULL; +} diff --git a/HLT/BASE/AliHLTHOMERBlockDesc.h b/HLT/BASE/AliHLTHOMERBlockDesc.h new file mode 100644 index 00000000000..85a52003c62 --- /dev/null +++ b/HLT/BASE/AliHLTHOMERBlockDesc.h @@ -0,0 +1,221 @@ +//-*- Mode: C++ -*- +#ifndef ALIHLTHOMERBLOCKDESC_H +#define ALIHLTHOMERBLOCKDESC_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 AliHLTHOMERBlockDesc.h + @author Jochen Thaeder + @date + @brief Container for HOMER Blocks +*/ + +// see below for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + +class AliHLTMessage; + +#include "TString.h" +#include "TObject.h" + +/** + * @class AliHLTHOMERBlockDesc + * This class contains the data which comes from 1 block, delivered via the + * HOMER interface. It used in order to fill these block in TLists. ( It has + * to inherit from TObject ). Further more it reads the specification of the + * block and classifies the data as TObject, raw data, or something else. Mainly + * used in the AliEVEHOMERManager, as data objects for AliEVE. + * + * @ingroup alihlt_homer + */ +class AliHLTHOMERBlockDesc : public TObject { + +public: + + /* + * --------------------------------------------------------------------------------- + * Constructor / Destructor + * --------------------------------------------------------------------------------- + */ + + /** standard constructor */ + AliHLTHOMERBlockDesc(); + + /** Constructor, set block data + * @param data Pointer to data + * @param size Size of data + * @param origin Detector + * @param dataType HLT data type + * @param specification HLT specification + */ + AliHLTHOMERBlockDesc( void * data, ULong_t size, TString origin, TString dataType, ULong_t specification ); + + /** destructor */ + virtual ~AliHLTHOMERBlockDesc(); + + /* + * --------------------------------------------------------------------------------- + * Data Handling - Setter - public + * --------------------------------------------------------------------------------- + */ + + /** Set block data + * @param data Pointer to data + * @param size Size of data + * @param origin Detector + * @param dataType HLT data type + * @param specification HLT specification + */ + void SetBlock( void * data, ULong_t size, TString origin, TString dataType, ULong_t specification ); + + /* + * --------------------------------------------------------------------------------- + * TObject Handling - public + * --------------------------------------------------------------------------------- + */ + + /** Returns if block contains a TObject + * @return Returns kTRUE if block contains a TObject, kFALSE otherwise. + */ + Bool_t IsTObject() { return fIsTObject;} + + /** Returns Pointer to TObject */ + TObject* GetTObject(); + + /* + * --------------------------------------------------------------------------------- + * Data Handling - Getter - public + * --------------------------------------------------------------------------------- + */ + + /** Returns if block contains a raw data, fClassName is not set in this case. + * @return Returns kTRUE if block contains raw data, kFALSE otherwise. + */ + Bool_t IsRawData() { return fIsRawData;} + + /** Get pointer to data + * @return Pointer to data + */ + void* GetData() { return fData; } + + /** Get size of data + * @return Size of data + */ + ULong_t GetSize() { return fSize; } + + /** Get detector of this block + * @return Detector name + */ + TString GetDetector() { return fDetector; } + + /** Get HLT data type of this block + * @return HLT data type + */ + TString GetDataType() { return fDataType; } + + /** Get HLT specification of this block + * @return HLT specification + */ + ULong_t GetSpecification() { return fSpecification; } + + /** Get class name of this block + * @return class name + */ + TString GetClassName() { return fClassName; } + + /** Get sub detector of this block + * @return subdetector + */ + TString GetSubDetector() { return fSubDetector; } + + /** Get sub sub detector of this block + * @return subsubdetector + */ + TString GetSubSubDetector() { return fSubSubDetector; } + + /** Returns kTRUE if HLT specification indicates a subdetector range + * @return kTRUE if subdetector range + */ + Bool_t HasSubDetectorRange() { return fHasSubDetectorRange; } + + /** Returns kTRUE if HLT specification indicates a subsubdetector range + * @return kTRUE if subsubdetector range + */ + Bool_t HasSubSubDetectorRange() { return fHasSubSubDetectorRange; } + + +private: + /** copy constructor prohibited */ + AliHLTHOMERBlockDesc(const AliHLTHOMERBlockDesc&); + + /** assignment operator prohibited */ + AliHLTHOMERBlockDesc& operator=(const AliHLTHOMERBlockDesc&); + + /** Set all additional members*/ + void SetBlockParameters(); + + /** Checks if Block contains a TObject. + * If so, set fIsTObject to kTRUE, otherwise kFALSE + * @return fIsTObject + */ + Bool_t CheckIfTObject(); + + /** Checks if Block contains a TObject raw data. + * If so, set fIsRawData to kTRUE, otherwise kFALSE + * @return fIsRawData + */ + Bool_t CheckIfRawData(); + /* + * --------------------------------------------------------------------------------- + * Members - private + * --------------------------------------------------------------------------------- + */ + + /** Pointer to data of the block */ + void* fData; //! transient + + /** Size of data */ + ULong_t fSize; // see above + + /** States if block contains a TObject */ + Bool_t fIsTObject; // see above + + /** States if block contains a raw data */ + Bool_t fIsRawData; // see above + + /** AliHTMessage object containg a TObject */ + AliHLTMessage* fMessage; //! transient + + /** Class Name of the block */ + TString fClassName; // see above + + /** Detector Name, e.g. PHOS */ + TString fDetector; // see above + + /** SubDetector Name e.g. MODULE */ + TString fSubDetector; // see above + + /** SubSubDetector Name e.g. PARTITION */ + TString fSubSubDetector; // see above + + /** HLT Specification */ + ULong_t fSpecification; // see above + + /** HLT DataType */ + TString fDataType; // see above + + /** States id block has a subdetector range */ + Bool_t fHasSubDetectorRange; // see above + + /** States id block has a subsubdetector range */ + Bool_t fHasSubSubDetectorRange; // see above + + ClassDef( AliHLTHOMERBlockDesc, 0 ) +}; + +#endif diff --git a/HLT/BASE/AliHLTHOMERSourceDesc.cxx b/HLT/BASE/AliHLTHOMERSourceDesc.cxx new file mode 100644 index 00000000000..c6a5215cf21 --- /dev/null +++ b/HLT/BASE/AliHLTHOMERSourceDesc.cxx @@ -0,0 +1,78 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Jochen Thaeder * + * 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 AliHLTHOMERSourceDesc.cxx + @author Jochen Thaeder + @date + @brief Container for HOMER Sources +*/ + +// see header file for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + +#if __GNUC__>= 3 + using namespace std; +#endif + +#include "AliHLTHOMERSourceDesc.h" + + +ClassImp(AliHLTHOMERSourceDesc) + +//################################################################################## +AliHLTHOMERSourceDesc::AliHLTHOMERSourceDesc() : + fSelected( kFALSE ), + fHostname(), + fPort(), + fSourceName(), + fClassName(), + fDetector(), + fSubDetector(), + fSubSubDetector(), + fSpecification(), + fDataType() { + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + + +//################################################################################## +AliHLTHOMERSourceDesc::AliHLTHOMERSourceDesc( TString hostname, Int_t port ) : + fSelected( kFALSE ), + fHostname( hostname ), + fPort( port ), + fSourceName(), + fClassName(), + fDetector(), + fSubDetector(), + fSubSubDetector(), + fSpecification(), + fDataType() { + // see header file for class documentation + +} + + +//################################################################################## +AliHLTHOMERSourceDesc::~AliHLTHOMERSourceDesc() { + // see header file for class documentation +} + diff --git a/HLT/BASE/AliHLTHOMERSourceDesc.h b/HLT/BASE/AliHLTHOMERSourceDesc.h new file mode 100644 index 00000000000..138423c3e6d --- /dev/null +++ b/HLT/BASE/AliHLTHOMERSourceDesc.h @@ -0,0 +1,185 @@ +//-*- Mode: C++ -*- +#ifndef ALIHLTHOMERSOURCEDESC_H +#define ALIHLTHOMERSOURCEDESC_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 AliHLTHOMERSourceDesc.h + @author Jochen Thaeder + @date + @brief Container for HOMER Sources +*/ + +// see below for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + +#include "TString.h" +#include "TObject.h" + +/** + * @class AliHLTHOMERSourceDesc + * This class contains the information of 1 homer source: hostname, port for the HOMER + * interface as well as data specifications. It used in order to fill these sources in + * TLists. ( It has to inherit from TObject ). Further more it knows if this source was + * selected for read from a user. Mainly used in the AliEVEHOMERManager, as source + * objects for AliEVE. + * + * @ingroup alihlt_homer + */ +class AliHLTHOMERSourceDesc : public TObject { + +public: + + /** standard constructor */ + AliHLTHOMERSourceDesc(); + + /** constructor + * @param hostname hostname of the source + * @param port port of the source + */ + AliHLTHOMERSourceDesc( TString hostname, Int_t port ); + + /** destructor */ + virtual ~AliHLTHOMERSourceDesc(); + + // -- SELECTION -- + + /** Set selection state + * @param state state, either kTRUE or kFALSE + */ + void SetState( Bool_t state ) { fSelected = state; } + + /** Checks if Source is selected to readout + * @return returns state, either kTRUE or kFALSE + */ + Bool_t IsSelected() { return fSelected; } + + /** Select this source */ + void Select() { fSelected = kTRUE; } + + /** Deselect this source */ + void Deselect() { fSelected = kFALSE; } + + // -- SETTER -- + + /** Set node name of this source + * @param hostname hostname of the source + * @param port port of the source + */ + void SetHostnamePort( TString hostname, Int_t port ) { fHostname = hostname; fPort = port; } + + /** Set name/obj name of this source + * @param s1 source name + * @param s2 source class name, default is "" + */ + void SetSourceName( TString s1, TString s2="" ) { fSourceName = s1; fClassName = s2; } + + /** Set detector, sub detector and sub sub detector of this source + * @param s1 detector name + * @param s2 subdetector name + * @param s3 subsubdetector name + */ + void SetDetectors( TString s1, TString s2, TString s3 ) { fDetector = s1; fSubDetector = s2; fSubSubDetector = s3; } + + /** Set HLT specification anf HLT data type of this source + * @param ul HLT specification + * @param s HLT data type + */ + void SetSourceType( ULong_t ul, TString s ) { fSpecification = ul, fDataType = s; } + + // -- GETTER -- + + /** Get node name of this source + * @return hostname + */ + TString GetHostname() { return fHostname; } + + /** Get node name of this source + * @return port + */ + Int_t GetPort() { return fPort; } + + /** Get name of this source + * @return #include "TString.h" name + */ + TString GetSourceName() { return fSourceName; } + + /** Get object name of this source + * @return class name + */ + TString GetClassName() { return fClassName; } + + /** Get detector of this source + * @return detector + */ + TString GetDetector() { return fDetector; } + + /** Get sub detector of this source + * @return subdetector + */ + TString GetSubDetector() { return fSubDetector; } + + /** Get sub sub detector of this source + * @return subsubdetector + */ + TString GetSubSubDetector() { return fSubSubDetector; } + + /** Get HLT data type of this source + * @return HLT data type + */ + TString GetDataType() { return fDataType; } + + /** Get HLT specification of this source + * @return HLT specification + */ + ULong_t GetSpecification() { return fSpecification; } + + +private: + /** copy constructor prohibited */ + AliHLTHOMERSourceDesc(const AliHLTHOMERSourceDesc&); + + /** assignment operator prohibited */ + AliHLTHOMERSourceDesc& operator=(const AliHLTHOMERSourceDesc&); + + /** is selected to read out */ + Bool_t fSelected; // see above + + /** Name of HOMER Node */ + TString fHostname; // see above + + /** Name of HOMER port */ + Int_t fPort; // see above + + /** Name of Source */ + TString fSourceName; // see above + + /** Object Name of Source */ + TString fClassName; // see above + + /** Detector Name, e.g. PHOS + * corresponds to HLT origin + */ + TString fDetector; // see above + + /** SubDetector Name e.g. MODULE */ + TString fSubDetector; // see above + + /** SubSubDetector Name e.g. PARTITION */ + TString fSubSubDetector; // see above + + /** HLT Specification */ + ULong_t fSpecification; // see above + + /** HLT DataType */ + TString fDataType; // see above + + ClassDef( AliHLTHOMERSourceDesc, 0 ) +}; + +#endif diff --git a/HLT/libHLTbase.pkg b/HLT/libHLTbase.pkg index 0cc9d2b95d1..94ae885cc10 100644 --- a/HLT/libHLTbase.pkg +++ b/HLT/libHLTbase.pkg @@ -21,6 +21,8 @@ CLASS_HDRS:= AliHLTComponent.h \ AliHLTOfflineDataSink.h \ AliHLTModuleAgent.h \ AliHLTHOMERLibManager.h \ + AliHLTHOMERBlockDesc.h \ + AliHLTHOMERSourceDesc.h \ AliHLTOUT.h \ AliHLTOUTHomerBuffer.h \ AliHLTOUTHandler.h \ -- 2.43.0