StHbtRoot3DCF.cc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /***************************************************************************
  2. *
  3. * $Id:
  4. *
  5. * Author: Laurent Conin, Fabrice Retiere, Subatech, France
  6. ***************************************************************************
  7. *
  8. * Description : implementation on Root3DCF
  9. *
  10. ***************************************************************************
  11. *
  12. * $Log:
  13. *
  14. ***************************************************************************/
  15. #include "StHbtMaker/Base/StHbtRoot3DCF.hh"
  16. #include <Stsstream.h>
  17. #ifdef __ROOT__
  18. ClassImp(StHbtRoot3DCF)
  19. #endif
  20. //____________________________
  21. StHbtRoot3DCF::StHbtRoot3DCF(
  22. char* aHTitle, int aNBinsX, double aHLoX, double aHHiX,
  23. int aNBinsY, double aHLoY, double aHHiY,
  24. int aNBinsZ, double aHLoZ, double aHHiZ)
  25. : StHbtCorrFctn(),StHbtNamed(),mHLo(aHLoX),mHHi(aHHiX),mHLoY(aHLoY),mHHiY(aHHiY),mHLoZ(aHLoZ),mHHiZ(aHHiZ)
  26. {
  27. StHbtNamed::SetName(aHTitle);
  28. char* tName=new char[strlen(GetName())+4];
  29. strcpy(tName+3,GetName());
  30. memcpy(tName,"Num",3);
  31. mNumerator = new StHbt3DHisto(tName,GetName(),aNBinsX,aHLoX,aHHiX,aNBinsY,mHLoY,mHHiY,aNBinsZ,mHLoZ,mHHiZ);
  32. memcpy(tName,"Den",3);
  33. mDenominator = new StHbt3DHisto(tName,GetName(),aNBinsX,mHLo,mHHi,aNBinsY,mHLoY,mHHiY,aNBinsZ,mHLoZ,mHHiZ);
  34. memcpy(tName,"Rat",3);
  35. mRatio = new StHbt3DHisto(tName,GetName(),aNBinsX,mHLo,mHHi,aNBinsY,mHLoY,mHHiY,aNBinsZ,mHLoZ,mHHiZ);
  36. delete [] tName;
  37. mNumerator->Sumw2();
  38. mDenominator->Sumw2();
  39. mRatio->Sumw2();
  40. }
  41. StHbtRoot3DCF::StHbtRoot3DCF(const StHbtRoot3DCF& cf)
  42. : StHbtNamed(cf),mHLo(cf.mHLo),mHHi(cf.mHHi),mHLoY(cf.mHLoY),mHHiY(cf.mHHiY),mHLoZ(cf.mHLoZ),mHHiZ(cf.mHHiZ) {
  43. mNumerator = new StHbt3DHisto(*(cf.mNumerator));
  44. mDenominator = new StHbt3DHisto(*(cf.mDenominator));
  45. mRatio = new StHbt3DHisto(*(cf.mRatio));
  46. }
  47. //____________________________
  48. StHbtRoot3DCF::~StHbtRoot3DCF(){
  49. delete mNumerator;
  50. delete mDenominator;
  51. delete mRatio;
  52. }
  53. void StHbtRoot3DCF::SetName( const char* aName) {
  54. StHbtNamed::SetName(aName);
  55. int tLen=strlen(GetName());
  56. char* tHName=new char[tLen+4];
  57. memcpy(tHName+3,GetName(),tLen+1);
  58. memcpy(tHName,"Num",3);
  59. mNumerator->SetTitle(GetName());
  60. mNumerator->SetName(tHName);
  61. memcpy(tHName,"Den",3);
  62. mDenominator->SetTitle(GetName());
  63. mDenominator->SetName(tHName);
  64. memcpy(tHName,"Rat",3);
  65. mRatio->SetTitle(GetName());
  66. mRatio->SetName(tHName);
  67. delete [] tHName;
  68. }
  69. //_________________________
  70. void StHbtRoot3DCF::Finish(){
  71. mRatio->Divide(mNumerator,mDenominator,1.0,1.0);
  72. if ((int)mNumerator->GetEntries()==(int)mDenominator->GetEntries()){
  73. // This CF is a Theoretical one : error mus be reprocessed
  74. int i;
  75. int tNcell=mRatio->GetNbinsX()*mRatio->GetNbinsY()*mRatio->GetNbinsZ();
  76. for(i=0;i<tNcell;i++){
  77. if (mDenominator->GetBinContent(i)) {
  78. mRatio->SetBinError(i,
  79. ::sqrt((::pow(mNumerator->GetBinError(i),2)/mDenominator->GetBinContent(i)-
  80. ::pow(mRatio->GetBinContent(i),2))/mDenominator->GetBinContent(i)));
  81. } else {
  82. mRatio->SetBinError(i,0.);
  83. }
  84. }
  85. }
  86. }
  87. //____________________________
  88. StHbtString StHbtRoot3DCF::Report(){
  89. ostrstream tStr;
  90. tStr << GetName() << " Correlation Function Report:"<< endl;
  91. tStr << "Number of entries in numerator: " << mNumerator->GetEntries() << endl;;
  92. tStr << "Number of entries in denominator: " << mDenominator->GetEntries() << endl;
  93. StHbtString returnThis = tStr.str();
  94. return returnThis;
  95. }