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
21 ClassImp(AliL3HistogramAdaptive)
23 AliL3HistogramAdaptive::AliL3HistogramAdaptive() : AliL3Histogram()
29 AliL3HistogramAdaptive::AliL3HistogramAdaptive(Char_t *name,Double_t minpt,Double_t maxpt,Double_t ptres,
30 Int_t nybins,Double_t ymin,Double_t ymax)
35 fXmin = -1*AliL3Transform::GetBFact()*AliL3Transform::GetBField()/minpt;
36 fXmax = AliL3Transform::GetBFact()*AliL3Transform::GetBField()/minpt;
40 fNxbins = InitPtBins();
41 //cout<<"Setting "<<fNxbins<<" bins on x"<<endl;
50 fNcells = (fNxbins+2)*(fNybins+2);
53 fContent = new Int_t[fNcells];
57 AliL3HistogramAdaptive::~AliL3HistogramAdaptive()
62 Int_t AliL3HistogramAdaptive::InitPtBins()
65 Double_t pt = fMinPt,delta_pt,local_pt;
72 delta_pt = fPtres*local_pt;
75 //cout<<"Setting "<<bin<<" at step "<<local_pt<<" "<<pt<<" interval "<<delta_pt<<endl;
78 return (bin+1)*2; //Both negative and positive kappa.
82 void AliL3HistogramAdaptive::Fill(Double_t x,Double_t y,Int_t weight)
84 Int_t bin = FindBin(x,y);
87 AddBinContent(bin,weight);
91 Int_t AliL3HistogramAdaptive::FindBin(Double_t x,Double_t y)
94 Int_t xbin = FindXbin(x);
95 Int_t ybin = FindYbin(y);
99 return GetBin(xbin,ybin);
102 Int_t AliL3HistogramAdaptive::FindXbin(Double_t x)
105 Double_t ptfind = fabs(AliL3Transform::GetBFact()*AliL3Transform::GetBField()/x);
106 if(ptfind < fMinPt || ptfind > fMaxPt) return -1;
107 //cout<<"Looking for pt "<<ptfind<<endl;
108 Double_t pt = fMinPt;
109 Double_t delta_pt,local_pt;
114 delta_pt = fPtres*local_pt;
117 if(ptfind >= local_pt && ptfind < pt)
119 // cout<<"Found in range "<<local_pt<<" "<<pt<<endl;
125 cerr<<"AliL3HistogramAdaptive::FindXbin : Bin out of range : "<<bin<<endl;
127 //cout<<"Found xbin "<<bin<<" and x is "<<x<<endl;
130 // cout<<"returning xbin "<<bin<<endl;
134 return fNxbins - 1 - bin;
137 Int_t AliL3HistogramAdaptive::FindYbin(Double_t y)
139 if(y < fYmin || y > fYmax)
142 return 1 + (Int_t)(fNybins*(y-fYmin)/(fYmax-fYmin));
146 Double_t AliL3HistogramAdaptive::GetBinCenterX(Int_t xbin)
148 //cout<<"Looking for bin "<<xbin<<endl;
149 if(xbin < 0 || xbin > fNxbins)
151 cerr<<"AliL3HistogramAdaptive::GetBinCenterX : Xbin out of range "<<xbin<<endl;
154 Double_t pt = fMinPt;
155 Double_t delta_pt=0,local_pt=0;
160 delta_pt = fPtres*local_pt;
162 if(xbin == bin || xbin == fNxbins - 1 - bin)
166 //cout<<"get center at ptinterval "<<local_pt<<" "<<pt;
168 Double_t kappa = AliL3Transform::GetBFact()*AliL3Transform::GetBField()/(local_pt + 0.5*delta_pt);
169 //cout<<" found pt "<<local_pt+delta_pt*0.5<<" kappa "<<kappa<<" xbin "<<xbin<<" fNxbins/2-1 "<<fNxbins/2-1<<endl;
176 Double_t AliL3HistogramAdaptive::GetBinCenterY(Int_t ybin)
179 Double_t binwidth = (fYmax - fYmin) / fNybins;
180 return fYmin + (ybin-1) * binwidth + 0.5*binwidth;
184 void AliL3HistogramAdaptive::Draw(Char_t *option)
192 for(Int_t i=0; i<fNxbins; i++)
194 kappa = GetBinCenterX(i);
195 for(Int_t j=0; j<fNybins; j++)
197 psi = GetBinCenterY(j);
199 content = GetBinContent(bin);
200 fRootHisto->Fill(kappa,psi,content);
203 fRootHisto->Draw(option);
206 cerr<<"AliL3HistogramAdaptive::Draw : You need to compile with ROOT in order to draw histogram"<<endl;
209 void AliL3HistogramAdaptive::Print()
211 cout<<"Printing content of histogram "<<fName<<endl;
212 for(Int_t i=0; i<fNcells; i++)
214 if(GetBinContent(i)==0) continue;
215 cout<<"Bin "<<i<<": "<<GetBinContent(i)<<endl;