1 //Author: Anders Strand Vestbo
2 //Last Modified: 14.09.01
4 #include "AliL3MemHandler.h"
5 #include "AliL3Logging.h"
6 #include "AliL3HoughTransformer.h"
8 #include "AliL3Transform.h"
9 #include "AliL3DigitData.h"
10 #include "AliL3Histogram.h"
12 ClassImp(AliL3HoughTransformer)
14 AliL3HoughTransformer::AliL3HoughTransformer()
20 AliL3HoughTransformer::AliL3HoughTransformer(Int_t slice,Int_t patch,Int_t n_eta_segments)
24 fNEtaSegments = n_eta_segments;
26 fEtaMax = fSlice < 18 ? 0.9 : -0.9;
27 fTransform = new AliL3Transform();
33 AliL3HoughTransformer::~AliL3HoughTransformer()
40 void AliL3HoughTransformer::DeleteHistograms()
44 for(Int_t i=0; i<fNEtaSegments; i++)
46 if(!fParamSpace[i]) continue;
47 delete fParamSpace[i];
49 delete [] fParamSpace;
52 void AliL3HoughTransformer::CreateHistograms(Int_t nxbin,Double_t pt_min,
53 Int_t nybin,Double_t phimin,Double_t phimax)
55 //Set the minimum absolute pt value, and phi0 angles given in degrees.
57 Double_t torad = 3.1415/180;
58 Double_t bfact = 0.0029980;
59 Double_t bfield = 0.2;
60 Double_t x = bfact*bfield/pt_min;
61 CreateHistograms(nxbin,-1.*x,x,nybin,phimin*torad,phimax*torad);
64 void AliL3HoughTransformer::CreateHistograms(Int_t nxbin,Double_t xmin,Double_t xmax,
65 Int_t nybin,Double_t ymin,Double_t ymax)
68 fParamSpace = new AliL3Histogram*[fNEtaSegments];
71 for(Int_t i=0; i<fNEtaSegments; i++)
73 sprintf(histname,"paramspace_%d",i);
74 fParamSpace[i] = new AliL3Histogram(histname,"",nxbin,xmin,xmax,nybin,ymin,ymax);
78 void AliL3HoughTransformer::Reset()
80 //Reset all the histograms
84 LOG(AliL3Log::kWarning,"AliL3HoughTransformer::Reset","Histograms")
85 <<"No histograms to reset"<<ENDLOG;
89 for(Int_t i=0; i<fNEtaSegments; i++)
90 fParamSpace[i]->Reset();
93 void AliL3HoughTransformer::SetInputData(UInt_t ndigits,AliL3DigitRowData *ptr)
95 fNDigitRowData = ndigits;
99 void AliL3HoughTransformer::TransformCircle()
101 //Transform the input data with a circle HT.
104 //Set pointer to the data
105 AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fDigitRowData;
106 if(!tempPt || fNDigitRowData==0)
108 printf("\nAliL3HoughTransformer::TransformCircle : No input data!!!\n\n");
112 Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments;
113 for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
115 AliL3DigitData *digPt = tempPt->fDigitData;
116 if(i != (Int_t)tempPt->fRow)
118 printf("AliL3HoughTransform::TransformCircle : Mismatching padrow numbering\n");
121 for(UInt_t j=0; j<tempPt->fNDigit; j++)
123 UShort_t charge = digPt[j].fCharge;
124 UChar_t pad = digPt[j].fPad;
125 UShort_t time = digPt[j].fTime;
126 if(charge <= fThreshold)
130 fTransform->Slice2Sector(fSlice,i,sector,row);
131 fTransform->Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
132 Double_t eta = fTransform->GetEta(xyz);
133 Int_t eta_index = (Int_t)((eta-fEtaMin)/etaslice);
134 if(eta_index < 0 || eta_index >= fNEtaSegments)
137 //Get the correct histogrampointer:
138 AliL3Histogram *hist = fParamSpace[eta_index];
141 printf("AliL3HoughTransformer::TransformCircle : Error getting histogram in index %d\n",eta_index);
145 //Start transformation
146 Float_t R = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); // + xyz[2]*xyz[2]);
147 Float_t phi = fTransform->GetPhi(xyz);
149 //Fill the histogram along the phirange
150 for(Int_t b=hist->GetFirstYbin(); b<=hist->GetLastYbin(); b++)
152 Float_t phi0 = hist->GetBinCenterY(b);
153 Float_t kappa = 2*sin(phi - phi0)/R;
154 hist->Fill(kappa,phi0,charge);
157 AliL3MemHandler::UpdateRowPointer(tempPt);
161 void AliL3HoughTransformer::TransformLine()
163 //Do a line transform on the data.
166 AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fDigitRowData;
167 if(!tempPt || fNDigitRowData==0)
169 printf("\nAliL3HoughTransformer::TransformLine : No input data!!!\n\n");
173 Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments;
174 for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
176 AliL3DigitData *digPt = tempPt->fDigitData;
177 if(i != (Int_t)tempPt->fRow)
179 printf("AliL3HoughTransform::TransformLine : Mismatching padrow numbering\n");
182 for(UInt_t j=0; j<tempPt->fNDigit; j++)
184 UShort_t charge = digPt[j].fCharge;
185 UChar_t pad = digPt[j].fPad;
186 UShort_t time = digPt[j].fTime;
187 if(charge < fThreshold)
191 fTransform->Slice2Sector(fSlice,i,sector,row);
192 fTransform->Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
193 Float_t eta = fTransform->GetEta(xyz);
194 Int_t eta_index = (Int_t)(eta/etaslice);
195 if(eta_index < 0 || eta_index >= fNEtaSegments)
198 //Get the correct histogram:
199 AliL3Histogram *hist = fParamSpace[eta_index];
202 printf("AliL3HoughTransformer::TransformLine : Error getting histogram in index %d\n",eta_index);
205 for(Int_t xbin=hist->GetFirstXbin(); xbin<hist->GetLastXbin(); xbin++)
207 Double_t theta = hist->GetBinCenterX(xbin);
208 Double_t rho = xyz[0]*cos(theta) + xyz[1]*sin(theta);
209 hist->Fill(theta,rho,charge);
212 AliL3MemHandler::UpdateRowPointer(tempPt);