StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHbtRoot3DCF.cc
1 /***************************************************************************
2  *
3  *
4  *
5  * Author: Laurent Conin, Fabrice Retiere, Subatech, France
6  ***************************************************************************
7  *
8  * Description : implementation on Root3DCF
9  *
10  ***************************************************************************
11  *
12  *
13  *
14  ***************************************************************************/
15 
16 #include "StHbtMaker/Base/StHbtRoot3DCF.hh"
17 #include <Stsstream.h>
18 
19 #ifdef __ROOT__
20 ClassImp(StHbtRoot3DCF)
21 #endif
22 //____________________________
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)
27  : StHbtCorrFctn(),StHbtNamed(),mHLo(aHLoX),mHHi(aHHiX),mHLoY(aHLoY),mHHiY(aHHiY),mHLoZ(aHLoZ),mHHiZ(aHHiZ)
28 
29 {
30 
31  StHbtNamed::SetName(aHTitle);
32  char* tName=new char[strlen(GetName())+4];
33  strcpy(tName+3,GetName());
34 
35  memcpy(tName,"Num",3);
36  mNumerator = new StHbt3DHisto(tName,GetName(),aNBinsX,aHLoX,aHHiX,aNBinsY,mHLoY,mHHiY,aNBinsZ,mHLoZ,mHHiZ);
37 
38  memcpy(tName,"Den",3);
39  mDenominator = new StHbt3DHisto(tName,GetName(),aNBinsX,mHLo,mHHi,aNBinsY,mHLoY,mHHiY,aNBinsZ,mHLoZ,mHHiZ);
40 
41  memcpy(tName,"Rat",3);
42  mRatio = new StHbt3DHisto(tName,GetName(),aNBinsX,mHLo,mHHi,aNBinsY,mHLoY,mHHiY,aNBinsZ,mHLoZ,mHHiZ);
43 
44  delete [] tName;
45  mNumerator->Sumw2();
46  mDenominator->Sumw2();
47  mRatio->Sumw2();
48 }
49 StHbtRoot3DCF::StHbtRoot3DCF(const StHbtRoot3DCF& cf)
50 : StHbtNamed(cf),mHLo(cf.mHLo),mHHi(cf.mHHi),mHLoY(cf.mHLoY),mHHiY(cf.mHHiY),mHLoZ(cf.mHLoZ),mHHiZ(cf.mHHiZ) {
51 
52 mNumerator = new StHbt3DHisto(*(cf.mNumerator));
53 mDenominator = new StHbt3DHisto(*(cf.mDenominator));
54 mRatio = new StHbt3DHisto(*(cf.mRatio));
55 
56 }
57 
58 
59 //____________________________
60 StHbtRoot3DCF::~StHbtRoot3DCF(){
61  delete mNumerator;
62  delete mDenominator;
63  delete mRatio;
64 }
65 
66 
67 void StHbtRoot3DCF::SetName( const char* aName) {
68 StHbtNamed::SetName(aName);
69 int tLen=strlen(GetName());
70 
71 char* tHName=new char[tLen+4];
72 memcpy(tHName+3,GetName(),tLen+1);
73 
74 memcpy(tHName,"Num",3);
75 mNumerator->SetTitle(GetName());
76 mNumerator->SetName(tHName);
77 
78 memcpy(tHName,"Den",3);
79 mDenominator->SetTitle(GetName());
80 mDenominator->SetName(tHName);
81 
82 memcpy(tHName,"Rat",3);
83 mRatio->SetTitle(GetName());
84 mRatio->SetName(tHName);
85 
86 delete [] tHName;
87 }
88 
89 //_________________________
90 void StHbtRoot3DCF::Finish(){
91  mRatio->Divide(mNumerator,mDenominator,1.0,1.0);
92 
93  if ((int)mNumerator->GetEntries()==(int)mDenominator->GetEntries()){
94  // This CF is a Theoretical one : error mus be reprocessed
95  int i;
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)));
102  } else {
103  mRatio->SetBinError(i,0.);
104  }
105  }
106  }
107 }
108 
109 //____________________________
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();
116  return returnThis;
117 }