//$Id$ // Author: Uli Frankenfeld //*-- Copyright © ULI #include #include #include #include "AliL3Logging.h" #include "AliL3TrackArray.h" #include "AliL3HoughTrack.h" #include "AliL3ModelTrack.h" #include "AliL3ConfMapTrack.h" #include "AliL3TrackSegmentData.h" #include "AliL3Transform.h" #include "AliL3ConfMapPoint.h" //_____________________________________________________________ // AliL3TrackArray // // Track array class // ClassImp(AliL3TrackArray) AliL3TrackArray::AliL3TrackArray(){ //Default constructor fSize = 0; fNTracks=0; fNAbsent=0; fTrackType='t'; SetSize(); } AliL3TrackArray::AliL3TrackArray(Int_t ntrack){ //Constructor. fSize = 0; fNTracks=0; fNAbsent=0; fTrackType='t'; SetSize(ntrack); } AliL3TrackArray::AliL3TrackArray(char* tracktype,Int_t ntrack){ //Constructor. fSize = 0; fNTracks=0; fNAbsent=0; if(strcmp(tracktype,"AliL3Track")==0) fTrackType='t'; if(strcmp(tracktype,"AliL3ConfMapTrack")==0) fTrackType='c'; if(strcmp(tracktype,"AliL3HoughTrack")==0) fTrackType='h'; if(strcmp(tracktype,"AliL3ModelTrack")==0) fTrackType='m'; SetSize(ntrack); } AliL3TrackArray::AliL3TrackArray(char* tracktype){ //Constructor. fSize = 0; fNTracks=0; fNAbsent=0; if(strcmp(tracktype,"AliL3Track")==0) fTrackType='t'; if(strcmp(tracktype,"AliL3ConfMapTrack")==0) fTrackType='c'; if(strcmp(tracktype,"AliL3HoughTrack")==0) fTrackType='h'; if(strcmp(tracktype,"AliL3ModelTrack")==0) fTrackType='m'; SetSize(); } AliL3TrackArray::~AliL3TrackArray(){ //Destructor DeleteArray(); } AliL3Track *AliL3TrackArray::NextTrack(){ if(fNTracksSetPt(trs->fPt); track->SetPsi(trs->fPsi); track->SetTgl(trs->fTgl); 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->SetHits( trs->fNPoints, trs->fPointIDs ); UChar_t *tmpP = (UChar_t*)trs; tmpP += sizeof(AliL3TrackSegmentData)+trs->fNPoints*sizeof(UInt_t); trs = (AliL3TrackSegmentData*)tmpP; } } void AliL3TrackArray::FillTracks(Int_t ntracks, AliL3TrackSegmentData* tr,Int_t slice){ //Read tracks from shared memory (or memory) AliL3TrackSegmentData *trs = tr; for(Int_t i=0; iSetPt(trs->fPt); Float_t psi[1]; psi[0]=trs->fPsi; AliL3Transform::Local2GlobalAngle(psi,slice); track->SetPsi(psi[0]); track->SetTgl(trs->fTgl); track->SetNHits(trs->fNPoints); track->SetCharge(trs->fCharge); Float_t first[3]; first[0]=trs->fX;first[1]=trs->fY;first[2]=trs->fZ; AliL3Transform::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; AliL3Transform::Local2Global(last,slice); track->SetLastPoint(last[0],last[1],last[2]); track->SetHits( trs->fNPoints, trs->fPointIDs ); UChar_t *tmpP = (UChar_t*)trs; tmpP += sizeof(AliL3TrackSegmentData)+trs->fNPoints*sizeof(UInt_t); trs = (AliL3TrackSegmentData*)tmpP; } } UInt_t AliL3TrackArray::GetOutSize(){ UInt_t count = GetOutCount(); //use only present tracks UInt_t tHits = 0; for(Int_t i=0;iGetNHits(); } //calculate size of track return count*sizeof(AliL3TrackSegmentData)+sizeof(UInt_t)*tHits; } UInt_t AliL3TrackArray::WriteTracks(UInt_t & ntracks,AliL3TrackSegmentData* tr){ ntracks = GetOutCount(); return WriteTracks(tr); } UInt_t AliL3TrackArray::WriteTracks(AliL3TrackSegmentData* tr){ if(GetTrackType()=='c') return WriteConfMapTracks(tr); AliL3TrackSegmentData *tP = tr; UInt_t *pP; UInt_t size = 0; for(Int_t i=0; ifX = track->GetFirstPointX(); tP->fY = track->GetFirstPointY(); tP->fZ = track->GetFirstPointZ(); tP->fPt = track->GetPt(); tP->fLastX = track->GetLastPointX(); tP->fLastY = track->GetLastPointY(); tP->fLastZ = track->GetLastPointZ(); tP->fPsi = track->GetPsi(); tP->fTgl = track->GetTgl(); tP->fCharge = track->GetCharge(); tP->fNPoints = track->GetNHits(); pP = (UInt_t*)track->GetHitNumbers(); for (UInt_t j=0;jfNPoints;j++){ tP->fPointIDs[j] = pP[j]; } Byte_t *tmpP = (Byte_t *)tP; tmpP += sizeof(AliL3TrackSegmentData)+tP->fNPoints*sizeof(UInt_t); size += sizeof(AliL3TrackSegmentData)+tP->fNPoints*sizeof(UInt_t); tP = (AliL3TrackSegmentData*)tmpP; } return size; } UInt_t AliL3TrackArray::WriteConfMapTracks(AliL3TrackSegmentData* tr){ // use first and last point objects AliL3TrackSegmentData *tP = tr; UInt_t *pP; UInt_t size = 0; for(Int_t i=0; ilastHit; AliL3ConfMapPoint *lastHit = (AliL3ConfMapPoint*)track->firstHit; tP->fX = hit->GetX(); tP->fY = hit->GetY(); tP->fZ = hit->GetZ(); tP->fLastX = lastHit->GetX(); tP->fLastY = lastHit->GetY(); tP->fLastZ = lastHit->GetZ(); // tP->fX = track->GetFirstPointX(); // tP->fY = track->GetFirstPointY(); // tP->fZ = track->GetFirstPointZ(); tP->fPt = track->GetPt(); // tP->fLastX = track->GetLastPointX(); // tP->fLastY = track->GetLastPointY(); // tP->fLastZ = track->GetLastPointZ(); tP->fPsi = track->GetPsi(); tP->fTgl = track->GetTgl(); tP->fCharge = track->GetCharge(); tP->fNPoints = track->GetNHits(); pP = (UInt_t*)track->GetHitNumbers(); for (UInt_t j=0;jfNPoints;j++){ tP->fPointIDs[j] = pP[j]; } Byte_t *tmpP = (Byte_t *)tP; tmpP += sizeof(AliL3TrackSegmentData)+tP->fNPoints*sizeof(UInt_t); size +=sizeof(AliL3TrackSegmentData)+tP->fNPoints*sizeof(UInt_t); tP = (AliL3TrackSegmentData*)tmpP; } return size; } void AliL3TrackArray::AddLast(AliL3Track *track) { AliL3Track *tpt = NextTrack(); tpt->Set(track); } void AliL3TrackArray::AddTracks(AliL3TrackArray *newtrack,Bool_t remove_old,Int_t slice) { if(GetTrackType() != newtrack->GetTrackType() && GetTrackType()!='t') { LOG(AliL3Log::kError,"AliL3TrackArray::AddTracks","Track types") <<"Bad idea to add tracks of different types"<GetNPresent()) SetSize(fSize+newtrack->GetSize()); for(Int_t i =0;iGetNTracks();i++){ AliL3Track *tpt = newtrack->GetCheckedTrack(i); if(!tpt) continue; if(remove_old) newtrack->Remove(i); AliL3Track *track = NextTrack(); track->Set(tpt); if(slice>=0) track->Rotate(slice); //Rotate track to global coordinates /* AliL3Track *track; if(GetTrackType()=='h') track = (AliL3HoughTrack*)NextTrack(); else track = NextTrack(); track->Set(tpt); */ } } void AliL3TrackArray::Compress(){ if(GetNPresent()==GetNTracks()) return; AliL3Track **tmp = new AliL3Track *[fNTracks]; Int_t present=0; Int_t absent=GetNPresent(); for(Int_t i=0;i 1) { i = first; j = last; for (;;) { while (++i < last && TrackCompare(a[i], a[first]) < 0) ; while (--j > first && TrackCompare(a[j], a[first]) > 0) ; if (i >= j) break; tmp = a[i]; a[i] = a[j]; a[j] = tmp; } if (j == first) { ++first; continue; } tmp = a[first]; a[first] = a[j]; a[j] = tmp; if (j - first < last - (j + 1)) { QSort(a, first, j); first = j + 1; // QSort(j + 1, last); } else { QSort(a, j + 1, last); last = j; // QSort(first, j); } } } Int_t AliL3TrackArray::TrackCompare(AliL3Track *a, AliL3Track *b){ // Compare the two tracks. return b->Compare(a); /* if(fTrackType=='h') { AliL3HoughTrack *tra = (AliL3HoughTrack*)a; AliL3HoughTrack *trb = (AliL3HoughTrack*)b; if(tra->GetWeight() < trb->GetWeight()) return 1; if(tra->GetWeight() > trb->GetWeight()) return -1; } else { if(a->GetNHits() < b->GetNHits()) return 1; if(a->GetNHits() > b->GetNHits()) return -1; } return 0; */ }