]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EMCAL/AliHLTEMCALTrackerComponent.cxx
### files: AliTPCTempMap.h (.cxx)
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALTrackerComponent.cxx
CommitLineData
4a8f32a0 1/**************************************************************************
a558187d 2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
4a8f32a0 4 * *
a558187d 5 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
6 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
7 * for The ALICE HLT Project. *
4a8f32a0 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
a558187d 19 @author Mateusz Ploskon
4a8f32a0 20 @date
a558187d 21 @brief EMCAL tracker component for HLT. */
4a8f32a0 22
a558187d 23#if __GNUC__== 3
4a8f32a0 24using namespace std;
25#endif
26
4a8f32a0 27#include "AliHLTEMCALTrackerComponent.h"
28#include "AliHLTEMCALDefinitions.h"
a558187d 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"
4a8f32a0 36#include "AliCDBManager.h"
a558187d 37#include "AliRawReaderMemory.h"
4a8f32a0 38#include "AliESDEvent.h"
4a8f32a0 39
40// this is a global object used for automatic component registration, do not use this
41AliHLTEMCALTrackerComponent gAliHLTEMCALTrackerComponent;
42
a558187d 43/** ROOT macro for the implementation of ROOT specific class methods */
44ClassImp(AliHLTEMCALTrackerComponent)
45
4a8f32a0 46AliHLTEMCALTrackerComponent::AliHLTEMCALTrackerComponent()
47 : AliHLTProcessor()
a558187d 48 , fOutputPercentage(100)
49 , fStorageDBpath("local://$ALICE_ROOT")
4a8f32a0 50 , fCDB(NULL)
4a8f32a0 51 , fGeometryFileName("")
4a8f32a0 52{
a558187d 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}
4a8f32a0 59
a558187d 60AliHLTEMCALTrackerComponent::AliHLTEMCALTrackerComponent(const AliHLTEMCALTrackerComponent &/*c*/)
61 : AliHLTProcessor()
62 , fOutputPercentage(100)
63 , fStorageDBpath("local://$ALICE_ROOT")
64 , fCDB(NULL)
65 , fGeometryFileName("")
66{
67 // may not use the copy contructor
68 HLTError("May not use.");
4a8f32a0 69}
70
a558187d 71AliHLTEMCALTrackerComponent& AliHLTEMCALTrackerComponent::operator=(const AliHLTEMCALTrackerComponent&)
4a8f32a0 72{
a558187d 73 // may not use the copy contructor
74 HLTError("May not use.");
75 return *this;
4a8f32a0 76}
77
a558187d 78AliHLTEMCALTrackerComponent::~AliHLTEMCALTrackerComponent()
4a8f32a0 79{
a558187d 80 // see header file for class documentation
4a8f32a0 81}
82
a558187d 83AliHLTComponentDataType AliHLTEMCALTrackerComponent::GetOutputDataType()
4a8f32a0 84{
a558187d 85 //return AliHLTEMCALDefinitions::fgkClusterDataType | AliHLTEMCALDefinitions::fgkDigitDataType;
86 return AliHLTEMCALDefinitions::fgkClusterDataType;
4a8f32a0 87}
88
a558187d 89const char* AliHLTEMCALTrackerComponent::GetComponentID()
90{
91 return "EMCALTracker";
92}
93
94void AliHLTEMCALTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
4a8f32a0 95{
a558187d 96 list.push_back(kAliHLTAnyDataType);
4a8f32a0 97}
98
a558187d 99void AliHLTEMCALTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
4a8f32a0 100{
4a8f32a0 101 constBase = 0;
102 inputMultiplier = ((double)fOutputPercentage)/100.0;
103}
104
4a8f32a0 105int AliHLTEMCALTrackerComponent::DoInit( int argc, const char** argv )
106{
a558187d 107 // see header file for class documentation
108 int iResult=0;
109 HLTInfo("parsing %d arguments", argc);
4a8f32a0 110
a558187d 111 TString argument="";
112 TString configuration="";
113 int bMissingParam=0;
114 bool bHaveMandatory1=false;
115 bool bHaveMandatory2=false;
4a8f32a0 116
a558187d 117 char *cpErr = 0;
4a8f32a0 118
a558187d 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 }
4a8f32a0 161
a558187d 162 if (bMissingParam)
4a8f32a0 163 {
a558187d 164 HLTError("missing parameter for argument %s", argument.Data());
165 iResult=-EINVAL;
4a8f32a0 166 }
a558187d 167
168 if (iResult>=0 && !bHaveMandatory1)
4a8f32a0 169 {
a558187d 170 HLTError("mandatory argument \'-cdb\' missing");
171 iResult=-EPROTO;
4a8f32a0 172 }
a558187d 173
174 if (iResult>=0 && !bHaveMandatory2)
4a8f32a0 175 {
a558187d 176 HLTError("mandatory argument \'-geometry\' missing");
177 iResult=-EPROTO;
4a8f32a0 178 }
a558187d 179
180 if (iResult>=0 && !configuration.IsNull())
4a8f32a0 181 {
a558187d 182 iResult=Configure(configuration.Data());
183 }
184 else
185 {
186 iResult=Reconfigure(NULL, NULL);
4a8f32a0 187 }
a558187d 188
189 // Initialize here
190 // raw reader
4a8f32a0 191
a558187d 192 // geometry
193 if (AliHLTEMCALUtils::GetGeometry() == NULL)
194 {
195 HLTError("unable to init geometry");
196 iResult=-EPROTO;
197 }
4a8f32a0 198
a558187d 199 // OCDB
4a8f32a0 200
a558187d 201 // tracker and raw utils
202 if (AliHLTEMCALUtils::GetRawUtils() == NULL)
203 {
204 HLTError("unable to init rawutils");
205 iResult=-EPROTO;
206 }
4a8f32a0 207
a558187d 208 if (AliHLTEMCALUtils::GetRawUtils() == NULL)
4a8f32a0 209 {
a558187d 210 HLTError("unable to init rawutils");
211 iResult=-EPROTO;
4a8f32a0 212 }
213
a558187d 214 if (AliHLTEMCALUtils::GetRecParam() == NULL)
215 {
216 HLTError("unable to init reco params");
217 iResult=-EPROTO;
218 }
219
220 return iResult;
221}
4a8f32a0 222
a558187d 223int AliHLTEMCALTrackerComponent::DoDeinit()
224{
225 // see header file for class documentation
226 AliHLTEMCALUtils::Cleanup();
227 HLTInfo("processing cleanup");
4a8f32a0 228 return 0;
229}
230
231int AliHLTEMCALTrackerComponent::DoEvent( const AliHLTComponentEventData & evtData,
232 AliHLTComponentTriggerData & trigData )
233{
a558187d 234 //
235 // see header file for class documentation
236 //
4a8f32a0 237
a558187d 238 // check if the input data are there at all - empty events possible
239
240 HLTDebug("HLT::TRDTracker::DoEvent", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt );
4a8f32a0 241
242 //implement a usage of the following
a558187d 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)
4a8f32a0 265 {
a558187d 266 clustersTree = (TTree*)tobjin;
4a8f32a0 267 }
a558187d 268
269 tobjin = (TObject *)GetFirstInputObject( AliHLTEMCALDefinitions::fgkDigitDataType, "TTree", ibForce);
270 if (tobjin)
4a8f32a0 271 {
a558187d 272 digitsTree = (TTree*)tobjin;
4a8f32a0 273 }
274
a558187d 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 }
4a8f32a0 283
a558187d 284 if (digitsTree != 0 && clustersTree != 0 && esd != 0)
4a8f32a0 285 {
a558187d 286 Bool_t retValue = AliHLTEMCALUtils::FillESD(digitsTree, clustersTree, esd);
287
288 if (retValue == kTRUE)
4a8f32a0 289 {
a558187d 290 PushBack(esd, AliHLTEMCALDefinitions::fgkEMCALESDDataType);
291 }
292 else
293 {
294 HLTWarning("Fill ESD failed.");
4a8f32a0 295 }
296 }
a558187d 297
298 if (clustersTree)
299 delete clustersTree;
4a8f32a0 300
a558187d 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)
4a8f32a0 323 {
a558187d 324 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++)
4a8f32a0 325 {
a558187d 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 }
4a8f32a0 352 }
a558187d 353 delete pTokens;
4a8f32a0 354 }
355
a558187d 356 if (bMissingParam)
4a8f32a0 357 {
a558187d 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)";
4a8f32a0 375 }
a558187d 376 if (path)
4a8f32a0 377 {
a558187d 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 }
4a8f32a0 396 }
a558187d 397 return iResult;
398}
4a8f32a0 399
a558187d 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;
4a8f32a0 407}