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 AliHLTOUTHandlerChain.cxx
20 @author Matthias Richter
22 @brief HLTOUT handler of type kChain.
25 #include "AliHLTOUTHandlerChain.h"
26 #include "AliHLTOUT.h"
27 #include "AliHLTSystem.h"
28 #include "AliHLTOUTTask.h"
30 #include "TObjString.h"
31 #include "TObjArray.h"
33 /** ROOT macro for the implementation of ROOT specific class methods */
34 ClassImp(AliHLTOUTHandlerChain)
36 AliHLTOUTHandlerChain::AliHLTOUTHandlerChain(const char* arguments)
43 // see header file for class documentation
45 // refer to README to build package
47 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
49 TString args=arguments;
50 TObjArray* pTokens=args.Tokenize(" ");
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(",", " ");
59 if (!fOptions.IsNull()) fOptions+=" ";
68 AliHLTOUTHandlerChain::~AliHLTOUTHandlerChain()
70 // see header file for class documentation
76 int AliHLTOUTHandlerChain::ProcessData(AliHLTOUT* pData)
78 // see header file for class documentation
79 if (!pData) return -EINVAL;
82 if (CheckStatus(kHandlerError)) {
83 HLTWarning("kChain handler '%s' in error state, skipping processing of associated HLTOUT blocks", fChains.Data());
87 if (!fpSystem && (iResult=InitSystem())<0) {
91 if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
92 HLTWarning("kChain handler '%s': system in error state, skipping processing of associated HLTOUT blocks", fChains.Data());
96 // run one event and do not stop the chain
98 AliHLTOUT::AliHLTOUTGlobalInstanceGuard g(pData);
99 if ((iResult=fpSystem->Run(1,0))>=0) {
100 // sub-collection is going to be reset from the
101 // parent HLTOUT collection
102 AliHLTOUT* pSubCollection=dynamic_cast<AliHLTOUT*>(fpTask);
103 pSubCollection->Init();
104 pData->AddSubCollection(pSubCollection);
113 int AliHLTOUTHandlerChain::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/)
115 //default implementation, nothing to do
119 int AliHLTOUTHandlerChain::InitSystem()
121 // see header file for class documentation
125 fpSystem = new AliHLTSystem(GetGlobalLoggingLevel());
127 if ((iResult=fpSystem->ScanOptions(fOptions.Data()))>=0) {
128 // load configurations if not specified by external macro
129 if (!fOptions.Contains("config="))
130 iResult=CreateConfigurations(fpSystem->fpConfigurationHandler);
133 iResult=fpSystem->BuildTaskList(fChains.Data());
136 // add AliHLTOUTTask on top of the configuartions in order to
138 fpTask=new AliHLTOUTTask(fChains.Data());
143 if (iResult>=0 && fpSystem && fpTask) {
144 if (fpTask->GetConf() && fpTask->GetConf()->SourcesResolved()>=0) {
145 iResult=fpSystem->InsertTask(fpTask);
147 HLTError("HLTOUT task (%s) sources not resolved", fpTask->GetName());
151 if (iResult<0 || !fpTask) {
152 SetStatusFlag(kHandlerError);
153 if (fpSystem) delete fpSystem; fpSystem=NULL;
154 if (fpTask) delete fpTask; fpTask=NULL;