purGraph = TGraphErrors(len(_NumberOfProtons), _NumberOfProtons, _Purity, _NumberOfProtonsErr, _PurityErr) purGraph.SetMarkerStyle(5) purGraph.SetLineColor(2) purGraph.SetMarkerColor(2) purGraph.SetMarkerSize(2) purGraph.GetXaxis().SetTitle("Mean N Proton") purGraph.GetYaxis().SetTitle("Purity") purGraph.SetTitle("Purity") MyFile = TFile( "effVsPurity_bs" + (str)(beamSpread) + "mrad_geo" + geoName + "_RestrictTracks" + (str)(restrictNTracks) + "_pitch" + (str)(pitch) + ".root", "RECREATE") mg = TMultiGraph() mg.SetTitle("Efficiency and Purity vs nProtons;Mean N Protons; (%)") mg.Add(effGraph, "lp") mg.Add(purGraph, "lp") mg.Draw("a") effGraph.Write() purGraph.Write() mg.Write() legend = TLegend(0.1, 0.7, 0.48, 0.9) legend.AddEntry(effGraph, "Efficiency", "lp") legend.AddEntry(purGraph, "Purity", "lp") legend.Draw("SAME") canvas1.Write("EffVsPurity")
def collectPerDirectionBx(options): """Fit data in both directions of a scan""" nSteps = len(O['nominalPos'][options['scan']]) for i in range(nSteps - 1): if O['nominalPos'][options['scan']][i+1] == \ O['nominalPos'][options['scan']][i]: break else: for i in range(nSteps - 1): if abs(O['nominalPos'][options['scan']][i+1] - \ O['nominalPos'][options['scan']][i]) < 10.0: break else: raise RuntimeError('Could not find change of direction.') if 'nominalPos' in options: nominalPos = options['nominalPos'] else: nominalPos = O['nominalPos'][options['scan']] oldname = options['scan'] + '_' + options['name'] + options['fitted'] if options.get('newname', False): newname = options['scan'] + '_' + options['newname'] + \ options['fitted'] else: newname = oldname if options.get('method', False): oldname += '_' + options['method'] newname += '_' + options['method'] newname += '_collected' f = openRootFileR(oldname) g = openRootFileW(newname) for bx in options['crossings']: average = [0 for j in range(nSteps)] averror = [0 for j in range(nSteps)] for step in range(nSteps): print '<<< Access data from:', options['scan'], bx, 'step', step histname = plotName(oldname+'_bx'+str(bx)+'_step'+str(step), \ timestamp=False) hist = f.Get(histname) if options['custom']: average[step], averror[step] = options['custom'](hist, step) else: average[step] = hist.GetMean() averror[step] = hist.GetMeanError() plotname = plotName(newname + '_bx' + str(bx), timestamp=False) plottitl = plotTitle(options['scan'] + ' BX ' + str(bx)) print '<<< Create plot:', plotname graphs = TMultiGraph(plotname, plottitl) residuals = TMultiGraph(plotname + '_residuals', '') for n, rnge in zip([i+1, nSteps-i-1], [lambda l: l[:i+1], \ lambda l: l[i+1:]]): graph = TGraphErrors(n, \ array('d', [options['x'](a) for a in rnge(nominalPos)]), \ array('d', [options['y'](a) for a in rnge(average)]), \ array('d', [0]*n), \ array('d', [options['e'](a) for a in rnge(averror)])) graph.Fit(options['fit']) residual = TGraphErrors(n, \ array('d', [options['x'](a) for a in rnge(nominalPos)]), \ array('d', [options['y'](a) - graph.GetFunction( \ options['fit']).Eval(options['x'](b)) for a, b \ in zip(rnge(average), rnge(nominalPos))]), array('d', [0]*n), \ array('d', [options['e'](a) for a in rnge(averror)])) graphs.Add(graph) residuals.Add(residual) graphs.Write('', TObject.kOverwrite) residuals.Write('', TObject.kOverwrite) closeRootFile(g, newname) closeRootFile(f, oldname)
def plotDistributionComparisonPlot(cfg): multiGraph = TMultiGraph() multiGraph.SetName("triggerRateMultiGraph") tfiles = [] histograms = [] canvas = TCanvas("canvas", "canvas", 800, 800) '''Contains the legend''' legend = TLegend(0.3, 0.7, 0.90, 0.9) '''Maximum value container, used to scale histograms''' maximumY = float("-inf") pad1 = TPad("pad1", "pad1", 0, 0.3, 1, 1.0) pad1.SetBottomMargin(0.05) # Upper and lower plot are joined #pad1.SetBottomMargin(0) # Upper and lower plot are joined pad1.SetGridx() # Vertical grid pad1.Draw() # Draw the upper pad: pad1 pad1.cd() # pad1 becomes the current pad for histogramFileNameAndTitle in cfg.plots: tfile = TFile(histogramFileNameAndTitle[0]) tfiles.append(tfile) histogram = tfile.Get(histogramFileNameAndTitle[1]) histograms.append(histogram) if histogram.ClassName() == "TH1F": histogram.SetStats(0) # No statistics on upper plot maximumY = histogram.GetMaximum( ) if histogram.GetMaximum() > maximumY else maximumY legend.AddEntry(histogram, histogramFileNameAndTitle[2], "l") # histograms[0] settings histograms[0].SetMarkerColor(4) histograms[0].SetLineColor(4) histograms[0].SetLineWidth(1) # Y axis histograms[0] plot settings histograms[0].GetYaxis().SetTitleSize(20) histograms[0].GetYaxis().SetTitleFont(43) histograms[0].GetYaxis().SetTitleOffset(1.55) #histograms[0].Scale(1./histograms[0].GetEntries()) if histograms[0].ClassName() == "TH1F": histograms[0].Draw( "SAME HIST") # Draw histograms[1] on top of histograms[0] else: histograms[0].Draw( "SAME APE") # Draw histograms[1] on top of histograms[0] #multiGraph.Add(histograms[0]) if getattr(cfg, "xRange", None) is not None: histograms[0].GetXaxis().SetRangeUser(cfg.xRange[0], cfg.xRange[1]) gPad.RedrawAxis() if getattr(cfg, "xAxisLabel", None) is not None: histograms[0].GetXaxis().SetTitle(cfg.xAxisLabel) gPad.RedrawAxis() if getattr(cfg, "yAxisLabel", None) is not None: histograms[0].GetYaxis().SetTitle(cfg.yAxisLabel) gPad.RedrawAxis() if getattr(cfg, "yRange", None) is not None: histograms[0].GetYaxis().SetRangeUser(cfg.yRange[0], cfg.yRange[1]) gPad.RedrawAxis() else: maximumY *= 1.1 histograms[0].GetYaxis().SetRangeUser(1e-6, maximumY) if getattr(cfg, "logY", False): canvas.SetLogy() # histograms[1] settings histograms[1].SetMarkerColor(2) histograms[1].SetLineColor(2) histograms[1].SetLineWidth(1) #histograms[1].Scale(1./histograms[1].GetEntries()) if histograms[1].ClassName() == "TH1F": histograms[1].Draw( "SAME HIST") # Draw histograms[1] on top of histograms[0] else: histograms[1].Draw( "SAME PE") # Draw histograms[1] on top of histograms[0] #multiGraph.Add(histograms[1]) #if multiGraph.GetListOfGraphs() != None: # multiGraph.Draw("SAME PE") # Do not draw the Y axis label on the upper plot and redraw a small # axis instead, in order to avoid the first label (0) to be clipped. #histograms[0].GetYaxis().SetLabelSize(0.) #axis = TGaxis( 0, 20, 0, maximumY, 20, maximumY, 510,"") #axis.SetLabelFont(43) # Absolute font size in pixel (precision 3) #axis.SetLabelSize(15) #axis.Draw() # Adding a small text with the chi-squared chiSquared = 0 if (histograms[0].ClassName() == "TGraph") or (histograms[0].ClassName() == "TGraphErrors"): numberOfBins = histograms[0].GetN() numberOfDegreesOfFreedom = numberOfBins else: numberOfBins = histograms[0].GetNbinsX() numberOfDegreesOfFreedom = numberOfBins for x in xrange( 1, numberOfBins + 1 ): # numberOfBins contains last bin, numberOfBins+1 contains the overflow (latter excluded), underflow also excluded if (histograms[0].ClassName() == "TGraph") or (histograms[0].ClassName() == "TGraphErrors"): binContent0 = histograms[0].GetY()[x - 1] else: binContent0 = histograms[0].GetBinContent(x) if (histograms[1].ClassName() == "TGraph") or (histograms[1].ClassName() == "TGraphErrors"): binContent1 = histograms[1].GetY()[x - 1] else: binContent1 = histograms[1].GetBinContent(x) bin0ErrorSquared = binContent0 bin1ErrorSquared = binContent1 #bin1ErrorSquared = 0 if (binContent0 == 0) and (binContent1 == 0): numberOfDegreesOfFreedom -= 1 #No data means one less degree of freedom else: binDifferenceSquared = (binContent0 - binContent1)**2 chiSquaredTerm = binDifferenceSquared / (bin0ErrorSquared + bin1ErrorSquared) chiSquared += chiSquaredTerm if chiSquaredTerm > chiSquaredWarningThreshold: if (histograms[0].ClassName() == "TGraph") or (histograms[0].ClassName() == "TGraphErrors"): print "Bin", x, "-", histograms[0].GetX()[ x - 1], "has a CS=", chiSquaredTerm else: print "Bin", x, "-", histograms[0].GetBinCenter( x), "has a CS=", chiSquaredTerm chiSquareLabel = TPaveText(0.7, 0.6, 0.9, 0.4) chiSquareLabel.AddText("#chi^{2}/ndf = " + str(chiSquared) + "/" + str(numberOfDegreesOfFreedom) + " = " + str(chiSquared / numberOfDegreesOfFreedom)) chiSquareLabel.Draw() print "FINAL CS IS", format( chiSquared, ".2f") + "/" + str(numberOfDegreesOfFreedom) + " = " + format( chiSquared / numberOfDegreesOfFreedom, ".2f") legend.SetHeader( "#chi^{2}/ndf = " + format(chiSquared, ".2f") + "/" + str(numberOfDegreesOfFreedom) + " = " + format(chiSquared / numberOfDegreesOfFreedom, ".2f"), "C") legend.Draw() # lower plot will be in pad canvas.cd() # Go back to the main canvas before defining pad2 pad2 = TPad("pad2", "pad2", 0, 0.05, 1, 0.3) pad2.SetTopMargin(0) pad2.SetBottomMargin(0.2) pad2.SetGridx() # vertical grid pad2.Draw() pad2.cd() # pad2 becomes the current pad pad2.SetGridy() # Define the ratio plot ratioPlot = TGraphErrors(histograms[0]) ratioPlot.SetName("ratioPlot") graph_histo0 = TGraphErrors(histograms[0]) graph_histo1 = TGraphErrors(histograms[1]) ratioPlot.SetLineColor(1) ratioPlot.SetMinimum(0.6) # Define Y .. ratioPlot.SetMaximum(1.5) # .. range #ratioPlot.Sumw2() #ratioPlot.SetStats(0) # No statistics on lower plot #Dividing point by point for index in xrange(0, ratioPlot.GetN()): if graph_histo1.GetY()[index] == 0: ratioPlot.GetY()[index] = 0 ratioPlot.GetEY()[index] = 0 else: ratioPlot.GetY()[index] /= graph_histo1.GetY()[index] ratioPlot.GetEY()[index] = sqrt( ((graph_histo1.GetY()[index])**2 * (graph_histo0.GetEY()[index])**2 + (graph_histo0.GetY()[index])**2 * (graph_histo1.GetEY()[index])**2) / (graph_histo1.GetY()[index])**4) ratioPlot.SetMarkerStyle(21) if getattr(cfg, "xRange", None) is not None: ratioPlot.GetXaxis().SetRangeUser(cfg.xRange[0], cfg.xRange[1]) gPad.RedrawAxis() if getattr(cfg, "yRangeRatio", None) is not None: ratioPlot.GetYaxis().SetRangeUser(cfg.yRangeRatio[0], cfg.yRangeRatio[1]) gPad.RedrawAxis() ratioPlot.Draw("APE") # Draw the ratio plot line0 = TLine(ratioPlot.GetXaxis().GetXmin(), 1, ratioPlot.GetXaxis().GetXmax(), 1) line0.SetLineColor(2) line0.SetLineWidth(2) line0.SetLineStyle(2) line0.Draw() # Ratio plot (ratioPlot) settings ratioPlot.SetTitle("") # Remove the ratio title # Y axis ratio plot settings ratioPlot.GetYaxis().SetTitle("Ratio #frac{blue}{red}") ratioPlot.GetYaxis().SetNdivisions(505) ratioPlot.GetYaxis().SetTitleSize(20) ratioPlot.GetYaxis().SetTitleFont(43) ratioPlot.GetYaxis().SetTitleOffset(1.55) ratioPlot.GetYaxis().SetLabelFont( 43) # Absolute font size in pixel (precision 3) ratioPlot.GetYaxis().SetLabelSize(15) # X axis ratio plot settings ratioPlot.GetXaxis().SetTitleSize(20) ratioPlot.GetXaxis().SetTitleFont(43) ratioPlot.GetXaxis().SetTitleOffset(4.) ratioPlot.GetXaxis().SetLabelFont( 43) # Absolute font size in pixel (precision 3) ratioPlot.GetXaxis().SetLabelSize(15) xRangeBinning = getattr(cfg, "simplifiedRatioPlotXRangeBinning", None) if xRangeBinning is not None: simplifiedRatioPlot = TGraphErrors(len(xRangeBinning) - 1) simplifiedRatioPlot.SetName("simplifiedRatioPlot") ratioPlotIndex = 0 for idx in xrange(0, simplifiedRatioPlot.GetN()): yAverage = 0. yMax = float("-inf") yMin = float("+inf") nPoints = 0. simplifiedRatioPlot.GetX()[idx] = (xRangeBinning[idx] + xRangeBinning[idx + 1]) / 2. simplifiedRatioPlot.GetEX()[idx] = (xRangeBinning[idx + 1] - xRangeBinning[idx]) / 2. while (ratioPlot.GetX()[ratioPlotIndex] < xRangeBinning[idx]): ratioPlotIndex += 1 while ((ratioPlotIndex < ratioPlot.GetN()) and (ratioPlot.GetX()[ratioPlotIndex] < xRangeBinning[idx + 1]) and (ratioPlot.GetX()[ratioPlotIndex] >= xRangeBinning[idx])): yAverage += ratioPlot.GetY()[ratioPlotIndex] if (yMax < ratioPlot.GetY()[ratioPlotIndex] + ratioPlot.GetEY()[ratioPlotIndex]): yMax = ratioPlot.GetY()[ratioPlotIndex] + ratioPlot.GetEY( )[ratioPlotIndex] if (yMin > ratioPlot.GetY()[ratioPlotIndex] - ratioPlot.GetEY()[ratioPlotIndex]): yMin = ratioPlot.GetY()[ratioPlotIndex] - ratioPlot.GetEY( )[ratioPlotIndex] nPoints += 1. ratioPlotIndex += 1 simplifiedRatioPlot.GetY()[idx] = yAverage / nPoints simplifiedRatioPlot.GetEY()[idx] = (yMax - yMin) / 2. saveFile = TFile(cfg.saveFileName, "RECREATE") saveFile.cd() canvas.Write() histograms[0].Write() histograms[1].Write() if multiGraph.GetListOfGraphs() != None: multiGraph.Write() ratioPlot.Write() if xRangeBinning is not None: simplifiedRatioPlot.Write() saveFile.Close() for tfile in tfiles: tfile.Close()
kk1.append(TGraph(int(len(bias1)), bias1, heigth_b_g[i])) for i in gain1: kk2.append(TGraph(int(len(bias1)), bias1, widht_b_g[i])) k = 0 for i in kk1: k = k + 1 i.SetLineColor(k + 1) l5.AddEntry(i, "gain " + str(k - 1), "alp") mm1.Add(i) k = 0 for i in kk2: k = k + 1 i.SetLineColor(k + 1) l5.AddEntry(i, "gain " + str(k - 1), "alp") mm2.Add(i) c5.cd() mm1.Draw("APL") l5.Draw("") c5.Modified() c5.Update() mm1.Write() c5.Write() c6.cd() mm2.Draw("APL") l6.Draw("") mm2.Write() c6.Modified() c6.Update() c6.Write()
def isobar_analysis_0pp(): """Does the 2D isobar analysis, based on 'print2DtoRoot', with all cuts, argands and what not""" root_name='isobar_analysis.root' outROOT=root_open('./ROOT/'+root_name,mode="RECREATE") isobar = 'f0_' jpcs = ['0-+','1++','2-+'] # jpcs = ['0-+'] M='0' iso_slices = { # do not use bin borders in definitions, a bin will be used, if any part of the defined interval overlaps with the bin #hence the *.**1 and *.**9 at the end of each definition '0-+':[[1.661,1.699,'below_resonance'],[1.781,1.819,'on_resonance'],[1.901,1.939,'above_resonance']], '1++':[[1.261,1.299,'below_resonance'],[1.381,1.419,'on_resonance'],[1.501,1.539,'above_resonance']], '2-+':[[1.781,1.819,'below_resonance'],[1.901,1.939,'on_resonance'],[2.021,2.059,'above_resonance']] } all_slices = True # Set True, if all 3pi slices shall be written out if all_slices: for i in range(50): mmin = 0.5 +i*0.04 + 0.001 mmax = 0.5 + (i+1)*0.04 - 0.001 name = "slice_"+str(i) iso_slices["0-+"].append([mmin,mmax,name]) iso_slices["1++"].append([mmin,mmax,name]) iso_slices["2-+"].append([mmin,mmax,name]) prefixes = {'0-+':'1-(0-+)0+ f0_','1++':'1-(1++)0+ f0_','2-+':'1-(2-+)0+ f0_'} suffixes = {'0-+':' pi S','1++':' pi P','2-+':' pi D'} X_slices = [[0.961,0.999,'f_0(980)'],[1.401,1.559,'f_0(1500)'],[0.2781,2.279,'Incoherent_sum']] suppressSigma=0 tbins=['0.10000-0.14077','0.14077-0.19435','0.19435-0.32617','0.32617-1.00000'] sumintens={} for tbin in tbins: dataSet = get2D('/nfs/mds/user/fkrinner/massIndepententFits/fits/4tbin_deisobarred/fit/'+tbin, '/nfs/mds/user/fkrinner/massIndepententFits/fits/4tbin_deisobarred/integrals/'+tbin ,normalizeToIntegrals = False, divide_key_intens = True) for jpc in jpcs: addString = '_'+isobar bins2Pi=[] bins3Pi=[] for i in range(0,len(dataSet[0])): if dataSet[0][i][4]==jpc and dataSet[0][i][13] == M and isobar in dataSet[0][i][14]: bins3Pi.append(dataSet[0][i][0]) bins3Pi.append(dataSet[0][i][1]) bins2Pi.append(dataSet[0][i][2]) bins2Pi.append(dataSet[0][i][3]) bins3Pi.sort() bins2Pi.sort() if not len(bins3Pi) + len(bins2Pi) == 0: binning2Pi=[bins2Pi[0]] binning3Pi=[bins3Pi[0]] for i in range(1,len(bins3Pi)-1): if binning3Pi[-1] != bins3Pi[i]: binning3Pi.append(bins3Pi[i]) if bins3Pi[i] != bins3Pi[i+1]: print "Warning: Binning in m(3Pi) is wrong." binning3Pi.append(bins3Pi[-1]) for i in range(1,len(bins2Pi)-1): if binning2Pi[-1] != bins2Pi[i]: binning2Pi.append(bins2Pi[i]) if bins2Pi[i] != bins2Pi[i+1]: print "Warning: Binning in m(2Pi) is wrong." binning2Pi.append(bins2Pi[-1]) binning2Pi= numpy.asarray(binning2Pi,dtype=numpy.float64) binning3Pi= numpy.asarray(binning3Pi,dtype=numpy.float64) histIn = TH2D("Intensity of "+jpc+'_'+M+addString+"_"+tbin,"Intensity of "+jpc+addString,len(binning3Pi)-1,binning3Pi,len(binning2Pi)-1,binning2Pi) histIn.SetDrawOption('col') histIn.GetXaxis().SetTitle("Mass of the #pi^{#font[122]{-}}#pi^{#font[122]{+}}#pi^{#font[122]{-}} System (GeV/#it{c}^{2})") histIn.GetYaxis().SetTitle("Mass of the #pi^{#font[122]{+}}#pi^{#font[122]{-}} System (GeV/#it{c}^{2})") histIn.GetZaxis().SetTitle("Intensity of "+jpc+addString) histRe = TH2D("Real part of "+jpc+'_'+M+addString+"_"+tbin,"Real part of "+jpc+addString,len(binning3Pi)-1,binning3Pi,len(binning2Pi)-1,binning2Pi) histRe.SetDrawOption('col') histRe.GetXaxis().SetTitle("Mass of the #pi^{#font[122]{-}}#pi^{#font[122]{+}}#pi^{#font[122]{-}} System (GeV/#it{c}^{2})") histRe.GetYaxis().SetTitle("Mass of the #pi^{#font[122]{+}}#pi^{#font[122]{-}} System (GeV/#it{c}^{2})") histRe.GetZaxis().SetTitle("Real part of "+jpc+addString) histIm = TH2D("Imag part of "+jpc+'_'+M+addString+"_"+tbin,"Imag part of "+jpc+addString,len(binning3Pi)-1,binning3Pi,len(binning2Pi)-1,binning2Pi) histIm.SetDrawOption('col') histIm.GetXaxis().SetTitle("Mass of the #pi^{#font[122]{-}}#pi^{#font[122]{+}}#pi^{#font[122]{-}} System (GeV/#it{c}^{2})") histIm.GetYaxis().SetTitle("Mass of the #pi^{#font[122]{+}}#pi^{#font[122]{-}} System (GeV/#it{c}^{2})") histIm.GetZaxis().SetTitle("Imag part of "+jpc+addString) histPh = TH2D("Phase of "+jpc+'_'+M+addString+"_"+tbin,"Phase of "+jpc+addString,len(binning3Pi)-1,binning3Pi,len(binning2Pi)-1,binning2Pi) histPh.SetDrawOption('col') histPh.GetXaxis().SetTitle("Mass of the #pi^{#font[122]{-}}#pi^{#font[122]{+}}#pi^{#font[122]{-}} System (GeV/#it{c}^{2})") histPh.GetYaxis().SetTitle("Mass of the #pi^{#font[122]{+}}#pi^{#font[122]{-}} System (GeV/#it{c}^{2})") histPh.GetZaxis().SetTitle("Phase of "+'_'+M+jpc+addString) for i in range(0,len(dataSet[0])): if dataSet[0][i][4] == jpc and dataSet[0][i][13] == M and isobar in dataSet[0][i][14]: m2Center = (dataSet[0][i][3] + dataSet[0][i][2])/2 m3Center = (dataSet[0][i][0] + dataSet[0][i][1])/2 n2 = histIn.GetYaxis().FindBin(m2Center) n3 = histIn.GetXaxis().FindBin(m3Center) histIn.SetBinContent(n3,n2,dataSet[0][i][5]) histRe.SetBinContent(n3,n2,dataSet[0][i][7]) histIm.SetBinContent(n3,n2,dataSet[0][i][9]) histPh.SetBinContent(n3,n2,dataSet[0][i][11]) histIn.SetBinError(n3,n2,dataSet[0][i][6]) histRe.SetBinError(n3,n2,dataSet[0][i][8]) histIm.SetBinError(n3,n2,dataSet[0][i][10]) histPh.SetBinError(n3,n2,dataSet[0][i][12]) if histIn.GetBinContent(n3,n2) < suppressSigma * histIn.GetBinError(n3,n2): histIn.SetBinContent(n3,n2,0.) histIn.SetBinError(n3,n2,0.) histPh=removePhaseAmbiguities(histPh) histIn.Write() histRe.Write() histIm.Write() histPh.Write() histIn.Draw("col") # canv.Print('./pdfs/'+histIn.GetName()+".pdf") for slic in iso_slices[jpc]: minm = slic[0] maxm = slic[1] name = slic[2] for i in range(len(binning3Pi)-1): bul = binning3Pi[i+1] bll = binning3Pi[i] if bul > maxm and bll < maxm: maxb = i+1 if bul > minm and bll < minm: minb = i+1 massstring = 'm3Pi='+str(binning3Pi[minb-1])+'-'+str(binning3Pi[maxb]) slcInt=histIn.ProjectionY('slice_of_'+jpc+'_intens_'+name+"_"+tbin ,minb,maxb) slcRe =histRe.ProjectionY('slice_of_'+jpc+'_real_part_'+name+"_"+tbin,minb,maxb) slcIm =histIm.ProjectionY('slice_of_'+jpc+'_imag_part_'+name+"_"+tbin,minb,maxb) slcPha=histPh.ProjectionY('slice_of_'+jpc+'_phase_'+name+"_"+tbin ,minb,maxb) adjust_phase_range(slcPha) slcInt.Draw() # canv.Print('./pdfs/'+slcInt.GetName()+".pdf") re = [] im = [] ree= [] ime= [] for i in range(1,slcRe.GetNbinsX()+1): e = slcRe.GetBinError(i)+ slcIm.GetBinError(i) if not e==0.: re.append(slcRe.GetBinContent(i)) im.append(slcIm.GetBinContent(i)) ree.append(slcRe.GetBinError(i)) ime.append(slcIm.GetBinError(i)) if len(re)>0 and len(re) == len(im) and len(re) == len(ree) and len(re) == len(ime): while re[-1] ==0. and im[-1]==0.: # Kill the last (zero) point re = re[:-1] im = im[:-1] ree=ree[:-1] ime=ime[:-1] re= numpy.asarray(re,dtype=numpy.float64) im= numpy.asarray(im,dtype=numpy.float64) ree= numpy.asarray(ree,dtype=numpy.float64) ime= numpy.asarray(ime,dtype=numpy.float64) argand = TGraphErrors(len(re),re,im,ree,ime) argand.SetName('slice_of_'+jpc+'_argand_'+name+"_"+tbin) # argand.Write() argand.Draw('apl') # canv.Print('./pdfs/'+argand.GetName()+".pdf") argand_wrapper = TMultiGraph() argand_wrapper.SetName(argand.GetName()) argand_wrapper.Add(argand) argand_wrapper.Write() slcInt.SetTitle(massstring) slcRe.SetTitle(massstring) slcIm.SetTitle(massstring) slcPha.SetTitle(massstring) slcInt.Write() slcRe.Write() slcIm.Write() slcPha.Write() for slic in X_slices: minm = slic[0] maxm = slic[1] name = slic[2] total_list = make_f0_wavelist(minm,maxm,prefixes[jpc],suffixes[jpc]) # if name == 'f_0(1500)': # print total_list # raise Exception total_data = getTotal('/nfs/mds/user/fkrinner/massIndepententFits/fits/4tbin_deisobarred/fit/'+tbin,total_list, '/nfs/mds/user/fkrinner/massIndepententFits/fits/4tbin_deisobarred/integrals/'+tbin,normalizeToDiag=True) total_binning = [total_data[0][0]] for total_point in total_data: total_binning.append(total_point[1]) total_binning= numpy.asarray(total_binning,dtype=numpy.float64) total_mmin = total_binning[0] total_mmax = total_binning[-1] total_hist = TH1D('coherent_sum_of_'+jpc+'_'+name+'_'+tbin,'coherent_sum_of_'+jpc+'_'+name+'_'+tbin,len(total_binning)-1,total_binning) total_hist.GetXaxis().SetTitle("Mass of the #pi^{#font[122]{-}}#pi^{#font[122]{+}}#pi^{#font[122]{-}} System (GeV/#it{c}^{2})") histIn.GetZaxis().SetTitle("Intensity of "+jpc+addString) for i in range(len(total_data)): total_hist.SetBinContent(i+1,total_data[i][2]) total_hist.SetBinError(i+1,total_data[i][3]) for i in range(len(binning2Pi)-1): bul = binning2Pi[i+1] bll = binning2Pi[i] if bul > maxm and bll < maxm: maxb = i+1 if bul > minm and bll < minm: minb = i+1 massstring = 'm2Pi='+str(binning2Pi[minb-1])+'-'+str(binning2Pi[maxb]) slcInt=histIn.ProjectionX('slice_of_'+jpc+'_intens_'+name+"_"+tbin ,minb,maxb) slcRe =histRe.ProjectionX('slice_of_'+jpc+'_real_part_'+name+"_"+tbin,minb,maxb) slcIm =histIm.ProjectionX('slice_of_'+jpc+'_imag_part_'+name+"_"+tbin,minb,maxb) slcPha=histPh.ProjectionX('slice_of_'+jpc+'_phase_'+name+"_"+tbin ,minb,maxb) slcInt.SetTitle(massstring) slcRe.SetTitle(massstring) slcIm.SetTitle(massstring) slcPha.SetTitle(massstring) total_hist.SetTitle(massstring) slcInt.Write() slcRe.Write() slcIm.Write() slcPha.Write() total_hist.Write() slcInt.Draw() # canv.Print('./pdfs/'+slcInt.GetName()+".pdf") if not sumintens.has_key(name+"_"+jpc): sumintens[name+"_"+jpc] = slcInt sumintens[name+"_"+jpc].SetName('incoherent_sum_'+jpc+'_'+name) else: sumintens[name+"_"+jpc].Add(slcInt) for key in sumintens.iterkeys(): sumintens[key].Write() sumintens[key].Draw() # canv.Print('./pdfs/'+sumintens[key].GetName()+".pdf") outROOT.close() print "ran with no exceptions"
def energylinearity(): outputfile = "EMLinearityEnergyRes" displayfile = TFile(outputfile + ".root", "RECREATE") MeanEnergyScin = array('d') MeanEnergyCher = array('d') MeanEnergy = array('d') resolutionscin = array('d') resolutioncher = array('d') resolution = array('d') towers = array('d') ##inputfiles = sorted(glob.glob(datapath+"*"), key=os.path.getmtime) #get files from tower 1 to 75 ordered by creation time inputfiles = [ "/home/software/Calo/results/newresults/barrel2/Barrel_" + str(i) + ".root" for i in range(1, 76) ] #inputfiles = ["/home/software/Calo/results/NewTowerScan4/Barrel_"+str(i)+".root" for i in range(1,76)] #inputfiles = ["/home/lorenzo/Desktop/Calo/results/NewTowerScan4/Barrel_"+str(i)+".root" for i in range(1,76)] for counter, inputfile in enumerate(inputfiles): inputfile = TFile(inputfile) print "Analyzing: " + str(inputfile) + " \n" tree = TTree() inputfile.GetObject("B4", tree) ScinEnergyHist = TH1F("scinenergy_", str(counter + 1) + "_scin", 200, 0., 100.) CherEnergyHist = TH1F("cherenergy_", str(counter + 1) + "_cher", 200, 0., 100.) RecEnergyHist = TH1F("RecEnergy_", str(counter + 1) + "_Energy", 200, 0., 100.) Energytot = 0.0 energy = 40.0 sqrtenergy = 1 / (40.0**0.5) towers.append(counter + 1.) #loop over events for Event in range(int(tree.GetEntries())): tree.GetEntry(Event) #Set values of the tree PrimaryParticleName = tree.PrimaryParticleName # MC truth: primary particle Geant4 name PrimaryParticleEnergy = tree.PrimaryParticleEnergy EnergyTot = tree.EnergyTot # Total energy deposited in calorimeter Energyem = tree.Energyem # Energy deposited by the em component EnergyScin = tree.EnergyScin # Energy deposited in Scin fibers (not Birk corrected) EnergyCher = tree.EnergyCher # Energy deposited in Cher fibers (not Birk corrected) NofCherenkovDetected = tree.NofCherenkovDetected # Total Cher p.e. detected BarrelR_VectorSignals = tree.VectorSignalsR # Vector of energy deposited in Scin fibers (Birk corrected) BarrelL_VectorSignals = tree.VectorSignalsL # Vector of energy deposited in Scin fibers (Birk corrected) BarrelR_VectorSignalsCher = tree.VectorSignalsCherR # Vector of Cher p.e. detected in Cher fibers BarrelL_VectorSignalsCher = tree.VectorSignalsCherL VectorR = tree.VectorR VectorL = tree.VectorL #apply calibrations Calib_BarrelL_VectorSignals = calibration2.calibscin( BarrelL_VectorSignals) Calib_BarrelR_VectorSignals = calibration2.calibscin( BarrelR_VectorSignals) Calib_BarrelL_VectorSignalsCher = calibration2.calibcher( BarrelL_VectorSignalsCher) Calib_BarrelR_VectorSignalsCher = calibration2.calibcher( BarrelR_VectorSignalsCher) #end of calibrations energyscin = sum(Calib_BarrelR_VectorSignals) + sum( Calib_BarrelL_VectorSignals) energycher = sum(Calib_BarrelR_VectorSignalsCher) + sum( Calib_BarrelL_VectorSignalsCher) ScinEnergyHist.Fill(energyscin) CherEnergyHist.Fill(energycher) #sigmascin = 0.15*(energyscin**0.5)+0.012*energyscin #old value #sigmacher = 0.18*(energycher**0.5)+0.0045*energycher #old value sigmascin = 0.177 * (energyscin**0.5) + 0.006 * energyscin sigmacher = 0.194 * (energycher**0.5) + 0.001 * energycher RecEnergyHist.Fill( (energyscin / (sigmascin**2) + energycher / (sigmacher**2)) / (1 / sigmascin**2 + 1 / sigmacher**2)) #RecEnergyHist.Fill((energyscin+energycher)/2) Energytot += (sum(VectorL) + sum(VectorR)) / 1000 Energytot = Energytot / int(tree.GetEntries()) print Energytot, ScinEnergyHist.GetMean(), CherEnergyHist.GetMean() displayfile.cd() gStyle.SetOptStat(111) ScinEnergyHist.Fit("gaus") CherEnergyHist.Fit("gaus") RecEnergyHist.Fit("gaus") RecEnergyHist.Write() ScinEnergyHist.Write() CherEnergyHist.Write() #MeanEnergyScin.append(ScinEnergyHist.GetFunction("gaus").GetParameter(1)/Energytot) MeanEnergyScin.append(ScinEnergyHist.GetMean() / energy) #MeanEnergyCher.append(CherEnergyHist.GetFunction("gaus").GetParameter(1)/Energytot) MeanEnergyCher.append(CherEnergyHist.GetMean() / energy) MeanEnergy.append( RecEnergyHist.GetFunction("gaus").GetParameter(1) / energy) resolution.append( RecEnergyHist.GetFunction("gaus").GetParameter(2) / RecEnergyHist.GetFunction("gaus").GetParameter(1)) resolutionscin.append( ScinEnergyHist.GetFunction("gaus").GetParameter(2) / ScinEnergyHist.GetFunction("gaus").GetParameter(1)) resolutioncher.append( CherEnergyHist.GetFunction("gaus").GetParameter(2) / CherEnergyHist.GetFunction("gaus").GetParameter(1)) print MeanEnergyScin, MeanEnergyCher LinearityGraph = TGraph(len(towers), towers, MeanEnergy) LinearityGraph.SetName("LinearityGraph") LinearityGraph.Write() LinearityGraphScin = TGraph(len(towers), towers, MeanEnergyScin) LinearityGraphCher = TGraph(len(towers), towers, MeanEnergyCher) LinearityGraphCher.SetName("LinearityGraphCher") LinearityGraphCher.Write() LinearityGraphScin.SetName("LinearityGraphScin") LinearityGraphScin.Write() ResolutionGraphScin = TGraph(len(towers), towers, resolutionscin) ResolutionGraphCher = TGraph(len(towers), towers, resolutioncher) ResolutionGraphScin.SetName("ResolutionGraphScin") ResolutionGraphScin.Write() ResolutionGraphCher.SetName("ResolutionGraphCher") ResolutionGraphCher.Write() ResolutionGraph = TGraph(len(towers), towers, resolution) ResolutionGraph.SetName("ResolutionGraph") ResolutionGraph.Write() x2 = array('d', (0., 90., 90., 0.)) y2 = array('d', (0.024, 0.024, 0.034, 0.034)) Fillgraph2 = TGraph(4, x2, y2) Fillgraph2.SetName("ban") Fillgraph2.Write() linefill1 = TF1("1", str(1.0), 0., 90.) linefill1.Write() EMResolutions = TMultiGraph() EMResolutions.Add(ResolutionGraphScin) EMResolutions.Add(ResolutionGraphCher) EMResolutions.Add(ResolutionGraph) EMResolutions.SetName("EMResolutions") EMResolutions.Write() Linearities = TMultiGraph() Linearities.Add(LinearityGraph) Linearities.Add(LinearityGraphScin) Linearities.Add(LinearityGraphCher) Linearities.SetName("Linearities") Linearities.Write()
MGElastic.Draw("al*") canvas.SetLogy() MGElastic.Draw() #if MGElastic.GetListOfGraphs().GetEntries() < 10: legendElastic.Draw() canvas.SaveAs("aa_ElasticBatch.png") MGInElastic.Draw("al*") #canvas.SetLogy() MGInElastic.Draw() #if MGInElastic.GetListOfGraphs().GetEntries() < 10: legendInElastic.Draw() canvas.SaveAs("aa_InElasticBatch.png") outFile = TFile("Batch.root","recreate") MGElastic.Write() MGInElastic.Write() couOnlyFile = TFile("../coulombOnly.root","read") if couOnlyFile: couOnlyGraph = couOnlyFile.Get("G1") if couOnlyGraph: couOnlyGraph.SetMarkerColor(ROOT.kWhite) couOnlyGraph.SetLineColor(ROOT.kMagenta) couOnlyGraph.SetFillColor(ROOT.kWhite) couOnlyGraph.SetLineWidth(5) couOnlyGraph.SetLineStyle(5) MGElastic.Add(couOnlyGraph,"L") legendElastic.AddEntry(couOnlyGraph,"Coulomb Only") MGElastic.Draw("al*")
def MakePlot(PlotList, name): canvas = TCanvas('canvas', 'shouldnotseethis', 0, 0, 1280, 720) colors = [ROOT.kRed, ROOT.kBlue, ROOT.kGreen, ROOT.kCyan, ROOT.kMagenta] # ROOT.kOrange+1, MG = TMultiGraph() MG.SetTitle( "Best Fits per Chi Square;Center of Mass Angle in Degrees;Cross Section in mb/sr" ) MG.SetTitle("MG") MG.SetName(name) legend = ROOT.TLegend(0.3, .65, .9, .9) # if len(PlotList) >6: # PlotList = PlotList[:6] # print "Cutting PlotList length for {}".format(name) # Zipper = zip(PlotList, colors) # # MG.Add(dataG,"P") # legend.AddEntry(dataG,"Data") i = 2 for bigInfo, color in Zipper: if len(Zipper) == 1: color = ROOT.kBlack plot = bigInfo[-1] plot.SetMarkerColor(ROOT.kWhite) plot.SetLineColor(color) plot.SetFillColor(ROOT.kWhite) plot.SetLineWidth(2) if len(Zipper) > 1: plot.SetLineStyle(i) i += 1 MG.Add(plot, "L") legend.AddEntry( plot, "chiSquare(" + str(int(bigInfo[0])) + ")_" + plot.GetName()) dataPlot = bigInfo[-2] dataPlot.SetMarkerColor(ROOT.TColor.GetColorDark(color)) dataPlot.SetLineColor(ROOT.TColor.GetColorDark(color)) dataPlot.SetFillColor(ROOT.kWhite) MG.Add(dataPlot, "P") legend.AddEntry( dataPlot, "data_chiSquare(" + str(int(bigInfo[0])) + ")_" + plot.GetName()) if len(PlotList) < 4: blurPlot = bigInfo[-3] blurPlot.SetMarkerColor(color) blurPlot.SetLineColor(color) blurPlot.SetLineStyle(2) blurPlot.SetLineWidth(2) blurPlot.SetFillColor(ROOT.kWhite) # print blurPlot.GetName() # blurPlot.Print() MG.Add(blurPlot, "L") legend.AddEntry(blurPlot, "Blurred Fresco Output") MG.Draw("AL") canvas.SetLogy() MG.GetXaxis().SetTitle("Center of Mass Angle in Degrees") MG.GetYaxis().SetTitle("Cross Section in mb/sr") MG.Draw() legend.Draw() outF.cd() MG.Write() canvas.SaveAs("pngs/{}.png".format(name))
def recenergy(): outputfile = "EMEnergyRes" displayfile = TFile(outputfile + ".root", "RECREATE") MeanEnergyScin = array('d') MeanEnergyCher = array('d') Energy = array('d') energyfractionscin = array('d') energyfractioncher = array('d') energyfraction = array('d') resolutionscin = array('d') resolutioncher = array('d') resolution = array('d') energies = array( 'd', [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) energies = array('d', [40, 50, 60, 70, 80, 90, 100]) energies = array('d', [5, 10, 40, 60, 80, 100, 150]) sqrtenergies = array('d', [1 / (x**0.5) for x in energies]) scin_sqrtenergies = array('d') cher_sqrtenergies = array('d') #inputfiles = sorted(glob.glob(datapath+"*"), key=os.path.getmtime) #get files from tower 1 to 75 ordered by creation time t = [5, 10, 40, 60, 80, 100, 150] inputfiles = [ "/home/software/Calo/results/newenergyscan3_noangsmearing/Electron_" + str(i) + ".root" for i in t ] for counter, inputfile in enumerate(inputfiles): inputfile = TFile(inputfile) print "Analyzing: " + str(inputfile) + " \n" tree = TTree() inputfile.GetObject("B4", tree) ScinEnergyHist = TH1F("scinenergy_", str(counter + 1) + "_scin", 500, 0., 200.) CherEnergyHist = TH1F("cherenergy_", str(counter + 1) + "_cher", 500, 0., 200.) RecEnergyHist = TH1F("RecEnergy_", str(counter + 1) + "_Energy", 500, 0., 200.) Signalscinhist = TH1F("scintot_", str(counter + 1) + "_scin", 3000, 0., 30000) EnergyHist = TH1F("Energy_", str(counter + 1) + "_Energy", 500, 0., 200.) #loop over events for Event in range(int(tree.GetEntries())): tree.GetEntry(Event) #Set values of the tree PrimaryParticleName = tree.PrimaryParticleName # MC truth: primary particle Geant4 name PrimaryParticleEnergy = tree.PrimaryParticleEnergy EnergyTot = tree.EnergyTot # Total energy deposited in calorimeter Energyem = tree.Energyem # Energy deposited by the em component EnergyScin = tree.EnergyScin # Energy deposited in Scin fibers (not Birk corrected) EnergyCher = tree.EnergyCher # Energy deposited in Cher fibers (not Birk corrected) NofCherenkovDetected = tree.NofCherenkovDetected # Total Cher p.e. detected BarrelR_VectorSignals = tree.VectorSignalsR # Vector of energy deposited in Scin fibers (Birk corrected) BarrelL_VectorSignals = tree.VectorSignalsL # Vector of energy deposited in Scin fibers (Birk corrected) BarrelR_VectorSignalsCher = tree.VectorSignalsCherR # Vector of Cher p.e. detected in Cher fibers BarrelL_VectorSignalsCher = tree.VectorSignalsCherL VectorR = tree.VectorR VectorL = tree.VectorL totalsignalscin = sum(BarrelR_VectorSignals) + sum( BarrelL_VectorSignals) Signalscinhist.Fill(totalsignalscin) energytot = (sum(VectorR) + sum(VectorL)) / 1000 EnergyHist.Fill(energytot) #apply calibrations Calib_BarrelL_VectorSignals = calibration.calibscin( BarrelL_VectorSignals) Calib_BarrelR_VectorSignals = calibration.calibscin( BarrelR_VectorSignals) Calib_BarrelL_VectorSignalsCher = calibration.calibcher( BarrelL_VectorSignalsCher) Calib_BarrelR_VectorSignalsCher = calibration.calibcher( BarrelR_VectorSignalsCher) #end of calibrations energyscin = sum(Calib_BarrelR_VectorSignals) + sum( Calib_BarrelL_VectorSignals) energycher = sum(Calib_BarrelR_VectorSignalsCher) + sum( Calib_BarrelL_VectorSignalsCher) ScinEnergyHist.Fill(energyscin) sigmascin = 0.15 * (energyscin**0.5) + 0.012 * energyscin CherEnergyHist.Fill(energycher) sigmacher = 0.18 * (energycher**0.5) + 0.0045 * energycher RecEnergyHist.Fill( (energyscin / (sigmascin**2) + energycher / (sigmacher**2)) / (1 / sigmascin**2 + 1 / sigmacher**2)) print energies[counter], ScinEnergyHist.GetMean( ), CherEnergyHist.GetMean() displayfile.cd() gStyle.SetOptStat(111) ScinEnergyHist.Fit("gaus") CherEnergyHist.Fit("gaus") RecEnergyHist.Fit("gaus") RecEnergyHist.Write() ScinEnergyHist.Write() CherEnergyHist.Write() Signalscinhist.Write() EnergyHist.Write() scin_sqrtenergies.append( 1. / (ScinEnergyHist.GetFunction("gaus").GetParameter(1)**0.5)) cher_sqrtenergies.append( 1. / (CherEnergyHist.GetFunction("gaus").GetParameter(1)**0.5)) MeanEnergyScin.append( ScinEnergyHist.GetFunction("gaus").GetParameter(1)) MeanEnergyCher.append( CherEnergyHist.GetFunction("gaus").GetParameter(1)) resolution.append( RecEnergyHist.GetFunction("gaus").GetParameter(2) / RecEnergyHist.GetFunction("gaus").GetParameter(1)) energyfractionscin.append( ScinEnergyHist.GetFunction("gaus").GetParameter(1)) energyfractioncher.append( CherEnergyHist.GetFunction("gaus").GetParameter(1)) energyfraction.append( RecEnergyHist.GetFunction("gaus").GetParameter(1)) resolutionscin.append( ScinEnergyHist.GetFunction("gaus").GetParameter(2) / ScinEnergyHist.GetFunction("gaus").GetParameter(1)) resolutioncher.append( CherEnergyHist.GetFunction("gaus").GetParameter(2) / CherEnergyHist.GetFunction("gaus").GetParameter(1)) LinearityGraph = TGraph(len(energies), energies, energyfraction) LinearityGraph.SetName("LinearityGraph") LinearityGraph.Write() LinearityGraphScin = TGraph(len(energies), energies, energyfractionscin) LinearityGraphCher = TGraph(len(energies), energies, energyfractioncher) LinearityGraphCher.SetName("LinearityGraphCher") LinearityGraphCher.Write() LinearityGraphScin.SetName("LinearityGraphScin") LinearityGraphScin.Write() ResolutionGraphScin = TGraph(len(energies), scin_sqrtenergies, resolutionscin) func = TF1("func", "[0]*x+[1]", 0.1, 0.45) ResolutionGraphCher = TGraph(len(energies), cher_sqrtenergies, resolutioncher) ResolutionGraphScin.Fit("func", "R") ResolutionGraphCher.Fit("func", "R") ResolutionGraphScin.SetName("ResolutionGraphScin") ResolutionGraphScin.Write() ResolutionGraphCher.SetName("ResolutionGraphCher") ResolutionGraphCher.Write() ResolutionGraph = TGraph(len(energies), sqrtenergies, resolution) ResolutionGraph.Fit("func", "R") ResolutionGraph.SetName("ResolutionGraph") ResolutionGraph.Write() rd52copper = array('d', [ 0.04478505426185217, 0.027392527130926082, 0.02420093893609386, 0.02229837387624884, 0.020999999999999998 ]) rd52graph = TGraph(len(energies), sqrtenergies, rd52copper) rd52graph.SetName("rd52resolution") rd52graph.Write() EMResolutions = TMultiGraph() EMResolutions.Add(ResolutionGraphScin) EMResolutions.Add(ResolutionGraphCher) EMResolutions.Add(ResolutionGraph) EMResolutions.Add(rd52graph) EMResolutions.SetName("EMResolutions") EMResolutions.Write() Linearities = TMultiGraph() Linearities.Add(LinearityGraph) Linearities.Add(LinearityGraphScin) Linearities.Add(LinearityGraphCher) Linearities.SetName("Linearities") Linearities.Write()
def combinedDraw(frescoGraph, goodPID, badPID, goodCORR, badCORR): #print "combinedDraw start" canvas = TCanvas('canvas', 'shouldnotseethis', 0, 0, 1280, 720) MG = TMultiGraph() legend = ROOT.TLegend(0.55, .55, .9, .9) ##legend.SetBorderSize(0) #underHisto.SetLineColor(ROOT.kBlack) #underHisto.SetMinimum(0) ##underHisto.SetMaximum(underHisto.GetMaximum() * 1.5) #underHisto.GetXaxis().SetRangeUser(0,180) #underHisto.SetTitle(title) #underHisto.SetLineColor(ROOT.kBlack) #underHisto.SetTitle(title) #underHisto.GetYaxis().SetTitle("Counts in Arb. Units") #legend.AddEntry(underHisto,"Simulated Angular Distribution") #underHisto.SetStats(ROOT.kFALSE) #underHisto.Draw() if frescoGraph: #print "frescoGraph" frescoGraph.SetMarkerColor(ROOT.kBlack) frescoGraph.SetLineColor(ROOT.kBlack) frescoGraph.SetFillColor(ROOT.kBlack) #frescoGraph.SetMarkerStyle(33) MG.Add(frescoGraph, "L") legend.AddEntry(frescoGraph, "Fresco Output") else: print "No FrescoGraph!!!" return if goodPID: #print "goodPID" goodPID.SetMarkerColor(ROOT.kGreen) goodPID.SetLineColor(ROOT.kGreen) goodPID.SetFillColor(ROOT.kGreen) #goodPID.SetMarkerStyle(33) MG.Add(goodPID, "P") legend.AddEntry(goodPID, "ScaledPID") else: print "No goodPID in Draw()" if goodCORR: #print "goodCORR" goodCORR.SetMarkerColor(TColor.GetColorDark(ROOT.kGreen)) goodCORR.SetLineColor(TColor.GetColorDark(ROOT.kGreen)) goodCORR.SetFillColor(TColor.GetColorDark(ROOT.kGreen)) goodCORR.SetMarkerStyle(21) #afterHisto.Draw("PLsame") MG.Add(goodCORR, "P") legend.AddEntry(goodCORR, "Good Dual Det") else: print "No goodCORR in Draw()" if badPID: #print "badPID" badPID.SetMarkerColor(ROOT.kRed) badPID.SetLineColor(ROOT.kRed) badPID.SetFillColor(ROOT.kRed) badPID.SetMarkerStyle(33) MG.Add(badPID, "P") legend.AddEntry(badPID, "Discard PID") else: print "No badPID in Draw()" if badCORR: #print "badCORR" badCORR.SetMarkerColor(TColor.GetColorDark(ROOT.kRed)) badCORR.SetLineColor(TColor.GetColorDark(ROOT.kRed)) badCORR.SetFillColor(TColor.GetColorDark(ROOT.kRed)) badCORR.SetMarkerStyle(21) MG.Add(badCORR, "P") legend.AddEntry(badCORR, "Discard Dual Det") else: print "No badCORR in Draw()" MG.SetTitle( "Scaled Elastic Distribution for detector {};Center of Mass Angle in Degrees;Cross section in mb/sr" .format(det)) MG.SetName("MG_d{}".format(det)) MG.Draw("AP") legend.Draw() MG.Write() MG.SetMaximum(500) MG.SetMinimum(0) canvas.SetLogy() #MG.GetYaxis().SetRangeUser(0,500) MG.Draw() canvas.SaveAs(MG.GetName() + '.png')