from ROOT import *
import sys

def main(argv):
    NTOYS=100000
    SEED=1000
    
    r=float(argv[1])
    r_err=float(argv[2])

    rand = TRandom(SEED)
   
    r_list=[]
    rsqr_list=[]
    
    print 'aaa'

    hist_r = TH1D("r", "r", 100, r-5.*r_err, r+5*r_err)
    hist_r2= TH1D("1/r2", "1/r2", 100, 1/((r-10*r_err)*(r-10*r_err)), 1/((r+10*r_err)*(r+10*r_err))) 

    for i in range(NTOYS):
        tmp=rand.Gaus(r,r_err)
        
        hist_r.Fill(tmp)
        hist_r2.Fill(1./(tmp*tmp))
        
    
    c1=TCanvas("c1", "c1", 1200, 600)
    c1.Divide(2,1)
    c1.cd(1)
    hist_r.Draw()
    hist_r.Fit('gaus')
    c1.cd(2)
    hist_r2.Draw()
    hist_r2.Fit('gaus')
    c1.SaveAs("result.png")




if __name__ == "__main__":
    main(sys.argv)
