Exemple #1
0
def create_fastgraph2(xs, ys):
	"""Function to perform ROOT graph"""

	#How many graph points
	n = len(xs)

	TGraph2 = TGraph(n, xs, ys)
	
	#Draw + DrawOptions, Fit + parameter estimation
	Style = gStyle
	XAxis = TGraph2.GetXaxis() #TGraphfasthescin
	TGraph2.SetMarkerColor(4)
	TGraph2.SetMarkerStyle(20)
	TGraph2.SetMarkerSize(1)
	XAxis.SetLimits(0.,0.6)
	XAxis.SetTitle("")
	YAxis = TGraph2.GetYaxis()
	YAxis.SetTitle("")
	TGraph2.Draw("ACP")
	gPad.SaveAs("Fastgraph.pdf")
	gPad.Close()
Exemple #2
0
def create_sixthroothistograms(SecondCombinedEnergy):
	"""Function to perform ROOT histograms"""
	
	#Set ROOT histograms
	TH1SecondCombinedEnergy = TH1F("Second Comb Energy","",100,0.0, np.mean(SecondCombinedEnergy)*2)

	#Fill histograms in for loop
	for Event in range(len(SecondCombinedEnergy)):
		TH1SecondCombinedEnergy.Fill(SecondCombinedEnergy[Event])

	#Draw + DrawOptions histograms		
	Style = gStyle
	Style.SetLineWidth(1) #TH1TraditionalCherEnergy
	Style.SetOptStat(1) #Show statistics
	XAxis = TH1SecondCombinedEnergy.GetXaxis()
	XAxis.SetTitle("Energy (MeV)")
	YAxis = TH1SecondCombinedEnergy.GetYaxis()
	YAxis.SetTitle("# events")
	TH1SecondCombinedEnergy.Draw()
	gPad.SaveAs("SecondCombinedEnergy.pdf")
	gPad.Close()
Exemple #3
0
    #basedir = "../FastZDC"
    #infile = "FastZDC.root"

    basedir = "../../../star-upc-data/ana/FastZDC/STnOOn_eta1p2_1Mevt"
    #infile = "FastZDC_HCal.root"
    #infile = "FastZDC_Grupen.root"
    #infile = "FastZDC_HCal_run16.root"
    infile = "FastZDC_Grupen_run16.root"

    #basedir = "../../../star-upc-data/ana/uTrees"
    #infile = "xuTp_run16_zdc_us.root"

    interactive = False

    if interactive == False: gROOT.SetBatch()
    gStyle.SetPadTickX(1)
    gStyle.SetFrameLineWidth(2)

    inp = TFile.Open(basedir + "/" + infile)
    tree = inp.Get("jRecTree")
    #tree = inp.Get("Tp")

    make_fit()

    #to prevent 'pure virtual method called'
    gPad.Close()

    #beep when finished
    gSystem.Exec("mplayer ../computerbeep_1.mp3 > /dev/null 2>&1")
Exemple #4
0
def write_rootgraph(vectorx, vectory, graphtitle, xtitle, ytitle,
                    sectorscurrents, rootdirectory):
    """Function to perform ROOT graph"""

    arrayx = array('d')
    arrayy = array('d')

    for x in vectorx:
        arrayx.append(x)

    for y in vectory:
        arrayy.append(y)

    #How many graph points
    n = len(vectorx)

    MyTGraph = TGraph(n, arrayx, arrayy)
    MyTGraph.SetName(graphtitle)

    if ytitle == "i":
        ytitle = ytitle + " (uA)"
        color = 2
        offset = 1.
        minimum = -0.5
        maximum = int(np.max(vectory) + 1.5)
        lineup = TLine(float(np.min(vectorx)), 500, float(np.max(vectorx)),
                       500)
        lineup.SetLineColor(2)
        lineup.SetLineStyle(2)
        linedown = TLine(float(np.min(vectorx)), 500., float(np.max(vectorx)),
                         500.)
        linedown.SetLineColor(8)
        linedown.SetLineStyle(2)
        for entry in range(len(sectorscurrents)):
            if vectory[entry] > 0.01:
                latex = TLatex(MyTGraph.GetX()[entry],
                               MyTGraph.GetY()[entry], sectorscurrents[entry])
                latex.SetTextSize(0.02)
                MyTGraph.GetListOfFunctions().Add(latex)
            else:
                latex = TLatex(MyTGraph.GetX()[entry],
                               MyTGraph.GetY()[entry], "")
                latex.SetTextSize(0.02)
                MyTGraph.GetListOfFunctions().Add(latex)

    if ytitle == "v":
        ytitle = ytitle + " (V)"
        color = 4
        offset = 0.9
        minimum = 400
        maximum = 600
        lineup = TLine(float(np.min(vectorx)), 580., float(np.max(vectorx)),
                       580.)
        lineup.SetLineColor(2)
        lineup.SetLineStyle(2)
        linedown = TLine(float(np.min(vectorx)), 530., float(np.max(vectorx)),
                         530.)
        linedown.SetLineColor(8)
        linedown.SetLineStyle(2)

        for entry in range(len(sectorscurrents)):
            if vectory[entry] > 569.0:
                latex = TLatex(MyTGraph.GetX()[entry],
                               MyTGraph.GetY()[entry], "")
            else:
                latex = TLatex(MyTGraph.GetX()[entry],
                               MyTGraph.GetY()[entry], sectorscurrents[entry])
            latex.SetTextSize(0.02)
            MyTGraph.GetListOfFunctions().Add(latex)

    #Draw + DrawOptions
    Style = gStyle
    Style.SetPadLeftMargin(2.0)
    XAxis = MyTGraph.GetXaxis()  #TGraphfasthescin
    #XAxis.SetTitleOffset(offset)
    XAxis.SetTitle(xtitle)
    MyTGraph.SetMarkerColor(color)
    MyTGraph.SetMarkerStyle(1)
    MyTGraph.SetMarkerSize(1)
    MyTGraph.SetLineColor(color)
    MyTGraph.SetTitle(graphtitle)
    #XAxis.SetTitle(xtitle)
    YAxis = MyTGraph.GetYaxis()
    YAxis.SetTitleOffset(offset)
    YAxis.SetTitle(ytitle)
    MyTGraph.GetHistogram().SetMinimum(minimum)
    MyTGraph.GetHistogram().SetMaximum(maximum)
    rootdirectory.WriteTObject(MyTGraph)
    c = TCanvas()
    c.SetName(graphtitle + "_canvas")
    MyTGraph.Draw("APL")
    lineup.Draw("")
    linedown.Draw("")
    rootdirectory.WriteTObject(c)

    #MyTGraph.Write(graphtitle)
    MyTGraph.Draw("APL")
    #gPad.SaveAs("current-"+graphtitle+".pdf")
    gPad.Close()
