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"
29 // header files of library components
30 #include "AliHLTDummyComponent.h"
31 #include "AliHLTSampleComponent1.h"
32 #include "AliHLTSampleComponent2.h"
33 #include "AliHLTSampleMonitoringComponent.h"
34 #include "AliHLTSampleCalibrationComponent.h"
36 // header file of the module preprocessor
37 #include "AliHLTSamplePreprocessor.h"
39 // raw data handler of HLTOUT data
40 #include "AliHLTOUTHandlerEquId.h"
41 #include "AliHLTOUTHandlerEsdBranch.h"
43 /** global instance for agent registration */
44 AliHLTAgentSample gAliHLTAgentSample;
46 const char* AliHLTAgentSample::fgkAliHLTAgentSampleData="/tmp/testdata";
47 const char* AliHLTAgentSample::fgkAliHLTAgentSampleOut="/tmp/hltout";
49 /** ROOT macro for the implementation of ROOT specific class methods */
50 ClassImp(AliHLTAgentSample)
52 AliHLTAgentSample::AliHLTAgentSample()
54 AliHLTModuleAgent("Sample")
56 // see header file for class documentation
58 // refer to README to build package
60 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
63 AliHLTAgentSample::~AliHLTAgentSample()
65 // see header file for class documentation
67 // delete the test data
68 ofstream dump(fgkAliHLTAgentSampleData, ios::in);
70 TString arg("rm -f ");
71 arg+=fgkAliHLTAgentSampleData;
72 gSystem->Exec(arg.Data());
76 int AliHLTAgentSample::CreateConfigurations(AliHLTConfigurationHandler* handler,
77 AliRawReader* /*rawReader*/,
78 AliRunLoader* runloader) const
80 // see header file for class documentation
82 // create some test data
83 ofstream dump(fgkAliHLTAgentSampleData, (ios::openmode)0);
84 dump << "This is just some test data for the ALICE HLT analysis example";
85 dump << "---- not copied" << endl;
89 // the publisher configuration for the test data
90 TString arg("-datatype DUMMYDAT TEST -datafile ");
91 arg+=fgkAliHLTAgentSampleData;
93 handler->CreateConfiguration("sample-fp1" , "FilePublisher", NULL , arg.Data());
95 // the configuration for the dummy component
96 handler->CreateConfiguration("sample-cp" , "Dummy" , "sample-fp1", "output_percentage 80");
98 // the writer configuration
99 arg="-datafile "; arg+=fgkAliHLTAgentSampleOut;
100 handler->CreateConfiguration("sample-sink1", "FileWriter" , "sample-cp" , arg.Data());
102 // specific example for the AliRoot simulation (run loader present)
104 // sample offline source
105 handler->CreateConfiguration("sample-offsrc", "AliLoaderPublisher" , NULL , "-loader TPCLoader -tree digits -verbose");
107 // sample offline sink
108 handler->CreateConfiguration("sample-offsnk", "SampleOfflineDataSink" , "sample-offsrc" , NULL);
114 const char* AliHLTAgentSample::GetReconstructionChains(AliRawReader* /*rawReader*/,
115 AliRunLoader* runloader) const
117 // see header file for class documentation
118 if (runloader) return "sample-sink1 sample-offsnk";
120 return "sample-sink1";
123 const char* AliHLTAgentSample::GetRequiredComponentLibraries() const
125 // see header file for class documentation
126 return "libAliHLTUtil.so libAliHLTSample.so";
129 int AliHLTAgentSample::RegisterComponents(AliHLTComponentHandler* pHandler) const
131 // see header file for class documentation
133 if (!pHandler) return -EINVAL;
134 pHandler->AddComponent(new AliHLTDummyComponent);
135 pHandler->AddComponent(new AliHLTSampleComponent1);
136 pHandler->AddComponent(new AliHLTSampleComponent2);
137 pHandler->AddComponent(new AliHLTSampleMonitoringComponent);
138 pHandler->AddComponent(new AliHLTSampleCalibrationComponent);
143 AliHLTModulePreprocessor* AliHLTAgentSample::GetPreprocessor()
145 // see header file for class documentation
146 return new AliHLTSamplePreprocessor;
149 int AliHLTAgentSample::GetHandlerDescription(AliHLTComponentDataType dt,
151 AliHLTOUTHandlerDesc& desc) const
153 // see header file for class documentation
154 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginSample)) {
155 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
156 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
157 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
161 // add TObject data blocks of type {ROOTTOBJ:SMPL} to ESD
162 if (dt==(kAliHLTDataTypeTObject|kAliHLTDataOriginSample)) {
163 desc=AliHLTOUTHandlerDesc(kEsd, dt, GetModuleId());
164 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
165 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
172 AliHLTOUTHandler* AliHLTAgentSample::GetOutputHandler(AliHLTComponentDataType dt,
173 AliHLTUInt32_t /*spec*/)
175 // see header file for class documentation
176 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginSample)) {
177 // use the default handler
178 static AliHLTOUTHandlerEquId handler;
182 if (dt==(kAliHLTDataTypeTObject|kAliHLTDataOriginSample)) {
183 // use AliHLTOUTHandlerEsdBranch handler to add the TObject
185 // Note: the object should have an appropriate name returned
186 // by GetName(). Use SetName() to prepare the object before streaming
187 static AliHLTOUTHandlerEsdBranch handler;
194 int AliHLTAgentSample::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
196 // see header file for class documentation
197 if (pInstance==NULL) return -EINVAL;
199 // nothing to delete, the handler have been defined static