//$Id$ // Author: Constantin Loizides //*-- Copyright © CL and ASV #include "AliL3MemHandler.h" #include "AliL3Logging.h" #include "AliL3Transform.h" #include "AliL3DigitData.h" #include "AliL3Histogram.h" #include "AliL3HoughTransformerVhdl.h" //_____________________________________________________________ // AliL3HoughTransformerVhdl // // Hough transformation class // ClassImp(AliL3HoughTransformerVhdl) AliL3HoughTransformerVhdl::AliL3HoughTransformerVhdl() { //Default constructor fParamSpace = 0; } AliL3HoughTransformerVhdl::AliL3HoughTransformerVhdl(Int_t slice,Int_t patch,Int_t n_eta_segments) : AliL3HoughBaseTransformer(slice,patch,n_eta_segments) { //Normal constructor fParamSpace = 0; } AliL3HoughTransformerVhdl::~AliL3HoughTransformerVhdl() { DeleteHistograms(); } void AliL3HoughTransformerVhdl::DeleteHistograms() { if(!fParamSpace) return; for(Int_t i=0; iReset(); } Int_t AliL3HoughTransformerVhdl::GetEtaIndex(Double_t eta) { //Return the histogram index of the corresponding eta. Double_t etaslice = (GetEtaMax() - GetEtaMin())/GetNEtaSegments(); Double_t index = (eta-GetEtaMin())/etaslice; return (Int_t)index; } void AliL3HoughTransformerVhdl::TransformCircle() { //Transform the input data with a circle HT. //The function loops over all the data, and transforms each pixel with the equations: // //kappa = 2/R*sin(phi - phi0) // //where R = sqrt(x*x +y*y), and phi = arctan(y/x) // //Each pixel then transforms into a curve in the (kappa,phi0)-space. In order to find //which histogram in which the pixel should be transformed, the eta-value is calcluated //and the proper histogram index is found by GetEtaIndex(eta). AliL3DigitRowData *tempPt = GetDataPointer(); if(!tempPt) { LOG(AliL3Log::kError,"AliL3HoughTransformerVhdl::TransformCircle","Data") <<"No input data "<fDigitData; if(i != (Int_t)tempPt->fRow) { printf("AliL3HoughTransform::TransformCircle : Mismatching padrow numbering\n"); continue; } //Loop over the data on this padrow: for(UInt_t j=0; jfNDigit; j++) { UShort_t charge = digPt[j].fCharge; UChar_t pad = digPt[j].fPad; UShort_t time = digPt[j].fTime; if((Int_t)charge <= GetLowerThreshold()) continue; Int_t sector,row; Float_t xyz[3]; //Transform data to local cartesian coordinates: AliL3Transform::Slice2Sector(GetSlice(),i,sector,row); AliL3Transform::Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time); //Calculate the eta: Double_t eta = AliL3Transform::GetEta(xyz); //Get the corresponding index, which determines which histogram to fill: Int_t eta_index = GetEtaIndex(eta); if(eta_index < 0 || eta_index >= GetNEtaSegments()) continue; //Get the correct histogrampointer: AliL3Histogram *hist = fParamSpace[eta_index]; if(!hist) { printf("AliL3HoughTransformerVhdl::TransformCircle : Error getting histogram in index %d\n",eta_index); continue; } //Do the transformation: Float_t R = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); Float_t phi = AliL3Transform::GetPhi(xyz); //Fill the histogram along the phirange for(Int_t b=hist->GetFirstYbin(); b<=hist->GetLastYbin(); b++) { Float_t phi0 = hist->GetBinCenterY(b); Float_t kappa = 2*sin(phi - phi0)/R; hist->Fill(kappa,phi0,charge); } } //Move the data pointer to the next padrow: AliL3MemHandler::UpdateRowPointer(tempPt); } } void AliL3HoughTransformerVhdl::TransformCircleC(Int_t row_range) { //Circle transform, using combinations of every 2 points lying //on different padrows and within the same etaslice. AliL3DigitRowData *tempPt = GetDataPointer(); if(!tempPt) LOG(AliL3Log::kError,"AliL3HoughTransformerVhdl::TransformCircleC","Data") <<"No input data "<fNDigit; AliL3MemHandler::UpdateRowPointer(tempPt); } struct Digit { Int_t row; Double_t r; Double_t phi; Int_t eta_index; Int_t charge; }; Digit *digits = new Digit[counter]; cout<<"Allocating "<fDigitData; for(UInt_t di=0; difNDigit; di++) { charge = digPt[di].fCharge; pad = digPt[di].fPad; time = digPt[di].fTime; AliL3Transform::Slice2Sector(GetSlice(),i,sector,row); AliL3Transform::Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time); eta = AliL3Transform::GetEta(xyz); digits[counter].row = i; digits[counter].r = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); digits[counter].phi = atan2(xyz[1],xyz[0]); digits[counter].eta_index = GetEtaIndex(eta); digits[counter].charge = charge; counter++; } AliL3MemHandler::UpdateRowPointer(tempPt); } for(Int_t i=0; i= GetNEtaSegments()) continue; Int_t ind = digits[i].eta_index; for(Int_t j=i+1; jFill(kappa,phi_0,tot_charge); } } delete [] digits; } void AliL3HoughTransformerVhdl::TransformLine() { //Do a line transform on the data. AliL3DigitRowData *tempPt = GetDataPointer(); if(!tempPt) { LOG(AliL3Log::kError,"AliL3HoughTransformerVhdl::TransformLine","Data") <<"No input data "<fDigitData; if(i != (Int_t)tempPt->fRow) { printf("AliL3HoughTransform::TransformLine : Mismatching padrow numbering\n"); continue; } for(UInt_t j=0; jfNDigit; j++) { UShort_t charge = digPt[j].fCharge; UChar_t pad = digPt[j].fPad; UShort_t time = digPt[j].fTime; if((Int_t)charge < GetLowerThreshold()) continue; Int_t sector,row; Float_t xyz[3]; AliL3Transform::Slice2Sector(GetSlice(),i,sector,row); AliL3Transform::Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time); Float_t eta = AliL3Transform::GetEta(xyz); Int_t eta_index = GetEtaIndex(eta);//(Int_t)(eta/etaslice); if(eta_index < 0 || eta_index >= GetNEtaSegments()) continue; //Get the correct histogram: AliL3Histogram *hist = fParamSpace[eta_index]; if(!hist) { printf("AliL3HoughTransformerVhdl::TransformLine : Error getting histogram in index %d\n",eta_index); continue; } for(Int_t xbin=hist->GetFirstXbin(); xbinGetLastXbin(); xbin++) { Double_t theta = hist->GetBinCenterX(xbin); Double_t rho = xyz[0]*cos(theta) + xyz[1]*sin(theta); hist->Fill(theta,rho,charge); } } AliL3MemHandler::UpdateRowPointer(tempPt); } }