3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliL3StandardIncludes.h"
7 #include "AliL3Logging.h"
8 #include "AliL3HistogramAdaptive.h"
9 #include "AliL3Transform.h"
10 #include "AliL3Track.h"
16 //_____________________________________________________________
17 // AliL3HistogramAdaptive
19 // 2D histogram class adapted for kappa and psi as used in the Circle Hough Transform.
20 // The bins in kappa is not linear, but has a width which is specified by argument
21 // ptres in the constructor. This gives the relative pt resolution which should
22 // be kept throughout the kappa range.
24 ClassImp(AliL3HistogramAdaptive)
26 AliL3HistogramAdaptive::AliL3HistogramAdaptive() : AliL3Histogram()
32 AliL3HistogramAdaptive::AliL3HistogramAdaptive(Char_t *name,Double_t minpt,Double_t maxpt,Double_t ptres,
33 Int_t nybins,Double_t ymin,Double_t ymax)
38 fXmin = -1*AliL3Transform::GetBFact()*AliL3Transform::GetBField()/minpt;
39 fXmax = AliL3Transform::GetBFact()*AliL3Transform::GetBField()/minpt;
43 fNxbins = InitKappaBins();
52 fNcells = (fNxbins+2)*(fNybins+2);
55 fContent = new Int_t[fNcells];
59 AliL3HistogramAdaptive::~AliL3HistogramAdaptive()
65 Int_t AliL3HistogramAdaptive::InitKappaBins()
67 //Here a LUT for the kappa values created. This has to be done since
68 //the binwidth in kappa is not constant, but change according to the
69 //set relative resolution in pt.
70 //Since the kappa values are symmetric about origo, the size of the
71 //LUT is half of the total number of bins in kappa direction.
73 Double_t pt = fMinPt,delta_pt,local_pt;
79 delta_pt = fPtres*local_pt*local_pt;
83 fKappaBins = new Double_t[bin+1];
86 fKappaBins[bin] = AliL3Transform::GetBFact()*AliL3Transform::GetBField()/fMinPt;
90 delta_pt = fPtres*local_pt*local_pt;
91 pt += 2*delta_pt; //*2 because pt +- 1/2*deltapt is one bin
93 fKappaBins[bin] = AliL3Transform::GetBFact()*AliL3Transform::GetBField()/pt;
95 return (bin+1)*2; //Both negative and positive kappa.
99 void AliL3HistogramAdaptive::Fill(Double_t x,Double_t y,Int_t weight)
101 Int_t bin = FindBin(x,y);
104 AddBinContent(bin,weight);
108 Int_t AliL3HistogramAdaptive::FindBin(Double_t x,Double_t y) const
111 Int_t xbin = FindXbin(x);
112 Int_t ybin = FindYbin(y);
116 return GetBin(xbin,ybin);
119 Int_t AliL3HistogramAdaptive::FindXbin(Double_t x) const
122 if(x < fXmin || x > fXmax || fabs(x) < fKappaBins[(fNxbins/2-1)])
125 //Remember that kappa value is decreasing with bin number!
126 //Also, the bin numbering starts at 1 and ends at fNxbins,
127 //so the corresponding elements in the LUT is bin - 1.
130 while(bin < fNxbins/2)
132 if(fabs(x) <= fKappaBins[bin] && fabs(x) > fKappaBins[bin+1])
139 return fNxbins - bin;
143 Int_t AliL3HistogramAdaptive::FindYbin(Double_t y) const
145 if(y < fYmin || y > fYmax)
148 return 1 + (Int_t)(fNybins*(y-fYmin)/(fYmax-fYmin));
151 Double_t AliL3HistogramAdaptive::GetBinCenterX(Int_t xbin) const
153 if(xbin < fFirstXbin || xbin > fLastXbin)
155 LOG(AliL3Log::kWarning,"AliL3HistogramAdaptive::GetBinCenterX","Bin-value")
156 <<"XBinvalue out of range "<<xbin<<ENDLOG;
160 //The bin numbers go from 1 to fNxbins, so the corresponding
161 //element in the LUT is xbin - 1. This is the reason why we
162 //substract a 1 here:
167 bin = fNxbins - 1 - bin;
169 //Remember again that the kappa-values are _decreasing_ with bin number.
171 Double_t binwidth = fKappaBins[bin] - fKappaBins[bin+1];
172 Double_t kappa = fKappaBins[bin] - 0.5*binwidth;
180 Double_t AliL3HistogramAdaptive::GetBinCenterY(Int_t ybin) const
182 if(ybin < fFirstYbin || ybin > fLastYbin)
184 LOG(AliL3Log::kError,"AliL3HistogramAdaptive::GetBinCenterY","ybin")
185 <<"Bin-value out of range "<<ybin<<ENDLOG;
188 Double_t binwidth = (fYmax - fYmin) / fNybins;
189 return fYmin + (ybin-0.5) * binwidth;
194 void AliL3HistogramAdaptive::Draw(Char_t *option)
202 for(Int_t i=fFirstXbin; i<=fLastXbin; i++)
204 kappa = GetBinCenterX(i);
205 for(Int_t j=fFirstYbin; j<=fLastYbin; j++)
207 psi = GetBinCenterY(j);
209 content = GetBinContent(bin);
210 fRootHisto->Fill(kappa,psi,content);
213 fRootHisto->Draw(option);
216 cerr<<"AliL3HistogramAdaptive::Draw : You need to compile with ROOT in order to draw histogram"<<endl;
219 void AliL3HistogramAdaptive::Print()
221 cout<<"Printing content of histogram "<<fName<<endl;
222 for(Int_t i=0; i<fNcells; i++)
224 if(GetBinContent(i)==0) continue;
225 cout<<"Bin "<<i<<": "<<GetBinContent(i)<<endl;