Exemple #5
0
def write_rootdategraph_plusatten(vectorx, vectory, vectory2, graphtitle,
                                  xtitle, ytitle, rootdirectory):
    '''plot graph current + source'''

    arrayx = array('d')
    arrayy = array('d')
    arrayy2 = array('d')

    for x in vectorx:
        arrayx.append(x.Convert())

    for y in vectory:
        arrayy.append(y)

    for y2 in vectory2:
        arrayy2.append(y2)

    if ytitle[0] == "i":
        ytitle = ytitle + " (uA) "
        color = 2
        offset = 1.
        minimum = -1
        maximum = int(np.max(vectory) + 1.5)
        if maximum > 10:
            maximum = int(10)

    if ytitle == "v":
        ytitle = ytitle + " (V)"
        color = 4
        offset = 0.9
        minimum = 400
        maximum = 600
    c = TCanvas(graphtitle + "_canvas")
    pad1 = TPad("pad1", "", 0, 0, 1, 1)
    pad2 = TPad("pad2", "", 0, 0, 1, 1)
    pad2.SetFillStyle(4000)
    pad2.SetFrameFillStyle(0)

    #How many graph points
    n = len(vectorx)

    MyTGraph = TGraph(n, arrayx, arrayy)
    MyTGraph.SetName(graphtitle)

    MyTGraph2 = TGraph(n, arrayx, arrayy2)

    #Draw + DrawOptions

    Style = gStyle
    Style.SetPadLeftMargin(2.0)
    XAxis = MyTGraph.GetXaxis()  #TGraphfasthescin
    XAxis.SetTimeDisplay(1)
    XAxis.SetTimeFormat("#splitline{%d/%m}{%H:%M}")
    XAxis.SetLabelOffset(0.025)
    MyTGraph.SetMarkerColor(color)
    MyTGraph.SetMarkerStyle(1)
    MyTGraph.SetMarkerSize(1)
    MyTGraph.SetLineColor(color)
    MyTGraph.SetTitle(graphtitle + " V")
    #XAxis.SetTitle(xtitle)
    YAxis = MyTGraph.GetYaxis()
    YAxis.SetTitleOffset(offset)
    YAxis.SetTitleOffset(offset)
    YAxis.SetTitleColor(2)
    YAxis.SetTitle(ytitle)
    MyTGraph.GetHistogram().SetMinimum(-1.)
    MyTGraph.GetHistogram().SetMaximum(
        23.)  #modified to have also attenuation 22 displayed
    #MyTGraph.Draw("APL")
    MyTGraph2.SetMarkerColor(4)
    MyTGraph2.SetMarkerStyle(1)
    MyTGraph2.SetMarkerSize(1)
    MyTGraph2.SetLineColor(4)
    MyTGraph2.SetLineStyle(7)
    MyTGraph2.GetHistogram().SetMinimum(-1.)
    MyTGraph2.GetHistogram().SetMaximum(23.)
    MyTGraph2.GetXaxis().SetLabelSize(0)
    MyTGraph2.GetXaxis().SetNdivisions(0)
    MyTGraph2.GetYaxis().SetTitle("Attenuation factor")
    MyTGraph2.GetYaxis().SetTitleOffset(offset)
    MyTGraph2.GetYaxis().SetTitleColor(4)
    MyTGraph2.SetTitle("")

    pad1.Draw()
    pad1.cd()
    MyTGraph.Draw("APL")

    pad2.Draw()
    pad2.cd()
    #MyTGraph2.SetMarkerColor(4)
    MyTGraph2.Draw("APLY+")
    #MyTGraph2.Draw("same")

    rootdirectory.WriteTObject(c)
    #MyTGraph.Write(graphtitle)
    #MyTGraph.Draw("APL")
    if "D" not in graphtitle:
        c.SaveAs("GIF-" + graphtitle[0:9] + ".pdf")
    gPad.Close()
