star-travex
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StiHifyRatiosHistContainer.cxx
Go to the documentation of this file.
2 
3 #include "TH1.h"
4 
5 
6 StiHifyRatiosHistContainer::StiHifyRatiosHistContainer(const char* name, TDirectory* motherDir, Option_t* option) :
7  tvx::HistContainer(name, motherDir, option)
8 {
9 }
10 
11 
12 void StiHifyRatiosHistContainer::CreateRatioHist(const TH1* hNumer, const TH1* hDenom)
13 {
14  if (!hNumer || !hDenom) {
15  Error(__FUNCTION__, "Cannot calculate ratio from non-existing histograms: "
16  "Numerator hist %p / Denumerator hist %p, ", hNumer, hDenom);
17  return;
18  }
19 
20  this->cd();
21 
22  TH1 *myRatio = static_cast<TH1*>(hNumer->Clone());
23 
24  myRatio->SetOption("colz");
25  myRatio->Sumw2();
26  myRatio->Divide(hNumer, hDenom, 1, 1, "B");
27 
28  if (myRatio->GetDimension() == 1)
29  {
30  myRatio->Fit("pol0", "Q"); // Fit a line to the data points
31  }
32 
33  Add(myRatio);
34 }
StiHifyRatiosHistContainer(const char *name, TDirectory *motherDir=0, Option_t *option="")
void CreateRatioHist(const TH1 *hNumer, const TH1 *hDenom)