def setpad(left, right, top, bottom): gPad.SetFillColor(10) gPad.SetBorderMode(0) gPad.SetBorderSize(0) gPad.SetFrameFillColor(10) gPad.SetFrameBorderMode(0) gPad.SetFrameBorderSize(0) gPad.SetLeftMargin(left) gPad.SetRightMargin(right) gPad.SetTopMargin(top) gPad.SetBottomMargin(bottom) gPad.SetGridx(0) gPad.SetGridy(0) gStyle.SetOptStat(0)
def PlotPosteriors(ListOfPosteriors, outputname = ""): RepeatIteration = False if (outputname != "" ): outputname = "_"+outputname c = TCanvas("Posteriors"+outputname,"Posteriors"+outputname,0,0,1600, 1600) c.Divide(math.ceil(pow(len(ListOfPosteriors),0.5)),math.ceil(pow(len(ListOfPosteriors),0.5))) legends = [] for i in range(len(ListOfPosteriors)): ListOfPosteriors[i].SetMaximum(ListOfPosteriors[i].GetMaximum()*2.0) #ListOfPosteriors[i].Fit("gaus") fit = ListOfPosteriors[i].GetFunction("gaus") chi2 = fit.GetChisquare() p1 = fit.GetParameter(1) #p0 = fit.GetParameter(0) p2 = fit.GetParameter(2) FitIntegral = fit.Integral(p1-10*p2,p1+10*p2) # fit integral , get mean plus minus 10 sigma PriorIntegral = ListOfPosteriors[i].Integral("width") Percentage = round((100*PriorIntegral/FitIntegral),0) c.cd(i+1) gPad.SetFrameFillColor(10) if (Percentage < 90): gPad.SetFillColor(kRed-4) RepeatIteration = True else: gPad.SetFillColor(8) leg = TLegend(0.1,0.5,0.85,0.9) leg.SetFillStyle(0) leg.AddEntry(None,"MeanHist = "+str(round(ListOfPosteriors[i].GetMean(),0))+", RMShist = "+str(round(ListOfPosteriors[i].GetRMS(),0))+", MeanFit = "+str(round(p1,0))+", #sigma_{fit} = "+str(round(p2,0)),"") leg.AddEntry(ListOfPosteriors[i],"Posterior ","l") leg.AddEntry(fit,"Fit ","l") leg.AddEntry(None,"#chi^{2}/NDF = "+str(round(chi2/len(ListOfPosteriors),2)),"") leg.AddEntry(None,"Integral Prior/Fit = "+str(round(Percentage,0))+" %","") leg.SetBorderSize(0) legends.append(leg) ListOfPosteriors[i].SetTitle("Posterior in bin "+str(i+1)) gStyle.SetOptStat(0) ListOfPosteriors[i].Draw() legends[i].Draw("same") if (round(chi2/len(ListOfPosteriors),2)) > 20.0: RepeatIteration = True #c.Update() c.cd(1) gStyle.SetOptStat(0) #gPad.Modified() #c.Update() PrintCan(c,c.GetName()+"_posteriors") return RepeatIteration
rigidity = np.append( np.array([33.6, 39.0, 48.65, 56.25, 65.0, 75.1]) , rigidity2 ) rigidity.astype(np.float) ccnumber = np.array([1490, 1990, 2544, 3085, 3676, 4736, 5843, 7984, 9951, 13566, 18153, 23759, 25410, 47545, 86928]).astype(np.float) correctnumber = np.array([92187167, 72002335, 48641517, 37497075, 29533378, 28661684, 17866111, 14404357, 10865174, 9209412, 7380493, 5768877, 3810445, 4223271, 3732153]).astype(np.float) ccratio = ccnumber/(correctnumber+ccnumber) ISSpositive = np.array([16165878, 12455567, 8304814, 6352927, 4953535, 3823826, 2961983, 2367438, 1780154, 1500592, 1197313, 930211, 614647, 683018, 610281]).astype(np.float) ISSnegative = np.array([39986, 28817, 17690, 12754, 9576, 7191, 5572, 4624, 3988, 3950, 4469, 4905, 5066, 9397, 16391]).astype(np.float) ISS_chargeconfused = ISSpositive*ccratio ####################################################################################### c1 = TCanvas() gPad.SetGrid() gPad.SetFrameFillColor(0) gStyle.SetOptStat("00000000") c1.SetLogy() zeroline = [0]*rigidity.shape[0] mg = TMultiGraph("mg","mg") grshade = TGraph(2*rigidity.shape[0]) grshade2 = TGraph(2*rigidity.shape[0]) for i in range(rigidity.shape[0]): grshade.SetPoint(i,rigidity[i],ISSnegative[i]) grshade.SetPoint(rigidity.shape[0]+i,rigidity[rigidity.shape[0]-i-1],ISS_chargeconfused[rigidity.shape[0]-i-1]) for i in range(rigidity.shape[0]): grshade2.SetPoint(i,rigidity[i],ISS_chargeconfused[i]) grshade2.SetPoint(rigidity.shape[0]+i,rigidity[rigidity.shape[0]-i-1],zeroline[rigidity.shape[0]-i-1])
## \macro_image ## \macro_code ## ## \author Juan Fernando Jaramillo Botero from ROOT import TCanvas, TF1, gSystem, gPad, TLegend, TPaveLabel, kBlack gSystem.Load("libMathMore") DistCanvas = TCanvas("DistCanvas", "Bessel functions example", 10, 10, 800, 600) DistCanvas.SetFillColor(17) DistCanvas.Divide(2, 2) DistCanvas.cd(1) gPad.SetGrid() gPad.SetFrameFillColor(19) leg = TLegend(0.75, 0.7, 0.89, 0.89) # Drawing the set of Bessel J functions # # n is the number of functions in each pad n = 5 JBessel = [] for nu in range(n): jbessel = TF1("J_0", "ROOT::Math::cyl_bessel_j([0],x)", 0, 10) jbessel.SetParameters(nu, 0.0) jbessel.SetTitle("") jbessel.SetLineStyle(1) jbessel.SetLineWidth(3) jbessel.SetLineColor(nu + 1) JBessel.append(jbessel)