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 AliHLTAgentSample.cxx
20 @author Matthias Richter
22 @brief Agent of the libAliHLTSample library
26 #include "AliHLTAgentSample.h"
27 #include "AliHLTConfiguration.h"
30 // header files of library components
31 #include "AliHLTDummyComponent.h"
32 #include "AliHLTSampleComponent1.h"
33 #include "AliHLTSampleComponent2.h"
34 #include "AliHLTSampleMonitoringComponent.h"
36 // header file of the module preprocessor
37 #include "AliHLTSamplePreprocessor.h"
39 // raw data handler of HLTOUT data
40 #include "AliHLTOUTHandlerEquId.h"
42 /** global instance for agent registration */
43 AliHLTAgentSample gAliHLTAgentSample;
45 const char* AliHLTAgentSample::fgkAliHLTAgentSampleData="/tmp/testdata";
46 const char* AliHLTAgentSample::fgkAliHLTAgentSampleOut="/tmp/hltout";
48 /** ROOT macro for the implementation of ROOT specific class methods */
49 ClassImp(AliHLTAgentSample)
51 AliHLTAgentSample::AliHLTAgentSample()
53 AliHLTModuleAgent("Sample")
55 // see header file for class documentation
57 // refer to README to build package
59 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 AliHLTAgentSample::~AliHLTAgentSample()
64 // see header file for class documentation
66 // delete the test data
67 ofstream dump(fgkAliHLTAgentSampleData, ios::in);
69 TString arg("rm -f ");
70 arg+=fgkAliHLTAgentSampleData;
71 gSystem->Exec(arg.Data());
75 int AliHLTAgentSample::CreateConfigurations(AliHLTConfigurationHandler* handler,
76 AliRawReader* /*rawReader*/,
77 AliRunLoader* runloader) const
79 // see header file for class documentation
81 // create some test data
82 ofstream dump(fgkAliHLTAgentSampleData, (ios::openmode)0);
83 dump << "This is just some test data for the ALICE HLT analysis example";
84 dump << "---- not copied" << endl;
88 // the publisher configuration for the test data
89 TString arg("-datatype DUMMYDAT TEST -datafile ");
90 arg+=fgkAliHLTAgentSampleData;
92 handler->CreateConfiguration("sample-fp1" , "FilePublisher", NULL , arg.Data());
94 // the configuration for the dummy component
95 handler->CreateConfiguration("sample-cp" , "Dummy" , "sample-fp1", "output_percentage 80");
97 // the writer configuration
98 arg="-datafile "; arg+=fgkAliHLTAgentSampleOut;
99 handler->CreateConfiguration("sample-sink1", "FileWriter" , "sample-cp" , arg.Data());
101 // specific example for the AliRoot simulation (run loader present)
103 // sample offline source
104 handler->CreateConfiguration("sample-offsrc", "AliLoaderPublisher" , NULL , "-loader TPCLoader -tree digits -verbose");
106 // sample offline sink
107 handler->CreateConfiguration("sample-offsnk", "SampleOfflineDataSink" , "sample-offsrc" , NULL);
113 const char* AliHLTAgentSample::GetReconstructionChains(AliRawReader* /*rawReader*/,
114 AliRunLoader* runloader) const
116 // see header file for class documentation
117 if (runloader) return "sample-sink1 sample-offsnk";
119 return "sample-sink1";
122 const char* AliHLTAgentSample::GetRequiredComponentLibraries() const
124 // see header file for class documentation
125 return "libAliHLTUtil.so libAliHLTSample.so";
128 int AliHLTAgentSample::RegisterComponents(AliHLTComponentHandler* pHandler) const
130 // see header file for class documentation
132 if (!pHandler) return -EINVAL;
133 pHandler->AddComponent(new AliHLTDummyComponent);
134 pHandler->AddComponent(new AliHLTSampleComponent1);
135 pHandler->AddComponent(new AliHLTSampleComponent2);
136 pHandler->AddComponent(new AliHLTSampleMonitoringComponent);
141 AliHLTModulePreprocessor* AliHLTAgentSample::GetPreprocessor()
143 // see header file for class documentation
144 return new AliHLTSamplePreprocessor;
147 int AliHLTAgentSample::GetHandlerDescription(AliHLTComponentDataType dt,
149 AliHLTOUTHandlerDesc& desc) const
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);
161 AliHLTOUTHandler* AliHLTAgentSample::GetOutputHandler(AliHLTComponentDataType dt,
162 AliHLTUInt32_t /*spec*/)
164 // see header file for class documentation
165 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginSample)) {
166 // use the default handler
167 return new AliHLTOUTHandlerEquId;
172 int AliHLTAgentSample::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
174 // see header file for class documentation
175 if (pInstance==NULL) return -EINVAL;