]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/EMCAL/AliHLTEMCALTrackerComponent.cxx
Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALTrackerComponent.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
6 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
7 * for The ALICE HLT Project. *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
18/** @file AliHLTEMCALTrackerComponent.cxx
19 @author Mateusz Ploskon
20 @date
21 @brief EMCAL tracker component for HLT. */
22
23#if __GNUC__== 3
24using namespace std;
25#endif
26
27#include "AliHLTEMCALTrackerComponent.h"
28#include "AliHLTEMCALDefinitions.h"
29#include "AliHLTEMCALUtils.h"
30
31#include "TString.h"
32#include "TObjString.h"
33#include "TObjArray.h"
34#include "TTree.h"
35#include "AliCDBEntry.h"
36#include "AliCDBManager.h"
37#include "AliRawReaderMemory.h"
38#include "AliESDEvent.h"
39
40// this is a global object used for automatic component registration, do not use this
41AliHLTEMCALTrackerComponent gAliHLTEMCALTrackerComponent;
42
43/** ROOT macro for the implementation of ROOT specific class methods */
44ClassImp(AliHLTEMCALTrackerComponent)
45
46AliHLTEMCALTrackerComponent::AliHLTEMCALTrackerComponent()
47 : AliHLTProcessor()
48 , fOutputPercentage(100)
49 , fStorageDBpath("local://$ALICE_ROOT/OCDB")
50 , fCDB(NULL)
51 , fGeometryFileName("")
52{
53 // see header file for class documentation
54 // or
55 // refer to README to build package
56 // or
57 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
58}
59
60AliHLTEMCALTrackerComponent::AliHLTEMCALTrackerComponent(const AliHLTEMCALTrackerComponent &/*c*/)
61 : AliHLTProcessor()
62 , fOutputPercentage(100)
63 , fStorageDBpath("local://$ALICE_ROOT/OCDB")
64 , fCDB(NULL)
65 , fGeometryFileName("")
66{
67 // may not use the copy contructor
68 HLTError("May not use.");
69}
70
71AliHLTEMCALTrackerComponent& AliHLTEMCALTrackerComponent::operator=(const AliHLTEMCALTrackerComponent&)
72{
73 // may not use the copy contructor
74 HLTError("May not use.");
75 return *this;
76}
77
78AliHLTEMCALTrackerComponent::~AliHLTEMCALTrackerComponent()
79{
80 // see header file for class documentation
81}
82
83AliHLTComponentDataType AliHLTEMCALTrackerComponent::GetOutputDataType()
84{
85 //return AliHLTEMCALDefinitions::fgkClusterDataType | AliHLTEMCALDefinitions::fgkDigitDataType;
86 return AliHLTEMCALDefinitions::fgkClusterDataType;
87}
88
89const char* AliHLTEMCALTrackerComponent::GetComponentID()
90{
91 return "EMCALTracker";
92}
93
94void AliHLTEMCALTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
95{
96 list.push_back(kAliHLTAnyDataType);
97}
98
99void AliHLTEMCALTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
100{
101 constBase = 0;
102 inputMultiplier = ((double)fOutputPercentage)/100.0;
103}
104
105int AliHLTEMCALTrackerComponent::DoInit( int argc, const char** argv )
106{
107 // see header file for class documentation
108 int iResult=0;
109 HLTInfo("parsing %d arguments", argc);
110
111 TString argument="";
112 TString configuration="";
113 int bMissingParam=0;
114 bool bHaveMandatory1=false;
115 bool bHaveMandatory2=false;
116
117 char *cpErr = 0;
118
119 for (int i=0; i<argc && iResult>=0; i++)
120 {
121 argument=argv[i];
122 if (argument.IsNull()) continue;
123
124 // -mandatory1
125 if (argument.CompareTo("-cdb")==0)
126 {
127 bHaveMandatory1|=1;
128 if ((bMissingParam=(++i>=argc))) break;
129 HLTInfo("got \'-cdb\' argument: %s", argv[i]);
130 fStorageDBpath = argv[i];
131 HLTInfo("CDB path is: %s", fStorageDBpath.c_str());
132 // -mandatory2
133 }
134 else if (argument.CompareTo("-geometry")==0)
135 {
136 bHaveMandatory2|=1;
137 if ((bMissingParam=(++i>=argc))) break;
138 HLTInfo("got \'-geometry\' argument");
139 fGeometryFileName = argv[i];
140 HLTInfo("Geometry file is: %s", fGeometryFileName.c_str());
141 // -optional1
142 }
143 else if (argument.CompareTo("-output_percentage")==0)
144 {
145 if ((bMissingParam=(++i>=argc))) break;
146 HLTInfo("got \'-output_percentage\' argument: %s", argv[i]);
147 fOutputPercentage = strtoul(argv[i], &cpErr, 0);
148 if ( *cpErr )
149 {
150 HLTError("Unable to convert ouput_percentage to a number %s", argv[i]);
151 return -EINVAL;
152 }
153 }
154 else
155 {
156 // the remaining arguments are treated as configuration
157 if (!configuration.IsNull()) configuration+=" ";
158 configuration+=argument;
159 }
160 }
161
162 if (bMissingParam)
163 {
164 HLTError("missing parameter for argument %s", argument.Data());
165 iResult=-EINVAL;
166 }
167
168 if (iResult>=0 && !bHaveMandatory1)
169 {
170 HLTError("mandatory argument \'-cdb\' missing");
171 iResult=-EPROTO;
172 }
173
174 if (iResult>=0 && !bHaveMandatory2)
175 {
176 HLTError("mandatory argument \'-geometry\' missing");
177 iResult=-EPROTO;
178 }
179
180 if (iResult>=0 && !configuration.IsNull())
181 {
182 iResult=Configure(configuration.Data());
183 }
184 else
185 {
186 iResult=Reconfigure(NULL, NULL);
187 }
188
189 // Initialize here
190 // raw reader
191
192 // geometry
193 if (AliHLTEMCALUtils::GetGeometry() == NULL)
194 {
195 HLTError("unable to init geometry");
196 iResult=-EPROTO;
197 }
198
199 // OCDB
200
201 // tracker and raw utils
202 if (AliHLTEMCALUtils::GetRawUtils() == NULL)
203 {
204 HLTError("unable to init rawutils");
205 iResult=-EPROTO;
206 }
207
208 if (AliHLTEMCALUtils::GetRawUtils() == NULL)
209 {
210 HLTError("unable to init rawutils");
211 iResult=-EPROTO;
212 }
213
214 if (AliHLTEMCALUtils::GetRecParam() == NULL)
215 {
216 HLTError("unable to init reco params");
217 iResult=-EPROTO;
218 }
219
220 return iResult;
221}
222
223int AliHLTEMCALTrackerComponent::DoDeinit()
224{
225 // see header file for class documentation
226 AliHLTEMCALUtils::Cleanup();
227 HLTInfo("processing cleanup");
228 return 0;
229}
230
231int AliHLTEMCALTrackerComponent::DoEvent( const AliHLTComponentEventData & /*evtData*/,
232 AliHLTComponentTriggerData & /*trigData*/ )
233{
234 //
235 // see header file for class documentation
236 //
237
238 // check if the input data are there at all - empty events possible
239
240 HLTDebug("HLT::TRDTracker::DoEvent", "BLOCKS", "NofBlocks %lu", GetNumberOfInputBlocks() );
241
242 //implement a usage of the following
243 // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
244 // AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
245 // void *triggerData = trigData.fData;
246 //HLTDebug("Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
247
248 // another way to check the blocks
249 // AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTEMCALDefinitions::fgkClusterDataType );
250 // if (dblock == 0)
251 // {
252 // HLTError(Form("First Input Block not found! 0x%x", dblock));
253 // return -1;
254 // }
255
256 // all those should be received by the component
257 AliESDEvent *esd = 0; // we assume we receive this one from a global merger component
258 TTree *clustersTree = 0;
259 TTree *digitsTree = 0;
260
261 Int_t ibForce = 0;
262 TObject *tobjin = 0;
263 tobjin = (TObject *)GetFirstInputObject( AliHLTEMCALDefinitions::fgkClusterDataType, "TTree", ibForce);
264 if (tobjin)
265 {
266 clustersTree = (TTree*)tobjin;
267 }
268
269 tobjin = (TObject *)GetFirstInputObject( AliHLTEMCALDefinitions::fgkDigitDataType, "TTree", ibForce);
270 if (tobjin)
271 {
272 digitsTree = (TTree*)tobjin;
273 }
274
275 // the data type used here is a prototype
276 // esd eventually should come from TPC alone or TPC+TRD matched tracks
277 // check the AliHLTEMCALDefinitions for extra comments
278 tobjin = (TObject *)GetFirstInputObject( AliHLTEMCALDefinitions::fgkESDDataType, "TTree", ibForce);
279 if (tobjin)
280 {
281 esd = (AliESDEvent*)tobjin;
282 }
283
284 if (digitsTree != 0 && clustersTree != 0 && esd != 0)
285 {
286 Bool_t retValue = AliHLTEMCALUtils::FillESD(digitsTree, clustersTree, esd);
287
288 if (retValue == kTRUE)
289 {
290 PushBack(esd, AliHLTEMCALDefinitions::fgkEMCALESDDataType);
291 }
292 else
293 {
294 HLTWarning("Fill ESD failed.");
295 }
296 }
297
298 if (clustersTree)
299 delete clustersTree;
300
301 if (digitsTree)
302 delete digitsTree;
303
304 if (esd)
305 delete esd;
306
307 return 0;
308}
309
310int AliHLTEMCALTrackerComponent::Configure(const char* arguments)
311{
312 // see header file for class documentation
313 int iResult=0;
314 if (!arguments) return iResult;
315 HLTInfo("parsing configuration string \'%s\'", arguments);
316
317 TString allArgs = arguments;
318 TString argument;
319 int bMissingParam=0;
320
321 TObjArray* pTokens = allArgs.Tokenize(" ");
322 if (pTokens)
323 {
324 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++)
325 {
326 argument=((TObjString*)pTokens->At(i))->GetString();
327 if (argument.IsNull()) continue;
328 HLTInfo("processing argument %\n", argument.Data());
329 // -config1
330 if (argument.CompareTo("-cdb")==0)
331 {
332 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
333 HLTInfo("got \'-cdb\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
334 // -config2
335 }
336 else if (argument.CompareTo("-geometry")==0)
337 {
338 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
339 HLTInfo("got \'-geometry\'");
340 }
341 else if (argument.CompareTo("-output_percentage")==0)
342 {
343 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
344 HLTInfo("got \'-output_percentage\'");
345 }
346 else
347 {
348 HLTError("unknown argument %s", argument.Data());
349 iResult=-EINVAL;
350 break;
351 }
352 }
353 delete pTokens;
354 }
355
356 if (bMissingParam)
357 {
358 HLTError("missing parameter for argument %s", argument.Data());
359 iResult=-EINVAL;
360 }
361
362 return iResult;
363}
364
365int AliHLTEMCALTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
366{
367 // see header file for class documentation
368 int iResult=0;
369 const char* path="HLT/ConfigEMCAL/EMCALTrackerComponent";
370 const char* defaultNotify="";
371 if (cdbEntry)
372 {
373 path=cdbEntry;
374 defaultNotify=" (default)";
375 }
376 if (path)
377 {
378 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
379 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
380 if (pEntry)
381 {
382 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
383 if (pString)
384 {
385 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
386 iResult=Configure(pString->GetString().Data());
387 } else
388 {
389 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
390 }
391 }
392 else
393 {
394 HLTError("can not fetch object \"%s\" from CDB", path);
395 }
396 }
397 return iResult;
398}
399
400int AliHLTEMCALTrackerComponent::ReadPreprocessorValues(const char* modules)
401{
402 // see header file for class documentation
403 int iResult=0;
404 TString detectors(modules!=NULL?modules:"");
405 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
406 return iResult;
407}