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. */
29 #include "AliHLTSampleComponent1.h"
31 #include "TObjString.h"
32 #include "TObjArray.h"
33 #include "AliCDBEntry.h"
34 #include "AliCDBManager.h"
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTSampleComponent1)
39 AliHLTSampleComponent1::AliHLTSampleComponent1()
41 // see header file for class documentation
43 // refer to README to build package
45 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
48 AliHLTSampleComponent1::~AliHLTSampleComponent1()
50 // see header file for class documentation
53 int AliHLTSampleComponent1::DoInit( int argc, const char** argv )
55 // see header file for class documentation
57 HLTInfo("parsing %d arguments", argc);
60 TString configuration="";
62 bool bHaveMandatory1=false;
63 bool bHaveMandatory2=false;
64 for (int i=0; i<argc && iResult>=0; i++) {
66 if (argument.IsNull()) continue;
69 if (argument.CompareTo("-mandatory1")==0) {
71 if ((bMissingParam=(++i>=argc))) break;
72 HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
75 } else if (argument.CompareTo("-mandatory2")==0) {
77 HLTInfo("got \'-mandatory2\' argument");
80 } else if (argument.CompareTo("-optional1")==0) {
81 if ((bMissingParam=(++i>=argc))) break;
82 HLTInfo("got \'-optional1\' argument: %s", argv[i]);
85 } else if (argument.CompareTo("-optional2")==0) {
86 HLTInfo("got \'-optional2\' argument");
89 // the remaining arguments are treated as configuration
90 if (!configuration.IsNull()) configuration+=" ";
91 configuration+=argument;
95 HLTError("missing parameter for argument %s", argument.Data());
99 if (iResult>=0 && !bHaveMandatory1) {
100 HLTError("mandatory argument \'-mandatory1\' missing");
103 if (iResult>=0 && !bHaveMandatory2) {
104 HLTError("mandatory argument \'-mandatory2\' missing");
107 if (iResult>=0 && !configuration.IsNull()) {
108 iResult=Configure(configuration.Data());
110 iResult=Reconfigure(NULL, NULL);
116 int AliHLTSampleComponent1::DoDeinit()
118 // see header file for class documentation
119 HLTInfo("processing cleanup");
123 int AliHLTSampleComponent1::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
124 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
125 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) {
126 // see header file for class documentation
127 HLTInfo("processing data");
128 if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 &&
129 outputPtr==0 && size==0)
131 outputBlocks.clear();
132 // this is just to get rid of the warning "unused parameter"
137 int AliHLTSampleComponent1::Configure(const char* arguments)
139 // see header file for class documentation
141 if (!arguments) return iResult;
142 HLTInfo("parsing configuration string \'%s\'", arguments);
144 TString allArgs=arguments;
148 TObjArray* pTokens=allArgs.Tokenize(" ");
150 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
151 argument=((TObjString*)pTokens->At(i))->GetString();
152 if (argument.IsNull()) continue;
155 if (argument.CompareTo("-config1")==0) {
156 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
157 HLTInfo("got \'-config1\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
160 } else if (argument.CompareTo("-config2")==0) {
161 HLTInfo("got \'-config2\'");
163 HLTError("unknown argument %s", argument.Data());
171 HLTError("missing parameter for argument %s", argument.Data());
177 int AliHLTSampleComponent1::Reconfigure(const char* cdbEntry, const char* chainId)
179 // see header file for class documentation
181 const char* path="HLT/ConfigSample/SampleComponent1";
182 const char* defaultNotify="";
185 defaultNotify=" (default)";
188 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
189 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
191 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
193 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
194 iResult=Configure(pString->GetString().Data());
196 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
199 HLTError("can not fetch object \"%s\" from CDB", path);
205 int AliHLTSampleComponent1::ReadPreprocessorValues(const char* modules)
207 // see header file for class documentation
209 TString detectors(modules!=NULL?modules:"");
210 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());