3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
8 * for The ALICE Off-line Project. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /** @file AliHLTComponent.cxx
20 @author Matthias Richter, Timm Steinbeck
22 @brief Base class implementation for HLT components. */
28 //#include "AliHLTStdIncludes.h"
29 #include "AliHLTComponent.h"
30 #include "AliHLTComponentHandler.h"
31 #include "AliHLTMessage.h"
33 #include "TObjArray.h"
35 #include "TStopwatch.h"
37 /** ROOT macro for the implementation of ROOT specific class methods */
38 ClassImp(AliHLTComponent);
40 /** stopwatch macro using the stopwatch guard */
41 #define ALIHLTCOMPONENT_STOPWATCH(type) AliHLTStopwatchGuard swguard(fpStopwatches!=NULL?reinterpret_cast<TStopwatch*>(fpStopwatches->At((int)type)):NULL)
42 //#define ALIHLTCOMPONENT_STOPWATCH(type)
44 /** stopwatch macro for operations of the base class */
45 #define ALIHLTCOMPONENT_BASE_STOPWATCH() ALIHLTCOMPONENT_STOPWATCH(kSWBase)
46 /** stopwatch macro for operations of the detector algorithm (DA) */
47 #define ALIHLTCOMPONENT_DA_STOPWATCH() ALIHLTCOMPONENT_STOPWATCH(kSWDA)
49 AliHLTComponent::AliHLTComponent()
57 fCurrentInputBlock(-1),
58 fSearchDataType(kAliHLTVoidDataType),
63 fOutputBufferFilled(0),
65 fpStopwatches(new TObjArray(kSWTypeCount))
67 // see header file for class documentation
69 // refer to README to build package
71 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
72 memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
73 if (fgpComponentHandler)
74 fgpComponentHandler->ScheduleRegister(this);
75 SetLocalLoggingLevel(kHLTLogDefault);
78 AliHLTComponent::AliHLTComponent(const AliHLTComponent&)
87 fCurrentInputBlock(-1),
88 fSearchDataType(kAliHLTVoidDataType),
93 fOutputBufferFilled(0),
97 // see header file for class documentation
98 HLTFatal("copy constructor untested");
101 AliHLTComponent& AliHLTComponent::operator=(const AliHLTComponent&)
103 // see header file for class documentation
104 HLTFatal("assignment operator untested");
108 AliHLTComponent::~AliHLTComponent()
110 // see header file for function documentation
111 CleanupInputObjects();
112 if (fpStopwatches!=NULL) delete fpStopwatches;
116 AliHLTComponentHandler* AliHLTComponent::fgpComponentHandler=NULL;
118 int AliHLTComponent::SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite)
120 // see header file for function documentation
122 if (fgpComponentHandler==NULL || bOverwrite!=0)
123 fgpComponentHandler=pCH;
129 int AliHLTComponent::UnsetGlobalComponentHandler()
131 // see header file for function documentation
132 return SetGlobalComponentHandler(NULL,1);
135 int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv )
137 // see header file for function documentation
140 memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment));
141 fEnvironment.fParam=environParam;
143 const char** pArguments=NULL;
148 pArguments=new const char*[argc];
150 for (int i=0; i<argc && iResult>=0; i++) {
152 if (argument.IsNull()) continue;
155 if (argument.CompareTo("benchmark")==0) {
158 } else if (argument.CompareTo("loglevel")==0) {
159 if ((bMissingParam=(++i>=argc))) break;
160 TString parameter(argv[i]);
161 parameter.Remove(TString::kLeading, ' '); // remove all blanks
162 if (parameter.BeginsWith("0x") &&
163 parameter.Replace(0,2,"",0).IsHex()) {
164 AliHLTComponentLogSeverity loglevel=kHLTLogNone;
165 sscanf(parameter.Data(),"%x", (unsigned int*)&loglevel);
166 SetLocalLoggingLevel(loglevel);
168 HLTError("wrong parameter for argument %s, hex number expected", argument.Data());
172 pArguments[iNofChildArgs++]=argv[i];
180 HLTError("missing parameter for argument %s", argument.Data());
184 iResult=DoInit(iNofChildArgs, pArguments);
186 if (iResult>=0) fEventCount=0;
187 if (pArguments) delete [] pArguments;
191 int AliHLTComponent::Deinit()
193 // see header file for function documentation
199 int AliHLTComponent::DoInit( int argc, const char** argv )
201 // see header file for function documentation
202 if (argc==0 && argv==NULL) {
203 // this is currently just to get rid of the warning "unused parameter"
209 int AliHLTComponent::DoDeinit()
211 // see header file for function documentation
216 void AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2] ) const
218 // see header file for function documentation
219 memset( output, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 );
220 strncat( output, type.fOrigin, kAliHLTComponentDataTypefOriginSize );
221 strcat( output, ":" );
222 strncat( output, type.fID, kAliHLTComponentDataTypefIDsize );
225 string AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type )
227 // see header file for function documentation
230 if (type==kAliHLTVoidDataType) {
233 // some gymnastics in order to avoid a '0' which is part of either or both
234 // ID and origin terminating the whole string. Unfortunately, string doesn't
235 // stop appending at the '0' if the number of elements to append was
236 // explicitely specified
238 tmp.append(type.fOrigin, kAliHLTComponentDataTypefOriginSize);
239 out.append(tmp.c_str());
242 tmp.append(type.fID, kAliHLTComponentDataTypefIDsize);
243 out.append(tmp.c_str());
249 void* AliHLTComponent::AllocMemory( unsigned long size )
251 // see header file for function documentation
252 if (fEnvironment.fAllocMemoryFunc)
253 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
254 HLTFatal("no memory allocation handler registered");
258 int AliHLTComponent::MakeOutputDataBlockList( const vector<AliHLTComponentBlockData>& blocks, AliHLTUInt32_t* blockCount,
259 AliHLTComponentBlockData** outputBlocks )
261 // see header file for function documentation
262 if ( blockCount==NULL || outputBlocks==NULL )
264 AliHLTUInt32_t count = blocks.size();
268 *outputBlocks = NULL;
271 *outputBlocks = reinterpret_cast<AliHLTComponentBlockData*>( AllocMemory( sizeof(AliHLTComponentBlockData)*count ) );
272 if ( !*outputBlocks )
274 for ( unsigned long i = 0; i < count; i++ ) {
275 (*outputBlocks)[i] = blocks[i];
276 if (blocks[i].fDataType==kAliHLTAnyDataType) {
277 (*outputBlocks)[i].fDataType=GetOutputDataType();
278 /* data type was set to the output data type by the PubSub AliRoot
279 Wrapper component, if data type of the block was ********:****.
280 Now handled by the component base class in order to have same
281 behavior when running embedded in AliRoot
282 memset((*outputBlocks)[i].fDataType.fID, '*', kAliHLTComponentDataTypefIDsize);
283 memset((*outputBlocks)[i].fDataType.fOrigin, '*', kAliHLTComponentDataTypefOriginSize);
292 int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd )
294 // see header file for function documentation
295 if (fEnvironment.fGetEventDoneDataFunc)
296 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
300 int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponentDataType>* tgtList)
302 // see header file for function documentation
305 vector<AliHLTComponentDataType> ctlist;
306 ((AliHLTComponent*)pConsumer)->GetInputDataTypes(ctlist);
307 vector<AliHLTComponentDataType>::iterator type=ctlist.begin();
308 //AliHLTComponentDataType ouptdt=GetOutputDataType();
309 //PrintDataTypeContent(ouptdt, "publisher \'%s\'");
310 while (type!=ctlist.end() && iResult==0) {
311 //PrintDataTypeContent((*type), "consumer \'%s\'");
312 if ((*type)==GetOutputDataType() ||
313 (*type)==kAliHLTAnyDataType) {
314 if (tgtList) tgtList->push_back(*type);
316 // this loop has to be changed in case of multiple output types
327 void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format) const
329 // see header file for function documentation
330 const char* fmt="publisher \'%s\'";
331 if (format) fmt=format;
332 HLTMessage(fmt, (DataType2Text(dt)).c_str());
333 HLTMessage("%x %x %x %x %x %x %x %x : %x %x %x %x",
348 void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData ) const
350 // see header file for function documentation
351 blockData.fStructSize = sizeof(blockData);
352 FillShmData( blockData.fShmKey );
353 blockData.fOffset = ~(AliHLTUInt32_t)0;
354 blockData.fPtr = NULL;
356 FillDataType( blockData.fDataType );
357 blockData.fSpecification = kAliHLTVoidDataSpec;
360 void AliHLTComponent::FillShmData( AliHLTComponentShmData& shmData ) const
362 // see header file for function documentation
363 shmData.fStructSize = sizeof(shmData);
364 shmData.fShmType = gkAliHLTComponentInvalidShmType;
365 shmData.fShmID = gkAliHLTComponentInvalidShmID;
368 void AliHLTComponent::FillDataType( AliHLTComponentDataType& dataType ) const
370 // see header file for function documentation
371 dataType=kAliHLTAnyDataType;
374 void AliHLTComponent::CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt)
376 // see header file for function documentation
377 memcpy(&tgtdt.fID[0], &srcdt.fID[0], kAliHLTComponentDataTypefIDsize);
378 memcpy(&tgtdt.fOrigin[0], &srcdt.fOrigin[0], kAliHLTComponentDataTypefOriginSize);
381 void AliHLTComponent::SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin)
383 // see header file for function documentation
384 tgtdt.fStructSize = sizeof(AliHLTComponentDataType);
385 memset(&tgtdt.fID[0], 0, kAliHLTComponentDataTypefIDsize);
386 memset(&tgtdt.fOrigin[0], 0, kAliHLTComponentDataTypefOriginSize);
388 if ((int)strlen(id)>kAliHLTComponentDataTypefIDsize) {
389 HLTWarning("data type id %s is too long, truncated to %d", id, kAliHLTComponentDataTypefIDsize);
391 strncpy(&tgtdt.fID[0], id, kAliHLTComponentDataTypefIDsize);
393 if ((int)strlen(origin)>kAliHLTComponentDataTypefOriginSize) {
394 HLTWarning("data type origin %s is too long, truncated to %d", origin, kAliHLTComponentDataTypefOriginSize);
396 strncpy(&tgtdt.fOrigin[0], origin, kAliHLTComponentDataTypefOriginSize);
399 void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData)
401 // see header file for function documentation
402 memset(&evtData, 0, sizeof(AliHLTComponentEventData));
403 evtData.fStructSize=sizeof(AliHLTComponentEventData);
406 void AliHLTComponent::PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt)
408 // see header file for function documentation
410 msg.Form("AliHLTComponentDataType(%d): ID=\"", dt.fStructSize);
411 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) {
412 if (dt.fID[i]!=0) msg+=dt.fID[i];
416 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) {
417 if (dt.fOrigin[i]!=0) msg+=dt.fOrigin[i];
421 AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, msg.Data());
424 int AliHLTComponent::GetEventCount() const
426 // see header file for function documentation
430 int AliHLTComponent::IncrementEventCounter()
432 // see header file for function documentation
433 if (fEventCount>=0) fEventCount++;
437 int AliHLTComponent::GetNumberOfInputBlocks() const
439 // see header file for function documentation
440 if (fpInputBlocks!=NULL) {
441 return fCurrentEventData.fBlockCnt;
446 const TObject* AliHLTComponent::GetFirstInputObject(const AliHLTComponentDataType& dt,
447 const char* classname,
450 // see header file for function documentation
451 ALIHLTCOMPONENT_BASE_STOPWATCH();
453 if (classname) fClassName=classname;
454 else fClassName.clear();
455 int idx=FindInputBlock(fSearchDataType, 0);
456 HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(dt).c_str());
459 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
460 fCurrentInputBlock=idx;
467 const TObject* AliHLTComponent::GetFirstInputObject(const char* dtID,
468 const char* dtOrigin,
469 const char* classname,
472 // see header file for function documentation
473 ALIHLTCOMPONENT_BASE_STOPWATCH();
474 AliHLTComponentDataType dt;
475 SetDataType(dt, dtID, dtOrigin);
476 return GetFirstInputObject(dt, classname, bForce);
479 const TObject* AliHLTComponent::GetNextInputObject(int bForce)
481 // see header file for function documentation
482 ALIHLTCOMPONENT_BASE_STOPWATCH();
483 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1);
484 //HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(fSearchDataType).c_str());
487 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
488 fCurrentInputBlock=idx;
494 int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int startIdx) const
496 // see header file for function documentation
498 if (fpInputBlocks!=NULL) {
499 int idx=startIdx<0?0:startIdx;
500 for ( ; (UInt_t)idx<fCurrentEventData.fBlockCnt && iResult==-ENOENT; idx++) {
501 if (dt == kAliHLTAnyDataType || fpInputBlocks[idx].fDataType == dt) {
509 TObject* AliHLTComponent::CreateInputObject(int idx, int bForce)
511 // see header file for function documentation
513 if (fpInputBlocks!=NULL) {
514 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
515 if (fpInputBlocks[idx].fPtr) {
516 AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
517 if (firstWord==fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) {
518 HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize);
519 AliHLTMessage msg(fpInputBlocks[idx].fPtr, fpInputBlocks[idx].fSize);
520 TClass* objclass=msg.GetClass();
521 pObj=msg.ReadObject(objclass);
522 if (pObj && objclass) {
523 HLTDebug("object %p type %s created", pObj, objclass->GetName());
527 // } else if (bForce!=0) {
528 HLTError("size missmatch: block size %d, indicated %d", fpInputBlocks[idx].fSize, firstWord+sizeof(AliHLTUInt32_t));
531 HLTFatal("block descriptor empty");
534 HLTError("index %d out of range %d", idx, fCurrentEventData.fBlockCnt);
537 HLTError("no input blocks available");
543 TObject* AliHLTComponent::GetInputObject(int idx, const char* classname, int bForce)
545 // see header file for function documentation
546 if (fpInputObjects==NULL) {
547 fpInputObjects=new TObjArray(fCurrentEventData.fBlockCnt);
550 if (fpInputObjects) {
551 pObj=fpInputObjects->At(idx);
553 pObj=CreateInputObject(idx, bForce);
555 fpInputObjects->AddAt(pObj, idx);
559 HLTFatal("memory allocation failed: TObjArray of size %d", fCurrentEventData.fBlockCnt);
564 int AliHLTComponent::CleanupInputObjects()
566 // see header file for function documentation
567 if (!fpInputObjects) return 0;
568 TObjArray* array=fpInputObjects;
570 for (int i=0; i<array->GetEntries(); i++) {
571 TObject* pObj=array->At(i);
572 if (pObj) delete pObj;
578 AliHLTComponentDataType AliHLTComponent::GetDataType(const TObject* pObject)
580 // see header file for function documentation
581 ALIHLTCOMPONENT_BASE_STOPWATCH();
582 AliHLTComponentDataType dt=kAliHLTVoidDataType;
583 int idx=fCurrentInputBlock;
585 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
587 HLTError("unknown object %p", pObject);
591 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
592 dt=fpInputBlocks[idx].fDataType;
594 HLTFatal("severe internal error, index out of range");
600 AliHLTUInt32_t AliHLTComponent::GetSpecification(const TObject* pObject)
602 // see header file for function documentation
603 ALIHLTCOMPONENT_BASE_STOPWATCH();
604 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
605 int idx=fCurrentInputBlock;
607 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
609 HLTError("unknown object %p", pObject);
613 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
614 iSpec=fpInputBlocks[idx].fSpecification;
616 HLTFatal("severe internal error, index out of range");
622 const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const AliHLTComponentDataType& dt)
624 // see header file for function documentation
625 ALIHLTCOMPONENT_BASE_STOPWATCH();
628 int idx=FindInputBlock(fSearchDataType, 0);
629 const AliHLTComponentBlockData* pBlock=NULL;
631 // check for fpInputBlocks pointer done in FindInputBlock
632 pBlock=&fpInputBlocks[idx];
637 const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const char* dtID,
638 const char* dtOrigin)
640 // see header file for function documentation
641 ALIHLTCOMPONENT_BASE_STOPWATCH();
642 AliHLTComponentDataType dt;
643 SetDataType(dt, dtID, dtOrigin);
644 return GetFirstInputBlock(dt);
647 const AliHLTComponentBlockData* AliHLTComponent::GetNextInputBlock()
649 // see header file for function documentation
650 ALIHLTCOMPONENT_BASE_STOPWATCH();
651 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1);
652 const AliHLTComponentBlockData* pBlock=NULL;
654 // check for fpInputBlocks pointer done in FindInputBlock
655 pBlock=&fpInputBlocks[idx];
660 int AliHLTComponent::FindInputBlock(const AliHLTComponentBlockData* pBlock) const
662 // see header file for function documentation
664 if (fpInputBlocks!=NULL) {
666 if (pBlock>=fpInputBlocks && pBlock<fpInputBlocks+fCurrentEventData.fBlockCnt) {
667 iResult=(int)(pBlock-fpInputBlocks);
676 AliHLTUInt32_t AliHLTComponent::GetSpecification(const AliHLTComponentBlockData* pBlock)
678 // see header file for function documentation
679 ALIHLTCOMPONENT_BASE_STOPWATCH();
680 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
681 int idx=fCurrentInputBlock;
683 if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) {
685 HLTError("unknown Block %p", pBlock);
689 // check for fpInputBlocks pointer done in FindInputBlock
690 iSpec=fpInputBlocks[idx].fSpecification;
695 int AliHLTComponent::PushBack(TObject* pObject, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec)
697 // see header file for function documentation
698 ALIHLTCOMPONENT_BASE_STOPWATCH();
701 AliHLTMessage msg(kMESS_OBJECT);
702 msg.WriteObject(pObject);
703 Int_t iMsgLength=msg.Length();
705 msg.SetLength(); // sets the length to the first (reserved) word
706 iResult=InsertOutputBlock(msg.Buffer(), iMsgLength, dt, spec);
708 HLTDebug("object %s (%p) size %d inserted to output", pObject->ClassName(), pObject, iMsgLength);
711 HLTError("object serialization failed for object %p", pObject);
720 int AliHLTComponent::PushBack(TObject* pObject, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec)
722 // see header file for function documentation
723 ALIHLTCOMPONENT_BASE_STOPWATCH();
724 AliHLTComponentDataType dt;
725 SetDataType(dt, dtID, dtOrigin);
726 return PushBack(pObject, dt, spec);
729 int AliHLTComponent::PushBack(void* pBuffer, int iSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec)
731 // see header file for function documentation
732 ALIHLTCOMPONENT_BASE_STOPWATCH();
733 return InsertOutputBlock(pBuffer, iSize, dt, spec);
736 int AliHLTComponent::PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec)
738 // see header file for function documentation
739 ALIHLTCOMPONENT_BASE_STOPWATCH();
740 AliHLTComponentDataType dt;
741 SetDataType(dt, dtID, dtOrigin);
742 return PushBack(pBuffer, iSize, dt, spec);
745 int AliHLTComponent::InsertOutputBlock(void* pBuffer, int iSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec)
747 // see header file for function documentation
750 if (fpOutputBuffer && iSize<=(int)(fOutputBufferSize-fOutputBufferFilled)) {
751 AliHLTUInt8_t* pTgt=fpOutputBuffer+fOutputBufferFilled;
752 AliHLTComponentBlockData bd;
754 bd.fOffset = fOutputBufferFilled;
758 bd.fSpecification = spec;
759 if (pBuffer!=NULL && pBuffer!=pTgt) {
760 memcpy(pTgt, pBuffer, iSize);
761 //AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)pBuffer);
762 //HLTDebug("copy %d bytes from %p to output buffer %p, first word %#x", iSize, pBuffer, pTgt, firstWord);
764 fOutputBufferFilled+=bd.fSize;
765 fOutputBlocks.push_back( bd );
766 //HLTDebug("buffer inserted to output: size %d data type %s spec %#x", iSize, DataType2Text(dt).c_str(), spec);
768 if (fpOutputBuffer) {
769 HLTError("too little space in output buffer: %d, required %d", fOutputBufferSize-fOutputBufferFilled, iSize);
771 HLTError("output buffer not available");
781 int AliHLTComponent::EstimateObjectSize(TObject* pObject) const
783 // see header file for function documentation
784 if (!pObject) return -EINVAL;
785 AliHLTMessage msg(kMESS_OBJECT);
786 msg.WriteObject(pObject);
790 int AliHLTComponent::CreateEventDoneData(AliHLTComponentEventDoneData edd)
792 // see header file for function documentation
794 //#warning function not yet implemented
795 HLTWarning("function not yet implemented");
799 int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
800 const AliHLTComponentBlockData* blocks,
801 AliHLTComponentTriggerData& trigData,
802 AliHLTUInt8_t* outputPtr,
803 AliHLTUInt32_t& size,
804 AliHLTUInt32_t& outputBlockCnt,
805 AliHLTComponentBlockData*& outputBlocks,
806 AliHLTComponentEventDoneData*& edd )
808 // see header file for function documentation
809 ALIHLTCOMPONENT_BASE_STOPWATCH();
811 fCurrentEvent=evtData.fEventID;
812 fCurrentEventData=evtData;
813 fpInputBlocks=blocks;
814 fCurrentInputBlock=-1;
815 fSearchDataType=kAliHLTAnyDataType;
816 fpOutputBuffer=outputPtr;
817 fOutputBufferSize=size;
818 fOutputBufferFilled=0;
819 fOutputBlocks.clear();
821 vector<AliHLTComponentBlockData> blockData;
822 { // dont delete, sets the scope for the stopwatch guard
823 ALIHLTCOMPONENT_DA_STOPWATCH();
824 iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd);
825 } // end of the scope of the stopwatch guard
827 if (fOutputBlocks.size()>0) {
828 //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size());
829 if (blockData.size()>0) {
830 HLTError("low level and high interface must not be mixed; use PushBack methods to insert data blocks");
833 iResult=MakeOutputDataBlockList(fOutputBlocks, &outputBlockCnt, &outputBlocks);
834 size=fOutputBufferFilled;
837 iResult=MakeOutputDataBlockList(blockData, &outputBlockCnt, &outputBlocks);
840 HLTFatal("component %s (%p): can not convert output block descriptor list", GetComponentID(), this);
847 CleanupInputObjects();
848 IncrementEventCounter();
852 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard()
857 // standard constructor (not for use)
860 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(TStopwatch* pStopwatch)
862 fpStopwatch(pStopwatch),
867 // check for already existing guard
868 if (fgpCurrent) fpPrec=fgpCurrent;
871 // stop the preceeding guard if it controls a different stopwatch
873 if (fpPrec && fpPrec!=this) bStart=fpPrec->Hold(fpStopwatch);
875 // start the stopwatch if the current guard controls a different one
876 if (fpStopwatch && bStart==1) fpStopwatch->Start(kFALSE);
879 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(AliHLTStopwatchGuard&)
884 // copy constructor (not for use)
887 AliHLTComponent::AliHLTStopwatchGuard* AliHLTComponent::AliHLTStopwatchGuard::fgpCurrent=NULL;
889 AliHLTComponent::AliHLTStopwatchGuard::~AliHLTStopwatchGuard()
893 // resume the preceeding guard if it controls a different stopwatch
895 if (fpPrec && fpPrec!=this) bStop=fpPrec->Resume(fpStopwatch);
897 // stop the stopwatch if the current guard controls a different one
898 if (fpStopwatch && bStop==1) fpStopwatch->Stop();
900 // resume to the preceeding guard
904 int AliHLTComponent::AliHLTStopwatchGuard::Hold(TStopwatch* pSucc)
906 // see header file for function documentation
907 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Stop();
908 return fpStopwatch!=pSucc?1:0;
911 int AliHLTComponent::AliHLTStopwatchGuard::Resume(TStopwatch* pSucc)
913 // see header file for function documentation
914 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Start(kFALSE);
915 return fpStopwatch!=pSucc?1:0;
918 int AliHLTComponent::SetStopwatch(TObject* pSW, AliHLTStopwatchType type)
920 // see header file for function documentation
922 if (pSW!=NULL && type<kSWTypeCount) {
924 TObject* pObj=fpStopwatches->At((int)type);
925 if (pSW==NULL // explicit reset
926 || pObj==NULL) { // explicit set
927 fpStopwatches->AddAt(pSW, (int)type);
928 } else if (pObj!=pSW) {
929 HLTWarning("stopwatch %d already set, reset first", (int)type);
939 int AliHLTComponent::SetStopwatches(TObjArray* pStopwatches)
941 // see header file for function documentation
942 if (pStopwatches==NULL) return -EINVAL;
945 for (int i=0 ; i<(int)kSWTypeCount && pStopwatches->GetEntries(); i++)
946 SetStopwatch(pStopwatches->At(i), (AliHLTStopwatchType)i);