]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/SampleLib/AliHLTSampleComponent1.cxx
adding some optional debugging functionality for the EventDoneData
[u/mrichter/AliRoot.git] / HLT / SampleLib / AliHLTSampleComponent1.cxx
CommitLineData
c5318542 1// $Id$
2
3/**************************************************************************
9be2600f 4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
c5318542 6 * *
9be2600f 7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
9 * for The ALICE HLT Project. *
c5318542 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
b22e91eb 20/** @file AliHLTSampleComponent1.cxx
21 @author Matthias Richter, Timm M. Steinbeck
22 @date
23 @brief A sample processing component for the HLT. */
c5318542 24
25#if __GNUC__== 3
26using namespace std;
27#endif
28
c5318542 29#include "AliHLTSampleComponent1.h"
5045badf 30#include "TString.h"
31#include "TObjString.h"
32#include "TObjArray.h"
33#include "AliCDBEntry.h"
34#include "AliCDBManager.h"
c5318542 35
5045badf 36/** ROOT macro for the implementation of ROOT specific class methods */
c5318542 37ClassImp(AliHLTSampleComponent1)
38
c5318542 39AliHLTSampleComponent1::AliHLTSampleComponent1()
40{
f644d3f1 41 // see header file for class documentation
5045badf 42 // or
43 // refer to README to build package
44 // or
45 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
c5318542 46}
47
48AliHLTSampleComponent1::~AliHLTSampleComponent1()
49{
f644d3f1 50 // see header file for class documentation
c5318542 51}
52
5045badf 53int AliHLTSampleComponent1::DoInit( int argc, const char** argv )
54{
f644d3f1 55 // see header file for class documentation
5045badf 56 int iResult=0;
57 HLTInfo("parsing %d arguments", argc);
58
59 TString argument="";
60 TString configuration="";
61 int bMissingParam=0;
62 bool bHaveMandatory1=false;
63 bool bHaveMandatory2=false;
64 for (int i=0; i<argc && iResult>=0; i++) {
65 argument=argv[i];
66 if (argument.IsNull()) continue;
67
68 // -mandatory1
69 if (argument.CompareTo("-mandatory1")==0) {
70 bHaveMandatory1|=1;
71 if ((bMissingParam=(++i>=argc))) break;
72 HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
73
74 // -mandatory2
75 } else if (argument.CompareTo("-mandatory2")==0) {
76 bHaveMandatory2|=1;
77 HLTInfo("got \'-mandatory2\' argument");
78
79 // -optional1
80 } else if (argument.CompareTo("-optional1")==0) {
81 if ((bMissingParam=(++i>=argc))) break;
82 HLTInfo("got \'-optional1\' argument: %s", argv[i]);
83
84 // -optional2
85 } else if (argument.CompareTo("-optional2")==0) {
86 HLTInfo("got \'-optional2\' argument");
87
88 } else {
89 // the remaining arguments are treated as configuration
90 if (!configuration.IsNull()) configuration+=" ";
91 configuration+=argument;
92 }
f644d3f1 93 }
5045badf 94 if (bMissingParam) {
95 HLTError("missing parameter for argument %s", argument.Data());
96 iResult=-EINVAL;
97 }
98
99 if (iResult>=0 && !bHaveMandatory1) {
100 HLTError("mandatory argument \'-mandatory1\' missing");
101 iResult=-EPROTO;
102 }
103 if (iResult>=0 && !bHaveMandatory2) {
104 HLTError("mandatory argument \'-mandatory2\' missing");
105 iResult=-EPROTO;
106 }
107 if (iResult>=0 && !configuration.IsNull()) {
108 iResult=Configure(configuration.Data());
109 } else {
110 iResult=Reconfigure(NULL, NULL);
111 }
112
113 return iResult;
c5318542 114}
115
5045badf 116int AliHLTSampleComponent1::DoDeinit()
117{
f644d3f1 118 // see header file for class documentation
5045badf 119 HLTInfo("processing cleanup");
c5318542 120 return 0;
121}
122
8ede8717 123int AliHLTSampleComponent1::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
124 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
125 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) {
f644d3f1 126 // see header file for class documentation
5045badf 127 HLTInfo("processing data");
f644d3f1 128 if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 &&
129 outputPtr==0 && size==0)
130 {
131 outputBlocks.clear();
132 // this is just to get rid of the warning "unused parameter"
133 }
c5318542 134 return 0;
135}
5045badf 136
137int AliHLTSampleComponent1::Configure(const char* arguments)
138{
139 // see header file for class documentation
140 int iResult=0;
141 if (!arguments) return iResult;
142 HLTInfo("parsing configuration string \'%s\'", arguments);
143
144 TString allArgs=arguments;
145 TString argument;
146 int bMissingParam=0;
147
148 TObjArray* pTokens=allArgs.Tokenize(" ");
149 if (pTokens) {
150 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
151 argument=((TObjString*)pTokens->At(i))->GetString();
152 if (argument.IsNull()) continue;
153
154 // -config1
155 if (argument.CompareTo("-config1")==0) {
156 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
157 HLTInfo("got \'-config1\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
158
159 // -config2
160 } else if (argument.CompareTo("-config2")==0) {
161 HLTInfo("got \'-config2\'");
162 } else {
163 HLTError("unknown argument %s", argument.Data());
164 iResult=-EINVAL;
165 break;
166 }
167 }
168 delete pTokens;
169 }
170 if (bMissingParam) {
171 HLTError("missing parameter for argument %s", argument.Data());
172 iResult=-EINVAL;
173 }
174 return iResult;
175}
176
177int AliHLTSampleComponent1::Reconfigure(const char* cdbEntry, const char* chainId)
178{
179 // see header file for class documentation
180 int iResult=0;
181 const char* path="HLT/ConfigSample/SampleComponent1";
182 const char* defaultNotify="";
183 if (cdbEntry) {
184 path=cdbEntry;
185 defaultNotify=" (default)";
186 }
187 if (path) {
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()*/);
190 if (pEntry) {
191 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
192 if (pString) {
193 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
194 iResult=Configure(pString->GetString().Data());
195 } else {
196 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
197 }
198 } else {
199 HLTError("can not fetch object \"%s\" from CDB", path);
200 }
201 }
202 return iResult;
203}
b543e186 204
205int AliHLTSampleComponent1::ReadPreprocessorValues(const char* modules)
206{
207 // see header file for class documentation
208 int iResult=0;
209 TString detectors(modules!=NULL?modules:"");
210 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
211 return iResult;
212}