11 #include "dProjector.h"
18 #define __ABS__(x) (x>0) ? x : -x
22 dProjector::dProjector(
dFitter3d* dFitter)
25 mRatio = dFitter->Ratio() ;
30 mRatio = (TH3D*) (dFitter->Numerator())->Clone() ;
31 mRatio->SetName(
"ratio") ;
32 mRatio->Scale(1.0/dFitter->Norm()) ;
33 mRatio->Divide(dFitter->Denominator()) ;
37 TMinuit* tMinuit = dFitter->getMinuit() ;
39 mFitParameters =
new double[5] ;
40 cout <<
" used fit parameters : " <<
"\t" ;
41 for(
int index = 0 ; index < 5 ; index++ )
45 tMinuit->GetParameter(index, value, error) ;
46 mFitParameters[index] = value ;
47 cout << value <<
"\t" ;
52 dProjector::~dProjector()
54 delete [] mFitParameters ;
57 TH1D* dProjector::get1dProjection(TString axis,
double xmin,
double xmax,
double ymin,
double ymax,
double zmin,
double zmax)
60 int xminBin = mRatio->GetXaxis()->FindFixBin(xmin) ;
61 int xmaxBin = mRatio->GetXaxis()->FindFixBin(xmax) ;
62 int yminBin = mRatio->GetYaxis()->FindFixBin(ymin) ;
63 int ymaxBin = mRatio->GetYaxis()->FindFixBin(ymax) ;
64 int zminBin = mRatio->GetZaxis()->FindFixBin(zmin) ;
65 int zmaxBin = mRatio->GetZaxis()->FindFixBin(zmax) ;
71 char* axistitle =
new char[20] ;
72 if (axis ==
"x") { proNbins = __ABS__(xmaxBin-xminBin)+1 ; proMin = xmin ; proMax = xmax ; strcpy(axistitle,mRatio->GetXaxis()->GetTitle()) ; }
73 else if (axis ==
"y") { proNbins = __ABS__(ymaxBin-yminBin)+1 ; proMin = ymin ; proMax = ymax ; strcpy(axistitle,mRatio->GetYaxis()->GetTitle()) ; }
74 else if (axis ==
"z") { proNbins = __ABS__(zmaxBin-zminBin)+1 ; proMin = zmin ; proMax = zmax ; strcpy(axistitle,mRatio->GetZaxis()->GetTitle()) ; }
75 else { cout <<
"Wrong axis in projector, this should not happen ! "<< endl ;
return 0; } ;
78 int ran = (int) (xmin*ymin*zmin*10000) ;
79 m1dpro =
new TH1D(
"my1dpro",
"my1dpro",proNbins,proMin,proMax) ;
80 m1dpro->SetXTitle(axistitle) ;
81 m1dpro->SetTitle(axistitle) ;
82 char restitle[20] ; sprintf(restitle,
"fit%s%d\n",axis.Data(),ran) ;
83 m1dpro->SetName(restitle) ;
84 m1dfit =
new TH1D(
"my1dfit",
"my1dfit",proNbins,proMin,proMax) ;
85 char fittitle[20] ; sprintf(fittitle,
"fit%s%d\n",axis.Data(),ran) ;
86 m1dfit->SetName(fittitle);
87 m1dfit->SetLineColor(2) ;
88 m1dfit->SetLineStyle(2) ;
89 m1dfit->SetLineWidth(5) ;
90 m1dnor =
new TH1D(
"my1dnor",
"my1dnor",proNbins,proMin,proMax) ;
91 char normtitle[20] ; sprintf(normtitle,
"norm%s%d\n",axis.Data(),ran) ;
92 m1dnor->SetName(normtitle);
95 for(
int indexX = xminBin ; indexX <= xmaxBin ; indexX++)
97 for(
int indexY = yminBin ; indexY <= ymaxBin ; indexY++)
99 for(
int indexZ = zminBin ; indexZ <= zmaxBin ; indexZ++)
102 double cellcontent = mRatio->GetBinContent(indexX,indexY,indexZ) ;
104 TVector3 position(mRatio->GetXaxis()->GetBinCenter(indexX),
105 mRatio->GetYaxis()->GetBinCenter(indexY),
106 mRatio->GetZaxis()->GetBinCenter(indexZ));
107 double cellContentFromFit = mFitter->ykpCorrelationFunction(position,mFitParameters) ;
112 if (axis ==
"x") { proBin = m1dpro->GetXaxis()->FindFixBin(mRatio->GetXaxis()->GetBinCenter(indexX)); }
113 else if (axis ==
"y") { proBin = m1dpro->GetXaxis()->FindFixBin(mRatio->GetYaxis()->GetBinCenter(indexY)); }
114 else if (axis ==
"z") { proBin = m1dpro->GetXaxis()->FindFixBin(mRatio->GetZaxis()->GetBinCenter(indexZ)); }
116 if(cellcontent>0.5 && cellcontent <1.5)
118 m1dpro->AddBinContent(proBin,cellcontent) ;
119 m1dfit->AddBinContent(proBin,cellContentFromFit) ;
121 if (axis ==
"z" && proBin<10) cout << proBin <<
" " ;
123 m1dnor->AddBinContent(proBin,1.0) ;
129 m1dpro->Divide(m1dnor) ;
130 m1dfit->Divide(m1dnor) ;
136 TH2D* dProjector::get2dProjection(TString axis,
double xmin,
double xmax,
double ymin,
double ymax,
double zmin,
double zmax)
139 int xminBin = mRatio->GetXaxis()->FindFixBin(xmin) ;
140 int xmaxBin = mRatio->GetXaxis()->FindFixBin(xmax) ;
141 int yminBin = mRatio->GetYaxis()->FindFixBin(ymin) ;
142 int ymaxBin = mRatio->GetYaxis()->FindFixBin(ymax) ;
143 int zminBin = mRatio->GetZaxis()->FindFixBin(zmin) ;
144 int zmaxBin = mRatio->GetZaxis()->FindFixBin(zmax) ;
148 double proMinX = 0.0 ;
149 double proMaxX = 0.0 ;
150 char* axistitleX =
new char[20] ;
152 double proMinY = 0.0 ;
153 double proMaxY = 0.0 ;
154 char* axistitleY =
new char[20] ;
158 proNbinsX = __ABS__(ymaxBin-yminBin)+1 ; proMinX = ymin ; proMaxX = ymax ; strcpy(axistitleX,mRatio->GetYaxis()->GetTitle()) ;
159 proNbinsY = __ABS__(zmaxBin-zminBin)+1 ; proMinY = zmin ; proMaxY = zmax ; strcpy(axistitleY,mRatio->GetZaxis()->GetTitle()) ;
161 else if (axis ==
"y")
163 proNbinsX = __ABS__(zmaxBin-zminBin)+1 ; proMinX = zmin ; proMaxX = zmax ; strcpy(axistitleX,mRatio->GetZaxis()->GetTitle()) ;
164 proNbinsY = __ABS__(xmaxBin-xminBin)+1 ; proMinY = xmin ; proMaxY = xmax ; strcpy(axistitleY,mRatio->GetXaxis()->GetTitle()) ;
166 else if (axis ==
"z")
168 proNbinsX = __ABS__(xmaxBin-xminBin)+1 ; proMinX = xmin ; proMaxX = xmax ; strcpy(axistitleX,mRatio->GetXaxis()->GetTitle()) ;
169 proNbinsY = __ABS__(ymaxBin-yminBin)+1 ; proMinY = ymin ; proMaxY = ymax ; strcpy(axistitleY,mRatio->GetYaxis()->GetTitle()) ;
172 else { cout <<
"Wrong axis in projector, this should not happen ! "<< endl ;
return 0; } ;
175 int ran = (int) (xmin*ymin*zmin*10000) ;
177 m2dpro =
new TH2D(
"my2dpro",
"my2dpro",proNbinsX,proMinX,proMaxX,proNbinsY,proMinY,proMaxY) ;
178 char resName[20] ; sprintf(resName,
"res%s%d\n",axis.Data(),ran) ; m2dpro->SetName(resName) ;
179 m2dpro->SetXTitle(axistitleX) ;
180 m2dpro->SetYTitle(axistitleY) ;
181 char restitle[20] ; sprintf(restitle,
"%s\n",axis.Data()) ;m2dpro->SetTitle(restitle) ;
183 m2dfit =
new TH2D(
"my2dfit",
"my2dfit",proNbinsX,proMinX,proMaxX,proNbinsY,proMinY,proMaxY) ;
184 char fittitle[20] ; sprintf(fittitle,
"fit%s%d\n",axis.Data(),ran) ; m2dfit->SetName(fittitle) ;
186 m2dnor =
new TH2D(
"my2dnor",
"my2dnor",proNbinsX,proMinX,proMaxX,proNbinsY,proMinY,proMaxY) ;
187 char normtitle[20] ; sprintf(normtitle,
"norm%s%d\n",axis.Data(),ran) ; m2dnor->SetName(normtitle) ;
190 for(
int indexX = xminBin ; indexX <= xmaxBin ; indexX++)
192 for(
int indexY = yminBin ; indexY <= ymaxBin ; indexY++)
194 for(
int indexZ = zminBin ; indexZ <= zmaxBin ; indexZ++)
197 double cellcontent = mRatio->GetBinContent(indexX,indexY,indexZ) ;
199 TVector3 position(mRatio->GetXaxis()->GetBinCenter(indexX),
200 mRatio->GetYaxis()->GetBinCenter(indexY),
201 mRatio->GetZaxis()->GetBinCenter(indexZ));
202 double cellContentFromFit = mFitter->ykpCorrelationFunction(position,mFitParameters) ;
206 double proX = 100000.0 ;
207 double proY = 100000.0 ;
210 proX = mRatio->GetYaxis()->GetBinCenter(indexY) ;
211 proY = mRatio->GetZaxis()->GetBinCenter(indexZ) ;
213 else if (axis ==
"y")
215 proX = mRatio->GetZaxis()->GetBinCenter(indexZ) ;
216 proY = mRatio->GetXaxis()->GetBinCenter(indexX) ;
218 else if (axis ==
"z")
220 proX = mRatio->GetXaxis()->GetBinCenter(indexX) ;
221 proY = mRatio->GetYaxis()->GetBinCenter(indexY) ;
224 if(cellcontent>0.5 && cellcontent <1.5)
227 m2dpro->Fill(proX,proY,cellcontent) ;
228 m2dfit->Fill(proX,proY,cellContentFromFit) ;
230 m2dnor->Fill(proX,proY,1.0) ;
236 m2dpro->Divide(m2dnor) ;
237 m2dfit->Divide(m2dnor) ;