// @(#) $Id$ // Author: Anders Vestbo //*-- Copyright © ALICE HLT Group #include "AliL3StandardIncludes.h" #include "AliL3HoughTest.h" #include "AliL3ModelTrack.h" #include "AliL3Transform.h" #include "AliL3Histogram.h" #include "AliL3TrackArray.h" #include "AliL3HoughTrack.h" #include #include #include #include #include #if __GNUC__ == 3 using namespace std; #endif //_____________________________________________________________ // AliL3HoughTest ClassImp(AliL3HoughTest) AliL3HoughTest::AliL3HoughTest() { //ctor fData=0; } AliL3HoughTest::~AliL3HoughTest() { //dtor if(fData) delete [] fData; } Bool_t AliL3HoughTest::GenerateTrackData(Double_t pt,Double_t psi,Double_t tgl,Int_t sign,Int_t patch,Int_t minhits) { //Generate digits according to given track parameters? fCurrentPatch=patch; if(fData) delete fData; fData = new AliL3SimData[AliL3Transform::GetNRows(patch)]; memset(fData,0,AliL3Transform::GetNRows(patch)*sizeof(AliL3SimData)); AliL3ModelTrack *track = new AliL3ModelTrack(); track->Init(0,patch); track->SetPt(pt); track->SetPsi(psi); track->SetTgl(tgl); track->SetCharge(sign); track->SetFirstPoint(0,0,0); track->CalculateHelix(); Int_t temp[200]; // Int_t temp2[AliL3Transform::GetNTimeBins()]; Int_t * temp2 = new Int_t[AliL3Transform::GetNTimeBins()]; Int_t entries=100; Int_t clustercharge=100; Int_t hitcounter=0; for(Int_t i=AliL3Transform::GetFirstRow(patch); i<=AliL3Transform::GetLastRow(patch); i++) { Float_t xyz[3]; if(!track->GetCrossingPoint(i,xyz)) continue; Int_t rowindex = i - AliL3Transform::GetFirstRow(patch); Int_t sector,row; AliL3Transform::Slice2Sector(0,i,sector,row); AliL3Transform::Local2Raw(xyz,sector,row); if(xyz[1] < 0 || xyz[1] >= AliL3Transform::GetNPads(i) || xyz[2] < 0 || xyz[2] >= AliL3Transform::GetNTimeBins()) continue; hitcounter++; track->SetPadHit(i,xyz[1]); track->SetTimeHit(i,xyz[2]); Double_t beta = track->GetCrossingAngle(i); track->SetCrossingAngleLUT(i,beta); track->CalculateClusterWidths(i); memset(temp,0,200*sizeof(Int_t)); memset(temp2,0,AliL3Transform::GetNTimeBins()*sizeof(Int_t)); Double_t xysigma = sqrt(track->GetParSigmaY2(i)); Double_t zsigma = sqrt(track->GetParSigmaZ2(i)); Int_t minpad=200,j; Int_t mintime = 1000; for(j=0; jGaus(xyz[1],xysigma)); Int_t time = TMath::Nint(gRandom->Gaus(xyz[2],zsigma)); if(pad < 0 || pad >= AliL3Transform::GetNPads(i) || time < 0 || time >= AliL3Transform::GetNTimeBins()) continue; temp[pad]++; temp2[time]++; if(pad < minpad) minpad=pad; if(time < mintime) mintime=time; } Int_t npads=0; for(j=0; j<200; j++) { if(temp[j]==0) continue; Int_t index = j - minpad; if(index < 0 || index >= 10) { cerr<<"AliL3HoughTest::GenerateTrackData : Wrong index "<= 10) { cerr<<"AliL3HoughTest::GenerateTrackData : Wrong timeindex "< 1023) charge=1023; //cout<<"row "<GetFirstYbin(); k<=hist->GetLastYbin(); k++) { phi0 = hist->GetBinCenterY(k); kappa = 2*sin(phi-phi0)/r; hist->Fill(kappa,phi0,charge); } } } } } void AliL3HoughTest::Transform2CircleC(AliL3Histogram *hist) { //Hough transform if(!fData) { cerr<<"AliL3HoughTest::TransformC : No data"<Fill(kappa,phi0,charge1+charge2); } } } return; } } } } void AliL3HoughTest::Transform2CircleF(AliL3Histogram *hist) { //Fix one point in the middle of the tpc if(!fData) { cerr<<"AliL3HoughTest::TransformF : No data"<Fill(kappa,phi0,charge1+charge2); //cout<<"Filling "<rowrange[1]) break; Int_t rowindex = i - AliL3Transform::GetFirstRow(fCurrentPatch); for(Int_t d=0; dGetFirstXbin(); xbinGetLastXbin(); xbin++) { theta = hist->GetBinCenterX(xbin); rho = hit[0]*cos(theta) + hit[1]*sin(theta); hist->Fill(theta,rho,charge); } } } } } void AliL3HoughTest::Transform2LineC(AliL3Histogram *hist,Int_t *rowrange) { //Hough transform? if(!fData) { cerr<<"AliL3HoughTest::Transform2Line : No data"<Fill(theta,rho,charge1+charge2); } } } } } } } void AliL3HoughTest::FillImage(TH2 *hist,Int_t displayrow) { //Draw digits data if(!fData) { cerr<<"AliL3HoughTest::FillImage : No data to fill"<=0) if(i != displayrow) continue; //cout<<"row "<=0) hist->Fill(pad,time,charge); else hist->Fill(xyz[0],xyz[1],charge); } } if(displayrow>=0) break; } } void AliL3HoughTest::Transform2Line3D(TH3 *hist,Int_t *rowrange,Float_t *phirange) { //HT in 3D? if(!fData) { cerr<<"AliL3HoughTest::Transform2Line : No data"<rowrange[1]) break; Int_t rowindex = i - AliL3Transform::GetFirstRow(fCurrentPatch); for(Int_t d=0; d phirange[1]) continue; hit[0] = hit[0] - AliL3Transform::Row2X(rowrange[0]); Float_t x = hit[0] + AliL3Transform::Row2X(rowrange[0]); r = sqrt(x*x + hit[1]*hit[1]); delta = atan(hit[2]/r); for(Int_t xbin=hist->GetXaxis()->GetFirst(); xbin<=hist->GetXaxis()->GetLast(); xbin++) { theta = hist->GetXaxis()->GetBinCenter(xbin); rho = hit[0]*cos(theta) + hit[1]*sin(theta); hist->Fill(theta,rho,delta,charge); } } } } } void AliL3HoughTest::Transform2LineC3D(TH3 *hist,Int_t *rowrange) { //HT in 3D? if(!fData) { cerr<<"AliL3HoughTest::Transform2Line : No data"<rowrange[1]) break; Int_t rowindex1 = i - AliL3Transform::GetFirstRow(fCurrentPatch); for(Int_t d1=0; d1Fill(theta,rho,delta,charge1+charge2); } } } } } } } void AliL3HoughTest::TransformLines2Circle(TH3 *hist,AliL3TrackArray *tracks) { //Another HT? for(Int_t i=0; iGetNTracks(); i++) { AliL3HoughTrack *tr = (AliL3HoughTrack*)tracks->GetCheckedTrack(i); if(!tr) continue; Int_t middlerow = (Int_t)(tr->GetFirstRow()+(tr->GetLastRow()-tr->GetFirstRow())/2); Float_t hit[3]; tr->GetLineCrossingPoint(middlerow,hit); hit[0] += AliL3Transform::Row2X(tr->GetFirstRow()); Float_t r = sqrt(hit[0]*hit[0] + hit[1]*hit[1]); hit[2] = r*tr->GetTgl(); Float_t phi = atan2(hit[1],hit[0]); Float_t theta = tr->GetPsiLine() - AliL3Transform::Pi()/2; Float_t psi = 2*phi - theta; Float_t kappa = 2/r*sin(phi-psi); Float_t delta = atan(hit[2]/r); hist->Fill(kappa,psi,delta,tr->GetWeight()); } } void AliL3HoughTest::Transform2Center(AliL3Histogram *hist) { //Choose parameter space to be center of curvature. if(!fData) { cerr<<"AliL3HoughTest::TransformC : No data"<Fill(xc,yc,charge1+charge2); } } } } } } } void AliL3HoughTest::FindAbsMaxima(TH3 *hist,Int_t zsearch,Float_t &maxx,Float_t &maxy,Float_t &maxz,Int_t &maxvalue) const { //Find peaks in the Hough space TH1 *h1 = hist->Project3D("z"); TAxis *z = hist->GetZaxis(); Float_t zpeak[50]; Int_t n=0,i,zbin[50]; for(i=z->GetFirst()+1; iGetLast()-1; i++) { int bin1 = h1->GetBin(i-1); int bin2 = h1->GetBin(i); int bin3 = h1->GetBin(i+1); if(h1->GetBinContent(bin2) > h1->GetBinContent(bin1) && h1->GetBinContent(bin2) > h1->GetBinContent(bin3)) { zbin[n]=bin2; zpeak[n++]=h1->GetBinCenter(bin2); } } Int_t zrange[2] = {z->GetFirst(),z->GetLast()}; z->SetRange(zbin[0]-zsearch,zbin[0]+zsearch); TH1 *h2 = hist->Project3D("yx"); z->SetRange(zrange[0],zrange[1]); TAxis *x = h2->GetXaxis(); TAxis *y = h2->GetYaxis(); maxvalue=0; for(i=0; iGetFirst(); xbin<=x->GetLast(); xbin++) { Float_t xvalue = x->GetBinCenter(xbin); for(Int_t ybin=y->GetFirst(); ybin<=y->GetLast(); ybin++) { Float_t yvalue = y->GetBinCenter(ybin); Int_t value = (Int_t)h2->GetBinContent(xbin,ybin); if(value > maxvalue) { maxvalue=value; maxx = xvalue; maxy = yvalue; maxz = zpeak[i]; } } } } delete h1; delete h2; }