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