]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/OnlineAnalysis/AliHLTMUONFullTrackerComponent.cxx
including extra debugging message
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONFullTrackerComponent.cxx
CommitLineData
52c6d8aa 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
4 * Permission to use, copy, modify and distribute this software and its *
5 * documentation strictly for non-commercial purposes is hereby granted *
6 * without fee, provided that the above copyright notice appears in all *
7 * copies and that both the copyright notice and this permission notice *
8 * appear in the supporting documentation. The authors make no claims *
9 * about the suitability of this software for any purpose. It is *
10 * provided "as is" without express or implied warranty. *
11 **************************************************************************/
12//-----------------------------------------------------------------------------
13/// \class AliHLTMUONFullTrackerComponent
14///
15/// Component class for full tracker, see the detail description
16/// of the full tracker in the full tracker header file
17/// \author :Indranil Das, email : indra.das@saha.ac.in | indra.ehep@gmail.com , Saha Institute of Nuclear Physics
18//-----------------------------------------------------------------------------
19
52c6d8aa 20#include "AliHLTMUONFullTrackerComponent.h"
21#include "TString.h"
22#include "TObjString.h"
23#include "TObjArray.h"
24#include "AliCDBEntry.h"
25#include "AliCDBManager.h"
26
27#include "AliHLTDefinitions.h"
28
29#include "AliHLTMUONConstants.h"
30
d24a4636 31#include "AliHLTMUONTracksBlockStruct.h"
52c6d8aa 32
a7f38894 33using namespace std;
34
52c6d8aa 35ClassImp(AliHLTMUONFullTrackerComponent)
36
37AliHLTMUONFullTrackerComponent::AliHLTMUONFullTrackerComponent() :
fd5b812e 38 AliHLTMUONProcessor(),
52c6d8aa 39 fTracker(NULL)
40{
41 // see header file for class documentation
42
43}
44
45AliHLTMUONFullTrackerComponent::~AliHLTMUONFullTrackerComponent()
46{
47 // see header file for class documentation
48
49 if (fTracker != NULL) delete fTracker;
50}
51
52const char* AliHLTMUONFullTrackerComponent::GetComponentID()
53{
54 // see header file for class documentation
55 return AliHLTMUONConstants::FullTrackerId();
56}
57
58void AliHLTMUONFullTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
59{
60 // see header file for class documentation
61 /* in order to be backward compatible we have to keep the old code, at
62 * least for a while. Remember to use the new const kAliHLTVoidDataType
63 * if you are using a more recent AliRoot version (from Jan 07)
64 list.push_back(kAliHLTAnyDataType); // We do not have any requirements for our input data type(s).
65 */
66
67 assert( list.empty() );
68 list.push_back( AliHLTMUONConstants::TriggerRecordsBlockDataType() );
69 list.push_back( AliHLTMUONConstants::RecHitsBlockDataType() );
70
71}
72
73AliHLTComponentDataType AliHLTMUONFullTrackerComponent::GetOutputDataType()
74{
75 // see header file for class documentation
76 /* in order to be backward compatible we have to keep the old code, at
77 * least for a while. Remember to use the new const kAliHLTVoidDataType
78 * if you are using a more recent AliRoot version (from Jan 07)
79 return kAliHLTVoidDataType;
80 */
81 return kAliHLTMultipleDataType;
82
83}
84
85int AliHLTMUONFullTrackerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
86{
87 /// Inherited from AliHLTComponent. Returns the output data types.
88
89 assert( list.empty() );
d24a4636 90 list.push_back( AliHLTMUONConstants::TracksBlockDataType() );
52c6d8aa 91 return list.size();
92}
93
94void AliHLTMUONFullTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
95{
96 // see header file for class documentation
d24a4636 97 constBase = sizeof(AliHLTMUONTracksBlockStruct) + 1024*1024;
52c6d8aa 98 inputMultiplier = 1;
99
100}
101
102
103
104// Spawn function, return new instance of this class
105AliHLTComponent* AliHLTMUONFullTrackerComponent::Spawn()
106{
107 // see header file for class documentation
108 return new AliHLTMUONFullTrackerComponent;
109}
110
111int AliHLTMUONFullTrackerComponent::DoInit( int argc, const char** argv )
112{
aa205fc6 113 // perform initialization
114 bool useFast = false;
fd5b812e 115 int result = AliHLTMUONProcessor::DoInit(argc, argv);
116 if (result != 0) return result;
117
118
119 for (int i = 0; i < argc; i++){
120
121 // To keep the legacy behaviour we need to have the following check
122 // for -cdbpath here, before ArgumentAlreadyHandled.
123 if (ArgumentAlreadyHandled(i, argv[i])) continue;
d24a4636 124
aa205fc6 125 if (strcmp(argv[i], "-usefast") == 0)
126 {
127 useFast = true;
128 }
129
fd5b812e 130 }
131
52c6d8aa 132
133 if (fTracker == NULL)
134 {
135 try
136 {
137 fTracker = new AliHLTMUONFullTracker;
138 }
139 catch (const std::bad_alloc&)
140 {
141 HLTError("Could not allocate a new AliHLTMUONFullTracker object. Ran out of memory.");
142 return -ENOMEM;
143 }
144 }
145
fd5b812e 146 result = FetchMappingStores();
52c6d8aa 147 fTracker->Init();
aa205fc6 148 fTracker->FastTracking(useFast);
fd5b812e 149
52c6d8aa 150 return 0;
151}
152
153int AliHLTMUONFullTrackerComponent::DoDeinit()
154{
155 // see header file for class documentation
156
157 if (fTracker != NULL)
158 {
159 delete fTracker;
160 fTracker = NULL;
161 }
162
163 return 0;
164}
165
166int AliHLTMUONFullTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
167 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
168 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
169{
52c6d8aa 170 // Process an event
171 unsigned long totalSize = 0;
172 AliHLTUInt32_t specification = 0; // Contains the output data block spec bits.
a038ee7d 173 bool resultOk = true;
52c6d8aa 174 // Loop over all input blocks in the event
ed5809f7 175
176 HLTDebug("Processing iEvent %llu with %u input data blocks.",
52c6d8aa 177 evtData.fEventID, evtData.fBlockCnt
ed5809f7 178 );
179
180 if (! IsDataEvent()){
181 size = totalSize;
0fddb3cc 182 resultOk = false;
ed5809f7 183 return 0;
184 }
185
fd5b812e 186 //if(evtData.fBlockCnt==3) return 0;
52c6d8aa 187
d24a4636 188 AliHLTMUONTracksBlockWriter block(outputPtr, size);
189 if (not block.InitCommonHeader())
52c6d8aa 190 {
191 Logging(kHLTLogError,
d24a4636 192 "AliHLTMUONFullTrackerComponent::DoEvent",
52c6d8aa 193 "Buffer overflow",
194 "The buffer is only %d bytes in size. We need a minimum of %d bytes.",
d24a4636 195 size, sizeof(AliHLTMUONTracksBlockWriter::HeaderType)
52c6d8aa 196 );
197 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
198 size = 0; // Important to tell framework that nothing was generated.
a038ee7d 199 resultOk = false;
52c6d8aa 200 return -ENOBUFS;
201 }
d24a4636 202
52c6d8aa 203
204 for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++){
fd5b812e 205
52c6d8aa 206 HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
fd5b812e 207 n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fPtr, blocks[n].fSize
208 );
209
0fddb3cc 210 if (not resultOk) break;
211
52c6d8aa 212 if (blocks[n].fDataType == AliHLTMUONConstants::RecHitsBlockDataType()){
213 specification |= blocks[n].fSpecification;
214
215 AliHLTMUONRecHitsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
216 if (not BlockStructureOk(inblock)){
fd5b812e 217 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
a038ee7d 218 resultOk = false;
52c6d8aa 219 }
fd5b812e 220
0fddb3cc 221 if(resultOk){
222 resultOk = fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification),
223 inblock.GetArray(), inblock.Nentries());
224 }
225
fd5b812e 226
52c6d8aa 227 }else if (blocks[n].fDataType == AliHLTMUONConstants::TriggerRecordsBlockDataType()){
228 specification |= blocks[n].fSpecification;
52c6d8aa 229 AliHLTMUONTriggerRecordsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
230 if (not BlockStructureOk(inblock)){
fd5b812e 231 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
a038ee7d 232 resultOk = false;
52c6d8aa 233 }
234
0fddb3cc 235 if(resultOk){
236 resultOk = fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification),
237 inblock.GetArray(),inblock.Nentries());
238 }
ed5809f7 239
52c6d8aa 240 }//check if trigger block
52c6d8aa 241 }//loop over blocks array of rechit and trigrecs
a038ee7d 242
243 AliHLTUInt32_t nofTracks = 0;
0fddb3cc 244 AliHLTUInt32_t emptyTrackBlockSize = block.BytesUsed();
245 if( resultOk ){
a038ee7d 246 nofTracks = block.MaxNumberOfEntries();
ed5809f7 247 resultOk = fTracker->Run(evtData.fEventID,block.GetArray(), nofTracks);
a038ee7d 248 }
249
fd5b812e 250 if (resultOk){
251 assert( nofTracks <= block.MaxNumberOfEntries() );
252 block.SetNumberOfEntries(nofTracks);
ed5809f7 253
0fddb3cc 254 HLTDebug("Number of reconstructed tracks found is %d, resultOk : %d, emptyTrackBlockSize : %d",
255 nofTracks,resultOk,emptyTrackBlockSize);
256 HLTDebug("sizeof %d", sizeof(AliHLTMUONTrackStruct));
257 HLTDebug("Bytes Used is %d",block.BytesUsed());
258 HLTDebug("Specification is %d", specification);
ed5809f7 259
fd5b812e 260 AliHLTComponentBlockData bd;
261 FillBlockData(bd);
262 bd.fPtr = outputPtr;
263 bd.fOffset = 0;
264 bd.fSize = block.BytesUsed();
0fddb3cc 265 bd.fDataType = AliHLTMUONConstants::TracksBlockDataType() ;
fd5b812e 266 bd.fSpecification = specification;
0fddb3cc 267
fd5b812e 268 outputBlocks.push_back(bd);
0fddb3cc 269
fd5b812e 270 totalSize = block.BytesUsed();
0fddb3cc 271
fd5b812e 272 }else{
0fddb3cc 273
fd5b812e 274 HLTDebug("Error while processing the full tracker algorithm.");
275 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
0fddb3cc 276
277 HLTDebug("Number of reconstructed tracks found is %d, resultOk : %d, emptyTrackBlockSize : %d",
278 nofTracks,resultOk,emptyTrackBlockSize);
279 HLTDebug("sizeof %d", sizeof(AliHLTMUONTrackStruct));
280 HLTDebug("Bytes Used is %d",block.BytesUsed());
281 HLTDebug("Specification is %d", specification);
282
283 AliHLTComponentBlockData bd;
284 FillBlockData(bd);
285 bd.fPtr = outputPtr;
286 bd.fOffset = 0;
287 bd.fSize = emptyTrackBlockSize;
288 bd.fDataType = AliHLTMUONConstants::TracksBlockDataType() ;
289 bd.fSpecification = specification;
290
291 outputBlocks.push_back(bd);
292
293 totalSize = emptyTrackBlockSize;
294
fd5b812e 295 //return -EIO;
fd5b812e 296 }
52c6d8aa 297
298 // Finally we set the total size of output memory we consumed.
0fddb3cc 299 size = totalSize; // Must tell the framework how much buffer space was used.
52c6d8aa 300 return 0;
301
302}
303
304
305int AliHLTMUONFullTrackerComponent::Configure(const char* arguments)
306{
307 // see header file for class documentation
308 int iResult=0;
309 if (!arguments) return iResult;
310 HLTInfo("parsing configuration string \'%s\'", arguments);
311
312 TString allArgs=arguments;
313 TString argument;
314 int bMissingParam=0;
315
316 TObjArray* pTokens=allArgs.Tokenize(" ");
317 if (pTokens) {
318 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
319 argument=((TObjString*)pTokens->At(i))->GetString();
320 if (argument.IsNull()) continue;
321
322 // -config1
323 if (argument.CompareTo("-config1")==0) {
324 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
325 HLTInfo("got \'-config1\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
326
327 // -config2
328 } else if (argument.CompareTo("-config2")==0) {
329 HLTInfo("got \'-config2\'");
330 } else {
331 HLTError("unknown argument %s", argument.Data());
332 iResult=-EINVAL;
333 break;
334 }
335 }
336 delete pTokens;
337 }
338 if (bMissingParam) {
339 HLTError("missing parameter for argument %s", argument.Data());
340 iResult=-EINVAL;
341 }
342 return iResult;
343}
344
345int AliHLTMUONFullTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
346{
347 // see header file for class documentation
348 int iResult=0;
349 const char* path="HLT/ConfigSample/FullTrackerComponent";
350 const char* defaultNotify="";
351 if (cdbEntry) {
352 path=cdbEntry;
353 defaultNotify=" (default)";
354 }
355 if (path) {
356 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
357 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
358 if (pEntry) {
359 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
360 if (pString) {
361 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
362 iResult=Configure(pString->GetString().Data());
363 } else {
364 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
365 }
366 } else {
367 HLTError("can not fetch object \"%s\" from CDB", path);
368 }
369 }
370 return iResult;
371}
372
373int AliHLTMUONFullTrackerComponent::ReadPreprocessorValues(const char* modules)
374{
375 // see header file for class documentation
376 int iResult=0;
377 TString detectors(modules!=NULL?modules:"");
378 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
379 return iResult;
380}