16 #include "StHbtMaker/Base/StHbtRoot3DCF.hh"
23 StHbtRoot3DCF::StHbtRoot3DCF(
24 char* aHTitle,
int aNBinsX,
double aHLoX,
double aHHiX,
25 int aNBinsY,
double aHLoY,
double aHHiY,
26 int aNBinsZ,
double aHLoZ,
double aHHiZ)
31 StHbtNamed::SetName(aHTitle);
32 char* tName=
new char[strlen(GetName())+4];
33 strcpy(tName+3,GetName());
35 memcpy(tName,
"Num",3);
36 mNumerator =
new StHbt3DHisto(tName,GetName(),aNBinsX,aHLoX,aHHiX,aNBinsY,mHLoY,mHHiY,aNBinsZ,mHLoZ,mHHiZ);
38 memcpy(tName,
"Den",3);
39 mDenominator =
new StHbt3DHisto(tName,GetName(),aNBinsX,mHLo,mHHi,aNBinsY,mHLoY,mHHiY,aNBinsZ,mHLoZ,mHHiZ);
41 memcpy(tName,
"Rat",3);
42 mRatio =
new StHbt3DHisto(tName,GetName(),aNBinsX,mHLo,mHHi,aNBinsY,mHLoY,mHHiY,aNBinsZ,mHLoZ,mHHiZ);
46 mDenominator->Sumw2();
50 :
StHbtNamed(cf),mHLo(cf.mHLo),mHHi(cf.mHHi),mHLoY(cf.mHLoY),mHHiY(cf.mHHiY),mHLoZ(cf.mHLoZ),mHHiZ(cf.mHHiZ) {
52 mNumerator =
new StHbt3DHisto(*(cf.mNumerator));
53 mDenominator =
new StHbt3DHisto(*(cf.mDenominator));
54 mRatio =
new StHbt3DHisto(*(cf.mRatio));
60 StHbtRoot3DCF::~StHbtRoot3DCF(){
67 void StHbtRoot3DCF::SetName(
const char* aName) {
68 StHbtNamed::SetName(aName);
69 int tLen=strlen(GetName());
71 char* tHName=
new char[tLen+4];
72 memcpy(tHName+3,GetName(),tLen+1);
74 memcpy(tHName,
"Num",3);
75 mNumerator->SetTitle(GetName());
76 mNumerator->SetName(tHName);
78 memcpy(tHName,
"Den",3);
79 mDenominator->SetTitle(GetName());
80 mDenominator->SetName(tHName);
82 memcpy(tHName,
"Rat",3);
83 mRatio->SetTitle(GetName());
84 mRatio->SetName(tHName);
90 void StHbtRoot3DCF::Finish(){
91 mRatio->Divide(mNumerator,mDenominator,1.0,1.0);
93 if ((
int)mNumerator->GetEntries()==(int)mDenominator->GetEntries()){
96 int tNcell=mRatio->GetNbinsX()*mRatio->GetNbinsY()*mRatio->GetNbinsZ();
97 for(i=0;i<tNcell;i++){
98 if (mDenominator->GetBinContent(i)) {
99 mRatio->SetBinError(i,
100 ::sqrt((::pow(mNumerator->GetBinError(i),2)/mDenominator->GetBinContent(i)-
101 ::pow(mRatio->GetBinContent(i),2))/mDenominator->GetBinContent(i)));
103 mRatio->SetBinError(i,0.);
110 StHbtString StHbtRoot3DCF::Report(){
111 std::ostringstream tStr;
112 tStr << GetName() <<
" Correlation Function Report:"<< endl;
113 tStr <<
"Number of entries in numerator: " << mNumerator->GetEntries() << endl;;
114 tStr <<
"Number of entries in denominator: " << mDenominator->GetEntries() << endl;
115 StHbtString returnThis = tStr.str();