AliHLTTPCTrackArray tracks;
inPtr=(AliHLTTPCTrackletData*)iter->fPtr;
HLTDebug("reading block %d (slice %d): %d tracklets", ndx, minslice, inPtr->fTrackletCnt);
- tracks.FillTracks(inPtr->fTrackletCnt, inPtr->fTracklets, minslice, 0/*don't rotate*/);
- if ((iResult=Tracks2ESD(&tracks, pESD))>=0) {
+ if ((iResult=tracks.FillTracksChecked(inPtr->fTracklets, inPtr->fTrackletCnt, iter->fSize, minslice, 0/*don't rotate*/))>=0) {
+ if ((iResult=Tracks2ESD(&tracks, pESD))>=0) {
+ }
}
} else {
HLTError("invalid sector number");
bTransform = 1;
}
- fTracks->FillTracks( nTracks, segmentData, slice, bTransform );
+ fTracks->FillTracksChecked( segmentData, nTracks, 0, slice, bTransform );
}
//Read tracks from shared memory (or memory)
AliHLTTPCTrackArray *destination = GetInTracks(fCurrentTracks);
if(Is2Global())
- destination->FillTracks(ntracks, tr, fSlice);
+ destination->FillTracksChecked(tr, ntracks, 0, fSlice);
else
- destination->FillTracks(ntracks, tr);
+ destination->FillTracksChecked(tr, ntracks, 0);
}
void AliHLTTPCMerger::AddAllTracks()
}
}
-void AliHLTTPCTrackArray::FillTracks(Int_t ntracks, AliHLTTPCTrackSegmentData* tr,Int_t slice, Int_t bTransform)
+int AliHLTTPCTrackArray::FillTracks(Int_t ntracks, AliHLTTPCTrackSegmentData* tr, Int_t slice, Int_t bTransform)
{
//Read tracks from shared memory (or memory)
+ return FillTracksChecked(tr, ntracks, 0, slice, bTransform);
+}
+
+int AliHLTTPCTrackArray::FillTracksChecked(AliHLTTPCTrackSegmentData* tr, Int_t ntracks, unsigned int sizeInByte, Int_t slice, Int_t bTransform)
+{
+ //Read tracks from shared memory (or memory)
+ int iResult=0;
AliHLTTPCTrackSegmentData *trs = tr;
for(Int_t i=0; i<ntracks; i++){
+ if (sizeInByte>0 &&
+ (((AliHLTUInt8_t*)trs)+sizeof(AliHLTTPCTrackSegmentData)>((AliHLTUInt8_t*)tr)+sizeInByte ||
+ ((AliHLTUInt8_t*)trs)+sizeof(AliHLTTPCTrackSegmentData)+trs->fNPoints*sizeof(UInt_t)>((AliHLTUInt8_t*)tr)+sizeInByte)) {
+ iResult=-EDOM;
+ break;
+ }
AliHLTTPCTrack *track = NextTrack();
track->SetPt(trs->fPt);
track->SetPterr(trs->fPterr);
tmpP += sizeof(AliHLTTPCTrackSegmentData)+trs->fNPoints*sizeof(UInt_t);
trs = (AliHLTTPCTrackSegmentData*)tmpP;
}
+
+ if (iResult==-EDOM) {
+ // try to recover the version 1 struct
+ Reset();
+ if ((iResult=FillTracksVersion1((AliHLTTPCTrackSegmentDataV1*)tr, ntracks, sizeInByte, slice, bTransform))>=0) {
+ LOG(AliHLTTPCLog::kWarning,"AliHLTTPCTrackArray::FillTracks","") << "version 1 track array recoverd (deprecated since r27415)" << ENDLOG;
+ }
+ }
+ if (iResult==-EDOM) {
+ Reset();
+ LOG(AliHLTTPCLog::kError,"AliHLTTPCTrackArray::FillTracks","") << "corrupted input data array" << ENDLOG;
+ }
+
+ return iResult;
+}
+
+int AliHLTTPCTrackArray::FillTracksVersion1(AliHLTTPCTrackSegmentDataV1* tr, Int_t ntracks, unsigned int sizeInByte, Int_t slice, Int_t bTransform)
+{
+ //Read tracks from shared memory (or memory)
+ int iResult=0;
+ AliHLTTPCTrackSegmentDataV1 *trs = tr;
+ for(Int_t i=0; i<ntracks; i++){
+ if (sizeInByte>0 &&
+ (((AliHLTUInt8_t*)trs)+sizeof(AliHLTTPCTrackSegmentDataV1)>((AliHLTUInt8_t*)tr)+sizeInByte ||
+ ((AliHLTUInt8_t*)trs)+sizeof(AliHLTTPCTrackSegmentDataV1)+trs->fNPoints*sizeof(UInt_t)>((AliHLTUInt8_t*)tr)+sizeInByte)) {
+ iResult=-EDOM;
+ break;
+ }
+ AliHLTTPCTrack *track = NextTrack();
+ track->SetPt(trs->fPt);
+ track->SetPterr(trs->fPterr);
+ Float_t psi[1];
+ psi[0]=trs->fPsi;
+ if (slice>=0 && bTransform!=0) {
+ AliHLTTPCTransform::Local2GlobalAngle(psi,slice);
+ }
+ track->SetPsi(psi[0]);
+ track->SetTgl(trs->fTgl);
+ track->SetPsierr(trs->fPsierr);
+ track->SetTglerr(trs->fTglerr);
+ track->SetNHits(trs->fNPoints);
+ track->SetCharge(trs->fCharge);
+ Float_t first[3];
+ first[0]=trs->fX;first[1]=trs->fY;first[2]=trs->fZ;
+ if (slice>=0 && bTransform!=0) {
+ AliHLTTPCTransform::Local2Global(first,slice);
+ }
+ track->SetFirstPoint(first[0],first[1],first[2]);
+ Float_t last[3];
+ last[0]=trs->fLastX;last[1]=trs->fLastY;last[2]=trs->fLastZ;
+ if (slice>=0 && bTransform!=0) {
+ AliHLTTPCTransform::Local2Global(last,slice);
+ }
+ track->SetLastPoint(last[0],last[1],last[2]);
+ track->SetHits( trs->fNPoints, trs->fPointIDs );
+
+ track->SetSector(slice);
+ if ( trs->fPt == -9876.0 || trs->fPt == -1.0) {
+ track->SetPhi0(atan2(first[1],first[0]));
+ track->SetKappa(1.0);
+ track->SetRadius(999999.0);
+ } else {
+ track->CalculateHelix();
+ }
+
+ UChar_t *tmpP = (UChar_t*)trs;
+ tmpP += sizeof(AliHLTTPCTrackSegmentDataV1)+trs->fNPoints*sizeof(UInt_t);
+ trs = (AliHLTTPCTrackSegmentDataV1*)tmpP;
+ }
+ return iResult;
}
UInt_t AliHLTTPCTrackArray::GetOutSize()
class AliHLTTPCConfMapTrack;
class AliHLTTPCTrack;
class AliHLTTPCTrackSegmentData;
+class AliHLTTPCTrackSegmentDataV1;
/**
* @class AliHLTTPCTrackArray
void QSort( AliHLTTPCTrack **a, Int_t first, Int_t last);
Int_t TrackCompare(AliHLTTPCTrack *a, AliHLTTPCTrack *b) const;
+ /**
+ * Fill track array from track segment array.
+ * Old method excluding buffer protection kept for backward compatibility.
+ * Forwarded to FillTracksChecked().
+ * @param ntracks size of the input array
+ * @param tr array of AliHLTTrackSegmentData
+ * @param slice slice no to transform the tracks to
+ * @param bTransform transform to global coordinates if 1
+ */
+ int FillTracks(Int_t ntracks, AliHLTTPCTrackSegmentData* tr, Int_t slice=-1, Int_t bTransform=1);
+
/**
* Fill track array from track segment array.
* Reads the track from an array of AliHLTTrackSegmentData. The coordinates
* are transformed to global coordinates if the slice parameter is specified.
* In that case to internal slice variable is set to zero.
+ *
+ * The sizeInByte parameter allows an additional buffer protection if
+ * non-zero. The size of the AliHLTTPCTrackSegmentData is not fixed due to
+ * variable array at the end of the structure. The pointer to the next
+ * entry must be set according to the variable array.
* @param ntracks size of the input array
* @param tr array of AliHLTTrackSegmentData
+ * @param sizeInByte additional size protection
* @param slice slice no to transform the tracks to
* @param bTransform transform to global coordinates if 1
*/
- void FillTracks(Int_t ntracks, AliHLTTPCTrackSegmentData* tr,Int_t slice=-1, Int_t bTransform=1);
+ int FillTracksChecked(AliHLTTPCTrackSegmentData* tr, Int_t ntracks, unsigned int sizeInByte, Int_t slice=-1, Int_t bTransform=1);
+
+ /**
+ * Fill array from version1 structure.
+ * The version 1 of ALiHLTTPCTrackSegmentData was valid until July 2008
+ * revision 27415.
+ *
+ * Similar behavior like FillTracksChecked.
+ */
+ int FillTracksVersion1(AliHLTTPCTrackSegmentDataV1* tr, Int_t ntracks, unsigned int sizeInByte, Int_t slice=-1, Int_t bTransform=1);
UInt_t WriteTracks(AliHLTTPCTrackSegmentData* tr); //Write tracks
UInt_t WriteTracks(UInt_t & ntracks,AliHLTTPCTrackSegmentData* tr); //Write tracks
typedef struct AliHLTTPCTrackSegmentData AliHLTTPCTrackSegmentData;
+/**
+ * @struct AliHLTTPCTrackSegmentDataV1
+ * Former structure track segments, valid until July 2008
+ * revision 27415
+ *
+ * @ingroup alihlt_tpc_datastructs
+ */
+struct AliHLTTPCTrackSegmentDataV1
+ {
+ Float_t fX;
+ Float_t fY;
+ Float_t fZ;
+ Float_t fLastX;
+ Float_t fLastY;
+ Float_t fLastZ;
+ Double_t fPt;
+ Double_t fPsi;
+ Double_t fTgl;
+ Double_t fPterr;
+ Double_t fPsierr;
+ Double_t fTglerr;
+ Int_t fCharge;
+ UInt_t fNPoints;
+#if defined(__HP_aCC) || defined(__DECCXX) || defined(__SUNPRO_CC)
+ UInt_t fPointIDs[1];
+#else
+ UInt_t fPointIDs[0];
+#endif
+ };
+
+typedef struct AliHLTTPCTrackSegmentDataV0 AliHLTTPCTrackSegmentDataV0;
+
#endif /* _ALIHLTTPCTRACKSEGMENTDATA_H_ */