-
Notifications
You must be signed in to change notification settings - Fork 0
/
thicknesscollection.cpp
101 lines (82 loc) · 2.68 KB
/
thicknesscollection.cpp
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
#include <TFile.h>
#include <TH1F.h>
#include <TF1.h>
#include <vector>
#include <TGraph.h>
#include <TCanvas.h>
void thicknesscollection(){
//Number of experiments
Int_t start = 1; //Starting parameter
Int_t end = 100; //Final parameter
Int_t n = end-start;
//Counter
Int_t c = 0;
//Arrays that will contain plotting data
Double_t meanCollection[n],stdDevCollection[n],entriesCollection[n],thickness[n];
for (int i=1;i<=100;i++){
//Generates file path string
std::string file = std::to_string(i);
std::string filePath = "figs/thickness/" + file + ".root";
//Gets file object
TFile files(filePath.c_str());
//Gets histogram from file
TH1F* data = nullptr;
files.GetObject("missHist",data);
//Fits Gaussian to data
TF1 *gfit = new TF1("gfit","gaus");
data->Fit("gfit","gaus");
//Calculates real unit
thickness[c] =(Double_t)(i)/100.0;
std::cout<<thickness[c]<<std::endl;
//Fills the arrays with their data
meanCollection[c] = gfit->GetParameter("Mean");
stdDevCollection[c] = gfit->GetParameter("Sigma");
entriesCollection[c] = data->GetEntries()/100240;
c++;
files.Close();
}
//Choose which data you want to plot
//Mean missing mass
TCanvas* c1 = new TCanvas();
auto dets = new TGraph(n,thickness,meanCollection);
dets->SetTitle("");
dets->GetXaxis()->SetTitle("Thickness of layers Detectors (mm)");
dets->GetYaxis()->SetTitle("Mean missing mass (keV/c^2)");
dets->SetMarkerStyle(7);
dets->Draw("acp");
dets->SaveAs("figs/collections/thickness_mass.root");
c1->SetRightMargin(0.09);
c1->SetLeftMargin(0.15);
c1->Print("figs/collections/thickness_mass.eps");
c1->Print("figs/collections/thickness_mass.png");
/*
//Standard deviation of missing mass
TCanvas* c1 = new TCanvas();
auto dets = new TGraph(n,thickness,stdDevCollection);
dets->SetTitle("");
dets->GetXaxis()->SetTitle("Thickness of layers Detectors (mm)");
dets->GetYaxis()->SetTitle("Standard deviation of missing mass (keV/c^2)");
dets->SetMarkerStyle(7);
dets->Draw("acp");
dets->SaveAs("figs/collections/thickness_std.root");
c1->SetRightMargin(0.09);
c1->SetLeftMargin(0.15);
c1->Print("figs/collections/thickness_std.eps");
c1->Print("figs/collections/thickness_std.png");
*/
/*
//Detector efficiency
TCanvas* c1 = new TCanvas();
auto dets = new TGraph(n,thickness,entriesCollection);
dets->SetTitle("");
dets->GetXaxis()->SetTitle("Thickness of layers Detectors (mm)");
dets->GetYaxis()->SetTitle("Detector efficiency");
dets->SetMarkerStyle(7);
dets->Draw("acp");
dets->SaveAs("figs/collections/thickness_eff.root");
c1->SetRightMargin(0.09);
c1->SetLeftMargin(0.15);
c1->Print("figs/collections/thickness_eff.eps");
c1->Print("figs/collections/thickness_eff.png");
*/
}