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) || !fpTask) {
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
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();
105 pData->AddSubCollection(pSubCollection);
114 int AliHLTOUTHandlerChain::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/)
116 //default implementation, nothing to do
120 int AliHLTOUTHandlerChain::InitSystem()
122 // see header file for class documentation
126 fpSystem = new AliHLTSystem(GetGlobalLoggingLevel());
128 if ((iResult=fpSystem->ScanOptions(fOptions.Data()))>=0) {
129 // load configurations if not specified by external macro
130 if (!fOptions.Contains("config="))
131 iResult=CreateConfigurations(fpSystem->fpConfigurationHandler);
134 iResult=fpSystem->BuildTaskList(fChains.Data());
137 // add AliHLTOUTTask on top of the configuartions in order to
139 fpTask=new AliHLTOUTTask(fChains.Data());
144 if (iResult>=0 && fpSystem && fpTask) {
145 if (fpTask->GetConf() && fpTask->GetConf()->SourcesResolved()>=0) {
146 iResult=fpSystem->InsertTask(fpTask);
148 HLTError("HLTOUT task (%s) sources not resolved", fpTask->GetName());
152 if (iResult<0 || !fpTask) {
153 SetStatusFlag(kHandlerError);
154 if (fpSystem) delete fpSystem; fpSystem=NULL;
155 if (fpTask) delete fpTask; fpTask=NULL;