def make_graph(a, output): c1 = TCanvas("c1", "c1", 1000, 1000) # Creates the canvas to draw the bar chart to. c1.SetGrid() # Adds grid lines to canvas. leg = TLegend(0.7, 0.6, 0.95, 0.95) leg.AddEntry(a, "Start", "P") n0 = TNtuple("n0", "n0", "x:y:z") # creates ntuple to store the values of x y z n0.SetMarkerColor(0) n0.Fill(-4500, -4500, -5700) n0.Fill(4500, 4500, 5700) n0.Draw("x:y:z") #a.SetMarkerColor(1) #a.SetMarkerStyle(6) #a.Draw("x:y:z","","same") # Draws the histogram to the canvas. a.SetMarkerColor(2) a.SetMarkerStyle(6) a.Draw("x2:y2:z2", "", "same") # Draws the histogram to the canvas. #leg.Draw() c1.Update() # Makes the canvas show the histogram. img = ROOT.TImage.Create() # creates image img.FromPad(c1) # takes it from canvas img.WriteImage( output) # Saves it to png file with this name in input file directory. return c1
def make_graph(a, b, c, d, e, f, g, h, i, j, k, l, output): c1 = TCanvas("c1", "c1", 800, 800) # Creates the canvas to draw the bar chart to. c1.SetGrid() # Adds grid lines to canvas. leg = TLegend(0.7, 0.6, 0.95, 0.95) leg.AddEntry(a, "EcalBarrelHits", "P") leg.AddEntry(b, "EcalEndcapHits", "P") leg.AddEntry(c, "HcalBarrelHits", "P") leg.AddEntry(d, "HcalEndcapHits", "P") leg.AddEntry(e, "LumiCalHits", "P") leg.AddEntry(f, "MuonBarrelHits", "P") leg.AddEntry(g, "MuonEndcapHits", "P") leg.AddEntry(h, "SiTrackerBarrelHits", "P") leg.AddEntry(i, "SiTrackerEndcapHits", "P") leg.AddEntry(j, "SiTrackerForwardHits", "P") leg.AddEntry(k, "SiVertexBarrelHits", "P") leg.AddEntry(l, "SiVertexEndcapHits", "P") n0 = TNtuple("n0", "n0", "x:y:z") # creates ntuple to store the values of x y z n0.SetMarkerColor(0) n0.Fill(-4500, -4500, -5700) n0.Fill(4500, 4500, 5700) n0.Draw("x:y:z") a.SetMarkerColor(1) a.SetMarkerStyle(6) a.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. b.SetMarkerColor(2) b.SetMarkerStyle(6) b.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. c.SetMarkerColor(3) c.SetMarkerStyle(6) c.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. d.SetMarkerColor(4) d.SetMarkerStyle(6) d.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. e.SetMarkerColor(5) e.SetMarkerStyle(6) e.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. f.SetMarkerColor(6) f.SetMarkerStyle(6) f.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. g.SetMarkerColor(7) g.SetMarkerStyle(6) g.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. h.SetMarkerColor(8) h.SetMarkerStyle(6) h.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. i.SetMarkerColor(9) i.SetMarkerStyle(6) i.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. j.SetMarkerColor(30) j.SetMarkerStyle(6) j.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. k.SetMarkerColor(40) k.SetMarkerStyle(6) k.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. l.SetMarkerColor(28) l.SetMarkerStyle(6) l.Draw("x:y:z", "", "same") # Draws the histogram to the canvas. leg.Draw() c1.Update() # Makes the canvas show the histogram. img = ROOT.TImage.Create() # creates image img.FromPad(c1) # takes it from canvas img.WriteImage( output) # Saves it to png file with this name in input file directory. return c1