-
Notifications
You must be signed in to change notification settings - Fork 0
/
make2Dplots.C
115 lines (104 loc) · 4.97 KB
/
make2Dplots.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
void make2Dplots()
{
// initialize file and tree
//TFile *infile = new TFile("studies_sampKenj/inputs/samples/sample_rootfiles/wagasci_sample_kenji.root");
//TFile *infile = new TFile("studies_sampKenj/inputs/samples/sample_rootfiles/splines_event_by_event.root");
TFile *outfile = new TFile("plots/2Dhist/2Dplot.root","RECREATE");
//TTree *tree = (TTree*)infile->Get("selectedEvents");
TChain *tree = new TChain("sample_sum");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run2aMCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run2wMCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run3MCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run4aMCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run4wMCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run5MCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run6MCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run7MCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run8aMCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run8wMCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/run9MCsplines_ForSFGD.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/SFGD_BANFFFormat_anu_500k_NaturalUnits_goodq3units_flatsplines_fixRS_wCoulombCorrection.root");
tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/SFGD_BANFFFormat_nu_2M_NaturalUnits_goodq3units_flatsplines_fixRS_wCoulombCorrection.root");
//tree->Add("studies_sampKenj/inputs/samples/sample_rootfiles/splines_event_by_event_CCcorrected.root");
// set parameters and variables
const int SAMPLES = 35;
double pmu, cs, peso;
int sample;
int nevent = tree->GetEntries();
// set branches
tree->SetBranchAddress("Pmu", &pmu);
tree->SetBranchAddress("CosThetamu", &cs);
tree->SetBranchAddress("POTWeight", &peso);
tree->SetBranchAddress("SelectedSample", &sample);
int nsamp[SAMPLES] = {
// FHC FGD
7, 8, 10, 12, 13, 31, 32, 34, 36, 37,
// RHC FGD
59, 60, 61, 65, 66, 67, 71, 72, 73, 77, 78, 79,
// FHC SFGD
101, 102, 103,
// RHC SFGD
111, 112, 113,
};
std::string nhist[SAMPLES] = {
"FHC FGD1 #nu_{#mu} CC 0#pi 0p 0#gamma",
"FHC FGD1 #nu_{#mu} CC 0#pi Np 0#gamma",
"FHC FGD1 #nu_{#mu} CC 1#pi 0#gamma",
"FHC FGD1 #nu_{#mu} CC Other 0#gamma",
"FHC FGD1 #nu_{#mu} CC #gamma",
"FHC FGD2 #nu_{#mu} CC 0#pi 0p 0#gamma",
"FHC FGD2 #nu_{#mu} CC 0#pi Np 0#gamma",
"FHC FGD2 #nu_{#mu} CC 1#pi 0#gamma",
"FHC FGD2 #nu_{#mu} CC Other 0#gamma",
"FHC FGD2 #nu_{#mu} CC #gamma",
"RHC FGD1 Anti #nu_{#mu} CC 0#pi",
"RHC FGD1 Anti #nu_{#mu} CC 1#pi",
"RHC FGD1 Anti #nu_{#mu} CC Other",
"RHC FGD2 Anti #nu_{#mu} CC 0#pi",
"RHC FGD2 Anti #nu_{#mu} CC 1#pi",
"RHC FGD2 Anti #nu_{#mu} CC Other",
"RHC FGD1 #nu_{#mu} (background) CC 0#pi in AntiNu_Mode",
"RHC FGD1 #nu_{#mu} (background) CC 1#pi in AntiNu_Mode",
"RHC FGD1 #nu_{#mu} (background) CC Other in AntiNu_Mode",
"RHC FGD2 #nu_{#mu} (background) CC 0#pi in AntiNu_Mode",
"RHC FGD2 #nu_{#mu} (background) CC 1#pi in AntiNu_Mode",
"RHC FGD2 #nu_{#mu} (background) CC Other in AntiNu_Mode",
"FHC SFGD #nu_{#mu} CC 0#pi 0p",
"FHC SFGD #nu_{#mu} CC 0#pi Np",
"FHC SFGD #nu_{#mu} CC 1#pi 0p",
"RHC SFGD #bar{#nu}_{#mu} CC 0#pi 0n",
"RHC SFGD #bar{#nu}_{#mu} CC 0#pi Nn",
"RHC SFGD #bar{#nu}_{#mu} CC 1#pi 0n",
};
// min/max entries per histo
// create histos
std::vector<TH2D*> h;
for(int isample = 0; isample < SAMPLES; isample++){
std::string nam = "h"+to_string(isample);
h.push_back(new TH2D(nam.c_str(), nhist[isample].c_str(), 40, -1, 1, 100, 0, 1500));
h[isample]->SetXTitle("cos #theta_{#mu}");
h[isample]->SetYTitle("P_{#mu}");
}
// fill histos per sample for ND280
for(int ientry = 0; ientry < nevent; ientry++) {
tree->GetEntry(ientry);
int isample = 0;
for(int n = 0; n < SAMPLES; n++) {
if ( sample == nsamp[n] ) {
isample = n;
break;
}
}
std::cout << "Pmu: " << pmu << "\tCosThetamu: " << cs << "\tPOTWeight: " << peso << std::endl;
h[isample]->Fill(cs, pmu, peso);
}
// draw and save plots
//TCanvas *c1 = new TCanvas();
gStyle->SetOptStat(0);
outfile->cd();
for(int isample = 0; isample < SAMPLES; isample++){
h[isample]->SetOption("LEGO2");
h[isample]->Write();
}
outfile->Close();
}