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 //* Timm Steinbeck <timm@kip.uni-heidelberg.de> *
9 //* for The ALICE HLT Project. *
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 //**************************************************************************
20 // @file AliHLTSampleComponent1.cxx
21 // @author Matthias Richter, Timm M. Steinbeck
23 // @brief A sample processing component for the HLT.
24 // Component illustrates the basic functionality and component
31 #include "AliHLTSampleComponent1.h"
33 #include "TObjString.h"
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTSampleComponent1)
39 /** one global instance used for registration */
40 AliHLTSampleComponent1 gAliHLTSampleComponent1;
42 AliHLTSampleComponent1::AliHLTSampleComponent1()
47 // an example component which implements the ALICE HLT processor
48 // interface and illustrates the basic interface methods
50 // see header file for class documentation
52 // refer to README to build package
54 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
56 // NOTE: all helper classes should be instantiated in DoInit()
59 AliHLTSampleComponent1::~AliHLTSampleComponent1()
63 // NOTE: implement proper cleanup in DoDeinit()
66 const char* AliHLTSampleComponent1::GetComponentID()
68 // component property: id
69 return "Sample-component1";
72 void AliHLTSampleComponent1::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
74 // component property: list of input data types
75 list.push_back(kAliHLTAnyDataType);
78 AliHLTComponentDataType AliHLTSampleComponent1::GetOutputDataType()
80 // component property: output data type
81 return kAliHLTVoidDataType;
84 void AliHLTSampleComponent1::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
86 // component property: output size estimator
91 void AliHLTSampleComponent1::GetOCDBObjectDescription( TMap* const targetMap)
93 // Get a list of OCDB object description.
94 // The list of objects is provided in a TMap
95 // - key: complete OCDB path, e.g. GRP/GRP/Data
96 // - value: short description why the object is needed
97 // Key and value objects created inside this class go into ownership of
99 if (!targetMap) return;
100 targetMap->Add(new TObjString("HLT/ConfigSample/SampleComponent1"),
101 new TObjString("configuration object"));
104 AliHLTComponent* AliHLTSampleComponent1::Spawn()
106 // Spawn function, return new class instance
107 return new AliHLTSampleComponent1;
110 int AliHLTSampleComponent1::DoInit( int argc, const char** argv )
112 // see header file for class documentation
115 // init stage 1: default values for all data members
119 // init stage 2: read configuration object
120 // ScanConfigurationArgument() needs to be implemented
121 TString cdbPath="HLT/ConfigSample/SampleComponent1";
122 iResult=ConfigureFromCDBTObjString(cdbPath);
124 // init stage 3: read the component arguments
126 iResult=ConfigureFromArgumentString(argc, argv);
130 // implement the component initialization
132 HLTError("mandatory argument \'-mandatory1\' missing");
136 HLTError("mandatory argument \'-mandatory2\' missing");
148 int AliHLTSampleComponent1::ScanConfigurationArgument( int argc, const char** argv )
150 // see header file for class documentation
154 TString configuration="";
158 if (argument.IsNull()) return 0;
161 if (argument.CompareTo("-mandatory1")==0) {
162 if (++i>=argc) return -EPROTO;
163 HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
167 } else if (argument.CompareTo("-mandatory2")==0) {
169 HLTInfo("got \'-mandatory2\' argument");
172 } else if (argument.CompareTo("-config1")==0) {
173 if (++i>=argc) return -EPROTO;
174 HLTInfo("got \'%s\' argument: %s", argument.Data(), argv[i]);
177 } else if (argument.CompareTo("-config2")==0) {
178 HLTInfo("got \'%s\' argument", argument.Data());
181 // no recognized argument
188 int AliHLTSampleComponent1::DoDeinit()
190 // see header file for class documentation
191 HLTInfo("processing cleanup");
195 int AliHLTSampleComponent1::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
196 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
197 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) {
198 // see header file for class documentation
199 HLTInfo("processing data");
200 if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 &&
201 outputPtr==0 && size==0)
203 outputBlocks.clear();
204 // this is just to get rid of the warning "unused parameter"
208 int AliHLTSampleComponent1::Reconfigure(const char* cdbEntry, const char* chainId)
210 // see header file for class documentation
212 const char* path="HLT/ConfigSample/SampleComponent1";
213 const char* defaultNotify="";
216 defaultNotify=" (default)";
219 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
220 iResult=ConfigureFromCDBTObjString(path);
225 int AliHLTSampleComponent1::ReadPreprocessorValues(const char* modules)
227 // see header file for class documentation
229 TString detectors(modules!=NULL?modules:"");
230 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());