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
152 TString configuration="";
155 if (argument.IsNull()) return 0;
158 if (argument.CompareTo("-mandatory1")==0) {
159 if (++i>=argc) return -EPROTO;
160 HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
164 } else if (argument.CompareTo("-mandatory2")==0) {
166 HLTInfo("got \'-mandatory2\' argument");
169 } else if (argument.CompareTo("-config1")==0) {
170 if (++i>=argc) return -EPROTO;
171 HLTInfo("got \'%s\' argument: %s", argument.Data(), argv[i]);
174 } else if (argument.CompareTo("-config2")==0) {
175 HLTInfo("got \'%s\' argument", argument.Data());
178 // no recognized argument
185 int AliHLTSampleComponent1::DoDeinit()
187 // see header file for class documentation
188 HLTInfo("processing cleanup");
192 int AliHLTSampleComponent1::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
193 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
194 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) {
195 // see header file for class documentation
196 HLTInfo("processing data");
197 if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 &&
198 outputPtr==0 && size==0)
200 outputBlocks.clear();
201 // this is just to get rid of the warning "unused parameter"
205 int AliHLTSampleComponent1::Reconfigure(const char* cdbEntry, const char* chainId)
207 // see header file for class documentation
209 const char* path="HLT/ConfigSample/SampleComponent1";
210 const char* defaultNotify="";
213 defaultNotify=" (default)";
216 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
217 iResult=ConfigureFromCDBTObjString(path);
222 int AliHLTSampleComponent1::ReadPreprocessorValues(const char* modules)
224 // see header file for class documentation
226 TString detectors(modules!=NULL?modules:"");
227 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());