CVNphotonSplitHist.C
Go to the documentation of this file.
1 //Create a histogram out of the .root file generated on the grid.
2 #ifdef __CINT__
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 
36 
37 using namespace ana;
38 
40 {
41 
42  //Make a new file that reads in my generated .root file.
43  TFile *fpenergy = new TFile ("/nova/app/users/rbowles/tag_releaseS18-01-19/NDAna/ncpi0/CVNphoton/fCVNphotonSplit.root","READ");
44 
45  //Check that the file exists.
46  if( !(fpenergy) || (fpenergy->IsZombie()))
47  {
48  std::cout << " <<<<<<<<<<< Intensity.root >>>>>>>> file doesn't exist OR Zombie!!" << std::endl;
49  }
50 
51 
52  //Fill the Spectrums with the information from the .root file
53  auto total = *Spectrum::LoadFrom(fpenergy->GetDirectory("total"));
54  auto electron = *Spectrum::LoadFrom(fpenergy->GetDirectory("electron"));
55  auto muon = *Spectrum::LoadFrom(fpenergy->GetDirectory("muon"));
56  auto photon = *Spectrum::LoadFrom(fpenergy->GetDirectory("photon"));
57  auto piplus = *Spectrum::LoadFrom(fpenergy->GetDirectory("piplus"));
58 
59 
60  //Make a new canvas to plot on.
61  TCanvas* c1 = new TCanvas;
62  //c1->SetLogy();
63 
64  //Scale the histogram.
65  const double pot = 8.09e20;
66  //const double pot = 1e19;
67  //Make histogram objects.
68  TH1* totalh = total.ToTH1(pot);
69 
70  TH1* electronh = electron.ToTH1(pot);
71  electronh->SetLineColor(kRed);
72 
73  TH1* muonh = muon.ToTH1(pot);
74  muonh->SetLineColor(kBlue);
75 
76  TH1* photonh = photon.ToTH1(pot);
77  photonh->SetLineColor(kGreen);
78 
79  TH1* piplush = piplus.ToTH1(pot);
80  piplush->SetLineColor(kMagenta);
81 
82 
83  //Draw a histogram with each object in it.
84  totalh->SetTitle("Input Variable: CVN Photon;CVN Photon;Events");
85  //totalh->GetXaxis()->SetRange(50,100);
86  totalh->GetYaxis()->SetRangeUser(0,100000);
87  electronh->Draw("hist");
88  // electronh->GetXaxis()->SetRange(50,100);
89  electronh->GetYaxis()->SetRangeUser(0,100000);
90  muonh->Draw("hist same");
91  //muonh->GetXaxis()->SetRange(50,100);
92  muonh->GetYaxis()->SetRangeUser(0,100000);
93  photonh->Draw("hist same");
94  //photonh->GetXaxis()->SetRange(50,100);
95  photonh->GetYaxis()->SetRangeUser(0,100000);
96  piplush->Draw("hist same");
97  //piplush->GetXaxis()->SetRange(50,100);
98  piplush->GetYaxis()->SetRangeUser(0,100000);
99 
100 
101  //Make the legend for the histogram.
102  TLegend* l1 = new TLegend(0.15,0.58,0.55,0.88);
103  l1->SetTextFont(42);
104  l1->SetTextSize(0.04);
105  l1->AddEntry(totalh,"Total Events","l1");
106  l1->AddEntry(electronh,"Electron Events","l1");
107  l1->AddEntry(muonh,"Muon Events","l1");
108  l1->AddEntry(photonh,"Photon Events","l1");
109  l1->AddEntry(piplush,"Pi Plus Events","l1");
110  l1->Draw("hist");
111 
112 
113 
114  c1->SaveAs("CVNphotonSplit.pdf");
115 
116 
117 }
118 
119 
120 #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
void CVNphotonSplitHist()
OStream cout
Definition: OStream.cxx:6
c1
Definition: demo5.py:24
enum BeamMode kGreen
enum BeamMode kBlue