13 #include "StHbtMaker/CorrFctn/YKPLongitudinal.h"
21 YKPLongitudinal::YKPLongitudinal( TString ctype, TString frame ,
22 const int& nbins,
const float& QLo,
const float& QHi,
23 const int& nKtbins,
const double& ktMin,
const double& ktMax,
24 const int& nYbins,
const double& YMin,
const double& YMax,
25 const int& nbinsQINV,
const float& QLoQINV ,
const float& QHiQINV )
28 if ( !ctype.CompareTo(
"YKP") || !ctype.CompareTo(
"BP") )
31 cout <<
"correlation function set to :" << ctype << endl ;
35 cout <<
"Error: correlationfunction didn't fit BP or YKP -> YKP used !\n" ;
40 if ( !frame.CompareTo(
"LCMS") || !frame.CompareTo(
"CMS") || !frame.CompareTo(
"PRF"))
43 cout <<
"frame set to :" << frame << endl ;
47 cout <<
"Error: frame choice didn't fit LCMS,CMS or PRF -> LCMS used !\n" ;
52 mNumberKtBins = nKtbins ;
53 mNumberYBins = nYbins ;
56 mNumberBins = mNumberKtBins * mNumberYBins ;
62 mNumerator =
new StHbt3DHisto[mNumberBins] ;
63 mDenominator =
new StHbt3DHisto[mNumberBins] ;
64 mRatio =
new StHbt3DHisto[mNumberBins] ;
72 char TitQinvNum[100] ;
73 char TitQinvDen[100] ;
74 char TitQinvRatio[100] ;
76 char xAxisTitle[100] ;
77 char yAxisTitle[100] ;
78 char zAxisTitle[100] ;
81 sprintf(xAxisTitle,
"qLong") ;
82 sprintf(yAxisTitle,
"qPerp") ;
83 sprintf(zAxisTitle,
"qNull") ;
85 else if (mCtype ==
"BP")
87 sprintf(xAxisTitle,
"qSide") ;
88 sprintf(yAxisTitle,
"qOut") ;
89 sprintf(zAxisTitle,
"qLong") ;
92 for(
int ktindex = 0 ; ktindex < mNumberKtBins ; ktindex++)
94 for(
int yindex = 0 ; yindex < mNumberYBins ; yindex++)
97 sprintf(TitNum,
"NumKt%dY%d",ktindex+1,yindex+1) ;
98 mNumerator[ktindex+yindex*mNumberKtBins].SetName(TitNum);
99 mNumerator[ktindex+yindex*mNumberKtBins].SetTitle(TitNum);
100 mNumerator[ktindex+yindex*mNumberKtBins].SetBins(nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi) ;
101 mNumerator[ktindex+yindex*mNumberKtBins].SetXTitle(xAxisTitle);
102 mNumerator[ktindex+yindex*mNumberKtBins].SetYTitle(yAxisTitle);
103 mNumerator[ktindex+yindex*mNumberKtBins].SetZTitle(zAxisTitle);
105 sprintf(TitDen,
"DenKt%dY%d",ktindex+1,yindex+1) ;
106 mDenominator[ktindex+yindex*mNumberKtBins].SetName(TitDen);
107 mDenominator[ktindex+yindex*mNumberKtBins].SetTitle(TitDen);
108 mDenominator[ktindex+yindex*mNumberKtBins].SetBins(nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi) ;
109 mDenominator[ktindex+yindex*mNumberKtBins].SetXTitle(xAxisTitle);
110 mDenominator[ktindex+yindex*mNumberKtBins].SetYTitle(yAxisTitle);
111 mDenominator[ktindex+yindex*mNumberKtBins].SetZTitle(zAxisTitle);
113 sprintf(TitRat,
"RatKt%dY%d",ktindex+1,yindex+1) ;
114 mRatio[ktindex+yindex*mNumberKtBins].SetName(TitRat);
115 mRatio[ktindex+yindex*mNumberKtBins].SetTitle(TitRat);
116 mRatio[ktindex+yindex*mNumberKtBins].SetBins(nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi) ;
117 mRatio[ktindex+yindex*mNumberKtBins].SetXTitle(xAxisTitle);
118 mRatio[ktindex+yindex*mNumberKtBins].SetYTitle(yAxisTitle);
119 mRatio[ktindex+yindex*mNumberKtBins].SetZTitle(zAxisTitle);
121 sprintf(TitQinvNum,
"QinvNumeratorKt%dY%d",ktindex+1,yindex+1) ;
122 mQinvNumerator[ktindex+yindex*mNumberKtBins].SetName(TitQinvNum);
123 mQinvNumerator[ktindex+yindex*mNumberKtBins].SetTitle(TitQinvNum);
124 mQinvNumerator[ktindex+yindex*mNumberKtBins].SetBins(nbinsQINV,QLoQINV,QHiQINV) ;
125 mQinvNumerator[ktindex+yindex*mNumberKtBins].SetXTitle(
"qInv");
127 sprintf(TitQinvDen,
"QinvDenominatorKt%dY%d",ktindex+1,yindex+1) ;
128 mQinvDenominator[ktindex+yindex*mNumberKtBins].SetName(TitQinvDen);
129 mQinvDenominator[ktindex+yindex*mNumberKtBins].SetTitle(TitQinvDen);
130 mQinvDenominator[ktindex+yindex*mNumberKtBins].SetBins(nbinsQINV,QLoQINV,QHiQINV) ;
131 mQinvDenominator[ktindex+yindex*mNumberKtBins].SetXTitle(
"qInv");
133 sprintf(TitQinvRatio,
"QinvRatioKt%dY%d",ktindex+1,yindex+1) ;
134 mQinvRatio[ktindex+yindex*mNumberKtBins].SetName(TitQinvRatio);
135 mQinvRatio[ktindex+yindex*mNumberKtBins].SetTitle(TitQinvRatio);
136 mQinvRatio[ktindex+yindex*mNumberKtBins].SetBins(nbinsQINV,QLoQINV,QHiQINV) ;
137 mQinvRatio[ktindex+yindex*mNumberKtBins].SetXTitle(
"qInv") ;
139 mNumerator[ktindex+yindex*mNumberKtBins].Sumw2() ;
140 mDenominator[ktindex+yindex*mNumberKtBins].Sumw2() ;
141 mRatio[ktindex+yindex*mNumberKtBins].Sumw2() ;
142 mQinvNumerator[ktindex+yindex*mNumberKtBins].Sumw2() ;
143 mQinvDenominator[ktindex+yindex*mNumberKtBins].Sumw2() ;
144 mQinvRatio[ktindex+yindex*mNumberKtBins].Sumw2() ;
153 mktBinsMin =
new double[mNumberKtBins] ;
154 mktBinsMax =
new double[mNumberKtBins] ;
155 double ktstep = (double)(ktMax-ktMin)/(double) mNumberKtBins ;
156 for(
int ktindex = 0 ; ktindex < mNumberKtBins ; ktindex++ )
158 mktBinsMin[ktindex] = ((double) ktindex) * ktstep + ktMin ;
159 mktBinsMax[ktindex] = ((double) (ktindex+1)) * ktstep + ktMin ;
162 mYBinsMin =
new double[mNumberKtBins] ;
163 mYBinsMax =
new double[mNumberYBins] ;
164 double ystep = (double)(YMax-YMin)/(double) mNumberYBins ;
165 for(
int yindex = 0 ; yindex < mNumberYBins ; yindex++ )
167 mYBinsMin[yindex] = ((double) yindex) * ystep + YMin ;
168 mYBinsMax[yindex] = ((double) (yindex+1)) * ystep + YMin ;
178 mNumRealsNorm =
new unsigned long int [mNumberBins] ;
179 mNumMixedNorm =
new unsigned long int [mNumberBins] ;
180 for(
int index = 0 ; index < mNumberBins ; index++ )
182 mNumRealsNorm[index] = mNumMixedNorm[index] = 0 ;
186 YKPLongitudinal::~YKPLongitudinal()
188 delete [] mNumRealsNorm ;
189 delete [] mNumMixedNorm ;
190 delete [] mNumerator ;
191 delete [] mDenominator ;
193 delete [] mQinvNumerator ;
194 delete [] mQinvDenominator ;
195 delete [] mQinvRatio ;
198 void YKPLongitudinal::Finish()
201 double NumFact,DenFact;
202 for(
int ktindex = 0 ; ktindex < mNumberKtBins ; ktindex++)
204 for(
int yindex = 0 ; yindex < mNumberYBins ; yindex++)
207 if ((mNumRealsNorm[ktindex+yindex*mNumberKtBins] !=0) && (mNumMixedNorm[ktindex+yindex*mNumberKtBins] !=0))
209 NumFact = double(mNumRealsNorm[ktindex+yindex*mNumberKtBins]) ;
210 DenFact = double(mNumMixedNorm[ktindex+yindex*mNumberKtBins]) ;
211 cout <<
" Normalizing with Num/Denom = norm : " << NumFact <<
"\t" << DenFact <<
"\t" << NumFact/DenFact
212 <<
" for kt bin : " << ktindex <<
" y bin : " << yindex << endl ;
217 cout <<
"Warning! - no normalization possible ..." << endl;
222 mRatio[ktindex+yindex*mNumberKtBins].Divide(&mNumerator[ktindex+yindex*mNumberKtBins],
223 &mDenominator[ktindex+yindex*mNumberKtBins],DenFact,NumFact) ;
226 mQinvRatio[ktindex+yindex*mNumberKtBins].Divide(&mQinvNumerator[ktindex+yindex*mNumberKtBins],
227 &mQinvDenominator[ktindex+yindex*mNumberKtBins]) ;
232 StHbtString YKPLongitudinal::Report()
236 int mNumeratorEntriesAll = 0 ;
237 int mDenominatorEntriesAll = 0 ;
238 int mRatioEntriesAll = 0 ;
239 int mNumRealsNormAll = 0 ;
240 int mNumMixedNormAll = 0 ;
242 for(
int ktindex = 0 ; ktindex < mNumberKtBins ; ktindex++)
244 for(
int yindex = 0 ; yindex < mNumberYBins ; yindex++)
246 mNumeratorEntriesAll += (int)mNumerator[ktindex+yindex*mNumberKtBins].GetEntries() ;
247 mDenominatorEntriesAll += (int)mDenominator[ktindex+yindex*mNumberKtBins].GetEntries() ;
248 mRatioEntriesAll += (int)mRatio[ktindex+yindex*mNumberKtBins].GetEntries() ;
249 mNumRealsNormAll += mNumRealsNorm[ktindex+yindex*mNumberKtBins] ;
250 mNumMixedNormAll += mNumMixedNorm[ktindex+yindex*mNumberKtBins] ;
254 string stemp =
"YKP Function Report:\n";
256 sprintf(ctemp,
"Number of entries in numerator in all %d histos:\t%d\n",mNumberBins,mNumeratorEntriesAll);
258 sprintf(ctemp,
"Number of entries in denominator in all %d histos:\t%d\n",mNumberBins,mDenominatorEntriesAll);
260 sprintf(ctemp,
"Number of entries in ratio in all %d histos:\t%d\n",mNumberBins,mRatioEntriesAll);
262 sprintf(ctemp,
"Normalization region in Qinv was:\t%E\t%E\n",mQinvNormLo,mQinvNormHi);
264 sprintf(ctemp,
"Number of pairs in Normalization region was:\n");
266 sprintf(ctemp,
"In numerator:\t%u\t In denominator:\t%u\n",mNumRealsNormAll,mNumMixedNormAll);
270 float radius = mCorrection->GetRadius();
271 sprintf(ctemp,
"Coulomb correction used radius of\t%E\n",radius) ;
275 sprintf(ctemp,
"No Coulomb Correction applied to this CorrFctn\n") ;
280 StHbtString returnThis = stemp ;
284 void YKPLongitudinal::AddRealPair(
const StHbtPair* pair)
287 double mKt = pair->kT() ;
288 double mRap = pair->rap() ;
289 double mQinv = fabs(pair->qInv()) ;
291 for(
int ktindex = 0 ; ktindex < mNumberKtBins ; ktindex++)
293 if( mKt >= mktBinsMin[ktindex] && mKt < mktBinsMax[ktindex] )
295 for(
int yindex = 0 ; yindex < mNumberYBins ; yindex++)
297 if( mRap >= mYBinsMin[yindex] && mRap < mYBinsMax[yindex] )
300 if ((mQinv < mQinvNormHi) && (mQinv > mQinvNormLo)) mNumRealsNorm[ktindex+yindex*mNumberKtBins]++;
302 mQinvNumerator[ktindex+yindex*mNumberKtBins].Fill(mQinv) ;
306 double qlong, qperp, q0 ;
307 if(mFrame ==
"LCMS") { pair->qYKPLCMS(qlong,qperp,q0) ;}
308 else if(mFrame ==
"CMS") { pair->qYKPCMS(qlong,qperp,q0) ;}
309 else if(mFrame ==
"PRF") { pair->qYKPPF(qlong,qperp,q0) ;}
311 mNumerator[ktindex+yindex*mNumberKtBins].Fill(qlong,qperp,q0) ;
313 else if (mCtype ==
"BP")
315 double qside, qout, qlong;
316 if(mFrame ==
"LCMS") { qside = pair->qSideCMS(); qout = pair->qOutCMS(); qlong = pair->qLongCMS(); }
317 else if(mFrame ==
"CMS") { qside = pair->qSideBf(); qout = pair->qOutBf(); qlong = pair->qLongBf(); }
318 else if(mFrame ==
"PRF") { qside = pair->qSidePf(); qout = pair->qOutPf(); qlong = pair->qLongPf(); }
320 mNumerator[ktindex+yindex*mNumberKtBins].Fill(fabs(qside),fabs(qout),fabs(qlong)) ;
332 void YKPLongitudinal::AddMixedPair(
const StHbtPair* pair)
335 double mKt = pair->kT() ;
336 double mRap = pair->rap() ;
337 double mQinv = fabs(pair->qInv());
342 weight = mCorrection->CoulombCorrect(pair);
346 for(
int ktindex = 0 ; ktindex < mNumberKtBins ; ktindex++)
348 if( mKt >= mktBinsMin[ktindex] && mKt < mktBinsMax[ktindex] )
350 for(
int yindex = 0 ; yindex < mNumberYBins ; yindex++)
352 if( mRap >= mYBinsMin[yindex] && mRap < mYBinsMax[yindex] )
355 if ((mQinv < mQinvNormHi) && (mQinv > mQinvNormLo)) mNumMixedNorm[ktindex+yindex*mNumberKtBins]++;
357 mQinvDenominator[ktindex+yindex*mNumberKtBins].Fill(mQinv,weight) ;
362 double qlong, qperp, q0 ;
363 if(mFrame ==
"LCMS") { pair->qYKPLCMS(qlong,qperp,q0) ;}
364 else if(mFrame ==
"CMS") { pair->qYKPCMS(qlong,qperp,q0) ;}
365 else if(mFrame ==
"PRF") { pair->qYKPPF(qlong,qperp,q0) ;}
367 mDenominator[ktindex+yindex*mNumberKtBins].Fill(qlong,qperp,q0,weight) ;
369 else if (mCtype ==
"BP")
371 double qside, qout, qlong;
372 if(mFrame ==
"LCMS") { qside = pair->qSideCMS(); qout = pair->qOutCMS(); qlong = pair->qLongCMS(); }
373 else if(mFrame ==
"CMS") { qside = pair->qSideBf(); qout = pair->qOutBf(); qlong = pair->qLongBf(); }
374 else if(mFrame ==
"PRF") { qside = pair->qSidePf(); qout = pair->qOutPf(); qlong = pair->qLongPf(); }
376 mDenominator[ktindex+yindex*mNumberKtBins].Fill(fabs(qside),fabs(qout),fabs(qlong),weight) ;