Exemple #6
0
def write_rootdategraph_fromgif(vectorx, vectory, graphtitle, xtitle, ytitle,
                                rootdirectory):
    """Function to perform ROOT graph"""

    arrayx = array('d')
    arrayy = array('d')

    for x in vectorx:
        arrayx.append(x.Convert())

    for y in vectory:
        arrayy.append(y)

    if ytitle == "i":
        ytitle = ytitle + " (uA)"
        color = 2
        offset = 1.
        minimum = -1
        maximum = int(np.max(vectory) + 1.5)
        if maximum > 10:
            maximum = int(maximum)

    if ytitle == "v":
        ytitle = ytitle + " (V)"
        color = 4
        offset = 0.9
        minimum = 400
        maximum = 600

    #How many graph points
    n = len(vectorx)

    MyTGraph = TGraph(n, arrayx, arrayy)
    MyTGraph.SetName(graphtitle)

    #Draw + DrawOptions
    c = TCanvas()
    Style = gStyle
    Style.SetPadLeftMargin(2.0)
    XAxis = MyTGraph.GetXaxis()  #TGraphfasthescin
    XAxis.SetTimeDisplay(1)
    XAxis.SetTimeFormat("#splitline{%d/%m}{%H:%M:%S}")
    XAxis.SetLabelOffset(0.025)
    MyTGraph.SetMarkerColor(color)
    MyTGraph.SetMarkerStyle(1)
    MyTGraph.SetMarkerSize(1)
    MyTGraph.SetLineColor(color)
    MyTGraph.SetTitle(graphtitle)
    #XAxis.SetTitle(xtitle)
    YAxis = MyTGraph.GetYaxis()
    YAxis.SetTitleOffset(offset)
    YAxis.SetTitleOffset(offset)
    YAxis.SetTitle(ytitle)
    MyTGraph.GetHistogram().SetMinimum(minimum)
    MyTGraph.GetHistogram().SetMaximum(maximum)
    MyTGraph.Draw("APL")
    rootdirectory.WriteTObject(MyTGraph)
    #MyTGraph.Write(graphtitle)
    MyTGraph.Draw("APL")
    if "D" not in graphtitle:
        gPad.SaveAs("GIF-" + graphtitle + ".pdf")
    gPad.Close()
Exemple #7
0
def create_fastgrapherror(Fastscinenergy, Fastcherenergy, rmsScin, rmsCher, fem, rmsfem, PrimaryParticleEnergy):
	"""Function to perform ROOT graphs and compute he values"""

	#How many graph points
	n = len(Fastscinenergy)

	TGraphfasthescin = TGraphErrors(n, fem, Fastscinenergy, rmsfem, rmsScin)
	TGraphfasthecher = TGraphErrors(n, fem, Fastcherenergy, rmsfem, rmsCher)
	
	#Draw + DrawOptions, Fit + parameter estimation
	Style = gStyle
	Style.SetOptFit(1)
	Style.SetOptStat(0) #Do not show statistics
	XAxis = TGraphfasthescin.GetXaxis() #TGraphfasthescin
	TGraphfasthescin.SetMarkerColor(4)
	TGraphfasthescin.SetMarkerStyle(1)
	TGraphfasthescin.SetMarkerSize(1)
	XAxis.SetTitle("fem")
	XAxis.SetLimits(0.0,1.0)
	YAxis = TGraphfasthescin.GetYaxis()
	YAxis.SetTitle("Energy scin (MeV)")
	YAxis.SetRange(int(0.0),int(float(PrimaryParticleEnergy)+10000.0))
	TGraphfasthescin.Fit("pol1")
	myfit = TGraphfasthescin.GetFunction("pol1")
	Fasthescin = myfit.GetParameter(0)/PrimaryParticleEnergy    
	Fasthescinerror = myfit.GetParError(0)/PrimaryParticleEnergy 
	Fasthescin2 = (PrimaryParticleEnergy - myfit.GetParameter(1))/PrimaryParticleEnergy
	TGraphfasthescin.SetTitle("")
	TGraphfasthescin.Draw("AP")
	gPad.SaveAs("Fasthescin-pol1fit.pdf")
	gPad.Close()
	combinedfit = TF1("combinedfit", '(x)*([1]-[0]*[1])+[0]*[1]', 0, max(fem))
	combinedfit.FixParameter(1, PrimaryParticleEnergy)
	TGraphfasthescin.Fit("combinedfit")
	hes = combinedfit.GetParameter(0)   
	heserror = combinedfit.GetParError(0)          
	TGraphfasthescin.Draw("AP")
	gPad.SaveAs("Fasthescin.pdf")
	gPad.Close()
	XAxis = TGraphfasthecher.GetXaxis() #TGraphfasthecher
	TGraphfasthecher.SetMarkerColor(4)
	TGraphfasthecher.SetMarkerStyle(1)
	TGraphfasthecher.SetMarkerSize(1)
	XAxis.SetTitle("fem")
	XAxis.SetLimits(0.0,1.0)
	YAxis = TGraphfasthecher.GetYaxis()
	YAxis.SetTitle("Energy Cher (MeV)")
	YAxis.SetRange(int(0.0),int(float(PrimaryParticleEnergy)+10000.0))
	TGraphfasthecher.Fit("pol1")
	myfit = TGraphfasthecher.GetFunction("pol1")
	Fasthecher = myfit.GetParameter(0)/PrimaryParticleEnergy
	Fasthechererror = myfit.GetParError(0)/PrimaryParticleEnergy
	Fasthecher2 = (PrimaryParticleEnergy - myfit.GetParameter(1))/PrimaryParticleEnergy
	TGraphfasthecher.SetTitle("")
	TGraphfasthecher.Draw("AP")
	gPad.SaveAs("Fasthecher-pol1fit.pdf")
	gPad.Close()  
	TGraphfasthecher.Fit("combinedfit")
	hec = combinedfit.GetParameter(0)  
	hecerror = combinedfit.GetParError(0)           
	TGraphfasthecher.Draw("AP")
	gPad.SaveAs("Fasthecher.pdf")
	gPad.Close()
	return Fasthescin, Fasthecher, Fasthescinerror, Fasthechererror, Fasthescin2, Fasthecher2, hes, hec, heserror, hecerror
