#include "AliHLTTPCTransform.h"
#include "AliHLTTPCClusterMCData.h"
#include "AliHLTTPCClusterTransformation.h"
+#include "AliHLTErrorGuard.h"
#include "AliRawDataHeader.h"
#include "AliCDBManager.h"
#include "AliCDBPath.h"
return new AliHLTTPCDataCompressionComponent;
}
+void AliHLTTPCDataCompressionComponent::GetOCDBObjectDescription(TMap* const targetMap)
+{
+ /// Get a list of OCDB object needed for the particular component
+ if (!targetMap) return;
+
+ targetMap->Add(new TObjString("HLT/ConfigTPC/TPCDataCompressor"),
+ new TObjString("component arguments"));
+ if (fDeflaterMode==2) {
+ targetMap->Add(new TObjString("HLT/ConfigTPC/TPCDataCompressorHuffmanTables"),
+ new TObjString("huffman tables for deflater mode 2"));
+ }
+}
+
int AliHLTTPCDataCompressionComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
const AliHLTComponentBlockData* /*inputBlocks*/,
AliHLTComponentTriggerData& /*trigData*/,
AliHLTUInt32_t outputDataSize=0;
int allClusters=0;
int associatedClusters=0;
+ float bz=GetBz();
/// input track array
vector<AliHLTGlobalBarrelTrack> inputTrackArray;
}
}
+ vector<int> trackindexmap; // stores index for every track id
+
// track data input
- if (fMode==2) {
+ if (fMode==2 || fMode==4) {
for (pDesc=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
pDesc!=NULL; pDesc=GetNextInputBlock()) {
if (GetBenchmarkInstance()) {
if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(pTracks, pDesc->fSize, inputTrackArray))<0) {
return iResult;
}
+ trackindexmap.resize(inputTrackArray.size(), -1);
}
}
}
// processing
+ int trackindex=0;
for (vector<AliHLTGlobalBarrelTrack>::iterator track=inputTrackArray.begin();
track!=inputTrackArray.end();
- track++) {
+ track++, trackindex++) {
int trackID=track->GetID();
if (trackID<0) {
// FIXME: error guard
HLTError("invalid track ID");
continue;
}
+ if (trackID>=(int)trackindexmap.size())
+ trackindexmap.resize(trackID+1, -1);
+ trackindexmap[trackID]=trackindex;
if (fVerbosity>0) {
UInt_t nofPoints=track->GetNumberOfPoints();
AliHLTTPCTrackGeometry* trackpoints=new AliHLTTPCTrackGeometry;
if (!trackpoints) continue;
+ HLTDebug("track %d id %d:", trackindex, trackID);
+
+ // in order to avoid rounding errors the track points are
+ // calculated in exactly the same way as in the decoding
+ // Thats why the track instance can not be used directly
+ // but a new instance is created from the values in the
+ // storage format.
+ // think about moving that to some common code used by
+ // both compression and decoding
+ AliHLTExternalTrackParam param;
+ memset(¶m, 0, sizeof(param));
+ float alpha=track->GetAlpha();
+ while (alpha<0.) alpha+=TMath::TwoPi();
+ while (alpha>TMath::TwoPi()) alpha-=TMath::TwoPi();
+ AliHLTUInt8_t tSlice=AliHLTUInt8_t(9*alpha/TMath::Pi());
+ param.fAlpha =( tSlice + 0.5 ) * TMath::Pi() / 9.0;
+ if (param.fAlpha>TMath::TwoPi()) param.fAlpha-=TMath::TwoPi();
+ param.fX = track->GetX();
+ param.fY = track->GetY();
+ param.fZ = track->GetZ();
+ param.fSinPsi = track->GetSnp();
+ param.fTgl = track->GetTgl();
+ param.fq1Pt = track->GetSigned1Pt();
+ AliHLTGlobalBarrelTrack ctrack(param);
+ ctrack.CalculateHelixParams(bz);
trackpoints->InitDriftTimeTransformation(fDriftTimeFactorA, fDriftTimeOffsetA, fDriftTimeFactorC, fDriftTimeOffsetC);
trackpoints->SetTrackId(trackID);
- trackpoints->CalculateTrackPoints(*track);
+ trackpoints->CalculateTrackPoints(ctrack);
trackpoints->RegisterTrackPoints(fTrackGrid);
track->SetTrackGeometry(trackpoints);
}
GetBenchmarkInstance()->Start(5);
}
allClusters+=fSpacePointGrid->GetNumberOfSpacePoints();
- iResult=ProcessTrackClusters(&inputTrackArray[0], inputTrackArray.size(), fTrackGrid, fSpacePointGrid, fRawInputClusters, slice, patch);
+ iResult=ProcessTrackClusters(&inputTrackArray[0], inputTrackArray.size(), fTrackGrid, trackindexmap, fSpacePointGrid, fRawInputClusters, slice, patch);
int assignedInThisPartition=0;
if (iResult>=0) {
assignedInThisPartition=iResult;
associatedClusters+=iResult;
}
- iResult=ProcessRemainingClusters(&inputTrackArray[0], inputTrackArray.size(), fTrackGrid, fSpacePointGrid, fRawInputClusters, slice, patch);
+ iResult=ProcessRemainingClusters(&inputTrackArray[0], inputTrackArray.size(), fTrackGrid, trackindexmap, fSpacePointGrid, fRawInputClusters, slice, patch);
if (iResult>=0) {
if (fSpacePointGrid->GetNumberOfSpacePoints()>0) {
if (fVerbosity>0) HLTInfo("associated %d (%d) of %d clusters in slice %d partition %d", iResult+assignedInThisPartition, assignedInThisPartition, fSpacePointGrid->GetNumberOfSpacePoints(), slice, patch);
outputDataSize+=iResult;
// the size of the optional cluster id array must be subtracted
if (fpWrittenAssociatedClusterIds && outputBlocks.size()>0 &&
- outputBlocks.back().fDataType==AliHLTTPCDefinitions::AliHLTDataTypeClusterMCInfo()) {
+ outputBlocks.back().fDataType==AliHLTTPCDefinitions::RemainingClusterIdsDataType()) {
outputDataSize-=outputBlocks.back().fSize;
}
if (GetBenchmarkInstance()) GetBenchmarkInstance()->AddOutput(iResult);
}
AliHLTUInt32_t parameterIndex=0;
- trackModelBlock->fGlobalParameters[parameterIndex++]=GetBz();
+ trackModelBlock->fGlobalParameters[parameterIndex++]=bz;
trackModelBlock->fGlobalParameters[parameterIndex++]=fDriftTimeFactorA;
trackModelBlock->fGlobalParameters[parameterIndex++]=fDriftTimeOffsetA;
trackModelBlock->fGlobalParameters[parameterIndex++]=fDriftTimeFactorC;
break;
}
- if (fMode==2) {
+ if (trackindexmap.size()>0) {// condition for track model compression
iResult=WriteTrackClusters(inputTrackArray, fRawInputClusters, fpDataDeflater, outputPtr+size+tracksBufferOffset, capacity-size-tracksBufferOffset);
if (iResult>=0) {
AliHLTComponent_BlockData bd;
int AliHLTTPCDataCompressionComponent::ProcessTrackClusters(AliHLTGlobalBarrelTrack* pTracks, unsigned nofTracks,
AliHLTTrackGeometry::AliHLTTrackGrid* pTrackIndex,
+ const vector<int>& trackIndexMap,
AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* pClusterIndex,
AliHLTSpacePointContainer* pClusters,
int slice, int partition) const
{
// process to assigned track clusters
+ int iResult=0;
int assignedClusters=0;
if (!pTracks || nofTracks==0) return 0;
- vector<AliHLTUInt32_t> processedTracks;
+ vector<int> processedTracks(nofTracks, -1);
for (AliHLTTrackGeometry::AliHLTTrackGrid::iterator& trackId=pTrackIndex->begin(slice, partition, -1);
trackId!=pTrackIndex->end(); trackId++) {
- if (find(processedTracks.begin(), processedTracks.end(), trackId.Data())!=processedTracks.end()) {
+ if (trackId.Data()>=trackIndexMap.size()) {
+ HLTError("can not find track id %d in index map of size %d", trackId.Data(), trackIndexMap.size());
continue;
}
- unsigned trackindex=0;
- for (; trackindex<nofTracks; trackindex++) {
- if ((unsigned)pTracks[trackindex].GetID()==trackId.Data()) break;
- }
- if (trackindex>=nofTracks) {
- HLTError("can not find track of id %d", trackId.Data());
+ int trackindex=trackIndexMap[trackId.Data()];
+ if (trackindex<0 || trackindex>=(int)nofTracks) {
+ HLTError("invalid index %d found for track id %d", trackindex, trackId.Data());
continue;
}
- processedTracks.push_back(trackId.Data());
+ if (processedTracks[trackindex]>0) continue;
+ processedTracks[trackindex]=1;
AliHLTGlobalBarrelTrack& track=pTracks[trackindex];
if (!track.GetTrackGeometry()) {
HLTError("can not find track geometry for track %d", trackId.Data());
// not in the current partition;
continue;
}
-
- AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid::iterator& cl=pClusterIndex->find(AliHLTSpacePointContainer::AliHLTSpacePointProperties(clusterId));
- if (cl==pClusterIndex->end()) {
- HLTError("can not find cluster no 0x%08x of track %d in index grid", clusterId, track.GetID());
- continue;
- }
int clusterrow=(int)pClusters->GetX(clusterId);
- float clusterpad=pClusters->GetY(clusterId);
- float clustertime=pClusters->GetZ(clusterId);
-
AliHLTUInt32_t pointId=AliHLTTPCSpacePointData::GetID(slice, partition, clusterrow);
AliHLTTrackGeometry::AliHLTTrackPoint* point=pTrackPoints->GetRawTrackPoint(pointId);
if (!point) {
}
float pad=point->GetU();
float time=point->GetV();
- if (TMath::Abs(clusterpad-pad)<fMaxDeltaPad &&
- TMath::Abs(clustertime-time)<fMaxDeltaTime) {
- // add this cluster to the track point and mark in the index grid
- cl.Data().fTrackId=track.GetID();
- point->AddAssociatedSpacePoint(clusterId, clusterpad-pad, clustertime-time);
- assignedClusters++;
- }
+
+ iResult=FindCellClusters(trackId.Data(), clusterrow, pad, time, pClusterIndex, pClusters, point, clusterId);
+ if (iResult>0) assignedClusters+=iResult;
}
}
return assignedClusters;
int AliHLTTPCDataCompressionComponent::ProcessRemainingClusters(AliHLTGlobalBarrelTrack* pTracks, unsigned nofTracks,
AliHLTTrackGeometry::AliHLTTrackGrid* pTrackIndex,
+ const vector<int>& trackIndexMap,
AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* pClusterIndex,
AliHLTSpacePointContainer* pClusters,
int slice, int partition) const
for (int padrow=0; padrow<AliHLTTPCTransform::GetNRows(partition); padrow++) {
for (AliHLTTrackGeometry::AliHLTTrackGrid::iterator& trackId=pTrackIndex->begin(slice, partition, padrow);
trackId!=pTrackIndex->end(); trackId++) {
- unsigned i=0;
- for (; i<nofTracks; i++) {
- if ((unsigned)pTracks[i].GetID()==trackId.Data()) break;
+ if (trackId.Data()>=trackIndexMap.size()) {
+ HLTError("can not find track id %d in index map of size %d", trackId.Data(), trackIndexMap.size());
+ continue;
}
- if (i>=nofTracks) {
- HLTError("can not find track of id %d", trackId.Data());
+ int trackindex=trackIndexMap[trackId.Data()];
+ if (trackindex<0 || trackindex>=(int)nofTracks) {
+ HLTError("invalid index %d found for track id %d", trackindex, trackId.Data());
continue;
}
- AliHLTGlobalBarrelTrack& track=pTracks[i];
+ AliHLTGlobalBarrelTrack& track=pTracks[trackindex];
if (!track.GetTrackGeometry()) {
HLTError("can not find track geometry for track %d", trackId.Data());
continue;
int AliHLTTPCDataCompressionComponent::FindCellClusters(int trackId, int padrow, float pad, float time,
AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* pClusterIndex,
AliHLTSpacePointContainer* pClusters,
- AliHLTTrackGeometry::AliHLTTrackPoint* pTrackPoint) const
+ AliHLTTrackGeometry::AliHLTTrackPoint* pTrackPoint,
+ AliHLTUInt32_t clusterId) const
{
// check index cell for entries and assign to track
int count=0;
// search a 4x4 matrix out of the 9x9 matrix around the cell addressed by
// pad and time
- int rowindex=pClusterIndex->GetYIndex((float)padrow);
- int padindex=pClusterIndex->GetYIndex(pad);
- int timeindex=pClusterIndex->GetZIndex(time);
- if (pClusterIndex->GetCenterY(padindex)>pad) padindex--;
- if (pClusterIndex->GetCenterZ(timeindex)>pad) timeindex--;
- for (int padcount=0; padcount<2; padcount++, padindex++) {
+ int rowindex=pClusterIndex->GetXIndex((float)padrow);
+ int padstartindex=pClusterIndex->GetYIndex(pad);
+ int timestartindex=pClusterIndex->GetZIndex(time);
+ int cellindex=pClusterIndex->Index(rowindex, padstartindex, timestartindex);
+ float centerpad=pClusterIndex->GetCenterY(cellindex);
+ float centertime=pClusterIndex->GetCenterZ(cellindex);
+ if ((TMath::Abs(centerpad-pad)>fMaxDeltaPad && pad>0.) ||
+ (TMath::Abs(centertime-time)>fMaxDeltaTime && time>0.)) {
+ ALIHLTERRORGUARD(20, "invalid pad center calculation, please check dimensions if dimensions of index grid match the maximum possible deviation");
+ }
+
+ int paddirection=1;
+ int timedirection=1;
+ if (centerpad>pad) paddirection=-1;
+ if (centertime>time) timedirection=-1;
+ for (int padcount=0, padindex=padstartindex; padcount<2; padcount++, padindex+=paddirection) {
if (padindex<0) continue;
if (padindex>=pClusterIndex->GetDimensionY()) break;
- for (int timecount=0; timecount<2; timecount++, timeindex++) {
+ for (int timecount=0, timeindex=timestartindex; timecount<2; timecount++, timeindex+=timedirection) {
if (timeindex<0) continue;
if (timeindex>=pClusterIndex->GetDimensionZ()) break;
- int cellindex=pClusterIndex->Index(rowindex, padindex, timeindex);
- pad=pClusterIndex->GetCenterY(cellindex);
- time=pClusterIndex->GetCenterZ(cellindex);
- for (AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid::iterator& cl=pClusterIndex->begin((float)padrow, pad, time);
+ cellindex=pClusterIndex->Index(rowindex, padindex, timeindex);
+ float cellpad=pClusterIndex->GetCenterY(cellindex);
+ float celltime=pClusterIndex->GetCenterZ(cellindex);
+ for (AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid::iterator& cl=pClusterIndex->begin((float)padrow, cellpad, celltime);
cl!=pClusterIndex->end(); cl++) {
if (cl.Data().fTrackId>=0) continue;
+ if (clusterId!=(~(AliHLTUInt32_t)0) && clusterId!=cl.Data().fId) continue;
+ if (TMath::Abs(padrow-pClusters->GetX(cl.Data().fId))>=1.) {
+ HLTError("cluster 0x%08x: mismatch on padrow: trackpoint %d cluster %f", cl.Data().fId, padrow, pClusters->GetX(cl.Data().fId));
+ continue;
+ }
float clusterpad=pClusters->GetY(cl.Data().fId);
float clustertime=pClusters->GetZ(cl.Data().fId);
if (TMath::Abs(clusterpad-pad)<fMaxDeltaPad &&
pTrackPoint->AddAssociatedSpacePoint(cl.Data().fId, clusterpad-pad, clustertime-time);
count++;
}
+ if (clusterId!=(~(AliHLTUInt32_t)0)) break;
}
}
}
return -ENOMEM;
}
- unsigned spacePointContainerMode=(fMode==2)?AliHLTTPCHWCFSpacePointContainer::kModeCreateMap:0;
+ unsigned spacePointContainerMode=0;
+ if (fMode==2 || fMode==4) {
+ // initialize map data for cluster access in the track association loop
+ spacePointContainerMode|=AliHLTTPCHWCFSpacePointContainer::kModeCreateMap;
+ }
+ if (fMode==3 || fMode==4) {
+ // optimized storage format: differential pad and time storage
+ spacePointContainerMode|=AliHLTTPCHWCFSpacePointContainer::kModeDifferentialPadTime;
+ }
std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> rawInputClusters(new AliHLTTPCHWCFSpacePointContainer(spacePointContainerMode));
std::auto_ptr<AliHLTTPCSpacePointContainer> inputClusters(new AliHLTTPCSpacePointContainer);