StHbtRoot1DCF.cc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /***************************************************************************
  2. *
  3. * $Id:
  4. *
  5. * Author: Laurent Conin, Fabrice Retiere, Subatech, France
  6. ***************************************************************************
  7. *
  8. * Description : implementation of Root1DCF
  9. *
  10. ***************************************************************************
  11. *
  12. * $Log:
  13. *
  14. ***************************************************************************/
  15. #include "StHbtMaker/Base/StHbtRoot1DCF.hh"
  16. #include <Stsstream.h>
  17. #include <Stiostream.h>
  18. #ifdef __ROOT__
  19. ClassImp(StHbtRoot1DCF)
  20. #endif
  21. //____________________________
  22. StHbtRoot1DCF::StHbtRoot1DCF(
  23. char* aHTitle, int aHNBins, double aHLo, double aHHi)
  24. : StHbtCorrFctn(),StHbtNamed(),mHLo(aHLo),mHHi(aHHi)
  25. {
  26. StHbtNamed::SetName(aHTitle);
  27. char* tName=new char[strlen(GetName())+4];
  28. strcpy(tName+3,GetName());
  29. memcpy(tName,"Num",3);
  30. mNumerator = new StHbt1DHisto(tName,GetName(),aHNBins,mHLo,mHHi);
  31. memcpy(tName,"Den",3);
  32. mDenominator = new StHbt1DHisto(tName,GetName(),aHNBins,mHLo,mHHi);
  33. memcpy(tName,"Rat",3);
  34. mRatio = new StHbt1DHisto(tName,GetName(),aHNBins,mHLo,mHHi);
  35. delete [] tName;
  36. mNumerator->Sumw2();
  37. mDenominator->Sumw2();
  38. mRatio->Sumw2();
  39. }
  40. StHbtRoot1DCF::StHbtRoot1DCF(const StHbtRoot1DCF& cf):
  41. StHbtNamed(cf),mHLo(cf.mHLo),mHHi(cf.mHHi)
  42. {
  43. mNumerator=new StHbt1DHisto(*(cf.mNumerator));
  44. mDenominator=new StHbt1DHisto(*(cf.mDenominator));
  45. mRatio=new StHbt1DHisto(*(cf.mRatio));
  46. }
  47. //____________________________
  48. StHbtRoot1DCF::~StHbtRoot1DCF(){
  49. delete mNumerator;
  50. delete mDenominator;
  51. delete mRatio;
  52. }
  53. void StHbtRoot1DCF::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 StHbtRoot1DCF::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 StHbtRoot1DCF::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. }