memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
if (fgpComponentHandler)
fgpComponentHandler->ScheduleRegister(this);
+ SetLocalLoggingLevel(kHLTLogDefault);
}
AliHLTComponent::AliHLTComponent(const AliHLTComponent&)
AliHLTComponent::~AliHLTComponent()
{
// see header file for function documentation
+ CleanupInputObjects();
}
AliHLTComponentHandler* AliHLTComponent::fgpComponentHandler=NULL;
memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment));
fEnvironment.fParam=environParam;
}
- iResult=DoInit(argc, argv);
+ const char** pArguments=NULL;
+ int iNofChildArgs=0;
+ TString argument="";
+ int bMissingParam=0;
+ if (argc>0) {
+ pArguments=new const char*[argc];
+ if (pArguments) {
+ for (int i=0; i<argc && iResult>=0; i++) {
+ argument=argv[i];
+ if (argument.IsNull()) continue;
+
+ // benchmark
+ if (argument.CompareTo("benchmark")==0) {
+
+ // loglevel
+ } else if (argument.CompareTo("loglevel")==0) {
+ if ((bMissingParam=(++i>=argc))) break;
+ TString parameter(argv[i]);
+ parameter.Remove(TString::kLeading, ' '); // remove all blanks
+ if (parameter.BeginsWith("0x") &&
+ parameter.Replace(0,2,"",0).IsHex()) {
+ AliHLTComponentLogSeverity loglevel=kHLTLogNone;
+ sscanf(parameter.Data(),"%x", &loglevel);
+ SetLocalLoggingLevel(loglevel);
+ } else {
+ HLTError("wrong parameter for argument %s, hex number expected", argument.Data());
+ iResult=-EINVAL;
+ }
+ } else {
+ pArguments[iNofChildArgs++]=argv[i];
+ }
+ }
+ } else {
+ iResult=-ENOMEM;
+ }
+ }
+ if (bMissingParam) {
+ HLTError("missing parameter for argument %s", argument.Data());
+ iResult=-EINVAL;
+ }
+ if (iResult>=0) {
+ iResult=DoInit(iNofChildArgs, pArguments);
+ }
if (iResult>=0) fEventCount=0;
+ if (pArguments) delete [] pArguments;
return iResult;
}
if (classname) fClassName=classname;
else fClassName.clear();
int idx=FindInputBlock(fSearchDataType, 0);
- //HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(dt).c_str());
+ HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(dt).c_str());
TObject* pObj=NULL;
if (idx>=0) {
if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
if (fpInputBlocks[idx].fPtr) {
AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
if (firstWord==fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) {
- //HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize);
+ HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize);
AliHLTMessage msg(fpInputBlocks[idx].fPtr, fpInputBlocks[idx].fSize);
pObj=msg.ReadObject(msg.GetClass());
if (pObj && msg.GetClass()) {
- //HLTDebug("object %p type %s created", pObj, msg.GetClass()->GetName());
+ HLTDebug("object %p type %s created", pObj, msg.GetClass()->GetName());
} else {
}
} else {
return pObj;
}
+int AliHLTComponent::CleanupInputObjects()
+{
+ if (!fpInputObjects) return 0;
+ TObjArray* array=fpInputObjects;
+ fpInputObjects=NULL;
+ for (int i=0; i<array->GetEntries(); i++) {
+ TObject* pObj=array->At(i);
+ if (pObj) delete pObj;
+ }
+ delete array;
+}
+
AliHLTComponentDataType AliHLTComponent::GetDataType(const TObject* pObject)
{
// see header file for function documentation
msg.SetLength(); // sets the length to the first (reserved) word
iResult=InsertOutputBlock(msg.Buffer(), iMsgLength, dt, spec);
if (iResult>=0) {
- //HLTDebug("object %s (%p) inserted to output", pObject->ClassName(), pObject);
+ HLTDebug("object %s (%p) size %d inserted to output", pObject->ClassName(), pObject, iMsgLength);
}
} else {
HLTError("object serialization failed for object %p", pObject);
// see header file for function documentation
int iResult=0;
if (pBuffer) {
- if (fpOutputBuffer && (fOutputBufferSize-fOutputBufferFilled)) {
+ if (fpOutputBuffer && iSize<=(fOutputBufferSize-fOutputBufferFilled)) {
AliHLTUInt8_t* pTgt=fpOutputBuffer+fOutputBufferFilled;
AliHLTComponentBlockData bd;
FillBlockData( bd );
return iResult;
}
+int AliHLTComponent::EstimateObjectSize(TObject* pObject) const
+{
+ if (!pObject) return -EINVAL;
+ AliHLTMessage msg(kMESS_OBJECT);
+ msg.WriteObject(pObject);
+ return msg.Length();
+}
+
int AliHLTComponent::CreateEventDoneData(AliHLTComponentEventDoneData edd)
{
// see header file for function documentation
outputBlockCnt=0;
outputBlocks=NULL;
}
+ CleanupInputObjects();
IncrementEventCounter();
return iResult;
}
* the parameters. The component implementation
* @see AliHLTProcessor AliHLTDataSource AliHLTDataSink
*
+ * \em IMPORTANT: objects and block descriptors provided by the high-level interface
+ * <b>MUST NOT BE DELETED</b> by the caller.
+ *
* @subsubsection alihltcomponent-high-level-int-guidelines High-level interface guidelines
* - Structures must inherit from the ROOT object base class TObject in order be
* transported by the transportation framework.
* If also the class name is provided, the object is checked for the right
* class type. The input data block needs a certain structure, namely the
* buffer size as first word. If the cross check fails, the retrieval is
- * silently abondoned, unless the \em bForce parameter is set.
+ * silently abondoned, unless the \em bForce parameter is set.<br>
+ * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
* @param dt data type of the object
* @param classname class name of the object
* @param bForce force the retrieval of an object, error messages
* If also the class name is provided, the object is checked for the right
* class type. The input data block needs a certain structure, namely the
* buffer size as first word. If the cross check fails, the retrieval is
- * silently abondoned, unless the \em bForce parameter is set.
+ * silently abondoned, unless the \em bForce parameter is set.<br>
+ * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
* @param dtID data type ID of the object
* @param dtOrigin data type origin of the object
* @param classname class name of the object
* The hight-level methods provide functionality to transfer ROOT data
* structures which inherit from TObject.
* The method looks for the next ROOT object of type and class specified
- * to the previous @ref GetFirstInputObject call.
+ * to the previous @ref GetFirstInputObject call.<br>
+ * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
* @param bForce force the retrieval of an object, error messages
* are suppressed if \em bForce is not set
* @return pointer to @ref TObject, NULL if no more objects available
/**
* Get the first block of a specific data type from the input data.
* The method looks for the first block of type dt in the input stream. It is intended
- * to be used within the high-level interface.
+ * to be used within the high-level interface.<br>
+ * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
* @param dt data type of the block
* @return pointer to @ref AliHLTComponentBlockData
*/
* Get the first block of a specific data type from the input data.
* The method looks for the first block of type specified by the ID and
* Origin strings in the input stream. It is intended
- * to be used within the high-level interface.
+ * to be used within the high-level interface.<br>
+ * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
* @param dtID data type ID of the block
* @param dtOrigin data type origin of the block
* @return pointer to @ref AliHLTComponentBlockData
const char* dtOrigin);
/**
- * Get input block by index
+ * Get input block by index.<br>
+ * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
* @return pointer to AliHLTComponentBlockData, NULL if index out of range
*/
const AliHLTComponentBlockData* GetInputBlock(int index);
* Get the next block of a specific data type from the input data.
* The method looks for the next block of type and class specified
* to the previous @ref GetFirstInputBlock call.
- * To be used within the high-level interface.
+ * To be used within the high-level interface.<br>
+ * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
*/
const AliHLTComponentBlockData* GetNextInputBlock();
int PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin,
AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
+ /**
+ * Estimate size of a TObject
+ * @param pObject
+ * @return buffer size in byte
+ */
+ int EstimateObjectSize(TObject* pObject) const;
+
/**
* Insert event-done data information into the output.
* @param edd event-done data information
/**
* Get input object
- * Get object from the input block list
+ * Get object from the input block list. The methods first checks whether the
+ * object was already created. If not, it is created by @ref CreateInputObject
+ * and inserted into the list of objects.
* @param idx index in the input block list
* @param classname name of the class, object is checked for correct class
* name if set
*/
TObject* GetInputObject(int idx, const char* classname=NULL, int bForce=0);
+ /**
+ * Clean the list of input objects.
+ * Cleanup is done at the end of each event processing.
+ */
+ int CleanupInputObjects();
+
/**
* Insert a buffer into the output block stream.
* This is the only method to insert blocks into the output stream, called
vector<AliHLTDataBuffer::AliHLTRawBuffer*> AliHLTDataBuffer::fgActiveBuffers;
AliHLTUInt32_t AliHLTDataBuffer::fgMargin=1024;
AliHLTLogging AliHLTDataBuffer::fgLogging;
+const Int_t AliHLTDataBuffer::fgkSafetyPatternSize=16;
+const char AliHLTDataBuffer::fgkSafetyPattern[]={0x28, 0x63, 0x29, 0x4d, 0x52, 0x49, 0x43, 0x48, 0x54, 0x45, 0x52, 0x20, 0x32, 0x30, 0x30, 0x37};
AliHLTDataBuffer::~AliHLTDataBuffer()
{
} else {
HLTError("block data specification %#d (%s) exceeds size of data buffer", i, AliHLTComponent::DataType2Text(arrayBlockData[i].fDataType).data());
HLTError("block offset=%d, block size=%d, buffer size=%d", arrayBlockData[i].fOffset, arrayBlockData[i].fSize, fpBuffer->fSize);
+ iResult=-E2BIG;
}
}
} else {
HLTError("this data buffer (%p) does not match the internal data buffer %p of raw buffer %p", pTgt, fpBuffer->fPtr, fpBuffer);
+ iResult=-EINVAL;
}
} else {
HLTFatal("internal data structur missmatch");
{
// see header file for function documentation
AliHLTRawBuffer* pRawBuffer=NULL;
+ int reqSize=size+fgkSafetyPatternSize;
vector<AliHLTRawBuffer*>::iterator buffer=fgFreeBuffers.begin();
while (buffer!=fgFreeBuffers.end() && pRawBuffer==NULL) {
- if ((*buffer)->fTotalSize>=size && ((*buffer)->fTotalSize-size)<fgMargin) {
+ if ((*buffer)->fTotalSize>=reqSize && ((*buffer)->fTotalSize-reqSize)<fgMargin) {
// assign this element
pRawBuffer=*buffer;
pRawBuffer->fSize=size;
pRawBuffer=new AliHLTRawBuffer;
if (pRawBuffer) {
memset(pRawBuffer, 0, sizeof(AliHLTRawBuffer));
- pRawBuffer->fPtr=malloc(size);
+ pRawBuffer->fPtr=malloc(reqSize);
if (pRawBuffer->fPtr) {
pRawBuffer->fSize=size;
- pRawBuffer->fTotalSize=size;
+ pRawBuffer->fTotalSize=reqSize;
fgActiveBuffers.push_back(pRawBuffer);
fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "new raw buffer %p of size %d created (container %p)", pRawBuffer->fPtr, pRawBuffer->fTotalSize, pRawBuffer);
+ if (fgkSafetyPatternSize>0) {
+ memcpy(((char*)pRawBuffer->fPtr)+pRawBuffer->fSize, fgkSafetyPattern, fgkSafetyPatternSize);
+ }
} else {
delete pRawBuffer;
pRawBuffer=NULL;
buffer++;
}
if (buffer!=fgActiveBuffers.end()) {
+ if (fgkSafetyPatternSize>0) {
+ if (memcmp(((char*)(*buffer)->fPtr)+(*buffer)->fSize, fgkSafetyPattern, fgkSafetyPatternSize)!=0) {
+ fgLogging.Logging(kHLTLogFatal, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "component has written beyond end of data buffer %p size %d", (*buffer)->fPtr, (*buffer)->fSize);
+ }
+ }
(*buffer)->fSize=0;
fgFreeBuffers.push_back(*buffer);
fgActiveBuffers.erase(buffer);
/** global instance to HLT logging class for static methods */
static AliHLTLogging fgLogging; // see above
+ /** size of the safety pattern */
+ static const Int_t fgkSafetyPatternSize; // see above
+
+ /** the safety pattern */
+ static const char fgkSafetyPattern[]; //!transient
+
//////////////////////////////////////////////////////////////////////////////
// internal helper functions
}
} else {
TObjLink* lnk=fgAgentList.FirstLink();
- log.Logging(kHLTLogInfo, "", "", "-----------------------");
- log.Logging(kHLTLogInfo, "", "", "available module agents");
+ log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
+ log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents");
if (lnk==NULL)
- log.Logging(kHLTLogInfo, "", "", " none");
+ log.Logging(kHLTLogInfo, "AliHLT", "", " none");
while (lnk) {
TString msg;
msg.Form(" %s : %p", ((AliHLTModuleAgent*)lnk->GetObject())->GetName(), lnk->GetObject());
- log.Logging(kHLTLogInfo, "", "", msg.Data());
+ log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data());
lnk=lnk->Next();
}
- log.Logging(kHLTLogInfo, "", "", "-----------------------");
+ log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
}
}
/**
* Default implementation as sources do not have a real FillESD method.
*/
- int FillESD(AliRunLoader* runLoader, AliESD* esd) {
+ int FillESD(int eventNo, AliRunLoader* runLoader, AliESD* esd) {
if (esd==NULL && runLoader==NULL) {
// get rid of 'unused parameter' warning
}
*/
#include "AliHLTOfflineInterface.h"
+#include "AliHLTLogging.h"
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTOfflineInterface)
TList AliHLTOfflineInterface::fgList;
TObjLink* AliHLTOfflineInterface::fgCurrentLnk=NULL;
+AliRunLoader* AliHLTOfflineInterface::fgpRunLoader=NULL;
+AliRawReader* AliHLTOfflineInterface::fgpRawReader=NULL;
AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader)
:
{
}
-const AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const
+AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const
{
- return fpRunLoader;
+ return fpRunLoader!=NULL?fpRunLoader:fgpRunLoader;
}
-const AliRawReader* AliHLTOfflineInterface::GetRawReader() const
+AliRawReader* AliHLTOfflineInterface::GetRawReader() const
{
- return fpRawReader;
+ return fpRawReader!=NULL?fpRawReader:fgpRawReader;
}
int AliHLTOfflineInterface::SetESD(Int_t eventNo, AliESD* pESD)
int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader)
{
// see header file for class documentation
+ AliHLTLogging log;
int iResult=0;
+ int count=0;
+ fgpRunLoader=runLoader;
+ fgpRawReader=rawReader;
fgCurrentLnk=fgList.FirstLink();
while (fgCurrentLnk!=NULL) {
AliHLTOfflineInterface* pComponent=reinterpret_cast<AliHLTOfflineInterface*>(fgCurrentLnk->GetObject());
int iLocal=0;
if (pComponent) iLocal=pComponent->SetParams(runLoader, rawReader);
if (iLocal<0) {
+ log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
+ "parameter initialization failed for component %p with result %d", pComponent, iLocal);
if (iResult>=0) iResult=iLocal;
}
+ count++;
fgCurrentLnk=fgCurrentLnk->Next();
}
+ if (iResult>=0) {
+ log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
+ "parameters set to %d offline interface component(s)", count);
+ }
return iResult;
}
return iResult;
}
-int AliHLTOfflineInterface::FillComponentESDs(AliRunLoader* runLoader, AliESD* esd)
+int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESD* esd)
{
// see header file for class documentation
int iResult=0;
while (fgCurrentLnk!=NULL) {
AliHLTOfflineInterface* pComponent=reinterpret_cast<AliHLTOfflineInterface*>(fgCurrentLnk->GetObject());
int iLocal=0;
- if (pComponent) iLocal=pComponent->FillESD(runLoader, esd);
+ if (pComponent) {
+ pComponent->SetESD(eventNo, esd);
+ if (pComponent->GetRunLoader()!=runLoader) {
+ //HLTWarning("runLoader missmatch: component %p was reconstructed with runLoader %p, but got %p now", pComponent, pComponent->GetRunLoader(), runLoader);
+ }
+ iLocal=pComponent->FillESD(eventNo, runLoader, esd);
+ }
if (iLocal<0) {
if (iResult>=0) iResult=iLocal;
}
/**
* Get the AliRoot run loader.
*/
- const AliRunLoader* GetRunLoader() const;
+ AliRunLoader* GetRunLoader() const;
/**
* Get the AliRoot raw reader
*/
- const AliRawReader* GetRawReader() const;
+ AliRawReader* GetRawReader() const;
/**
* Set AliRoot ESD for the current event.
* Fill ESD for one event.
* Fill the ESD with the previously reconstructed data. It must be implmented
* by the child class.
+ * @param eventNo event No. \em Note: this is an internal enumeration of the
+ * processed events.
* @param runLoader the AliRoot runloader
* @param esd an AliESD instance
* @return neg. error code if failed
*/
- virtual int FillESD(AliRunLoader* runLoader, AliESD* esd)=0;
+ virtual int FillESD(int eventNo, AliRunLoader* runLoader, AliESD* esd)=0;
/**
* Fill ESD for one event.
* The FillESD method of all active AliHLTOfflineDataSink's is called in
* order to fill the ESD with the previously reconstructed data. This method
* works on the global list.
+ * @param eventNo event No. \em Note: this is an internal enumeration of the
+ * processed events.
* @param runLoader the AliRoot runloader
* @param esd an AliESD instance
* @return neg. error code if failed
*/
- static int FillComponentESDs(AliRunLoader* runLoader, AliESD* esd);
+ static int FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESD* esd);
/**
* Reset AliRoot internal params of all active components.
/** the current object link (list position) */
static TObjLink* fgCurrentLnk; // see above
- /** AliRoot run loader instance */
+ /** global AliRoot run loader instance (for all components) */
+ static AliRunLoader* fgpRunLoader; //! transient
+ /** global AliRoot raw reader instance (for all components) */
+ static AliRawReader* fgpRawReader; //! transient
+
+ /** private AliRoot run loader instance */
AliRunLoader* fpRunLoader; //! transient
- /** AliRoot raw reader instance */
+ /** private AliRoot raw reader instance */
AliRawReader* fpRawReader; //! transient
/** AliRoot HLT ESD instance */
AliESD* fpESD; //! transient
#include "AliHLTConfigurationHandler.h"
#include "AliHLTTask.h"
#include "AliHLTModuleAgent.h"
+#include "AliHLTOfflineInterface.h"
#include <TObjArray.h>
#include <TObjString.h>
#include <TString.h>
if (runLoader) {
HLTInfo("Run Loader %p, Raw Reader %p , %d events", runLoader, rawReader, nofEvents);
if (CheckStatus(kReady)) {
- iResult=Run(nofEvents);
+ if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
+ iResult=Run(nofEvents);
+ }
} else {
HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
}
int iResult=0;
if (runLoader) {
HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd);
+ iResult=AliHLTOfflineInterface::FillComponentESDs(eventNo, runLoader, esd);
} else {
HLTError("missing run loader/ESD instance(s)");
iResult=-EINVAL;