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