]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/SampleLib/AliHLTAgentSample.cxx
cache diffusion coefficients from AliTRDCommonParam
[u/mrichter/AliRoot.git] / HLT / SampleLib / AliHLTAgentSample.cxx
CommitLineData
242bb794 1// @(#) $Id$
2
9be2600f 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
242bb794 19/** @file AliHLTAgentSample.cxx
20 @author Matthias Richter
21 @date
22 @brief Agent of the libAliHLTSample library
23*/
24
f3506ea2 25#include <cassert>
242bb794 26#include "AliHLTAgentSample.h"
242bb794 27#include "TSystem.h"
28
f3506ea2 29// header files of library components
30#include "AliHLTDummyComponent.h"
5045badf 31#include "AliHLTSampleComponent1.h"
32#include "AliHLTSampleComponent2.h"
2accc11f 33#include "AliHLTSampleMonitoringComponent.h"
f3506ea2 34
12ec5482 35// header file of the module preprocessor
36#include "AliHLTSamplePreprocessor.h"
37
833b3167 38// raw data handler of HLTOUT data
39#include "AliHLTOUTHandlerEquId.h"
2b71116d 40#include "AliHLTOUTHandlerEsdBranch.h"
833b3167 41
242bb794 42/** global instance for agent registration */
43AliHLTAgentSample gAliHLTAgentSample;
44
90ebac25 45const char* AliHLTAgentSample::fgkAliHLTAgentSampleData="/tmp/testdata";
46const char* AliHLTAgentSample::fgkAliHLTAgentSampleOut="/tmp/hltout";
242bb794 47
48/** ROOT macro for the implementation of ROOT specific class methods */
49ClassImp(AliHLTAgentSample)
50
51AliHLTAgentSample::AliHLTAgentSample()
626bfcc1 52 :
53 AliHLTModuleAgent("Sample")
242bb794 54{
55 // see header file for class documentation
56 // or
57 // refer to README to build package
58 // or
59 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
60}
61
62AliHLTAgentSample::~AliHLTAgentSample()
63{
64 // see header file for class documentation
65
66 // delete the test data
90ebac25 67 ofstream dump(fgkAliHLTAgentSampleData, ios::in);
242bb794 68 if (dump.good()) {
69 TString arg("rm -f ");
90ebac25 70 arg+=fgkAliHLTAgentSampleData;
242bb794 71 gSystem->Exec(arg.Data());
72 }
73}
74
75int AliHLTAgentSample::CreateConfigurations(AliHLTConfigurationHandler* handler,
d76bc02a 76 AliRawReader* /*rawReader*/,
833b3167 77 AliRunLoader* runloader) const
242bb794 78{
79 // see header file for class documentation
80
81 // create some test data
90ebac25 82 ofstream dump(fgkAliHLTAgentSampleData, (ios::openmode)0);
242bb794 83 dump << "This is just some test data for the ALICE HLT analysis example";
84 dump << "---- not copied" << endl;
85 dump.close();
86
87 if (handler) {
88 // the publisher configuration for the test data
90191691 89 TString arg("-datatype DUMMYDAT TEST -datafile ");
90ebac25 90 arg+=fgkAliHLTAgentSampleData;
242bb794 91 HLTDebug(arg.Data());
90ebac25 92 handler->CreateConfiguration("sample-fp1" , "FilePublisher", NULL , arg.Data());
242bb794 93
94 // the configuration for the dummy component
90ebac25 95 handler->CreateConfiguration("sample-cp" , "Dummy" , "sample-fp1", "output_percentage 80");
242bb794 96
97 // the writer configuration
90ebac25 98 arg="-datafile "; arg+=fgkAliHLTAgentSampleOut;
99 handler->CreateConfiguration("sample-sink1", "FileWriter" , "sample-cp" , arg.Data());
100
833b3167 101 // specific example for the AliRoot simulation (run loader present)
102 if (runloader) {
90ebac25 103 // sample offline source
104 handler->CreateConfiguration("sample-offsrc", "AliLoaderPublisher" , NULL , "-loader TPCLoader -tree digits -verbose");
105
106 // sample offline sink
107 handler->CreateConfiguration("sample-offsnk", "SampleOfflineDataSink" , "sample-offsrc" , NULL);
833b3167 108 }
242bb794 109 }
110 return 0;
111}
112
d76bc02a 113const char* AliHLTAgentSample::GetReconstructionChains(AliRawReader* /*rawReader*/,
833b3167 114 AliRunLoader* runloader) const
242bb794 115{
116 // see header file for class documentation
833b3167 117 if (runloader) return "sample-sink1 sample-offsnk";
118
119 return "sample-sink1";
242bb794 120}
121
122const char* AliHLTAgentSample::GetRequiredComponentLibraries() const
123{
124 // see header file for class documentation
125 return "libAliHLTUtil.so libAliHLTSample.so";
126}
f3506ea2 127
128int AliHLTAgentSample::RegisterComponents(AliHLTComponentHandler* pHandler) const
129{
130 // see header file for class documentation
131 assert(pHandler);
132 if (!pHandler) return -EINVAL;
133 pHandler->AddComponent(new AliHLTDummyComponent);
5045badf 134 pHandler->AddComponent(new AliHLTSampleComponent1);
135 pHandler->AddComponent(new AliHLTSampleComponent2);
2accc11f 136 pHandler->AddComponent(new AliHLTSampleMonitoringComponent);
5045badf 137
f3506ea2 138 return 0;
139}
d76bc02a 140
12ec5482 141AliHLTModulePreprocessor* AliHLTAgentSample::GetPreprocessor()
142{
143 // see header file for class documentation
144 return new AliHLTSamplePreprocessor;
145}
833b3167 146
147int AliHLTAgentSample::GetHandlerDescription(AliHLTComponentDataType dt,
148 AliHLTUInt32_t spec,
149 AliHLTOUTHandlerDesc& desc) const
150{
151 // see header file for class documentation
152 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginSample)) {
153 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
154 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
155 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
156 return 1;
157 }
2b71116d 158
159 // add TObject data blocks of type {ROOTTOBJ:SMPL} to ESD
160 if (dt==(kAliHLTDataTypeTObject|kAliHLTDataOriginSample)) {
161 desc=AliHLTOUTHandlerDesc(kEsd, dt, GetModuleId());
162 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
163 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
164 return 1;
165 }
166
833b3167 167 return 0;
168}
169
170AliHLTOUTHandler* AliHLTAgentSample::GetOutputHandler(AliHLTComponentDataType dt,
171 AliHLTUInt32_t /*spec*/)
172{
173 // see header file for class documentation
174 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginSample)) {
175 // use the default handler
2b71116d 176 static AliHLTOUTHandlerEquId handler;
177 return &handler;
178 }
179
180 if (dt==(kAliHLTDataTypeTObject|kAliHLTDataOriginSample)) {
181 // use AliHLTOUTHandlerEsdBranch handler to add the TObject
182 // to the ESD branch
183 // Note: the object should have an appropriate name returned
184 // by GetName(). Use SetName() to prepare the object before streaming
185 static AliHLTOUTHandlerEsdBranch handler;
186 return &handler;
833b3167 187 }
2b71116d 188
833b3167 189 return NULL;
190}
191
192int AliHLTAgentSample::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
193{
194 // see header file for class documentation
195 if (pInstance==NULL) return -EINVAL;
196
2b71116d 197 // nothing to delete, the handler have been defined static
833b3167 198 return 0;
199}