Exemplo n.º 1
0
in_file = "spettro.preamp.dat"
out_file = "preamp.grafici.out"
with open(out_file, "w") as output:
    with open(in_file) as file:
        for line, tuple in zip(file, means):
            pot, tens, _ = [float(x) for x in line.split()]
            media, err_media = tuple
            new_line = [pot, tens, media, 0, 0.03 * tens, err_media]
            new_line = [str(x) for x in new_line]
            new_line = " ".join(new_line) + "\n"
            output.write(new_line)

can_pot = TCanvas(out_file, out_file)
gr_pot = TGraphErrors(out_file, "%lg %*lg %lg %lg %*g %lg")
gr_pot.SetMarkerStyle(8)
gr_pot.Draw("ap")
f_pot = TF1("retta", "pol1")
gr_pot.Fit("retta")
print(gr_pot.GetCorrelationFactor())
print(f_pot.GetChisquare(), "/", f_pot.GetNDF())

can_tens = TCanvas(out_file + "2", out_file)
gr_tens = TGraphErrors(out_file, "%*lg %lg %lg %*lg %g %lg")
gr_tens.SetMarkerStyle(8)
gr_tens.Draw("ap")
f_tens = TF1("retta", "pol1")
gr_tens.Fit("retta")
print(f_tens.GetChisquare(), "/", f_tens.GetNDF())
input()
Exemplo n.º 2
0
]

out_intensity = "intensity.out"
with open(out_intensity, "w") as out_file:
    for dist, intens, int_err in zip(prefissi, intensity, intensity_error):
        line = dist + " " + str(intens) + " " + "0" + " " + str(int_err) + "\n"
        out_file.write(line)

can = TCanvas("dist", "dist")
can.SetFillColor(0)
intensity_graph = TGraphErrors(out_intensity)
intensity_graph.SetTitle()
line = TF1("line", "pol1")
intensity_graph.SetMarkerStyle(8)
intensity_graph.Fit("line")
intensity_graph.GetYaxis().SetDecimals()
intensity_graph.GetYaxis().SetTitle("I^{-1/2} #[]{n_events^{-1/2}}")
intensity_graph.GetYaxis().SetDecimals()
intensity_graph.GetXaxis().SetTitle("distance #[]{mm}")
intensity_graph.Draw("ap")
r = intensity_graph.GetCorrelationFactor()  #correlation coefficient=?
print(r)
#r = 0.826 #correlation coefficient=?
npoints = 6
ndf = npoints - 2
t = r * sqrt(ndf / (1 - r**2))
prob = TMath.StudentI(t, ndf)
print('probability = ', (prob) * 100, '%')
can.SaveAs("distance.eps")
input()