// @(#) $Id$ // Author: Anders Vestbo //*-- Copyright © ALICE HLT Group //_____________________________________________________________ // AliL3ModelTrack // // #include "AliL3StandardIncludes.h" #include "AliL3Logging.h" #include "AliL3Transform.h" #include "AliL3Vertex.h" #include "AliL3DataCompressorHelper.h" #include "AliL3ModelTrack.h" #if __GNUC__ == 3 using namespace std; #endif ClassImp(AliL3ModelTrack) AliL3ModelTrack::AliL3ModelTrack() { // default constructor fNClusters = 0; fClusters = 0; fOverlap = 0; fPad=0; fTime=0; fNoverlaps=0; fClusterCharge=0; fTrackModel=0; fCrossingAngle=0; fParSigmaY2=0; fParSigmaZ2=0; fArraysCreated=kFALSE; } AliL3ModelTrack::~AliL3ModelTrack() { // destructor DeleteArrays(); } void AliL3ModelTrack::DeleteArrays() { // deletes all arrays if(fClusters) delete [] fClusters; if(fPad) delete [] fPad; if(fTime) delete [] fTime; if(fCrossingAngle) delete [] fCrossingAngle; if(fParSigmaY2) delete [] fParSigmaY2; if(fParSigmaZ2) delete [] fParSigmaZ2; if(fTrackModel) delete fTrackModel; if(fNoverlaps) delete [] fNoverlaps; if(fOverlap) { for(Int_t i=0; i AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::CalculcateClusterWidths : Wrond index "<fPresent |= 0x2; //set second bit to true, because a fit attempt has been made Int_t patch = AliL3Transform::GetPatch(row); if(!charge || npads == 1) { cl->fPresent &= ~0x1; //set first bit to false } else { cl->fPresent|=0x1;//set first bit to true cl->fDPad = (fpad - GetPadHit(row))/(AliL3DataCompressorHelper::GetXYResidualStep(row)/AliL3Transform::GetPadPitchWidth(patch)); cl->fDTime = (ftime - GetTimeHit(row))/(AliL3DataCompressorHelper::GetZResidualStep(row)/AliL3Transform::GetZWidth()); cl->fDCharge = charge; if(sigmaY2==0 && sigmaZ2==0) { cl->fDSigmaY=0;//if width is zero, shape is not supposed to be written cl->fDSigmaZ=0; } else { //cl->fDSigmaY2 = (sigmaY2 - GetParSigmaY2(row))/(pow(AliL3DataCompressorHelper::GetXYWidthStep(),2)/pow(AliL3Transform::GetPadPitchWidth(patch),2)); //cl->fDSigmaZ2 = (sigmaZ2 - GetParSigmaZ2(row))/(pow(AliL3DataCompressorHelper::GetZWidthStep(),2)/pow(AliL3Transform::GetZWidth(),2)); cl->fDSigmaY = (sqrt(sigmaY2) - sqrt(GetParSigmaY2(row)))/(AliL3DataCompressorHelper::GetXYWidthStep()/AliL3Transform::GetPadPitchWidth(patch)); cl->fDSigmaZ = (sqrt(sigmaZ2) - sqrt(GetParSigmaZ2(row)))/(AliL3DataCompressorHelper::GetZWidthStep()/AliL3Transform::GetZWidth()); } cl->fNPads = npads; } } void AliL3ModelTrack::Set(AliL3Track *tpt) { // Sets track and does initialization AliL3ModelTrack *tr = (AliL3ModelTrack*)tpt; SetRowRange(tr->GetFirstRow(),tr->GetLastRow()); SetPhi0(tr->GetPhi0()); SetKappa(tr->GetKappa()); SetFirstPoint(tr->GetFirstPointX(),tr->GetFirstPointY(),tr->GetFirstPointZ()); SetLastPoint(tr->GetLastPointX(),tr->GetLastPointY(),tr->GetLastPointZ()); SetPt(tr->GetPt()); SetPsi(tr->GetPsi()); SetTgl(tr->GetTgl()); SetCharge(tr->GetCharge()); if(fClusters) { cerr<<"AliL3ModelTrack::Set : Init has already been called for this object!"<fSlice,tr->fPatch); Init(0,tr->fPatch); memcpy(fClusters,tr->fClusters,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel)); memcpy(fPad,tr->fPad,AliL3Transform::GetNRows(fPatch)*sizeof(Float_t)); memcpy(fTime,tr->fTime,AliL3Transform::GetNRows(fPatch)*sizeof(Float_t)); memcpy(fParSigmaY2,tr->fParSigmaY2,AliL3Transform::GetNRows(fPatch)*sizeof(Float_t)); memcpy(fParSigmaZ2,tr->fParSigmaZ2,AliL3Transform::GetNRows(fPatch)*sizeof(Float_t)); memcpy(fCrossingAngle,tr->fCrossingAngle,AliL3Transform::GetNRows(fPatch)*sizeof(Float_t)); memcpy(fTrackModel,tr->fTrackModel,sizeof(AliL3TrackModel)); } Int_t AliL3ModelTrack::GetNPresentClusters() { //Return the number of assigned clusters to the track. //Differs from fNClusters, which should be equal to the //number of padrows in the present patch. Int_t count=0; for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++) if(IsPresent(i)) count++; return count; } void AliL3ModelTrack::FillModel() { //Fill the track structure if(fNClusters != AliL3Transform::GetNRows(fPatch)) { cout<<"AliL3ModelTrack::FillModel : fNClusters != nrows; beware, this could be caused by a bug!!!"<fKappa = GetKappa(); fTrackModel->fPhi = atan2(impact[1],impact[0]); fTrackModel->fD = sqrt(impact[0]*impact[0] + impact[1]*impact[1]); fTrackModel->fZ0 = impact[2]; fTrackModel->fTgl = GetTgl(); //We have to check on which of the vertex the track fit is lying //This we need to encode the azimuthal angle coordinate of the center of curvature. if(GetRadius() < sqrt(GetCenterX()*GetCenterX()+GetCenterY()*GetCenterY())) fTrackModel->fD *=-1; } void AliL3ModelTrack::FillTrack() { //Fill the track parameters from the structure. if(!fTrackModel) { cerr<<"AliL3ModelTrack::FillTrack() : No data!!"<fKappa); Double_t impact[3],psi; Float_t trackPhi0 = fTrackModel->fPhi; if(fTrackModel->fD < 0) trackPhi0 += AliL3Transform::Pi(); Int_t charge = -1*(Int_t)copysign(1.,GetKappa()); impact[0] = fabs(fTrackModel->fD)*cos(fTrackModel->fPhi); impact[1] = fabs(fTrackModel->fD)*sin(fTrackModel->fPhi); impact[2] = fTrackModel->fZ0; psi = trackPhi0 - charge*0.5*AliL3Transform::Pi(); if(psi < 0) psi += 2*AliL3Transform::Pi(); SetCharge(charge); SetFirstPoint(impact[0],impact[1],impact[2]); SetPsi(psi); SetTgl(fTrackModel->fTgl); SetPt((AliL3Transform::GetBFact()*AliL3Transform::GetBField())/fabs(GetKappa())); fNClusters = AliL3Transform::GetNRows(fPatch); CalculateHelix(); for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++) { AliL3ClusterModel *cl = GetClusterModel(i); if(!cl) continue; if(cl->fSlice == -1) { SetPadHit(i,-1); SetTimeHit(i,-1); continue; } if(cl->fSlice < 0 || cl->fSlice > 35) { cerr<<"AliL3ModelTrack::FillTrack : Slice out of range "<fSlice<<" on row "<fSlice); if(!CalculateReferencePoint(angle,AliL3Transform::Row2X(i))) { if(IsPresent(i)) { cerr<<"AliL3ModelTrack::FillTrack : Track does not cross slice "<fSlice<<" row "<fSlice,i,sector,row); AliL3Transform::Global2Raw(hit,sector,row); SetPadHit(i,hit[1]); SetTimeHit(i,hit[2]); Float_t crossingangle = GetCrossingAngle(i,cl->fSlice); SetCrossingAngleLUT(i,crossingangle); CalculateClusterWidths(i,kTRUE); } } void AliL3ModelTrack::SetPadHit(Int_t row,Float_t pad) { // sets pad hit Int_t index = row-AliL3Transform::GetFirstRow(fPatch); if(index < 0 || index > AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::SetPadHit() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::SetTimeHit() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::SetCrossingAngle() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::SetOverlap() : Wrong index: "<= fMaxOverlaps) return; fOverlap[index][fNoverlaps[index]++] = id; } Bool_t AliL3ModelTrack::IsPresent(Int_t row) { AliL3ClusterModel *cl = GetClusterModel(row); return (Bool_t)(cl->fPresent & 0x1); } Bool_t AliL3ModelTrack::IsSet(Int_t row) { // checks if row was set AliL3ClusterModel *cl = GetClusterModel(row); return (Bool_t)(cl->fPresent & 0x2); } Int_t AliL3ModelTrack::GetNPads(Int_t row) { // gets number of pads AliL3ClusterModel *cl = GetClusterModel(row); return cl->fNPads; } Bool_t AliL3ModelTrack::GetPad(Int_t row,Float_t &pad) { // gets pad //(fpad - GetPadHit(row))/(AliL3DataCompressorHelper::GetXYResidualStep(row)/AliL3Transform::GetPadPitchWidth(patch)); AliL3ClusterModel *cl = GetClusterModel(row); Int_t patch = AliL3Transform::GetPatch(row); pad = cl->fDPad*(AliL3DataCompressorHelper::GetXYResidualStep(row)/AliL3Transform::GetPadPitchWidth(patch)) + GetPadHit(row); return IsPresent(row); } Bool_t AliL3ModelTrack::GetTime(Int_t row,Float_t &time) { // gets time AliL3ClusterModel *cl = GetClusterModel(row); time = cl->fDTime*(AliL3DataCompressorHelper::GetZResidualStep(row)/AliL3Transform::GetZWidth()) + GetTimeHit(row); return IsPresent(row); } Bool_t AliL3ModelTrack::GetClusterCharge(Int_t row,Int_t &charge) { // gets cluster's charge AliL3ClusterModel *cl = GetClusterModel(row); charge = (Int_t)cl->fDCharge;// + AliL3DataCompressorHelperHelper::GetClusterCharge(); return IsPresent(row); } Bool_t AliL3ModelTrack::GetSigmaY2(Int_t row,Float_t &sigma2) { // gets SigmaY2 //cl->fDSigmaY = (sqrt(sigmaY2) - sqrt(GetParSigmaY2(row)))/(AliL3DataCompressorHelper::GetXYWidthStep()/AliL3Transform::GetPadPitchWidth(patch)); AliL3ClusterModel *cl = GetClusterModel(row); Int_t patch = AliL3Transform::GetPatch(row); Float_t sigma = cl->fDSigmaY*(AliL3DataCompressorHelper::GetXYWidthStep()/AliL3Transform::GetPadPitchWidth(patch)) + sqrt(GetParSigmaY2(row)); sigma2 = sigma*sigma; return IsPresent(row); } Bool_t AliL3ModelTrack::GetSigmaZ2(Int_t row,Float_t &sigma2) { // gets SigmaZ2 //cl->fDSigmaZ = (sqrt(sigmaZ2) - sqrt(GetParSigmaZ2(row)))/(AliL3DataCompressorHelper::GetZWidthStep()/AliL3Transform::GetZWidth()); AliL3ClusterModel *cl = GetClusterModel(row); Float_t sigma = cl->fDSigmaZ*(AliL3DataCompressorHelper::GetZWidthStep()/AliL3Transform::GetZWidth()) + sqrt(GetParSigmaZ2(row)); sigma2 = sigma*sigma; return IsPresent(row); } Bool_t AliL3ModelTrack::GetPadResidual(Int_t row,Float_t &res) { // gets pad residual AliL3ClusterModel *cl = GetClusterModel(row); Int_t patch = AliL3Transform::GetPatch(row); res = cl->fDPad*(AliL3DataCompressorHelper::GetXYResidualStep(row)/AliL3Transform::GetPadPitchWidth(patch)); return IsPresent(row); } Bool_t AliL3ModelTrack::GetTimeResidual(Int_t row,Float_t &res) { // gets time residual AliL3ClusterModel *cl = GetClusterModel(row); res = cl->fDTime*(AliL3DataCompressorHelper::GetZResidualStep(row)/AliL3Transform::GetZWidth()); return IsPresent(row); } Bool_t AliL3ModelTrack::GetSigmaYResidual(Int_t row,Float_t &res) { // gets SigmaY residual (?) AliL3ClusterModel *cl = GetClusterModel(row); Int_t patch = AliL3Transform::GetPatch(row); res = cl->fDSigmaY*(AliL3DataCompressorHelper::GetXYWidthStep()/AliL3Transform::GetPadPitchWidth(patch)); return IsPresent(row); } Bool_t AliL3ModelTrack::GetSigmaZResidual(Int_t row,Float_t &res) { // gets SigmaZ resigual (?) AliL3ClusterModel *cl = GetClusterModel(row); res = cl->fDSigmaZ*(AliL3DataCompressorHelper::GetZWidthStep()/AliL3Transform::GetZWidth()); return IsPresent(row); } Int_t AliL3ModelTrack::GetSlice(Int_t row) { // Gets slice AliL3ClusterModel *cl = GetClusterModel(row); return cl->fSlice; } Float_t AliL3ModelTrack::GetPadHit(Int_t row) { // Gets pad hit Int_t index = row-AliL3Transform::GetFirstRow(fPatch); if(index < 0 || index > AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::GetPadHit() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::GetTimeHit() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::GetCrossingAngleLUT() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::GetParSigmaY2() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::GetParSigmaZ2() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::GetOverlap() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::GetOverlap() : Wrong index: "< AliL3Transform::GetNRows(fPatch)) { cerr<<"AliL3ModelTrack::GetClusterModel() : Wrong index: "<fSlice<<" Padcrossing "<fSlice,i,GetPadHit(i),GetTimeHit(i)); //cout<fSlice<<" x "<fSlice; else if(cl->fSlice != origslice) cout<<"Change in slice "<fSlice<<" "<fSlice<<" Dpad "<fDPad<<" Dtime "<fDTime<<" Dcharge "<fDCharge; cout<<" sigmaY2 "<fTrackID[0] = trackID[0]; cl->fTrackID[1] = trackID[1]; cl->fTrackID[2] = trackID[2]; #endif return; } void AliL3ModelTrack::GetClusterLabel(Int_t row,Int_t *trackID) { // gets cluster label #ifdef do_mc AliL3ClusterModel *cl = GetClusterModel(row); trackID[0] = cl->fTrackID[0]; trackID[1] = cl->fTrackID[1]; trackID[2] = cl->fTrackID[2]; #endif return; }