StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHbtRoot1DCF.cc
1 /***************************************************************************
2  *
3  *
4  *
5  * Author: Laurent Conin, Fabrice Retiere, Subatech, France
6  ***************************************************************************
7  *
8  * Description : implementation of Root1DCF
9  *
10  ***************************************************************************
11  *
12  *
13  *
14  ***************************************************************************/
15 
16 #include "StHbtMaker/Base/StHbtRoot1DCF.hh"
17 #include <Stsstream.h>
18 #include <Stiostream.h>
19 
20 #ifdef __ROOT__
21 ClassImp(StHbtRoot1DCF)
22 #endif
23 //____________________________
24 StHbtRoot1DCF::StHbtRoot1DCF(
25  char* aHTitle, int aHNBins, double aHLo, double aHHi)
26  : StHbtCorrFctn(),StHbtNamed(),mHLo(aHLo),mHHi(aHHi)
27 {
28  StHbtNamed::SetName(aHTitle);
29  char* tName=new char[strlen(GetName())+4];
30  strcpy(tName+3,GetName());
31 
32  memcpy(tName,"Num",3);
33  mNumerator = new StHbt1DHisto(tName,GetName(),aHNBins,mHLo,mHHi);
34 
35  memcpy(tName,"Den",3);
36  mDenominator = new StHbt1DHisto(tName,GetName(),aHNBins,mHLo,mHHi);
37 
38  memcpy(tName,"Rat",3);
39  mRatio = new StHbt1DHisto(tName,GetName(),aHNBins,mHLo,mHHi);
40 
41  delete [] tName;
42  mNumerator->Sumw2();
43  mDenominator->Sumw2();
44  mRatio->Sumw2();
45 }
46 
47 StHbtRoot1DCF::StHbtRoot1DCF(const StHbtRoot1DCF& cf):
48 StHbtNamed(cf),mHLo(cf.mHLo),mHHi(cf.mHHi)
49  {
50  mNumerator=new StHbt1DHisto(*(cf.mNumerator));
51  mDenominator=new StHbt1DHisto(*(cf.mDenominator));
52  mRatio=new StHbt1DHisto(*(cf.mRatio));
53 }
54 
55 
56 //____________________________
57 StHbtRoot1DCF::~StHbtRoot1DCF(){
58  delete mNumerator;
59  delete mDenominator;
60  delete mRatio;
61 }
62 
63 void StHbtRoot1DCF::SetName( const char* aName) {
64 StHbtNamed::SetName(aName);
65 int tLen=strlen(GetName());
66 
67 char* tHName=new char[tLen+4];
68 memcpy(tHName+3,GetName(),tLen+1);
69 
70 memcpy(tHName,"Num",3);
71 mNumerator->SetTitle(GetName());
72 mNumerator->SetName(tHName);
73 
74 memcpy(tHName,"Den",3);
75 mDenominator->SetTitle(GetName());
76 mDenominator->SetName(tHName);
77 
78 memcpy(tHName,"Rat",3);
79 mRatio->SetTitle(GetName());
80 mRatio->SetName(tHName);
81 
82 delete [] tHName;
83 }
84 
85 
86 //_________________________
87 void StHbtRoot1DCF::Finish(){
88  mRatio->Divide(mNumerator,mDenominator,1.0,1.0);
89 
90  if ((int)mNumerator->GetEntries()==(int)mDenominator->GetEntries()){
91  // This CF is a Theoretical one : error mus be reprocessed
92  int i;
93  int tNcell=mRatio->GetNbinsX()*mRatio->GetNbinsY()*mRatio->GetNbinsZ();
94  for(i=0;i<tNcell;i++){
95  if (mDenominator->GetBinContent(i)) {
96  mRatio->SetBinError(i,
97  ::sqrt((::pow(mNumerator->GetBinError(i),2)/mDenominator->GetBinContent(i)-
98  ::pow(mRatio->GetBinContent(i),2))/mDenominator->GetBinContent(i)));
99  } else {
100  mRatio->SetBinError(i,0.);
101  }
102  }
103  }
104 }
105 
106 //____________________________
107 StHbtString StHbtRoot1DCF::Report(){
108  std::ostringstream tStr;
109  tStr << GetName() << " Correlation Function Report:"<< endl;
110  tStr << "Number of entries in numerator: " << mNumerator->GetEntries() << endl;;
111  tStr << "Number of entries in denominator: " << mDenominator->GetEntries() << endl;
112  StHbtString returnThis = tStr.str();
113  return returnThis;
114 }