1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Indranil Das <indra.das@saha.ac.in> *
7 * Artur Szostak <artursz@iafrica.com> *
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 **************************************************************************/
21 /// @file AliHLTMUONTriggerReconstructorComponent.cxx
22 /// @author Indranil Das <indra.das@saha.ac.in>, Artur Szostak <artursz@iafrica.com>
24 /// @brief Implementation of the trigger DDL reconstructor component.
27 #include "AliHLTMUONTriggerReconstructorComponent.h"
28 #include "AliHLTMUONTriggerReconstructor.h"
29 #include "AliHLTMUONHitReconstructor.h"
30 #include "AliHLTMUONConstants.h"
31 #include "AliHLTMUONCalculations.h"
32 #include "AliHLTMUONUtils.h"
33 #include "AliHLTMUONDataBlockWriter.h"
34 #include "AliRawDataHeader.h"
35 #include "AliCDBManager.h"
36 #include "AliCDBStorage.h"
37 #include "AliGeomManager.h"
38 #include "AliMUONGeometryTransformer.h"
39 #include "AliMUONGeometryDetElement.h"
41 #include "AliMpDDLStore.h"
43 #include "AliMpSegmentation.h"
44 #include "AliMpDEIterator.h"
45 #include "AliMpVSegmentation.h"
46 #include "AliMpDEManager.h"
47 #include "AliMpLocalBoard.h"
48 #include "AliMpTriggerCrate.h"
55 ClassImp(AliHLTMUONTriggerReconstructorComponent)
58 AliHLTMUONTriggerReconstructorComponent::AliHLTMUONTriggerReconstructorComponent() :
59 AliHLTMUONProcessor(),
62 fWarnForUnexpecedBlock(false),
63 fStopOnOverflow(false),
65 fZmiddleSpecified(false),
67 fLutInitialised(false)
70 /// Default constructor.
75 AliHLTMUONTriggerReconstructorComponent::~AliHLTMUONTriggerReconstructorComponent()
78 /// Default destructor.
81 if (fTrigRec != NULL) delete fTrigRec;
85 const char* AliHLTMUONTriggerReconstructorComponent::GetComponentID()
88 /// Inherited from AliHLTComponent. Returns the component ID.
91 return AliHLTMUONConstants::TriggerReconstructorId();
95 void AliHLTMUONTriggerReconstructorComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
98 /// Inherited from AliHLTProcessor. Returns the list of expected input data types.
102 list.push_back( AliHLTMUONConstants::DDLRawDataType() );
106 AliHLTComponentDataType AliHLTMUONTriggerReconstructorComponent::GetOutputDataType()
109 /// Inherited from AliHLTComponent. Returns the output data type.
112 return AliHLTMUONConstants::TriggerRecordsBlockDataType();
116 void AliHLTMUONTriggerReconstructorComponent::GetOutputDataSize(
117 unsigned long& constBase, double& inputMultiplier
121 /// Inherited from AliHLTComponent. Returns an estimate of the expected output data size.
124 constBase = sizeof(AliHLTMUONTriggerRecordsBlockWriter::HeaderType);
129 AliHLTComponent* AliHLTMUONTriggerReconstructorComponent::Spawn()
132 /// Inherited from AliHLTComponent. Creates a new object instance.
135 return new AliHLTMUONTriggerReconstructorComponent;
139 int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
142 /// Inherited from AliHLTComponent.
143 /// Parses the command line parameters and initialises the component.
146 HLTInfo("Initialising dHLT trigger reconstructor component.");
148 // Inherit the parents functionality.
149 int result = AliHLTMUONProcessor::DoInit(argc, argv);
150 if (result != 0) return result;
152 // Make sure to cleanup fTrigRec if it is still there for some reason.
153 if (fTrigRec != NULL)
160 fWarnForUnexpecedBlock = false;
161 fStopOnOverflow = false;
163 fZmiddleSpecified = false;
164 fBLSpecified = false;
165 fLutInitialised = false;
167 const char* lutFileName = NULL;
169 bool suppressPartialTrigs = true;
170 bool tryRecover = false;
171 bool useLocalId = true;
173 double bfieldintegral = 0;
175 for (int i = 0; i < argc; i++)
177 // To keep the legacy behaviour we need to have the following check
178 // for -cdbpath here, before ArgumentAlreadyHandled.
179 if (strcmp(argv[i], "-cdbpath") == 0)
184 if (ArgumentAlreadyHandled(i, argv[i])) continue;
186 if (strcmp( argv[i], "-lut" ) == 0)
188 if (lutFileName != NULL)
190 HLTWarning("LUT path was already specified."
191 " Will replace previous value given by -lut."
197 HLTError("The lookup table filename was not specified." );
201 lutFileName = argv[i+1];
207 if (strcmp( argv[i], "-ddl" ) == 0)
211 HLTWarning("DDL number was already specified."
212 " Will replace previous value given by -ddl or -ddlid."
218 HLTError("DDL number not specified. It must be in the range [21..22]");
223 unsigned long num = strtoul(argv[i+1], &cpErr, 0);
224 if (cpErr == NULL or *cpErr != '\0')
226 HLTError("Cannot convert '%s' to a DDL Number.", argv[i+1]);
229 if (num < 21 or 22 < num)
231 HLTError("The DDL number must be in the range [21..22].");
234 fDDL = num - 1; // Convert to DDL number in the range 0..21
240 if (strcmp( argv[i], "-ddlid" ) == 0)
244 HLTWarning("DDL number was already specified."
245 " Will replace previous value given by -ddl or -ddlid."
251 HLTError("DDL equipment ID number not specified. It must be in the range [2816..2817]");
256 unsigned long num = strtoul(argv[i+1], &cpErr, 0);
257 if (cpErr == NULL or *cpErr != '\0')
259 HLTError("Cannot convert '%s' to a DDL equipment ID Number.", argv[i+1]);
262 fDDL = AliHLTMUONUtils::EquipIdToDDLNumber(num); // Convert to DDL number in the range 0..21
263 if (fDDL < 20 or 21 < fDDL)
265 HLTError("The DDL equipment ID number must be in the range [2816..2817].");
273 if (strcmp( argv[i], "-cdb" ) == 0)
279 if (strcmp( argv[i], "-zmiddle" ) == 0)
281 if (fZmiddleSpecified)
283 HLTWarning("The Z coordinate for the middle of the dipole was already specified."
284 " Will replace previous value given by -zmiddle."
290 HLTError("The Z coordinate for the middle of the dipole was not specified.");
295 zmiddle = strtod(argv[i+1], &cpErr);
296 if (cpErr == NULL or *cpErr != '\0')
298 HLTError("Cannot convert '%s' to a valid floating point number.",
304 fZmiddleSpecified = true;
309 if (strcmp( argv[i], "-bfieldintegral" ) == 0)
313 HLTWarning("The magnetic field integral was already specified."
314 " Will replace previous value given by -bfieldintegral."
320 HLTError("The magnetic field integral was not specified." );
325 bfieldintegral = strtod(argv[i+1], &cpErr);
326 if (cpErr == NULL or *cpErr != '\0')
328 HLTError("Cannot convert '%s' to a valid floating point number.",
339 if (strcmp( argv[i], "-warn_on_unexpected_block" ) == 0)
341 fWarnForUnexpecedBlock = true;
345 if (strcmp( argv[i], "-suppress_partial_triggers" ) == 0)
347 suppressPartialTrigs = true;
351 if (strcmp( argv[i], "-generate_partial_triggers" ) == 0)
353 suppressPartialTrigs = false;
357 if (strcmp( argv[i], "-stop_on_buffer_overflow" ) == 0)
359 fStopOnOverflow = true;
363 if (strcmp( argv[i], "-tryrecover" ) == 0)
369 if (strcmp( argv[i], "-dont_use_crateid" ) == 0)
375 if (strcmp( argv[i], "-dont_use_localid" ) == 0)
381 HLTError("Unknown option '%s'.", argv[i]);
388 fTrigRec = new AliHLTMUONTriggerReconstructor();
390 catch (const std::bad_alloc&)
392 HLTError("Could not allocate more memory for the trigger reconstructor component.");
396 if (fZmiddleSpecified and useCDB)
398 HLTWarning("The -cdb or -cdbpath parameter was specified, which indicates that"
399 " this component should read from the CDB, but then the -zmiddle argument"
400 " was also used. Will override the value from CDB with the command"
401 " line parameter given."
404 if (fBLSpecified and useCDB)
406 HLTWarning("The -cdb or -cdbpath parameter was specified, which indicates that"
407 " this component should read from the CDB, but then the -bfieldintegral"
408 " argument was also used. Will override the value from CDB with the"
409 " command line parameter given."
413 if (lutFileName != NULL and useCDB == true)
415 HLTWarning("The -cdb or -cdbpath parameter was specified, which indicates that"
416 " this component should read from the CDB, but then the -lut argument"
417 " was also used. Will ignore the -lut option and load from CDB anyway."
421 if (lutFileName == NULL) useCDB = true;
423 if (fDDL == -1 and not DelaySetup())
425 HLTWarning("DDL number not specified. Cannot check if incomming data is valid.");
430 if (not DelaySetup())
432 HLTInfo("Loading lookup table information from CDB for DDL %d (ID = %d).",
433 fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
435 result = ReadLutFromCDB();
438 // Error messages already generated in ReadLutFromCDB.
439 delete fTrigRec; // Make sure to delete fTrigRec to avoid partial initialisation.
443 fLutInitialised = true;
448 HLTInfo("Loading lookup table information from file %s.", lutFileName);
449 result = ReadLookUpTable(lutFileName);
452 // Error messages already generated in ReadLookUpTable.
453 delete fTrigRec; // Make sure to delete fTrigRec to avoid partial initialisation.
457 fLutInitialised = true;
460 if (fZmiddleSpecified) AliHLTMUONCalculations::Zf(zmiddle);
461 if (fBLSpecified) AliHLTMUONCalculations::QBL(bfieldintegral);
463 if (not DelaySetup())
465 if (not fZmiddleSpecified or not fBLSpecified)
467 HLTInfo("Loading configuration parameters from CDB for DDL %d (ID = %d).",
468 fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
471 result = ReadConfigFromCDB(not fZmiddleSpecified, not fBLSpecified);
474 // Error messages already generated in ReadConfigFromCDB.
475 delete fTrigRec; // Make sure to delete fTrigRec to avoid partial initialisation.
482 // Print the debug messages here since ReadConfigFromCDB does not get called,
483 // in-which the debug messages would have been printed.
484 HLTDebug("Using the following configuration parameters:");
485 HLTDebug(" Middle of dipole Z coordinate = %f cm", AliHLTMUONCalculations::Zf());
486 HLTDebug(" Magnetic field integral = %f T.m", AliHLTMUONCalculations::QBL());
490 fTrigRec->SuppressPartialTriggers(suppressPartialTrigs);
491 fTrigRec->TryRecover(tryRecover);
492 fTrigRec->UseCrateId(fUseCrateId);
493 fTrigRec->UseLocalId(useLocalId);
499 int AliHLTMUONTriggerReconstructorComponent::DoDeinit()
502 /// Inherited from AliHLTComponent. Performs a cleanup of the component.
505 HLTInfo("Deinitialising dHLT trigger reconstructor component.");
507 if (fTrigRec != NULL)
516 int AliHLTMUONTriggerReconstructorComponent::DoEvent(
517 const AliHLTComponentEventData& evtData,
518 const AliHLTComponentBlockData* blocks,
519 AliHLTComponentTriggerData& trigData,
520 AliHLTUInt8_t* outputPtr,
521 AliHLTUInt32_t& size,
522 AliHLTComponentBlockDataList& outputBlocks
526 /// Inherited from AliHLTProcessor. Processes the new event data.
529 // Initialise the LUT and configuration parameters from CDB if we were
530 // requested to initialise only when the first event was received.
533 // Use the specification given by the first data block if we
534 // have not been given a DDL number on the command line.
537 bool blockFound = false;
538 for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt and not blockFound; n++)
540 if (blocks[n].fDataType != AliHLTMUONConstants::DDLRawDataType()) continue;
543 fDDL = AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification);
547 HLTError("Received a data block with a specification (0x%8.8X)"
548 " indicating multiple DDL data sources, but we must only"
549 " receive raw DDL data from one trigger station DDL.",
550 blocks[n].fSpecification
558 HLTError("The initialisation from CDB of the component has"
559 " been delayed to the first received event. However,"
560 " no raw DDL data blocks have been found in the first event."
566 // Check that the LUT was not already loaded in DoInit.
567 if (not fLutInitialised)
569 HLTInfo("Loading lookup table information from CDB for DDL %d (ID = %d).",
570 fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
572 int result = ReadLutFromCDB();
573 if (result != 0) return result;
574 fLutInitialised = true;
577 // Load the configuration paramters from CDB if they have not been given
578 // on the command line.
579 if (not fZmiddleSpecified or not fBLSpecified)
581 HLTInfo("Loading configuration parameters from CDB for DDL %d (ID = %d).",
582 fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
584 int result = ReadConfigFromCDB(not fZmiddleSpecified, not fBLSpecified);
585 if (result != 0) return result;
592 unsigned long totalSize = 0; // Amount of memory currently consumed in bytes.
594 HLTDebug("Processing event %llu with %u input data blocks.",
595 evtData.fEventID, evtData.fBlockCnt
598 // Loop over all input blocks in the event and run the trigger DDL
599 // reconstruction algorithm on the raw data.
600 for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++)
602 HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
603 n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fPtr, blocks[n].fSize
606 if (blocks[n].fDataType != AliHLTMUONConstants::DDLRawDataType()
607 or not AliHLTMUONUtils::IsTriggerDDL(blocks[n].fSpecification)
610 // Log a message indicating that we got a data block that we
611 // do not know how to handle.
612 if (fWarnForUnexpecedBlock)
613 HLTWarning("Received a data block of a type we cannot handle: '%s', spec: 0x%X",
614 DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification
618 HLTDebug("Received a data block of a type we cannot handle: '%s', spec: 0x%X",
619 DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification
626 AliHLTInt32_t receivedDDL = AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification);
629 if (receivedDDL != fDDL)
631 HLTWarning("Received raw data from DDL %d (ID = %d),"
632 " but expect data only from DDL %d (ID = %d).",
633 receivedDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(receivedDDL),
634 fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
639 // Create a new output data block and initialise the header.
640 AliHLTMUONTriggerRecordsBlockWriter block(outputPtr+totalSize, size-totalSize);
641 if (not block.InitCommonHeader())
643 HLTError("There is not enough space in the output buffer for the new data block."
644 " We require at least %ufTrigRec->GetkDDLHeaderSize() bytes, but have %u bytes left.",
645 sizeof(AliHLTMUONTriggerRecordsBlockWriter::HeaderType),
651 AliHLTUInt32_t totalDDLSize = blocks[n].fSize;
652 if (totalDDLSize < sizeof(AliRawDataHeader))
654 HLTError("Raw data block %d is %d bytes in size and is too short to"
655 " possibly contain valid DDL raw data. We expect it to have"
656 " at least %d bytes for the commond data header.",
657 n, totalDDLSize, sizeof(AliRawDataHeader)
661 AliRawDataHeader* header = reinterpret_cast<AliRawDataHeader*>(blocks[n].fPtr);
662 AliHLTUInt32_t payloadSize = totalDDLSize - sizeof(AliRawDataHeader);
663 AliHLTUInt8_t* buffer = reinterpret_cast<AliHLTUInt8_t*>(header + 1);
664 AliHLTUInt32_t nofTrigRec = block.MaxNumberOfEntries();
666 // Decode if this is a scalar event or not.
667 bool scalarEvent = ((header->GetL1TriggerMessage() & 0x1) == 0x1);
669 // Remember: the following does NOT change the mapping!
670 // It is just to generate unique trigger record IDs.
671 fTrigRec->SetDDL(receivedDDL);
673 bool runOk = fTrigRec->Run(
674 buffer, payloadSize, scalarEvent,
675 block.GetArray(), nofTrigRec
679 HLTError("Error while processing the trigger DDL reconstruction algorithm.");
680 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
681 if (not fTrigRec->OverflowedOutputBuffer()
682 or (fTrigRec->OverflowedOutputBuffer() and fStopOnOverflow)
685 size = totalSize; // Must tell the framework how much buffer space was used.
690 // nofTrigRec should now contain the number of triggers actually found
691 // and filled into the output data block, so we can set this number.
692 assert( nofTrigRec <= block.MaxNumberOfEntries() );
693 block.SetNumberOfEntries(nofTrigRec);
695 HLTDebug("Number of trigger records found is %d", nofTrigRec);
697 // Fill a block data structure for our output block.
698 AliHLTComponentBlockData bd;
701 // This block's start (offset) is after all other blocks written so far.
702 bd.fOffset = totalSize;
703 bd.fSize = block.BytesUsed();
704 bd.fDataType = AliHLTMUONConstants::TriggerRecordsBlockDataType();
705 bd.fSpecification = blocks[n].fSpecification;
706 outputBlocks.push_back(bd);
708 HLTDebug("Created a new output data block at fPtr = %p,"
709 " with fOffset = %u (0x%.X) and fSize = %u bytes.",
710 bd.fPtr, bd.fOffset, bd.fOffset, bd.fSize
713 // Increase the total amount of data written so far to our output memory.
714 totalSize += block.BytesUsed();
717 // Finally we set the total size of output memory we consumed.
723 int AliHLTMUONTriggerReconstructorComponent::Reconfigure(
724 const char* cdbEntry, const char* componentId
727 /// Inherited from AliHLTComponent. This method will reload CDB configuration
728 /// entries for this component from the CDB.
729 /// \param cdbEntry If this is NULL then it is assumed that all CDB entries should
730 /// be reloaded. Otherwise a particular value for 'cdbEntry' will trigger
731 /// reloading of the LUT if the path contains 'MUON/', but the other
732 /// configuration parameters will be loaded if 'cdbEntry' contains
733 /// "HLT/ConfigMUON/TriggerReconstructor".
734 /// \param componentId The name of the component in the current chain.
736 bool startsWithMUON = TString(cdbEntry).Index("MUON/", 5, 0, TString::kExact) == 0;
737 bool givenConfigPath = strcmp(cdbEntry, AliHLTMUONConstants::TriggerReconstructorCDBPath()) == 0;
739 if (cdbEntry == NULL or startsWithMUON or givenConfigPath)
741 HLTInfo("Reading new configuration entries from CDB for component '%s'.", componentId);
744 if (cdbEntry == NULL or startsWithMUON)
746 int result = ReadLutFromCDB();
747 if (result != 0) return result;
750 if (cdbEntry == NULL or givenConfigPath)
752 int result = ReadConfigFromCDB();
753 if (result != 0) return result;
760 int AliHLTMUONTriggerReconstructorComponent::ReadPreprocessorValues(const char* modules)
762 /// Inherited from AliHLTComponent.
763 /// Updates the configuration of this component if either HLT or MUON have
764 /// been specified in the 'modules' list.
766 TString mods = modules;
767 if (mods.Contains("ALL") or (mods.Contains("HLT") and mods.Contains("MUON")))
769 return Reconfigure(NULL, GetComponentID());
771 if (mods.Contains("HLT"))
773 return Reconfigure(AliHLTMUONConstants::TriggerReconstructorCDBPath(), GetComponentID());
775 if (mods.Contains("MUON"))
777 return Reconfigure("MUON/*", GetComponentID());
783 int AliHLTMUONTriggerReconstructorComponent::ReadLookUpTable(const char* lutpath)
786 /// Read in the lookup table from file.
789 assert(fTrigRec != NULL);
792 file.open(lutpath, fstream::binary | fstream::in);
795 HLTError("Could not open file: %s", lutpath);
799 file.read(reinterpret_cast<char*>(fTrigRec->LookupTableBuffer()), fTrigRec->LookupTableSize());
802 HLTError("The file %s was too short to contain a valid lookup table for this component.", lutpath);
808 HLTError("Could not read from file: %s", lutpath);
818 int AliHLTMUONTriggerReconstructorComponent::ReadConfigFromCDB(
819 bool setZmiddle, bool setBL
822 /// Reads this component's configuration parameters from the CDB.
823 /// These include the middle of the dipole Z coordinate (zmiddle) and the
824 /// integrated magnetic field of the dipole.
825 /// \param setZmiddle Indicates if the zmiddle parameter should be set
827 /// \param setBL Indicates if the integrated magnetic field parameter should
828 /// be set (default true).
829 /// \return 0 if no errors occured and negative error code compatible with
830 /// the HLT framework on errors.
832 const char* pathToEntry = AliHLTMUONConstants::TriggerReconstructorCDBPath();
835 int result = FetchTMapFromCDB(pathToEntry, map);
836 if (result != 0) return result;
841 result = GetFloatFromTMap(map, "zmiddle", value, pathToEntry, "dipole middle Z coordinate");
842 if (result != 0) return result;
843 AliHLTMUONCalculations::Zf(value);
848 result = GetFloatFromTMap(map, "bfieldintegral", value, pathToEntry, "integrated magnetic field");
849 if (result != 0) return result;
850 AliHLTMUONCalculations::QBL(value);
853 HLTDebug("Using the following configuration parameters:");
854 HLTDebug(" Middle of dipole Z coordinate = %f cm", AliHLTMUONCalculations::Zf());
855 HLTDebug(" Magnetic field integral = %f T.m", AliHLTMUONCalculations::QBL());
861 int AliHLTMUONTriggerReconstructorComponent::ReadLutFromCDB()
863 /// Loads the lookup table containing channel and geometrical position
864 /// information about trigger strips from CDB.
866 /// \note To override the default CDB path and / or run number the
867 /// SetCDBPathAndRunNo(cdbPath, run) method should be called before this
870 /// \return 0 on success and non zero codes for errors.
874 HLTError("No DDL number specified for which to load LUT data from CDB.");
878 int result = FetchMappingStores();
879 // Error message already generated in FetchMappingStores.
880 if (result != 0) return result;
881 AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
883 AliMpSegmentation* segmentation = AliMpSegmentation::Instance();
884 if (segmentation == NULL)
886 HLTError("Could not find segmentation mapping (AliMpSegmentation) instance.");
890 // Only load geometry if not already loaded.
891 if (AliGeomManager::GetGeometry() == NULL)
893 AliGeomManager::LoadGeometry();
895 AliMUONGeometryTransformer transformer;
896 if (not transformer.LoadGeometryData())
898 HLTError("Could not load geometry into transformer.");
902 AliHLTMUONTriggerRecoLookupTable* lookupTable = fTrigRec->LookupTableBuffer();
904 for (Int_t i = 0; i < 16; i++)
905 for (Int_t j = 0; j < 16; j++)
906 for (Int_t k = 0; k < 4; k++)
907 for (Int_t n = 0; n < 2; n++)
908 for (Int_t m = 0; m < 16; m++)
910 lookupTable->fRow[i][j][k][n][m].fIdFlags = 0x0;
911 lookupTable->fRow[i][j][k][n][m].fX = 0;
912 lookupTable->fRow[i][j][k][n][m].fY = 0;
913 lookupTable->fRow[i][j][k][n][m].fZ = 0;
916 AliMpDEIterator detElemIter;
917 for (Int_t iReg = 0; iReg < 8; iReg++)
919 AliMpTriggerCrate* crate = ddlStore->GetTriggerCrate(fDDL, iReg);
922 HLTError("Could not get crate mapping for regional header = %d"
923 " and DDL %d (ID = %d).",
924 iReg, fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
928 // Depending on the value of fUseCrateId, use either the crate ID as would
929 // be found in the regional header structures or the sequencial index number
931 UInt_t crateId = (fUseCrateId ? crate->GetId() : iReg);
934 HLTError("The crate ID number (%d) for regional header = %d and"
935 " DDL %d (ID = %d) is too big. It should be in the range [0..15]",
936 crateId, iReg, fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
941 for (Int_t iLocBoard = 0; iLocBoard < 16; iLocBoard++)
943 Int_t boardId = crate->GetLocalBoardId(iLocBoard);
944 if (boardId == 0) continue;
946 AliMpLocalBoard* localBoard = ddlStore->GetLocalBoard(boardId);
947 if (localBoard == NULL)
949 HLTError("Could not get local board: %d.", boardId);
954 if (! localBoard->IsNotified()) continue;
956 for (Int_t iChamber = 0; iChamber < 4; iChamber++)
958 Int_t detElemId = ddlStore->GetDEfromLocalBoard(boardId, iChamber);
960 AliHLTUInt32_t idflags = AliHLTMUONUtils::PackRecHitFlags(iChamber+10, detElemId);
962 const AliMUONGeometryDetElement* detElemTransform = transformer.GetDetElement(detElemId);
963 if (detElemTransform == NULL)
965 HLTError("Got NULL pointer for geometry transformer"
966 " for detection element ID = %d.",
972 for (Int_t iCathode = 0; iCathode <= 1; iCathode++)
974 const AliMpVSegmentation* seg = segmentation->GetMpSegmentation(
975 detElemId, AliMp::GetCathodType(iCathode)
978 for (Int_t bitxy = 0; bitxy < 16; bitxy++)
981 if (iCathode && localBoard->GetSwitch(6)) offset = -8;
983 AliMpPad pad = seg->PadByLocation(AliMpIntPair(boardId, bitxy+offset), kFALSE);
987 // There is no pad associated with the given local board and bit pattern.
991 // Get the global coodinates of the pad.
992 Float_t lx = pad.Position().X();
993 Float_t ly = pad.Position().Y();
995 detElemTransform->Local2Global(lx, ly, 0, gx, gy, gz);
998 lookupTable->fRow[crateId][iLocBoard][iChamber][iCathode][bitxy].fIdFlags = idflags;
999 lookupTable->fRow[crateId][iLocBoard][iChamber][iCathode][bitxy].fX = gx;
1000 lookupTable->fRow[crateId][iLocBoard][iChamber][iCathode][bitxy].fY = gy;
1001 lookupTable->fRow[crateId][iLocBoard][iChamber][iCathode][bitxy].fZ = gz;
1012 bool AliHLTMUONTriggerReconstructorComponent::GenerateLookupTable(
1013 AliHLTInt32_t ddl, const char* filename,
1014 const char* cdbPath, Int_t run, bool useCrateId
1017 /// Generates a binary file containing the lookup table (LUT) from the
1018 /// CDB, which can be used for the trigger reconstructor component later.
1019 /// @param ddl Must be the DDL for which to generate the DDL,
1020 /// in the range [20..21].
1021 /// @param filename The name of the LUT file to generate.
1022 /// @param cdbPath The CDB path to use.
1023 /// @param run The run number to use for the CDB.
1024 /// @param useCrateId Indicates that the crate ID should be used rather
1025 /// than a sequencial number.
1026 /// @return True if the generation of the LUT file succeeded.
1028 AliHLTMUONTriggerReconstructorComponent comp;
1030 if (ddl < 20 or 21 < ddl)
1032 std::cerr << "ERROR: the DDL number must be in the range [20..21]." << std::endl;
1038 sprintf(ddlNum, "%d", ddl+1);
1039 sprintf(runNum, "%d", run);
1041 const char* argv[8] = {"-ddl", ddlNum, "-cdbpath", cdbPath, "-run", runNum, "-dont_use_crateid", NULL};
1047 int result = comp.DoInit(argc, argv);
1050 // Error message already generated in DoInit.
1054 std::fstream file(filename, std::ios::out);
1057 std::cerr << "ERROR: could not open file: " << filename << std::endl;
1062 reinterpret_cast<char*>(comp.fTrigRec->LookupTableBuffer()),
1063 comp.fTrigRec->LookupTableSize()
1067 std::cerr << "ERROR: There was a problem writing to the file: " << filename << std::endl;