3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* Timm Steinbeck <timm@kip.uni-heidelberg.de> *
9 //* for The ALICE HLT Project. *
11 //* Permission to use, copy, modify and distribute this software and its *
12 //* documentation strictly for non-commercial purposes is hereby granted *
13 //* without fee, provided that the above copyright notice appears in all *
14 //* copies and that both the copyright notice and this permission notice *
15 //* appear in the supporting documentation. The authors make no claims *
16 //* about the suitability of this software for any purpose. It is *
17 //* provided "as is" without express or implied warranty. *
18 //**************************************************************************
20 /** @file AliHLTComponent.cxx
21 @author Matthias Richter, Timm Steinbeck
23 @brief Base class implementation for HLT components. */
29 //#include "AliHLTStdIncludes.h"
30 #include "AliHLTComponent.h"
31 #include "AliHLTComponentHandler.h"
32 #include "AliHLTMessage.h"
35 #include "TObjArray.h"
36 #include "TObjectTable.h"
38 #include "TStopwatch.h"
39 #include "AliHLTMemoryFile.h"
40 #include "AliHLTMisc.h"
45 * default compression level for ROOT objects
47 #define ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION 5
49 /** ROOT macro for the implementation of ROOT specific class methods */
50 ClassImp(AliHLTComponent);
52 /** stopwatch macro using the stopwatch guard */
53 #define ALIHLTCOMPONENT_STOPWATCH(type) AliHLTStopwatchGuard swguard(fpStopwatches!=NULL?reinterpret_cast<TStopwatch*>(fpStopwatches->At((int)type)):NULL)
54 //#define ALIHLTCOMPONENT_STOPWATCH(type)
56 /** stopwatch macro for operations of the base class */
57 #define ALIHLTCOMPONENT_BASE_STOPWATCH() ALIHLTCOMPONENT_STOPWATCH(kSWBase)
58 /** stopwatch macro for operations of the detector algorithm (DA) */
59 #define ALIHLTCOMPONENT_DA_STOPWATCH() ALIHLTCOMPONENT_STOPWATCH(kSWDA)
61 AliHLTComponent::AliHLTComponent()
69 fCurrentInputBlock(-1),
70 fSearchDataType(kAliHLTVoidDataType),
75 fOutputBufferFilled(0),
77 fpStopwatches(new TObjArray(kSWTypeCount)),
81 fCDBSetRunNoFunc(false),
85 fRequireSteeringBlocks(false),
86 fEventType(gkAliEventTypeUnknown),
89 fEventDoneDataSize(0),
90 fCompressionLevel(ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION)
93 // see header file for class documentation
95 // refer to README to build package
97 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
98 memset(&fEnvironment, 0, sizeof(AliHLTAnalysisEnvironment));
99 if (fgpComponentHandler)
100 fgpComponentHandler->ScheduleRegister(this);
101 //SetLocalLoggingLevel(kHLTLogDefault);
104 AliHLTComponent::~AliHLTComponent()
106 // see header file for function documentation
107 if (fpBenchmark) delete fpBenchmark;
110 CleanupInputObjects();
111 if (fpStopwatches!=NULL) delete fpStopwatches;
113 AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
114 while (element!=fMemFiles.end()) {
116 if ((*element)->IsClosed()==0) {
117 HLTWarning("memory file has not been closed, possible data loss or incomplete buffer");
118 // close but do not flush as we dont know whether the buffer is still valid
119 (*element)->CloseMemoryFile(0);
131 delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
134 AliHLTComponentHandler* AliHLTComponent::fgpComponentHandler=NULL;
136 int AliHLTComponent::SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite)
138 // see header file for function documentation
140 if (fgpComponentHandler==NULL || bOverwrite!=0)
141 fgpComponentHandler=pCH;
147 int AliHLTComponent::UnsetGlobalComponentHandler()
149 // see header file for function documentation
150 return SetGlobalComponentHandler(NULL,1);
153 int AliHLTComponent::Init(const AliHLTAnalysisEnvironment* comenv, void* environParam, int argc, const char** argv )
155 // see header file for function documentation
156 HLTLogKeyword(GetComponentID());
159 memset(&fEnvironment, 0, sizeof(AliHLTAnalysisEnvironment));
160 memcpy(&fEnvironment, comenv, comenv->fStructSize<sizeof(AliHLTAnalysisEnvironment)?comenv->fStructSize:sizeof(AliHLTAnalysisEnvironment));
161 fEnvironment.fStructSize=sizeof(AliHLTAnalysisEnvironment);
162 fEnvironment.fParam=environParam;
165 const char** pArguments=NULL;
170 pArguments=new const char*[argc];
172 for (int i=0; i<argc && iResult>=0; i++) {
173 if (fComponentArgs.size()>0) fComponentArgs+=" ";
174 fComponentArgs+=argv[i];
176 if (argument.IsNull()) continue;
179 if (argument.CompareTo("benchmark")==0) {
182 } else if (argument.CompareTo("loglevel")==0) {
183 if ((bMissingParam=(++i>=argc))) break;
184 TString parameter(argv[i]);
185 parameter.Remove(TString::kLeading, ' '); // remove all blanks
186 if (parameter.BeginsWith("0x") &&
187 parameter.Replace(0,2,"",0).IsHex()) {
188 unsigned int loglevel=kHLTLogNone;
189 sscanf(parameter.Data(),"%x", &loglevel);
190 SetLocalLoggingLevel((AliHLTComponentLogSeverity)loglevel);
192 HLTError("wrong parameter for argument %s, hex number expected", argument.Data());
195 // -object-compression=
196 } else if (argument.BeginsWith("-object-compression=")) {
197 argument.ReplaceAll("-object-compression=", "");
198 if (argument.IsDigit()) {
199 fCompressionLevel=argument.Atoi();
200 if (fCompressionLevel<0 || fCompressionLevel>9) {
201 HLTWarning("invalid compression level %d, setting to default %d", fCompressionLevel, ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION);
202 fCompressionLevel=ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION;
205 HLTError("wrong parameter for argument -object-compression, number expected");
208 pArguments[iNofChildArgs++]=argv[i];
216 HLTError("missing parameter for argument %s", argument.Data());
220 iResult=DoInit(iNofChildArgs, pArguments);
225 // find out if the component wants to get the steering events
227 AliHLTComponentDataTypeList inputDt;
228 GetInputDataTypes(inputDt);
229 for (AliHLTComponentDataTypeList::iterator dt=inputDt.begin();
230 dt!=inputDt.end() && !fRequireSteeringBlocks;
232 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeSOR);
233 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeRunType);
234 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeEOR);
235 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeDDL);
236 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeComponentStatistics);
239 if (pArguments) delete [] pArguments;
241 #if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
242 // benchmarking stopwatch for the component statistics
243 fpBenchmark=new TStopwatch;
245 fpBenchmark->Start();
252 int AliHLTComponent::Deinit()
254 // see header file for function documentation
255 HLTLogKeyword(GetComponentID());
259 HLTWarning("did not receive EOR for run %d", fpRunDesc->fRunNo);
260 AliHLTRunDesc* pRunDesc=fpRunDesc;
268 int AliHLTComponent::InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler)
270 // see header file for function documentation
273 // I have to think about separating the library handling from the
274 // component handler. Requiring the component hanlder here is not
275 // the cleanest solution.
276 // We presume the library already to be loaded
278 AliHLTMiscInitCDB_t pFunc=(AliHLTMiscInitCDB_t)pHandler->FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_INIT_CDB);
281 if (cdbPath && cdbPath[0]!=0) {
283 // very temporary fix, have to check for other formats
284 if (!path.BeginsWith("local://")) {
289 if ((iResult=(*pFunc)(path.Data()))>=0) {
290 if (!(fCDBSetRunNoFunc=pHandler->FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_SET_CDB_RUNNO))) {
291 Message(NULL, kHLTLogWarning, "AliHLTComponent::InitCDB", "init CDB",
292 "can not find function to set CDB run no");
296 Message(NULL, kHLTLogError, "AliHLTComponent::InitCDB", "init CDB",
297 "can not find initialization function");
306 int AliHLTComponent::SetCDBRunNo(int runNo)
308 // see header file for function documentation
309 if (!fCDBSetRunNoFunc) return 0;
310 return (*((AliHLTMiscSetCDBRunNo_t)fCDBSetRunNoFunc))(runNo);
313 int AliHLTComponent::SetRunDescription(const AliHLTRunDesc* desc, const char* /*runType*/)
315 // see header file for function documentation
316 if (!desc) return -EINVAL;
317 if (desc->fStructSize!=sizeof(AliHLTRunDesc)) {
318 HLTError("invalid size of RunDesc struct (%ul)", desc->fStructSize);
323 fpRunDesc=new AliHLTRunDesc;
324 if (!fpRunDesc) return -ENOMEM;
325 *fpRunDesc=kAliHLTVoidRunDesc;
328 if (fpRunDesc->fRunNo!=kAliHLTVoidRunNo && fpRunDesc->fRunNo!=desc->fRunNo) {
329 HLTWarning("Run description has already been set");
332 SetCDBRunNo(fpRunDesc->fRunNo);
333 // TODO: we have to decide about the runType
337 int AliHLTComponent::SetComponentDescription(const char* desc)
339 // see header file for function documentation
343 TString descriptor=desc;
344 TObjArray* pTokens=descriptor.Tokenize(" ");
346 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
347 TString argument=((TObjString*)pTokens->At(i++))->GetString();
348 if (!argument || argument.IsNull()) continue;
351 if (argument.BeginsWith("chainid")) {
352 argument.ReplaceAll("chainid", "");
353 if (argument.BeginsWith("=")) {
354 fChainId=argument.Replace(0,1,"");
355 fChainIdCrc=CalculateChecksum((const AliHLTUInt8_t*)fChainId.c_str(), fChainId.length());
356 HLTDebug("setting component description: chain id %s crc 0x%8x", fChainId.c_str(), fChainIdCrc);
361 HLTWarning("unknown component description %s", argument.Data());
369 int AliHLTComponent::DoInit( int /*argc*/, const char** /*argv*/)
371 // default implementation, childs can overload
372 HLTLogKeyword("dummy");
376 int AliHLTComponent::DoDeinit()
378 // default implementation, childs can overload
379 HLTLogKeyword("dummy");
383 int AliHLTComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
385 // default implementation, childs can overload
386 HLTLogKeyword("dummy");
390 int AliHLTComponent::ReadPreprocessorValues(const char* /*modules*/)
392 // default implementation, childs can overload
393 HLTLogKeyword("dummy");
397 int AliHLTComponent::StartOfRun()
399 // default implementation, childs can overload
400 HLTLogKeyword("dummy");
404 int AliHLTComponent::EndOfRun()
406 // default implementation, childs can overload
407 HLTLogKeyword("dummy");
412 int AliHLTComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& /*tgtList*/)
414 // default implementation, childs can overload
415 HLTLogKeyword("dummy");
419 void AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2] ) const
421 // see header file for function documentation
422 memset( output, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 );
423 strncat( output, type.fOrigin, kAliHLTComponentDataTypefOriginSize );
424 strcat( output, ":" );
425 strncat( output, type.fID, kAliHLTComponentDataTypefIDsize );
428 string AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, int mode)
430 // see header file for function documentation
436 for (i=0; i<kAliHLTComponentDataTypefOriginSize; i++) {
437 sprintf(tmp, "'%d", type.fOrigin[i]);
441 for (i=0; i<kAliHLTComponentDataTypefIDsize; i++) {
442 sprintf(tmp, "%d'", type.fID[i]);
451 for (i=0; i<kAliHLTComponentDataTypefOriginSize; i++) {
452 unsigned char* puc=(unsigned char*)type.fOrigin;
454 sprintf(tmp, "'\\%x", type.fOrigin[i]);
456 sprintf(tmp, "'%c", type.fOrigin[i]);
460 for (i=0; i<kAliHLTComponentDataTypefIDsize; i++) {
461 unsigned char* puc=(unsigned char*)type.fID;
463 sprintf(tmp, "\\%x'", type.fID[i]);
465 sprintf(tmp, "%c'", type.fID[i]);
471 if (type==kAliHLTVoidDataType) {
474 // some gymnastics in order to avoid a '0' which is part of either or both
475 // ID and origin terminating the whole string. Unfortunately, string doesn't
476 // stop appending at the '0' if the number of elements to append was
477 // explicitely specified
479 tmp.append(type.fOrigin, kAliHLTComponentDataTypefOriginSize);
480 out.append(tmp.c_str());
483 tmp.append(type.fID, kAliHLTComponentDataTypefIDsize);
484 out.append(tmp.c_str());
490 void* AliHLTComponent::AllocMemory( unsigned long size )
492 // see header file for function documentation
493 if (fEnvironment.fAllocMemoryFunc)
494 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
495 HLTFatal("no memory allocation handler registered");
499 int AliHLTComponent::MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
500 AliHLTComponentBlockData** outputBlocks )
502 // see header file for function documentation
503 if ( blockCount==NULL || outputBlocks==NULL )
505 AliHLTUInt32_t count = blocks.size();
509 *outputBlocks = NULL;
512 *outputBlocks = reinterpret_cast<AliHLTComponentBlockData*>( AllocMemory( sizeof(AliHLTComponentBlockData)*count ) );
513 if ( !*outputBlocks )
515 for ( unsigned long i = 0; i < count; i++ ) {
516 (*outputBlocks)[i] = blocks[i];
517 if (MatchExactly(blocks[i].fDataType, kAliHLTAnyDataType)) {
518 (*outputBlocks)[i].fDataType=GetOutputDataType();
519 /* data type was set to the output data type by the PubSub AliRoot
520 Wrapper component, if data type of the block was ********:****.
521 Now handled by the component base class in order to have same
522 behavior when running embedded in AliRoot
523 memset((*outputBlocks)[i].fDataType.fID, '*', kAliHLTComponentDataTypefIDsize);
524 memset((*outputBlocks)[i].fDataType.fOrigin, '*', kAliHLTComponentDataTypefOriginSize);
533 int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd )
535 // see header file for function documentation
536 if (fEnvironment.fGetEventDoneDataFunc)
537 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
541 int AliHLTComponent::ReserveEventDoneData( unsigned long size )
543 // see header file for function documentation
547 if (size>fEventDoneDataSize) {
548 AliHLTComponentEventDoneData* newEDD = reinterpret_cast<AliHLTComponentEventDoneData*>( new AliHLTUInt8_t[ sizeof(AliHLTComponentEventDoneData)+size ] );
551 newEDD->fStructSize = sizeof(AliHLTComponentEventDoneData);
552 newEDD->fDataSize = 0;
553 newEDD->fData = reinterpret_cast<AliHLTUInt8_t*>(newEDD)+newEDD->fStructSize;
554 if (fEventDoneData) {
555 memcpy( newEDD->fData, fEventDoneData->fData, fEventDoneData->fDataSize );
556 newEDD->fDataSize = fEventDoneData->fDataSize;
557 delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
559 fEventDoneData = newEDD;
560 fEventDoneDataSize = size;
566 int AliHLTComponent::PushEventDoneData( AliHLTUInt32_t eddDataWord )
570 if (fEventDoneData->fDataSize+sizeof(AliHLTUInt32_t)>fEventDoneDataSize)
572 *reinterpret_cast<AliHLTUInt32_t*>((reinterpret_cast<AliHLTUInt8_t*>(fEventDoneData->fData)+fEventDoneData->fDataSize)) = eddDataWord;
573 fEventDoneData->fDataSize += sizeof(AliHLTUInt32_t);
577 void AliHLTComponent::ReleaseEventDoneData()
580 delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
581 fEventDoneData = NULL;
582 fEventDoneDataSize = 0;
586 int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList)
588 // see header file for function documentation
591 AliHLTComponentDataTypeList itypes;
592 AliHLTComponentDataTypeList otypes;
593 otypes.push_back(GetOutputDataType());
594 if (otypes[0]==kAliHLTMultipleDataType) {
597 if ((count=GetOutputDataTypes(otypes))>0) {
598 } else if (GetComponentType()!=kSink) {
599 HLTWarning("component %s indicates multiple output data types but GetOutputDataTypes returns %d", GetComponentID(), count);
602 ((AliHLTComponent*)pConsumer)->GetInputDataTypes(itypes);
603 AliHLTComponentDataTypeList::iterator otype=otypes.begin();
604 for (;otype!=otypes.end();otype++) {
605 //PrintDataTypeContent((*otype), "publisher \'%s\'");
606 if ((*otype)==(kAliHLTAnyDataType|kAliHLTDataOriginPrivate)) {
607 if (tgtList) tgtList->push_back(*otype);
612 AliHLTComponentDataTypeList::iterator itype=itypes.begin();
613 for ( ; itype!=itypes.end() && (*itype)!=(*otype) ; itype++) {/* empty body */};
614 //if (itype!=itypes.end()) PrintDataTypeContent(*itype, "consumer \'%s\'");
615 if (itype!=itypes.end()) {
616 if (tgtList) tgtList->push_back(*otype);
626 void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format)
628 // see header file for function documentation
629 const char* fmt="\'%s\'";
630 if (format) fmt=format;
631 AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, Form(fmt, (DataType2Text(dt)).c_str()));
632 AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL,
633 Form("%x %x %x %x %x %x %x %x : %x %x %x %x",
648 void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData )
650 // see header file for function documentation
651 blockData.fStructSize = sizeof(blockData);
652 FillShmData( blockData.fShmKey );
653 blockData.fOffset = ~(AliHLTUInt32_t)0;
654 blockData.fPtr = NULL;
656 FillDataType( blockData.fDataType );
657 blockData.fSpecification = kAliHLTVoidDataSpec;
660 void AliHLTComponent::FillShmData( AliHLTComponentShmData& shmData )
662 // see header file for function documentation
663 shmData.fStructSize = sizeof(shmData);
664 shmData.fShmType = gkAliHLTComponentInvalidShmType;
665 shmData.fShmID = gkAliHLTComponentInvalidShmID;
668 void AliHLTComponent::FillDataType( AliHLTComponentDataType& dataType )
670 // see header file for function documentation
671 dataType=kAliHLTAnyDataType;
674 void AliHLTComponent::CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt)
676 // see header file for function documentation
677 memcpy(&tgtdt.fID[0], &srcdt.fID[0], kAliHLTComponentDataTypefIDsize);
678 memcpy(&tgtdt.fOrigin[0], &srcdt.fOrigin[0], kAliHLTComponentDataTypefOriginSize);
681 void AliHLTComponent::SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin)
683 // see header file for function documentation
684 tgtdt.fStructSize=sizeof(AliHLTComponentDataType);
686 memset(&tgtdt.fID[0], 0, kAliHLTComponentDataTypefIDsize);
687 strncpy(&tgtdt.fID[0], id, strlen(id)<(size_t)kAliHLTComponentDataTypefIDsize?strlen(id):kAliHLTComponentDataTypefIDsize);
690 memset(&tgtdt.fOrigin[0], 0, kAliHLTComponentDataTypefOriginSize);
691 strncpy(&tgtdt.fOrigin[0], origin, strlen(origin)<(size_t)kAliHLTComponentDataTypefOriginSize?strlen(origin):kAliHLTComponentDataTypefOriginSize);
695 void AliHLTComponent::SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t origin)
697 // see header file for function documentation
698 dt.fStructSize=sizeof(AliHLTComponentDataType);
699 assert(kAliHLTComponentDataTypefIDsize==sizeof(id));
700 assert(kAliHLTComponentDataTypefOriginSize==sizeof(origin));
701 memcpy(&dt.fID, &id, kAliHLTComponentDataTypefIDsize);
702 memcpy(&dt.fOrigin, &origin, kAliHLTComponentDataTypefOriginSize);
705 void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData)
707 // see header file for function documentation
708 memset(&evtData, 0, sizeof(AliHLTComponentEventData));
709 evtData.fStructSize=sizeof(AliHLTComponentEventData);
710 evtData.fEventID=kAliHLTVoidEventID;
713 void AliHLTComponent::PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt)
715 // see header file for function documentation
717 msg.Form("AliHLTComponentDataType(%d): ID=\"", dt.fStructSize);
718 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) {
719 if (dt.fID[i]!=0) msg+=dt.fID[i];
723 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) {
724 if (dt.fOrigin[i]!=0) msg+=dt.fOrigin[i];
728 AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, msg.Data());
731 int AliHLTComponent::GetEventCount() const
733 // see header file for function documentation
737 int AliHLTComponent::IncrementEventCounter()
739 // see header file for function documentation
740 if (fEventCount>=0) fEventCount++;
744 int AliHLTComponent::GetNumberOfInputBlocks() const
746 // see header file for function documentation
747 if (fpInputBlocks!=NULL) {
748 return fCurrentEventData.fBlockCnt;
753 AliHLTEventID_t AliHLTComponent::GetEventId() const
755 // see header file for function documentation
756 if (fpInputBlocks!=NULL) {
757 return fCurrentEventData.fEventID;
762 const TObject* AliHLTComponent::GetFirstInputObject(const AliHLTComponentDataType& dt,
763 const char* classname,
766 // see header file for function documentation
767 ALIHLTCOMPONENT_BASE_STOPWATCH();
769 if (classname) fClassName=classname;
770 else fClassName.clear();
771 int idx=FindInputBlock(fSearchDataType, 0, 1);
774 HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(dt).c_str());
775 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
776 fCurrentInputBlock=idx;
783 const TObject* AliHLTComponent::GetFirstInputObject(const char* dtID,
784 const char* dtOrigin,
785 const char* classname,
788 // see header file for function documentation
789 ALIHLTCOMPONENT_BASE_STOPWATCH();
790 AliHLTComponentDataType dt;
791 SetDataType(dt, dtID, dtOrigin);
792 return GetFirstInputObject(dt, classname, bForce);
795 const TObject* AliHLTComponent::GetNextInputObject(int bForce)
797 // see header file for function documentation
798 ALIHLTCOMPONENT_BASE_STOPWATCH();
799 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1, 1);
800 //HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(fSearchDataType).c_str());
803 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
804 fCurrentInputBlock=idx;
810 int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int startIdx, int bObject) const
812 // see header file for function documentation
814 if (fpInputBlocks!=NULL) {
815 int idx=startIdx<0?0:startIdx;
816 for ( ; (UInt_t)idx<fCurrentEventData.fBlockCnt && iResult==-ENOENT; idx++) {
817 if (dt!=fpInputBlocks[idx].fDataType) continue;
820 if (fpInputBlocks[idx].fPtr==NULL) continue;
821 AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
822 if (firstWord!=fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) continue;
830 TObject* AliHLTComponent::CreateInputObject(int idx, int bForce)
832 // see header file for function documentation
834 if (fpInputBlocks!=NULL) {
835 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
836 if (fpInputBlocks[idx].fPtr) {
837 AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
838 if (firstWord==fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) {
839 HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize);
840 AliHLTMessage msg(fpInputBlocks[idx].fPtr, fpInputBlocks[idx].fSize);
841 TClass* objclass=msg.GetClass();
842 pObj=msg.ReadObject(objclass);
843 if (pObj && objclass) {
844 HLTDebug("object %p type %s created", pObj, objclass->GetName());
848 } else if (bForce!=0) {
849 HLTError("size mismatch: block size %d, indicated %d", fpInputBlocks[idx].fSize, firstWord+sizeof(AliHLTUInt32_t));
852 HLTFatal("block descriptor empty");
855 HLTError("index %d out of range %d", idx, fCurrentEventData.fBlockCnt);
858 HLTError("no input blocks available");
864 TObject* AliHLTComponent::GetInputObject(int idx, const char* /*classname*/, int bForce)
866 // see header file for function documentation
867 if (fpInputObjects==NULL) {
868 fpInputObjects=new TObjArray(fCurrentEventData.fBlockCnt);
871 if (fpInputObjects) {
872 pObj=fpInputObjects->At(idx);
874 pObj=CreateInputObject(idx, bForce);
876 fpInputObjects->AddAt(pObj, idx);
880 HLTFatal("memory allocation failed: TObjArray of size %d", fCurrentEventData.fBlockCnt);
885 int AliHLTComponent::CleanupInputObjects()
887 // see header file for function documentation
888 if (!fpInputObjects) return 0;
889 TObjArray* array=fpInputObjects;
891 for (int i=0; i<array->GetEntries(); i++) {
892 TObject* pObj=array->At(i);
893 // grrr, garbage collection strikes back: When read via AliHLTMessage
894 // (CreateInputObject), and written to a TFile afterwards, the
895 // TFile::Close calls ROOOT's garbage collection. No clue why the
896 // object ended up in the key list and needs to be deleted
898 // Matthias 09.11.2008 follow up
899 // This approach doesn't actually work in all cases: the object table
900 // can be switched off globally, the flag needs to be checked here as
901 // well in order to avoid memory leaks.
902 // This means we have to find another solution for the problem if it
905 (!TObject::GetObjectStat() || gObjectTable->PtrIsValid(pObj))) {
913 AliHLTComponentDataType AliHLTComponent::GetDataType(const TObject* pObject)
915 // see header file for function documentation
916 ALIHLTCOMPONENT_BASE_STOPWATCH();
917 AliHLTComponentDataType dt=kAliHLTVoidDataType;
918 int idx=fCurrentInputBlock;
920 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
922 HLTError("unknown object %p", pObject);
926 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
927 dt=fpInputBlocks[idx].fDataType;
929 HLTFatal("severe internal error, index out of range");
935 AliHLTUInt32_t AliHLTComponent::GetSpecification(const TObject* pObject)
937 // see header file for function documentation
938 ALIHLTCOMPONENT_BASE_STOPWATCH();
939 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
940 int idx=fCurrentInputBlock;
942 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
944 HLTError("unknown object %p", pObject);
948 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
949 iSpec=fpInputBlocks[idx].fSpecification;
951 HLTFatal("severe internal error, index out of range");
957 int AliHLTComponent::Forward(const TObject* pObject)
959 // see header file for function documentation
961 int idx=fCurrentInputBlock;
963 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
965 HLTError("unknown object %p", pObject);
970 fOutputBlocks.push_back(fpInputBlocks[idx]);
975 int AliHLTComponent::Forward(const AliHLTComponentBlockData* pBlock)
977 // see header file for function documentation
979 int idx=fCurrentInputBlock;
981 if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) {
983 HLTError("unknown Block %p", pBlock);
988 // check for fpInputBlocks pointer done in FindInputBlock
989 fOutputBlocks.push_back(fpInputBlocks[idx]);
994 const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const AliHLTComponentDataType& dt)
996 // see header file for function documentation
997 ALIHLTCOMPONENT_BASE_STOPWATCH();
1000 int idx=FindInputBlock(fSearchDataType, 0);
1001 const AliHLTComponentBlockData* pBlock=NULL;
1003 // check for fpInputBlocks pointer done in FindInputBlock
1004 pBlock=&fpInputBlocks[idx];
1005 fCurrentInputBlock=idx;
1010 const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const char* dtID,
1011 const char* dtOrigin)
1013 // see header file for function documentation
1014 ALIHLTCOMPONENT_BASE_STOPWATCH();
1015 AliHLTComponentDataType dt;
1016 SetDataType(dt, dtID, dtOrigin);
1017 return GetFirstInputBlock(dt);
1020 const AliHLTComponentBlockData* AliHLTComponent::GetInputBlock(int index) const
1022 // see header file for function documentation
1023 ALIHLTCOMPONENT_BASE_STOPWATCH();
1024 assert( 0 <= index and index < (int)fCurrentEventData.fBlockCnt );
1025 return &fpInputBlocks[index];
1028 const AliHLTComponentBlockData* AliHLTComponent::GetNextInputBlock()
1030 // see header file for function documentation
1031 ALIHLTCOMPONENT_BASE_STOPWATCH();
1032 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1);
1033 const AliHLTComponentBlockData* pBlock=NULL;
1035 // check for fpInputBlocks pointer done in FindInputBlock
1036 pBlock=&fpInputBlocks[idx];
1037 fCurrentInputBlock=idx;
1042 int AliHLTComponent::FindInputBlock(const AliHLTComponentBlockData* pBlock) const
1044 // see header file for function documentation
1045 int iResult=-ENOENT;
1046 if (fpInputBlocks!=NULL) {
1048 if (pBlock>=fpInputBlocks && pBlock<fpInputBlocks+fCurrentEventData.fBlockCnt) {
1049 iResult=(int)(pBlock-fpInputBlocks);
1058 AliHLTUInt32_t AliHLTComponent::GetSpecification(const AliHLTComponentBlockData* pBlock)
1060 // see header file for function documentation
1061 ALIHLTCOMPONENT_BASE_STOPWATCH();
1062 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
1063 int idx=fCurrentInputBlock;
1065 if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) {
1067 HLTError("unknown Block %p", pBlock);
1071 // check for fpInputBlocks pointer done in FindInputBlock
1072 iSpec=fpInputBlocks[idx].fSpecification;
1077 int AliHLTComponent::PushBack(TObject* pObject, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
1078 void* pHeader, int headerSize)
1080 // see header file for function documentation
1081 ALIHLTCOMPONENT_BASE_STOPWATCH();
1085 AliHLTMessage msg(kMESS_OBJECT);
1086 msg.SetCompressionLevel(fCompressionLevel);
1087 msg.WriteObject(pObject);
1088 Int_t iMsgLength=msg.Length();
1090 // Matthias Sep 2008
1091 // NOTE: AliHLTMessage does implement it's own SetLength method
1092 // which is not architecture independent. The original SetLength
1093 // stores the size always in network byte order.
1094 // I'm trying to remember the rational for that, might be that
1095 // it was just some lack of knowledge. Want to change this, but
1096 // has to be done carefullt to be backward compatible.
1097 msg.SetLength(); // sets the length to the first (reserved) word
1099 // does nothing if the level is 0
1102 char *mbuf = msg.Buffer();
1103 if (msg.CompBuffer()) {
1104 msg.SetLength(); // set once more to have to byte order
1105 mbuf = msg.CompBuffer();
1106 iMsgLength = msg.CompLength();
1109 iResult=InsertOutputBlock(mbuf, iMsgLength, dt, spec, pHeader, headerSize);
1111 HLTDebug("object %s (%p) size %d compression %d inserted to output", pObject->ClassName(), pObject, iMsgLength, msg.GetCompressionLevel());
1113 fLastObjectSize=iMsgLength;
1115 HLTError("object serialization failed for object %p", pObject);
1124 int AliHLTComponent::PushBack(TObject* pObject, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec,
1125 void* pHeader, int headerSize)
1127 // see header file for function documentation
1128 ALIHLTCOMPONENT_BASE_STOPWATCH();
1129 AliHLTComponentDataType dt;
1130 SetDataType(dt, dtID, dtOrigin);
1131 return PushBack(pObject, dt, spec, pHeader, headerSize);
1134 int AliHLTComponent::PushBack(const void* pBuffer, int iSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
1135 const void* pHeader, int headerSize)
1137 // see header file for function documentation
1138 ALIHLTCOMPONENT_BASE_STOPWATCH();
1139 return InsertOutputBlock(pBuffer, iSize, dt, spec, pHeader, headerSize);
1142 int AliHLTComponent::PushBack(const void* pBuffer, int iSize, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec,
1143 const void* pHeader, int headerSize)
1145 // see header file for function documentation
1146 ALIHLTCOMPONENT_BASE_STOPWATCH();
1147 AliHLTComponentDataType dt;
1148 SetDataType(dt, dtID, dtOrigin);
1149 return PushBack(pBuffer, iSize, dt, spec, pHeader, headerSize);
1152 int AliHLTComponent::InsertOutputBlock(const void* pBuffer, int iBufferSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
1153 const void* pHeader, int iHeaderSize)
1155 // see header file for function documentation
1157 int iBlkSize = iBufferSize + iHeaderSize;
1159 if ((pBuffer!=NULL && iBufferSize>0) || (pHeader!=NULL && iHeaderSize>0)) {
1160 if (fpOutputBuffer && iBlkSize<=(int)(fOutputBufferSize-fOutputBufferFilled)) {
1161 AliHLTUInt8_t* pTgt=fpOutputBuffer+fOutputBufferFilled;
1163 // copy header if provided but skip if the header is the target location
1164 // in that case it has already been copied
1165 if (pHeader!=NULL && pHeader!=pTgt) {
1166 memcpy(pTgt, pHeader, iHeaderSize);
1169 pTgt += (AliHLTUInt8_t) iHeaderSize;
1171 // copy buffer if provided but skip if buffer is the target location
1172 // in that case it has already been copied
1173 if (pBuffer!=NULL && pBuffer!=pTgt) {
1174 memcpy(pTgt, pBuffer, iBufferSize);
1176 //AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)pBuffer);
1177 //HLTDebug("copy %d bytes from %p to output buffer %p, first word %#x", iBufferSize, pBuffer, pTgt, firstWord);
1179 //HLTDebug("buffer inserted to output: size %d data type %s spec %#x", iBlkSize, DataType2Text(dt).c_str(), spec);
1181 if (fpOutputBuffer) {
1182 HLTError("too little space in output buffer: %d of %d, required %d", fOutputBufferSize-fOutputBufferFilled, fOutputBufferSize, iBlkSize);
1184 HLTError("output buffer not available");
1190 AliHLTComponentBlockData bd;
1191 FillBlockData( bd );
1192 bd.fOffset = fOutputBufferFilled;
1193 bd.fSize = iBlkSize;
1195 bd.fSpecification = spec;
1196 fOutputBlocks.push_back( bd );
1197 fOutputBufferFilled+=bd.fSize;
1203 int AliHLTComponent::EstimateObjectSize(TObject* pObject) const
1205 // see header file for function documentation
1206 if (!pObject) return -EINVAL;
1207 AliHLTMessage msg(kMESS_OBJECT);
1208 msg.WriteObject(pObject);
1209 return msg.Length();
1212 AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity, const char* dtID,
1213 const char* dtOrigin,
1214 AliHLTUInt32_t spec)
1216 // see header file for function documentation
1217 ALIHLTCOMPONENT_BASE_STOPWATCH();
1218 AliHLTComponentDataType dt;
1219 SetDataType(dt, dtID, dtOrigin);
1220 return CreateMemoryFile(capacity, dt, spec);
1223 AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity,
1224 const AliHLTComponentDataType& dt,
1225 AliHLTUInt32_t spec)
1227 // see header file for function documentation
1228 ALIHLTCOMPONENT_BASE_STOPWATCH();
1229 AliHLTMemoryFile* pFile=NULL;
1230 if (capacity>=0 && static_cast<unsigned int>(capacity)<=fOutputBufferSize-fOutputBufferFilled){
1231 AliHLTUInt8_t* pTgt=fpOutputBuffer+fOutputBufferFilled;
1232 pFile=new AliHLTMemoryFile((char*)pTgt, capacity);
1234 unsigned int nofBlocks=fOutputBlocks.size();
1235 if (nofBlocks+1>fMemFiles.size()) {
1236 fMemFiles.resize(nofBlocks+1, NULL);
1238 if (nofBlocks<fMemFiles.size()) {
1239 fMemFiles[nofBlocks]=pFile;
1240 AliHLTComponentBlockData bd;
1241 FillBlockData( bd );
1242 bd.fOffset = fOutputBufferFilled;
1243 bd.fSize = capacity;
1245 bd.fSpecification = spec;
1246 fOutputBufferFilled+=bd.fSize;
1247 fOutputBlocks.push_back( bd );
1249 HLTError("can not allocate/grow object array");
1250 pFile->CloseMemoryFile(0);
1256 HLTError("can not create memory file of size %d (%d available)", capacity, fOutputBufferSize-fOutputBufferFilled);
1261 AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(const char* dtID,
1262 const char* dtOrigin,
1263 AliHLTUInt32_t spec,
1266 // see header file for function documentation
1267 ALIHLTCOMPONENT_BASE_STOPWATCH();
1268 AliHLTComponentDataType dt;
1269 SetDataType(dt, dtID, dtOrigin);
1270 int size=fOutputBufferSize-fOutputBufferFilled;
1271 if (capacity<0 || capacity>1.0) {
1272 HLTError("invalid parameter: capacity %f", capacity);
1275 size=(int)(size*capacity);
1276 return CreateMemoryFile(size, dt, spec);
1279 AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(const AliHLTComponentDataType& dt,
1280 AliHLTUInt32_t spec,
1283 // see header file for function documentation
1284 ALIHLTCOMPONENT_BASE_STOPWATCH();
1285 int size=fOutputBufferSize-fOutputBufferFilled;
1286 if (capacity<0 || capacity>1.0) {
1287 HLTError("invalid parameter: capacity %f", capacity);
1290 size=(int)(size*capacity);
1291 return CreateMemoryFile(size, dt, spec);
1294 int AliHLTComponent::Write(AliHLTMemoryFile* pFile, const TObject* pObject,
1295 const char* key, int option)
1297 // see header file for function documentation
1299 if (pFile && pObject) {
1301 iResult=pObject->Write(key, option);
1305 iResult=-pFile->GetErrno();
1306 if (iResult==-ENOSPC) {
1307 HLTError("error writing memory file, buffer too small");
1316 int AliHLTComponent::CloseMemoryFile(AliHLTMemoryFile* pFile)
1318 // see header file for function documentation
1321 AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
1323 while (element!=fMemFiles.end() && iResult>=0) {
1324 if (*element && *element==pFile) {
1325 iResult=pFile->CloseMemoryFile();
1327 // sync memory files and descriptors
1329 fOutputBlocks[i].fSize=(*element)->GetSize()+(*element)->GetHeaderSize();
1337 HLTError("can not find memory file %p", pFile);
1345 int AliHLTComponent::CreateEventDoneData(AliHLTComponentEventDoneData edd)
1347 // see header file for function documentation
1350 AliHLTComponentEventDoneData* newEDD = NULL;
1352 unsigned long newSize=edd.fDataSize;
1354 newSize += fEventDoneData->fDataSize;
1356 if (newSize>fEventDoneDataSize) {
1357 newEDD = reinterpret_cast<AliHLTComponentEventDoneData*>( new AliHLTUInt8_t[ sizeof(AliHLTComponentEventDoneData)+newSize ] );
1360 newEDD->fStructSize = sizeof(AliHLTComponentEventDoneData);
1361 newEDD->fDataSize = newSize;
1362 newEDD->fData = reinterpret_cast<AliHLTUInt8_t*>(newEDD)+newEDD->fStructSize;
1363 unsigned long long offset = 0;
1364 if (fEventDoneData) {
1365 memcpy( newEDD->fData, fEventDoneData->fData, fEventDoneData->fDataSize );
1366 offset += fEventDoneData->fDataSize;
1368 memcpy( reinterpret_cast<AliHLTUInt8_t*>(newEDD->fData)+offset, edd.fData, edd.fDataSize );
1370 delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
1371 fEventDoneData = newEDD;
1372 fEventDoneDataSize = newSize;
1375 memcpy( reinterpret_cast<AliHLTUInt8_t*>(fEventDoneData->fData)+fEventDoneData->fDataSize, edd.fData, edd.fDataSize );
1376 fEventDoneData->fDataSize += edd.fDataSize;
1381 int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
1382 const AliHLTComponentBlockData* blocks,
1383 AliHLTComponentTriggerData& trigData,
1384 AliHLTUInt8_t* outputPtr,
1385 AliHLTUInt32_t& size,
1386 AliHLTUInt32_t& outputBlockCnt,
1387 AliHLTComponentBlockData*& outputBlocks,
1388 AliHLTComponentEventDoneData*& edd )
1390 // see header file for function documentation
1391 HLTLogKeyword(GetComponentID());
1392 ALIHLTCOMPONENT_BASE_STOPWATCH();
1394 fCurrentEvent=evtData.fEventID;
1395 fCurrentEventData=evtData;
1396 fpInputBlocks=blocks;
1397 fCurrentInputBlock=-1;
1398 fSearchDataType=kAliHLTAnyDataType;
1399 fpOutputBuffer=outputPtr;
1400 fOutputBufferSize=size;
1401 fOutputBufferFilled=0;
1402 fOutputBlocks.clear();
1406 AliHLTComponentBlockDataList forwardedBlocks;
1408 // optional component statistics
1409 AliHLTComponentStatisticsList compStats;
1410 bool bAddComponentTableEntry=false;
1411 vector<AliHLTUInt32_t> parentComponentTables;
1412 #if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
1413 AliHLTComponentStatistics outputStat;
1414 memset(&outputStat, 0, sizeof(AliHLTComponentStatistics));
1415 outputStat.fId=fChainIdCrc;
1416 compStats.push_back(outputStat);
1418 fpBenchmark->Reset();
1419 fpBenchmark->Start();
1423 // data processing is skipped
1424 // - if there are only steering events in the block list.
1425 // For the sake of data source components data processing
1426 // is not skipped if there is no block list at all or if it
1427 // just contains the eventType block
1428 // - always skipped if the event is of type
1429 // - gkAliEventTypeConfiguration
1430 // - gkAliEventTypeReadPreprocessor
1431 const unsigned int skipModeDefault=0x1;
1432 const unsigned int skipModeForce=0x2;
1433 unsigned int bSkipDataProcessing=skipModeDefault;
1435 // find special events
1436 if (fpInputBlocks && evtData.fBlockCnt>0) {
1437 // first look for all special events and execute in the appropriate
1438 // sequence afterwords
1439 int indexComConfEvent=-1;
1440 int indexUpdtDCSEvent=-1;
1441 int indexSOREvent=-1;
1442 int indexEOREvent=-1;
1443 for (unsigned int i=0; i<evtData.fBlockCnt && iResult>=0; i++) {
1444 if (fpInputBlocks[i].fDataType==kAliHLTDataTypeSOR) {
1446 // the AliHLTCalibrationProcessor relies on the SOR and EOR events
1447 bSkipDataProcessing&=~skipModeDefault;
1448 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeRunType) {
1450 // handling is not clear yet
1451 if (fpInputBlocks[i].fPtr) {
1452 HLTDebug("got run type \"%s\"\n", fpInputBlocks[i].fPtr);
1454 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) {
1456 // the calibration processor relies on the SOR and EOR events
1457 bSkipDataProcessing&=~skipModeDefault;
1458 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) {
1460 // this event is most likely deprecated
1461 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComConf) {
1462 indexComConfEvent=i;
1463 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeUpdtDCS) {
1464 indexUpdtDCSEvent=i;
1465 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEvent) {
1466 fEventType=fpInputBlocks[i].fSpecification;
1468 // skip always in case of gkAliEventTypeConfiguration
1469 if (fpInputBlocks[i].fSpecification==gkAliEventTypeConfiguration) bSkipDataProcessing|=skipModeForce;
1471 // skip always in case of gkAliEventTypeReadPreprocessor
1472 if (fpInputBlocks[i].fSpecification==gkAliEventTypeReadPreprocessor) bSkipDataProcessing|=skipModeForce;
1474 // never skip if the event type block is the only block
1475 if (evtData.fBlockCnt==1) bSkipDataProcessing&=~skipModeDefault;
1477 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComponentStatistics) {
1478 if (compStats.size()>0) {
1479 AliHLTUInt8_t* pData=reinterpret_cast<AliHLTUInt8_t*>(fpInputBlocks[i].fPtr);
1480 for (AliHLTUInt32_t offset=0;
1481 offset+sizeof(AliHLTComponentStatistics)<=fpInputBlocks[i].fSize;
1482 offset+=sizeof(AliHLTComponentStatistics)) {
1483 AliHLTComponentStatistics* pStat=reinterpret_cast<AliHLTComponentStatistics*>(pData+offset);
1484 if (pStat && compStats[0].fLevel<=pStat->fLevel) {
1485 compStats[0].fLevel=pStat->fLevel+1;
1487 compStats.push_back(*pStat);
1490 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComponentTable) {
1491 forwardedBlocks.push_back(fpInputBlocks[i]);
1492 parentComponentTables.push_back(fpInputBlocks[i].fSpecification);
1494 // the processing function is called if there is at least one
1495 // non-steering data block. Steering blocks are not filtered out
1496 // for sake of performance
1497 bSkipDataProcessing&=~skipModeDefault;
1498 if (compStats.size()>0) {
1499 compStats[0].fInputBlockCount++;
1500 compStats[0].fTotalInputSize+=fpInputBlocks[i].fSize;
1505 if (indexSOREvent>=0) {
1507 bAddComponentTableEntry=true;
1508 if (fpRunDesc==NULL) {
1509 fpRunDesc=new AliHLTRunDesc;
1510 if (fpRunDesc) *fpRunDesc=kAliHLTVoidRunDesc;
1513 AliHLTRunDesc rundesc;
1514 if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), indexSOREvent, "AliHLTRunDesc", "SOR"))>0) {
1515 if (fpRunDesc->fRunNo==kAliHLTVoidRunNo) {
1517 HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo);
1518 SetCDBRunNo(fpRunDesc->fRunNo);
1519 } else if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
1520 HLTWarning("already set run properties run no %d, ignoring SOR with run no %d", fpRunDesc->fRunNo, rundesc.fRunNo);
1527 if (indexEOREvent>=0) {
1528 bAddComponentTableEntry=true;
1529 if (fpRunDesc!=NULL) {
1531 AliHLTRunDesc rundesc;
1532 if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), indexEOREvent, "AliHLTRunDesc", "SOR"))>0) {
1533 if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
1534 HLTWarning("run no mismatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo);
1536 HLTDebug("EOR run no %d", fpRunDesc->fRunNo);
1539 AliHLTRunDesc* pRunDesc=fpRunDesc;
1544 HLTWarning("did not receive SOR, ignoring EOR");
1547 if (indexComConfEvent>=0 || fEventType==gkAliEventTypeConfiguration) {
1549 if (indexComConfEvent>=0 && fpInputBlocks[indexComConfEvent].fPtr!=NULL && fpInputBlocks[indexComConfEvent].fSize>0) {
1550 cdbEntry.Append(reinterpret_cast<const char*>(fpInputBlocks[indexComConfEvent].fPtr), fpInputBlocks[indexComConfEvent].fSize);
1552 HLTDebug("received component configuration command: entry %s", cdbEntry.IsNull()?"none":cdbEntry.Data());
1553 int tmpResult=Reconfigure(cdbEntry[0]==0?NULL:cdbEntry.Data(), fChainId.c_str());
1555 HLTWarning("reconfiguration of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
1558 if (indexUpdtDCSEvent>=0 || fEventType==gkAliEventTypeReadPreprocessor) {
1560 if (fpInputBlocks[indexUpdtDCSEvent].fPtr!=NULL && fpInputBlocks[indexUpdtDCSEvent].fSize>0) {
1561 modules.Append(reinterpret_cast<const char*>(fpInputBlocks[indexUpdtDCSEvent].fPtr), fpInputBlocks[indexUpdtDCSEvent].fSize);
1563 HLTDebug("received preprocessor update command: detectors %s", modules.IsNull()?"ALL":modules.Data());
1564 int tmpResult=ReadPreprocessorValues(modules[0]==0?"ALL":modules.Data());
1566 HLTWarning("preprocessor update of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
1570 // processing function needs to be called if there are no input data
1571 // blocks in order to make data source components working.
1572 bSkipDataProcessing&=~skipModeDefault;
1575 // data processing is not skipped if the component explicitly asks
1576 // for the private blocks
1577 if (fRequireSteeringBlocks) bSkipDataProcessing=0;
1579 AliHLTComponentBlockDataList blockData;
1580 if (iResult>=0 && !bSkipDataProcessing)
1581 { // dont delete, sets the scope for the stopwatch guard
1582 // do not use ALIHLTCOMPONENT_DA_STOPWATCH(); macro
1583 // in order to avoid 'shadowed variable' warning
1584 AliHLTStopwatchGuard swguard2(fpStopwatches!=NULL?reinterpret_cast<TStopwatch*>(fpStopwatches->At((int)kSWDA)):NULL);
1585 iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd);
1586 } // end of the scope of the stopwatch guard
1587 if (iResult>=0 && !bSkipDataProcessing) {
1588 if (fOutputBlocks.size()>0) {
1589 // High Level interface
1591 //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size());
1592 // sync memory files and descriptors
1593 AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
1595 while (element!=fMemFiles.end() && iResult>=0) {
1597 if ((*element)->IsClosed()==0) {
1598 HLTWarning("memory file has not been closed, force flush");
1599 iResult=CloseMemoryFile(*element);
1606 // create the descriptor list
1607 if (blockData.size()>0) {
1608 HLTError("low level and high interface must not be mixed; use PushBack methods to insert data blocks");
1611 if (compStats.size()>0 && IsDataEvent()) {
1612 int offset=AddComponentStatistics(fOutputBlocks, fpOutputBuffer, fOutputBufferSize, fOutputBufferFilled, compStats);
1613 if (offset>0) fOutputBufferFilled+=offset;
1615 if (bAddComponentTableEntry) {
1616 int offset=AddComponentTableEntry(fOutputBlocks, fpOutputBuffer, fOutputBufferSize, fOutputBufferFilled, parentComponentTables);
1617 if (offset>0) size+=offset;
1619 if (forwardedBlocks.size()>0) {
1620 fOutputBlocks.insert(fOutputBlocks.end(), forwardedBlocks.begin(), forwardedBlocks.end());
1622 iResult=MakeOutputDataBlockList(fOutputBlocks, &outputBlockCnt, &outputBlocks);
1623 size=fOutputBufferFilled;
1627 // Low Level interface
1628 if (compStats.size()>0) {
1629 int offset=AddComponentStatistics(blockData, fpOutputBuffer, fOutputBufferSize, size, compStats);
1630 if (offset>0) size+=offset;
1632 if (bAddComponentTableEntry) {
1633 int offset=AddComponentTableEntry(blockData, fpOutputBuffer, fOutputBufferSize, size, parentComponentTables);
1634 if (offset>0) size+=offset;
1636 if (forwardedBlocks.size()>0) {
1637 blockData.insert(blockData.end(), forwardedBlocks.begin(), forwardedBlocks.end());
1639 iResult=MakeOutputDataBlockList(blockData, &outputBlockCnt, &outputBlocks);
1642 HLTFatal("component %s (%p): can not convert output block descriptor list", GetComponentID(), this);
1645 if (iResult<0 || bSkipDataProcessing) {
1649 CleanupInputObjects();
1650 if (iResult>=0 && IsDataEvent()) {
1651 IncrementEventCounter();
1653 if (outputBlockCnt==0) {
1654 // no output blocks, set size to 0
1657 FillEventData(fCurrentEventData);
1661 int AliHLTComponent::AddComponentStatistics(AliHLTComponentBlockDataList& blocks,
1662 AliHLTUInt8_t* buffer,
1663 AliHLTUInt32_t bufferSize,
1664 AliHLTUInt32_t offset,
1665 AliHLTComponentStatisticsList& stats) const
1667 // see header file for function documentation
1669 #if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
1670 if (stats.size()==0) return -ENOENT;
1671 stats[0].fTotalOutputSize=offset;
1672 stats[0].fOutputBlockCount=blocks.size();
1674 stats[0].fTime=(AliHLTUInt32_t)(fpBenchmark->RealTime()*1000000);
1675 stats[0].fCTime=(AliHLTUInt32_t)(fpBenchmark->CpuTime()*1000000);
1677 if (offset+stats.size()*sizeof(AliHLTComponentStatistics)<=bufferSize) {
1678 AliHLTComponentBlockData bd;
1679 FillBlockData( bd );
1680 bd.fOffset = offset;
1681 bd.fSize = stats.size()*sizeof(AliHLTComponentStatistics);
1682 bd.fDataType = kAliHLTDataTypeComponentStatistics;
1683 bd.fSpecification = kAliHLTVoidDataSpec;
1684 unsigned int master=0;
1685 for (unsigned int i=1; i<blocks.size(); i++) {
1686 if (blocks[i].fSize>blocks[master].fSize &&
1687 !MatchExactly(blocks[i].fDataType, kAliHLTVoidDataType|kAliHLTDataOriginPrivate))
1690 if (blocks.size()>0 && !MatchExactly(blocks[master].fDataType, kAliHLTVoidDataType|kAliHLTDataOriginPrivate)) {
1691 // take the data origin of the biggest block as specification
1692 // this is similar to the treatment in the HOMER interface. For traditional
1693 // reasons, the bytes are swapped there on a little endian architecture, so
1694 // we do it as well.
1695 memcpy(&bd.fSpecification, &blocks[master].fDataType.fOrigin, sizeof(bd.fSpecification));
1696 #ifdef R__BYTESWAP // set on little endian architectures
1697 bd.fSpecification=((bd.fSpecification & 0xFFULL) << 24) |
1698 ((bd.fSpecification & 0xFF00ULL) << 8) |
1699 ((bd.fSpecification & 0xFF0000ULL) >> 8) |
1700 ((bd.fSpecification & 0xFF000000ULL) >> 24);
1703 memcpy(buffer+offset, &(stats[0]), bd.fSize);
1704 blocks.push_back(bd);
1708 if (blocks.size() && buffer && bufferSize && offset && stats.size()) {
1709 // get rid of warning
1715 int AliHLTComponent::AddComponentTableEntry(AliHLTComponentBlockDataList& blocks,
1716 AliHLTUInt8_t* buffer,
1717 AliHLTUInt32_t bufferSize,
1718 AliHLTUInt32_t offset,
1719 const vector<AliHLTUInt32_t>& parents) const
1721 // see header file for function documentation
1723 #if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
1724 // the payload consists of the AliHLTComponentTableEntry struct,
1725 // followed by a an array of 32bit crc chain ids and the component
1726 // description string
1727 unsigned int payloadSize=sizeof(AliHLTComponentTableEntry);
1728 payloadSize+=parents.size()*sizeof(AliHLTUInt32_t);
1730 // the component description has the following format:
1731 // chain-id{component-id:arguments}
1732 const char* componentId=const_cast<AliHLTComponent*>(this)->GetComponentID();
1733 unsigned int descriptionSize=fChainId.size()+1;
1734 descriptionSize+=2; // the '{}' around the component id
1735 descriptionSize+=strlen(componentId);
1736 descriptionSize+=1; // the ':' between component id and arguments
1737 descriptionSize+=fComponentArgs.size();
1739 payloadSize+=descriptionSize;
1740 if (buffer && (offset+payloadSize<=bufferSize)) {
1741 AliHLTUInt8_t* pTgt=buffer+offset;
1742 memset(pTgt, 0, payloadSize);
1745 AliHLTComponentTableEntry* pEntry=reinterpret_cast<AliHLTComponentTableEntry*>(pTgt);
1746 pEntry->fStructSize=sizeof(AliHLTComponentTableEntry);
1747 pEntry->fNofParents=parents.size();
1748 pEntry->fSizeDescription=descriptionSize;
1749 pTgt=pEntry->fBuffer;
1751 // write array of parents
1752 if (parents.size()>0) {
1753 unsigned int copy=parents.size()*sizeof(vector<AliHLTUInt32_t>::value_type);
1754 memcpy(pTgt, &parents[0], parents.size()*sizeof(vector<AliHLTUInt32_t>::value_type));
1758 // write component description
1759 memcpy(pTgt, fChainId.c_str(), fChainId.size());
1760 pTgt+=fChainId.size();
1762 memcpy(pTgt, componentId, strlen(componentId));
1763 pTgt+=strlen(componentId);
1765 memcpy(pTgt, fComponentArgs.c_str(), fComponentArgs.size());
1766 pTgt+=fComponentArgs.size();
1770 AliHLTComponentBlockData bd;
1771 FillBlockData( bd );
1772 bd.fOffset = offset;
1773 bd.fSize = payloadSize;
1774 bd.fDataType = kAliHLTDataTypeComponentTable;
1775 bd.fSpecification = fChainIdCrc;
1776 blocks.push_back(bd);
1780 if (blocks.size() && buffer && bufferSize && offset && parents.size()) {
1781 // get rid of warning
1787 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard()
1792 // standard constructor (not for use)
1795 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(TStopwatch* pStopwatch)
1797 fpStopwatch(pStopwatch),
1802 // check for already existing guard
1803 if (fgpCurrent) fpPrec=fgpCurrent;
1806 // stop the preceeding guard if it controls a different stopwatch
1808 if (fpPrec && fpPrec!=this) bStart=fpPrec->Hold(fpStopwatch);
1810 // start the stopwatch if the current guard controls a different one
1811 if (fpStopwatch && bStart==1) fpStopwatch->Start(kFALSE);
1814 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(const AliHLTStopwatchGuard&)
1820 // copy constructor not for use
1824 AliHLTComponent::AliHLTStopwatchGuard& AliHLTComponent::AliHLTStopwatchGuard::operator=(const AliHLTStopwatchGuard&)
1827 // assignment operator not for use
1834 AliHLTComponent::AliHLTStopwatchGuard* AliHLTComponent::AliHLTStopwatchGuard::fgpCurrent=NULL;
1836 AliHLTComponent::AliHLTStopwatchGuard::~AliHLTStopwatchGuard()
1840 // resume the preceeding guard if it controls a different stopwatch
1842 if (fpPrec && fpPrec!=this) bStop=fpPrec->Resume(fpStopwatch);
1844 // stop the stopwatch if the current guard controls a different one
1845 if (fpStopwatch && bStop==1) fpStopwatch->Stop();
1847 // resume to the preceeding guard
1851 int AliHLTComponent::AliHLTStopwatchGuard::Hold(TStopwatch* pSucc)
1853 // see header file for function documentation
1854 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Stop();
1855 return fpStopwatch!=pSucc?1:0;
1858 int AliHLTComponent::AliHLTStopwatchGuard::Resume(TStopwatch* pSucc)
1860 // see header file for function documentation
1861 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Start(kFALSE);
1862 return fpStopwatch!=pSucc?1:0;
1865 int AliHLTComponent::SetStopwatch(TObject* pSW, AliHLTStopwatchType type)
1867 // see header file for function documentation
1869 if (pSW!=NULL && type<kSWTypeCount) {
1870 if (fpStopwatches) {
1871 TObject* pObj=fpStopwatches->At((int)type);
1872 if (pSW==NULL // explicit reset
1873 || pObj==NULL) { // explicit set
1874 fpStopwatches->AddAt(pSW, (int)type);
1875 } else if (pObj!=pSW) {
1876 HLTWarning("stopwatch %d already set, reset first", (int)type);
1886 int AliHLTComponent::SetStopwatches(TObjArray* pStopwatches)
1888 // see header file for function documentation
1889 if (pStopwatches==NULL) return -EINVAL;
1892 for (int i=0 ; i<(int)kSWTypeCount && pStopwatches->GetEntries(); i++)
1893 SetStopwatch(pStopwatches->At(i), (AliHLTStopwatchType)i);
1897 AliHLTUInt32_t AliHLTComponent::GetRunNo() const
1899 // see header file for function documentation
1900 if (fpRunDesc==NULL) return kAliHLTVoidRunNo;
1901 return fpRunDesc->fRunNo;
1904 AliHLTUInt32_t AliHLTComponent::GetRunType() const
1906 // see header file for function documentation
1907 if (fpRunDesc==NULL) return kAliHLTVoidRunType;
1908 return fpRunDesc->fRunType;
1911 bool AliHLTComponent::IsDataEvent(AliHLTUInt32_t* pTgt)
1913 // see header file for function documentation
1914 if (pTgt) *pTgt=fEventType;
1915 return (fEventType==gkAliEventTypeData ||
1916 fEventType==gkAliEventTypeDataReplay ||
1917 fEventType==gkAliEventTypeCalibration);
1920 int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo,
1921 const char* structname, const char* eventname)
1923 // see header file for function documentation
1925 if (pStruct!=NULL && iStructSize>sizeof(AliHLTUInt32_t)) {
1926 if (fpInputBlocks!=NULL && iBlockNo<fCurrentEventData.fBlockCnt) {
1927 AliHLTUInt32_t* pTgt=(AliHLTUInt32_t*)pStruct;
1928 if (fpInputBlocks[iBlockNo].fPtr && fpInputBlocks[iBlockNo].fSize) {
1929 AliHLTUInt32_t copy=*((AliHLTUInt32_t*)fpInputBlocks[iBlockNo].fPtr);
1930 if (fpInputBlocks[iBlockNo].fSize!=copy) {
1931 HLTWarning("%s event: mismatch of block size (%d) and structure size (%d)", eventname, fpInputBlocks[iBlockNo].fSize, copy);
1932 if (copy>fpInputBlocks[iBlockNo].fSize) copy=fpInputBlocks[iBlockNo].fSize;
1934 if (copy!=iStructSize) {
1935 HLTWarning("%s event: mismatch in %s version (data type version %d)", eventname, structname, ALIHLT_DATA_TYPES_VERSION);
1936 if (copy>iStructSize) {
1939 memset(pTgt, 0, iStructSize);
1942 memcpy(pTgt, fpInputBlocks[iBlockNo].fPtr, copy);
1946 HLTWarning("%s event: missing data block", eventname);
1952 HLTError("invalid struct");
1958 void AliHLTComponent::SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const
1960 // see header file for function documentation
1962 // -- Detector offset
1963 Int_t ddlIdBase = TMath::FloorNint( (Double_t) ddlId / 256.0 );
1965 // -- Word Base = 1. word of detector ( TPC has 8 words, TOF 3 )
1968 if ( ddlIdBase <= 3 )
1969 wordBase = ddlIdBase;
1970 else if ( ddlIdBase > 3 && ddlIdBase < 5 )
1971 wordBase = ddlIdBase + 7;
1973 wordBase = ddlIdBase + 9;
1975 // -- Bit index in Word
1976 Int_t bitIdx = ddlId % 32;
1979 Int_t wordIdx = wordBase;
1981 // -- if TPC (3) or TOD (5) add word idx
1982 if ( ( ddlIdBase == 3 ) || ( ddlIdBase == 5 ) ) {
1983 wordIdx += TMath::FloorNint( (Double_t) ( ddlId - ( ddlIdBase * 256 ) ) / 32.0 );
1986 // -- Set -- 'OR' word with bit mask;
1988 list.fList[wordIdx] |= ( 0x00000001 << bitIdx );
1989 // -- Unset -- 'AND' word with bit mask;
1991 list.fList[wordIdx] &= ( 0xFFFFFFFF ^ ( 0x00000001 << bitIdx ) );
1994 Int_t AliHLTComponent::GetFirstUsedDDLWord(AliHLTEventDDL &list) const
1996 // see header file for function documentation
2000 for ( Int_t wordNdx = 0 ; wordNdx < gkAliHLTDDLListSize ; wordNdx++ ) {
2002 if ( list.fList[wordNdx] != 0 && iResult == -1 ) {
2003 // check for special cases TPC and TOF
2004 if ( wordNdx > 3 && wordNdx <= 10 ) {
2008 else if ( wordNdx > 12 && wordNdx <= 14 ) {
2015 else if ( list.fList[wordNdx] != 0 && iResult >= 0 ) {
2016 HLTError( "DDLIDs for minimum of TWO detectors ( %d, %d ) set, this function works only for ONE detector.", iResult, wordNdx );
2025 AliHLTUInt32_t AliHLTComponent::CalculateChecksum(const AliHLTUInt8_t* buffer, int size)
2027 // see header file for function documentation
2028 AliHLTUInt32_t remainder = 0;
2029 const AliHLTUInt8_t crcwidth=(8*sizeof(AliHLTUInt32_t));
2030 const AliHLTUInt32_t topbit=1 << (crcwidth-1);
2031 const AliHLTUInt32_t polynomial=0xD8; /* 11011 followed by 0's */
2034 // http://www.netrino.com/Embedded-Systems/How-To/CRC-Calculation-C-Code
2037 * Perform modulo-2 division, a byte at a time.
2039 for (int byte = 0; byte < size; ++byte)
2042 * Bring the next byte into the remainder.
2044 remainder ^= (buffer[byte] << (crcwidth - 8));
2047 * Perform modulo-2 division, a bit at a time.
2049 for (uint8_t bit = 8; bit > 0; --bit)
2052 * Try to divide the current data bit.
2054 if (remainder & topbit)
2056 remainder = (remainder << 1) ^ polynomial;
2060 remainder = (remainder << 1);
2066 * The final remainder is the CRC result.
2071 int AliHLTComponent::ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
2072 string& retChainId, string& retCompId, string& retCompArgs,
2073 vector<AliHLTUInt32_t>& parents)
2075 // see header file for function documentation
2078 retCompArgs.clear();
2080 if (!pBuffer || size==0) return 0;
2082 const AliHLTComponentTableEntry* pEntry=reinterpret_cast<const AliHLTComponentTableEntry*>(pBuffer);
2083 if (size<8/* the initial size of the structure*/ ||
2084 pEntry==NULL || pEntry->fStructSize<8) return -ENOMSG;
2085 const AliHLTUInt32_t* pParents=reinterpret_cast<const AliHLTUInt32_t*>(pEntry->fBuffer);
2086 const AliHLTUInt8_t* pEnd=pBuffer+size;
2088 if (pParents+pEntry->fNofParents>=reinterpret_cast<const AliHLTUInt32_t*>(pEnd)) return -ENODEV;
2089 for (unsigned int i=0; i<pEntry->fNofParents; i++, pParents++) {
2090 parents.push_back(*pParents);
2093 const char* pDescription=reinterpret_cast<const char*>(pParents);
2094 if (pDescription+pEntry->fSizeDescription>=reinterpret_cast<const char*>(pEnd) ||
2095 *(pDescription+pEntry->fSizeDescription)!=0) {
2099 TString descriptor=reinterpret_cast<const char*>(pDescription);
2103 TObjArray* pTokens=descriptor.Tokenize("{");
2106 if (pTokens->GetEntries()>n) {
2107 retChainId=((TObjString*)pTokens->At(n++))->GetString();
2109 if (pTokens->GetEntries()>n) {
2110 compId=((TObjString*)pTokens->At(n++))->GetString();
2114 if (!compId.IsNull() && (pTokens=compId.Tokenize(":"))!=NULL) {
2116 if (pTokens->GetEntries()>n) {
2117 compId=((TObjString*)pTokens->At(n++))->GetString();
2119 if (pTokens->GetEntries()>n) {
2120 compArgs=((TObjString*)pTokens->At(n++))->GetString();
2124 compId.ReplaceAll("}", "");
2125 compArgs.ReplaceAll("}", "");
2128 retCompArgs=compArgs;
2130 if (retChainId.size()==0) return -ENODATA;
2135 int AliHLTComponent::LoggingVarargs(AliHLTComponentLogSeverity severity,
2136 const char* originClass, const char* originFunc,
2137 const char* file, int line, ... ) const
2139 // see header file for function documentation
2143 va_start(args, line);
2145 // logging function needs to be const in order to be called from const member functions
2146 // without problems. But at this point we face the problem with virtual members which
2147 // are not necessarily const.
2148 AliHLTComponent* nonconst=const_cast<AliHLTComponent*>(this);
2149 AliHLTLogging::SetLogString("%s (%s, %p): ",
2150 fChainId[0]!=0?fChainId.c_str():nonconst->GetComponentID(),
2151 nonconst->GetComponentID(), this);
2152 iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, true /*append*/));