Exemple #8
0
def create_firstroothistograms(PrimaryParticleName, VectorSignals, VectorSignalsCher, 
	GroupedVectorSignals, GroupedVectorSignalsCher, ScinTreshold, 
	CherTreshold, ScinMaxFiber, CherMaxFiber, NumFibers, NumModules):
	"""Function to perform ROOT histograms"""
	
	#Set ROOT histograms
	TH2Signals = TH2F("ScatterplotSignals",PrimaryParticleName,111*8,1.2*0,1.2*111,111*8,1.2*0,1.2*111)
	TH2SignalsGrouped = TH2F("ScatterplotSignalsGrouped",PrimaryParticleName,111,1.2*0,1.2*111,111,1.2*0,1.2*111)
	TH2SignalsCher = TH2F("ScatterplotSignalsCher",PrimaryParticleName,111*8,0.0*111,1.2*111,111*8,0.0*111,1.2*111)
	TH2SignalsCherGrouped = TH2F("ScatterplotSignalsCherGrouped",PrimaryParticleName,111,1.2*0,1.2*111,111,1.2*0,1.2*111)
	TH1Signals = TH1F("Scintillation",PrimaryParticleName,100,0.0,ScinMaxFiber+200.0)
	TH1SignalsCher = TH1F("Cherenkov",PrimaryParticleName,100,0.0,CherMaxFiber+5)

	#Fill histograms in for loop
	for fiberindex in range(NumFibers):
		X,Y = map.mapXY(fiberindex)
		if VectorSignals[fiberindex] > ScinTreshold:
			TH2Signals.Fill(X,Y,VectorSignals[fiberindex])
			TH1Signals.Fill(VectorSignals[fiberindex])
		if VectorSignalsCher[fiberindex] > CherTreshold:
			TH2SignalsCher.Fill(X,Y,VectorSignalsCher[fiberindex])
			TH1SignalsCher.Fill(VectorSignalsCher[fiberindex])

	for moduleindex in range(NumModules):
		X,Y = mapgroup.mapgroupedXY(moduleindex)
		TH2SignalsGrouped.Fill(X,Y,GroupedVectorSignals[moduleindex])
		TH2SignalsCherGrouped.Fill(X,Y,GroupedVectorSignalsCher[moduleindex])
		
	#Draw + DrawOptions histograms		
	Style = gStyle
	Style.SetPalette(1) #Root palette style
	Style.SetOptStat(0) #Do not show statistics
	TH2Signals.SetLineWidth(0) #TH2Signals #No line width
	TH2Signals.SetLineColor(2)
	#TH2Signals.SetFillColorAlpha(2, 0.)
	XAxis = TH2Signals.GetXaxis()
	XAxis.SetTitle("x (cm)")
	XAxis.CenterTitle()
	XAxis.SetTitleOffset(1.8)
	YAxis = TH2Signals.GetYaxis()
	YAxis.SetTitle("y (cm)")
	YAxis.CenterTitle()
	YAxis.SetTitleOffset(1.8)
	ZAxis = TH2Signals.GetZaxis()
	ZAxis.SetTitle("Energy (MeV)")
	ZAxis.SetTitleOffset(1.4)
	TH2Signals.Draw("LEGO2Z 0 FB")
	gPad.SaveAs("ImageScintillation.pdf")
	TH2SignalsGrouped.SetLineWidth(0) #TH2GroupedSignals #No line width
	TH2SignalsGrouped.SetLineColor(2)
	#TH2Signals.SetFillColorAlpha(2, 0.)
	XAxis = TH2SignalsGrouped.GetXaxis()
	XAxis.SetTitle("x (cm)")
	XAxis.CenterTitle()
	XAxis.SetTitleOffset(1.8)
	YAxis = TH2SignalsGrouped.GetYaxis()
	YAxis.SetTitle("y (cm)")
	YAxis.CenterTitle()
	YAxis.SetTitleOffset(1.8)
	ZAxis = TH2SignalsGrouped.GetZaxis()
	ZAxis.SetTitle("Energy (MeV)")
	ZAxis.SetTitleOffset(1.4)
	TH2SignalsGrouped.Draw("LEGO2Z 0 FB")
	gPad.SaveAs("ImageScintillationGrouped.pdf")
	TH2SignalsCherGrouped.SetLineWidth(0) #TH2GroupedCherSignals #No line width
	TH2SignalsCherGrouped.SetLineColor(4)
	#TH2Signals.SetFillColorAlpha(2, 0.)
	XAxis = TH2SignalsCherGrouped.GetXaxis()
	XAxis.SetTitle("x (cm)")
	XAxis.CenterTitle()
	XAxis.SetTitleOffset(1.8)
	YAxis = TH2SignalsCherGrouped.GetYaxis()
	YAxis.SetTitle("y (cm)")
	YAxis.CenterTitle()
	YAxis.SetTitleOffset(1.8)
	ZAxis = TH2SignalsCherGrouped.GetZaxis()
	ZAxis.SetTitle("Energy (MeV)")
	ZAxis.SetTitleOffset(1.4)
	TH2SignalsCherGrouped.Draw("LEGO2Z 0 FB")
	gPad.SaveAs("ImageCherenkovGrouped.pdf")
	TH2SignalsCher.SetLineWidth(0) #TH2SignalsCher #No line width
	TH2SignalsCher.SetLineColor(4)
	XAxis = TH2SignalsCher.GetXaxis()
	XAxis.SetTitle("x (cm)")
	XAxis.CenterTitle()
	XAxis.SetTitleOffset(1.8)
	YAxis = TH2SignalsCher.GetYaxis()
	YAxis.SetTitle("y (cm)")
	YAxis.CenterTitle()
	YAxis.SetTitleOffset(1.8)
	ZAxis = TH2SignalsCher.GetZaxis()
	ZAxis.SetTitle("Energy (MeV)")
	ZAxis.SetTitleOffset(1.4)
	TH2SignalsCher.Draw("LEGO2Z FB 0")
	gPad.SaveAs("ImageCherenkov.pdf")
	Style.SetLineWidth(1) #TH1Signals
	Style.SetOptStat(1) #Show statistics
	gPad.SetLogy()
	gPad.SetLogx()
	XAxis = TH1Signals.GetXaxis()
	XAxis.SetTitle("Energy (MeV)")
	XAxis.SetTitleOffset(1.2)
	YAxis = TH1Signals.GetYaxis()
	YAxis.SetTitle("# fibers")
	TH1Signals.Draw()
	gPad.SaveAs("EnergyFibers.pdf")
	XAxis = TH1SignalsCher.GetXaxis() #TH1SignalsCher
	XAxis.SetTitle("# Cher p.e.")
	XAxis.SetTitleOffset(1.2)
	YAxis = TH1SignalsCher.GetYaxis()
	YAxis.SetTitle("# fibers")
	TH1SignalsCher.Draw()
	gPad.SaveAs("CherpeFibers.pdf")
	gPad.Close()
