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 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /// @file AliHLTCompStatCollector.cxx
20 /// @author Matthias Richter
22 /// @brief Collector component for the component statistics information.
25 #include "AliHLTCompStatCollector.h"
27 #include "TStopwatch.h"
39 #define HLTSTAT_FOLDER_NAME "HLTstat"
40 #define HLTSTAT_FOLDER_DESC "ALICE HLT component statistics"
41 #define HLTSTAT_ENTRY_PARENT_FOLDER_NAME "parents"
42 #define HLTSTAT_ENTRY_PARENT_FOLDER_DESC "parent components"
43 #define HLTSTAT_ENTRY_PROPS_FOLDER_NAME "props"
44 #define HLTSTAT_ENTRY_PROPS_FOLDER_DESC "component properties"
45 #define HLTSTAT_ENTRY_PROPS_IDOBJ_NAME "id"
46 #define HLTSTAT_ENTRY_PROPS_IDOBJ_DESC "numerical id calculated from chain id"
48 /** ROOT macro for the implementation of ROOT specific class methods */
49 ClassImp(AliHLTCompStatCollector)
51 AliHLTCompStatCollector::AliHLTCompStatCollector()
68 fpInputBlockCountArray(NULL),
69 fpTotalInputSizeArray(NULL),
70 fpNormalizedInputSizeArray(NULL),
71 fpOutputBlockCountArray(NULL),
72 fpTotalOutputSizeArray(NULL)
73 , fpInputOutputRatioArray(NULL)
74 , fpNormalizedInputOutputRatioArray(NULL)
75 , fpComponentCycleTimeArray(NULL)
76 , fpEventTypeArray(NULL)
77 , fpEventCountArray(NULL)
78 , fSizeEstimator(1000)
79 , fMode(kPublishObjects)
82 , fLastTime(time(NULL))
86 // see header file for class documentation
88 // refer to README to build package
90 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
93 AliHLTCompStatCollector::~AliHLTCompStatCollector()
95 // see header file for class documentation
99 void AliHLTCompStatCollector::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
101 // see header file for class documentation
102 list.push_back(kAliHLTDataTypeComponentStatistics);
105 AliHLTComponentDataType AliHLTCompStatCollector::GetOutputDataType()
107 // see header file for class documentation
108 return kAliHLTMultipleDataType;
111 int AliHLTCompStatCollector::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
113 // see header file for class documentation
115 tgtList.push_back(kAliHLTDataTypeHistogram);
116 tgtList.push_back(kAliHLTDataTypeTTree);
117 return tgtList.size();
120 void AliHLTCompStatCollector::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
122 // see header file for class documentation
123 constBase=fSizeEstimator;
124 inputMultiplier=100.0;
127 int AliHLTCompStatCollector::DoInit( int argc, const char** argv )
129 // see header file for class documentation
133 for (int i=0; i<argc && iResult>=0; i++) {
135 if (argument.IsNull()) continue;
138 if (argument.CompareTo("-file")==0) {
139 if ((bMissingParam=(++i>=argc))) break;
144 } else if (argument.CompareTo("-modulo")==0) {
145 if ((bMissingParam=(++i>=argc))) break;
146 TString param=argv[i];
147 if (param.IsDigit()) {
148 fEventModulo=param.Atoi();
150 HLTError("expecting number as parameter for option %s", argument.Data());
155 } else if (argument.CompareTo("-period")==0) {
156 if ((bMissingParam=(++i>=argc))) break;
157 TString param=argv[i];
158 if (param.IsDigit()) {
159 fPeriod=param.Atoi();
161 HLTError("expecting number as parameter for option %s", argument.Data());
166 } else if (argument.CompareTo("-publish")==0) {
167 if ((bMissingParam=(++i>=argc))) break;
168 TString param=argv[i];
169 if (param.IsDigit()) {
170 if (param.Atoi()==1) fMode|=kPublishObjects;
171 else if (param.Atoi()==0) fMode&=~kPublishObjects;
173 HLTError("expecting 0 or 1 as parameter for option %s", argument.Data());
177 HLTError("expecting number as parameter for option %s", argument.Data());
182 } else if (argument.CompareTo("-arraysize")==0) {
183 if ((bMissingParam=(++i>=argc))) break;
184 TString param=argv[i];
185 if (param.IsDigit()) {
186 //fArraySize=param.Atoi();
187 HLTWarning("argument -arraysize is deprecated, array size adjusted dynamically");
189 HLTError("expecting number as parameter for option %s", argument.Data());
194 HLTError("unknown argument %s", argument.Data());
199 HLTError("missing parameter for argument %s", argument.Data());
203 if (!fFileName.empty()) {
204 fFile=new TFile(fFileName.c_str(), "RECREATE");
209 int AliHLTCompStatCollector::DoDeinit( )
211 // see header file for class documentation
222 int AliHLTCompStatCollector::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
224 // see header file for class documentation
227 AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
228 IsDataEvent(&eventType);
230 ResetFillingVariables();
232 fCycleTime=fpTimer->RealTime()*1000000;
235 // only if the map of instances is empty it can be initialized from the
236 // component table entries
237 // the logical check fo eventType==gkAliEventTypeStartOfRun does not work
238 // for simulated data where the blocks of the SOR are stored inside the
240 bool bMapInitialization=fInstances.empty();
241 vector<AliHLTCompStatCollector::AliHLTCompStatInstance> sortedInstances;
243 bool bEmbeddedTree=false;
244 bool bFolderCreated=false;
245 if ((bFolderCreated=(fpFolder==NULL))) {
246 fpFolder=new TFolder(HLTSTAT_FOLDER_NAME, HLTSTAT_FOLDER_DESC);
247 if (bEmbeddedTree) fpFolder->Add(fpStatTree);
249 if (!fpFolder) return -ENOMEM;
250 vector<TFolder*> newFolders;
252 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeComponentTable);
253 pBlock && iResult>=0;
254 pBlock=GetNextInputBlock()) {
255 string chainId, compId, compArgs;
256 vector<AliHLTUInt32_t> parents;
258 iResult=ExtractComponentTableEntry((const AliHLTUInt8_t*)pBlock->fPtr, pBlock->fSize,
259 chainId, compId, compArgs,
262 HLTDebug("%s(%s) 0x%08x", chainId.c_str(), compId.c_str(), pBlock->fSpecification);
263 if (bMapInitialization) {
264 map<AliHLTUInt32_t, AliHLTCompStatInstance>::const_iterator element=fInstances.find(pBlock->fSpecification);
265 AliHLTCompStatInstance newInstance(pBlock->fSpecification, chainId, compId, compArgs, parents, level);
266 if (element==fInstances.end()) {
268 fInstances[pBlock->fSpecification]=newInstance;
269 sortedInstances.push_back(newInstance);
271 // check existing instance
272 if (element->second!=newInstance) {
273 HLTWarning("component table entries have identical CRC ids but different content\n in list: %s\n skipping: %s",
274 element->second.Description().c_str(), newInstance.Description().c_str());
280 TFolder* pEntry=NULL;
281 if ((pObj=fpFolder->FindObjectAny(chainId.c_str()))!=NULL &&
282 (pEntry=dynamic_cast<TFolder*>(pObj))!=NULL ) {
285 HLTError("entry %s exists in folder, but is not a sub-folder", chainId.c_str());
286 } else if (chainId.size()>0) {
287 pEntry=new TFolder(chainId.c_str(), chainId.c_str());
290 TFolder* pProps=pEntry->AddFolder(HLTSTAT_ENTRY_PROPS_FOLDER_NAME, HLTSTAT_ENTRY_PROPS_FOLDER_DESC);
292 pProps->Add(new TObjString(compId.c_str()));
293 if (!compArgs.empty())
294 pProps->Add(new TObjString(compArgs.c_str()));
295 TNamed* pCRC=new TNamed(HLTSTAT_ENTRY_PROPS_IDOBJ_NAME, HLTSTAT_ENTRY_PROPS_IDOBJ_DESC);
297 pCRC->SetUniqueID(pBlock->fSpecification);
301 TFolder* pParents=pEntry->AddFolder(HLTSTAT_ENTRY_PARENT_FOLDER_NAME, HLTSTAT_ENTRY_PARENT_FOLDER_DESC);
303 for (vector<AliHLTUInt32_t>::iterator parent=parents.begin();
304 parent!=parents.end(); parent++) {
305 TString name; name.Form("0x%08x", *parent);
306 pParents->Add(new TObjString(name));
309 if (parents.size()==0) {
310 newFolders.push_back(pEntry);
312 vector<TFolder*>::iterator iter=newFolders.begin();
313 vector<AliHLTUInt32_t>::iterator parent=parents.begin();
314 while (iter!=newFolders.end() && parent!=parents.end()) {
315 TObject* idobj=(*iter)->FindObjectAny(HLTSTAT_ENTRY_PROPS_IDOBJ_NAME);
316 AliHLTUInt32_t crcid=0;
317 if (idobj) crcid=idobj->GetUniqueID();
318 HLTDebug("check: %s 0x%08x", (*iter)->GetName(), crcid);
319 if (idobj && crcid==*parent) break;
320 if ((++parent!=parents.end())) continue;
321 parent=parents.begin();
324 newFolders.insert(iter,pEntry);
328 HLTError("missing chain id for table entry 0x%08x (%p %d), skipping ...", pBlock->fSpecification, pBlock->fPtr, pBlock->fSize);
330 } else if (iResult!=0) {
331 HLTError("extraction of table entry 0x%08x (%p %d) failed with %d", pBlock->fSpecification, pBlock->fPtr, pBlock->fSize, iResult);
336 if (bMapInitialization) {
337 // assign tags to all instances in the map
341 TObjArray* taglist=NULL;
342 sort(sortedInstances.begin(), sortedInstances.end(), AliHLTCompStatInstance::SortByLevelAndComponentId);
343 for (vector< AliHLTCompStatInstance>::const_iterator element=sortedInstances.begin();
344 element!=sortedInstances.end();
346 if (level!=element->GetLevel() ||
347 componentId.CompareTo(element->GetComponentId().c_str())!=0) {
349 level=element->GetLevel();
350 componentId=element->GetComponentId().c_str();
353 taglist=new TObjArray;
354 taglist->SetName("CompStatMap");
355 fpFolder->Add(taglist);
359 entry.Form("%02d ", tag); entry+=componentId;
360 taglist->Add(new TObjString(entry));
364 fInstances[element->GetCRCId()].SetTag(tag);
367 if (fpStatTree==NULL && !fInstances.empty()) {
368 iResult=AllocateStatTree(fInstances.size());
372 if (newFolders.size()>0) {
373 vector<TFolder*> revert;
374 vector<TFolder*>::iterator iter=newFolders.begin();
375 while (iter!=newFolders.end()) {
376 revert.insert(revert.begin(), *iter);
377 HLTDebug("%s", (*iter)->GetName());
381 newFolders.assign(revert.begin(), revert.end());
383 vector<TFolder*>::iterator publisher=newFolders.begin();
384 while (publisher!=newFolders.end()) {
386 HLTDebug("checking %s for parents", (*publisher)->GetName());
387 TFolder* propsFolder=dynamic_cast<TFolder*>((*publisher)->FindObject(HLTSTAT_ENTRY_PROPS_FOLDER_NAME));
390 if (propsFolder) idobj=propsFolder->FindObject(HLTSTAT_ENTRY_PROPS_IDOBJ_NAME);
392 AliHLTUInt32_t crcid=idobj->GetUniqueID();
393 TString idstr; idstr.Form("0x%08x", crcid);
395 for (vector<TFolder*>::iterator consumer=publisher+1;
396 consumer!=newFolders.end(); consumer++) {
397 HLTDebug(" checking %s", (*consumer)->GetName());
398 TFolder* parentFolder=dynamic_cast<TFolder*>((*consumer)->FindObject(HLTSTAT_ENTRY_PARENT_FOLDER_NAME));
399 assert(parentFolder);
402 TIter entries(parentFolder->GetListOfFolders());
403 while (TObject* entry=entries.Next())
405 HLTDebug(" searching %s in %s: %s", idstr.Data(), (*consumer)->GetName(), entry->GetName());
408 TObject* parent=parentFolder->FindObjectAny(idstr);
410 parentFolder->Add(*publisher);
411 parentFolder->Remove(parent);
417 if (bRemove) publisher=newFolders.erase(publisher);
421 for (publisher=newFolders.begin();
422 publisher!=newFolders.end(); publisher++) {
423 RemoveRecurrence(*publisher);
424 fpFolder->Add(*publisher);
429 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeComponentStatistics);
430 pBlock && iResult>=0;
431 pBlock=GetNextInputBlock(), blockNo++) {
432 unsigned int current=fPosition;
433 iResult=FillVariablesSorted(pBlock->fPtr, pBlock->fSize, eventType);
434 for (; current<fPosition; current++) {
435 fpSpecArray[current]=pBlock->fSpecification;
436 fpBlockNoArray[current]=blockNo;
438 // indicate availability of component statistic block
442 int totalOutputSize=0;
443 if (iResult>0 && eventType) {
447 // init the timer for the next cycle
448 if (!fpTimer) fpTimer=new TStopwatch;
455 if (eventType==gkAliEventTypeEndOfRun ||
456 (iResult>=0 && CheckPeriod())) {
458 // publish objects to component output
459 if ((fMode&kPublishObjects)!=0) {
460 if (!bEmbeddedTree) {
461 iResult=PushBack(fpStatTree, kAliHLTDataTypeTTree|kAliHLTDataOriginOut);
462 totalOutputSize+=GetLastObjectSize();
464 iResult=PushBack(fpFolder, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
465 totalOutputSize+=GetLastObjectSize();
468 // save objects to file
469 if ((fMode&kSaveObjects)!=0 && fFile!=NULL) {
470 HLTDebug("saving objects to file %s", fFileName.c_str());
472 if (!bEmbeddedTree) {
473 fpStatTree->Write("", TObject::kOverwrite);
475 fpFolder->Write("", TObject::kOverwrite);
479 if (iResult==-ENOSPC) {
480 fSizeEstimator+=totalOutputSize;
483 if (iResult>0) iResult=0;
487 void AliHLTCompStatCollector::ResetFillingVariables()
489 // see header file for class documentation
491 for (map<AliHLTUInt32_t, AliHLTCompStatInstance>::iterator element=fInstances.begin();
492 element!=fInstances.end();
494 element->second.ResetProcessed();
500 if (fArraySize==0) return;
501 memset(fpLevelArray, 0, sizeof(UInt_t)*fArraySize);
502 memset(fpSpecArray, 0, sizeof(UInt_t)*fArraySize);
503 memset(fpBlockNoArray, 0, sizeof(UInt_t)*fArraySize);
504 memset(fpIdArray, 0, sizeof(UInt_t)*fArraySize);
505 memset(fpTimeArray, 0, sizeof(UInt_t)*fArraySize);
506 memset(fpCTimeArray, 0, sizeof(UInt_t)*fArraySize);
507 memset(fpInputBlockCountArray, 0, sizeof(UInt_t)*fArraySize);
508 memset(fpTotalInputSizeArray, 0, sizeof(UInt_t)*fArraySize);
509 memset(fpNormalizedInputSizeArray, 0, sizeof(UInt_t)*fArraySize);
510 memset(fpOutputBlockCountArray, 0, sizeof(UInt_t)*fArraySize);
511 memset(fpTotalOutputSizeArray, 0, sizeof(UInt_t)*fArraySize);
512 memset(fpInputOutputRatioArray, 0, sizeof(UInt_t)*fArraySize);
513 memset(fpNormalizedInputOutputRatioArray, 0, sizeof(UInt_t)*fArraySize);
514 memset(fpComponentCycleTimeArray, 0, sizeof(UInt_t)*fArraySize);
515 memset(fpEventTypeArray, 0, sizeof(UInt_t)*fArraySize);
516 memset(fpEventCountArray, 0, sizeof(UInt_t)*fArraySize);
519 int AliHLTCompStatCollector::FillVariablesSorted(void* ptr, int size, AliHLTUInt32_t eventType)
521 // see header file for class documentation
523 if (size%sizeof(AliHLTComponentStatistics)) {
524 // older or invalid structure
525 HLTError("data block is not aligned to the size of the AliHLTComponentStatistics struct");
529 AliHLTComponentStatistics* pStat=reinterpret_cast<AliHLTComponentStatistics*>(ptr);
530 UInt_t nofStats=size/sizeof(AliHLTComponentStatistics);
531 vector<int> indexList;
533 for (i=0; i<nofStats; i++) {
534 vector<int>::iterator element=indexList.begin();
535 for (; element!=indexList.end(); element++) {
536 if (pStat[i].fLevel>pStat[*element].fLevel) {
540 indexList.insert(element, i);
544 for (vector<int>::iterator element=indexList.begin();
545 element!=indexList.end();
547 map<AliHLTUInt32_t, AliHLTCompStatInstance>::iterator instance=fInstances.find(pStat[*element].fId);
548 if (i<fArraySize && instance!=fInstances.end()) {
549 if (instance->second.IsProcessed()) {
550 //HLTWarning("already processed instance %s, skip", instance->second.Description().c_str());
553 instance->second.MarkProcessed();
554 if ((int)pStat[*element].fLevel!=instance->second.GetLevel()) {
555 // TODO: there is currently a mismatch of the level set in the statistics entry and
556 // the one in the component table entries. However this does not matter for
557 // archiving because the CRC id is related to a tag/level
558 //HLTWarning("level does not match for instance %s, expected %d", instance->second.Description().c_str(), pStat[*element].fLevel);
560 fpLevelArray[i]=instance->second.GetTag();
561 fpIdArray[i]=pStat[*element].fId;
562 fpTimeArray[i]=pStat[*element].fTime;
563 fpCTimeArray[i]=pStat[*element].fCTime;
564 fpInputBlockCountArray[i]=pStat[*element].fInputBlockCount;
565 fpTotalInputSizeArray[i]=pStat[*element].fTotalInputSize;
566 fpNormalizedInputSizeArray[i]=pStat[*element].fTotalInputSize;
567 if (pStat[*element].fInputBlockCount>0)
568 fpNormalizedInputSizeArray[i]/=pStat[*element].fInputBlockCount;
569 fpOutputBlockCountArray[i]=pStat[*element].fOutputBlockCount;
570 fpTotalOutputSizeArray[i]=pStat[*element].fTotalOutputSize;
571 if (pStat[*element].fTotalOutputSize>0)
572 fpInputOutputRatioArray[i]=pStat[*element].fTotalInputSize/pStat[*element].fTotalOutputSize;
573 if (pStat[*element].fInputBlockCount>0)
574 fpNormalizedInputOutputRatioArray[i]=fpInputOutputRatioArray[i]*pStat[*element].fOutputBlockCount/pStat[*element].fInputBlockCount;
575 fpComponentCycleTimeArray[i]=pStat[*element].fComponentCycleTime;
576 fpEventTypeArray[i]=eventType;
577 fpEventCountArray[i]=GetEventCount();
579 } else if (instance==fInstances.end()) {
580 HLTWarning("can not find instance of CRC id 0x%08x", pStat[*element].fId);
585 HLTWarning("too little space in branch variables to fill %d statistics blocks, total available %d, current position %d", i, fArraySize, fPosition);
586 fPosition=fArraySize;
594 int AliHLTCompStatCollector::AllocateStatTree(AliHLTUInt32_t size)
596 // allocate the statistics tree and the branch arrays
601 if (fArraySize==0) return 0;
603 fpLevelArray=new UInt_t[fArraySize];
604 fpSpecArray=new UInt_t[fArraySize];
605 fpBlockNoArray=new UInt_t[fArraySize];
606 fpIdArray=new UInt_t[fArraySize];
607 fpTimeArray=new UInt_t[fArraySize];
608 fpCTimeArray=new UInt_t[fArraySize];
609 fpInputBlockCountArray=new UInt_t[fArraySize];
610 fpTotalInputSizeArray=new UInt_t[fArraySize];
611 fpNormalizedInputSizeArray=new UInt_t[fArraySize];
612 fpOutputBlockCountArray=new UInt_t[fArraySize];
613 fpTotalOutputSizeArray=new UInt_t[fArraySize];
614 fpInputOutputRatioArray=new UInt_t[fArraySize];
615 fpNormalizedInputOutputRatioArray=new UInt_t[fArraySize];
616 fpComponentCycleTimeArray=new UInt_t[fArraySize];
617 fpEventTypeArray=new UInt_t[fArraySize];
618 fpEventCountArray=new UInt_t[fArraySize];
620 fpStatTree=new TTree("CompStat", "HLT component statistics");
622 fpStatTree->SetDirectory(0);
623 fpStatTree->Branch("cycleTime", &fCycleTime, "cycleTime/F");
624 fpStatTree->Branch("nofSets", &fNofSets, "nofSets/I");
625 fpStatTree->Branch("Level", fpLevelArray, "Level[nofSets]/i");
626 fpStatTree->Branch("Specification", fpSpecArray, "Specification[nofSets]/i");
627 fpStatTree->Branch("BlockNo", fpBlockNoArray, "BlockNo[nofSets]/i");
628 fpStatTree->Branch("Id", fpIdArray, "Id[nofSets]/i");
629 fpStatTree->Branch("Time", fpTimeArray, "Time[nofSets]/i");
630 fpStatTree->Branch("CTime", fpCTimeArray, "CTime[nofSets]/i");
631 fpStatTree->Branch("InputBlockCount", fpInputBlockCountArray, "InputBlockCount[nofSets]/i");
632 fpStatTree->Branch("TotalInputSize", fpTotalInputSizeArray, "TotalInputSize[nofSets]/i");
633 fpStatTree->Branch("NormalizedInputSize", fpNormalizedInputSizeArray, "NormalizedInputSize[nofSets]/i");
634 fpStatTree->Branch("OutputBlockCount", fpOutputBlockCountArray, "OutputBlockCount[nofSets]/i");
635 fpStatTree->Branch("TotalOutputSize", fpTotalOutputSizeArray, "TotalOutputSize[nofSets]/i");
636 fpStatTree->Branch("InputOutputRatio", fpInputOutputRatioArray, "InputOutputRatio[nofSets]/i");
637 fpStatTree->Branch("NormalizedInputOutputRatio", fpNormalizedInputOutputRatioArray, "NormalizedInputOutputRatio[nofSets]/i");
638 fpStatTree->Branch("ComponentCycleTime",fpComponentCycleTimeArray, "ComponentCycleTime[nofSets]/i");
639 fpStatTree->Branch("EventType",fpEventTypeArray, "EventType[nofSets]/i");
640 fpStatTree->Branch("EventCount",fpEventCountArray, "EventCount[nofSets]/i");
646 void AliHLTCompStatCollector::ClearAll()
648 // see header file for class documentation
649 if (fpTimer) delete fpTimer; fpTimer=NULL;
650 if (fpFolder) delete fpFolder; fpFolder=NULL;
654 void AliHLTCompStatCollector::ClearStatTree()
656 // clear the statistics tree and the branch arrays
657 if (fpStatTree) delete fpStatTree; fpStatTree=NULL;
658 if (fpLevelArray) delete fpLevelArray; fpLevelArray=NULL;
659 if (fpSpecArray) delete fpSpecArray; fpSpecArray=NULL;
660 if (fpBlockNoArray) delete fpBlockNoArray; fpBlockNoArray=NULL;
661 if (fpIdArray) delete fpIdArray; fpIdArray=NULL;
662 if (fpTimeArray) delete fpTimeArray; fpTimeArray=NULL;
663 if (fpCTimeArray) delete fpCTimeArray; fpCTimeArray=NULL;
664 if (fpInputBlockCountArray) delete fpInputBlockCountArray; fpInputBlockCountArray=NULL;
665 if (fpTotalInputSizeArray) delete fpTotalInputSizeArray; fpTotalInputSizeArray=NULL;
666 if (fpNormalizedInputSizeArray) delete fpNormalizedInputSizeArray; fpNormalizedInputSizeArray=NULL;
667 if (fpOutputBlockCountArray) delete fpOutputBlockCountArray; fpOutputBlockCountArray=NULL;
668 if (fpTotalOutputSizeArray) delete fpTotalOutputSizeArray; fpTotalOutputSizeArray=NULL;
669 if (fpInputOutputRatioArray) delete fpInputOutputRatioArray; fpInputOutputRatioArray=NULL;
670 if (fpNormalizedInputOutputRatioArray) delete fpNormalizedInputOutputRatioArray; fpNormalizedInputOutputRatioArray=NULL;
671 if (fpComponentCycleTimeArray) delete fpComponentCycleTimeArray; fpComponentCycleTimeArray=NULL;
672 if (fpEventTypeArray) delete fpEventTypeArray; fpEventTypeArray=NULL;
673 if (fpEventCountArray) delete fpEventCountArray; fpEventCountArray=NULL;
677 int AliHLTCompStatCollector::RemoveRecurrence(TFolder* pRoot) const
679 // see header file for class documentation
681 if (!pRoot) return -EINVAL;
682 TFolder* parentFolder=dynamic_cast<TFolder*>(pRoot->FindObject(HLTSTAT_ENTRY_PARENT_FOLDER_NAME));
683 assert(parentFolder);
684 vector<TFolder*> listRemove;
686 TIter entries(parentFolder->GetListOfFolders());
689 while ((obj=entries.Next())!=NULL && (entry=dynamic_cast<TFolder*>(obj))!=NULL) {
690 TString name=entry->GetName();
691 HLTDebug("checking %s for recurrence", name.Data());
692 TIter tokens(parentFolder->GetListOfFolders());
694 while ((obj=tokens.Next())!=NULL && (token=dynamic_cast<TFolder*>(obj))!=NULL) {
695 if (name.CompareTo(token->GetName())==0) continue;
696 if ((obj=token->FindObjectAny(name))!=NULL) {
697 listRemove.push_back(entry);
698 HLTDebug("found recurrence in %s", token->GetName());
701 HLTDebug("no recurrence found in %s", token->GetName());
704 RemoveRecurrence(entry);
706 for (vector<TFolder*>::iterator removeElement=listRemove.begin();
707 removeElement!=listRemove.end(); removeElement++) {
708 parentFolder->Remove(*removeElement);
715 bool AliHLTCompStatCollector::CheckPeriod(bool bUpdate)
717 // see header file for class documentation
719 if (fEventModulo>0) {
720 if ((result=((GetEventCount()+1)%fEventModulo)==0)) {
725 if ((result=((difftime(time(NULL), fLastTime)>(double)fPeriod))) &&
727 fLastTime=time(NULL);
733 void AliHLTCompStatCollector::Print(const char* option) const
736 if (strcmp(option, "instances")==0) {
737 vector<AliHLTCompStatInstance> sortedInstances;
738 for (map<AliHLTUInt32_t, AliHLTCompStatInstance>::const_iterator element=fInstances.begin();
739 element!=fInstances.end();
741 sortedInstances.push_back(element->second);
743 sort(sortedInstances.begin(), sortedInstances.end(), AliHLTCompStatInstance::SortByLevelAndComponentId);
744 for (vector<AliHLTCompStatInstance>::const_iterator element=sortedInstances.begin();
745 element!=sortedInstances.end();
752 AliHLTCompStatCollector::AliHLTCompStatInstance::AliHLTCompStatInstance()
762 /// default constructor
765 AliHLTCompStatCollector::AliHLTCompStatInstance::AliHLTCompStatInstance(AliHLTUInt32_t CRCId,
767 const char* componentId,
768 const char* componentParam,
769 const vector<AliHLTUInt32_t>& parents,
774 , fComponentId(componentId)
775 , fComponentParam(componentParam)
783 AliHLTCompStatCollector::AliHLTCompStatInstance::AliHLTCompStatInstance(AliHLTUInt32_t CRCId,
784 const string& chainId,
785 const string& componentId,
786 const string& componentParam,
787 const vector<AliHLTUInt32_t>& parents,
792 , fComponentId(componentId)
793 , fComponentParam(componentParam)
801 AliHLTCompStatCollector::AliHLTCompStatInstance::AliHLTCompStatInstance(const AliHLTCompStatCollector::AliHLTCompStatInstance& src)
803 , fChainId(src.fChainId)
804 , fComponentId(src.fComponentId)
805 , fComponentParam(src.fComponentParam)
806 , fParents(src.fParents)
809 , fProcessed(src.fProcessed)
814 AliHLTCompStatCollector::AliHLTCompStatInstance& AliHLTCompStatCollector::AliHLTCompStatInstance::operator=(const AliHLTCompStatCollector::AliHLTCompStatInstance& src)
816 /// assignment operator
817 if (&src==this) return *this;
820 fChainId=src.fChainId;
821 fComponentId=src.fComponentId;
822 fComponentParam=src.fComponentParam;
823 fParents.assign(src.fParents.begin(), src.fParents.end());
830 AliHLTCompStatCollector::AliHLTCompStatInstance::~AliHLTCompStatInstance()
835 string AliHLTCompStatCollector::AliHLTCompStatInstance::Description(const char* /*option*/) const
837 // get a description string
839 description.Form("0x%08x level %d tag %d: %s (%s) %s",
840 fCRCId, fLevel, fTag, fChainId.c_str(), fComponentId.c_str(), fComponentParam.c_str());
841 string ret=description.Data();
845 void AliHLTCompStatCollector::AliHLTCompStatInstance::Print(const char* /*option*/) const
847 // print info to cout
848 cout << Description() << endl;
851 bool AliHLTCompStatCollector::AliHLTCompStatInstance::operator==(const AliHLTCompStatInstance &b) const
853 // check if two instances are equal
854 if (fChainId !=b.fChainId) return false;
855 if (fComponentId !=b.fComponentId) return false;
856 if (fComponentParam!=b.fComponentParam) return false;
857 if (fCRCId !=b.fCRCId) return false;
858 if (fLevel !=b.fLevel) return false;
859 if (fTag>=0 && fTag!=b.fTag && b.fTag>=0) return false;
864 bool AliHLTCompStatCollector::AliHLTCompStatInstance::SortByLevelAndComponentId(const AliHLTCompStatInstance &a,
865 const AliHLTCompStatInstance &b)
867 // helper function for std::sort
868 if ( a.fLevel != b.fLevel ) return ( a.fLevel < b.fLevel );
869 if ( a.fComponentId != b.fComponentId ) return ( a.fComponentId < b.fComponentId );
870 if ( a.fChainId != b.fChainId ) return ( a.fChainId < b.fChainId );