// @(#) $Id$
// Original: AliHLTTrackArray.cxx,v 1.21 2005/06/14 10:55:21 cvetan
-// Author: Uli Frankenfeld <mailto:franken@fi.uib.no>
-//*-- Copyright © ALICE HLT Group
-
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Primary Authors: Uli Frankenfeld, maintained by *
+ * Matthias Richter <Matthias.Richter@ift.uib.no> *
+ * for The ALICE HLT Project. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * 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 *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/** @file AliHLTTPCTrackArray.cxx
+ @author Uli Frankenfeld, maintained by Matthias Richter
+ @date
+ @brief Array of AliHLTTPCTracks */
+
+#include "AliLog.h"
+#include "TClass.h"
#include "AliHLTTPCLogging.h"
#include "AliHLTTPCTrackArray.h"
+// Matthias 17.10.2007 the hough code has been disabled for the moment
+//#define INCLUDE_TPC_HOUGH
#ifdef INCLUDE_TPC_HOUGH
#include "AliHLTTPCHoughTrack.h"
#endif
#include "AliHLTTPCTrackSegmentData.h"
#include "AliHLTTPCTransform.h"
#include "AliHLTTPCConfMapPoint.h"
-
-/** \class AliHLTTPCTrackArray
-<pre>
-//_____________________________________________________________
-// AliHLTTPCTrackArray
-//
-// Track array class
-//
-</pre>
-*/
+#include "AliHLTExternalTrackParam.h"
#if __GNUC__ >= 3
using namespace std;
ClassImp(AliHLTTPCTrackArray)
AliHLTTPCTrackArray::AliHLTTPCTrackArray()
+ :
+ fTrackType('t'),
+ fSize(0),
+ fIsPresent(NULL),
+ fNAbsent(0),
+ fTrack(NULL),
+ fNTracks(0)
{
//Default constructor
- fSize = 0;
- fNTracks=0;
- fNAbsent=0;
- fTrackType='t';
SetSize();
}
AliHLTTPCTrackArray::AliHLTTPCTrackArray(Int_t ntrack)
+ :
+ fTrackType('t'),
+ fSize(0),
+ fIsPresent(NULL),
+ fNAbsent(0),
+ fTrack(NULL),
+ fNTracks(0)
{
//Constructor.
- fSize = 0;
- fNTracks=0;
- fNAbsent=0;
- fTrackType='t';
SetSize(ntrack);
}
-AliHLTTPCTrackArray::AliHLTTPCTrackArray(char* tracktype,Int_t ntrack)
+AliHLTTPCTrackArray::AliHLTTPCTrackArray(const char* tracktype,Int_t ntrack)
+ :
+ fTrackType('t'),
+ fSize(0),
+ fIsPresent(NULL),
+ fNAbsent(0),
+ fTrack(NULL),
+ fNTracks(0)
{
//Constructor.
- fSize = 0;
- fNTracks=0;
- fNAbsent=0;
if(strcmp(tracktype,"AliHLTTPCTrack")==0) fTrackType='t';
if(strcmp(tracktype,"AliHLTTPCConfMapTrack")==0) fTrackType='c';
#ifdef INCLUDE_TPC_HOUGH
SetSize(ntrack);
}
-AliHLTTPCTrackArray::AliHLTTPCTrackArray(char* tracktype)
+AliHLTTPCTrackArray::AliHLTTPCTrackArray(const char* tracktype)
+ :
+ fTrackType('t'),
+ fSize(0),
+ fIsPresent(NULL),
+ fNAbsent(0),
+ fTrack(NULL),
+ fNTracks(0)
{
//Constructor.
- fSize = 0;
- fNTracks=0;
- fNAbsent=0;
if(strcmp(tracktype,"AliHLTTPCTrack")==0) fTrackType='t';
if(strcmp(tracktype,"AliHLTTPCConfMapTrack")==0) fTrackType='c';
#ifdef INCLUDE_TPC_HOUGH
delete fTrack[i];
delete[] fIsPresent;
delete[] fTrack;
+ fSize=0;
}
Bool_t AliHLTTPCTrackArray::SetSize(Int_t newsize)
}
}
-void AliHLTTPCTrackArray::FillTracks(Int_t ntracks, AliHLTTPCTrackSegmentData* tr){
+int AliHLTTPCTrackArray::FillTracks(Int_t ntracks, AliHLTTPCTrackSegmentData* tr, Int_t slice, Int_t bTransform)
+{
//Read tracks from shared memory (or memory)
- AliHLTTPCTrackSegmentData *trs = tr;
- for(Int_t i=0; i<ntracks; i++){
+ return FillTracksChecked(tr, ntracks, 0, slice, bTransform);
+}
+
+int AliHLTTPCTrackArray::FillTracksChecked(AliHLTExternalTrackParam* tr, Int_t ntracks, unsigned int sizeInByte, Int_t slice, Int_t bTransform)
+{
+ int iResult=0;
+ AliHLTExternalTrackParam *trs = tr;
+
+ for(Int_t i=0; i<ntracks; i++){
+ if (sizeInByte>0 &&
+ (((AliHLTUInt8_t*)trs)+sizeof(AliHLTExternalTrackParam)>((AliHLTUInt8_t*)tr)+sizeInByte ||
+ ((AliHLTUInt8_t*)trs)+sizeof(AliHLTExternalTrackParam)+trs->fNPoints*sizeof(UInt_t)>((AliHLTUInt8_t*)tr)+sizeInByte)) {
+ iResult=-EDOM;
+ break;
+ }
AliHLTTPCTrack *track = NextTrack();
- track->SetPt(trs->fPt);
- track->SetPsi(trs->fPsi);
+ track->SetId( i );
+ track->SetPt(trs->fq1Pt);
+ track->SetPterr(trs->fC[14]);
+ Float_t psi[1];
+ psi[0]=trs->fSinPsi;
+ if (slice>=0 && bTransform!=0) {
+ AliHLTTPCTransform::Local2GlobalAngle(psi,slice);
+ }
+ //cout << "psi " << psi[0] << endl;
+ track->SetPsi(psi[0]);
track->SetTgl(trs->fTgl);
- track->SetPterr(trs->fPterr);
- track->SetPsierr(trs->fPsierr);
- track->SetTglerr(trs->fTglerr);
+ track->SetPsierr(trs->fC[5]);
+ track->SetTglerr(trs->fC[9]);
+ track->SetY0err(trs->fC[0]);
+ track->SetZ0err(trs->fC[2]);
track->SetNHits(trs->fNPoints);
- track->SetCharge(trs->fCharge);
- track->SetFirstPoint(trs->fX,trs->fY,trs->fZ);
- track->SetLastPoint(trs->fLastX,trs->fLastY,trs->fLastZ);
+ //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);
+ }
+ //cout << "first point: " << first[0] << " " << first[1] << " " << first[3] << endl;
+ 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);
+ }
+ //cout << "last point: " << last[0] << " " << last[1] << " " << last[3] << endl;
+ track->SetLastPoint(last[0],last[1],last[2]);
track->SetHits( trs->fNPoints, trs->fPointIDs );
+
+ //if (slice>=0 && bTransform!=0) {
+ // Matthias Feb07: as everything is now in global coordinates, sector should
+ // be set to 0. But as the display does a check on the sector, we have to set
+ // it to the slice no. I suspect, that the transformation is done twice.
+ //track->SetSector(0);
+
+ track->SetSector(slice);
+
+ //} else {
+ // the parameters are in local coordinates, set the sector no
+ //#ifndef INCLUDE_TPC_HOUGH
+ //if (slice<0) track->SetSector(0);
+ //else track->SetSector(slice);
+ //#else
+ // Matthias Feb 2007: this is some kind of legacy ...
+ // the INCLUDE_TPC_HOUGH has never been switched on in the new TPCLib
+ // and this line was below in the corresponding block. As the slice
+ // parameter is very useful but not available if the define is off
+ // we distinguish the two cases here. Should be cleaned up.
+ // Matthias April 2007: update, try to integrate Cvetans Hough tracker
+ // so we need the support for the AliHLTTPCHoughTrack. I dont have the
+ // full control of this code (should we use slice or trs->fSector?)
+ // But the FillTracks method is never called from the hough code, so we
+ // take 'slice'
+ if (GetTrackType()=='h') {
+ AliErrorClassStream() << "FillTracks was never used with AliHLTTPCHoughTrack:"
+ << " CHECK THIS CODE!!!" << endl;
+ }
+ //track->SetSector(trs->fSector);
+ //#endif // INCLUDE_TPC_HOUGH
+ //}
+
+ // this is currently a quick hack for straight lines of the first version
+ // of the CA tracker.
+ // we have to think about a more general way of treating straight and curved
+ // tracks
+ if ( trs->fq1Pt == -9876.0 || trs->fq1Pt == -1.0) {
+ track->SetPhi0(atan2(first[1],first[0]));
+ track->SetKappa(1.0);
+ track->SetRadius(999999.0);
+ } else {
+ // Matthias Feb07: just tried to take this away, but this causes the tracks
+ // in the display not to be drawn. But we still have to tink about this.
+ track->CalculateHelix();
+ }
+
#ifdef INCLUDE_TPC_HOUGH
#ifdef ROWHOUGHPARAMS
if(GetTrackType()=='h') {
}
track->SetMCid(trs->fTrackID);
track->SetRowRange(trs->fRowRange1,trs->fRowRange2);
- track->SetSector(trs->fSector);
track->SetPID(trs->fPID);
#endif
#endif // INCLUDE_TPC_HOUGH
+ track->CheckConsistency();
+
UChar_t *tmpP = (UChar_t*)trs;
- tmpP += sizeof(AliHLTTPCTrackSegmentData)+trs->fNPoints*sizeof(UInt_t);
- trs = (AliHLTTPCTrackSegmentData*)tmpP;
+ tmpP += sizeof(AliHLTExternalTrackParam)+trs->fNPoints*sizeof(UInt_t);
+ trs = (AliHLTExternalTrackParam*)tmpP;
}
+ return iResult;
}
-void AliHLTTPCTrackArray::FillTracks(Int_t ntracks, AliHLTTPCTrackSegmentData* tr,Int_t slice)
+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->SetId( i );
track->SetPt(trs->fPt);
track->SetPterr(trs->fPterr);
Float_t psi[1];
psi[0]=trs->fPsi;
- AliHLTTPCTransform::Local2GlobalAngle(psi,slice);
+ if (slice>=0 && bTransform!=0) {
+ AliHLTTPCTransform::Local2GlobalAngle(psi,slice);
+ }
+ //cout << "psi " << psi[0] << endl;
track->SetPsi(psi[0]);
track->SetTgl(trs->fTgl);
track->SetPsierr(trs->fPsierr);
track->SetTglerr(trs->fTglerr);
+ track->SetY0err(trs->fY0err);
+ track->SetZ0err(trs->fZ0err);
track->SetNHits(trs->fNPoints);
track->SetCharge(trs->fCharge);
Float_t first[3];
first[0]=trs->fX;first[1]=trs->fY;first[2]=trs->fZ;
- AliHLTTPCTransform::Local2Global(first,slice);
+ if (slice>=0 && bTransform!=0) {
+ AliHLTTPCTransform::Local2Global(first,slice);
+ }
+ //cout << "first point: " << first[0] << " " << first[1] << " " << first[3] << endl;
track->SetFirstPoint(first[0],first[1],first[2]);
Float_t last[3];
last[0]=trs->fLastX;last[1]=trs->fLastY;last[2]=trs->fLastZ;
- AliHLTTPCTransform::Local2Global(last,slice);
+ if (slice>=0 && bTransform!=0) {
+ AliHLTTPCTransform::Local2Global(last,slice);
+ }
+ //cout << "last point: " << last[0] << " " << last[1] << " " << last[3] << endl;
track->SetLastPoint(last[0],last[1],last[2]);
track->SetHits( trs->fNPoints, trs->fPointIDs );
-// BEGINN ############################################## MODIFIY JMT
- track->SetSector(slice);
- track->CalculateHelix();
-// END ################################################# MODIFIY JMT
+
+ //if (slice>=0 && bTransform!=0) {
+ // Matthias Feb07: as everything is now in global coordinates, sector should
+ // be set to 0. But as the display does a check on the sector, we have to set
+ // it to the slice no. I suspect, that the transformation is done twice.
+ //track->SetSector(0);
+ track->SetSector(slice);
+ //} else {
+ // the parameters are in local coordinates, set the sector no
+ //#ifndef INCLUDE_TPC_HOUGH
+ //if (slice<0) track->SetSector(0);
+ //else track->SetSector(slice);
+ //#else
+ // Matthias Feb 2007: this is some kind of legacy ...
+ // the INCLUDE_TPC_HOUGH has never been switched on in the new TPCLib
+ // and this line was below in the corresponding block. As the slice
+ // parameter is very useful but not available if the define is off
+ // we distinguish the two cases here. Should be cleaned up.
+ // Matthias April 2007: update, try to integrate Cvetans Hough tracker
+ // so we need the support for the AliHLTTPCHoughTrack. I dont have the
+ // full control of this code (should we use slice or trs->fSector?)
+ // But the FillTracks method is never called from the hough code, so we
+ // take 'slice'
+ if (GetTrackType()=='h') {
+ AliErrorClassStream() << "FillTracks was never used with AliHLTTPCHoughTrack:"
+ << " CHECK THIS CODE!!!" << endl;
+ }
+ //track->SetSector(trs->fSector);
+ //#endif // INCLUDE_TPC_HOUGH
+ //}
+
+ // this is currently a quick hack for straight lines of the first version
+ // of the CA tracker.
+ // we have to think about a more general way of treating straight and curved
+ // tracks
+ 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 {
+ // Matthias Feb07: just tried to take this away, but this causes the tracks
+ // in the display not to be drawn. But we still have to tink about this.
+ track->CalculateHelix();
+ }
+
#ifdef INCLUDE_TPC_HOUGH
#ifdef ROWHOUGHPARAMS
if(GetTrackType()=='h') {
}
track->SetMCid(trs->fTrackID);
track->SetRowRange(trs->fRowRange1,trs->fRowRange2);
- track->SetSector(slice);
track->SetPID(trs->fPID);
#endif
#endif // INCLUDE_TPC_HOUGH
+ track->CheckConsistency();
+
UChar_t *tmpP = (UChar_t*)trs;
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()
tP->fTgl = track->GetTgl();
tP->fPsierr = track->GetPsierr();
tP->fTglerr = track->GetTglerr();
+ tP->fY0err = track->GetY0err();
+ tP->fZ0err = track->GetZ0err();
tP->fCharge = track->GetCharge();
tP->fNPoints = track->GetNHits();
#ifdef INCLUDE_TPC_HOUGH
size += sizeof(AliHLTTPCTrackSegmentData)+tP->fNPoints*sizeof(UInt_t);
tP = (AliHLTTPCTrackSegmentData*)tmpP;
-// BEGINN ############################################## MODIFIY JMT
// LOG(AliHLTTPCLog::kError,"AliHLTTPCTrackArray::WriteTracks","TRACKPARAMETER") <<ENDLOG;
// track->Rotate(0,kFALSE);
// track->Print();
-// END ################################################# MODIFIY JMT
}
return size;
tP->fTgl = track->GetTgl();
tP->fPsierr = track->GetPsierr();
tP->fTglerr = track->GetTglerr();
+ tP->fY0err = track->GetY0err();
+ tP->fZ0err = track->GetZ0err();
tP->fCharge = track->GetCharge();
#ifdef INCLUDE_TPC_HOUGH
#ifdef ROWHOUGHPARAMS
AliHLTTPCTrack* AliHLTTPCTrackArray::operator[](int index)
{
+ // access operator
if (index<fNTracks) return fTrack[index];
return NULL;
}