Exemple #9
0
def create_graph(Fastscinenergy, Fastcherenergy, Scinenergy, Cherenergy, fem, PrimaryParticleEnergy):
	"""Function to perform ROOT graphs and compute he values"""

	#How many graph points
	n = len(Fastscinenergy)

	TGraphfasthescin = TGraph(n, fem, Fastscinenergy)
	TGraphfasthecher = TGraph(n, fem, Fastcherenergy)
	TGraphhescin = TGraph(n, fem, Scinenergy)
	TGraphhecher = TGraph(n, fem, Cherenergy)

	#Draw + DrawOptions, Fit + parameter estimation
	Style = gStyle
	XAxis = TGraphfasthescin.GetXaxis() #TGraphfasthescin
	TGraphfasthescin.SetMarkerColor(4)
	TGraphfasthescin.SetMarkerStyle(20)
	TGraphfasthescin.SetMarkerSize(1)
	XAxis.SetTitle("fem")
	YAxis = TGraphfasthescin.GetYaxis()
	YAxis.SetTitle("Energy scin (MeV)")
	TGraphfasthescin.Fit("pol1")
	myfit = TGraphfasthescin.GetFunction("pol1")
	Fasthescin = myfit.GetParameter(0)/PrimaryParticleEnergy             
	TGraphfasthescin.Draw("AP")
	gPad.SaveAs("Fasthescin.pdf")
	gPad.Close()
	XAxis = TGraphfasthecher.GetXaxis() #TGraphfasthecher
	TGraphfasthecher.SetMarkerColor(4)
	TGraphfasthecher.SetMarkerStyle(20)
	TGraphfasthecher.SetMarkerSize(1)
	XAxis.SetTitle("fem")
	YAxis = TGraphfasthecher.GetYaxis()
	YAxis.SetTitle("Energy Cher (MeV)")
	TGraphfasthecher.Fit("pol1")
	myfit = TGraphfasthecher.GetFunction("pol1")
	Fasthecher = myfit.GetParameter(0)/PrimaryParticleEnergy  
	TGraphfasthecher.Draw("AP")
	gPad.SaveAs("Fasthecher.pdf")
	gPad.Close()
	XAxis = TGraphhescin.GetXaxis() #TGraphhescin
	TGraphhescin.SetMarkerColor(4)
	TGraphhescin.SetMarkerStyle(20)
	TGraphhescin.SetMarkerSize(1)
	XAxis.SetTitle("fem")
	YAxis = TGraphhescin.GetYaxis()
	YAxis.SetTitle("Energy scin (MeV)")
	TGraphhescin.Fit("pol1")
	myfit = TGraphhescin.GetFunction("pol1")
	hescin = myfit.GetParameter(0)/PrimaryParticleEnergy  
	TGraphhescin.Draw("AP")
	gPad.SaveAs("hescin.pdf")
	gPad.Close()
	XAxis = TGraphhecher.GetXaxis() #TGraphhecher
	TGraphhecher.SetMarkerColor(4)
	TGraphhecher.SetMarkerStyle(20)
	TGraphhecher.SetMarkerSize(1)
	XAxis.SetTitle("fem")
	YAxis = TGraphhecher.GetYaxis()
	YAxis.SetTitle("Energy cher (MeV)")
	TGraphhecher.Fit("pol1")
	myfit = TGraphhecher.GetFunction("pol1")
	hecher = myfit.GetParameter(0)/PrimaryParticleEnergy  
	TGraphhecher.Draw("AP")
	gPad.SaveAs("hecher.pdf")
	gPad.Close()
	return Fasthescin, Fasthecher, hescin, hecher
