#	hist.Draw("e")
    #	gPad.Modified()
    #	hist_sim.Draw("esames")
    #else:
    #	hist_sim.Draw("e")
    #	gPad.Modified()
    #	hist.Draw("esames")
    #
    #
    #
    #
    #can.SaveAs("clusterPlots_Pos" + cfg.position + ".pdf")
    can.SaveAs(name + ".pdf]")


lhcbStyle.setLHCbStyle()
gStyle.SetOptStat(1)

#measurements = [
#		 ["1431786652", "a_at_0deg", "pos_a_0_deg"]
#		,["1432091294", "a_at_10deg", "pos_a_10_deg"]
#		,["1432264510", "a_at_20deg", "pos_a_20_deg"]
#		,["1432350729", "a_at_30deg", "pos_a_30_deg"]
#		,["1432169457", "c_at_0deg", "pos_c_0_deg"]
#		,["1432089102", "c_at_10deg", "pos_c_10_deg"]
#		,["1432187205", "c_at_20deg", "pos_c_20_deg"]
#		,["1432358809", "c_at_30deg", "pos_c_30_deg"]
#		]

#for measurement in measurements:
#
        # 	hist.Draw("e")
        # 	gPad.Modified()
        # 	hist_sim.Draw("esames")
        # else:
        # 	hist_sim.Draw("e")
        # 	gPad.Modified()
        # 	hist.Draw("esames")
        #
        #
        #
        #
        # can.SaveAs("clusterPlots_Pos" + cfg.position + ".pdf")
    can.SaveAs(name + ".pdf]")


lhcbStyle.setLHCbStyle()
gStyle.SetOptStat(1)

path = "/home/ttekampe/SciFi/results/DataSimCompare/"

data_path = "/home/ttekampe/SciFi/results/clusters/"


# t = "6thTry"
# t = "6thTry_LSw_125"
# t = "6thTry_LSw_125_measured_att"
t = "standard_boole"

# data_name = "testbeam_data_pos_{position}_at_{angle}_deg_corrected_clusterAnalyis.root"
data_name = "testbeam_data_pos_{position}_at_{angle}_deg_corrected_clusterAnalyisexpected_cl_pos.root"
# sim_name = "testbeam_simulation_position_{position}_at_{angle}deg_toolFixed_clusterAnalyis.root"
        spdbinwidth = (upperlim2 - lowerlim2)/bincount
        i = int(bpt[0]/bptbinwidth) +1
        j = int(spd[0]/spdbinwidth) + 1
        r = ROOT.TRandom3(0)
        o[0] = r.Gaus(Weight.GetBinContent(i, j), Weight.GetBinError(i, j))
        brBranch.Fill()

    nt.SetBranchStatus("*", 1)
    nt.Write()
    m.Close()

    print time.asctime(time.localtime()), "Branch Filled!"
        
c=ROOT.TCanvas()
c.Divide(2,1)
lhcb.setLHCbStyle()

#Extracts the two reweighting variables and their ranges from a CSV file, and then runs the Reweight function above based this information

def plotsep(name, source, data, MC, bincount):
    import csv
    print time.asctime(time.localtime()), "Extracting information from " + str(source)
    with open(source, 'rb') as csvfile:
        i = 0
        reader = csv.reader(csvfile, delimiter=',', quotechar='|')
        v = []
        ul = []
        ll = []
        for row in reader:
            x = row
            v.append(x[0])