1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
5 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
6 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
7 * for The ALICE HLT Project. *
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 **************************************************************************/
18 /** @file AliHLTEMCALTrackerComponent.cxx
19 @author Mateusz Ploskon
21 @brief EMCAL tracker component for HLT. */
27 #include "AliHLTEMCALTrackerComponent.h"
28 #include "AliHLTEMCALDefinitions.h"
29 #include "AliHLTEMCALUtils.h"
32 #include "TObjString.h"
33 #include "TObjArray.h"
35 #include "AliCDBEntry.h"
36 #include "AliCDBManager.h"
37 #include "AliRawReaderMemory.h"
38 #include "AliESDEvent.h"
40 // this is a global object used for automatic component registration, do not use this
41 AliHLTEMCALTrackerComponent gAliHLTEMCALTrackerComponent;
43 /** ROOT macro for the implementation of ROOT specific class methods */
44 ClassImp(AliHLTEMCALTrackerComponent)
46 AliHLTEMCALTrackerComponent::AliHLTEMCALTrackerComponent()
48 , fOutputPercentage(100)
49 , fStorageDBpath("local://$ALICE_ROOT/OCDB")
51 , fGeometryFileName("")
53 // see header file for class documentation
55 // refer to README to build package
57 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
60 AliHLTEMCALTrackerComponent::AliHLTEMCALTrackerComponent(const AliHLTEMCALTrackerComponent &/*c*/)
62 , fOutputPercentage(100)
63 , fStorageDBpath("local://$ALICE_ROOT/OCDB")
65 , fGeometryFileName("")
67 // may not use the copy contructor
68 HLTError("May not use.");
71 AliHLTEMCALTrackerComponent& AliHLTEMCALTrackerComponent::operator=(const AliHLTEMCALTrackerComponent&)
73 // may not use the copy contructor
74 HLTError("May not use.");
78 AliHLTEMCALTrackerComponent::~AliHLTEMCALTrackerComponent()
80 // see header file for class documentation
83 AliHLTComponentDataType AliHLTEMCALTrackerComponent::GetOutputDataType()
85 //return AliHLTEMCALDefinitions::fgkClusterDataType | AliHLTEMCALDefinitions::fgkDigitDataType;
86 return AliHLTEMCALDefinitions::fgkClusterDataType;
89 const char* AliHLTEMCALTrackerComponent::GetComponentID()
91 return "EMCALTracker";
94 void AliHLTEMCALTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
96 list.push_back(kAliHLTAnyDataType);
99 void AliHLTEMCALTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
102 inputMultiplier = ((double)fOutputPercentage)/100.0;
105 int AliHLTEMCALTrackerComponent::DoInit( int argc, const char** argv )
107 // see header file for class documentation
109 HLTInfo("parsing %d arguments", argc);
112 TString configuration="";
114 bool bHaveMandatory1=false;
115 bool bHaveMandatory2=false;
119 for (int i=0; i<argc && iResult>=0; i++)
122 if (argument.IsNull()) continue;
125 if (argument.CompareTo("-cdb")==0)
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());
134 else if (argument.CompareTo("-geometry")==0)
137 if ((bMissingParam=(++i>=argc))) break;
138 HLTInfo("got \'-geometry\' argument");
139 fGeometryFileName = argv[i];
140 HLTInfo("Geometry file is: %s", fGeometryFileName.c_str());
143 else if (argument.CompareTo("-output_percentage")==0)
145 if ((bMissingParam=(++i>=argc))) break;
146 HLTInfo("got \'-output_percentage\' argument: %s", argv[i]);
147 fOutputPercentage = strtoul(argv[i], &cpErr, 0);
150 HLTError("Unable to convert ouput_percentage to a number %s", argv[i]);
156 // the remaining arguments are treated as configuration
157 if (!configuration.IsNull()) configuration+=" ";
158 configuration+=argument;
164 HLTError("missing parameter for argument %s", argument.Data());
168 if (iResult>=0 && !bHaveMandatory1)
170 HLTError("mandatory argument \'-cdb\' missing");
174 if (iResult>=0 && !bHaveMandatory2)
176 HLTError("mandatory argument \'-geometry\' missing");
180 if (iResult>=0 && !configuration.IsNull())
182 iResult=Configure(configuration.Data());
186 iResult=Reconfigure(NULL, NULL);
193 if (AliHLTEMCALUtils::GetGeometry() == NULL)
195 HLTError("unable to init geometry");
201 // tracker and raw utils
202 if (AliHLTEMCALUtils::GetRawUtils() == NULL)
204 HLTError("unable to init rawutils");
208 if (AliHLTEMCALUtils::GetRawUtils() == NULL)
210 HLTError("unable to init rawutils");
214 if (AliHLTEMCALUtils::GetRecParam() == NULL)
216 HLTError("unable to init reco params");
223 int AliHLTEMCALTrackerComponent::DoDeinit()
225 // see header file for class documentation
226 AliHLTEMCALUtils::Cleanup();
227 HLTInfo("processing cleanup");
231 int AliHLTEMCALTrackerComponent::DoEvent( const AliHLTComponentEventData & /*evtData*/,
232 AliHLTComponentTriggerData & /*trigData*/ )
235 // see header file for class documentation
238 // check if the input data are there at all - empty events possible
240 HLTDebug("HLT::TRDTracker::DoEvent", "BLOCKS", "NofBlocks %lu", GetNumberOfInputBlocks() );
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);
248 // another way to check the blocks
249 // AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTEMCALDefinitions::fgkClusterDataType );
252 // HLTError(Form("First Input Block not found! 0x%x", dblock));
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;
263 tobjin = (TObject *)GetFirstInputObject( AliHLTEMCALDefinitions::fgkClusterDataType, "TTree", ibForce);
266 clustersTree = (TTree*)tobjin;
269 tobjin = (TObject *)GetFirstInputObject( AliHLTEMCALDefinitions::fgkDigitDataType, "TTree", ibForce);
272 digitsTree = (TTree*)tobjin;
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);
281 esd = (AliESDEvent*)tobjin;
284 if (digitsTree != 0 && clustersTree != 0 && esd != 0)
286 Bool_t retValue = AliHLTEMCALUtils::FillESD(digitsTree, clustersTree, esd);
288 if (retValue == kTRUE)
290 PushBack(esd, AliHLTEMCALDefinitions::fgkEMCALESDDataType);
294 HLTWarning("Fill ESD failed.");
310 int AliHLTEMCALTrackerComponent::Configure(const char* arguments)
312 // see header file for class documentation
314 if (!arguments) return iResult;
315 HLTInfo("parsing configuration string \'%s\'", arguments);
317 TString allArgs = arguments;
321 TObjArray* pTokens = allArgs.Tokenize(" ");
324 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++)
326 argument=((TObjString*)pTokens->At(i))->GetString();
327 if (argument.IsNull()) continue;
328 HLTInfo("processing argument %\n", argument.Data());
330 if (argument.CompareTo("-cdb")==0)
332 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
333 HLTInfo("got \'-cdb\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
336 else if (argument.CompareTo("-geometry")==0)
338 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
339 HLTInfo("got \'-geometry\'");
341 else if (argument.CompareTo("-output_percentage")==0)
343 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
344 HLTInfo("got \'-output_percentage\'");
348 HLTError("unknown argument %s", argument.Data());
358 HLTError("missing parameter for argument %s", argument.Data());
365 int AliHLTEMCALTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
367 // see header file for class documentation
369 const char* path="HLT/ConfigEMCAL/EMCALTrackerComponent";
370 const char* defaultNotify="";
374 defaultNotify=" (default)";
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()*/);
382 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
385 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
386 iResult=Configure(pString->GetString().Data());
389 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
394 HLTError("can not fetch object \"%s\" from CDB", path);
400 int AliHLTEMCALTrackerComponent::ReadPreprocessorValues(const char* modules)
402 // see header file for class documentation
404 TString detectors(modules!=NULL?modules:"");
405 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());