16 #include "StHbtMaker/Base/StHbtRoot2DCF.hh"
23 StHbtRoot2DCF::StHbtRoot2DCF(
24 char* aHTitle,
int aNBinsX,
double aHLoX,
double aHHiX,
25 int aNBinsY,
double aHLoY,
double aHHiY)
30 StHbtNamed::SetName(aHTitle);
31 char* tName=
new char[strlen(GetName())+4];
32 strcpy(tName+3,GetName());
34 memcpy(tName,
"Num",3);
35 mNumerator =
new StHbt2DHisto(tName,GetName(),aNBinsX,aHLoX,aHHiX,aNBinsY,mHLoY,mHHiY);
37 memcpy(tName,
"Den",3);
38 mDenominator =
new StHbt2DHisto(tName,GetName(),aNBinsX,mHLo,mHHi,aNBinsY,mHLoY,mHHiY);
40 memcpy(tName,
"Rat",3);
41 mRatio =
new StHbt2DHisto(tName,GetName(),aNBinsX,mHLo,mHHi,aNBinsY,mHLoY,mHHiY);
45 mDenominator->Sumw2();
49 :
StHbtNamed(cf),mHLo(cf.mHLo),mHHi(cf.mHHi),mHLoY(cf.mHLoY),mHHiY(cf.mHHiY) {
59 StHbtRoot2DCF::~StHbtRoot2DCF(){
66 void StHbtRoot2DCF::SetName(
const char* aName) {
67 StHbtNamed::SetName(aName);
68 int tLen=strlen(GetName());
70 char* tHName=
new char[tLen+4];
71 memcpy(tHName+3,GetName(),tLen+1);
73 memcpy(tHName,
"Num",3);
74 mNumerator->SetTitle(GetName());
75 mNumerator->SetName(tHName);
77 memcpy(tHName,
"Den",3);
78 mDenominator->SetTitle(GetName());
79 mDenominator->SetName(tHName);
81 memcpy(tHName,
"Rat",3);
82 mRatio->SetTitle(GetName());
83 mRatio->SetName(tHName);
89 void StHbtRoot2DCF::Finish(){
90 mRatio->Divide(mNumerator,mDenominator,1.0,1.0);
92 if ((
int)mNumerator->GetEntries()==(int)mDenominator->GetEntries()){
95 int tNcell=mRatio->GetNbinsX()*mRatio->GetNbinsY()*mRatio->GetNbinsZ();
96 for(i=0;i<tNcell;i++){
97 if (mDenominator->GetBinContent(i)) {
98 mRatio->SetBinError(i,
99 ::sqrt((::pow(mNumerator->GetBinError(i),2)/mDenominator->GetBinContent(i)-
100 ::pow(mRatio->GetBinContent(i),2))/mDenominator->GetBinContent(i)));
102 mRatio->SetBinError(i,0.);
109 StHbtString StHbtRoot2DCF::Report(){
110 std::ostringstream tStr;
111 tStr << GetName() <<
" Correlation Function Report:"<< endl;
112 tStr <<
"Number of entries in numerator: " << mNumerator->GetEntries() << endl;;
113 tStr <<
"Number of entries in denominator: " << mDenominator->GetEntries() << endl;
114 StHbtString returnThis = tStr.str();