Exemple #10
0
def main():

    gROOT.SetBatch()

    #range for |t|
    ptmin = 0.
    ptmax = 0.109  #   0.109  0.01 for interference range

    #default binning
    ptbin = 0.004  # 0.004  0.0005 for interference range

    #long bins at high |t|
    ptmid = 0.06  # 0.08, value > ptmax will switch it off   0.06
    ptlon = 0.01  # 0.01

    #short bins at low |t|
    ptlow = 0.01
    ptshort = 0.0005

    #mass interval
    mmin = 2.8
    mmax = 3.2

    #dy = 2. # rapidity interval, for integrated sigma
    dy = 1.

    ngg = 131  # number of gamma-gamma from mass fit

    lumi = 13871.907  # lumi in inv. ub

    #correction to luminosity for ana/triggered events
    ratio_ana = 3420950. / 3694000

    #scale the lumi for |z| around nominal bunch crossing
    ratio_zdc_vtx = 0.502

    Reta = 0.503  # pseudorapidity preselection
    #Reta = 1.

    trg_eff = 0.67  # bemc trigger efficiency

    ratio_tof = 1.433  # tof correction to efficiency

    bbceff = 0.97  # BBC veto inefficiency

    zdc_acc = 0.49  # ZDC acceptance to XnXn 0.7
    #zdc_acc = 1.

    br = 0.05971  # dielectrons branching ratio

    #data
    basedir = "../../../star-upc-data/ana/muDst/muDst_run1/sel5"
    infile = "ana_muDst_run1_all_sel5z.root"

    #MC
    basedir_sl = "../../../star-upc-data/ana/starsim/slight14e/sel5"
    #infile_sl = "ana_slight14e1x2_s6_sel5z.root"
    infile_sl = "ana_slight14e1x3_s6_sel5z.root"
    #
    basedir_sart = "../../../star-upc-data/ana/starsim/sartre14a/sel5"
    infile_sart = "ana_sartre14a1_sel5z_s6_v2.root"
    #
    basedir_bgen = "../../../star-upc-data/ana/starsim/bgen14a/sel5"
    infile_bgen = "ana_bgen14a1_v0_sel5z_s6.root"
    #infile_bgen = "ana_bgen14a2_sel5z_s6.root"
    #
    basedir_gg = "../../../star-upc-data/ana/starsim/slight14e/sel5"
    infile_gg = "ana_slight14e2x1_sel5_nzvtx.root"

    #model predictions
    gSlight = load_starlight(dy)
    gSartre = load_sartre()
    gFlat = loat_flat_pt2()
    gMS = load_ms()
    gCCK = load_cck()

    #open the inputs
    inp = TFile.Open(basedir + "/" + infile)
    tree = inp.Get("jRecTree")
    #
    inp_gg = TFile.Open(basedir_gg + "/" + infile_gg)
    tree_gg = inp_gg.Get("jRecTree")
    #
    inp_sl = TFile.Open(basedir_sl + "/" + infile_sl)
    tree_sl_gen = inp_sl.Get("jGenTree")
    #
    inp_sart = TFile.Open(basedir_sart + "/" + infile_sart)
    tree_sart_gen = inp_sart.Get("jGenTree")
    #
    inp_bgen = TFile.Open(basedir_bgen + "/" + infile_bgen)
    tree_bgen_gen = inp_bgen.Get("jGenTree")

    #evaluate binning
    #print "bins:", ut.get_nbins(ptbin, ptmin, ptmax)

    bins = ut.get_bins_vec_2pt(ptbin, ptlon, ptmin, ptmax, ptmid)
    #bins = ut.get_bins_vec_3pt(ptshort, ptbin, ptlon, ptmin, ptmax, ptlow, ptmid)
    #print "bins2:", bins.size()-1

    #load the data
    strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)

    hPt = ut.prepare_TH1D_vec("hPt", bins)
    tree.Draw("jRecPt*jRecPt >> hPt", strsel)

    #distribution for bin centers
    hPtCen = hPt.Clone("hPtCen")

    #gamma-gamma component
    hPtGG = ut.prepare_TH1D_vec("hPtGG", bins)
    tree_gg.Draw("jRecPt*jRecPt >> hPtGG", strsel)

    #normalize the gamma-gamma component
    ut.norm_to_num(hPtGG, ngg, rt.kGreen)

    #incoherent functional shape
    func_incoh_pt2 = TF1("func_incoh", "[0]*exp(-[1]*x)", 0., 10.)
    func_incoh_pt2.SetParameters(873.04, 3.28)

    #fill incoherent histogram from functional shape
    hPtIncoh = ut.prepare_TH1D_vec("hPtIncoh", bins)
    ut.fill_h1_tf(hPtIncoh, func_incoh_pt2, rt.kRed)

    #print "Entries before gamma-gamma and incoherent subtraction:", hPt.GetEntries()

    #subtract gamma-gamma and incoherent components
    hPt.Sumw2()
    hPt.Add(hPtGG, -1)
    #print "Gamma-gamma entries:", hPtGG.Integral()
    #print "Entries after gamma-gamma subtraction:", hPt.Integral()
    #print "Incoherent entries:", hPtIncoh.Integral()
    hPt.Add(hPtIncoh, -1)

    #print "Entries after all subtraction:", hPt.Integral()

    #scale the luminosity
    lumi_scaled = lumi * ratio_ana * ratio_zdc_vtx
    #print "lumi_scaled:", lumi_scaled

    #denominator for deconvoluted distribution, conversion ub to mb
    den = Reta * br * zdc_acc * trg_eff * bbceff * ratio_tof * lumi_scaled * 1000. * dy

    #deconvolution
    deconv_min = bins[0]
    deconv_max = bins[bins.size() - 1]
    deconv_nbin = bins.size() - 1
    gROOT.LoadMacro("fill_response_matrix.C")

    #Starlight response
    #resp_sl = RooUnfoldResponse(deconv_nbin, deconv_min, deconv_max, deconv_nbin, deconv_min, deconv_max)
    resp_sl = RooUnfoldResponse(hPt, hPt)
    rt.fill_response_matrix(tree_sl_gen, resp_sl)
    #
    unfold_sl = RooUnfoldBayes(resp_sl, hPt, 15)
    #unfold_sl = RooUnfoldSvd(resp_sl, hPt, 15)
    hPtSl = unfold_sl.Hreco()
    #ut.set_H1D(hPtSl)
    #apply the denominator and bin width
    ut.norm_to_den_w(hPtSl, den)

    #Sartre response
    #resp_sart = RooUnfoldResponse(deconv_nbin, deconv_min, deconv_max, deconv_nbin, deconv_min, deconv_max)
    #resp_sart = RooUnfoldResponse(hPt, hPt)
    #rt.fill_response_matrix(tree_sart_gen, resp_sart)
    #
    #unfold_sart = RooUnfoldBayes(resp_sart, hPt, 10)
    #hPtSart = unfold_sart.Hreco()
    #ut.set_H1D(hPtSart)
    #hPtSart.SetMarkerStyle(21)

    #Flat pT^2 response
    #resp_bgen = RooUnfoldResponse(deconv_nbin, deconv_min, deconv_max, deconv_nbin, deconv_min, deconv_max)
    resp_bgen = RooUnfoldResponse(hPt, hPt)
    rt.fill_response_matrix(tree_bgen_gen, resp_bgen)
    #
    unfold_bgen = RooUnfoldBayes(resp_bgen, hPt, 14)
    hPtFlat = unfold_bgen.Hreco()
    #ut.set_H1D(hPtFlat)
    #apply the denominator and bin width
    ut.norm_to_den_w(hPtFlat, den)
    #hPtFlat.SetMarkerStyle(22)
    #hPtFlat.SetMarkerSize(1.3)

    #systematical errors
    err_zdc_acc = 0.1
    err_bemc_eff = 0.03
    #sys_err = rt.TMath.Sqrt(err_zdc_acc*err_zdc_acc + err_bemc_eff*err_bemc_eff)
    sys_err = err_zdc_acc * err_zdc_acc + err_bemc_eff * err_bemc_eff
    #print "Total sys err:", sys_err
    hSys = ut.prepare_TH1D_vec("hSys", bins)
    hSys.SetOption("E2")
    hSys.SetFillColor(rt.kOrange + 1)
    hSys.SetLineColor(rt.kOrange)
    for ibin in xrange(1, hPtFlat.GetNbinsX() + 1):
        hSys.SetBinContent(ibin, hPtFlat.GetBinContent(ibin))
        sig_sl = hPtSl.GetBinContent(ibin)
        sig_fl = hPtFlat.GetBinContent(ibin)
        err_deconv = TMath.Abs(sig_fl - sig_sl) / sig_fl
        #print "err_deconv", err_deconv
        #sys_err += err_deconv*err_deconv
        sys_err_sq = sys_err + err_deconv * err_deconv
        sys_err_bin = TMath.Sqrt(sys_err_sq)
        stat_err = hPtFlat.GetBinError(ibin) / hPtFlat.GetBinContent(ibin)
        tot_err = TMath.Sqrt(stat_err * stat_err + sys_err_sq)
        #hSys.SetBinError(ibin, hPtFlat.GetBinContent(ibin)*err_deconv)
        hSys.SetBinError(ibin, hPtFlat.GetBinContent(ibin) * sys_err_bin)
        #hPtFlat.SetBinError(ibin, hPtFlat.GetBinContent(ibin)*tot_err)

    #draw the results
    gStyle.SetPadTickX(1)
    gStyle.SetFrameLineWidth(2)

    #frame for models plot only
    frame = ut.prepare_TH1D("frame", ptbin, ptmin, ptmax)

    can = ut.box_canvas()
    #ut.set_margin_lbtr(gPad, 0.1, 0.09, 0.03, 0.03)
    ut.set_margin_lbtr(gPad, 0.1, 0.09, 0.055, 0.01)

    ytit = "d#it{#sigma}/d#it{t}d#it{y} (mb/(GeV/c)^{2})"
    xtit = "|#kern[0.3]{#it{t}}| ((GeV/c)^{2})"

    ut.put_yx_tit(frame, ytit, xtit, 1.4, 1.2)
    frame.SetMaximum(11)
    #frame.SetMinimum(1.e-6)
    #frame.SetMinimum(2e-4)
    frame.SetMinimum(1e-5)  # 3e-5
    frame.Draw()

    #hSys.Draw("e2same")

    #bin center points from data
    #gSig = apply_centers(hPtFlat, hPtCen)
    gSig = fixed_centers(hPtFlat)
    ut.set_graph(gSig)

    #hPtSl.Draw("e1same")
    #hPtSart.Draw("e1same")
    #hPtFlat.Draw("e1same")

    #put model predictions
    #gSartre.Draw("lsame")
    #gFlat.Draw("lsame")
    gMS.Draw("lsame")
    gCCK.Draw("lsame")
    gSlight.Draw("lsame")

    gSig.Draw("P")

    frame.Draw("same")

    gPad.SetLogy()

    cleg = ut.prepare_leg(0.1, 0.96, 0.14, 0.01, 0.035)
    cleg.AddEntry(
        None,
        "Au+Au #rightarrow J/#psi + Au+Au + XnXn, #sqrt{#it{s}_{#it{NN}}} = 200 GeV",
        "")
    cleg.Draw("same")

    leg = ut.prepare_leg(0.45, 0.82, 0.18, 0.1, 0.035)
    leg.AddEntry(None, "#bf{|#kern[0.3]{#it{y}}| < 1}", "")
    hx = ut.prepare_TH1D("hx", 1, 0, 1)
    leg.AddEntry(hx, "STAR")
    hx.Draw("same")
    leg.Draw("same")

    #legend for models
    mleg = ut.prepare_leg(0.68, 0.76, 0.3, 0.16, 0.035)
    #mleg = ut.prepare_leg(0.68, 0.8, 0.3, 0.12, 0.035)
    mleg.AddEntry(gSlight, "STARLIGHT", "l")
    mleg.AddEntry(gMS, "MS", "l")
    mleg.AddEntry(gCCK, "CCK-hs", "l")
    #mleg.AddEntry(gSartre, "Sartre", "l")
    #mleg.AddEntry(gFlat, "Flat #it{p}_{T}^{2}", "l")
    mleg.Draw("same")

    #legend for deconvolution method
    dleg = ut.prepare_leg(0.3, 0.75, 0.2, 0.18, 0.035)
    #dleg = ut.prepare_leg(0.3, 0.83, 0.2, 0.1, 0.035)
    dleg.AddEntry(None, "Unfolding with:", "")
    dleg.AddEntry(hPtSl, "Starlight", "p")
    #dleg.AddEntry(hPtSart, "Sartre", "p")
    dleg.AddEntry(hPtFlat, "Flat #it{p}_{T}^{2}", "p")
    #dleg.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")

    #to prevent 'pure virtual method called'
    gPad.Close()

    #save the cross section to output file
    out = TFile("sigma.root", "recreate")
    gSig.Write("sigma")
    out.Close()

    #beep when finished
    gSystem.Exec("mplayer ../computerbeep_1.mp3 > /dev/null 2>&1")