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();
114 AliHLTComponentHandler* AliHLTComponent::fgpComponentHandler=NULL;
116 int AliHLTComponent::SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite)
118 // see header file for function documentation
120 if (fgpComponentHandler==NULL || bOverwrite!=0)
121 fgpComponentHandler=pCH;
127 int AliHLTComponent::UnsetGlobalComponentHandler()
129 // see header file for function documentation
130 return SetGlobalComponentHandler(NULL,1);
133 int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv )
135 // see header file for function documentation
138 memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment));
139 fEnvironment.fParam=environParam;
141 const char** pArguments=NULL;
146 pArguments=new const char*[argc];
148 for (int i=0; i<argc && iResult>=0; i++) {
150 if (argument.IsNull()) continue;
153 if (argument.CompareTo("benchmark")==0) {
156 } else if (argument.CompareTo("loglevel")==0) {
157 if ((bMissingParam=(++i>=argc))) break;
158 TString parameter(argv[i]);
159 parameter.Remove(TString::kLeading, ' '); // remove all blanks
160 if (parameter.BeginsWith("0x") &&
161 parameter.Replace(0,2,"",0).IsHex()) {
162 AliHLTComponentLogSeverity loglevel=kHLTLogNone;
163 sscanf(parameter.Data(),"%x", (unsigned int*)&loglevel);
164 SetLocalLoggingLevel(loglevel);
166 HLTError("wrong parameter for argument %s, hex number expected", argument.Data());
170 pArguments[iNofChildArgs++]=argv[i];
178 HLTError("missing parameter for argument %s", argument.Data());
182 iResult=DoInit(iNofChildArgs, pArguments);
184 if (iResult>=0) fEventCount=0;
185 if (pArguments) delete [] pArguments;
189 int AliHLTComponent::Deinit()
191 // see header file for function documentation
197 int AliHLTComponent::DoInit( int argc, const char** argv )
199 // see header file for function documentation
200 if (argc==0 && argv==NULL) {
201 // this is currently just to get rid of the warning "unused parameter"
207 int AliHLTComponent::DoDeinit()
209 // see header file for function documentation
214 void AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2] ) const
216 // see header file for function documentation
217 memset( output, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 );
218 strncat( output, type.fOrigin, kAliHLTComponentDataTypefOriginSize );
219 strcat( output, ":" );
220 strncat( output, type.fID, kAliHLTComponentDataTypefIDsize );
223 string AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type )
225 // see header file for function documentation
228 if (type==kAliHLTVoidDataType) {
231 // some gymnastics in order to avoid a '0' which is part of either or both
232 // ID and origin terminating the whole string. Unfortunately, string doesn't
233 // stop appending at the '0' if the number of elements to append was
234 // explicitely specified
236 tmp.append(type.fOrigin, kAliHLTComponentDataTypefOriginSize);
237 out.append(tmp.c_str());
240 tmp.append(type.fID, kAliHLTComponentDataTypefIDsize);
241 out.append(tmp.c_str());
247 void* AliHLTComponent::AllocMemory( unsigned long size )
249 // see header file for function documentation
250 if (fEnvironment.fAllocMemoryFunc)
251 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
252 HLTFatal("no memory allocation handler registered");
256 int AliHLTComponent::MakeOutputDataBlockList( const vector<AliHLTComponentBlockData>& blocks, AliHLTUInt32_t* blockCount,
257 AliHLTComponentBlockData** outputBlocks )
259 // see header file for function documentation
260 if ( blockCount==NULL || outputBlocks==NULL )
262 AliHLTUInt32_t count = blocks.size();
266 *outputBlocks = NULL;
269 *outputBlocks = reinterpret_cast<AliHLTComponentBlockData*>( AllocMemory( sizeof(AliHLTComponentBlockData)*count ) );
270 if ( !*outputBlocks )
272 for ( unsigned long i = 0; i < count; i++ ) {
273 (*outputBlocks)[i] = blocks[i];
274 if (blocks[i].fDataType==kAliHLTAnyDataType) {
275 (*outputBlocks)[i].fDataType=GetOutputDataType();
276 /* data type was set to the output data type by the PubSub AliRoot
277 Wrapper component, if data type of the block was ********:****.
278 Now handled by the component base class in order to have same
279 behavior when running embedded in AliRoot
280 memset((*outputBlocks)[i].fDataType.fID, '*', kAliHLTComponentDataTypefIDsize);
281 memset((*outputBlocks)[i].fDataType.fOrigin, '*', kAliHLTComponentDataTypefOriginSize);
290 int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd )
292 // see header file for function documentation
293 if (fEnvironment.fGetEventDoneDataFunc)
294 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
298 int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponentDataType>* tgtList)
300 // see header file for function documentation
303 vector<AliHLTComponentDataType> ctlist;
304 ((AliHLTComponent*)pConsumer)->GetInputDataTypes(ctlist);
305 vector<AliHLTComponentDataType>::iterator type=ctlist.begin();
306 //AliHLTComponentDataType ouptdt=GetOutputDataType();
307 //PrintDataTypeContent(ouptdt, "publisher \'%s\'");
308 while (type!=ctlist.end() && iResult==0) {
309 //PrintDataTypeContent((*type), "consumer \'%s\'");
310 if ((*type)==GetOutputDataType() ||
311 (*type)==kAliHLTAnyDataType) {
312 if (tgtList) tgtList->push_back(*type);
314 // this loop has to be changed in case of multiple output types
325 void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format) const
327 // see header file for function documentation
328 const char* fmt="publisher \'%s\'";
329 if (format) fmt=format;
330 HLTMessage(fmt, (DataType2Text(dt)).c_str());
331 HLTMessage("%x %x %x %x %x %x %x %x : %x %x %x %x",
346 void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData ) const
348 // see header file for function documentation
349 blockData.fStructSize = sizeof(blockData);
350 FillShmData( blockData.fShmKey );
351 blockData.fOffset = ~(AliHLTUInt32_t)0;
352 blockData.fPtr = NULL;
354 FillDataType( blockData.fDataType );
355 blockData.fSpecification = kAliHLTVoidDataSpec;
358 void AliHLTComponent::FillShmData( AliHLTComponentShmData& shmData ) const
360 // see header file for function documentation
361 shmData.fStructSize = sizeof(shmData);
362 shmData.fShmType = gkAliHLTComponentInvalidShmType;
363 shmData.fShmID = gkAliHLTComponentInvalidShmID;
366 void AliHLTComponent::FillDataType( AliHLTComponentDataType& dataType ) const
368 // see header file for function documentation
369 dataType=kAliHLTAnyDataType;
372 void AliHLTComponent::CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt)
374 // see header file for function documentation
375 memcpy(&tgtdt.fID[0], &srcdt.fID[0], kAliHLTComponentDataTypefIDsize);
376 memcpy(&tgtdt.fOrigin[0], &srcdt.fOrigin[0], kAliHLTComponentDataTypefOriginSize);
379 void AliHLTComponent::SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin)
381 // see header file for function documentation
382 tgtdt.fStructSize = sizeof(AliHLTComponentDataType);
383 memset(&tgtdt.fID[0], 0, kAliHLTComponentDataTypefIDsize);
384 memset(&tgtdt.fOrigin[0], 0, kAliHLTComponentDataTypefOriginSize);
386 if ((int)strlen(id)>kAliHLTComponentDataTypefIDsize) {
387 HLTWarning("data type id %s is too long, truncated to %d", id, kAliHLTComponentDataTypefIDsize);
389 strncpy(&tgtdt.fID[0], id, kAliHLTComponentDataTypefIDsize);
391 if ((int)strlen(origin)>kAliHLTComponentDataTypefOriginSize) {
392 HLTWarning("data type origin %s is too long, truncated to %d", origin, kAliHLTComponentDataTypefOriginSize);
394 strncpy(&tgtdt.fOrigin[0], origin, kAliHLTComponentDataTypefOriginSize);
397 void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData)
399 // see header file for function documentation
400 memset(&evtData, 0, sizeof(AliHLTComponentEventData));
401 evtData.fStructSize=sizeof(AliHLTComponentEventData);
404 void AliHLTComponent::PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt)
406 // see header file for function documentation
408 msg.Form("AliHLTComponentDataType(%d): ID=\"", dt.fStructSize);
409 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) {
410 if (dt.fID[i]!=0) msg+=dt.fID[i];
414 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) {
415 if (dt.fOrigin[i]!=0) msg+=dt.fOrigin[i];
419 AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, msg.Data());
422 int AliHLTComponent::GetEventCount() const
424 // see header file for function documentation
428 int AliHLTComponent::IncrementEventCounter()
430 // see header file for function documentation
431 if (fEventCount>=0) fEventCount++;
435 int AliHLTComponent::GetNumberOfInputBlocks() const
437 // see header file for function documentation
438 if (fpInputBlocks!=NULL) {
439 return fCurrentEventData.fBlockCnt;
444 const TObject* AliHLTComponent::GetFirstInputObject(const AliHLTComponentDataType& dt,
445 const char* classname,
448 // see header file for function documentation
449 ALIHLTCOMPONENT_BASE_STOPWATCH();
451 if (classname) fClassName=classname;
452 else fClassName.clear();
453 int idx=FindInputBlock(fSearchDataType, 0);
454 HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(dt).c_str());
457 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
458 fCurrentInputBlock=idx;
465 const TObject* AliHLTComponent::GetFirstInputObject(const char* dtID,
466 const char* dtOrigin,
467 const char* classname,
470 // see header file for function documentation
471 ALIHLTCOMPONENT_BASE_STOPWATCH();
472 AliHLTComponentDataType dt;
473 SetDataType(dt, dtID, dtOrigin);
474 return GetFirstInputObject(dt, classname, bForce);
477 const TObject* AliHLTComponent::GetNextInputObject(int bForce)
479 // see header file for function documentation
480 ALIHLTCOMPONENT_BASE_STOPWATCH();
481 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1);
482 //HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(fSearchDataType).c_str());
485 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
486 fCurrentInputBlock=idx;
492 int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int startIdx) const
494 // see header file for function documentation
496 if (fpInputBlocks!=NULL) {
497 int idx=startIdx<0?0:startIdx;
498 for ( ; (UInt_t)idx<fCurrentEventData.fBlockCnt && iResult==-ENOENT; idx++) {
499 if (dt == kAliHLTAnyDataType || fpInputBlocks[idx].fDataType == dt) {
507 TObject* AliHLTComponent::CreateInputObject(int idx, int bForce)
509 // see header file for function documentation
511 if (fpInputBlocks!=NULL) {
512 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
513 if (fpInputBlocks[idx].fPtr) {
514 AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
515 if (firstWord==fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) {
516 HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize);
517 AliHLTMessage msg(fpInputBlocks[idx].fPtr, fpInputBlocks[idx].fSize);
518 TClass* objclass=msg.GetClass();
519 pObj=msg.ReadObject(objclass);
520 if (pObj && objclass) {
521 HLTDebug("object %p type %s created", pObj, objclass->GetName());
525 // } else if (bForce!=0) {
526 HLTError("size missmatch: block size %d, indicated %d", fpInputBlocks[idx].fSize, firstWord+sizeof(AliHLTUInt32_t));
529 HLTFatal("block descriptor empty");
532 HLTError("index %d out of range %d", idx, fCurrentEventData.fBlockCnt);
535 HLTError("no input blocks available");
541 TObject* AliHLTComponent::GetInputObject(int idx, const char* classname, int bForce)
543 // see header file for function documentation
544 if (fpInputObjects==NULL) {
545 fpInputObjects=new TObjArray(fCurrentEventData.fBlockCnt);
548 if (fpInputObjects) {
549 pObj=fpInputObjects->At(idx);
551 pObj=CreateInputObject(idx, bForce);
553 fpInputObjects->AddAt(pObj, idx);
557 HLTFatal("memory allocation failed: TObjArray of size %d", fCurrentEventData.fBlockCnt);
562 int AliHLTComponent::CleanupInputObjects()
564 // see header file for function documentation
565 if (!fpInputObjects) return 0;
566 TObjArray* array=fpInputObjects;
568 for (int i=0; i<array->GetEntries(); i++) {
569 TObject* pObj=array->At(i);
570 if (pObj) delete pObj;
576 AliHLTComponentDataType AliHLTComponent::GetDataType(const TObject* pObject)
578 // see header file for function documentation
579 ALIHLTCOMPONENT_BASE_STOPWATCH();
580 AliHLTComponentDataType dt=kAliHLTVoidDataType;
581 int idx=fCurrentInputBlock;
583 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
585 HLTError("unknown object %p", pObject);
589 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
590 dt=fpInputBlocks[idx].fDataType;
592 HLTFatal("severe internal error, index out of range");
598 AliHLTUInt32_t AliHLTComponent::GetSpecification(const TObject* pObject)
600 // see header file for function documentation
601 ALIHLTCOMPONENT_BASE_STOPWATCH();
602 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
603 int idx=fCurrentInputBlock;
605 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
607 HLTError("unknown object %p", pObject);
611 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
612 iSpec=fpInputBlocks[idx].fSpecification;
614 HLTFatal("severe internal error, index out of range");
620 const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const AliHLTComponentDataType& dt)
622 // see header file for function documentation
623 ALIHLTCOMPONENT_BASE_STOPWATCH();
626 int idx=FindInputBlock(fSearchDataType, 0);
627 const AliHLTComponentBlockData* pBlock=NULL;
629 // check for fpInputBlocks pointer done in FindInputBlock
630 pBlock=&fpInputBlocks[idx];
635 const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const char* dtID,
636 const char* dtOrigin)
638 // see header file for function documentation
639 ALIHLTCOMPONENT_BASE_STOPWATCH();
640 AliHLTComponentDataType dt;
641 SetDataType(dt, dtID, dtOrigin);
642 return GetFirstInputBlock(dt);
645 const AliHLTComponentBlockData* AliHLTComponent::GetNextInputBlock()
647 // see header file for function documentation
648 ALIHLTCOMPONENT_BASE_STOPWATCH();
649 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1);
650 const AliHLTComponentBlockData* pBlock=NULL;
652 // check for fpInputBlocks pointer done in FindInputBlock
653 pBlock=&fpInputBlocks[idx];
658 int AliHLTComponent::FindInputBlock(const AliHLTComponentBlockData* pBlock) const
660 // see header file for function documentation
662 if (fpInputBlocks!=NULL) {
664 if (pBlock>=fpInputBlocks && pBlock<fpInputBlocks+fCurrentEventData.fBlockCnt) {
665 iResult=(int)(pBlock-fpInputBlocks);
674 AliHLTUInt32_t AliHLTComponent::GetSpecification(const AliHLTComponentBlockData* pBlock)
676 // see header file for function documentation
677 ALIHLTCOMPONENT_BASE_STOPWATCH();
678 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
679 int idx=fCurrentInputBlock;
681 if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) {
683 HLTError("unknown Block %p", pBlock);
687 // check for fpInputBlocks pointer done in FindInputBlock
688 iSpec=fpInputBlocks[idx].fSpecification;
693 int AliHLTComponent::PushBack(TObject* pObject, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec)
695 // see header file for function documentation
696 ALIHLTCOMPONENT_BASE_STOPWATCH();
699 AliHLTMessage msg(kMESS_OBJECT);
700 msg.WriteObject(pObject);
701 Int_t iMsgLength=msg.Length();
703 msg.SetLength(); // sets the length to the first (reserved) word
704 iResult=InsertOutputBlock(msg.Buffer(), iMsgLength, dt, spec);
706 HLTDebug("object %s (%p) size %d inserted to output", pObject->ClassName(), pObject, iMsgLength);
709 HLTError("object serialization failed for object %p", pObject);
718 int AliHLTComponent::PushBack(TObject* pObject, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec)
720 // see header file for function documentation
721 ALIHLTCOMPONENT_BASE_STOPWATCH();
722 AliHLTComponentDataType dt;
723 SetDataType(dt, dtID, dtOrigin);
724 return PushBack(pObject, dt, spec);
727 int AliHLTComponent::PushBack(void* pBuffer, int iSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec)
729 // see header file for function documentation
730 ALIHLTCOMPONENT_BASE_STOPWATCH();
731 return InsertOutputBlock(pBuffer, iSize, dt, spec);
734 int AliHLTComponent::PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec)
736 // see header file for function documentation
737 ALIHLTCOMPONENT_BASE_STOPWATCH();
738 AliHLTComponentDataType dt;
739 SetDataType(dt, dtID, dtOrigin);
740 return PushBack(pBuffer, iSize, dt, spec);
743 int AliHLTComponent::InsertOutputBlock(void* pBuffer, int iSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec)
745 // see header file for function documentation
748 if (fpOutputBuffer && iSize<=(int)(fOutputBufferSize-fOutputBufferFilled)) {
749 AliHLTUInt8_t* pTgt=fpOutputBuffer+fOutputBufferFilled;
750 AliHLTComponentBlockData bd;
752 bd.fOffset = fOutputBufferFilled;
756 bd.fSpecification = spec;
757 if (pBuffer!=NULL && pBuffer!=pTgt) {
758 memcpy(pTgt, pBuffer, iSize);
759 //AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)pBuffer);
760 //HLTDebug("copy %d bytes from %p to output buffer %p, first word %#x", iSize, pBuffer, pTgt, firstWord);
762 fOutputBufferFilled+=bd.fSize;
763 fOutputBlocks.push_back( bd );
764 //HLTDebug("buffer inserted to output: size %d data type %s spec %#x", iSize, DataType2Text(dt).c_str(), spec);
766 if (fpOutputBuffer) {
767 HLTError("too little space in output buffer: %d, required %d", fOutputBufferSize-fOutputBufferFilled, iSize);
769 HLTError("output buffer not available");
779 int AliHLTComponent::EstimateObjectSize(TObject* pObject) const
781 // see header file for function documentation
782 if (!pObject) return -EINVAL;
783 AliHLTMessage msg(kMESS_OBJECT);
784 msg.WriteObject(pObject);
788 int AliHLTComponent::CreateEventDoneData(AliHLTComponentEventDoneData edd)
790 // see header file for function documentation
792 //#warning function not yet implemented
793 HLTWarning("function not yet implemented");
797 int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
798 const AliHLTComponentBlockData* blocks,
799 AliHLTComponentTriggerData& trigData,
800 AliHLTUInt8_t* outputPtr,
801 AliHLTUInt32_t& size,
802 AliHLTUInt32_t& outputBlockCnt,
803 AliHLTComponentBlockData*& outputBlocks,
804 AliHLTComponentEventDoneData*& edd )
806 // see header file for function documentation
807 ALIHLTCOMPONENT_BASE_STOPWATCH();
809 fCurrentEvent=evtData.fEventID;
810 fCurrentEventData=evtData;
811 fpInputBlocks=blocks;
812 fCurrentInputBlock=-1;
813 fSearchDataType=kAliHLTAnyDataType;
814 fpOutputBuffer=outputPtr;
815 fOutputBufferSize=size;
816 fOutputBufferFilled=0;
817 fOutputBlocks.clear();
819 vector<AliHLTComponentBlockData> blockData;
820 { // dont delete, sets the scope for the stopwatch guard
821 ALIHLTCOMPONENT_DA_STOPWATCH();
822 iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd);
823 } // end of the scope of the stopwatch guard
825 if (fOutputBlocks.size()>0) {
826 //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size());
827 if (blockData.size()>0) {
828 HLTError("low level and high interface must not be mixed; use PushBack methods to insert data blocks");
831 iResult=MakeOutputDataBlockList(fOutputBlocks, &outputBlockCnt, &outputBlocks);
832 size=fOutputBufferFilled;
835 iResult=MakeOutputDataBlockList(blockData, &outputBlockCnt, &outputBlocks);
838 HLTFatal("component %s (%p): can not convert output block descriptor list", GetComponentID(), this);
845 CleanupInputObjects();
846 IncrementEventCounter();
850 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard()
855 // standard constructor (not for use)
858 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(TStopwatch* pStopwatch)
860 fpStopwatch(pStopwatch),
865 // check for already existing guard
866 if (fgpCurrent) fpPrec=fgpCurrent;
869 // stop the preceeding guard if it controls a different stopwatch
871 if (fpPrec && fpPrec!=this) bStart=fpPrec->Hold(fpStopwatch);
873 // start the stopwatch if the current guard controls a different one
874 if (fpStopwatch && bStart==1) fpStopwatch->Start(kFALSE);
877 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(AliHLTStopwatchGuard&)
882 // copy constructor (not for use)
885 AliHLTComponent::AliHLTStopwatchGuard* AliHLTComponent::AliHLTStopwatchGuard::fgpCurrent=NULL;
887 AliHLTComponent::AliHLTStopwatchGuard::~AliHLTStopwatchGuard()
891 // resume the preceeding guard if it controls a different stopwatch
893 if (fpPrec && fpPrec!=this) bStop=fpPrec->Resume(fpStopwatch);
895 // stop the stopwatch if the current guard controls a different one
896 if (fpStopwatch && bStop==1) fpStopwatch->Stop();
898 // resume to the preceeding guard
902 int AliHLTComponent::AliHLTStopwatchGuard::Hold(TStopwatch* pSucc)
904 // see header file for function documentation
905 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Stop();
906 return fpStopwatch!=pSucc?1:0;
909 int AliHLTComponent::AliHLTStopwatchGuard::Resume(TStopwatch* pSucc)
911 // see header file for function documentation
912 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Start(kFALSE);
913 return fpStopwatch!=pSucc?1:0;
916 int AliHLTComponent::SetStopwatch(TObject* pSW, AliHLTStopwatchType type)
918 // see header file for function documentation
920 if (pSW!=NULL && type<kSWTypeCount) {
922 TObject* pObj=fpStopwatches->At((int)type);
923 if (pSW==NULL // explicit reset
924 || pObj==NULL) { // explicit set
925 fpStopwatches->AddAt(pSW, (int)type);
926 } else if (pObj!=pSW) {
927 HLTWarning("stopwatch %d already set, reset first", (int)type);
937 int AliHLTComponent::SetStopwatches(TObjArray* pStopwatches)
939 // see header file for function documentation
940 if (pStopwatches==NULL) return -EINVAL;
943 for (int i=0 ; i<(int)kSWTypeCount && pStopwatches->GetEntries(); i++)
944 SetStopwatch(pStopwatches->At(i), (AliHLTStopwatchType)i);