1 #include "StHbtMaker/CorrFctn/QinvEbyECorrFctn.h"
8 QinvEbyECorrFctn::QinvEbyECorrFctn(
char* title,
const int& nbins,
const float& QinvLo,
const float& QinvHi){
11 char TitNum[100] =
"Num";
13 mNumerator =
new StHbt1DHisto(TitNum,title,nbins,QinvLo,QinvHi);
16 char TitDen[100] =
"Den";
18 mDenominator =
new StHbt1DHisto(TitDen,title,nbins,QinvLo,QinvHi);
21 char TitRat[100] =
"Rat";
23 mRatio =
new StHbt1DHisto(TitRat,title,nbins,QinvLo,QinvHi);
26 mNumerator->SetDirectory(0);
27 mDenominator->SetDirectory(0);
28 mRatio->SetDirectory(0);
34 char TitIntNum[100] =
"IntNum";
35 strcat(TitIntNum,title);
36 mIntNumerator =
new StHbt1DHisto(TitIntNum,title,nbins,QinvLo,QinvHi);
38 char TitIntDen[100] =
"IntDen";
39 strcat(TitIntDen,title);
40 mIntDenominator =
new StHbt1DHisto(TitIntDen,title,nbins,QinvLo,QinvHi);
42 char TitIntRat[100] =
"IntRat";
43 strcat(TitIntRat,title);
44 mIntRatio =
new StHbt1DHisto(TitIntRat,title,nbins,QinvLo,QinvHi);
48 mThreeFitLambda =
new StHbt1DHisto(
"ThreeFitLambda",
"ThreeFitLambda",100,0,2);
49 mThreeFitRadius =
new StHbt1DHisto(
"ThreeFitRadius",
"ThreeFitRadius",100,0,50);
50 mTwoFitLambda =
new StHbt1DHisto(
"TwoFitLambda",
"TwoFitLambda",100,0,2);
51 mTwoFitRadius =
new StHbt1DHisto(
"TwoFitRadius",
"TwoFitRadius",100,0,50);
52 mRmsByHandMeV =
new StHbt1DHisto(
"RmsByHandMeV",
"RmsByHandMeV",100,0.0,0.2);
53 mRmsByHandFm =
new StHbt1DHisto(
"RmsByHandFm",
"RmsByHandFm",100,0,20);
54 mThreeFitLambda->SetDirectory(0);
55 mThreeFitRadius->SetDirectory(0);
56 mTwoFitLambda->SetDirectory(0);
57 mTwoFitRadius->SetDirectory(0);
58 mRmsByHandMeV->SetDirectory(0);
59 mRmsByHandFm->SetDirectory(0);
66 mDenominator->Sumw2();
73 QinvEbyECorrFctn::~QinvEbyECorrFctn(){
74 delete mThreeFitLambda;
75 delete mThreeFitRadius;
84 delete mIntDenominator;
86 if (mCorrection)
delete mCorrection;
89 void QinvEbyECorrFctn::Finish(){
91 mIntRatio->Divide(mIntNumerator,mIntDenominator,1.0,1.0) ;
95 Three_param_fit( fit3 , mRatio);
96 cout <<
" Inclusive fit : " << fit3.radius << endl ;
100 StHbtString QinvEbyECorrFctn::Report(){
101 string stemp =
"Qinv Correlation Function Report:\n";
103 sprintf(ctemp,
"Number of entries in numerator:\t%E\n",mNumerator->GetEntries());
105 sprintf(ctemp,
"Number of entries in denominator:\t%E\n",mDenominator->GetEntries());
107 sprintf(ctemp,
"Number of entries in ratio:\t%E\n",mRatio->GetEntries());
110 StHbtString returnThis = stemp;
114 void QinvEbyECorrFctn::AddRealPair(
const StHbtPair* pair){
115 mNumerator->Fill( fabs(pair->qInv()) );
118 void QinvEbyECorrFctn::AddMixedPair(
const StHbtPair* pair){
119 mDenominator->Fill( fabs(pair->qInv()) );
122 void QinvEbyECorrFctn::SetCorrection(
const StHbt1DHisto* correc){
126 void QinvEbyECorrFctn::EventBegin(
const StHbtEvent* myev)
130 mDenominator->Reset();
134 void QinvEbyECorrFctn::EventEnd(
const StHbtEvent* myev)
138 if (mDenominator->GetEntries() == 0)
return ;
141 cout <<
"Start ebye." << endl ;
145 mRatio->Divide(mNumerator,mDenominator,1.0,1.0) ;
150 cout <<
"Scale ratio by (integral method) : " << Norm_by_integral(0.1,0.2) << endl ;
151 mRatio->Scale(Norm_by_integral(0.1,0.2)) ;
155 cout <<
"Going to Coulomb correct now..." << endl;
156 mRatio->Divide(mCorrection);
159 cout <<
"NOT Coulomb correcting..." << endl;
163 mIntNumerator->Add(mNumerator);
164 mIntDenominator->Add(mDenominator);
168 double Width_MeV = 0 ;
169 double Width_fm = 0 ;
170 Rms_by_hand(Width_MeV, Width_fm) ;
171 mRmsByHandMeV->Fill(Width_MeV) ;
172 mRmsByHandFm->Fill(Width_fm) ;
175 twoFit fit2 = { 0.,0.,0.,0., 0., 0. };
176 Two_param_fit( fit2 );
177 mTwoFitLambda->Fill( fit2.lambda);
178 mTwoFitRadius->Fill( fit2.radius);
182 mRatio->Divide(mNumerator,mDenominator,1.0,1.0) ;
185 cout <<
"Going to Coulomb correct now for the 3 Fit ..." << endl;
186 mRatio->Divide(mCorrection);
189 cout <<
"NOT Coulomb correcting for the 3 Fit ..." << endl;
191 threeFit fit3 = { 0.2,0.0,0.5,0.0,10.,0., 0., 0. };
192 Three_param_fit( fit3 , mRatio);
193 mThreeFitLambda->Fill( (fit3.lambda*1/(fit3.constant+0.000001)) );
194 mThreeFitRadius->Fill( fit3.radius );
201 cout <<
"Going to Coulomb correct a second time just to see it ..." << endl;
202 mRatio->Divide(mCorrection);
205 cout <<
"NOT Coulomb correcting..." << endl;
208 cout << endl << endl ;
210 cout <<
" lambda=" << fit2.lambda <<
" radius=" << fit2.radius << endl;
211 cout <<
" threeFit: ";
212 cout <<
" lambda=" << (fit3.lambda/(fit3.constant+0.000001)) <<
" radius=" << fit3.radius ;
213 cout <<
" constant :" << fit3.constant << endl;
214 cout <<
" RmsByHand ";
215 cout <<
" Width MeV " << Width_MeV <<
" Width FM " << Width_fm << endl;
217 if (fit3.constant!=0) norm3 = 1/(fit3.constant) ;
219 cout <<
" Norm by integ : " << Norm_by_integral(0.1,0.2) << endl;
220 cout <<
" Norm by line fit : " << Norm_by_fit(0.1,0.2) << endl;
221 cout <<
" Norm by 3d fit : " << norm3 << endl;
223 cout <<
" Scaled by : " << Norm_by_integral(0.1,0.2) << endl;
224 cout << endl << endl ;
247 StHbtTF1* f3param =
new StHbtTF1(
"f3param",
"[0]+[1]*exp(- (x**2) * ([2]**2) / (0.197327**2))",0.0,0.2) ;
248 f3param->SetParNames(
"Normfactor",
"Lambda",
"Rinv") ;
249 f3param->SetParameters(0.2,0.5,10) ;
250 histo->Fit(
"f3param",
"R0") ;
253 fit.constant = histo->GetFunction(
"f3param")->GetParameter(0);
254 fit.lambda = histo->GetFunction(
"f3param")->GetParameter(1);
255 fit.radius = histo->GetFunction(
"f3param")->GetParameter(2);
256 fit.constantErr = histo->GetFunction(
"f3param")->GetParError(0);
257 fit.lambdaErr = histo->GetFunction(
"f3param")->GetParError(1);
258 fit.radiusErr = histo->GetFunction(
"f3param")->GetParError(2);
259 fit.chi2 = histo->GetFunction(
"f3param")->GetChisquare();
260 fit.ndf = histo->GetFunction(
"f3param")->GetNDF() ;
266 void QinvEbyECorrFctn::Two_param_fit(
twoFit& fit) {
270 StHbtTF1* f2param =
new StHbtTF1(
"f2param",
" 1 + [0]*exp(- (x**2) * ([1]**2) / (0.197327**2))",0.0,0.2) ;
271 f2param->SetParNames(
"Lambda",
"Rinv") ;
272 f2param->SetParameters(0.5,10) ;
273 mRatio->Fit(
"f2param",
"R0+") ;
276 fit.lambda = mRatio->GetFunction(
"f2param")->GetParameter(0);
277 fit.radius = mRatio->GetFunction(
"f2param")->GetParameter(1);
278 fit.lambdaErr = mRatio->GetFunction(
"f2param")->GetParError(0);
279 fit.radiusErr = mRatio->GetFunction(
"f2param")->GetParError(1);
280 fit.chi2 = mRatio->GetFunction(
"f2param")->GetChisquare();
281 fit.ndf = mRatio->GetFunction(
"f2param")->GetNDF() ;
287 void QinvEbyECorrFctn::Rms_by_hand(
double& Width_MeV,
double& Width_fm) {
293 for(
int hist_index=1; hist_index <= (int) mRatio->GetNbinsX() ; hist_index++)
295 double x = (double) (mRatio->GetBinCenter(hist_index)) ;
296 double y = (double) (mRatio->GetBinContent(hist_index)) ;
297 sum = sum + x * x * ( y -1 ) ;
298 S_y = S_y + ( y -1 ) ;
303 Width_MeV = ::sqrt(fabs(sum/(S_y))) ;
304 Width_fm = 0.197327/Width_MeV ;
306 cout <<
"Rough rms calculation : " << (double) Width_MeV <<
"\t";
307 cout <<
"Rough rms calculation : " << (double) Width_fm << endl ;
310 void QinvEbyECorrFctn::Fill_ratio_artificial()
316 for(
int i = 1 ; i < mRatio->GetNbinsX() ; i++)
318 double x = (double) (mRatio->GetBinCenter(i));
319 double y = 1 + exp(-(x*x)*(radius*radius)/(0.2*0.2));
326 void QinvEbyECorrFctn::Fill_ratio_artificial_random()
331 double lam = rand()/RAND_MAX;
332 double R = 1 + 10 * rand()/RAND_MAX;
334 for(
int i = 1 ; i < mRatio->GetNbinsX() ; i++)
336 double x = (double) (mRatio->GetBinCenter(i));
337 double y = 1 + lam * exp(-(x*x)*(R*R)/(0.2*0.2));
344 double QinvEbyECorrFctn::Norm_by_integral(
double min_GeV = 0.1,
double max_GeV = 0.2 )
348 int minbin = mDenominator->GetXaxis()->FindFixBin(min_GeV);
349 int maxbin = mDenominator->GetXaxis()->FindFixBin(max_GeV);
350 double numinteg = mNumerator->Integral(minbin,maxbin) ;
351 double denominteg = mDenominator->Integral(minbin,maxbin) ;
355 norm = denominteg / numinteg ;
360 cout <<
"Cannot normlize, because denominator equals 0." << endl ;
365 double QinvEbyECorrFctn::Norm_by_fit(
double min_GeV = 0.1,
double max_GeV = 0.2)
368 StHbtTF1* line =
new StHbtTF1(
"line",
"[0]+[1] * x",min_GeV,max_GeV) ;
369 line->SetParameters(0.3,0.0) ;
370 mRatio->Fit(
"line",
"QR0") ;
374 cout <<
"Fit result line fit, norm : " << mRatio->GetFunction(
"line")->GetParameter(0) <<
" " << mRatio->GetFunction(
"line")->GetParameter(1) << endl ;
378 double a = mRatio->GetFunction(
"line")->GetParameter(0) ;
379 double b = mRatio->GetFunction(
"line")->GetParameter(1) ;
380 double c = (max_GeV+min_GeV)/2 * b + a ;