ReMIdHist.C
Go to the documentation of this file.
1 //Create a histogram out of the .root file generated on the grid.
2 #ifdef __CINT__
3 void ReMIdHist()
4 {
5  std::cout << "Sorry, you must run in compiled mode" << std::endl;
6 }
7 #else
8 
9 #include "CAFAna/Cuts/Cuts.h"
10 #include "CAFAna/Core/Spectrum.h"
12 
13 
14 #include "TCanvas.h"
15 #include "TH2.h"
16 #include "TStyle.h"
17 #include "TArrow.h"
18 #include "TH1.h"
19 #include "TH3.h"
20 #include "TFile.h"
21 #include "TLegend.h"
22 #include "TGraph.h"
23 #include <cmath>
24 #include <cassert>
25 #include <memory>
26 #include "TProfile.h"
27 #include <fstream>
28 #include <sstream>
29 #include <iostream>
30 #include <iomanip>
31 #include <stdarg.h>
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <string.h>
35 #include "TLatex.h"
36 #include "TGaxis.h"
37 
38 using namespace ana;
39 
41 {
42  TLatex* prelim = new TLatex(.9, .95, "NOvA Simulation");
43  prelim->SetTextColor(kGray+1);
44  prelim->SetNDC();
45  prelim->SetTextSize(2/30.);
46  prelim->SetTextAlign(32);
47  TGaxis::SetMaxDigits(3);
48  prelim->Draw();
49 }
50 
51 void ReMIdHist()
52 {
53 
54  //Make a new file that reads in my generated .root file.
55  TFile *fpid = new TFile ("/nova/app/users/rbowles/tag_releaseS18-04-23/NDAna/ncpi0/Variables/PID/fReMIdOptVolGrid.root","READ");
56 
57 
58  //Check that the file exists.
59  if( !(fpid) || (fpid->IsZombie()))
60  {
61  std::cout << " <<<<<<<<<<< Intensity.root >>>>>>>> file doesn't exist OR Zombie!!" << std::endl;
62  }
63 
64 
65  //Fill the Spectrums with the information from the .root file
66  auto sig = *Spectrum::LoadFrom(fpid->GetDirectory("sig"));
67  auto bkg = *Spectrum::LoadFrom(fpid->GetDirectory("bkg"));
68  auto ncbkg = *Spectrum::LoadFrom(fpid->GetDirectory("ncbkg"));
69  auto ccpi0bkg = *Spectrum::LoadFrom(fpid->GetDirectory("ccpi0bkg"));
70  auto ccnonpi0bkg = *Spectrum::LoadFrom(fpid->GetDirectory("ccnonpi0bkg"));
71 
72 
73  //Make a new canvas to plot on.
74  TCanvas* c1 = new TCanvas;
75  //c1->SetLogy();
76 
77  //Scale the histogram.
78  const double pot = 8.09e20;
79 
80  //Make histogram objects.
81  TH1* totbkgh = bkg.ToTH1(pot);
82 
83  TH1* sigh = sig.ToTH1(pot);
84  sigh->SetLineColor(kRed);
85 
86  TH1* ncbkgh = ncbkg.ToTH1(pot);
87  ncbkgh->SetLineColor(kBlue);
88 
89  TH1* ccpi0bkgh = ccpi0bkg.ToTH1(pot);
90  ccpi0bkgh->SetLineColor(kGreen);
91 
92  TH1* ccnonpi0bkgh = ccnonpi0bkg.ToTH1(pot);
93  ccnonpi0bkgh->SetLineColor(kMagenta);
94 
95 
96  //Draw a histogram with each object in it.
97  totbkgh->SetTitle(";ReMId;Events");
98  totbkgh->GetXaxis()->SetRange(1,40);
99  totbkgh->Draw("hist");
100  sigh->GetXaxis()->SetRange(1,40);
101  sigh->Draw("hist same");
102  ncbkgh->GetXaxis()->SetRange(1,40);
103  ncbkgh->Draw("hist same");
104  ccpi0bkgh->GetXaxis()->SetRange(1,40);
105  ccpi0bkgh->Draw("hist same");
106  ccnonpi0bkgh->GetXaxis()->SetRange(1,40);
107  ccnonpi0bkgh->Draw("hist same");
108 
109 
110  //Make the legend for the histogram.
111  TLegend* l1 = new TLegend(0.55,0.65,0.65,0.88);
112  l1->SetTextFont(42);
113  l1->SetTextSize(0.04);
114  l1->AddEntry(totbkgh,"Total Background","l1");
115  l1->AddEntry(sigh,"NC Pi0 Signal","l1");
116  l1->AddEntry(ncbkgh,"NC Background","l1");
117  l1->AddEntry(ccpi0bkgh,"CC Pi0 Background","l1");
118  l1->AddEntry(ccnonpi0bkgh,"CC No Pi0 Background","l1");
119  l1->Draw("hist");
120 
121  NDSimulation();
122 
123  //c1->SaveAs("SigVsBkg.pdf");
124 
125 }
126 
127 
128 #endif
enum BeamMode kRed
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:535
#define pot
TLatex * prelim
Definition: Xsec_final.C:133
OStream cout
Definition: OStream.cxx:6
c1
Definition: demo5.py:24
void NDSimulation()
Definition: ReMIdHist.C:40
enum BeamMode kGreen
enum BeamMode kBlue
void ReMIdHist()
Definition: ReMIdHist.C:51