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)
92 // see header file for class documentation
94 // refer to README to build package
96 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
97 memset(&fEnvironment, 0, sizeof(AliHLTAnalysisEnvironment));
98 if (fgpComponentHandler)
99 fgpComponentHandler->ScheduleRegister(this);
100 //SetLocalLoggingLevel(kHLTLogDefault);
103 AliHLTComponent::~AliHLTComponent()
105 // see header file for function documentation
106 if (fpBenchmark) delete fpBenchmark;
109 CleanupInputObjects();
110 if (fpStopwatches!=NULL) delete fpStopwatches;
112 AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
113 while (element!=fMemFiles.end()) {
115 if ((*element)->IsClosed()==0) {
116 HLTWarning("memory file has not been closed, possible data loss or incomplete buffer");
117 // close but do not flush as we dont know whether the buffer is still valid
118 (*element)->CloseMemoryFile(0);
130 delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
133 AliHLTComponentHandler* AliHLTComponent::fgpComponentHandler=NULL;
135 int AliHLTComponent::SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite)
137 // see header file for function documentation
139 if (fgpComponentHandler==NULL || bOverwrite!=0)
140 fgpComponentHandler=pCH;
146 int AliHLTComponent::UnsetGlobalComponentHandler()
148 // see header file for function documentation
149 return SetGlobalComponentHandler(NULL,1);
152 int AliHLTComponent::Init(const AliHLTAnalysisEnvironment* comenv, void* environParam, int argc, const char** argv )
154 // see header file for function documentation
155 HLTLogKeyword(GetComponentID());
158 memset(&fEnvironment, 0, sizeof(AliHLTAnalysisEnvironment));
159 memcpy(&fEnvironment, comenv, comenv->fStructSize<sizeof(AliHLTAnalysisEnvironment)?comenv->fStructSize:sizeof(AliHLTAnalysisEnvironment));
160 fEnvironment.fStructSize=sizeof(AliHLTAnalysisEnvironment);
161 fEnvironment.fParam=environParam;
164 const char** pArguments=NULL;
169 pArguments=new const char*[argc];
171 for (int i=0; i<argc && iResult>=0; i++) {
172 if (fComponentArgs.size()>0) fComponentArgs+=" ";
173 fComponentArgs+=argv[i];
175 if (argument.IsNull()) continue;
178 if (argument.CompareTo("benchmark")==0) {
181 } else if (argument.CompareTo("loglevel")==0) {
182 if ((bMissingParam=(++i>=argc))) break;
183 TString parameter(argv[i]);
184 parameter.Remove(TString::kLeading, ' '); // remove all blanks
185 if (parameter.BeginsWith("0x") &&
186 parameter.Replace(0,2,"",0).IsHex()) {
187 unsigned int loglevel=kHLTLogNone;
188 sscanf(parameter.Data(),"%x", &loglevel);
189 SetLocalLoggingLevel((AliHLTComponentLogSeverity)loglevel);
191 HLTError("wrong parameter for argument %s, hex number expected", argument.Data());
194 // -object-compression=
195 } else if (argument.BeginsWith("-object-compression=")) {
196 argument.ReplaceAll("-object-compression=", "");
197 if (argument.IsDigit()) {
198 fCompressionLevel=argument.Atoi();
199 if (fCompressionLevel<0 || fCompressionLevel>9) {
200 HLTWarning("invalid compression level %d, setting to default %d", fCompressionLevel, ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION);
201 fCompressionLevel=ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION;
204 HLTError("wrong parameter for argument -object-compression, number expected");
207 pArguments[iNofChildArgs++]=argv[i];
215 HLTError("missing parameter for argument %s", argument.Data());
219 iResult=DoInit(iNofChildArgs, pArguments);
224 // find out if the component wants to get the steering events
226 AliHLTComponentDataTypeList inputDt;
227 GetInputDataTypes(inputDt);
228 for (AliHLTComponentDataTypeList::iterator dt=inputDt.begin();
229 dt!=inputDt.end() && !fRequireSteeringBlocks;
231 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeSOR);
232 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeRunType);
233 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeEOR);
234 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeDDL);
235 fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeComponentStatistics);
238 if (pArguments) delete [] pArguments;
240 #if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
241 // benchmarking stopwatch for the component statistics
242 fpBenchmark=new TStopwatch;
244 fpBenchmark->Start();
251 int AliHLTComponent::Deinit()
253 // see header file for function documentation
254 HLTLogKeyword(GetComponentID());
258 HLTWarning("did not receive EOR for run %d", fpRunDesc->fRunNo);
259 AliHLTRunDesc* pRunDesc=fpRunDesc;
267 int AliHLTComponent::InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler)
269 // see header file for function documentation
272 // I have to think about separating the library handling from the
273 // component handler. Requiring the component hanlder here is not
274 // the cleanest solution.
275 // We presume the library already to be loaded
277 AliHLTMiscInitCDB_t pFunc=(AliHLTMiscInitCDB_t)pHandler->FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_INIT_CDB);
280 if (cdbPath && cdbPath[0]!=0) {
282 // very temporary fix, have to check for other formats
283 if (!path.BeginsWith("local://")) {
288 if ((iResult=(*pFunc)(path.Data()))>=0) {
289 if (!(fCDBSetRunNoFunc=pHandler->FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_SET_CDB_RUNNO))) {
290 Message(NULL, kHLTLogWarning, "AliHLTComponent::InitCDB", "init CDB",
291 "can not find function to set CDB run no");
295 Message(NULL, kHLTLogError, "AliHLTComponent::InitCDB", "init CDB",
296 "can not find initialization function");
305 int AliHLTComponent::SetCDBRunNo(int runNo)
307 // see header file for function documentation
308 if (!fCDBSetRunNoFunc) return 0;
309 return (*((AliHLTMiscSetCDBRunNo_t)fCDBSetRunNoFunc))(runNo);
312 int AliHLTComponent::SetRunDescription(const AliHLTRunDesc* desc, const char* /*runType*/)
314 // see header file for function documentation
315 if (!desc) return -EINVAL;
316 if (desc->fStructSize!=sizeof(AliHLTRunDesc)) {
317 HLTError("invalid size of RunDesc struct (%ul)", desc->fStructSize);
322 fpRunDesc=new AliHLTRunDesc;
323 if (!fpRunDesc) return -ENOMEM;
324 *fpRunDesc=kAliHLTVoidRunDesc;
327 if (fpRunDesc->fRunNo!=kAliHLTVoidRunNo && fpRunDesc->fRunNo!=desc->fRunNo) {
328 HLTWarning("Run description has already been set");
331 SetCDBRunNo(fpRunDesc->fRunNo);
332 // TODO: we have to decide about the runType
336 int AliHLTComponent::SetComponentDescription(const char* desc)
338 // see header file for function documentation
342 TString descriptor=desc;
343 TObjArray* pTokens=descriptor.Tokenize(" ");
345 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
346 TString argument=((TObjString*)pTokens->At(i++))->GetString();
347 if (!argument || argument.IsNull()) continue;
350 if (argument.BeginsWith("chainid")) {
351 argument.ReplaceAll("chainid", "");
352 if (argument.BeginsWith("=")) {
353 fChainId=argument.Replace(0,1,"");
354 fChainIdCrc=CalculateChecksum((const AliHLTUInt8_t*)fChainId.c_str(), fChainId.length());
355 HLTDebug("setting component description: chain id %s crc 0x%8x", fChainId.c_str(), fChainIdCrc);
360 HLTWarning("unknown component description %s", argument.Data());
368 int AliHLTComponent::DoInit( int /*argc*/, const char** /*argv*/)
370 // default implementation, childs can overload
371 HLTLogKeyword("dummy");
375 int AliHLTComponent::DoDeinit()
377 // default implementation, childs can overload
378 HLTLogKeyword("dummy");
382 int AliHLTComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
384 // default implementation, childs can overload
385 HLTLogKeyword("dummy");
389 int AliHLTComponent::ReadPreprocessorValues(const char* /*modules*/)
391 // default implementation, childs can overload
392 HLTLogKeyword("dummy");
396 int AliHLTComponent::StartOfRun()
398 // default implementation, childs can overload
399 HLTLogKeyword("dummy");
403 int AliHLTComponent::EndOfRun()
405 // default implementation, childs can overload
406 HLTLogKeyword("dummy");
411 int AliHLTComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& /*tgtList*/)
413 // default implementation, childs can overload
414 HLTLogKeyword("dummy");
418 void AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2] ) const
420 // see header file for function documentation
421 memset( output, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 );
422 strncat( output, type.fOrigin, kAliHLTComponentDataTypefOriginSize );
423 strcat( output, ":" );
424 strncat( output, type.fID, kAliHLTComponentDataTypefIDsize );
427 string AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, int mode)
429 // see header file for function documentation
435 for (i=0; i<kAliHLTComponentDataTypefOriginSize; i++) {
436 sprintf(tmp, "'%d", type.fOrigin[i]);
440 for (i=0; i<kAliHLTComponentDataTypefIDsize; i++) {
441 sprintf(tmp, "%d'", type.fID[i]);
450 for (i=0; i<kAliHLTComponentDataTypefOriginSize; i++) {
451 unsigned char* puc=(unsigned char*)type.fOrigin;
453 sprintf(tmp, "'\\%x", type.fOrigin[i]);
455 sprintf(tmp, "'%c", type.fOrigin[i]);
459 for (i=0; i<kAliHLTComponentDataTypefIDsize; i++) {
460 unsigned char* puc=(unsigned char*)type.fID;
462 sprintf(tmp, "\\%x'", type.fID[i]);
464 sprintf(tmp, "%c'", type.fID[i]);
470 if (type==kAliHLTVoidDataType) {
473 // some gymnastics in order to avoid a '0' which is part of either or both
474 // ID and origin terminating the whole string. Unfortunately, string doesn't
475 // stop appending at the '0' if the number of elements to append was
476 // explicitely specified
478 tmp.append(type.fOrigin, kAliHLTComponentDataTypefOriginSize);
479 out.append(tmp.c_str());
482 tmp.append(type.fID, kAliHLTComponentDataTypefIDsize);
483 out.append(tmp.c_str());
489 void* AliHLTComponent::AllocMemory( unsigned long size )
491 // see header file for function documentation
492 if (fEnvironment.fAllocMemoryFunc)
493 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
494 HLTFatal("no memory allocation handler registered");
498 int AliHLTComponent::MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
499 AliHLTComponentBlockData** outputBlocks )
501 // see header file for function documentation
502 if ( blockCount==NULL || outputBlocks==NULL )
504 AliHLTUInt32_t count = blocks.size();
508 *outputBlocks = NULL;
511 *outputBlocks = reinterpret_cast<AliHLTComponentBlockData*>( AllocMemory( sizeof(AliHLTComponentBlockData)*count ) );
512 if ( !*outputBlocks )
514 for ( unsigned long i = 0; i < count; i++ ) {
515 (*outputBlocks)[i] = blocks[i];
516 if (MatchExactly(blocks[i].fDataType, kAliHLTAnyDataType)) {
517 (*outputBlocks)[i].fDataType=GetOutputDataType();
518 /* data type was set to the output data type by the PubSub AliRoot
519 Wrapper component, if data type of the block was ********:****.
520 Now handled by the component base class in order to have same
521 behavior when running embedded in AliRoot
522 memset((*outputBlocks)[i].fDataType.fID, '*', kAliHLTComponentDataTypefIDsize);
523 memset((*outputBlocks)[i].fDataType.fOrigin, '*', kAliHLTComponentDataTypefOriginSize);
532 int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd )
534 // see header file for function documentation
535 if (fEnvironment.fGetEventDoneDataFunc)
536 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
540 int AliHLTComponent::ReserveEventDoneData( unsigned long size )
542 // see header file for function documentation
546 if (size>fEventDoneDataSize) {
547 AliHLTComponentEventDoneData* newEDD = reinterpret_cast<AliHLTComponentEventDoneData*>( new AliHLTUInt8_t[ sizeof(AliHLTComponentEventDoneData)+size ] );
550 newEDD->fStructSize = sizeof(AliHLTComponentEventDoneData);
551 newEDD->fDataSize = 0;
552 newEDD->fData = reinterpret_cast<AliHLTUInt8_t*>(newEDD)+newEDD->fStructSize;
553 if (fEventDoneData) {
554 memcpy( newEDD->fData, fEventDoneData->fData, fEventDoneData->fDataSize );
555 newEDD->fDataSize = fEventDoneData->fDataSize;
556 delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
558 fEventDoneData = newEDD;
559 fEventDoneDataSize = size;
565 int AliHLTComponent::PushEventDoneData( AliHLTUInt32_t eddDataWord )
569 if (fEventDoneData->fDataSize+sizeof(AliHLTUInt32_t)>fEventDoneDataSize)
571 *reinterpret_cast<AliHLTUInt32_t*>((reinterpret_cast<AliHLTUInt8_t*>(fEventDoneData->fData)+fEventDoneData->fDataSize)) = eddDataWord;
572 fEventDoneData->fDataSize += sizeof(AliHLTUInt32_t);
576 void AliHLTComponent::ReleaseEventDoneData()
579 delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
580 fEventDoneData = NULL;
581 fEventDoneDataSize = 0;
585 int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList)
587 // see header file for function documentation
590 AliHLTComponentDataTypeList itypes;
591 AliHLTComponentDataTypeList otypes;
592 otypes.push_back(GetOutputDataType());
593 if (otypes[0]==kAliHLTMultipleDataType) {
596 if ((count=GetOutputDataTypes(otypes))>0) {
597 } else if (GetComponentType()!=kSink) {
598 HLTWarning("component %s indicates multiple output data types but GetOutputDataTypes returns %d", GetComponentID(), count);
601 ((AliHLTComponent*)pConsumer)->GetInputDataTypes(itypes);
602 AliHLTComponentDataTypeList::iterator otype=otypes.begin();
603 for (;otype!=otypes.end();otype++) {
604 //PrintDataTypeContent((*otype), "publisher \'%s\'");
605 if ((*otype)==(kAliHLTAnyDataType|kAliHLTDataOriginPrivate)) {
606 if (tgtList) tgtList->push_back(*otype);
611 AliHLTComponentDataTypeList::iterator itype=itypes.begin();
612 for ( ; itype!=itypes.end() && (*itype)!=(*otype) ; itype++) {/* empty body */};
613 //if (itype!=itypes.end()) PrintDataTypeContent(*itype, "consumer \'%s\'");
614 if (itype!=itypes.end()) {
615 if (tgtList) tgtList->push_back(*otype);
625 void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format)
627 // see header file for function documentation
628 const char* fmt="\'%s\'";
629 if (format) fmt=format;
630 AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, Form(fmt, (DataType2Text(dt)).c_str()));
631 AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL,
632 Form("%x %x %x %x %x %x %x %x : %x %x %x %x",
647 void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData )
649 // see header file for function documentation
650 blockData.fStructSize = sizeof(blockData);
651 FillShmData( blockData.fShmKey );
652 blockData.fOffset = ~(AliHLTUInt32_t)0;
653 blockData.fPtr = NULL;
655 FillDataType( blockData.fDataType );
656 blockData.fSpecification = kAliHLTVoidDataSpec;
659 void AliHLTComponent::FillShmData( AliHLTComponentShmData& shmData )
661 // see header file for function documentation
662 shmData.fStructSize = sizeof(shmData);
663 shmData.fShmType = gkAliHLTComponentInvalidShmType;
664 shmData.fShmID = gkAliHLTComponentInvalidShmID;
667 void AliHLTComponent::FillDataType( AliHLTComponentDataType& dataType )
669 // see header file for function documentation
670 dataType=kAliHLTAnyDataType;
673 void AliHLTComponent::CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt)
675 // see header file for function documentation
676 memcpy(&tgtdt.fID[0], &srcdt.fID[0], kAliHLTComponentDataTypefIDsize);
677 memcpy(&tgtdt.fOrigin[0], &srcdt.fOrigin[0], kAliHLTComponentDataTypefOriginSize);
680 void AliHLTComponent::SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin)
682 // see header file for function documentation
683 tgtdt.fStructSize=sizeof(AliHLTComponentDataType);
685 memset(&tgtdt.fID[0], 0, kAliHLTComponentDataTypefIDsize);
686 strncpy(&tgtdt.fID[0], id, strlen(id)<(size_t)kAliHLTComponentDataTypefIDsize?strlen(id):kAliHLTComponentDataTypefIDsize);
689 memset(&tgtdt.fOrigin[0], 0, kAliHLTComponentDataTypefOriginSize);
690 strncpy(&tgtdt.fOrigin[0], origin, strlen(origin)<(size_t)kAliHLTComponentDataTypefOriginSize?strlen(origin):kAliHLTComponentDataTypefOriginSize);
694 void AliHLTComponent::SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t origin)
696 // see header file for function documentation
697 dt.fStructSize=sizeof(AliHLTComponentDataType);
698 assert(kAliHLTComponentDataTypefIDsize==sizeof(id));
699 assert(kAliHLTComponentDataTypefOriginSize==sizeof(origin));
700 memcpy(&dt.fID, &id, kAliHLTComponentDataTypefIDsize);
701 memcpy(&dt.fOrigin, &origin, kAliHLTComponentDataTypefOriginSize);
704 void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData)
706 // see header file for function documentation
707 memset(&evtData, 0, sizeof(AliHLTComponentEventData));
708 evtData.fStructSize=sizeof(AliHLTComponentEventData);
709 evtData.fEventID=kAliHLTVoidEventID;
712 void AliHLTComponent::PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt)
714 // see header file for function documentation
716 msg.Form("AliHLTComponentDataType(%d): ID=\"", dt.fStructSize);
717 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) {
718 if (dt.fID[i]!=0) msg+=dt.fID[i];
722 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) {
723 if (dt.fOrigin[i]!=0) msg+=dt.fOrigin[i];
727 AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, msg.Data());
730 int AliHLTComponent::GetEventCount() const
732 // see header file for function documentation
736 int AliHLTComponent::IncrementEventCounter()
738 // see header file for function documentation
739 if (fEventCount>=0) fEventCount++;
743 int AliHLTComponent::GetNumberOfInputBlocks() const
745 // see header file for function documentation
746 if (fpInputBlocks!=NULL) {
747 return fCurrentEventData.fBlockCnt;
752 AliHLTEventID_t AliHLTComponent::GetEventId() const
754 // see header file for function documentation
755 if (fpInputBlocks!=NULL) {
756 return fCurrentEventData.fEventID;
761 const TObject* AliHLTComponent::GetFirstInputObject(const AliHLTComponentDataType& dt,
762 const char* classname,
765 // see header file for function documentation
766 ALIHLTCOMPONENT_BASE_STOPWATCH();
768 if (classname) fClassName=classname;
769 else fClassName.clear();
770 int idx=FindInputBlock(fSearchDataType, 0, 1);
773 HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(dt).c_str());
774 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
775 fCurrentInputBlock=idx;
782 const TObject* AliHLTComponent::GetFirstInputObject(const char* dtID,
783 const char* dtOrigin,
784 const char* classname,
787 // see header file for function documentation
788 ALIHLTCOMPONENT_BASE_STOPWATCH();
789 AliHLTComponentDataType dt;
790 SetDataType(dt, dtID, dtOrigin);
791 return GetFirstInputObject(dt, classname, bForce);
794 const TObject* AliHLTComponent::GetNextInputObject(int bForce)
796 // see header file for function documentation
797 ALIHLTCOMPONENT_BASE_STOPWATCH();
798 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1, 1);
799 //HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(fSearchDataType).c_str());
802 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
803 fCurrentInputBlock=idx;
809 int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int startIdx, int bObject) const
811 // see header file for function documentation
813 if (fpInputBlocks!=NULL) {
814 int idx=startIdx<0?0:startIdx;
815 for ( ; (UInt_t)idx<fCurrentEventData.fBlockCnt && iResult==-ENOENT; idx++) {
816 if (dt!=fpInputBlocks[idx].fDataType) continue;
819 if (fpInputBlocks[idx].fPtr==NULL) continue;
820 AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
821 if (firstWord!=fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) continue;
829 TObject* AliHLTComponent::CreateInputObject(int idx, int bForce)
831 // see header file for function documentation
833 if (fpInputBlocks!=NULL) {
834 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
835 if (fpInputBlocks[idx].fPtr) {
836 AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
837 if (firstWord==fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) {
838 HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize);
839 AliHLTMessage msg(fpInputBlocks[idx].fPtr, fpInputBlocks[idx].fSize);
840 TClass* objclass=msg.GetClass();
841 pObj=msg.ReadObject(objclass);
842 if (pObj && objclass) {
843 HLTDebug("object %p type %s created", pObj, objclass->GetName());
847 } else if (bForce!=0) {
848 HLTError("size mismatch: block size %d, indicated %d", fpInputBlocks[idx].fSize, firstWord+sizeof(AliHLTUInt32_t));
851 HLTFatal("block descriptor empty");
854 HLTError("index %d out of range %d", idx, fCurrentEventData.fBlockCnt);
857 HLTError("no input blocks available");
863 TObject* AliHLTComponent::GetInputObject(int idx, const char* /*classname*/, int bForce)
865 // see header file for function documentation
866 if (fpInputObjects==NULL) {
867 fpInputObjects=new TObjArray(fCurrentEventData.fBlockCnt);
870 if (fpInputObjects) {
871 pObj=fpInputObjects->At(idx);
873 pObj=CreateInputObject(idx, bForce);
875 fpInputObjects->AddAt(pObj, idx);
879 HLTFatal("memory allocation failed: TObjArray of size %d", fCurrentEventData.fBlockCnt);
884 int AliHLTComponent::CleanupInputObjects()
886 // see header file for function documentation
887 if (!fpInputObjects) return 0;
888 TObjArray* array=fpInputObjects;
890 for (int i=0; i<array->GetEntries(); i++) {
891 TObject* pObj=array->At(i);
892 // grrr, garbage collection strikes back: When read via AliHLTMessage
893 // (CreateInputObject), and written to a TFile afterwards, the
894 // TFile::Close calls ROOOT's garbage collection. No clue why the
895 // object ended up in the key list and needs to be deleted
896 if (pObj && gObjectTable->PtrIsValid(pObj)) delete pObj;
902 AliHLTComponentDataType AliHLTComponent::GetDataType(const TObject* pObject)
904 // see header file for function documentation
905 ALIHLTCOMPONENT_BASE_STOPWATCH();
906 AliHLTComponentDataType dt=kAliHLTVoidDataType;
907 int idx=fCurrentInputBlock;
909 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
911 HLTError("unknown object %p", pObject);
915 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
916 dt=fpInputBlocks[idx].fDataType;
918 HLTFatal("severe internal error, index out of range");
924 AliHLTUInt32_t AliHLTComponent::GetSpecification(const TObject* pObject)
926 // see header file for function documentation
927 ALIHLTCOMPONENT_BASE_STOPWATCH();
928 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
929 int idx=fCurrentInputBlock;
931 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
933 HLTError("unknown object %p", pObject);
937 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
938 iSpec=fpInputBlocks[idx].fSpecification;
940 HLTFatal("severe internal error, index out of range");
946 int AliHLTComponent::Forward(const TObject* pObject)
948 // see header file for function documentation
950 int idx=fCurrentInputBlock;
952 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
954 HLTError("unknown object %p", pObject);
959 fOutputBlocks.push_back(fpInputBlocks[idx]);
964 int AliHLTComponent::Forward(const AliHLTComponentBlockData* pBlock)
966 // see header file for function documentation
968 int idx=fCurrentInputBlock;
970 if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) {
972 HLTError("unknown Block %p", pBlock);
977 // check for fpInputBlocks pointer done in FindInputBlock
978 fOutputBlocks.push_back(fpInputBlocks[idx]);
983 const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const AliHLTComponentDataType& dt)
985 // see header file for function documentation
986 ALIHLTCOMPONENT_BASE_STOPWATCH();
989 int idx=FindInputBlock(fSearchDataType, 0);
990 const AliHLTComponentBlockData* pBlock=NULL;
992 // check for fpInputBlocks pointer done in FindInputBlock
993 pBlock=&fpInputBlocks[idx];
994 fCurrentInputBlock=idx;
999 const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const char* dtID,
1000 const char* dtOrigin)
1002 // see header file for function documentation
1003 ALIHLTCOMPONENT_BASE_STOPWATCH();
1004 AliHLTComponentDataType dt;
1005 SetDataType(dt, dtID, dtOrigin);
1006 return GetFirstInputBlock(dt);
1009 const AliHLTComponentBlockData* AliHLTComponent::GetInputBlock(int index) const
1011 // see header file for function documentation
1012 ALIHLTCOMPONENT_BASE_STOPWATCH();
1013 assert( 0 <= index and index < (int)fCurrentEventData.fBlockCnt );
1014 return &fpInputBlocks[index];
1017 const AliHLTComponentBlockData* AliHLTComponent::GetNextInputBlock()
1019 // see header file for function documentation
1020 ALIHLTCOMPONENT_BASE_STOPWATCH();
1021 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1);
1022 const AliHLTComponentBlockData* pBlock=NULL;
1024 // check for fpInputBlocks pointer done in FindInputBlock
1025 pBlock=&fpInputBlocks[idx];
1026 fCurrentInputBlock=idx;
1031 int AliHLTComponent::FindInputBlock(const AliHLTComponentBlockData* pBlock) const
1033 // see header file for function documentation
1034 int iResult=-ENOENT;
1035 if (fpInputBlocks!=NULL) {
1037 if (pBlock>=fpInputBlocks && pBlock<fpInputBlocks+fCurrentEventData.fBlockCnt) {
1038 iResult=(int)(pBlock-fpInputBlocks);
1047 AliHLTUInt32_t AliHLTComponent::GetSpecification(const AliHLTComponentBlockData* pBlock)
1049 // see header file for function documentation
1050 ALIHLTCOMPONENT_BASE_STOPWATCH();
1051 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
1052 int idx=fCurrentInputBlock;
1054 if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) {
1056 HLTError("unknown Block %p", pBlock);
1060 // check for fpInputBlocks pointer done in FindInputBlock
1061 iSpec=fpInputBlocks[idx].fSpecification;
1066 int AliHLTComponent::PushBack(TObject* pObject, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
1067 void* pHeader, int headerSize)
1069 // see header file for function documentation
1070 ALIHLTCOMPONENT_BASE_STOPWATCH();
1073 AliHLTMessage msg(kMESS_OBJECT);
1074 msg.SetCompressionLevel(fCompressionLevel);
1075 msg.WriteObject(pObject);
1076 Int_t iMsgLength=msg.Length();
1078 // Matthias Sep 2008
1079 // NOTE: AliHLTMessage does implement it's own SetLength method
1080 // which is not architecture independent. The original SetLength
1081 // stores the size always in network byte order.
1082 // I'm trying to remember the rational for that, might be that
1083 // it was just some lack of knowledge. Want to change this, but
1084 // has to be done carefullt to be backward compatible.
1085 msg.SetLength(); // sets the length to the first (reserved) word
1087 // does nothing if the level is 0
1090 char *mbuf = msg.Buffer();
1091 if (msg.CompBuffer()) {
1092 msg.SetLength(); // set once more to have to byte order
1093 mbuf = msg.CompBuffer();
1094 iMsgLength = msg.CompLength();
1097 iResult=InsertOutputBlock(mbuf, iMsgLength, dt, spec, pHeader, headerSize);
1099 HLTDebug("object %s (%p) size %d compression %d inserted to output", pObject->ClassName(), pObject, iMsgLength, msg.GetCompressionLevel());
1102 HLTError("object serialization failed for object %p", pObject);
1111 int AliHLTComponent::PushBack(TObject* pObject, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec,
1112 void* pHeader, int headerSize)
1114 // see header file for function documentation
1115 ALIHLTCOMPONENT_BASE_STOPWATCH();
1116 AliHLTComponentDataType dt;
1117 SetDataType(dt, dtID, dtOrigin);
1118 return PushBack(pObject, dt, spec, pHeader, headerSize);
1121 int AliHLTComponent::PushBack(const void* pBuffer, int iSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
1122 const void* pHeader, int headerSize)
1124 // see header file for function documentation
1125 ALIHLTCOMPONENT_BASE_STOPWATCH();
1126 return InsertOutputBlock(pBuffer, iSize, dt, spec, pHeader, headerSize);
1129 int AliHLTComponent::PushBack(const void* pBuffer, int iSize, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec,
1130 const void* pHeader, int headerSize)
1132 // see header file for function documentation
1133 ALIHLTCOMPONENT_BASE_STOPWATCH();
1134 AliHLTComponentDataType dt;
1135 SetDataType(dt, dtID, dtOrigin);
1136 return PushBack(pBuffer, iSize, dt, spec, pHeader, headerSize);
1139 int AliHLTComponent::InsertOutputBlock(const void* pBuffer, int iBufferSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
1140 const void* pHeader, int iHeaderSize)
1142 // see header file for function documentation
1144 int iBlkSize = iBufferSize + iHeaderSize;
1146 if ((pBuffer!=NULL && iBufferSize>0) || (pHeader!=NULL && iHeaderSize>0)) {
1147 if (fpOutputBuffer && iBlkSize<=(int)(fOutputBufferSize-fOutputBufferFilled)) {
1148 AliHLTUInt8_t* pTgt=fpOutputBuffer+fOutputBufferFilled;
1150 // copy header if provided but skip if the header is the target location
1151 // in that case it has already been copied
1152 if (pHeader!=NULL && pHeader!=pTgt) {
1153 memcpy(pTgt, pHeader, iHeaderSize);
1156 pTgt += (AliHLTUInt8_t) iHeaderSize;
1158 // copy buffer if provided but skip if buffer is the target location
1159 // in that case it has already been copied
1160 if (pBuffer!=NULL && pBuffer!=pTgt) {
1161 memcpy(pTgt, pBuffer, iBufferSize);
1163 //AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)pBuffer);
1164 //HLTDebug("copy %d bytes from %p to output buffer %p, first word %#x", iBufferSize, pBuffer, pTgt, firstWord);
1166 //HLTDebug("buffer inserted to output: size %d data type %s spec %#x", iBlkSize, DataType2Text(dt).c_str(), spec);
1168 if (fpOutputBuffer) {
1169 HLTError("too little space in output buffer: %d, required %d", fOutputBufferSize-fOutputBufferFilled, iBlkSize);
1171 HLTError("output buffer not available");
1177 AliHLTComponentBlockData bd;
1178 FillBlockData( bd );
1179 bd.fOffset = fOutputBufferFilled;
1180 bd.fSize = iBlkSize;
1182 bd.fSpecification = spec;
1183 fOutputBlocks.push_back( bd );
1184 fOutputBufferFilled+=bd.fSize;
1190 int AliHLTComponent::EstimateObjectSize(TObject* pObject) const
1192 // see header file for function documentation
1193 if (!pObject) return -EINVAL;
1194 AliHLTMessage msg(kMESS_OBJECT);
1195 msg.WriteObject(pObject);
1196 return msg.Length();
1199 AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity, const char* dtID,
1200 const char* dtOrigin,
1201 AliHLTUInt32_t spec)
1203 // see header file for function documentation
1204 ALIHLTCOMPONENT_BASE_STOPWATCH();
1205 AliHLTComponentDataType dt;
1206 SetDataType(dt, dtID, dtOrigin);
1207 return CreateMemoryFile(capacity, dt, spec);
1210 AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity,
1211 const AliHLTComponentDataType& dt,
1212 AliHLTUInt32_t spec)
1214 // see header file for function documentation
1215 ALIHLTCOMPONENT_BASE_STOPWATCH();
1216 AliHLTMemoryFile* pFile=NULL;
1217 if (capacity>=0 && static_cast<unsigned int>(capacity)<=fOutputBufferSize-fOutputBufferFilled){
1218 AliHLTUInt8_t* pTgt=fpOutputBuffer+fOutputBufferFilled;
1219 pFile=new AliHLTMemoryFile((char*)pTgt, capacity);
1221 unsigned int nofBlocks=fOutputBlocks.size();
1222 if (nofBlocks+1>fMemFiles.size()) {
1223 fMemFiles.resize(nofBlocks+1, NULL);
1225 if (nofBlocks<fMemFiles.size()) {
1226 fMemFiles[nofBlocks]=pFile;
1227 AliHLTComponentBlockData bd;
1228 FillBlockData( bd );
1229 bd.fOffset = fOutputBufferFilled;
1230 bd.fSize = capacity;
1232 bd.fSpecification = spec;
1233 fOutputBufferFilled+=bd.fSize;
1234 fOutputBlocks.push_back( bd );
1236 HLTError("can not allocate/grow object array");
1237 pFile->CloseMemoryFile(0);
1243 HLTError("can not create memory file of size %d (%d available)", capacity, fOutputBufferSize-fOutputBufferFilled);
1248 AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(const char* dtID,
1249 const char* dtOrigin,
1250 AliHLTUInt32_t spec,
1253 // see header file for function documentation
1254 ALIHLTCOMPONENT_BASE_STOPWATCH();
1255 AliHLTComponentDataType dt;
1256 SetDataType(dt, dtID, dtOrigin);
1257 int size=fOutputBufferSize-fOutputBufferFilled;
1258 if (capacity<0 || capacity>1.0) {
1259 HLTError("invalid parameter: capacity %f", capacity);
1262 size=(int)(size*capacity);
1263 return CreateMemoryFile(size, dt, spec);
1266 AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(const AliHLTComponentDataType& dt,
1267 AliHLTUInt32_t spec,
1270 // see header file for function documentation
1271 ALIHLTCOMPONENT_BASE_STOPWATCH();
1272 int size=fOutputBufferSize-fOutputBufferFilled;
1273 if (capacity<0 || capacity>1.0) {
1274 HLTError("invalid parameter: capacity %f", capacity);
1277 size=(int)(size*capacity);
1278 return CreateMemoryFile(size, dt, spec);
1281 int AliHLTComponent::Write(AliHLTMemoryFile* pFile, const TObject* pObject,
1282 const char* key, int option)
1284 // see header file for function documentation
1286 if (pFile && pObject) {
1288 iResult=pObject->Write(key, option);
1292 iResult=-pFile->GetErrno();
1293 if (iResult==-ENOSPC) {
1294 HLTError("error writing memory file, buffer too small");
1303 int AliHLTComponent::CloseMemoryFile(AliHLTMemoryFile* pFile)
1305 // see header file for function documentation
1308 AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
1310 while (element!=fMemFiles.end() && iResult>=0) {
1311 if (*element && *element==pFile) {
1312 iResult=pFile->CloseMemoryFile();
1314 // sync memory files and descriptors
1316 fOutputBlocks[i].fSize=(*element)->GetSize()+(*element)->GetHeaderSize();
1324 HLTError("can not find memory file %p", pFile);
1332 int AliHLTComponent::CreateEventDoneData(AliHLTComponentEventDoneData edd)
1334 // see header file for function documentation
1337 AliHLTComponentEventDoneData* newEDD = NULL;
1339 unsigned long newSize=edd.fDataSize;
1341 newSize += fEventDoneData->fDataSize;
1343 if (newSize>fEventDoneDataSize) {
1344 newEDD = reinterpret_cast<AliHLTComponentEventDoneData*>( new AliHLTUInt8_t[ sizeof(AliHLTComponentEventDoneData)+newSize ] );
1347 newEDD->fStructSize = sizeof(AliHLTComponentEventDoneData);
1348 newEDD->fDataSize = newSize;
1349 newEDD->fData = reinterpret_cast<AliHLTUInt8_t*>(newEDD)+newEDD->fStructSize;
1350 unsigned long long offset = 0;
1351 if (fEventDoneData) {
1352 memcpy( newEDD->fData, fEventDoneData->fData, fEventDoneData->fDataSize );
1353 offset += fEventDoneData->fDataSize;
1355 memcpy( reinterpret_cast<AliHLTUInt8_t*>(newEDD->fData)+offset, edd.fData, edd.fDataSize );
1357 delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
1358 fEventDoneData = newEDD;
1359 fEventDoneDataSize = newSize;
1362 memcpy( reinterpret_cast<AliHLTUInt8_t*>(fEventDoneData->fData)+fEventDoneData->fDataSize, edd.fData, edd.fDataSize );
1363 fEventDoneData->fDataSize += edd.fDataSize;
1368 int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
1369 const AliHLTComponentBlockData* blocks,
1370 AliHLTComponentTriggerData& trigData,
1371 AliHLTUInt8_t* outputPtr,
1372 AliHLTUInt32_t& size,
1373 AliHLTUInt32_t& outputBlockCnt,
1374 AliHLTComponentBlockData*& outputBlocks,
1375 AliHLTComponentEventDoneData*& edd )
1377 // see header file for function documentation
1378 HLTLogKeyword(GetComponentID());
1379 ALIHLTCOMPONENT_BASE_STOPWATCH();
1381 fCurrentEvent=evtData.fEventID;
1382 fCurrentEventData=evtData;
1383 fpInputBlocks=blocks;
1384 fCurrentInputBlock=-1;
1385 fSearchDataType=kAliHLTAnyDataType;
1386 fpOutputBuffer=outputPtr;
1387 fOutputBufferSize=size;
1388 fOutputBufferFilled=0;
1389 fOutputBlocks.clear();
1393 AliHLTComponentBlockDataList forwardedBlocks;
1395 // optional component statistics
1396 AliHLTComponentStatisticsList compStats;
1397 bool bAddComponentTableEntry=false;
1398 vector<AliHLTUInt32_t> parentComponentTables;
1399 #if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
1400 AliHLTComponentStatistics outputStat;
1401 memset(&outputStat, 0, sizeof(AliHLTComponentStatistics));
1402 outputStat.fId=fChainIdCrc;
1403 compStats.push_back(outputStat);
1405 fpBenchmark->Reset();
1406 fpBenchmark->Start();
1410 // data processing is skipped
1411 // - if there are only steering events in the block list.
1412 // For the sake of data source components data processing
1413 // is not skipped if there is no block list at all or if it
1414 // just contains the eventType block
1415 // - always skipped if the event is of type
1416 // - gkAliEventTypeConfiguration
1417 // - gkAliEventTypeReadPreprocessor
1418 const unsigned int skipModeDefault=0x1;
1419 const unsigned int skipModeForce=0x2;
1420 unsigned int bSkipDataProcessing=skipModeDefault;
1422 // find special events
1423 if (fpInputBlocks && evtData.fBlockCnt>0) {
1424 // first look for all special events and execute in the appropriate
1425 // sequence afterwords
1426 int indexComConfEvent=-1;
1427 int indexUpdtDCSEvent=-1;
1428 int indexSOREvent=-1;
1429 int indexEOREvent=-1;
1430 for (unsigned int i=0; i<evtData.fBlockCnt && iResult>=0; i++) {
1431 if (fpInputBlocks[i].fDataType==kAliHLTDataTypeSOR) {
1433 // the AliHLTCalibrationProcessor relies on the SOR and EOR events
1434 bSkipDataProcessing&=~skipModeDefault;
1435 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeRunType) {
1437 // handling is not clear yet
1438 if (fpInputBlocks[i].fPtr) {
1439 HLTDebug("got run type \"%s\"\n", fpInputBlocks[i].fPtr);
1441 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) {
1443 // the calibration processor relies on the SOR and EOR events
1444 bSkipDataProcessing&=~skipModeDefault;
1445 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) {
1447 // this event is most likely deprecated
1448 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComConf) {
1449 indexComConfEvent=i;
1450 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeUpdtDCS) {
1451 indexUpdtDCSEvent=i;
1452 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEvent) {
1453 fEventType=fpInputBlocks[i].fSpecification;
1455 // skip always in case of gkAliEventTypeConfiguration
1456 if (fpInputBlocks[i].fSpecification==gkAliEventTypeConfiguration) bSkipDataProcessing|=skipModeForce;
1458 // skip always in case of gkAliEventTypeReadPreprocessor
1459 if (fpInputBlocks[i].fSpecification==gkAliEventTypeReadPreprocessor) bSkipDataProcessing|=skipModeForce;
1461 // never skip if the event type block is the only block
1462 if (evtData.fBlockCnt==1) bSkipDataProcessing&=~skipModeDefault;
1464 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComponentStatistics) {
1465 if (compStats.size()>0) {
1466 AliHLTUInt8_t* pData=reinterpret_cast<AliHLTUInt8_t*>(fpInputBlocks[i].fPtr);
1467 for (AliHLTUInt32_t offset=0;
1468 offset+sizeof(AliHLTComponentStatistics)<=fpInputBlocks[i].fSize;
1469 offset+=sizeof(AliHLTComponentStatistics)) {
1470 AliHLTComponentStatistics* pStat=reinterpret_cast<AliHLTComponentStatistics*>(pData+offset);
1471 if (pStat && compStats[0].fLevel<=pStat->fLevel) {
1472 compStats[0].fLevel=pStat->fLevel+1;
1474 compStats.push_back(*pStat);
1477 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComponentTable) {
1478 forwardedBlocks.push_back(fpInputBlocks[i]);
1479 parentComponentTables.push_back(fpInputBlocks[i].fSpecification);
1481 // the processing function is called if there is at least one
1482 // non-steering data block. Steering blocks are not filtered out
1483 // for sake of performance
1484 bSkipDataProcessing&=~skipModeDefault;
1485 if (compStats.size()>0) {
1486 compStats[0].fInputBlockCount++;
1487 compStats[0].fTotalInputSize+=fpInputBlocks[i].fSize;
1492 if (indexSOREvent>=0) {
1494 bAddComponentTableEntry=true;
1495 if (fpRunDesc==NULL) {
1496 fpRunDesc=new AliHLTRunDesc;
1497 if (fpRunDesc) *fpRunDesc=kAliHLTVoidRunDesc;
1500 AliHLTRunDesc rundesc;
1501 if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), indexSOREvent, "AliHLTRunDesc", "SOR"))>0) {
1502 if (fpRunDesc->fRunNo==kAliHLTVoidRunNo) {
1504 HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo);
1505 SetCDBRunNo(fpRunDesc->fRunNo);
1506 } else if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
1507 HLTWarning("already set run properties run no %d, ignoring SOR with run no %d", fpRunDesc->fRunNo, rundesc.fRunNo);
1514 if (indexEOREvent>=0) {
1515 bAddComponentTableEntry=true;
1516 if (fpRunDesc!=NULL) {
1518 AliHLTRunDesc rundesc;
1519 if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), indexEOREvent, "AliHLTRunDesc", "SOR"))>0) {
1520 if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
1521 HLTWarning("run no mismatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo);
1523 HLTDebug("EOR run no %d", fpRunDesc->fRunNo);
1526 AliHLTRunDesc* pRunDesc=fpRunDesc;
1531 HLTWarning("did not receive SOR, ignoring EOR");
1534 if (indexComConfEvent>=0 || fEventType==gkAliEventTypeConfiguration) {
1536 if (indexComConfEvent>=0 && fpInputBlocks[indexComConfEvent].fPtr!=NULL && fpInputBlocks[indexComConfEvent].fSize>0) {
1537 cdbEntry.Append(reinterpret_cast<const char*>(fpInputBlocks[indexComConfEvent].fPtr), fpInputBlocks[indexComConfEvent].fSize);
1539 HLTDebug("received component configuration command: entry %s", cdbEntry.IsNull()?"none":cdbEntry.Data());
1540 int tmpResult=Reconfigure(cdbEntry[0]==0?NULL:cdbEntry.Data(), fChainId.c_str());
1542 HLTWarning("reconfiguration of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
1545 if (indexUpdtDCSEvent>=0 || fEventType==gkAliEventTypeReadPreprocessor) {
1547 if (fpInputBlocks[indexUpdtDCSEvent].fPtr!=NULL && fpInputBlocks[indexUpdtDCSEvent].fSize>0) {
1548 modules.Append(reinterpret_cast<const char*>(fpInputBlocks[indexUpdtDCSEvent].fPtr), fpInputBlocks[indexUpdtDCSEvent].fSize);
1550 HLTDebug("received preprocessor update command: detectors %s", modules.IsNull()?"ALL":modules.Data());
1551 int tmpResult=ReadPreprocessorValues(modules[0]==0?"ALL":modules.Data());
1553 HLTWarning("preprocessor update of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
1557 // processing function needs to be called if there are no input data
1558 // blocks in order to make data source components working.
1559 bSkipDataProcessing&=~skipModeDefault;
1562 // data processing is not skipped if the component explicitly asks
1563 // for the private blocks
1564 if (fRequireSteeringBlocks) bSkipDataProcessing=0;
1566 AliHLTComponentBlockDataList blockData;
1567 if (iResult>=0 && !bSkipDataProcessing)
1568 { // dont delete, sets the scope for the stopwatch guard
1569 // do not use ALIHLTCOMPONENT_DA_STOPWATCH(); macro
1570 // in order to avoid 'shadowed variable' warning
1571 AliHLTStopwatchGuard swguard2(fpStopwatches!=NULL?reinterpret_cast<TStopwatch*>(fpStopwatches->At((int)kSWDA)):NULL);
1572 iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd);
1573 } // end of the scope of the stopwatch guard
1574 if (iResult>=0 && !bSkipDataProcessing) {
1575 if (fOutputBlocks.size()>0) {
1576 // High Level interface
1578 //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size());
1579 // sync memory files and descriptors
1580 AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
1582 while (element!=fMemFiles.end() && iResult>=0) {
1584 if ((*element)->IsClosed()==0) {
1585 HLTWarning("memory file has not been closed, force flush");
1586 iResult=CloseMemoryFile(*element);
1593 // create the descriptor list
1594 if (blockData.size()>0) {
1595 HLTError("low level and high interface must not be mixed; use PushBack methods to insert data blocks");
1598 if (compStats.size()>0 && IsDataEvent()) {
1599 int offset=AddComponentStatistics(fOutputBlocks, fpOutputBuffer, fOutputBufferSize, fOutputBufferFilled, compStats);
1600 if (offset>0) fOutputBufferFilled+=offset;
1602 if (bAddComponentTableEntry) {
1603 int offset=AddComponentTableEntry(fOutputBlocks, fpOutputBuffer, fOutputBufferSize, fOutputBufferFilled, parentComponentTables);
1604 if (offset>0) size+=offset;
1606 if (forwardedBlocks.size()>0) {
1607 fOutputBlocks.insert(fOutputBlocks.end(), forwardedBlocks.begin(), forwardedBlocks.end());
1609 iResult=MakeOutputDataBlockList(fOutputBlocks, &outputBlockCnt, &outputBlocks);
1610 size=fOutputBufferFilled;
1614 // Low Level interface
1615 if (compStats.size()>0) {
1616 int offset=AddComponentStatistics(blockData, fpOutputBuffer, fOutputBufferSize, size, compStats);
1617 if (offset>0) size+=offset;
1619 if (bAddComponentTableEntry) {
1620 int offset=AddComponentTableEntry(blockData, fpOutputBuffer, fOutputBufferSize, size, parentComponentTables);
1621 if (offset>0) size+=offset;
1623 if (forwardedBlocks.size()>0) {
1624 blockData.insert(blockData.end(), forwardedBlocks.begin(), forwardedBlocks.end());
1626 iResult=MakeOutputDataBlockList(blockData, &outputBlockCnt, &outputBlocks);
1629 HLTFatal("component %s (%p): can not convert output block descriptor list", GetComponentID(), this);
1632 if (iResult<0 || bSkipDataProcessing) {
1636 CleanupInputObjects();
1637 if (iResult>=0 && IsDataEvent()) {
1638 IncrementEventCounter();
1640 if (outputBlockCnt==0) {
1641 // no output blocks, set size to 0
1644 FillEventData(fCurrentEventData);
1648 int AliHLTComponent::AddComponentStatistics(AliHLTComponentBlockDataList& blocks,
1649 AliHLTUInt8_t* buffer,
1650 AliHLTUInt32_t bufferSize,
1651 AliHLTUInt32_t offset,
1652 AliHLTComponentStatisticsList& stats) const
1654 // see header file for function documentation
1656 #if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
1657 if (stats.size()==0) return -ENOENT;
1658 stats[0].fTotalOutputSize=offset;
1659 stats[0].fOutputBlockCount=blocks.size();
1661 stats[0].fTime=(AliHLTUInt32_t)(fpBenchmark->RealTime()*1000000);
1662 stats[0].fCTime=(AliHLTUInt32_t)(fpBenchmark->CpuTime()*1000000);
1664 if (offset+stats.size()*sizeof(AliHLTComponentStatistics)<=bufferSize) {
1665 AliHLTComponentBlockData bd;
1666 FillBlockData( bd );
1667 bd.fOffset = offset;
1668 bd.fSize = stats.size()*sizeof(AliHLTComponentStatistics);
1669 bd.fDataType = kAliHLTDataTypeComponentStatistics;
1670 bd.fSpecification = kAliHLTVoidDataSpec;
1671 unsigned int master=0;
1672 for (unsigned int i=1; i<blocks.size(); i++) {
1673 if (blocks[i].fSize>blocks[master].fSize &&
1674 !MatchExactly(blocks[i].fDataType, kAliHLTVoidDataType|kAliHLTDataOriginPrivate))
1677 if (blocks.size()>0 && !MatchExactly(blocks[master].fDataType, kAliHLTVoidDataType|kAliHLTDataOriginPrivate)) {
1678 // take the data origin of the biggest block as specification
1679 // this is similar to the treatment in the HOMER interface. For traditional
1680 // reasons, the bytes are swapped there on a little endian architecture, so
1681 // we do it as well.
1682 memcpy(&bd.fSpecification, &blocks[master].fDataType.fOrigin, sizeof(bd.fSpecification));
1683 #ifdef R__BYTESWAP // set on little endian architectures
1684 bd.fSpecification=((bd.fSpecification & 0xFFULL) << 24) |
1685 ((bd.fSpecification & 0xFF00ULL) << 8) |
1686 ((bd.fSpecification & 0xFF0000ULL) >> 8) |
1687 ((bd.fSpecification & 0xFF000000ULL) >> 24);
1690 memcpy(buffer+offset, &(stats[0]), bd.fSize);
1691 blocks.push_back(bd);
1695 if (blocks.size() && buffer && bufferSize && offset && stats.size()) {
1696 // get rid of warning
1702 int AliHLTComponent::AddComponentTableEntry(AliHLTComponentBlockDataList& blocks,
1703 AliHLTUInt8_t* buffer,
1704 AliHLTUInt32_t bufferSize,
1705 AliHLTUInt32_t offset,
1706 const vector<AliHLTUInt32_t>& parents) const
1708 // see header file for function documentation
1710 #if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
1711 // the payload consists of the AliHLTComponentTableEntry struct,
1712 // followed by a an array of 32bit crc chain ids and the component
1713 // description string
1714 unsigned int payloadSize=sizeof(AliHLTComponentTableEntry);
1715 payloadSize+=parents.size()*sizeof(AliHLTUInt32_t);
1717 // the component description has the following format:
1718 // chain-id{component-id:arguments}
1719 const char* componentId=const_cast<AliHLTComponent*>(this)->GetComponentID();
1720 unsigned int descriptionSize=fChainId.size()+1;
1721 descriptionSize+=2; // the '{}' around the component id
1722 descriptionSize+=strlen(componentId);
1723 descriptionSize+=1; // the ':' between component id and arguments
1724 descriptionSize+=fComponentArgs.size();
1726 payloadSize+=descriptionSize;
1727 if (buffer && (offset+payloadSize<=bufferSize)) {
1728 AliHLTUInt8_t* pTgt=buffer+offset;
1729 memset(pTgt, 0, payloadSize);
1732 AliHLTComponentTableEntry* pEntry=reinterpret_cast<AliHLTComponentTableEntry*>(pTgt);
1733 pEntry->fStructSize=sizeof(AliHLTComponentTableEntry);
1734 pEntry->fNofParents=parents.size();
1735 pEntry->fSizeDescription=descriptionSize;
1736 pTgt=pEntry->fBuffer;
1738 // write array of parents
1739 if (parents.size()>0) {
1740 unsigned int copy=parents.size()*sizeof(vector<AliHLTUInt32_t>::value_type);
1741 memcpy(pTgt, &parents[0], parents.size()*sizeof(vector<AliHLTUInt32_t>::value_type));
1745 // write component description
1746 memcpy(pTgt, fChainId.c_str(), fChainId.size());
1747 pTgt+=fChainId.size();
1749 memcpy(pTgt, componentId, strlen(componentId));
1750 pTgt+=strlen(componentId);
1752 memcpy(pTgt, fComponentArgs.c_str(), fComponentArgs.size());
1753 pTgt+=fComponentArgs.size();
1757 AliHLTComponentBlockData bd;
1758 FillBlockData( bd );
1759 bd.fOffset = offset;
1760 bd.fSize = payloadSize;
1761 bd.fDataType = kAliHLTDataTypeComponentTable;
1762 bd.fSpecification = fChainIdCrc;
1763 blocks.push_back(bd);
1767 if (blocks.size() && buffer && bufferSize && offset && parents.size()) {
1768 // get rid of warning
1774 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard()
1779 // standard constructor (not for use)
1782 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(TStopwatch* pStopwatch)
1784 fpStopwatch(pStopwatch),
1789 // check for already existing guard
1790 if (fgpCurrent) fpPrec=fgpCurrent;
1793 // stop the preceeding guard if it controls a different stopwatch
1795 if (fpPrec && fpPrec!=this) bStart=fpPrec->Hold(fpStopwatch);
1797 // start the stopwatch if the current guard controls a different one
1798 if (fpStopwatch && bStart==1) fpStopwatch->Start(kFALSE);
1801 AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(const AliHLTStopwatchGuard&)
1807 // copy constructor not for use
1811 AliHLTComponent::AliHLTStopwatchGuard& AliHLTComponent::AliHLTStopwatchGuard::operator=(const AliHLTStopwatchGuard&)
1814 // assignment operator not for use
1821 AliHLTComponent::AliHLTStopwatchGuard* AliHLTComponent::AliHLTStopwatchGuard::fgpCurrent=NULL;
1823 AliHLTComponent::AliHLTStopwatchGuard::~AliHLTStopwatchGuard()
1827 // resume the preceeding guard if it controls a different stopwatch
1829 if (fpPrec && fpPrec!=this) bStop=fpPrec->Resume(fpStopwatch);
1831 // stop the stopwatch if the current guard controls a different one
1832 if (fpStopwatch && bStop==1) fpStopwatch->Stop();
1834 // resume to the preceeding guard
1838 int AliHLTComponent::AliHLTStopwatchGuard::Hold(TStopwatch* pSucc)
1840 // see header file for function documentation
1841 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Stop();
1842 return fpStopwatch!=pSucc?1:0;
1845 int AliHLTComponent::AliHLTStopwatchGuard::Resume(TStopwatch* pSucc)
1847 // see header file for function documentation
1848 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Start(kFALSE);
1849 return fpStopwatch!=pSucc?1:0;
1852 int AliHLTComponent::SetStopwatch(TObject* pSW, AliHLTStopwatchType type)
1854 // see header file for function documentation
1856 if (pSW!=NULL && type<kSWTypeCount) {
1857 if (fpStopwatches) {
1858 TObject* pObj=fpStopwatches->At((int)type);
1859 if (pSW==NULL // explicit reset
1860 || pObj==NULL) { // explicit set
1861 fpStopwatches->AddAt(pSW, (int)type);
1862 } else if (pObj!=pSW) {
1863 HLTWarning("stopwatch %d already set, reset first", (int)type);
1873 int AliHLTComponent::SetStopwatches(TObjArray* pStopwatches)
1875 // see header file for function documentation
1876 if (pStopwatches==NULL) return -EINVAL;
1879 for (int i=0 ; i<(int)kSWTypeCount && pStopwatches->GetEntries(); i++)
1880 SetStopwatch(pStopwatches->At(i), (AliHLTStopwatchType)i);
1884 AliHLTUInt32_t AliHLTComponent::GetRunNo() const
1886 // see header file for function documentation
1887 if (fpRunDesc==NULL) return kAliHLTVoidRunNo;
1888 return fpRunDesc->fRunNo;
1891 AliHLTUInt32_t AliHLTComponent::GetRunType() const
1893 // see header file for function documentation
1894 if (fpRunDesc==NULL) return kAliHLTVoidRunType;
1895 return fpRunDesc->fRunType;
1898 bool AliHLTComponent::IsDataEvent(AliHLTUInt32_t* pTgt)
1900 // see header file for function documentation
1901 if (pTgt) *pTgt=fEventType;
1902 return (fEventType==gkAliEventTypeData ||
1903 fEventType==gkAliEventTypeDataReplay ||
1904 fEventType==gkAliEventTypeCalibration);
1907 int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo,
1908 const char* structname, const char* eventname)
1910 // see header file for function documentation
1912 if (pStruct!=NULL && iStructSize>sizeof(AliHLTUInt32_t)) {
1913 if (fpInputBlocks!=NULL && iBlockNo<fCurrentEventData.fBlockCnt) {
1914 AliHLTUInt32_t* pTgt=(AliHLTUInt32_t*)pStruct;
1915 if (fpInputBlocks[iBlockNo].fPtr && fpInputBlocks[iBlockNo].fSize) {
1916 AliHLTUInt32_t copy=*((AliHLTUInt32_t*)fpInputBlocks[iBlockNo].fPtr);
1917 if (fpInputBlocks[iBlockNo].fSize!=copy) {
1918 HLTWarning("%s event: mismatch of block size (%d) and structure size (%d)", eventname, fpInputBlocks[iBlockNo].fSize, copy);
1919 if (copy>fpInputBlocks[iBlockNo].fSize) copy=fpInputBlocks[iBlockNo].fSize;
1921 if (copy!=iStructSize) {
1922 HLTWarning("%s event: mismatch in %s version (data type version %d)", eventname, structname, ALIHLT_DATA_TYPES_VERSION);
1923 if (copy>iStructSize) {
1926 memset(pTgt, 0, iStructSize);
1929 memcpy(pTgt, fpInputBlocks[iBlockNo].fPtr, copy);
1933 HLTWarning("%s event: missing data block", eventname);
1939 HLTError("invalid struct");
1945 void AliHLTComponent::SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const
1947 // see header file for function documentation
1949 // -- Detector offset
1950 Int_t ddlIdBase = TMath::FloorNint( (Double_t) ddlId / 256.0 );
1952 // -- Word Base = 1. word of detector ( TPC has 8 words, TOF 3 )
1955 if ( ddlIdBase <= 3 )
1956 wordBase = ddlIdBase;
1957 else if ( ddlIdBase > 3 && ddlIdBase < 5 )
1958 wordBase = ddlIdBase + 7;
1960 wordBase = ddlIdBase + 9;
1962 // -- Bit index in Word
1963 Int_t bitIdx = ddlId % 32;
1966 Int_t wordIdx = wordBase;
1968 // -- if TPC (3) or TOD (5) add word idx
1969 if ( ( ddlIdBase == 3 ) || ( ddlIdBase == 5 ) ) {
1970 wordIdx += TMath::FloorNint( (Double_t) ( ddlId - ( ddlIdBase * 256 ) ) / 32.0 );
1973 // -- Set -- 'OR' word with bit mask;
1975 list.fList[wordIdx] |= ( 0x00000001 << bitIdx );
1976 // -- Unset -- 'AND' word with bit mask;
1978 list.fList[wordIdx] &= ( 0xFFFFFFFF ^ ( 0x00000001 << bitIdx ) );
1981 Int_t AliHLTComponent::GetFirstUsedDDLWord(AliHLTEventDDL &list) const
1983 // see header file for function documentation
1987 for ( Int_t wordNdx = 0 ; wordNdx < gkAliHLTDDLListSize ; wordNdx++ ) {
1989 if ( list.fList[wordNdx] != 0 && iResult == -1 ) {
1990 // check for special cases TPC and TOF
1991 if ( wordNdx > 3 && wordNdx <= 10 ) {
1995 else if ( wordNdx > 12 && wordNdx <= 14 ) {
2002 else if ( list.fList[wordNdx] != 0 && iResult >= 0 ) {
2003 HLTError( "DDLIDs for minimum of TWO detectors ( %d, %d ) set, this function works only for ONE detector.", iResult, wordNdx );
2012 AliHLTUInt32_t AliHLTComponent::CalculateChecksum(const AliHLTUInt8_t* buffer, int size)
2014 // see header file for function documentation
2015 AliHLTUInt32_t remainder = 0;
2016 const AliHLTUInt8_t crcwidth=(8*sizeof(AliHLTUInt32_t));
2017 const AliHLTUInt32_t topbit=1 << (crcwidth-1);
2018 const AliHLTUInt32_t polynomial=0xD8; /* 11011 followed by 0's */
2021 // http://www.netrino.com/Embedded-Systems/How-To/CRC-Calculation-C-Code
2024 * Perform modulo-2 division, a byte at a time.
2026 for (int byte = 0; byte < size; ++byte)
2029 * Bring the next byte into the remainder.
2031 remainder ^= (buffer[byte] << (crcwidth - 8));
2034 * Perform modulo-2 division, a bit at a time.
2036 for (uint8_t bit = 8; bit > 0; --bit)
2039 * Try to divide the current data bit.
2041 if (remainder & topbit)
2043 remainder = (remainder << 1) ^ polynomial;
2047 remainder = (remainder << 1);
2053 * The final remainder is the CRC result.
2058 int AliHLTComponent::ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
2059 string& retChainId, string& retCompId, string& retCompArgs,
2060 vector<AliHLTUInt32_t>& parents)
2062 // see header file for function documentation
2065 retCompArgs.clear();
2067 if (!pBuffer || size==0) return 0;
2069 const AliHLTComponentTableEntry* pEntry=reinterpret_cast<const AliHLTComponentTableEntry*>(pBuffer);
2070 if (size<8/* the initial size of the structure*/ ||
2071 pEntry==NULL || pEntry->fStructSize<8) return -ENOMSG;
2072 const AliHLTUInt32_t* pParents=reinterpret_cast<const AliHLTUInt32_t*>(pEntry->fBuffer);
2073 const AliHLTUInt8_t* pEnd=pBuffer+size;
2075 if (pParents+pEntry->fNofParents>=reinterpret_cast<const AliHLTUInt32_t*>(pEnd)) return -ENODEV;
2076 for (unsigned int i=0; i<pEntry->fNofParents; i++, pParents++) {
2077 parents.push_back(*pParents);
2080 const char* pDescription=reinterpret_cast<const char*>(pParents);
2081 if (pDescription+pEntry->fSizeDescription>=reinterpret_cast<const char*>(pEnd) ||
2082 *(pDescription+pEntry->fSizeDescription)!=0) {
2086 TString descriptor=reinterpret_cast<const char*>(pDescription);
2090 TObjArray* pTokens=descriptor.Tokenize("{");
2093 if (pTokens->GetEntries()>n) {
2094 retChainId=((TObjString*)pTokens->At(n++))->GetString();
2096 if (pTokens->GetEntries()>n) {
2097 compId=((TObjString*)pTokens->At(n++))->GetString();
2101 if (!compId.IsNull() && (pTokens=compId.Tokenize(":"))!=NULL) {
2103 if (pTokens->GetEntries()>n) {
2104 compId=((TObjString*)pTokens->At(n++))->GetString();
2106 if (pTokens->GetEntries()>n) {
2107 compArgs=((TObjString*)pTokens->At(n++))->GetString();
2111 compId.ReplaceAll("}", "");
2112 compArgs.ReplaceAll("}", "");
2115 retCompArgs=compArgs;
2117 if (retChainId.size()==0) return -ENODATA;