#include <cerrno>
#include <cassert>
#include "AliHLTOUT.h"
+#include "TSystem.h"
+#include "TClass.h"
+#include "TROOT.h"
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTOUT)
((src & 0xFF0000ULL) >> 8) |
((src & 0xFF000000ULL) >> 24);
}
+
+AliHLTOUT* AliHLTOUT::New(AliRawReader* pRawReader)
+{
+ // see header file for class documentation
+ AliHLTOUT* instance=New("AliHLTOUTRawReader");
+ if (instance) {
+ instance->SetParam(pRawReader);
+ }
+ return instance;
+}
+
+AliHLTOUT* AliHLTOUT::New(TTree* pDigitTree, int event)
+{
+ // see header file for class documentation
+ AliHLTOUT* instance=New("AliHLTOUTDigitReader");
+ if (instance) {
+ instance->SetParam(pDigitTree, event);
+ }
+ return instance;
+}
+
+AliHLTOUT* AliHLTOUT::New(const char* classname)
+{
+ // see header file for class documentation
+ int iLibResult=0;
+ AliHLTOUT* instance=NULL;
+ AliHLTLogging log;
+ TClass* pCl=NULL;
+ ROOT::NewFunc_t pNewFunc=NULL;
+ do {
+ pCl=TClass::GetClass(classname);
+ } while (!pCl && (iLibResult=gSystem->Load("libHLTRec.so"))==0);
+ if (iLibResult>=0) {
+ if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
+ void* p=(*pNewFunc)(NULL);
+ if (p) {
+ instance=reinterpret_cast<AliHLTOUT*>(p);
+ if (!instance) {
+ log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "type cast to AliHLTOUT instance failed");
+ }
+ } else {
+ log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not create AliHLTOUT instance from class descriptor");
+ }
+ } else {
+ log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not find AliHLTOUT class descriptor");
+ }
+ } else {
+ log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not load libHLTrec library");
+ }
+ return instance;
+}
+
+void AliHLTOUT::Delete(AliHLTOUT* pInstance)
+{
+ // see header file for class documentation
+ if (!pInstance) return;
+
+ // check if the library is still there in order to have the
+ // destructor available
+ TClass* pCl1=TClass::GetClass("AliHLTOUTRawReader");
+ TClass* pCl2=TClass::GetClass("AliHLTOUTDigitReader");
+ if (!pCl1 && !pCl2) {
+ AliHLTLogging log;
+ log.Logging(kHLTLogError, "AliHLTOUT::Delete", "HLTOUT handling", "potential memory leak: libHLTrec library not available, skipping destruction %p", pInstance);
+ return;
+ }
+
+ delete pInstance;
+}
+
+void AliHLTOUT::SetParam(AliRawReader* /*pRawReader*/)
+{
+ // see header file for class documentation
+ // default implementation, we should never get here
+ // this function can only be called from the class itsself and
+ // is intended to be used with the New functions. If we get into
+ // the default implementation there is a class mismatch.
+ assert(0);
+ HLTFatal("severe internal error: class mismatch");
+}
+
+void AliHLTOUT::SetParam(TTree* /*pDigitTree*/, int /*event*/)
+{
+ // see header file for class documentation
+ // default implementation, we should never get here
+ // this function can only be called from the class itsself and
+ // is intended to be used with the New functions. If we get into
+ // the default implementation there is a class mismatch.
+ assert(0);
+ HLTFatal("severe internal error: class mismatch");
+}
class AliHLTOUTHandlerDesc; // AliHLTModuleAgent.h
class AliESDEvent;
class AliHLTReconstructor;
+class AliRawReader;
+class TTree;
#define AliHLTOUTInvalidIndex (~(AliHLTUInt32_t)0)
/** standard destructor */
virtual ~AliHLTOUT();
+ /**
+ * Create an AliHLTOUTRawReader instance.
+ * Helper function to transparently access classes from the
+ * libHLTrec library.
+ */
+ static AliHLTOUT* New(AliRawReader* pRawReader);
+
+ /**
+ * Create an AliHLTOUTDigitReader instance
+ * Helper function to transparently access classes from the
+ * libHLTrec library.
+ */
+ static AliHLTOUT* New(TTree* pDigitTree, int event=-1);
+
+ /**
+ * Delete an instance of the HLTOUT.
+ * Helper function to transparently access classes from the
+ * libHLTrec library. Before deleting, the availability of the
+ * library is checked.
+ */
+ static void Delete(AliHLTOUT* pInstance);
+
/**
* Locking guard for the AliHLTOUT object.
* If the object is locked, the selection of data blocks can not be changed.
* @param dt [in] data type to match <br>
* @param spec [in] data specification to match <br>
* @param handlerType [in] type of the handler
- * @return identifier >0 if success, 0 if no block found <br>
+ * @return block index: >= 0 if success, -ENOENT if no block found <br>
* neg. error code if failed <br>
* -EPERM if access denied (object locked)
*/
/**
* Select the next data block of data type and specification of the previous
* call to @ref SelectFirstDataBlock.
- * @return identifier >0 if success, 0 if no block found <br>
+ * @return block index: >= 0 if success, -ENOENT if no block found <br>
* neg. error code if failed <br>
* -EPERM if access denied (object locked)
*/
*/
const AliHLTOUTHandlerListEntry& FindHandlerDesc(AliHLTUInt32_t blockIndex);
+ /**
+ * Internal New function for the external HLTOUT instances.
+ * Currently supported classes are AliHLTOUTRawReader and
+ * AliHLTOUTDigitReader, both implemented in libHLTrec.so.
+ */
+ static AliHLTOUT* New(const char* classname);
+
+ /**
+ * Set the RawReader as parameter.
+ * The function is for internal use only in conjunction with the
+ * New() functions.
+ */
+ virtual void SetParam(AliRawReader* pRawReader);
+
+ /**
+ * Set the RunLoader as parameter
+ * The function is for internal use only in conjunction with the
+ * New() functions.
+ */
+ virtual void SetParam(TTree* pDigitTree, int event=-1);
+
/** data type for the current block search, set from @ref SelectFirstDataBlock */
AliHLTComponentDataType fSearchDataType; //!transient
#include "AliHLTFileWriter.h"
#include "AliHLTFilePublisher.h"
#include "AliHLTBlockFilterComponent.h"
+#include "AliHLTEsdCollectorComponent.h"
+#include "AliHLTOUTPublisherComponent.h"
/** global instance for agent registration */
AliHLTAgentUtil gAliHLTAgentUtil;
pHandler->AddComponent(new AliHLTFileWriter);
pHandler->AddComponent(new AliHLTFilePublisher);
pHandler->AddComponent(new AliHLTBlockFilterComponent);
+ pHandler->AddComponent(new AliHLTEsdCollectorComponent);
+ pHandler->AddComponent(new AliHLTOUTPublisherComponent);
return 0;
}
// @(#) $Id$
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project *
- * ALICE Experiment at CERN, All rights reserved. *
- * *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
- * 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. *
- **************************************************************************/
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+//* 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 AliHLTBlockFilterComponent.cxx
@author Matthias Richter
@date
@brief A simple data block filter and merger, merges block descriptors
-
- */
-// see header file for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+*/
#include <cstdlib>
#include "AliHLTBlockFilterComponent.h"
HLTDebug("block type %s %#x discarded by filter rules", DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification);
}
}
-// for (int n=0; n<(int)evtData.fBlockCnt; n++ ) {
-// if (IsSelected(blocks[n])) {
-// HLTDebug("block %d type %s %#x (ptr=%p offset=%d size=%d) selected by filter rules",
-// n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification,
-// blocks[n].fPtr, blocks[n].fOffset, blocks[n].fSize);
-// outputBlocks.push_back(blocks[n]);
-// } else {
-// HLTDebug("block %d type %s %#x discarded by filter rules", n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification);
-// }
-// }
size=0;
return iResult;
}
--- /dev/null
+// $Id$
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+//* 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 AliHLTEsdCollectorComponent.cxx
+ @author Matthias Richter
+ @date
+ @brief Base class for writer components to store data in a ROOT file
+
+ */
+
+#include "AliHLTEsdCollectorComponent.h"
+#include "AliHLTEsdManager.h"
+#include "TString.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTEsdCollectorComponent)
+
+AliHLTEsdCollectorComponent::AliHLTEsdCollectorComponent()
+ :
+ AliHLTFileWriter(),
+ fpManager(NULL)
+{
+ // see header file for class documentation
+ // or
+ // refer to README to build package
+ // or
+ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+ // all event go into the same file, but there are individual files for
+ // different data blocks
+ SetMode(kConcatenateEvents);
+}
+
+AliHLTEsdCollectorComponent::~AliHLTEsdCollectorComponent()
+{
+ // see header file for class documentation
+}
+
+int AliHLTEsdCollectorComponent::InitWriter()
+{
+ // see header file for class documentation
+ int iResult=0;
+
+ // choose .root as default extension
+ if (GetExtension().IsNull()) SetExtension("root");
+
+ if ((fpManager=AliHLTEsdManager::New())) {
+ fpManager->SetDirectory(GetDirectory().Data());
+ } else {
+ HLTError("can not find AliHLTEsdManager class descriptor");
+ iResult=-ENODEV;
+ }
+
+ return iResult;
+}
+
+int AliHLTEsdCollectorComponent::CloseWriter()
+{
+ // see header file for class documentation
+ if (fpManager!=NULL) {
+ AliHLTEsdManager::Delete(fpManager);
+ fpManager=NULL;
+ }
+ return 0;
+}
+
+int AliHLTEsdCollectorComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/,
+ const AliHLTComponentBlockData* /*blocks*/,
+ AliHLTComponentTriggerData& /*trigData*/ )
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!fpManager) return -ENODEV;
+
+ for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
+ pBlock && iResult>=0;
+ pBlock=GetNextInputBlock()) {
+ if (pBlock->fDataType!=kAliHLTDataTypeESDObject &&
+ pBlock->fDataType!=kAliHLTDataTypeESDTree) continue;
+ HLTInfo("writing ESD, data type %s", (DataType2Text(pBlock->fDataType).c_str()));
+ iResult=fpManager->WriteESD(reinterpret_cast<const AliHLTUInt8_t*>(pBlock->fPtr),
+ pBlock->fSize, pBlock->fDataType, NULL, GetEventCount());
+ }
+ return iResult;
+}
+
+int AliHLTEsdCollectorComponent::ScanArgument(int /*argc*/, const char** /*argv*/)
+{
+ // see header file for class documentation
+ // no other arguments known
+ int iResult=-EINVAL;
+ return iResult;
+}
--- /dev/null
+// -*- Mode: C++ -*-
+// $Id$
+
+#ifndef ALIHLTESDCOLLECTORCOMPONENT_H
+#define ALIHLTESDCOLLECTORCOMPONENT_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 AliHLTEsdCollectorComponent.h
+ @author Matthias Richter
+ @date
+ @brief Collect ESDs of multiple events and write toi file
+*/
+
+#include "AliHLTFileWriter.h"
+
+class AliHLTEsdManager;
+
+/**
+ * @class AliHLTEsdCollectorComponent
+ * The EsdCollector component merges ESDs from multiple events into one
+ * ESD file per origin using the AliHLTEsdManager class.
+ * \b Note: The component just merges ESDs of the same type/origin from
+ * multiple events into one file. It does not implement merging of ESDs
+ * from one event but several origins.
+ *
+ * Component ID: \b EsdCollector <br>
+ * Library: \b libAliHLTUtil.so
+ *
+ * Mandatory arguments: <br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * Optional arguments: <br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * The only AliHLTFileWriter argument of relevance is the -directory argument.
+ *
+ * See AliHLTFileWriter for full list of arguments.
+ */
+class AliHLTEsdCollectorComponent : public AliHLTFileWriter
+{
+ public:
+ /** standard constructor */
+ AliHLTEsdCollectorComponent();
+ /** destructor */
+ virtual ~AliHLTEsdCollectorComponent();
+
+ /**
+ * The id of the component.
+ * @return component id (string)
+ */
+ const char* GetComponentID() {return "EsdCollector";};
+
+ /**
+ * Spawn function.
+ * @return new class instance
+ */
+ AliHLTComponent* Spawn() {return new AliHLTEsdCollectorComponent;}
+
+ protected:
+ // interface functions
+ int InitWriter();
+ int CloseWriter();
+ int DumpEvent( const AliHLTComponentEventData& evtData,
+ const AliHLTComponentBlockData* blocks,
+ AliHLTComponentTriggerData& trigData );
+
+ using AliHLTFileWriter::DumpEvent;
+ int ScanArgument(int argc, const char** argv);
+
+private:
+ /** copy constructor prohibited */
+ AliHLTEsdCollectorComponent(const AliHLTEsdCollectorComponent&);
+ /** assignment operator prohibited */
+ AliHLTEsdCollectorComponent& operator=(const AliHLTEsdCollectorComponent&);
+
+ /** the ESD manager instance writes the ESDs */
+ AliHLTEsdManager* fpManager; //! transient
+
+ ClassDef(AliHLTEsdCollectorComponent, 0)
+};
+#endif
*/
void SetExtension(const char* extension) {fExtension=extension!=NULL?extension:"";}
+ /**
+ * Get the target directory
+ */
+ TString GetDirectory() {return fDirectory;}
+
/**
* Working modes of the writer
* @internal
--- /dev/null
+// $Id$
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+//* 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 AliHLTOUTPublisherComponent.cxx
+ @author Matthias Richter
+ @date 2008-06-11
+ @brief A data publisher for data block out of the HLTOUT data
+*/
+
+#include <cstdlib>
+#include "AliHLTOUTPublisherComponent.h"
+#include "AliHLTOUT.h"
+#include "TString.h"
+#include "AliRawReader.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTOUTPublisherComponent)
+
+AliHLTOUTPublisherComponent::AliHLTOUTPublisherComponent()
+ :
+ fFilterRules(),
+ fMaxSize(0)
+{
+ // see header file for class documentation
+ // or
+ // refer to README to build package
+ // or
+ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTOUTPublisherComponent::~AliHLTOUTPublisherComponent()
+{
+ // see header file for class documentation
+}
+
+const char* AliHLTOUTPublisherComponent::GetComponentID()
+{
+ // see header file for class documentation
+ return "AliHLTOUTPublisher";
+}
+
+AliHLTComponentDataType AliHLTOUTPublisherComponent::GetOutputDataType()
+{
+ // see header file for class documentation
+ if (fFilterRules.size()==1) return fFilterRules[0].fDataType;
+ if (fFilterRules.size()==0) return kAliHLTAnyDataType;
+ return kAliHLTMultipleDataType;
+}
+
+int AliHLTOUTPublisherComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
+{
+ // see header file for class documentation
+ tgtList.clear();
+ AliHLTComponentBlockDataList::iterator desc=fFilterRules.begin();
+ while (desc!=fFilterRules.end()) {
+ AliHLTComponentDataTypeList::iterator type=tgtList.begin();
+ while (type!=tgtList.end()) {
+ if (*type==(*desc).fDataType) break;
+ type++;
+ }
+ if (type==tgtList.end()) tgtList.push_back((*desc).fDataType);
+ desc++;
+ }
+ return tgtList.size();
+}
+
+void AliHLTOUTPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+ // see header file for class documentation
+ constBase=fMaxSize;
+ inputMultiplier=0.0; // there is no new data, just forwarded descriptors
+}
+
+AliHLTComponent* AliHLTOUTPublisherComponent::Spawn()
+{
+ // see header file for class documentation
+ return new AliHLTOUTPublisherComponent;
+}
+
+int AliHLTOUTPublisherComponent::DoInit( int argc, const char** argv )
+{
+ // see header file for class documentation
+ int iResult=0;
+ TString argument="";
+ int bMissingParam=0;
+ AliHLTComponentBlockData rule;
+ FillBlockData(rule);
+ for (int i=0; i<argc && iResult>=0; i++) {
+ argument=argv[i];
+ if (argument.IsNull()) continue;
+
+ // -datatype
+ if (argument.CompareTo("-datatype")==0) {
+ if ((bMissingParam=(i+2>=argc))) break;
+
+ if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
+ // the data type has already been set, add to list
+ // and reset
+ fFilterRules.push_back(rule);
+ FillBlockData(rule);
+ }
+
+ SetDataType(rule.fDataType, argv[i+1], argv[i+2]);
+ i+=2;
+
+ // -origin
+ } else if (argument.CompareTo("-origin")==0) {
+ if ((bMissingParam=(i+1>=argc))) break;
+
+ if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
+ // the data type has already been set, add to list
+ // and reset
+ fFilterRules.push_back(rule);
+ FillBlockData(rule);
+ }
+
+ SetDataType(rule.fDataType, NULL, argv[i+1]);
+ i+=1;
+
+ // -typeid
+ } else if (argument.CompareTo("-typeid")==0) {
+ if ((bMissingParam=(i+1>=argc))) break;
+
+ if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
+ // the data type has already been set, add to list
+ // and reset
+ fFilterRules.push_back(rule);
+ FillBlockData(rule);
+ }
+
+ SetDataType(rule.fDataType, argv[i+1], NULL);
+ i+=1;
+
+ // -dataspec
+ } else if (argument.CompareTo("-dataspec")==0) {
+ if ((bMissingParam=(++i>=argc))) break;
+
+ if (rule.fSpecification!=kAliHLTVoidDataSpec) {
+ // the specification has already been set, add to list
+ // and reset
+ fFilterRules.push_back(rule);
+ FillBlockData(rule);
+ }
+
+ TString parameter(argv[i]);
+ parameter.Remove(TString::kLeading, ' '); // remove all blanks
+ char* pRemnant=NULL;
+ rule.fSpecification=strtoul(parameter.Data(), &pRemnant, 0);
+ if (pRemnant!=NULL && pRemnant[0]!=0) {
+ HLTError("invalid parameter/remnant (%s) for argument %s, number expected", pRemnant, argument.Data());
+ iResult=-EINVAL;
+ }
+ } else {
+ HLTError("unknown argument %s", argument.Data());
+ iResult=-EINVAL;
+ break;
+ }
+ }
+ if (iResult>=0) {
+ // add the pending rule or at least the empty default rule
+ fFilterRules.push_back(rule);
+ FillBlockData(rule);
+ }
+ return iResult;
+}
+
+int AliHLTOUTPublisherComponent::DoDeinit()
+{
+ // see header file for class documentation
+ int iResult=0;
+ fFilterRules.clear();
+ return iResult;
+}
+
+int AliHLTOUTPublisherComponent::GetEvent( const AliHLTComponentEventData& /*evtData*/,
+ AliHLTComponentTriggerData& /*trigData*/,
+ AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size,
+ AliHLTComponentBlockDataList& outputBlocks )
+{
+ // see header file for class documentation
+ int iResult=0;
+ unsigned int offset=0;
+ AliHLTOUT* pHLTOUT=NULL;
+ AliRawReader* pRawReader=GetRawReader();
+ if (pRawReader) {
+ pRawReader->Reset();
+ pHLTOUT=AliHLTOUT::New(pRawReader);
+// } else {
+ // this is just a hack and work-around for the missing HLT AliLoader.
+ // Because of that the AliRoot framework does not provide the digit tree.
+ // The HLTDigits.root file is opened directly in the AliHLTOUTDigitReader.
+ // Later, the TTree digit tree object must be fetched here and passed to
+ // the HLTOUT instance.
+ // Maybe it's obsolete anyhow:
+ // 1. AliHLT reconstruction from digit data is not supported
+ // 2. When integrated into HLTOUHandler of type kChain, most likely the
+ // AliRawReaderMemory will be used.
+ // The functionality is tested also with the AliHLTOUTDigitReader, for the
+ // mentioned reasons I comment this branch.
+// pHLTOUT=AliHLTOUT::New(NULL, GetEventCount());
+ } else {
+ if (GetEventCount()==0) {
+ HLTFatal("can not get RunLoader or RawReader, event processing aborted for current and subsequent events");
+ }
+ iResult=-ENODEV;
+ }
+ if (iResult>=0 && pHLTOUT) {
+ if ((iResult=pHLTOUT->Init())>=0) {
+ for (iResult=pHLTOUT->SelectFirstDataBlock();
+ iResult>=0;
+ iResult=pHLTOUT->SelectNextDataBlock()) {
+ AliHLTComponentDataType dt=kAliHLTVoidDataType;
+ AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
+ pHLTOUT->GetDataBlockDescription(dt, spec);
+ if (fFilterRules.size()>0) {
+ // check if the block is selected
+ unsigned int rule=0;
+ for (; rule<fFilterRules.size(); rule++) {
+ if (fFilterRules[rule].fDataType!=dt) continue;
+ if (fFilterRules[rule].fSpecification!=kAliHLTVoidDataSpec &&
+ fFilterRules[rule].fSpecification!=spec) continue;
+ break;
+ }
+ // skip the block if none of the filter rules matches
+ if (rule>=fFilterRules.size()) continue;
+ }
+ const AliHLTUInt8_t* pBuffer=NULL;
+ AliHLTUInt32_t bufferSize=0;
+ if ((iResult=pHLTOUT->GetDataBuffer(pBuffer, bufferSize))>=0) {
+ if (bufferSize+offset<=size) {
+ memcpy(outputPtr+offset, pBuffer, bufferSize);
+ AliHLTComponentBlockData bd;
+ FillBlockData( bd );
+ bd.fOffset = offset;
+ bd.fSize = bufferSize;
+ bd.fDataType = dt;
+ bd.fSpecification = spec;
+ outputBlocks.push_back( bd );
+ } else {
+ // we keep the loop going in order to collect the full size
+ fMaxSize=offset+bufferSize;
+ }
+ offset+=bufferSize;
+ }
+ }
+ // -ENOENT is not an error but the return value for 'no more data block'
+ if (iResult==-ENOENT) iResult=0;
+
+ // indicate too little space in buffer for repeated processing
+ if (offset>size) {
+ iResult=-ENOSPC;
+ }
+ } else if (GetEventCount()<5) {
+ const char* message="";
+ if (GetEventCount()==4) message=", suppressing further messages";
+ HLTError("failed initializing HLTOUT%s", message);
+ }
+ AliHLTOUT::Delete(pHLTOUT);
+ pHLTOUT=NULL;
+ } else {
+ if (GetEventCount()==0) {
+ HLTFatal("can not create HLTOUT instance, event processing aborted for current and most likely subsequent events");
+ }
+ iResult=-ENODEV;
+ }
+
+ // finally set the output size
+ size=offset;
+
+ return iResult;
+}
--- /dev/null
+//-*- Mode: C++ -*-
+// $Id$
+
+#ifndef ALIHLTOUTPUBLISHERCOMPONENT_H
+#define ALIHLTOUTPUBLISHERCOMPONENT_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 AliHLTOUTPublisherComponent.h
+ @author Matthias Richter
+ @date 2008-06-11
+ @brief A data publisher for data block out of the HLTOUT data
+*/
+
+#include "AliHLTOfflineDataSource.h"
+
+/**
+ * @class AliHLTOUTPublisherComponent
+ * A data publisher component for data blocks out of the HLTOUT data.
+ * All data blocks forwarded to the HLTOUT (either real or simulated),
+ * are encoded in HOMER format and stored in the HLT data links, or
+ * eventually the HLT digit file in case of simulation.
+ *
+ * This component publishes data blocks out of the HLTOUT data. To the
+ * subscribing components the data blocks seem to come directly from
+ * the producing component in the HLT analysis chain. The HLTOUT is just
+ * a transparent transport layer. Filter rules by data type and
+ * specification can be applied.
+ *
+ * Component ID: \b AliHLTOUTPublisher <br>
+ * Library: \b libAliHLTUtil.
+ *
+ * Mandatory arguments: <br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * Optional arguments:<br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li -datatype <i> id origin </i>
+ * e.g. <tt> -datatype 'ESD_TREE' 'TPC ' </tt> <br>
+ * \b Note: due to the 4-character data origin it might be necessary to
+ * append a blank to the detectorname, e.g. TPC -> 'TPC '
+ * \li -origin <i> origin </i>
+ * e.g. -origin 'TPC ', \b Note: the filter rule has type id 'ANY'
+ * \li -typeid <i> id </i>
+ * e.g. -typeid ESD_TREE, \b Note: the filter rule has origin 'ANY'
+ * \li -dataspec <i> specification </i> <br>
+ * data specification treated as decimal number or hex number if
+ * prepended by '0x'
+ * \li -verbose<br>
+ * print out some more info messages, mainly for the sake of tutorials
+ *
+ * By default, all blocks will be published. By means of the -datatype,
+ * -origin, and -typeid arguments, the blocks can be selected. A list of filter
+ * rules can be built up by multiple usage of the arguments. Each time a new
+ * filter rule is added.
+ *
+ * No filtering by the data specification is applied unless the -specification
+ * argument is used. The specification applies to to the current filter rule,
+ * regardless of the sequence of -datatype/-specification arguments.
+ *
+ * @ingroup alihlt_system
+ */
+class AliHLTOUTPublisherComponent : public AliHLTOfflineDataSource {
+ public:
+ /** standard constructor */
+ AliHLTOUTPublisherComponent();
+ /** destructor */
+ virtual ~AliHLTOUTPublisherComponent();
+
+ const char* GetComponentID();
+ AliHLTComponentDataType GetOutputDataType();
+ int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
+ void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+ virtual AliHLTComponent* Spawn();
+
+ protected:
+ int DoInit( int argc, const char** argv );
+ int DoDeinit();
+
+ /**
+ * Data source method.
+ * @param evtData event data structure
+ * @param trigData trigger data structure
+ * @param outputPtr pointer to target buffer
+ * @param size <i>input</i>: size of target buffer
+ * <i>output</i>:size of produced data
+ * @param outputBlocks list to receive output block descriptors
+ * @return neg. error code if failed
+ */
+ int GetEvent( const AliHLTComponentEventData& evtData,
+ AliHLTComponentTriggerData& trigData,
+ AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size,
+ AliHLTComponentBlockDataList& outputBlocks );
+
+ using AliHLTOfflineDataSource::GetEvent;
+
+ protected:
+
+ private:
+ /** copy constructor prohibited */
+ AliHLTOUTPublisherComponent(const AliHLTOUTPublisherComponent&);
+ /** assignment operator prohibited */
+ AliHLTOUTPublisherComponent& operator=(const AliHLTOUTPublisherComponent&);
+
+ /** filtering rules, only the data type and specification members are use */
+ AliHLTComponentBlockDataList fFilterRules; //! transient
+
+ /** maximum output size */
+ int fMaxSize; //!
+
+ ClassDef(AliHLTOUTPublisherComponent, 0);
+};
+
+#endif
--- /dev/null
+// $Id$
+/**
+ * @file hltout-collect-esd.C
+ * @brief Example for the AliHLTEsdCollectorComponent
+ *
+ * Example macro to run a small chain with the AliHLTOUTPublisherComponent
+ * and the AliHLTEsdCollectorComponent. The AliHLTOUTPublisherComponent
+ * is configured to publish all ESD objects from the HLTOUT data, the
+ * AliHLTEsdCollectorComponent writes the files using the AliHLTEsdManager.
+ *
+ * Usage: aliroot -b -q hltout-collect-esd.C | tee hltout-collect-esd.log
+ *
+ * The macro asumes HLTOUT raw data ddl files in order to open an
+ * AliRawReaderFile, e.g. simulated using the default AliSimulation with
+ * at least SetWriteRawData("HLT") enabled.
+ *
+ * \b Note: The example disables a few steps in the AliReconstruction,
+ * mainly because of crashes in various parts of AliRoot. This does not
+ * have any impact to the HLT features to be presented.
+ *
+ * @author Matthias.Richter@ift.uib.no
+ * @ingroup alihlt_tutorial
+ */
+void hltout_collect_esd()
+{
+ /////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // setup of the HLT system
+ gSystem->Load("libHLTrec");
+ AliHLTSystem* pHLT=AliHLTReconstructorBase::GetInstance();
+ if (!pHLT) {
+ cerr << "fatal error: can not get HLT instance" << endl;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // the configuration chain
+ TString arg;
+
+ // the publisher configuration
+ arg.Form("-typeid ESD_TREE -typeid ALIESDV0");
+ AliHLTConfiguration publisher("hltout-publisher", "AliHLTOUTPublisher" , NULL, arg.Data());
+
+ // the writer configuration
+ arg.Form("");
+ AliHLTConfiguration collector("sink1", "EsdCollector" , "hltout-publisher", arg.Data());
+
+ /////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // setup of the reconstruction
+ AliReconstruction rec;
+ rec.SetInput("./");
+ rec.SetRunLocalReconstruction("HLT");
+ rec.SetRunTracking("");
+ rec.SetFillESD("");
+ rec.SetRunQA(kFALSE);
+ rec.SetFillTriggerESD(kFALSE);
+ rec.SetRunVertexFinder(kFALSE);
+ rec.SetOption("HLT", "libAliHLTUtil.so loglevel=0x7c chains=sink1");
+ rec.Run();
+}
--- /dev/null
+// $Id$
+/**
+ * @file split-hltout.C
+ * @brief Example for the AliHLTOUTPublisherComponent
+ *
+ * Example macro to run a small chain with the AliHLTOUTPublisherComponent.
+ * The AliHLTOUTPublisherComponent is a tool to publish data blocks from
+ * the HLTOUT data stream into an AliHLT reconstruction chain.
+ *
+ * Usage: aliroot -b -q split-hltout.C | tee split-hltout.log
+ *
+ * The macro asumes HLTOUT raw data ddl files in order to open an
+ * AliRawReaderFile, e.g. simulated by sim-hlt-rawddl.C. A small chain with
+ * just a FileWriter connected is run embedded into AliReconstruction.
+ *
+ * \b Note: The example disables a few steps in the AliReconstruction,
+ * mainly because of crashes in various parts of AliRoot. This does not
+ * have any impact to the HLT features to be presented.
+ *
+ * @author Matthias.Richter@ift.uib.no
+ * @ingroup alihlt_tutorial
+ */
+void split_hltout()
+{
+ /////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // setup of the HLT system
+ gSystem->Load("libHLTrec");
+ AliHLTSystem* pHLT=AliHLTReconstructorBase::GetInstance();
+ if (!pHLT) {
+ cerr << "fatal error: can not get HLT instance" << endl;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // the configuration chain
+ TString arg;
+
+ // the publisher configuration
+ arg.Form("");
+ AliHLTConfiguration publisher("hltout-publisher", "AliHLTOUTPublisher" , NULL, arg.Data());
+
+ // the writer configuration
+ arg.Form("-subdir=out%%d -datafile hltout.dat -specfmt=_0x%%x");
+ // see AliHLTFileWriter
+ AliHLTConfiguration fwconf("sink1", "FileWriter" , "hltout-publisher", arg.Data());
+
+ /////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // setup of the reconstruction
+ AliReconstruction rec;
+ rec.SetInput("./");
+ rec.SetRunLocalReconstruction("HLT");
+ rec.SetRunTracking("");
+ rec.SetFillESD("");
+ rec.SetRunQA(kFALSE);
+ rec.SetFillTriggerESD(kFALSE);
+ rec.SetRunVertexFinder(kFALSE);
+ rec.SetOption("HLT", "libAliHLTUtil.so loglevel=0x7c chains=sink1");
+ rec.Run();
+}
AliHLTRootFileStreamerComponent.h \
AliHLTLoaderPublisherComponent.h \
AliHLTRawReaderPublisherComponent.h \
+ AliHLTOUTPublisherComponent.h \
+ AliHLTEsdCollectorComponent.h \
AliHLTDataGenerator.h \
AliHLTBlockFilterComponent.h \
AliHLTAgentUtil.h
return iResult;
}
+
+void AliHLTOUTDigitReader::SetParam(TTree* /*pDigitTree*/, int event)
+{
+ // see header file for class documentation
+
+ // TODO: here we have the implemented to correct loading of
+ // the digit file from the run loader. At time of writing
+ // (Jun 2008) the AliLoader for the HLT is missing in the AliRoot
+ // framework.
+ fEvent=event;
+}
*/
int CloseTree();
+ /**
+ * Set the RunLoader as parameter
+ * The function is for internal use only in conjunction with the
+ * AliHLTOUT::New() functions.
+ */
+ void SetParam(TTree* pDigitTree, int event=-1);
+
/** name of the digit file */
TString fDigitFileName; //! transient
/** current instance of the HOMER reader */
AliHLTHOMERReader* fpCurrent; //!transient
+protected:
/** current event no */
int fEvent; //!transient
+private:
/** instance of the ESD manager for writing and merging */
AliHLTEsdManager* fpEsdManager; //!transient
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTOUTRawReader)
+AliHLTOUTRawReader::AliHLTOUTRawReader()
+ :
+ AliHLTOUTHomerCollection(),
+ fpRawreader(NULL)
+{
+ // see header file for class documentation
+ // or
+ // refer to README to build package
+ // or
+ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
AliHLTOUTRawReader::AliHLTOUTRawReader(AliRawReader* pRawreader, int event, AliHLTEsdManager* pEsdManager)
:
AliHLTOUTHomerCollection(event, pEsdManager),
*/
class AliHLTOUTRawReader : public AliHLTOUTHomerCollection {
public:
+ /** standard constructor */
+ AliHLTOUTRawReader();
/** constructor */
AliHLTOUTRawReader(AliRawReader* pRawReader, int event=-1, AliHLTEsdManager* pEsdManager=NULL);
/** destructor */
int GetEquipmentId();
private:
- /** standard constructor prohibited */
- AliHLTOUTRawReader();
/** copy constructor prohibited */
AliHLTOUTRawReader(const AliHLTOUTRawReader&);
/** assignment operator prohibited */
AliHLTOUTRawReader& operator=(const AliHLTOUTRawReader&);
+ /**
+ * Set the RawReader as parameter.
+ * The function is for internal use only in conjunction with the
+ * AliHLTOUT::New() functions.
+ */
+ void SetParam(AliRawReader* pRawReader) {fpRawreader=pRawReader;}
+
/** the rawreader */
AliRawReader* fpRawreader; //!transient