]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/AliHLTMUONProcessor.cxx
Preventing automatic compilation of trace statements into debug build.
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONProcessor.cxx
CommitLineData
154cba94 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
4 * *
5 * Primary Authors: *
6 * Artur Szostak <artursz@iafrica.com> *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/* $Id: $ */
18
19///
20/// @file AliHLTMUONProcessor.cxx
21/// @author Artur Szostak <artursz@iafrica.com>
dba14d7d 22/// @date 19 May 2008
154cba94 23/// @brief Implementation of the abstract base dHLT processor component.
24///
25/// This component is the abstract base class of dHLT specific components.
26/// It implements some common methods used by all the dHLT components.
27///
28
29#include "AliHLTMUONProcessor.h"
17d68f2a 30#include "AliMUONRecoParam.h"
dba14d7d 31#include "AliCDBManager.h"
32#include "AliCDBStorage.h"
ffc1a6f6 33#include "AliCDBEntry.h"
dba14d7d 34#include "AliMpCDB.h"
35#include "AliMpDDLStore.h"
36#include "AliMpDEStore.h"
ffc1a6f6 37#include "TMap.h"
38#include "TObjString.h"
39#include "TString.h"
ffb64d3e 40#include <string>
41#include <cstdlib>
42#include <fstream>
43
154cba94 44
45ClassImp(AliHLTMUONProcessor)
46
dba14d7d 47
ffb64d3e 48AliHLTMUONProcessor::AliHLTMUONProcessor() :
49 AliHLTProcessor(),
50 fWarnForUnexpecedBlock(false),
51 fDelaySetup(false),
52 fDumpDataOnError(false),
53 fDumpPath("./")
54{
55 /// Default constructor.
56}
57
58
59int AliHLTMUONProcessor::DoInit(int argc, const char** argv)
60{
61 /// Parses common dHLT component arguments.
62
63 // Set the default values for various arguments comming from the command line.
64 fDelaySetup = false;
65 fDumpDataOnError = false;
66 fDumpPath = "./";
67 const char* cdbPath = NULL;
68 Int_t run = -1;
69
70 for (int i = 0; i < argc; i++)
71 {
72 // Ignore the argument if the child class indicates to do so.
73 if (IgnoreArgument(argv[i])) continue;
74
75 if (strcmp(argv[i], "-cdbpath") == 0)
76 {
77 if (cdbPath != NULL)
78 {
79 HLTWarning("CDB path was already specified. Will"
80 " replace previous value given by -cdbpath."
81 );
82 }
83 if (argc <= i+1)
84 {
85 HLTError("The CDB path was not specified." );
86 return -EINVAL;
87 }
88 cdbPath = argv[i+1];
89 i++;
90 continue;
91 }
92
93 if (strcmp(argv[i], "-run") == 0)
94 {
95 if (run != -1)
96 {
97 HLTWarning("Run number was already specified. Will"
98 " replace previous value given by -run."
99 );
100 }
101 if (argc <= i+1)
102 {
103 HLTError("The run number was not specified.");
104 return -EINVAL;
105 }
106
107 char* cpErr = NULL;
108 run = Int_t( strtol(argv[i+1], &cpErr, 0) );
109 if (cpErr == NULL or *cpErr != '\0' or run < 0)
110 {
111 HLTError("Cannot convert '%s' to a valid run number."
112 " Expected a positive integer value.", argv[i+1]
113 );
114 return -EINVAL;
115 }
116
117 i++;
118 continue;
119 }
120
121 if (strcmp(argv[i], "-delaysetup") == 0)
122 {
123 fDelaySetup = true;
124 continue;
125 }
126
127 if (strcmp(argv[i], "-dumponerror") == 0)
128 {
129 fDumpDataOnError = true;
130 continue;
131 }
132
133 if (strcmp(argv[i], "-dumppath") == 0)
134 {
135 if (fDumpPath != NULL)
136 {
137 HLTWarning("The dump path was already specified. Will"
138 " replace previous value given by -dumppath."
139 );
140 }
141 if (argc <= i+1)
142 {
143 HLTError("The dump path was not specified.");
144 return -EINVAL;
145 }
146 fDumpPath = argv[i+1];
147 i++;
148 continue;
149 }
150 }
151
152 if (cdbPath != NULL or run != -1)
153 {
154 int result = SetCDBPathAndRunNo(cdbPath, run);
155 if (result != 0)
156 {
157 // Error messages already generated in SetCDBPathAndRunNo.
158 return result;
159 }
160 }
161
162 return 0;
163}
164
165
166bool AliHLTMUONProcessor::ArgumentAlreadyHandled(int& i, const char* argi) const
167{
168 /// This method can be used by the derivind child class to check if a particular
169 /// argument in argv was already processed.
170
171 if (strcmp(argi, "-cdbpath") == 0)
172 {
173 if (IgnoreArgument(argi)) return false;
a63da6d6 174 i++; // argument takes one parameter
ffb64d3e 175 return true;
176 }
177
178 if (strcmp(argi, "-run") == 0)
179 {
180 if (IgnoreArgument(argi)) return false;
a63da6d6 181 i++; // argument takes one parameter
ffb64d3e 182 return true;
183 }
184
185 if (strcmp(argi, "-delaysetup") == 0)
186 {
187 if (IgnoreArgument(argi)) return false;
188 return true;
189 }
190
191 if (strcmp(argi, "-dumponerror") == 0)
192 {
193 if (IgnoreArgument(argi)) return false;
194 return true;
195 }
196
197 if (strcmp(argi, "-dumppath") == 0)
198 {
199 if (IgnoreArgument(argi)) return false;
a63da6d6 200 i++; // argument takes one parameter
ffb64d3e 201 return true;
202 }
203
204 return false;
205}
206
207
ffc1a6f6 208int AliHLTMUONProcessor::SetCDBPathAndRunNo(
dba14d7d 209 const char* cdbPath, Int_t run, bool useDefault
210 ) const
211{
ffc1a6f6 212 /// Sets the CDB path and run number to read from.
dba14d7d 213 /// \param cdbPath The CDB path to use. If set to NULL and the path has
214 /// not been set in the CDB manager then the default path
162637e4 215 /// "local://$ALICE_ROOT/OCDB" is used if the 'useDefault' flag is also true.
dba14d7d 216 /// \param run The run number to use. If set to -1 and the run number has
217 /// not been set in the CDB manager then a value of zero is used if
218 /// the 'useDefault' flag is also true.
ffc1a6f6 219 /// \param useDefault If set to true then a default CDB path and/or run number
dba14d7d 220 /// is used if they have not been set and 'cdbPath' == NULL or
ffc1a6f6 221 /// 'run' == -1.
222 /// \return Zero if the object could be loaded. Otherwise an error code,
223 /// compatible with the HLT framework, is returned.
dba14d7d 224
162637e4 225 const char* defaultPath = "local://$ALICE_ROOT/OCDB";
dba14d7d 226 Int_t defaultRun = 0;
227
228 AliCDBManager* cdbManager = AliCDBManager::Instance();
229 if (cdbManager == NULL)
230 {
231 HLTError("CDB manager instance does not exist.");
232 return -EIO;
233 }
234
235 // Setup the CDB path.
dba14d7d 236 if (cdbPath != NULL)
237 {
238 cdbManager->SetDefaultStorage(cdbPath);
dba14d7d 239 }
ffc1a6f6 240 else if (not cdbManager->IsDefaultStorageSet() and useDefault)
dba14d7d 241 {
ffc1a6f6 242 cdbManager->SetDefaultStorage(defaultPath);
dba14d7d 243 }
244
245 // Now setup the run number.
246 if (run != -1)
247 {
248 cdbManager->SetRun(run);
249 }
250 else
251 {
252 if (useDefault) cdbManager->SetRun(defaultRun);
253 }
ffc1a6f6 254
255 return 0;
256}
257
258
259int AliHLTMUONProcessor::FetchMappingStores() const
260{
261 /// Fetches the DDL and detector element store objects for MUON mapping.
262 /// \return Zero if the objects could be loaded. Otherwise an error code,
263 /// which is compatible with the HLT framework, is returned.
264 /// \note AliMpDDLStore::Instance() and AliMpDEStore::Instance() must be used
265 /// to fetch the objects after this method returns a code equal to zero.
266
267 Bool_t warn = kFALSE;
268
269 // Check if the objects are already loaded. If they are then exit early,
270 // otherwise we need to try load the objects.
271 if (AliMpDDLStore::Instance(warn) != NULL and AliMpDEStore::Instance(warn) != NULL)
272 return 0;
273
274 AliCDBManager* cdbManager = AliCDBManager::Instance();
275 if (cdbManager == NULL)
276 {
277 HLTError("CDB manager instance does not exist.");
278 return -EIO;
279 }
280
281 const char* cdbPathUsed = "unknown (not set)";
282 AliCDBStorage* store = cdbManager->GetDefaultStorage();
283 if (store != NULL) cdbPathUsed = store->GetURI().Data();
284
dba14d7d 285 Int_t runUsed = cdbManager->GetRun();
286
287 // Now we can try load the DDL and DE store objects.
dba14d7d 288 if (not AliMpCDB::LoadDDLStore(warn))
289 {
290 HLTError("Failed to load DDL or detector element store specified"
291 " for CDB path '%s' and run no. %d.",
292 cdbPathUsed, runUsed
293 );
294 return -ENOENT;
295 }
296
550ea228 297 if (AliMpDDLStore::Instance(warn) == NULL or AliMpDEStore::Instance(warn) == NULL)
dba14d7d 298 {
299 HLTError("Could not find or load the DDL or detector element store instance.");
300 return -EIO;
301 }
302
303 return 0;
304}
305
ffc1a6f6 306
307int AliHLTMUONProcessor::FetchTMapFromCDB(const char* pathToEntry, TMap*& map) const
308{
309 /// Fetches a TMap object from the CDB.
310 /// [in] \param pathToEntry The relative path to the entry in the CDB to fetch.
311 /// [out] \param map This will be filled with the TMap object found if
312 /// a successful status code is returned. Otherwise it will be unchanged.
313 /// \return Zero if the object could be found. Otherwise an error code,
314 /// which is compatible with the HLT framework, is returned.
315
316 assert(AliCDBManager::Instance() != NULL);
317
21b32623 318 AliCDBStorage* store = AliCDBManager::Instance()->GetDefaultStorage();
319 if (store == NULL)
320 {
321 HLTError("Could not get the the default storage for the CDB.");
322 return -EIO;
323 }
324
325 Int_t version = store->GetLatestVersion(pathToEntry, GetRunNo());
326 Int_t subVersion = store->GetLatestSubVersion(pathToEntry, GetRunNo(), version);
327 AliCDBEntry* entry = AliCDBManager::Instance()->Get(pathToEntry, GetRunNo(), version, subVersion);
ffc1a6f6 328 if (entry == NULL)
329 {
330 HLTError("Could not get the CDB entry for \"%s\".", pathToEntry);
331 return -EIO;
332 }
333
334 TObject* obj = entry->GetObject();
335 if (obj == NULL)
336 {
337 HLTError("Configuration object for \"%s\" is missing.", pathToEntry);
338 return -ENOENT;
339 }
340
341 if (obj->IsA() != TMap::Class())
342 {
343 HLTError("Wrong type for configuration object in \"%s\". Found a %s but we need a TMap.",
344 pathToEntry, obj->ClassName()
345 );
346 return -EPROTO;
347 }
348 map = dynamic_cast<TMap*>(obj);
349
350 return 0;
351}
352
353
354int AliHLTMUONProcessor::GetValueFromTMap(
355 TMap* map, const char* paramName, TString& value,
356 const char* pathToEntry, const char* prettyName
357 ) const
358{
359 /// Tries to find the string value associated with a certain parameter in a TMap.
360 /// [in] \param map The TMap object to search in.
361 /// [in] \param paramName The name of the parameter to search for.
362 /// [out] \param value Will be filled with the object found.
363 /// [in] \param pathToEntry The relative path to the entry in the CDB.
364 /// Used when printing error messages. If set to NULL then a string of
365 /// "(unknown)" is used. (default is NULL).
366 /// [in] \param prettyName Should be the name of the parameter which will
367 /// be used when printing error messages. If this is set to NULL then
368 /// the paramName will be used instead (default is NULL).
369 /// \return Zero if the object could be found. Otherwise an error code,
370 /// which is compatible with the HLT framework, is returned.
371
372 if (pathToEntry == NULL) pathToEntry = "(unknown)";
373 if (prettyName == NULL) prettyName = paramName;
374
375 TPair* pair = static_cast<TPair*>(map->FindObject(paramName));
376 if (pair == NULL)
377 {
378 HLTError("Configuration object for \"%s\" does not contain the %s value.",
379 pathToEntry, prettyName
380 );
381 return -ENOENT;
382 }
383 TObject* valueObj = pair->Value();
384 if (valueObj->IsA() != TObjString::Class())
385 {
386 HLTError("The %s parameter found in configuration object \"%s\""
387 " is not a TObjString. Found an object of type %s instead.",
388 prettyName, pathToEntry, valueObj->ClassName()
389 );
390 return -EPROTO;
391 }
392 value = dynamic_cast<TObjString*>(valueObj)->GetString();
393
394 return 0;
395}
396
397
398int AliHLTMUONProcessor::GetIntFromTMap(
399 TMap* map, const char* paramName, Int_t& value,
400 const char* pathToEntry, const char* prettyName
401 ) const
402{
403 /// Tries to find a certain parameter in the TMap object and convert it to
404 /// an integer value.
405 /// [in] \param map The TMap object to search in.
406 /// [in] \param paramName The name of the parameter to search for.
407 /// [out] \param value Will be filled with the integer value for the parameter,
408 /// if it was found and it was an integer value.
409 /// [in] \param pathToEntry The relative path to the entry in the CDB.
410 /// Used when printing error messages. If set to NULL then a string of
411 /// "(unknown)" is used. (default is NULL).
412 /// [in] \param prettyName Should be the name of the parameter which will
413 /// be used when printing error messages. If this is set to NULL then
414 /// the paramName will be used instead (default is NULL).
415 /// \return Zero if the object could be found and is valid. Otherwise an
416 /// error code, which is compatible with the HLT framework, is returned.
417
418 if (pathToEntry == NULL) pathToEntry = "(unknown)";
419 if (prettyName == NULL) prettyName = paramName;
420
421 TString valueStr;
2b7af22a 422 int result = GetValueFromTMap(map, paramName, valueStr, pathToEntry, prettyName);
ffc1a6f6 423 if (result != 0) return result;
424
425 if (not valueStr.IsDigit())
426 {
427 HLTError("The %s parameter found in configuration object \"%s\""
428 "is not a valid integer number string; found \"%s\".",
429 prettyName, pathToEntry, valueStr.Data()
430 );
431 return -EPROTO;
432 }
433 value = valueStr.Atoi();
434
435 return 0;
436}
437
438
439int AliHLTMUONProcessor::GetPositiveIntFromTMap(
440 TMap* map, const char* paramName, Int_t& value,
441 const char* pathToEntry, const char* prettyName
442 ) const
443{
444 /// Tries to find a certain parameter in the TMap object and convert it to
445 /// a positive integer value.
446 /// [in] \param map The TMap object to search in.
447 /// [in] \param paramName The name of the parameter to search for.
448 /// [out] \param value Will be filled with the integer value for the parameter,
449 /// if it was found and it was a positive integer value.
450 /// [in] \param pathToEntry The relative path to the entry in the CDB.
451 /// Used when printing error messages. If set to NULL then a string of
452 /// "(unknown)" is used. (default is NULL).
453 /// [in] \param prettyName Should be the name of the parameter which will
454 /// be used when printing error messages. If this is set to NULL then
455 /// the paramName will be used instead (default is NULL).
456 /// \return Zero if the object could be found and is valid. Otherwise an
457 /// error code, which is compatible with the HLT framework, is returned.
458
459 if (pathToEntry == NULL) pathToEntry = "(unknown)";
460 if (prettyName == NULL) prettyName = paramName;
461
462 TString valueStr;
2b7af22a 463 int result = GetValueFromTMap(map, paramName, valueStr, pathToEntry, prettyName);
ffc1a6f6 464 if (result != 0) return result;
465
466 if (not valueStr.IsDigit())
467 {
468 HLTError("The %s parameter found in configuration object \"%s\""
469 "is not a valid integer number string; found \"%s\".",
470 prettyName, pathToEntry, valueStr.Data()
471 );
472 return -EPROTO;
473 }
474 Int_t val = valueStr.Atoi();
475 if (val < 0)
476 {
477 HLTError("The %s parameter found in configuration object \"%s\""
478 "is not a positive integer number; found \"%d\".",
479 prettyName, pathToEntry, val
480 );
481 return -EPROTO;
482 }
483 value = val;
484
485 return 0;
486}
487
488
489int AliHLTMUONProcessor::GetFloatFromTMap(
490 TMap* map, const char* paramName, Double_t& value,
491 const char* pathToEntry, const char* prettyName
492 ) const
493{
494 /// Tries to find a certain parameter in the TMap object and convert it to
495 /// an floating point value.
496 /// [in] \param map The TMap object to search in.
497 /// [in] \param paramName The name of the parameter to search for.
498 /// [out] \param value Will be filled with the floating point value for the
499 /// parameter, if it was found and it was a floating point value.
500 /// [in] \param pathToEntry The relative path to the entry in the CDB.
501 /// Used when printing error messages. If set to NULL then a string of
502 /// "(unknown)" is used. (default is NULL).
503 /// [in] \param prettyName Should be the name of the parameter which will
504 /// be used when printing error messages. If this is set to NULL then
505 /// the paramName will be used instead (default is NULL).
506 /// \return Zero if the object could be found and is valid. Otherwise an
507 /// error code, which is compatible with the HLT framework, is returned.
508
509 if (pathToEntry == NULL) pathToEntry = "(unknown)";
510 if (prettyName == NULL) prettyName = paramName;
511
512 TString valueStr;
2b7af22a 513 int result = GetValueFromTMap(map, paramName, valueStr, pathToEntry, prettyName);
ffc1a6f6 514 if (result != 0) return result;
515
516 if (not valueStr.IsFloat())
517 {
518 HLTError("The %s parameter found in configuration object \"%s\""
519 "is not a valid floating point number string; found \"%s\".",
520 prettyName, pathToEntry, valueStr.Data()
521 );
522 return -EPROTO;
523 }
524 value = valueStr.Atof();
525
526 return 0;
527}
528
529
530int AliHLTMUONProcessor::GetPositiveFloatFromTMap(
531 TMap* map, const char* paramName, Double_t& value,
532 const char* pathToEntry, const char* prettyName
533 ) const
534{
535 /// Tries to find a certain parameter in the TMap object and convert it to
536 /// an positive floating point value.
537 /// [in] \param map The TMap object to search in.
538 /// [in] \param paramName The name of the parameter to search for.
539 /// [out] \param value Will be filled with the floating point value for the
540 /// parameter, if it was found and it was a positive floating point value.
541 /// [in] \param pathToEntry The relative path to the entry in the CDB.
542 /// Used when printing error messages. If set to NULL then a string of
543 /// "(unknown)" is used. (default is NULL).
544 /// [in] \param prettyName Should be the name of the parameter which will
545 /// be used when printing error messages. If this is set to NULL then
546 /// the paramName will be used instead (default is NULL).
547 /// \return Zero if the object could be found and is valid. Otherwise an
548 /// error code, which is compatible with the HLT framework, is returned.
549
550 if (pathToEntry == NULL) pathToEntry = "(unknown)";
551 if (prettyName == NULL) prettyName = paramName;
552
553 TString valueStr;
2b7af22a 554 int result = GetValueFromTMap(map, paramName, valueStr, pathToEntry, prettyName);
ffc1a6f6 555 if (result != 0) return result;
556
557 if (not valueStr.IsFloat())
558 {
559 HLTError("The %s parameter found in configuration object \"%s\""
560 "is not a valid floating point number string; found \"%s\".",
561 prettyName, pathToEntry, valueStr.Data()
562 );
563 return -EPROTO;
564 }
565 Double_t val = valueStr.Atof();
566 if (val < 0)
567 {
568 HLTError("The %s parameter found in configuration object \"%s\""
569 "is not a positive floating point number; found \"%d\".",
570 prettyName, pathToEntry, val
571 );
572 return -EPROTO;
573 }
574 value = val;
575
576 return 0;
577}
17d68f2a 578
579
580int AliHLTMUONProcessor::LoadRecoParamsFromCDB(AliMUONRecoParam*& params) const
581{
582 /// Fetches the reconstruction parameters object from the CDB for MUON.
583 /// [out] \param params This will be filled with the reconstruction
584 /// parameters object found if a successful status code is returned.
585 /// Otherwise it will be unchanged.
586 /// \return Zero if the object could be found. Otherwise an error code,
587 /// which is compatible with the HLT framework, is returned.
588
589 assert(AliCDBManager::Instance() != NULL);
21b32623 590
591 AliCDBStorage* store = AliCDBManager::Instance()->GetDefaultStorage();
592 if (store == NULL)
593 {
594 HLTError("Could not get the the default storage for the CDB.");
595 return -EIO;
596 }
597
17d68f2a 598 const char* pathToEntry = "MUON/Calib/RecoParam";
21b32623 599 Int_t version = store->GetLatestVersion(pathToEntry, GetRunNo());
600 Int_t subVersion = store->GetLatestSubVersion(pathToEntry, GetRunNo(), version);
601 AliCDBEntry* entry = AliCDBManager::Instance()->Get(pathToEntry, GetRunNo(), version, subVersion);
17d68f2a 602 if (entry == NULL)
603 {
604 HLTError("Could not get the CDB entry for \"%s\".", pathToEntry);
605 return -EIO;
606 }
607
608 TObject* obj = entry->GetObject();
609 if (obj == NULL)
610 {
611 HLTError("Reconstruction parameters object for \"%s\" is missing.", pathToEntry);
612 return -ENOENT;
613 }
614
615 TObjArray* objarr = dynamic_cast<TObjArray*>(obj);
616 if (objarr != NULL)
617 {
618 obj = objarr->Last();
619 }
620
621 AliMUONRecoParam* par = dynamic_cast<AliMUONRecoParam*>(obj);
622 if (par == NULL)
623 {
624 HLTError("No AliMUONRecoParam class found for entry \"%s\". Found a %s class instead.",
625 pathToEntry, obj->ClassName()
626 );
627 return -EPROTO;
628 }
629
630 params = par;
631 return 0;
632}
633
ffb64d3e 634
635void AliHLTMUONProcessor::DumpBuffer(
636 const void* buffer, AliHLTUInt32_t size, const char* filename
637 ) const
638{
639 /// Dumps the data contained in a buffer to file as is.
640
641 using std::fstream;
642
643 fstream file(filename, fstream::out | fstream::trunc | fstream::binary);
644 if (file.good())
645 {
646 file.write(reinterpret_cast<const char*>(buffer), size);
647 if (file.fail())
648 {
649 HLTError("Could not write data block to file %s during"
650 " dumping operation!",
651 filename
652 );
653 }
654 }
655 else
656 {
657 HLTError("Could not open file %s for dumping data block!", filename);
658 }
659}
660
661
662void AliHLTMUONProcessor::DumpBlock(
663 const AliHLTComponentBlockData* block, const char* fileNamePrefix
664 ) const
665{
666 /// Dumps the data block and meta information to file.
667
668 std::string filename = fDumpPath;
669 filename += fileNamePrefix;
670 filename += "-blockmeta.bin";
671 DumpBuffer(block, sizeof(AliHLTComponentBlockData), filename.c_str());
672 filename = fDumpPath;
673 filename += fileNamePrefix;
674 filename += "-data.bin";
675 DumpBuffer(block->fPtr, block->fSize, filename.c_str());
676}
677
678
679void AliHLTMUONProcessor::DumpEvent(
680 const AliHLTComponentEventData& evtData,
681 const AliHLTComponentBlockData* blocks,
682 AliHLTComponentTriggerData& trigData,
683 AliHLTUInt8_t* outputPtr,
684 AliHLTUInt32_t& size,
685 AliHLTComponentBlockDataList& outputBlocks
686 ) const
687{
688 /// Dumps the event information to files in the dump path given by the
689 /// method DumpPath, which can be set by the command line argument -dumppath.
690
691 using std::fstream;
692 char strbuf[1024];
693
694 std::string filename = fDumpPath;
695 sprintf(strbuf, "dump_event-0x%16.16llX.log", evtData.fEventID);
696 filename += strbuf;
697 fstream logfile(filename.c_str(), fstream::out | fstream::trunc);
698 if (logfile.fail())
699 {
700 HLTError("Could not open log file '%s' for dump information.", filename.c_str());
701 return;
702 }
703
704 filename = fDumpPath;
705 sprintf(strbuf, "dump_event-0x%16.16llX-eventdata.bin", evtData.fEventID);
706 filename += strbuf;
707 logfile << "Dumping event data structure to file: " << filename << std::endl;
708 DumpBuffer(&evtData, sizeof(AliHLTComponentEventData), filename.c_str());
709
710 filename = fDumpPath;
711 sprintf(strbuf, "dump_event-0x%16.16llX-triggerdata.bin", evtData.fEventID);
712 filename += strbuf;
713 logfile << "Dumping trigger data structure to file: " << filename << std::endl;
714 DumpBuffer(&trigData, sizeof(AliHLTComponentTriggerData), filename.c_str());
715
716 for (unsigned int n = 0; n < evtData.fBlockCnt; n++)
717 {
718 sprintf(strbuf, "dump_event-0x%16.16llX-block-0x%8.8X", evtData.fEventID, n);
719 filename = strbuf;
720 sprintf(strbuf, "0x%8.8X", blocks[n].fSpecification);
721 logfile << "Found block with data type = " << DataType2Text(blocks[n].fDataType)
722 << ", specification = " << strbuf << ". Dumping to file: "
723 << filename << "-data.bin" << std::endl;
724 DumpBlock(&blocks[n], filename.c_str());
725 }
726
727 filename = fDumpPath;
728 sprintf(strbuf, "dump_event-0x%16.16llX-output-buffer.bin", evtData.fEventID);
729 filename += strbuf;
730 logfile << "Dumping output buffer to file: " << filename << std::endl;
731 DumpBuffer(outputPtr, size, filename.c_str());
732
733 for (size_t i = 0; i < outputBlocks.size(); i++)
734 {
735 sprintf(strbuf, "dump_event-0x%16.16llX-output-block-0x%8.8X", evtData.fEventID, int(i));
736 filename = strbuf;
737 sprintf(strbuf, "0x%8.8X", outputBlocks[i].fSpecification);
738 logfile << "Generated output data block with type = "
739 << DataType2Text(outputBlocks[i].fDataType)
740 << ", specification = " << strbuf << ". Dumping to file: "
741 << filename << "-data.bin" << std::endl;
742 DumpBlock(&outputBlocks[i], filename.c_str());
743 }
744}
745
746
747void AliHLTMUONProcessor::DumpEvent(
748 const AliHLTComponentEventData& evtData,
749 AliHLTComponentTriggerData& trigData
750 ) const
751{
752 /// Dumps the event information to files in the dump path given by the
753 /// method DumpPath, which can be set by the command line argument -dumppath.
754
755 using std::fstream;
756 char strbuf[1024];
757
758 std::string filename = fDumpPath;
759 sprintf(strbuf, "dump_event-0x%16.16llX.log", evtData.fEventID);
760 filename += strbuf;
761 fstream logfile(filename.c_str(), fstream::out | fstream::trunc);
762 if (logfile.fail())
763 {
764 HLTError("Could not open log file '%s' for dump information.", filename.c_str());
765 return;
766 }
767
768 filename = fDumpPath;
769 sprintf(strbuf, "dump_event-0x%16.16llX-eventdata.bin", evtData.fEventID);
770 filename += strbuf;
771 logfile << "Dumping event data structure to file: " << filename << std::endl;
772 DumpBuffer(&evtData, sizeof(AliHLTComponentEventData), filename.c_str());
773
774 filename = fDumpPath;
775 sprintf(strbuf, "dump_event-0x%16.16llX-triggerdata.bin", evtData.fEventID);
776 filename += strbuf;
777 logfile << "Dumping trigger data structure to file: " << filename << std::endl;
778 DumpBuffer(&trigData, sizeof(AliHLTComponentTriggerData), filename.c_str());
779
780 for (int i = 0; i < GetNumberOfInputBlocks(); i++)
781 {
782 const AliHLTComponentBlockData* block = GetInputBlock(i);
783 sprintf(strbuf, "dump_event-0x%16.16llX-block-0x%8.8X", evtData.fEventID, i);
784 filename = strbuf;
785 sprintf(strbuf, "0x%8.8X", block->fSpecification);
786 logfile << "Found block with data type = " << DataType2Text(block->fDataType)
787 << ", specification = " << strbuf << ". Dumping to file: "
788 << filename << "-data.bin" << std::endl;
789 DumpBlock(block, filename.c_str());
790 }
791}
792