]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/SampleLib/AliHLTSampleComponent1.cxx
Update master to aliroot
[u/mrichter/AliRoot.git] / HLT / SampleLib / AliHLTSampleComponent1.cxx
CommitLineData
c5318542 1// $Id$
2
289c6c1a 3//**************************************************************************
0cfce653 4//* This file is property of and copyright by the *
289c6c1a 5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* Timm Steinbeck <timm@kip.uni-heidelberg.de> *
9//* for The ALICE HLT Project. *
10//* *
11//* Permission to use, copy, modify and distribute this software and its *
12//* documentation strictly for non-commercial purposes is hereby granted *
13//* without fee, provided that the above copyright notice appears in all *
14//* copies and that both the copyright notice and this permission notice *
15//* appear in the supporting documentation. The authors make no claims *
16//* about the suitability of this software for any purpose. It is *
17//* provided "as is" without express or implied warranty. *
18//**************************************************************************
19
20// @file AliHLTSampleComponent1.cxx
21// @author Matthias Richter, Timm M. Steinbeck
22// @date
23// @brief A sample processing component for the HLT.
24// Component illustrates the basic functionality and component
25// initialization.
c5318542 26
c5318542 27#include "AliHLTSampleComponent1.h"
5045badf 28#include "TString.h"
29#include "TObjString.h"
289c6c1a 30#include "TMap.h"
c5318542 31
0cfce653 32using namespace std;
33
5045badf 34/** ROOT macro for the implementation of ROOT specific class methods */
c5318542 35ClassImp(AliHLTSampleComponent1)
36
c5318542 37AliHLTSampleComponent1::AliHLTSampleComponent1()
289c6c1a 38 : AliHLTProcessor()
39 , fArgument1(0)
40 , fArgument2(0)
c5318542 41{
289c6c1a 42 // an example component which implements the ALICE HLT processor
43 // interface and illustrates the basic interface methods
44 //
289c6c1a 45 //
46 // NOTE: all helper classes should be instantiated in DoInit()
c5318542 47}
48
49AliHLTSampleComponent1::~AliHLTSampleComponent1()
50{
289c6c1a 51 // destructor
52 //
53 // NOTE: implement proper cleanup in DoDeinit()
54}
55
56const char* AliHLTSampleComponent1::GetComponentID()
57{
58 // component property: id
59 return "Sample-component1";
60}
61
62void AliHLTSampleComponent1::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
63{
64 // component property: list of input data types
65 list.push_back(kAliHLTAnyDataType);
66}
67
68AliHLTComponentDataType AliHLTSampleComponent1::GetOutputDataType()
69{
70 // component property: output data type
71 return kAliHLTVoidDataType;
72}
73
74void AliHLTSampleComponent1::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
75{
76 // component property: output size estimator
77 constBase = 0;
78 inputMultiplier = 0;
79}
80
81void AliHLTSampleComponent1::GetOCDBObjectDescription( TMap* const targetMap)
82{
83 // Get a list of OCDB object description.
84 // The list of objects is provided in a TMap
85 // - key: complete OCDB path, e.g. GRP/GRP/Data
86 // - value: short description why the object is needed
87 // Key and value objects created inside this class go into ownership of
88 // target TMap.
89 if (!targetMap) return;
90 targetMap->Add(new TObjString("HLT/ConfigSample/SampleComponent1"),
91 new TObjString("configuration object"));
92}
93
94AliHLTComponent* AliHLTSampleComponent1::Spawn()
95{
96 // Spawn function, return new class instance
97 return new AliHLTSampleComponent1;
c5318542 98}
99
5045badf 100int AliHLTSampleComponent1::DoInit( int argc, const char** argv )
101{
f644d3f1 102 // see header file for class documentation
5045badf 103 int iResult=0;
289c6c1a 104
105 // init stage 1: default values for all data members
106 fArgument1=0;
107 fArgument2=0;
108
109 // init stage 2: read configuration object
110 // ScanConfigurationArgument() needs to be implemented
111 TString cdbPath="HLT/ConfigSample/SampleComponent1";
112 iResult=ConfigureFromCDBTObjString(cdbPath);
113
114 // init stage 3: read the component arguments
115 if (iResult>=0) {
116 iResult=ConfigureFromArgumentString(argc, argv);
117 }
118
119 if (iResult>=0) {
120 // implement the component initialization
121 if (!fArgument1) {
122 HLTError("mandatory argument \'-mandatory1\' missing");
123 iResult=-EPROTO;
124 }
125 if (!fArgument2) {
126 HLTError("mandatory argument \'-mandatory2\' missing");
127 iResult=-EPROTO;
128 }
129 }
130
131 if (iResult<0) {
132 // implement cleanup
133 }
134
135 return iResult;
136}
137
138int AliHLTSampleComponent1::ScanConfigurationArgument( int argc, const char** argv )
139{
140 // see header file for class documentation
5045badf 141 TString argument="";
142 TString configuration="";
289c6c1a 143 int i=0;
5045badf 144 argument=argv[i];
289c6c1a 145 if (argument.IsNull()) return 0;
5045badf 146
147 // -mandatory1
148 if (argument.CompareTo("-mandatory1")==0) {
289c6c1a 149 if (++i>=argc) return -EPROTO;
5045badf 150 HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
289c6c1a 151 fArgument1=1;
5045badf 152
153 // -mandatory2
154 } else if (argument.CompareTo("-mandatory2")==0) {
289c6c1a 155 fArgument2=1;
5045badf 156 HLTInfo("got \'-mandatory2\' argument");
157
289c6c1a 158 // -config1
159 } else if (argument.CompareTo("-config1")==0) {
160 if (++i>=argc) return -EPROTO;
161 HLTInfo("got \'%s\' argument: %s", argument.Data(), argv[i]);
5045badf 162
289c6c1a 163 // -config2
164 } else if (argument.CompareTo("-config2")==0) {
165 HLTInfo("got \'%s\' argument", argument.Data());
5045badf 166
167 } else {
289c6c1a 168 // no recognized argument
169 i--;
5045badf 170 }
5045badf 171
289c6c1a 172 return i+1;
c5318542 173}
174
5045badf 175int AliHLTSampleComponent1::DoDeinit()
176{
f644d3f1 177 // see header file for class documentation
5045badf 178 HLTInfo("processing cleanup");
c5318542 179 return 0;
180}
181
8ede8717 182int AliHLTSampleComponent1::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
183 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
0cfce653 184 AliHLTUInt32_t& size, AliHLTComponentBlockDataList& outputBlocks ) {
f644d3f1 185 // see header file for class documentation
5045badf 186 HLTInfo("processing data");
f644d3f1 187 if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 &&
188 outputPtr==0 && size==0)
189 {
190 outputBlocks.clear();
191 // this is just to get rid of the warning "unused parameter"
192 }
c5318542 193 return 0;
194}
5045badf 195int AliHLTSampleComponent1::Reconfigure(const char* cdbEntry, const char* chainId)
196{
197 // see header file for class documentation
198 int iResult=0;
199 const char* path="HLT/ConfigSample/SampleComponent1";
200 const char* defaultNotify="";
201 if (cdbEntry) {
202 path=cdbEntry;
203 defaultNotify=" (default)";
204 }
289c6c1a 205
206 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
207 iResult=ConfigureFromCDBTObjString(path);
208
5045badf 209 return iResult;
210}
b543e186 211
212int AliHLTSampleComponent1::ReadPreprocessorValues(const char* modules)
213{
214 // see header file for class documentation
215 int iResult=0;
216 TString detectors(modules!=NULL?modules:"");
217 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
218 return iResult;
219}