PlottI
 All Classes Files Functions Variables Enumerations Enumerator Pages
functionality.h
Go to the documentation of this file.
1 
2 // ----------------------------------------------------------------------------
3 //
4 // ADDITIONAL FUNCTIONALITY
5 //
6 // ----------------------------------------------------------------------------
7 
10 #define FUNC_H
11 
12 template <class AO>
13 Int_t GetXfirstFilledBin(AO* hst){
14 
18  Int_t bin;
19 
20  for (bin = 0; bin < hst->GetNbinsX(); bin++){
21  if (hst->GetBinContent(bin) > 0) break;
22  }
23 
24  return (bin < hst->GetNbinsX()) ? bin : 0;
25 
26 }
27 
28 template <class AO>
29 Int_t GetXlastFilledBin(AO* hst){
30 
34  Int_t bin;
35 
36  for (bin = hst->GetNbinsX(); bin > 0; bin--){
37  if (hst->GetBinContent(bin) > 0) break;
38  }
39 
40  return (bin > 0) ? bin : hst->GetNbinsX();
41 
42 }
43 
44 void CleanUpHistogram(TH1* hist, Double_t factor){
45 
51  if (!hist){
52  std::cout << "\033[1;31mERROR:\033[0m histogram to be cleaned up does not exist!" << std::endl;
53  return;
54  }
55 
56  Int_t cutoff = hist->GetNbinsX();
57  Float_t range = TMath::Abs(hist->GetMaximum() - hist->GetMinimum());
58 
59  for (Int_t bin = 0; bin <= cutoff; bin++){
60 
61  Float_t error = 2*hist->GetBinError(bin);
62  if (error/range >= factor) cutoff = bin;
63 
64  }
65 
66  for (Int_t bin = cutoff; bin < hist->GetNbinsX(); bin++){
67 
68  hist->SetBinContent(bin, 0);
69  hist->SetBinError(bin, 0);
70 
71  }
72 
73 }
void CleanUpHistogram(TH1 *hist, Double_t factor)
Definition: functionality.h:44
Int_t GetXfirstFilledBin(AO *hst)
Definition: functionality.h:13
Int_t GetXlastFilledBin(AO *hst)
Definition: functionality.h:29