* provided "as is" without express or implied warranty. *
**************************************************************************/
-/* $Id$ */
+// $Id$
///
/// @file AliHLTMUONHitReconstructorComponent.cxx
#include "AliHLTLogging.h"
#include "AliHLTSystem.h"
#include "AliHLTDefinitions.h"
+#include "AliHLTCDHWrapper.h"
#include <cstdlib>
#include <cerrno>
#include <cassert>
fLutSize(0),
fLut(NULL),
fIdToEntry(),
+ fMaxEntryPerBusPatch(),
fWarnForUnexpecedBlock(false),
- fDelaySetup(false)
+ fUseIdealGain(false),
+ fWarnIfPadSkipped(false)
{
///
/// Default constructor.
}
-void AliHLTMUONHitReconstructorComponent::GetInputDataTypes( std::vector<AliHLTComponentDataType>& list)
+void AliHLTMUONHitReconstructorComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
{
///
/// Inherited from AliHLTProcessor. Returns the list of expected input data types.
/// Inherited from AliHLTComponent. Returns the output data type.
///
- return AliHLTMUONConstants::RecHitsBlockDataType();
+ return kAliHLTMultipleDataType;
}
-void AliHLTMUONHitReconstructorComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+int AliHLTMUONHitReconstructorComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
+{
+ /// Inherited from AliHLTComponent. Returns the output data types.
+
+ assert( list.empty() );
+ list.push_back( AliHLTMUONConstants::RecHitsBlockDataType() );
+ list.push_back( AliHLTMUONConstants::ClusterBlockDataType() );
+ list.push_back( AliHLTMUONConstants::ChannelBlockDataType() );
+ return list.size();
+}
+
+
+void AliHLTMUONHitReconstructorComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
{
///
/// Inherited from AliHLTComponent. Returns an estimate of the expected output data size.
///
- constBase = sizeof(AliHLTMUONRecHitsBlockWriter::HeaderType);
+ constBase = sizeof(AliHLTMUONRecHitsBlockWriter::HeaderType) + 1024*1024;
inputMultiplier = 1;
}
///
HLTInfo("Initialising dHLT hit reconstruction component.");
+
+ // Inherit the parents functionality.
+ int result = AliHLTMUONProcessor::DoInit(argc, argv);
+ if (result != 0) return result;
// Must make sure that fHitRec and fLut is deleted if it is still
// allocated for whatever reason.
FreeMemory();
- try
- {
- fHitRec = new AliHLTMUONHitReconstructor();
- }
- catch (const std::bad_alloc&)
- {
- HLTError("Could not allocate more memory for the hit reconstructor component.");
- return -ENOMEM;
- }
-
// Initialise fields with default values then parse the command line.
fDDL = -1;
fIdToEntry.clear();
+ fMaxEntryPerBusPatch.clear();
fWarnForUnexpecedBlock = false;
- fDelaySetup = false;
-
+ fUseIdealGain = false;
+ fWarnIfPadSkipped = false;
const char* lutFileName = NULL;
- const char* cdbPath = NULL;
- Int_t run = -1;
bool useCDB = false;
- bool tryRecover = false;
+ typedef AliHLTMUONHitReconstructor HR;
+ HR::ERecoveryMode recoveryMode = HR::kDontTryRecover;
AliHLTInt32_t dccut = -1;
+ bool skipParityErrors = false;
+ bool dontPrintParityErrors = false;
+ bool makeClusters = false;
+ bool makeChannels = false;
for (int i = 0; i < argc; i++)
{
- HLTDebug("argv[%d] == %s", i, argv[i]);
+ // To keep the legacy behaviour we need to have the following check
+ // for -cdbpath here, before ArgumentAlreadyHandled.
+ if (strcmp(argv[i], "-cdbpath") == 0)
+ {
+ useCDB = true;
+ }
+
+ if (ArgumentAlreadyHandled(i, argv[i])) continue;
if (strcmp( argv[i], "-ddl" ) == 0)
{
if (argc <= i+1)
{
- HLTError("The DDL number was not specified. Must be in the range [13..20].");
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+ HLTError("The DDL number was not specified. Must be in the range [1..20].");
return -EINVAL;
}
if (cpErr == NULL or *cpErr != '\0')
{
HLTError("Cannot convert '%s' to DDL a number.", argv[i+1] );
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
return -EINVAL;
}
- if (num < 13 or 20 < num)
+ if (num < 1 or 20 < num)
{
- HLTError("The DDL number must be in the range [13..20].");
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+ HLTError("The DDL number must be in the range [1..20].");
return -EINVAL;
}
- fDDL = num - 1; // convert to range [12..19]
+ fDDL = num - 1; // convert to range [0..19]
i++;
continue;
if ( argc <= i+1 )
{
- HLTError("DDL equipment ID number not specified. It must be in the range [2572..2579]" );
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+ HLTError("DDL equipment ID number not specified. It must be in the range [2560..2579]" );
return -EINVAL;
}
if (cpErr == NULL or *cpErr != '\0')
{
HLTError("Cannot convert '%s' to a DDL equipment ID Number.", argv[i+1]);
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
return -EINVAL;
}
fDDL = AliHLTMUONUtils::EquipIdToDDLNumber(num); // Convert to DDL number in the range 0..21
- if (fDDL < 12 or 19 < fDDL)
+ if (fDDL < 0 or 19 < fDDL)
{
- HLTError("The DDL equipment ID number must be in the range [2572..2579].");
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+ HLTError("The DDL equipment ID number must be in the range [2560..2579].");
return -EINVAL;
}
if (argc <= i+1)
{
HLTError("The lookup table filename was not specified.");
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
return -EINVAL;
}
lutFileName = argv[i+1];
continue;
} // -cdb argument
- if (strcmp( argv[i], "-cdbpath" ) == 0)
- {
- if (cdbPath != NULL)
- {
- HLTWarning("CDB path was already specified."
- " Will replace previous value given by -cdbpath."
- );
- }
-
- if ( argc <= i+1 )
- {
- HLTError("The CDB path was not specified." );
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
- return -EINVAL;
- }
- cdbPath = argv[i+1];
- useCDB = true;
- i++;
- continue;
- } // -cdb argument
-
- if (strcmp( argv[i], "-run" ) == 0)
- {
- if (run != -1)
- {
- HLTWarning("Run number was already specified."
- " Will replace previous value given by -run."
- );
- }
-
- if ( argc <= i+1 )
- {
- HLTError("The run number was not specified." );
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
- return -EINVAL;
- }
-
- char* cpErr = NULL;
- run = Int_t( strtol(argv[i+1], &cpErr, 0) );
- if (cpErr == NULL or *cpErr != '\0' or run < 0)
- {
- HLTError("Cannot convert '%s' to a valid run number."
- " Expected a positive integer value.", argv[i+1]
- );
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
- return -EINVAL;
- }
-
- i++;
- continue;
- } // -run argument
-
if (strcmp( argv[i], "-dccut" ) == 0)
{
if (dccut != -1)
if ( argc <= i+1 )
{
HLTError("No DC cut value was specified. It should be a positive integer value." );
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
return -EINVAL;
}
HLTError("Cannot convert '%s' to a valid DC cut value."
" Expected a positive integer value.", argv[i+1]
);
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
return -EINVAL;
}
continue;
}
- if (strcmp( argv[i], "-delaysetup" ) == 0)
+ if (strcmp( argv[i], "-warn_on_unexpected_block" ) == 0)
{
- fDelaySetup = true;
+ fWarnForUnexpecedBlock = true;
continue;
}
- if (strcmp( argv[i], "-warn_on_unexpected_block" ) == 0)
+ if (strcmp( argv[i], "-tryrecover" ) == 0)
{
- fWarnForUnexpecedBlock = true;
+ if (argc > i+1)
+ {
+ // There might be an optional parameter so check
+ // if it is a recognised one. If not then assume it
+ // is the next argument, so no error message.
+ if (strcmp(argv[i+1], "full") == 0)
+ {
+ recoveryMode = HR::kRecoverFull;
+ i++;
+ }
+ else if (strcmp(argv[i+1], "skip") == 0)
+ {
+ recoveryMode = HR::kRecoverJustSkip;
+ i++;
+ }
+ else if (strcmp(argv[i+1], "parityerrors") == 0)
+ {
+ recoveryMode = HR::kRecoverFromParityErrorsOnly;
+ i++;
+ }
+ else
+ {
+ recoveryMode = HR::kRecoverFull;
+ }
+ }
+ else
+ {
+ recoveryMode = HR::kRecoverFull;
+ }
continue;
}
- if (strcmp( argv[i], "-tryrecover" ) == 0)
+ if (strcmp( argv[i], "-skipparityerrors" ) == 0)
{
- tryRecover = true;
+ skipParityErrors = true;
+ continue;
+ }
+
+ if (strcmp( argv[i], "-dontprintparityerrors" ) == 0)
+ {
+ dontPrintParityErrors = true;
+ continue;
+ }
+
+ if (strcmp( argv[i], "-useidealgain" ) == 0)
+ {
+ fUseIdealGain = true;
+ continue;
+ }
+
+ if (strcmp( argv[i], "-makeclusters" ) == 0)
+ {
+ makeClusters = true;
+ continue;
+ }
+
+ if (strcmp( argv[i], "-makechannels" ) == 0)
+ {
+ makeChannels = true;
+ continue;
+ }
+
+ if (strcmp( argv[i], "-warnifpadskipped" ) == 0)
+ {
+ fWarnIfPadSkipped = true;
continue;
}
HLTError("Unknown option '%s'", argv[i]);
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
return -EINVAL;
} // for loop
+ try
+ {
+ fHitRec = new AliHLTMUONHitReconstructor();
+ }
+ catch (const std::bad_alloc&)
+ {
+ HLTError("Could not allocate more memory for the hit reconstructor component.");
+ return -ENOMEM;
+ }
+
if (dccut != -1 and useCDB)
{
HLTWarning("The -cdb or -cdbpath parameter was specified, which indicates that"
if (lutFileName == NULL) useCDB = true;
- if (fDDL == -1 and not fDelaySetup)
+ if (fDDL == -1 and not DelaySetup())
{
HLTWarning("DDL number not specified. Cannot check if incomming data is valid.");
}
- if (cdbPath != NULL or run != -1)
- {
- int result = SetCDBPathAndRunNo(cdbPath, run);
- if (result != 0)
- {
- // Error messages already generated in SetCDBPathAndRunNo.
- FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
- return result;
- }
- }
-
if (useCDB)
{
- if (not fDelaySetup)
+ if (not DelaySetup())
{
HLTInfo("Loading lookup table information from CDB for DDL %d (ID = %d).",
fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
);
- int result = ReadLutFromCDB();
+ result = ReadLutFromCDB();
if (result != 0)
{
// Error messages already generated in ReadLutFromCDB.
FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
return result;
}
- fHitRec->SetLookUpTable(fLut, &fIdToEntry);
+ fHitRec->SetLookUpTable(fLut, &fIdToEntry, &fMaxEntryPerBusPatch);
}
}
else
{
HLTInfo("Loading lookup table information from file %s.", lutFileName);
- int result = ReadLookUpTable(lutFileName);
+ result = ReadLookUpTable(lutFileName);
if (result != 0)
{
// Error messages already generated in ReadLookUpTable.
FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
return result;
}
- fHitRec->SetLookUpTable(fLut, &fIdToEntry);
+ fHitRec->SetLookUpTable(fLut, &fIdToEntry, &fMaxEntryPerBusPatch);
}
if (dccut == -1)
{
- if (not fDelaySetup)
+ if (not DelaySetup())
{
HLTInfo("Loading DC cut parameters from CDB for DDL %d (ID = %d).",
fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
);
- int result = ReadDCCutFromCDB();
+ result = ReadDCCutFromCDB();
if (result != 0)
{
// Error messages already generated in ReadDCCutFromCDB.
HLTDebug("Using DC cut parameter of %d ADC channels.", fHitRec->GetDCCut());
}
- fHitRec->TryRecover(tryRecover);
-
+ fHitRec->TryRecover(recoveryMode);
+ fHitRec->SkipParityErrors(skipParityErrors);
+ fHitRec->DontPrintParityErrors(dontPrintParityErrors);
+ fHitRec->GenerateClusterInfo(makeClusters);
+ fHitRec->GenerateChannelInfo(makeChannels);
+ fHitRec->DDLNumber(fDDL);
+ //The DDL number has to be set before the following InitDetElemInDDLArray() method
+ fHitRec->InitDetElemInDDLArray();
+ HLTDebug("dHLT hit reconstruction component is initialized.");
return 0;
}
///
/// Inherited from AliHLTComponent. Performs a cleanup of the component.
///
-
+ fHitRec->DeInitDetElemInDDLArray();
HLTInfo("Deinitialising dHLT hit reconstruction component.");
FreeMemory();
return 0;
/// cut parameter if 'cdbEntry' equals "HLT/ConfigMUON/HitReconstructor".
/// \param componentId The name of the component in the current chain.
- bool startsWithMUON = TString(cdbEntry).Index("MUON/", 5, 0, TString::kExact) == 0;
- bool givenConfigPath = strcmp(cdbEntry, AliHLTMUONConstants::HitReconstructorCDBPath()) == 0;
+ TString path = cdbEntry;
+ bool startsWithMUON = path.Index("MUON/", 5, 0, TString::kExact) == 0;
+ bool givenConfigPath = (path == AliHLTMUONConstants::HitReconstructorCDBPath());
if (cdbEntry == NULL or startsWithMUON or givenConfigPath)
{
}
fIdToEntry.clear();
-
+ fMaxEntryPerBusPatch.clear();
int result = ReadLutFromCDB();
if (result != 0) return result;
- fHitRec->SetLookUpTable(fLut, &fIdToEntry);
+ fHitRec->SetLookUpTable(fLut, &fIdToEntry, &fMaxEntryPerBusPatch);
}
if (cdbEntry == NULL or not startsWithMUON)
int AliHLTMUONHitReconstructorComponent::DoEvent(
const AliHLTComponentEventData& evtData,
const AliHLTComponentBlockData* blocks,
- AliHLTComponentTriggerData& /*trigData*/,
+ AliHLTComponentTriggerData& trigData,
AliHLTUInt8_t* outputPtr,
AliHLTUInt32_t& size,
- std::vector<AliHLTComponentBlockData>& outputBlocks
+ AliHLTComponentBlockDataList& outputBlocks
)
{
///
/// Inherited from AliHLTProcessor. Processes the new event data.
///
-
+
// Initialise the LUT and DC cut parameter from CDB if we were requested
// to initialise only when the first event was received.
- if (fDelaySetup)
+ if (DelaySetup())
{
// Use the specification given by the first data block if we
// have not been given a DDL number on the command line.
int result = ReadLutFromCDB();
if (result != 0) return result;
- fHitRec->SetLookUpTable(fLut, &fIdToEntry);
+ fHitRec->SetLookUpTable(fLut, &fIdToEntry, &fMaxEntryPerBusPatch);
}
// Check that the DC cut was not already loaded in DoInit.
if (result != 0) return result;
}
- fDelaySetup = false;
+ DoneDelayedSetup();
}
if (fLut == NULL)
HLTWarning("Received a data block of a type we cannot handle: '%s', spec: 0x%X",
DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification
);
+#ifdef __DEBUG
else
HLTDebug("Received a data block of a type we cannot handle: '%s', spec: 0x%X",
DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification
);
+#endif
continue;
}
break;
}
+ AliHLTCDHWrapper cdh(blocks[n].fPtr);
+
+ AliHLTUInt32_t headerSize = cdh.GetHeaderSize();
+
AliHLTUInt32_t totalDDLSize = blocks[n].fSize / sizeof(AliHLTUInt32_t);
- AliHLTUInt32_t ddlRawDataSize = totalDDLSize - fHitRec->GetkDDLHeaderSize();
- AliHLTUInt32_t* buffer = reinterpret_cast<AliHLTUInt32_t*>(
- reinterpret_cast<char*>(blocks[n].fPtr) + blocks[n].fOffset
- ) + fHitRec->GetkDDLHeaderSize();
+ AliHLTUInt32_t ddlRawDataSize = totalDDLSize - headerSize / sizeof(AliHLTUInt32_t);
+ AliHLTUInt32_t* buffer = reinterpret_cast<AliHLTUInt32_t*>(blocks[n].fPtr)
+ + headerSize/sizeof(AliHLTUInt32_t);
AliHLTUInt32_t nofHit = block.MaxNumberOfEntries();
#ifdef DEBUG
if (not fHitRec->Run(buffer, ddlRawDataSize, block.GetArray(), nofHit))
{
HLTError("Error while processing the hit reconstruction algorithm.");
+ if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
size = totalSize; // Must tell the framework how much buffer space was used.
return -EIO;
}
// Increase the total amount of data written so far to our output memory
totalSize += block.BytesUsed();
+
+ if (fHitRec->GenerateClusterInfo())
+ {
+ // Create a new output clusters data block and initialise the header.
+ AliHLTMUONClustersBlockWriter clustblock(outputPtr+totalSize, size-totalSize);
+ if (not clustblock.InitCommonHeader())
+ {
+ HLTError("There is not enough space in the output buffer for the new clusters data block."
+ " We require at least %u bytes, but have %u bytes left.",
+ sizeof(AliHLTMUONClustersBlockWriter::HeaderType),
+ clustblock.BufferSize()
+ );
+ break;
+ }
+
+ AliHLTUInt32_t nofClusters = clustblock.MaxNumberOfEntries();
+ bool filledOk = fHitRec->FillClusterData(clustblock.GetArray(), nofClusters);
+ // nofClusters should now contain the number of clusters filled.
+ assert( nofClusters <= clustblock.MaxNumberOfEntries() );
+ clustblock.SetNumberOfEntries(nofClusters);
+
+ // Fill a block data structure for our output block.
+ AliHLTComponentBlockData bdc;
+ FillBlockData(bdc);
+ bdc.fPtr = outputPtr;
+ // This block's start (offset) is after all other blocks written so far.
+ bdc.fOffset = totalSize;
+ bdc.fSize = clustblock.BytesUsed();
+ bdc.fDataType = AliHLTMUONConstants::ClusterBlockDataType();
+ bdc.fSpecification = blocks[n].fSpecification;
+ outputBlocks.push_back(bdc);
+
+ // Increase the total amount of data written so far to our output memory
+ totalSize += clustblock.BytesUsed();
+
+ if (not filledOk)
+ {
+ HLTError("We have overflowed the output buffer space for the new clusters data block.");
+ break;
+ }
+ }
+
+ if (fHitRec->GenerateChannelInfo())
+ {
+ // Create a new output channels data block and initialise the header.
+ AliHLTMUONChannelsBlockWriter channelblock(outputPtr+totalSize, size-totalSize);
+ if (not channelblock.InitCommonHeader())
+ {
+ HLTError("There is not enough space in the output buffer for the new channels data block."
+ " We require at least %u bytes, but have %u bytes left.",
+ sizeof(AliHLTMUONChannelsBlockWriter::HeaderType),
+ channelblock.BufferSize()
+ );
+ break;
+ }
+
+ AliHLTUInt32_t nofChannels = channelblock.MaxNumberOfEntries();
+ bool filledOk = fHitRec->FillChannelData(channelblock.GetArray(), nofChannels);
+ // nofChannels should now contain the number of channels filled.
+ assert( nofChannels <= channelblock.MaxNumberOfEntries() );
+ channelblock.SetNumberOfEntries(nofChannels);
+
+ // Fill a block data structure for our output block.
+ AliHLTComponentBlockData bdc;
+ FillBlockData(bdc);
+ bdc.fPtr = outputPtr;
+ // This block's start (offset) is after all other blocks written so far.
+ bdc.fOffset = totalSize;
+ bdc.fSize = channelblock.BytesUsed();
+ bdc.fDataType = AliHLTMUONConstants::ChannelBlockDataType();
+ bdc.fSpecification = blocks[n].fSpecification;
+ outputBlocks.push_back(bdc);
+
+ // Increase the total amount of data written so far to our output memory
+ totalSize += channelblock.BytesUsed();
+
+ if (not filledOk)
+ {
+ HLTError("We have overflowed the output buffer space for the new channels data block.");
+ break;
+ }
+ }
}
// Finally we set the total size of output memory we consumed.
size = totalSize;
}
fIdToEntry.clear();
+ fMaxEntryPerBusPatch.clear();
}
assert( fLut == NULL );
assert( fLutSize == 0 );
assert( fIdToEntry.empty() );
+ assert( fMaxEntryPerBusPatch.empty() );
std::ifstream file(lutFileName);
if (not file.good())
return -EIO;
}
- AliHLTInt32_t idManuChannel;
+ AliHLTInt32_t idManuChannel,buspatchId;
for (AliHLTUInt32_t i = 1; i < fLutSize; i++)
{
if (std::getline(file, str).fail())
}
int result = sscanf(
- str.c_str(), "%d\t%d\t%d\t%d\t%e\t%e\t%e\t%e\t%d\t%e\t%e\t%e\t%e\t%d\t%d",
+ str.c_str(), "%14d\t%14d\t%14d\t%14d\t%23e\t%23e\t%23e\t%23e\t%14d\t%23e\t%23e\t%23e\t%23e\t%14d\t%14d",
&idManuChannel, &fLut[i].fDetElemId, &fLut[i].fIX,
&fLut[i].fIY, &fLut[i].fRealX,
&fLut[i].fRealY, &fLut[i].fRealZ,
HLTError("Line %d in LUT file %s does not contain 15 elements.", i, lutFileName);
return -EIO;
}
-
+ buspatchId = (idManuChannel>>17) & 0x7FF;
fIdToEntry[idManuChannel] = i;
+ fMaxEntryPerBusPatch[buspatchId] = fMaxEntryPerBusPatch[buspatchId] + 1;
+
+ }
+
+ MaxEntryPerBusPatch::iterator it;
+ for(it=fMaxEntryPerBusPatch.begin(); it!=fMaxEntryPerBusPatch.end(); it++){
+ HLTDebug("fMaxEntryPerBusPatch[%d] : %d",it->first,it->second);
+ fMaxEntryPerBusPatch[it->first] = AliHLTInt32_t(0.05*(it->second));///< for 10% occupancy
+ HLTDebug("fMaxEntryPerBusPatch[%d] : %d",it->first,it->second);
}
return 0;
assert( fLut == NULL );
assert( fLutSize == 0 );
assert( fIdToEntry.empty() );
+ assert( fMaxEntryPerBusPatch.empty() );
if (fDDL == -1)
{
HLTError("Failed to load geomerty data.");
return -ENOENT;
}
-
+
AliMUONCalibrationData calibData(AliCDBManager::Instance()->GetRun());
+ bool skippedPads = false;
Int_t chamberId;
- for(Int_t iCh = 6; iCh < 10; iCh++)
+ for(Int_t iCh = 0; iCh < 10; iCh++)
{
chamberId = iCh;
Int_t idManuChannel, manuId, channelId, buspatchId;
AliHLTFloat32_t padSizeX, padSizeY;
AliHLTFloat32_t halfPadSize;
+ AliHLTFloat32_t padSizeXY;
Double_t realX, realY, realZ;
Double_t localX, localY, localZ;
Float_t calibA0Coeff,calibA1Coeff,pedestal,sigma;
- Int_t thresold,saturation;
+ Float_t thresold,saturation;
// Pad Info of a slat to print in lookuptable
for (Int_t iX = 0; iX<= maxIX ; iX++)
for (Int_t iY = 0; iY<= maxIY ; iY++)
{
+#ifndef HAVE_NOT_MUON_ALIMPPAD_GETPOSITION
+ if (not seg->HasPadByIndices(iX,iY)) continue;
+#else // old AliMpPad functionality < r 31742
if (not seg->HasPad(AliMpIntPair(iX,iY))) continue;
+#endif
+#ifndef HAVE_NOT_MUON_ALIMPPAD_GETPOSITION
+ AliMpPad pad = seg->PadByIndices(iX,iY, kFALSE);
+#else // old AliMpPad functionality < r 31742
AliMpPad pad = seg->PadByIndices(AliMpIntPair(iX,iY), kFALSE);
+#endif
// Getting Manu id
+#ifndef HAVE_NOT_MUON_ALIMPPAD_GETPOSITION
+ manuId = pad.GetManuId();
+#else // old AliMpPad functionality < r 31742
manuId = pad.GetLocation().GetFirst();
+#endif
manuId &= 0x7FF; // 11 bits
+ if (calibData.Gains(detElemId, manuId) == NULL) continue;
+ if (calibData.Pedestals(detElemId, manuId) == NULL) continue;
buspatchId = ddlStore->GetBusPatchId(detElemId,manuId);
// Getting channel id
+#ifndef HAVE_NOT_MUON_ALIMPPAD_GETPOSITION
+ channelId = pad.GetManuChannel();
+#else // old AliMpPad functionality < r 31742
channelId = pad.GetLocation().GetSecond();
+#endif
channelId &= 0x3F; // 6 bits
idManuChannel = buspatchId << 11;
idManuChannel = (idManuChannel | manuId) << 6;
idManuChannel |= channelId;
+#ifndef HAVE_NOT_MUON_ALIMPPAD_GETPOSITION
+ localX = pad.GetPositionX();
+ localY = pad.GetPositionY();
+#else // old AliMpPad functionality < r 31769
localX = pad.Position().X();
localY = pad.Position().Y();
+#endif //HAVE_NOT_MUON_ALIMPPAD_GETPOSITION
localZ = 0.0;
chamberGeometryTransformer.Local2Global(
realX,realY,realZ
);
- padSizeX = pad.Dimensions().X();
- padSizeY = pad.Dimensions().Y();
+#ifndef HAVE_NOT_MUON_ALIMPPAD_GETPOSITION
+ padSizeX = AliHLTFloat32_t( pad.GetDimensionX() );
+ padSizeY = AliHLTFloat32_t( pad.GetDimensionY() );
+#else // old AliMpPad functionality < r 31769
+ padSizeX = AliHLTFloat32_t( pad.Dimensions().X() );
+ padSizeY = AliHLTFloat32_t( pad.Dimensions().Y() );
+#endif //HAVE_NOT_MUON_ALIMPPAD_GETPOSITION
- calibA0Coeff = (calibData.Gains(detElemId, manuId))->ValueAsFloat(channelId, 0);
- calibA1Coeff = (calibData.Gains(detElemId, manuId))->ValueAsFloat(channelId, 1);
- thresold = (calibData.Gains(detElemId, manuId))->ValueAsInt(channelId, 2);
- saturation = (calibData.Gains(detElemId, manuId))->ValueAsInt(channelId, 4);
+ if (fUseIdealGain)
+ {
+ calibA0Coeff = 1.0;
+ calibA1Coeff = 0.0;
+ thresold = 0;
+ saturation = 0;
+ }
+ else
+ {
+ calibA0Coeff = (calibData.Gains(detElemId, manuId))->ValueAsFloat(channelId, 0);
+ calibA1Coeff = (calibData.Gains(detElemId, manuId))->ValueAsFloat(channelId, 1);
+ thresold = (calibData.Gains(detElemId, manuId))->ValueAsFloat(channelId, 2);
+ saturation = (calibData.Gains(detElemId, manuId))->ValueAsFloat(channelId, 4);
+ }
pedestal = (calibData.Pedestals(detElemId, manuId))->ValueAsFloat(channelId, 0);
sigma = (calibData.Pedestals(detElemId, manuId))->ValueAsFloat(channelId, 1);
- if (plane == 0)
+ // Check if any of the values fetched from the calibration data are
+ // invalid. If they are then skip this pad.
+ if (calibA0Coeff == AliMUONVCalibParam::InvalidFloatValue() or
+ calibA1Coeff == AliMUONVCalibParam::InvalidFloatValue() or
+ thresold == AliMUONVCalibParam::InvalidFloatValue() or
+ saturation == AliMUONVCalibParam::InvalidFloatValue() or
+ pedestal == AliMUONVCalibParam::InvalidFloatValue() or
+ sigma == AliMUONVCalibParam::InvalidFloatValue()
+ )
+ {
+ if (fWarnIfPadSkipped)
+ {
+ HLTWarning("Skipping pad on detection element %d, MANU %d, channel %d, since"
+ " the calibration data contains invalid values in that channel.",
+ detElemId, manuId, channelId
+ );
+ }
+ skippedPads = true;
+ continue;
+ }
+
+
+ if (plane == 0){
halfPadSize = padSizeX;
- else
+ padSizeXY = padSizeY;
+ }else{
halfPadSize = padSizeY;
-
+ padSizeXY = padSizeX;
+ }
+
fIdToEntry[idManuChannel] = iEntry+1;
-
+ fMaxEntryPerBusPatch[buspatchId] = fMaxEntryPerBusPatch[buspatchId] + 1;
+
lut.fDetElemId = detElemId;
lut.fIX = iX;
lut.fIY = iY;
lut.fRealY = realY;
lut.fRealZ = realZ;
lut.fHalfPadSize = halfPadSize;
+ lut.fPadSizeXY = padSizeXY;
lut.fPlane = plane;
lut.fPed = pedestal;
lut.fSigma = sigma;
lut.fA0 = calibA0Coeff;
lut.fA1 = calibA1Coeff;
- lut.fThres = thresold;
- lut.fSat = saturation;
+ lut.fThres = Int_t(thresold);
+ lut.fSat = Int_t(saturation);
+
+ HLTDebug("lut : detele : %d, id : %d, manu : %d, channel : %d, iX : %d, iY: %d, (X,Y) : (%f, %f), padsize : %f, plane : %d, ped : %f, sigma : %f",
+ lut.fDetElemId,idManuChannel,manuId,channelId,lut.fIX,lut.fIY,lut.fRealX,lut.fRealY,lut.fHalfPadSize,lut.fPlane,lut.fPed,lut.fSigma
+ );
lutList.push_back(lut);
iEntry++;
} // iCath loop
} // detElemId loop
} // ichamber loop
+
+ if (skippedPads and not fWarnIfPadSkipped)
+ {
+ HLTWarning("Skipped pads since they contained invalid calibration values."
+ " Use the -warnifpadskipped argument to generate detailed information"
+ " about which pads were skipped."
+ );
+ }
try
{
// which is used as a sentinel value.
fLut = new AliHLTMUONHitRecoLutRow[iEntry+1];
fLutSize = iEntry+1;
+ HLTDebug("Address of new LUT buffer at fLut = %p", fLut);
}
catch (const std::bad_alloc&)
{
HLTError("Could not allocate more memory for the lookuptable.");
+ //lutList.clear(); not necessary, implicitly done during stack cleanup.
return -ENOMEM;
}
fLut[0].fRealY = 0.0;
fLut[0].fRealZ = 0.0;
fLut[0].fHalfPadSize = 0.0;
+ fLut[0].fPadSizeXY = 0.0;
fLut[0].fPlane = -1;
fLut[0].fPed = -1;
fLut[0].fSigma = -1;
for (AliHLTUInt32_t i = 0; i < iEntry; i++)
fLut[i+1] = lutList[i];
-
+ lutList.clear();
+
+ MaxEntryPerBusPatch::iterator it;
+ for(it=fMaxEntryPerBusPatch.begin(); it!=fMaxEntryPerBusPatch.end(); it++){
+ HLTDebug("fMaxEntryPerBusPatch[%d] : %d",it->first,it->second);
+ fMaxEntryPerBusPatch[it->first] = AliHLTInt32_t(0.05*(it->second));///< for 10% occupancy
+ HLTDebug("fMaxEntryPerBusPatch[%d] : %d",it->first,it->second);
+ }
+
return 0;
}
/// Generates a ASCII text file containing the lookup table (LUT) from
/// the CDB, which can be used for the hit reconstructor component later.
/// @param ddl Must be the DDL for which to generate the DDL,
- /// in the range [13..20].
+ /// in the range [0..19].
/// @param filename The name of the LUT file to generate.
/// @param cdbPath The CDB path to use.
/// @param run The run number to use for the CDB.
AliHLTMUONHitReconstructorComponent comp;
- if (ddl < 12 or 19 < ddl)
+ if (ddl < 0 or 19 < ddl)
{
- std::cerr << "ERROR: the DDL number must be in the range [12..19]." << std::endl;
+ std::cerr << "ERROR: the DDL number must be in the range [0..19]." << std::endl;
return false;
}