]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTOUTHandlerChain.cxx
- adding event type data block {EVENTTYP:PRIV} to component input blocks
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOUTHandlerChain.cxx
CommitLineData
7131ea63 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 AliHLTOUTHandlerChain.cxx
20 @author Matthias Richter
21 @date 24.06.2008
22 @brief HLTOUT handler of type kChain.
23*/
24
25#include "AliHLTOUTHandlerChain.h"
26#include "AliHLTOUT.h"
27#include "AliHLTSystem.h"
28#include "AliHLTOUTTask.h"
29#include "TString.h"
30#include "TObjString.h"
31#include "TObjArray.h"
32
33/** ROOT macro for the implementation of ROOT specific class methods */
34ClassImp(AliHLTOUTHandlerChain)
35
36AliHLTOUTHandlerChain::AliHLTOUTHandlerChain(const char* arguments)
37 :
38 fChains(),
39 fOptions(),
40 fpSystem(NULL),
41 fpTask(NULL)
42{
43 // see header file for class documentation
44 // or
45 // refer to README to build package
46 // or
47 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
48 if (arguments) {
49 TString args=arguments;
50 TObjArray* pTokens=args.Tokenize(" ");
51 if (pTokens) {
52 int iEntries=pTokens->GetEntries();
53 for (int i=0; i<iEntries; i++) {
54 TString token=(((TObjString*)pTokens->At(i))->GetString());
55 if (token.Contains("chains=")) {
56 TString param=token.ReplaceAll("chains=", "");
57 fChains=param.ReplaceAll(",", " ");
58 } else {
59 if (!fOptions.IsNull()) fOptions+=" ";
60 fOptions+=token;
61 }
62 }
63 delete pTokens;
64 }
65 }
66}
67
68AliHLTOUTHandlerChain::~AliHLTOUTHandlerChain()
69{
70 // see header file for class documentation
71 if (fpSystem) {
72 delete fpSystem;
73 }
74}
75
76int AliHLTOUTHandlerChain::ProcessData(AliHLTOUT* pData)
77{
78 // see header file for class documentation
79 if (!pData) return -EINVAL;
80 int iResult=0;
81
82 if (CheckStatus(kHandlerError)) {
83 HLTWarning("kChain handler '%s' in error state, skipping processing of associated HLTOUT blocks", fChains.Data());
84 return -EPERM;
85 }
86
87 if (!fpSystem && (iResult=InitSystem())<0) {
88 return iResult;
89 }
90
f3c1d403 91 if (fpSystem->CheckStatus(AliHLTSystem::kError) || !fpTask) {
7131ea63 92 HLTWarning("kChain handler '%s': system in error state, skipping processing of associated HLTOUT blocks", fChains.Data());
93 return -EACCES;
94 }
95
96 // run one event and do not stop the chain
f3c1d403 97 fpTask->Reset();
7131ea63 98 {
99 AliHLTOUT::AliHLTOUTGlobalInstanceGuard g(pData);
100 if ((iResult=fpSystem->Run(1,0))>=0) {
101 // sub-collection is going to be reset from the
102 // parent HLTOUT collection
103 AliHLTOUT* pSubCollection=dynamic_cast<AliHLTOUT*>(fpTask);
104 pSubCollection->Init();
f75868b3 105
106 // filter out some data blocks which should not be processed
107 // in the next stage:
108 // 1. we are not interested in the component statistics
109 // produced in the HLTOUT handler chain
110 for (iResult=pSubCollection->SelectFirstDataBlock();
111 iResult>=0;
112 iResult=pSubCollection->SelectNextDataBlock()) {
113 AliHLTComponentDataType dt=kAliHLTVoidDataType;
114 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
115 pSubCollection->GetDataBlockDescription(dt, spec);
116 if (dt==kAliHLTDataTypeComponentStatistics) {
117 pSubCollection->MarkDataBlockProcessed();
118 }
119 }
120
7131ea63 121 pData->AddSubCollection(pSubCollection);
122 } else {
123 fpTask->Reset();
124 }
125 }
126
127 return iResult;
128}
129
130int AliHLTOUTHandlerChain::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/)
131{
132 //default implementation, nothing to do
133 return 0;
134}
135
136int AliHLTOUTHandlerChain::InitSystem()
137{
138 // see header file for class documentation
139 int iResult=0;
140 if (!fpSystem) {
141 // init AliHLTSystem
142 fpSystem = new AliHLTSystem(GetGlobalLoggingLevel());
143 if (fpSystem) {
144 if ((iResult=fpSystem->ScanOptions(fOptions.Data()))>=0) {
145 // load configurations if not specified by external macro
146 if (!fOptions.Contains("config="))
147 iResult=CreateConfigurations(fpSystem->fpConfigurationHandler);
148
149 if (iResult>=0) {
150 iResult=fpSystem->BuildTaskList(fChains.Data());
151 }
152
153 // add AliHLTOUTTask on top of the configuartions in order to
154 // collect the data
155 fpTask=new AliHLTOUTTask(fChains.Data());
156 }
157 } else {
158 iResult=-ENOMEM;
159 }
160 if (iResult>=0 && fpSystem && fpTask) {
161 if (fpTask->GetConf() && fpTask->GetConf()->SourcesResolved()>=0) {
162 iResult=fpSystem->InsertTask(fpTask);
163 } else {
164 HLTError("HLTOUT task (%s) sources not resolved", fpTask->GetName());
165 iResult=-ENOENT;
166 }
167 }
168 if (iResult<0 || !fpTask) {
169 SetStatusFlag(kHandlerError);
170 if (fpSystem) delete fpSystem; fpSystem=NULL;
171 if (fpTask) delete fpTask; fpTask=NULL;
172 }
173 }
174 return iResult;
175}