Enumerations | Functions
plotLogicalSpectra.C File Reference

Go to the source code of this file.

Enumerations

enum  type { kNominal, kPlus1Sigma, kMinus1Sigma }
 

Functions

std::vector< double > getNormFactors (TH1D *h, double cutoff)
 
void normaliseBins (TH1D *h, std::vector< double > &norms)
 
void styleHistogram (TH1D *h, type t)
 
void plotLogicalSpectra (bool pm1sigma=false)
 

Enumeration Type Documentation

enum type
Enumerator
kNominal 
kPlus1Sigma 
kMinus1Sigma 

Definition at line 6 of file plotLogicalSpectra.C.

Function Documentation

std::vector<double> getNormFactors ( TH1D *  h,
double  cutoff 
)

Definition at line 12 of file plotLogicalSpectra.C.

References MECModelEnuComparisons::i.

Referenced by plotLogicalSpectra().

12  {
13 
14  std::vector<double> norms;
15  for (int i = 1; i < h->GetNbinsX()+1; ++i){
16  if (h->GetBinContent(i) > cutoff)
17  norms.push_back(0.0005);
18  else
19  norms.push_back(1.0);
20  }
21  return norms;
22 
23 };
void normaliseBins ( TH1D *  h,
std::vector< double > &  norms 
)

Definition at line 25 of file plotLogicalSpectra.C.

References MECModelEnuComparisons::i.

Referenced by plotLogicalSpectra().

25  {
26  for (int i = 0; i < h->GetNbinsX(); ++i){
27  h->SetBinContent(i+1, h->GetBinContent(i+1)*norms.at(i));
28  }
29 };
void plotLogicalSpectra ( bool  pm1sigma = false)

Definition at line 53 of file plotLogicalSpectra.C.

References demo5::c1, getNormFactors(), kMinus1Sigma, kNominal, kPlus1Sigma, MECModelEnuComparisons::leg, normaliseBins(), and styleHistogram().

53  {
54 
55  TH1D* logicalSpectra = (TH1D*)_file0->Get("covar/NominalBin");
56 
57  TCanvas* c1 = new TCanvas("c1", "c1", 2000, 500);
58  c1->SetGridy();
59  c1->SetLeftMargin(0.08);
60  c1->SetRightMargin(0.05);
61 
62  std::vector<double> norms = getNormFactors(logicalSpectra, 100);
63 
64  normaliseBins(logicalSpectra, norms);
65  styleHistogram(logicalSpectra, kNominal);
66 
67  logicalSpectra->Draw("hist");
68 
69  if (pm1sigma){
70 
71  TH1D* plus1SigmaSpectra = (TH1D*)_file0->Get("covar/Plus1SigmaSpectrum");
72  TH1D* minus1SigmaSpectra = (TH1D*)_file0->Get("covar/Minus1SigmaSpectrum");
73 
74  normaliseBins(plus1SigmaSpectra, norms);
75  styleHistogram(plus1SigmaSpectra, kPlus1Sigma);
76 
77  normaliseBins(minus1SigmaSpectra, norms);
78  styleHistogram(minus1SigmaSpectra, kMinus1Sigma);
79 
80  plus1SigmaSpectra ->Draw("same hist");
81  minus1SigmaSpectra->Draw("same hist");
82  logicalSpectra ->Draw("same hist");
83 
84  TLegend* leg = new TLegend(0.75, 0.70, 0.85, 0.85);
85  leg->AddEntry(logicalSpectra , "Nominal Spectra", "l");
86  leg->AddEntry(plus1SigmaSpectra , "+1 #sigma Spectra", "l");
87  leg->AddEntry(minus1SigmaSpectra, "-1 #sigma Spectra", "l");
88  leg->SetLineWidth(0);
89  leg->SetFillStyle(0);
90  leg->Draw("same");
91 
92  }
93 
94  c1->SaveAs("logicalBinSpectra.pdf");
95 
96 }
void styleHistogram(TH1D *h, type t)
void normaliseBins(TH1D *h, std::vector< double > &norms)
std::vector< double > getNormFactors(TH1D *h, double cutoff)
c1
Definition: demo5.py:24
void styleHistogram ( TH1D *  h,
type  t 
)

Definition at line 32 of file plotLogicalSpectra.C.

References kGreen, kMinus1Sigma, and kPlus1Sigma.

Referenced by plotLogicalSpectra().

32  {
33  h->SetLineWidth(2);
34 
35  if (t == kPlus1Sigma)
36  h->SetLineColor(kGreen+1);
37  if (t == kMinus1Sigma)
38  h->SetLineColor(kAzure+1);
39 
40  h->GetXaxis()->CenterTitle();
41  h->GetYaxis()->CenterTitle();
42 
43  h->GetYaxis()->SetTitleOffset(0.6);
44 
45  h->GetXaxis()->SetTitle("Logical Bin Number");
46  h->GetYaxis()->SetTitle("Normalised Event Count");
47 
48  h->GetYaxis()->SetRangeUser(0, h->GetBinContent(h->GetMaximumBin())*1.25);
49 
50 
51 };
enum BeamMode kGreen