]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/util/AliHLTCompStatCollector.cxx
minor bugfix regarding optional propagation of component statistics:
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTCompStatCollector.cxx
CommitLineData
b765ad15 1// $Id$
2
3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* for The ALICE HLT Project. *
9//* *
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//**************************************************************************
18
19/** @file AliHLTCompStatCollector.cxx
20 @author Matthias Richter
21 @date
22 @brief Collector component for the component statistics information.
23*/
24
25#include "AliHLTCompStatCollector.h"
c7b299f1 26#include "TFile.h"
b765ad15 27#include "TStopwatch.h"
28#include "TH1F.h"
29#include "TH2F.h"
30#include "TH2C.h"
31#include "TTree.h"
abb52c8f 32#include "TFolder.h"
33#include "TNamed.h"
b765ad15 34#include "TString.h"
abb52c8f 35#include <cassert>
36
37#define HLTSTAT_FOLDER_NAME "HLTstat"
38#define HLTSTAT_FOLDER_DESC "ALICE HLT component statistics"
39#define HLTSTAT_ENTRY_PARENT_FOLDER_NAME "parents"
40#define HLTSTAT_ENTRY_PARENT_FOLDER_DESC "parent components"
41#define HLTSTAT_ENTRY_PROPS_FOLDER_NAME "props"
42#define HLTSTAT_ENTRY_PROPS_FOLDER_DESC "component properties"
43#define HLTSTAT_ENTRY_PROPS_IDOBJ_NAME "id"
44#define HLTSTAT_ENTRY_PROPS_IDOBJ_DESC "numerical id calculated from chain id"
b765ad15 45
46/** ROOT macro for the implementation of ROOT specific class methods */
47ClassImp(AliHLTCompStatCollector)
48
49AliHLTCompStatCollector::AliHLTCompStatCollector()
50 :
51 AliHLTProcessor(),
52 fpTimer(NULL),
abb52c8f 53 fpFolder(NULL),
b765ad15 54 fpStatTree(NULL),
55 fCycleTime(0),
56 fNofSets(0),
57 fArraySize(1000),
58 fPosition(0),
59 fpLevelArray(NULL),
60 fpSpecArray(NULL),
61 fpBlockNoArray(NULL),
62 fpIdArray(NULL),
63 fpTimeArray(NULL),
64 fpCTimeArray(NULL),
65 fpInputBlockCountArray(NULL),
66 fpTotalInputSizeArray(NULL),
67 fpOutputBlockCountArray(NULL),
68 fpTotalOutputSizeArray(NULL)
2e3fd14f 69 , fpComponentCycleTimeArray(NULL)
70 , fpEventTypeArray(NULL)
71 , fpEventCountArray(NULL)
63410eb4 72 , fSizeEstimator(1000)
c7b299f1 73 , fMode(kPublishObjects)
74 , fFileName()
75 , fFile(NULL)
76 , fLastTime(time(NULL))
77 , fPeriod(0)
78 , fEventModulo(0)
b765ad15 79{
80 // see header file for class documentation
81 // or
82 // refer to README to build package
83 // or
84 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
85}
86
87AliHLTCompStatCollector::~AliHLTCompStatCollector()
88{
89 // see header file for class documentation
90 ClearAll();
91}
92
93void AliHLTCompStatCollector::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
94{
95 // see header file for class documentation
96 list.push_back(kAliHLTDataTypeComponentStatistics);
97}
98
99AliHLTComponentDataType AliHLTCompStatCollector::GetOutputDataType()
100{
101 // see header file for class documentation
102 return kAliHLTMultipleDataType;
103}
104
105int AliHLTCompStatCollector::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
106{
107 // see header file for class documentation
108 tgtList.clear();
109 tgtList.push_back(kAliHLTDataTypeHistogram);
110 tgtList.push_back(kAliHLTDataTypeTTree);
111 return tgtList.size();
112}
113
114void AliHLTCompStatCollector::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
115{
116 // see header file for class documentation
63410eb4 117 constBase=fSizeEstimator;
b765ad15 118 inputMultiplier=100.0;
119}
120
121int AliHLTCompStatCollector::DoInit( int argc, const char** argv )
122{
123 // see header file for class documentation
124 int iResult=0;
125 TString argument="";
126 int bMissingParam=0;
127 for (int i=0; i<argc && iResult>=0; i++) {
128 argument=argv[i];
129 if (argument.IsNull()) continue;
130
c7b299f1 131 // -file
132 if (argument.CompareTo("-file")==0) {
b765ad15 133 if ((bMissingParam=(++i>=argc))) break;
c7b299f1 134 fFileName=argv[i];
135 fMode|=kSaveObjects;
136
137 // -modulo
138 } else if (argument.CompareTo("-modulo")==0) {
139 if ((bMissingParam=(++i>=argc))) break;
140 TString param=argv[i];
b765ad15 141 if (param.IsDigit()) {
c7b299f1 142 fEventModulo=param.Atoi();
b765ad15 143 } else {
c7b299f1 144 HLTError("expecting number as parameter for option %s", argument.Data());
b765ad15 145 iResult=-EINVAL;
146 }
147
c7b299f1 148 // -period
149 } else if (argument.CompareTo("-period")==0) {
150 if ((bMissingParam=(++i>=argc))) break;
151 TString param=argv[i];
152 if (param.IsDigit()) {
153 fPeriod=param.Atoi();
154 } else {
155 HLTError("expecting number as parameter for option %s", argument.Data());
156 iResult=-EINVAL;
157 }
158
159 // -publish
160 } else if (argument.CompareTo("-publish")==0) {
161 if ((bMissingParam=(++i>=argc))) break;
162 TString param=argv[i];
163 if (param.IsDigit()) {
164 if (param.Atoi()==1) fMode|=kPublishObjects;
165 else if (param.Atoi()==0) fMode&=~kPublishObjects;
166 else {
167 HLTError("expecting 0 or 1 as parameter for option %s", argument.Data());
168 iResult=-EINVAL;
169 }
170 } else {
171 HLTError("expecting number as parameter for option %s", argument.Data());
172 iResult=-EINVAL;
173 }
b765ad15 174 } else {
c7b299f1 175 HLTError("unknown argument %s", argument.Data());
b765ad15 176 iResult=-EINVAL;
177 }
178 }
179 if (bMissingParam) {
180 HLTError("missing parameter for argument %s", argument.Data());
181 iResult=-EINVAL;
182 }
183
184 if (iResult>=0) {
185 fpLevelArray=new UInt_t[fArraySize];
186 fpSpecArray=new UInt_t[fArraySize];
187 fpBlockNoArray=new UInt_t[fArraySize];
188 fpIdArray=new UInt_t[fArraySize];
189 fpTimeArray=new UInt_t[fArraySize];
190 fpCTimeArray=new UInt_t[fArraySize];
191 fpInputBlockCountArray=new UInt_t[fArraySize];
192 fpTotalInputSizeArray=new UInt_t[fArraySize];
193 fpOutputBlockCountArray=new UInt_t[fArraySize];
194 fpTotalOutputSizeArray=new UInt_t[fArraySize];
2e3fd14f 195 fpComponentCycleTimeArray=new UInt_t[fArraySize];
196 fpEventTypeArray=new UInt_t[fArraySize];
197 fpEventCountArray=new UInt_t[fArraySize];
b765ad15 198
199 fpStatTree=new TTree("CompStat", "HLT component statistics");
200 if (fpStatTree) {
201 fpStatTree->SetDirectory(0);
202 fpStatTree->Branch("cycleTime", &fCycleTime, "cycleTime/F");
203 fpStatTree->Branch("nofSets", &fNofSets, "nofSets/I");
204 fpStatTree->Branch("Level", fpLevelArray, "Level[nofSets]/i");
205 fpStatTree->Branch("Specification", fpSpecArray, "Specification[nofSets]/i");
206 fpStatTree->Branch("BlockNo", fpBlockNoArray, "BlockNo[nofSets]/i");
207 fpStatTree->Branch("Id", fpIdArray, "Id[nofSets]/i");
208 fpStatTree->Branch("Time", fpTimeArray, "Time[nofSets]/i");
209 fpStatTree->Branch("CTime", fpCTimeArray, "CTime[nofSets]/i");
210 fpStatTree->Branch("InputBlockCount", fpInputBlockCountArray, "InputBlockCount[nofSets]/i");
211 fpStatTree->Branch("TotalInputSize", fpTotalInputSizeArray, "TotalInputSize[nofSets]/i");
212 fpStatTree->Branch("OutputBlockCount", fpOutputBlockCountArray, "OutputBlockCount[nofSets]/i");
213 fpStatTree->Branch("TotalOutputSize", fpTotalOutputSizeArray, "TotalOutputSize[nofSets]/i");
2e3fd14f 214 fpStatTree->Branch("ComponentCycleTime",fpComponentCycleTimeArray, "ComponentCycleTime[nofSets]/i");
215 fpStatTree->Branch("EventType",fpEventTypeArray, "EventType[nofSets]/i");
216 fpStatTree->Branch("EventCount",fpEventCountArray, "EventCount[nofSets]/i");
b765ad15 217 }
218 }
c7b299f1 219
220 if (!fFileName.empty()) {
221 fFile=new TFile(fFileName.c_str(), "RECREATE");
222 }
b765ad15 223 return iResult;
224}
225
226int AliHLTCompStatCollector::DoDeinit( )
227{
228 // see header file for class documentation
229 ClearAll();
230
c7b299f1 231 if (fFile) {
232 fFile->Close();
233 delete fFile;
234 fFile=NULL;
235 }
b765ad15 236 return 0;
237}
238
239int AliHLTCompStatCollector::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
240{
241 // see header file for class documentation
242 int iResult=0;
243
abb52c8f 244 AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
245 IsDataEvent(&eventType);
246
b765ad15 247 ResetFillingVariables();
248 if (fpTimer) {
249 fCycleTime=fpTimer->RealTime()*1000000;
250 }
251
abb52c8f 252 bool bEmbeddedTree=false;
253 bool bFolderCreated=false;
9d5f00ad 254 if ((bFolderCreated=(fpFolder==NULL))) {
abb52c8f 255 fpFolder=new TFolder(HLTSTAT_FOLDER_NAME, HLTSTAT_FOLDER_DESC);
256 if (bEmbeddedTree) fpFolder->Add(fpStatTree);
257 }
258 if (!fpFolder) return -ENOMEM;
259 vector<TFolder*> newFolders;
260
261 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeComponentTable);
262 pBlock && iResult>=0;
263 pBlock=GetNextInputBlock()) {
264 string chainId, compId, compArgs;
265 vector<AliHLTUInt32_t> parents;
266 iResult=ExtractComponentTableEntry((const AliHLTUInt8_t*)pBlock->fPtr, pBlock->fSize,
267 chainId, compId, compArgs,
268 parents);
269 if (iResult>0) {
270 HLTDebug("%s(%s) 0x%08x", chainId.c_str(), compId.c_str(), pBlock->fSpecification);
271 TObject* pObj=NULL;
272 TFolder* pEntry=NULL;
273 if ((pObj=fpFolder->FindObjectAny(chainId.c_str()))!=NULL &&
274 (pEntry=dynamic_cast<TFolder*>(pObj))!=NULL ) {
275
276 } else if (pObj) {
277 HLTError("entry %s exists in folder, but is not a sub-folder", chainId.c_str());
278 } else if (chainId.size()>0) {
279 pEntry=new TFolder(chainId.c_str(), chainId.c_str());
280 if (pEntry) {
281 pEntry->SetOwner();
282 TFolder* pProps=pEntry->AddFolder(HLTSTAT_ENTRY_PROPS_FOLDER_NAME, HLTSTAT_ENTRY_PROPS_FOLDER_DESC);
283 if (pProps) {
284 pProps->Add(new TObjString(compId.c_str()));
285 if (!compArgs.empty())
286 pProps->Add(new TObjString(compArgs.c_str()));
287 TNamed* pCRC=new TNamed(HLTSTAT_ENTRY_PROPS_IDOBJ_NAME, HLTSTAT_ENTRY_PROPS_IDOBJ_DESC);
288 if (pCRC) {
289 pCRC->SetUniqueID(pBlock->fSpecification);
290 pProps->Add(pCRC);
291 }
292 }
293 TFolder* pParents=pEntry->AddFolder(HLTSTAT_ENTRY_PARENT_FOLDER_NAME, HLTSTAT_ENTRY_PARENT_FOLDER_DESC);
294 if (pParents) {
295 for (vector<AliHLTUInt32_t>::iterator parent=parents.begin();
296 parent!=parents.end(); parent++) {
297 TString name; name.Form("0x%08x", *parent);
298 pParents->Add(new TObjString(name));
299 }
300 }
301 if (parents.size()==0) {
302 newFolders.push_back(pEntry);
303 } else {
304 vector<TFolder*>::iterator iter=newFolders.begin();
305 vector<AliHLTUInt32_t>::iterator parent=parents.begin();
306 while (iter!=newFolders.end() && parent!=parents.end()) {
307 TObject* idobj=(*iter)->FindObjectAny(HLTSTAT_ENTRY_PROPS_IDOBJ_NAME);
308 AliHLTUInt32_t crcid=0;
309 if (idobj) crcid=idobj->GetUniqueID();
310 HLTDebug("check: %s 0x%08x", (*iter)->GetName(), crcid);
311 if (idobj && crcid==*parent) break;
312 if ((++parent!=parents.end())) continue;
313 parent=parents.begin();
314 iter++;
315 }
316 newFolders.insert(iter,pEntry);
317 }
318 }
319 } else {
320 HLTError("missing chain id for table entry 0x%08x (%p %d), skipping ...", pBlock->fSpecification, pBlock->fPtr, pBlock->fSize);
321 }
322 } else if (iResult!=0) {
323 HLTError("extraction of table entry 0x%08x (%p %d) failed with %d", pBlock->fSpecification, pBlock->fPtr, pBlock->fSize, iResult);
324 }
325 iResult=0;
326 }
327
328 if (newFolders.size()>0) {
329 vector<TFolder*> revert;
330 vector<TFolder*>::iterator iter=newFolders.begin();
331 while (iter!=newFolders.end()) {
332 revert.insert(revert.begin(), *iter);
333 HLTDebug("%s", (*iter)->GetName());
334 iter++;
335 }
336 newFolders.empty();
337 newFolders.assign(revert.begin(), revert.end());
338
339 vector<TFolder*>::iterator publisher=newFolders.begin();
340 while (publisher!=newFolders.end()) {
341 bool bRemove=false;
342 HLTDebug("checking %s for parents", (*publisher)->GetName());
343 TFolder* propsFolder=dynamic_cast<TFolder*>((*publisher)->FindObject(HLTSTAT_ENTRY_PROPS_FOLDER_NAME));
344 assert(propsFolder);
345 TObject* idobj=NULL;
346 if (propsFolder) idobj=propsFolder->FindObject(HLTSTAT_ENTRY_PROPS_IDOBJ_NAME);
347 assert(idobj);
348 AliHLTUInt32_t crcid=idobj->GetUniqueID();
349 TString idstr; idstr.Form("0x%08x", crcid);
350 if (idobj) {
351 for (vector<TFolder*>::iterator consumer=publisher+1;
352 consumer!=newFolders.end(); consumer++) {
353 HLTDebug(" checking %s", (*consumer)->GetName());
354 TFolder* parentFolder=dynamic_cast<TFolder*>((*consumer)->FindObject(HLTSTAT_ENTRY_PARENT_FOLDER_NAME));
355 assert(parentFolder);
356 if (parentFolder) {
357 TIter entries(parentFolder->GetListOfFolders());
358 while (TObject* entry=entries.Next())
460c4045 359 if (entry) {
360 Bool_t foo; foo=kTRUE;// only to avoid warning in non-debug compile
361 HLTDebug(" searching %s in %s: %s", idstr.Data(), (*consumer)->GetName(), entry->GetName());
362 }
abb52c8f 363 TObject* parent=parentFolder->FindObjectAny(idstr);
364 if (parent) {
365 parentFolder->Add(*publisher);
366 parentFolder->Remove(parent);
367 bRemove=true;
368 }
369 }
370 }
371 }
372 if (bRemove) publisher=newFolders.erase(publisher);
373 else publisher++;
374 }
375
376 for (publisher=newFolders.begin();
377 publisher!=newFolders.end(); publisher++) {
378 RemoveRecurrence(*publisher);
379 fpFolder->Add(*publisher);
380 }
381 }
382
b765ad15 383 int blockNo=0;
384 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeComponentStatistics);
385 pBlock && iResult>=0;
386 pBlock=GetNextInputBlock(), blockNo++) {
387 unsigned int current=fPosition;
2e3fd14f 388 iResult=FillVariablesSorted(pBlock->fPtr, pBlock->fSize, eventType);
b765ad15 389 for (; current<fPosition; current++) {
390 fpSpecArray[current]=pBlock->fSpecification;
391 fpBlockNoArray[current]=blockNo;
392 }
587c9cf9 393 // indicate availability of component statistic block
394 iResult=1;
b765ad15 395 }
396
4e5a2a53 397 int totalOutputSize=0;
2e3fd14f 398 if (iResult>0 && eventType) {
b765ad15 399 fNofSets=fPosition;
400 fpStatTree->Fill();
b765ad15 401
587c9cf9 402 // init the timer for the next cycle
403 if (!fpTimer) fpTimer=new TStopwatch;
404 if (fpTimer) {
405 fpTimer->Reset();
406 fpTimer->Start();
407 }
b765ad15 408 }
409
c7b299f1 410 if (eventType==gkAliEventTypeEndOfRun ||
411 (iResult>=0 && CheckPeriod())) {
412
413 // publish objects to component output
414 if ((fMode&kPublishObjects)!=0) {
415 if (!bEmbeddedTree) {
416 iResult=PushBack(fpStatTree, kAliHLTDataTypeTTree|kAliHLTDataOriginOut);
417 totalOutputSize+=GetLastObjectSize();
418 }
419 iResult=PushBack(fpFolder, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
420 totalOutputSize+=GetLastObjectSize();
421 }
422
423 // save objects to file
424 if ((fMode&kSaveObjects)!=0 && fFile!=NULL) {
425 HLTDebug("saving objects to file %s", fFileName.c_str());
426 fFile->cd();
427 if (!bEmbeddedTree) {
428 fpStatTree->Write("", TObject::kOverwrite);
429 }
430 fpFolder->Write("", TObject::kOverwrite);
431 }
4e5a2a53 432 }
c7b299f1 433
4e5a2a53 434 if (iResult==-ENOSPC) {
435 fSizeEstimator+=totalOutputSize;
abb52c8f 436 }
437
438 if (iResult>0) iResult=0;
b765ad15 439 return iResult;
440}
441
442void AliHLTCompStatCollector::ResetFillingVariables()
443{
444 // see header file for class documentation
445 fCycleTime=0;
446 fNofSets=0;
447 fPosition=0;
448 memset(fpLevelArray, 0, sizeof(UInt_t)*fArraySize);
449 memset(fpSpecArray, 0, sizeof(UInt_t)*fArraySize);
450 memset(fpBlockNoArray, 0, sizeof(UInt_t)*fArraySize);
451 memset(fpIdArray, 0, sizeof(UInt_t)*fArraySize);
452 memset(fpTimeArray, 0, sizeof(UInt_t)*fArraySize);
453 memset(fpCTimeArray, 0, sizeof(UInt_t)*fArraySize);
454 memset(fpInputBlockCountArray, 0, sizeof(UInt_t)*fArraySize);
455 memset(fpTotalInputSizeArray, 0, sizeof(UInt_t)*fArraySize);
456 memset(fpOutputBlockCountArray, 0, sizeof(UInt_t)*fArraySize);
457 memset(fpTotalOutputSizeArray, 0, sizeof(UInt_t)*fArraySize);
2e3fd14f 458 memset(fpComponentCycleTimeArray, 0, sizeof(UInt_t)*fArraySize);
459 memset(fpEventTypeArray, 0, sizeof(UInt_t)*fArraySize);
460 memset(fpEventCountArray, 0, sizeof(UInt_t)*fArraySize);
b765ad15 461}
462
2e3fd14f 463int AliHLTCompStatCollector::FillVariablesSorted(void* ptr, int size, AliHLTUInt32_t eventType)
b765ad15 464{
465 // see header file for class documentation
466 int iResult=0;
467 if (size%sizeof(AliHLTComponentStatistics)) {
2e3fd14f 468 // older or invalid structure
b765ad15 469 HLTError("data block is not aligned to the size of the AliHLTComponentStatistics struct");
470 return -EINVAL;
471 }
2e3fd14f 472
b765ad15 473 AliHLTComponentStatistics* pStat=reinterpret_cast<AliHLTComponentStatistics*>(ptr);
474 UInt_t nofStats=size/sizeof(AliHLTComponentStatistics);
475 vector<int> indexList;
476 UInt_t i=0;
477 for (i=0; i<nofStats; i++) {
478 vector<int>::iterator element=indexList.begin();
479 for (; element!=indexList.end(); element++) {
480 if (pStat[i].fLevel>pStat[*element].fLevel) {
481 break;
482 }
483 }
484 indexList.insert(element, i);
485 }
486
487 i=fPosition;
488 for (vector<int>::iterator element=indexList.begin();
489 element!=indexList.end();
490 element++, i++) {
491 if (i<fArraySize) {
492 fpLevelArray[i]=pStat[*element].fLevel;
493 fpIdArray[i]=pStat[*element].fId;
494 fpTimeArray[i]=pStat[*element].fTime;
495 fpCTimeArray[i]=pStat[*element].fCTime;
496 fpInputBlockCountArray[i]=pStat[*element].fInputBlockCount;
497 fpTotalInputSizeArray[i]=pStat[*element].fTotalInputSize;
498 fpOutputBlockCountArray[i]=pStat[*element].fOutputBlockCount;
499 fpTotalOutputSizeArray[i]=pStat[*element].fTotalOutputSize;
2e3fd14f 500 fpComponentCycleTimeArray[i]=pStat[*element].fComponentCycleTime;
501 fpEventTypeArray[i]=eventType;
502 fpEventCountArray[i]=GetEventCount();
c7b299f1 503 } else {
504 // TODO: dynamically grow arrays with placement new
b765ad15 505 }
506 }
507
508 if (i>=fArraySize) {
509 HLTWarning("too little space in branch variables to fill %d statistics blocks, available %d at position %d", i, fArraySize, fPosition);
510 fPosition=fArraySize;
511 } else {
512 fPosition=i;
513 }
514
515 return iResult;
516}
517
518void AliHLTCompStatCollector::ClearAll()
519{
abb52c8f 520 // see header file for class documentation
b765ad15 521 if (fpTimer) delete fpTimer; fpTimer=NULL;
abb52c8f 522 if (fpFolder) delete fpFolder; fpFolder=NULL;
b765ad15 523 if (fpStatTree) delete fpStatTree; fpStatTree=NULL;
524 if (fpLevelArray) delete fpLevelArray; fpLevelArray=NULL;
525 if (fpSpecArray) delete fpSpecArray; fpSpecArray=NULL;
526 if (fpBlockNoArray) delete fpBlockNoArray; fpBlockNoArray=NULL;
527 if (fpIdArray) delete fpIdArray; fpIdArray=NULL;
528 if (fpTimeArray) delete fpTimeArray; fpTimeArray=NULL;
529 if (fpCTimeArray) delete fpCTimeArray; fpCTimeArray=NULL;
530 if (fpInputBlockCountArray) delete fpInputBlockCountArray; fpInputBlockCountArray=NULL;
531 if (fpTotalInputSizeArray) delete fpTotalInputSizeArray; fpTotalInputSizeArray=NULL;
532 if (fpOutputBlockCountArray) delete fpOutputBlockCountArray; fpOutputBlockCountArray=NULL;
533 if (fpTotalOutputSizeArray) delete fpTotalOutputSizeArray; fpTotalOutputSizeArray=NULL;
2e3fd14f 534 if (fpComponentCycleTimeArray) delete fpComponentCycleTimeArray; fpComponentCycleTimeArray=NULL;
535 if (fpEventTypeArray) delete fpEventTypeArray; fpEventTypeArray=NULL;
536 if (fpEventCountArray) delete fpEventCountArray; fpEventCountArray=NULL;
b765ad15 537}
abb52c8f 538
539int AliHLTCompStatCollector::RemoveRecurrence(TFolder* pRoot) const
540{
541 // see header file for class documentation
542 int iResult=0;
543 if (!pRoot) return -EINVAL;
544 TFolder* parentFolder=dynamic_cast<TFolder*>(pRoot->FindObject(HLTSTAT_ENTRY_PARENT_FOLDER_NAME));
545 assert(parentFolder);
546 vector<TFolder*> listRemove;
547 if (parentFolder) {
548 TIter entries(parentFolder->GetListOfFolders());
549 TFolder* entry=NULL;
550 TObject* obj=NULL;
551 while ((obj=entries.Next())!=NULL && (entry=dynamic_cast<TFolder*>(obj))!=NULL) {
552 TString name=entry->GetName();
553 HLTDebug("checking %s for recurrence", name.Data());
554 TIter tokens(parentFolder->GetListOfFolders());
555 TFolder* token=NULL;
556 while ((obj=tokens.Next())!=NULL && (token=dynamic_cast<TFolder*>(obj))!=NULL) {
557 if (name.CompareTo(token->GetName())==0) continue;
558 if ((obj=token->FindObjectAny(name))!=NULL) {
559 listRemove.push_back(entry);
560 HLTDebug("found recurrence in %s", token->GetName());
561 break;
562 } else {
563 HLTDebug("no recurrence found in %s", token->GetName());
564 }
565 }
566 RemoveRecurrence(entry);
567 }
568 for (vector<TFolder*>::iterator removeElement=listRemove.begin();
569 removeElement!=listRemove.end(); removeElement++) {
570 parentFolder->Remove(*removeElement);
571 }
572 }
573
574 return iResult;
575}
c7b299f1 576
577bool AliHLTCompStatCollector::CheckPeriod(bool bUpdate)
578{
579 // see header file for class documentation
580 bool result=true;
581 if (fEventModulo>0) {
582 if ((result=((GetEventCount()+1)%fEventModulo)==0)) {
583 return true;
584 }
585 }
586 if (fPeriod>0) {
587 if ((result=((difftime(time(NULL), fLastTime)>(double)fPeriod))) &&
588 bUpdate) {
589 fLastTime=time(NULL);
590 }
591 }
592 return result;
593}