/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project *
+ * This file is property of and copyright by the ALICE HLT Project *
* All rights reserved. *
* *
* Primary Authors: *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
+ * about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
-/* $Id$ */
+// $Id$
///
/// @file AliHLTMUONMansoTrackerFSMComponent.cxx
FreeMemory();
fWarnForUnexpecedBlock = false;
+ bool makeCandidates = false;
ResetCanLoadFlags();
double zmiddle = 0;
double bfieldintegral = 0;
fWarnForUnexpecedBlock = true;
continue;
}
-
+
+ if (strcmp(argv[i], "-makecandidates") == 0)
+ {
+ makeCandidates = true;
+ continue;
+ }
+
HLTError("Unknown option '%s'.", argv[i]);
return -EINVAL;
}
return -ENOMEM;
}
fTracker->SetCallback(this);
+ fTracker->MakeCandidates(makeCandidates);
// Set all the parameters that were found on the command line.
if (not fCanLoadZmiddle) AliHLTMUONCalculations::Zf(zmiddle);
/// then new configuration parameters are loaded, otherwise nothing is done.
/// \param componentId The name of the component in the current chain.
- bool givenConfigPath = strcmp(cdbEntry, AliHLTMUONConstants::MansoTrackerFSMCDBPath()) == 0;
+ TString path = cdbEntry;
+ bool givenConfigPath = (path == AliHLTMUONConstants::MansoTrackerFSMCDBPath());
if (cdbEntry == NULL or givenConfigPath)
{
if (fCanLoadBL)
{
- result = GetFloatFromTMap(map, "bfieldintegral", value, pathToEntry, "integrated magnetic field");
- if (result != 0) return result;
- AliHLTMUONCalculations::QBL(value);
+ Double_t bfieldintegral;
+ result = FetchFieldIntegral(bfieldintegral);
+ if (result == 0)
+ {
+ AliHLTMUONCalculations::QBL(bfieldintegral);
+ }
+ else
+ {
+ HLTWarning("Failed to load the magnetic field integral from GRP information.");
+ result = GetFloatFromTMap(map, "bfieldintegral", value, pathToEntry, "integrated magnetic field");
+ if (result != 0) return result;
+ HLTWarning(Form("Using deprecated magnetic field integral value of %f T.m.", value));
+ AliHLTMUONCalculations::QBL(value);
+ }
}
if (fCanLoadA[0])
bd.fDataType = AliHLTMUONConstants::MansoTracksBlockDataType();
bd.fSpecification = specification;
outputBlocks.push_back(bd);
- size = block.BytesUsed();
-
+ AliHLTUInt32_t totalSize = block.BytesUsed();
+
+ if (fTracker->MakeCandidates())
+ {
+ AliHLTMUONMansoCandidatesBlockWriter candidatesBlock(outputPtr+totalSize, size-totalSize);
+ if (not candidatesBlock.InitCommonHeader())
+ {
+ HLTError("Buffer overflowed. There are only %d bytes left in the buffer,"
+ " but we need a minimum of %d bytes.",
+ size, sizeof(AliHLTMUONMansoCandidatesBlockWriter::HeaderType)
+ );
+ if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+ size = 0; // Important to tell framework that nothing was generated.
+ return -ENOBUFS;
+ }
+
+ // Fill in the output block buffer.
+ candidatesBlock.SetNumberOfEntries(fTracker->TrackCandidatesCount());
+ for (AliHLTUInt32_t i = 0; i < fTracker->TrackCandidatesCount(); ++i)
+ {
+ candidatesBlock[i] = fTracker->TrackCandidates()[i];
+ }
+
+ fTracker->ZeroTrackCandidatesList();
+
+ AliHLTComponentBlockData bdc;
+ FillBlockData(bdc);
+ bdc.fPtr = outputPtr;
+ bdc.fOffset = totalSize;
+ bdc.fSize = candidatesBlock.BytesUsed();
+ bdc.fDataType = AliHLTMUONConstants::MansoCandidatesBlockDataType();
+ bdc.fSpecification = specification;
+ outputBlocks.push_back(bdc);
+ totalSize += candidatesBlock.BytesUsed();
+ }
+
+ size = totalSize;
return 0;
}
}
else
{
- Logging(kHLTLogError,
- "AliHLTMUONMansoTrackerFSMComponent::AddRecHits",
- "Invalid chamber",
- "Received a data block with data from chamber %d"
- " which is outside the expected range: [7..10].",
- chamberMap[i]
- );
+ if (fWarnForUnexpecedBlock)
+ {
+ Logging(kHLTLogWarning,
+ "AliHLTMUONMansoTrackerFSMComponent::AddRecHits",
+ "Invalid chamber",
+ "Received a data block with data from chamber %d"
+ " which is outside the expected range: [7..10].",
+ chamberMap[i]
+ );
+ }
return;
}
}
AliHLTMUONMansoTrackStruct newTrack;
tracker->FillTrackData(newTrack);
- // Check if there is any track that uses the same hits as the one found.
- // If there is, then use the one that has the higher pT.
+ // The indicies of the duplicate tracks. If set to block->Nentries() then
+ // this indicates the index is not used.
+ AliHLTUInt32_t dup1 = block->Nentries();
+ AliHLTUInt32_t dup2 = block->Nentries();
+
+ // Check if there are any tracks that use the same hits as the one found.
+ // If there are, then use the one that has the highest pT.
+ // There will be at most 2 duplicate tracks.
for (AliHLTUInt32_t i = 0; i < block->Nentries(); i++)
{
AliHLTMUONMansoTrackStruct& track = (*block)[i];
}
if (hasNoDuplicates) continue;
- // The tracks share a hit, so find out if the new track has higher pT
- // If it does, then replace the old track, otherwise simply ignore the new track.
- double newPt = sqrt(newTrack.fPx * newTrack.fPx + newTrack.fPy * newTrack.fPy);
- double oldPt = sqrt(track.fPx * track.fPx + track.fPy * track.fPy);
- if (newPt > oldPt)
+ if (dup1 == block->Nentries())
{
- track = newTrack;
- DebugTrace("\tReplaced track " << i << " with: " << *track);
+ dup1 = i;
+ }
+ else if (dup2 == block->Nentries())
+ {
+ dup2 = i;
+ }
+ else
+ {
+ HLTError("Found more than 2 tracks with duplicate hits. This is completely unexpected. Something is seriously wrong!");
}
- return;
}
- // No track found with duplicate hits so we can add the new track as is.
- AliHLTMUONMansoTrackStruct* track = block->AddEntry();
- if (track == NULL)
+ if (dup1 != block->Nentries() and dup2 != block->Nentries())
{
- Logging(kHLTLogError,
- "AliHLTMUONMansoTrackerFSMComponent::FoundTrack",
- "Buffer overflow",
- "We have overflowed the output buffer for Manso track data."
- " The output buffer size is only %d bytes.",
- block->BufferSize()
- );
- return;
+ // In this case we found 2 duplicate entries.
+ // Figure out which one has the highest pT and keep only that one.
+ AliHLTMUONMansoTrackStruct& track1 = (*block)[dup1];
+ AliHLTMUONMansoTrackStruct& track2 = (*block)[dup2];
+ double newPt = sqrt(newTrack.fPx * newTrack.fPx + newTrack.fPy * newTrack.fPy);
+ double dupPt1 = sqrt(track1.fPx * track1.fPx + track1.fPy * track1.fPy);
+ double dupPt2 = sqrt(track2.fPx * track2.fPx + track2.fPy * track2.fPy);
+
+ if (newPt >= dupPt1 and newPt >= dupPt2)
+ {
+ // The new track must replace both existing tracks.
+ track1 = newTrack;
+ track2 = (*block)[block->Nentries()-1];
+ }
+ else if (dupPt1 >= newPt and dupPt1 >= dupPt2)
+ {
+ // track1 has the highest pT so ignore the new track and delete track2.
+ track2 = (*block)[block->Nentries()-1];
+ }
+ else
+ {
+ // In this case track2 must have the highest pT so ignore the new
+ // track and delete track1.
+ track1 = (*block)[block->Nentries()-1];
+ }
+
+ // Decrement the number of entries because we deleted a track.
+ assert(fTrackCount > 0);
+ assert(block->Nentries() > 0);
+ block->SetNumberOfEntries(block->Nentries()-1);
+ fTrackCount--;
+ }
+ else if (dup1 != block->Nentries())
+ {
+ // Only one track with duplicate hits found.
+ // See if the new track has higher pT. If it does then replace the
+ // exisiting track, otherwise ignore the new track.
+ AliHLTMUONMansoTrackStruct& track1 = (*block)[dup1];
+ double newPt = sqrt(newTrack.fPx * newTrack.fPx + newTrack.fPy * newTrack.fPy);
+ double dupPt1 = sqrt(track1.fPx * track1.fPx + track1.fPy * track1.fPy);
+ if (newPt >= dupPt1)
+ {
+ track1 = newTrack;
+ }
+ }
+ else
+ {
+ // No track found with duplicate hits so we can add the new track as it is.
+ AliHLTMUONMansoTrackStruct* track = block->AddEntry();
+ if (track == NULL)
+ {
+ Logging(kHLTLogError,
+ "AliHLTMUONMansoTrackerFSMComponent::FoundTrack",
+ "Buffer overflow",
+ "We have overflowed the output buffer for Manso track data."
+ " The output buffer size is only %d bytes.",
+ block->BufferSize()
+ );
+ return;
+ }
+
+ fTrackCount++;
+ *track = newTrack;
+ DebugTrace("\tAdded new track: " << *track);
}
-
- fTrackCount++;
- *track = newTrack;
- DebugTrace("\tAdded new track: " << *track);
}