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