// AliL3HoughTransformer
//
// Hough transformation class
+//
ClassImp(AliL3HoughTransformer)
AliL3HoughTransformer::AliL3HoughTransformer(Int_t slice,Int_t patch,Int_t n_eta_segments)
{
+ //Normal constructor
+
fSlice = slice;
fPatch = patch;
fNEtaSegments = n_eta_segments;
void AliL3HoughTransformer::CreateHistograms(Int_t nxbin,Double_t pt_min,
Int_t nybin,Double_t phimin,Double_t phimax)
{
- //Set the minimum absolute pt value, and phi0 angles given in degrees.
-
+ //Create the histograms (parameter space).
+ //These are 2D histograms, span by kappa (curvature of track) and phi0 (emission angle with x-axis).
+ //The arguments give the range and binning;
+ //nxbin = #bins in kappa
+ //nybin = #bins in phi0
+ //pt_min = mimium Pt of track (corresponding to maximum kappa)
+ //phi_min = mimimum phi0 (degrees)
+ //phi_max = maximum phi0 (degrees)
+
Double_t bfact = 0.0029980;
Double_t bfield = 0.2;
Double_t x = bfact*bfield/pt_min;
void AliL3HoughTransformer::SetInputData(UInt_t ndigits,AliL3DigitRowData *ptr)
{
+ //Give the pointer to the data.
+
fNDigitRowData = ndigits;
fDigitRowData = ptr;
}
Int_t AliL3HoughTransformer::GetEtaIndex(Double_t eta)
{
-
+ //Return the histogram index of the corresponding eta.
+
Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments;
Double_t index = (eta-fEtaMin)/etaslice;
return (Int_t)index;
void AliL3HoughTransformer::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).
+
- //Set pointer to the data
AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fDigitRowData;
if(!tempPt || fNDigitRowData==0)
{
return;
}
- //Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments;
+ //Loop over the padrows:
for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
{
+ //Get the data on this padrow:
AliL3DigitData *digPt = tempPt->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; j<tempPt->fNDigit; j++)
{
UShort_t charge = digPt[j].fCharge;
continue;
Int_t sector,row;
Float_t xyz[3];
+
+ //Transform data to local cartesian coordinates:
fTransform->Slice2Sector(fSlice,i,sector,row);
fTransform->Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
+
+ //Calculate the eta:
Double_t eta = fTransform->GetEta(xyz);
+
+ //Get the corresponding index, which determines which histogram to fill:
Int_t eta_index = GetEtaIndex(eta);//(Int_t)((eta-fEtaMin)/etaslice);
if(eta_index < 0 || eta_index >= fNEtaSegments)
continue;
continue;
}
- //Start transformation
- Float_t R = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); // + xyz[2]*xyz[2]);
+ //Do the transformation:
+ Float_t R = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
Float_t phi = fTransform->GetPhi(xyz);
//Fill the histogram along the phirange
hist->Fill(kappa,phi0,charge);
}
}
+
+ //Move the data pointer to the next padrow:
AliL3MemHandler::UpdateRowPointer(tempPt);
}
}
-void AliL3HoughTransformer::TransformCircleC()
+void AliL3HoughTransformer::TransformCircleC(Int_t row_range)
{
//Circle transform, using combinations of every 2 points lying
//on different padrows and within the same etaslice.
-
- Int_t nrows = NRows[fPatch][1] - NRows[fPatch][0] + 1;
- AliL3DigitRowData **rowPt = new AliL3DigitRowData*[nrows];
-
AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fDigitRowData;
if(!tempPt)
printf("\nAliL3HoughTransformer::TransformCircleC() : Zero data pointer\n");
- Int_t prow;
+ Int_t counter=0;
for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
{
- prow = i - NRows[fPatch][0];
- rowPt[prow] = tempPt;
+ counter += tempPt->fNDigit;
AliL3MemHandler::UpdateRowPointer(tempPt);
}
- //Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments;
-
- AliL3DigitData *digPt;
+
+ 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 "<<counter*sizeof(Digit)<<" bytes to digitsarray"<<endl;
+
+ Int_t total_digits=counter;
+ Int_t sector,row,tot_charge,pad,time,charge;
Double_t r1,r2,phi1,phi2,eta,kappa,phi_0;
- UShort_t charge1,charge2,time;
- UChar_t pad;
Float_t xyz[3];
- Int_t sector,row,eta_index1,eta_index2,tot_charge;
- for(Int_t i=NRows[fPatch][0]; i<NRows[fPatch][1]; i++)
+
+ counter=0;
+ tempPt = (AliL3DigitRowData*)fDigitRowData;
+
+ for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
{
- prow = i - NRows[fPatch][0];
- digPt = rowPt[prow]->fDigitData;
- for(UInt_t di=0; di<rowPt[prow]->fNDigit; di++)
+ AliL3DigitData *digPt = tempPt->fDigitData;
+ for(UInt_t di=0; di<tempPt->fNDigit; di++)
{
- charge1 = digPt[di].fCharge;
+ charge = digPt[di].fCharge;
pad = digPt[di].fPad;
time = digPt[di].fTime;
- if(charge1 <= fThreshold)
- continue;
fTransform->Slice2Sector(fSlice,i,sector,row);
fTransform->Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
eta = fTransform->GetEta(xyz);
- eta_index1 = GetEtaIndex(eta);//(Int_t)((eta-fEtaMin)/etaslice);
- if(eta_index1 < 0 || eta_index1 >= fNEtaSegments)
- continue;
- r1 = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
- phi1 = atan2(xyz[1],xyz[0]);
+ 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<total_digits; i++)
+ {
+ if(digits[i].eta_index < 0 || digits[i].eta_index >= fNEtaSegments) continue;
+ Int_t ind = digits[i].eta_index;
+
+ for(Int_t j=i+1; j<total_digits; j++)
+ {
+ if(digits[i].row == digits[j].row) continue;
+ if(digits[i].eta_index != digits[j].eta_index) continue;
+ if(digits[i].row + row_range < digits[j].row) break;
//Get the correct histogrampointer:
- AliL3Histogram *hist = fParamSpace[eta_index1];
+ AliL3Histogram *hist = fParamSpace[ind];
if(!hist)
{
- printf("AliL3HoughTransformer::TransformCircleC() : No histogram at index %d\n",eta_index1);
+ printf("AliL3HoughTransformer::TransformCircleC() : No histogram at index %d\n",ind);
continue;
}
-
- for(Int_t j=i+1; j<NRows[fPatch][1]; j++)
- {
- prow = j - NRows[fPatch][0];
- digPt = rowPt[prow]->fDigitData;
- for(UInt_t ni=0; ni<rowPt[prow]->fNDigit; ni++)
- {
- charge2 = digPt[ni].fCharge;
- pad = digPt[ni].fPad;
- time = digPt[ni].fTime;
- if(charge2 <= fThreshold)
- continue;
- fTransform->Slice2Sector(fSlice,j,sector,row);
- fTransform->Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
- eta = fTransform->GetEta(xyz);
- eta_index2 = GetEtaIndex(eta);//(Int_t)((eta-fEtaMin)/etaslice);
- if(eta_index2 != eta_index1)
- continue;
- r2 = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
- phi2 = atan2(xyz[1],xyz[0]);
-
- phi_0 = atan( (r2*sin(phi1)-r1*sin(phi2))/(r2*cos(phi1)-r1*cos(phi2)) );
- kappa = 2*sin(phi2-phi_0)/r2;
- tot_charge = charge1+charge2;
- //printf("Filling kappa %f phi %f charge %d\n",kappa,phi_0,tot_charge);
- hist->Fill(kappa,phi_0,tot_charge);
- }
- }
+
+ r1 = digits[i].r;
+ phi1 = digits[i].phi;
+ r2 = digits[j].r;
+ phi2 = digits[j].phi;
+ phi_0 = atan( (r2*sin(phi1)-r1*sin(phi2))/(r2*cos(phi1)-r1*cos(phi2)) );
+ kappa = 2*sin(phi2-phi_0)/r2;
+ tot_charge = digits[i].charge + digits[j].charge;
+ hist->Fill(kappa,phi_0,tot_charge);
}
}
-
- delete [] rowPt;
+ delete [] digits;
}
void AliL3HoughTransformer::TransformLine()