def AddDiffHisto(histname1, histname2, phase=True):

    prefix_=""
    if phase: prefix_  = "h2_phase"
    if not phase: prefix_  = "h2_delay"
    
    hname1 = prefix_ + "_" + histname1
    hname2 = prefix_ + "_" + histname2
    
    hname = prefix_ + "_" + histname1 + "_Minus_" + histname2  
    print hname1, hname2, hname
    
    f_in = TFile("databaseHist.root","UPDATE")
    
    h_target = f_in.Get(hname1)
    h_base =   f_in.Get(hname2)
    
    h_target.Add(h_base,-1)
    h_target.SetName(hname)
    h_target.Write()
    
    c = canvasL.EPCanvas2DLongXColz()
    gStyle.SetPalette(1)
    h_target.Draw("colz")
    latextext = prefix_+histname1 + "_Minus_" + histname2
    latexL.EPLatex(latextext)
    histname=h_target.GetName()+".pdf"
    print " name of the hist is ", histname
    if h_target.Integral()!=0:
        c.SaveAs("plots/"+histname)

    
    print h_target.Integral()
    f_in.Close()
示例#2
0
def PDFSummary(histname, timeid):
    print "histo", histname
    c = canvasL.EPCanvas2DLongXColz()
    gStyle.SetPalette(1)
    fin = TFile("gapFlag_errorFrac.root", "READ")
    h2 = fin.Get(histname)
    h2.Draw("colz")
    h2.GetXaxis().SetTitle("TCC Id")
    h2.GetYaxis().SetTitle("Channel #")

    latextext = "Gap Flag data                                            " + Era + " 2018"
    latexL.EPLatex(latextext)

    latexL.EPLatex(timeid, 0.48, 0.8)

    c.SaveAs("plots/" + histname + ".pdf")
    print "will work here"
示例#3
0
def SaveTimeSummary(histogram, axistitle, histparam, time):
    c = canvasL.EPCanvas(0)
    hist = histL.Set1DHistParameters(histogram, histparam)
    hist.GetXaxis().SetTitle(axistitle[0])
    hist.GetYaxis().SetTitle(axistitle[1])
    hist.Draw("HIST")
    print "saving pdf for ", hist.GetName()

    latexText = time
    latexL.EPLatex(latexText, 0.25, 0.80)
    c.SaveAs("plots/" + Era + hist.GetName() + ".pdf")
def makeplotsFromDatabase(filename, latextext):
    df = pd.read_csv(filename,sep=" ",names=["tcc", "tower", "stripInTower", "TCCch", "delay", "phase"])
    
    rootfilename = filename.replace(".dat_out.txt", ".root")
    
    df.to_root(rootfilename)
    
    f = TFile(rootfilename,"READ")
    
    t = f.Get("my_ttree")
    
    ###
    h2_noweight = TH2F("h2_noweight", "h2_noweight", 120, 0,120, 80,0,80)
    c = canvasL.EPCanvas2DLongXColz()
    gStyle.SetPalette(1)
    t.Draw("TCCch:tcc>>h2_noweight","","goff")
    h2_noweight.Draw("colz")
    latexL.EPLatex(latextext)
    histname=h2_noweight.GetName()+"_"+latextext.replace(" ", "_")+"_"+(filename.replace("gapflag_database/","")).replace(".dat_out.txt",".pdf")
    c.SaveAs("plots/"+histname)
    
    
    ### 
    h2_phase = TH2F("h2_phase", "h2_phase", 120, 0,120, 80,0,80)
    c = canvasL.EPCanvas2DLongXColz()
    gStyle.SetPalette(1)
    t.Draw("TCCch:tcc>>h2_phase","1*phase","goff")
    h2_phase.Draw("colz")
    latexL.EPLatex(latextext)
    histname=h2_phase.GetName()+"_"+latextext.replace(" ", "_")+"_"+(filename.replace("gapflag_database/","")).replace(".dat_out.txt",".pdf")
    c.SaveAs("plots/"+histname)


    ### 
    h2_delay = TH2F("h2_delay", "h2_delay", 120, 0,120, 80,0,80)
    c = canvasL.EPCanvas2DLongXColz()
    gStyle.SetPalette(1)
    t.Draw("TCCch:tcc>>h2_delay","1*delay","goff")
    h2_delay.Draw("colz")
    latexL.EPLatex(latextext)
    histname=h2_delay.GetName()+"_"+latextext.replace(" ", "_")+"_"+(filename.replace("gapflag_database/","")).replace(".dat_out.txt",".pdf")
    c.SaveAs("plots/"+histname)

    f_out = TFile("databaseHist.root","UPDATE")
    f_out.cd()
    postfix=latextext.replace(" ", "_")
    n1 = h2_noweight.GetName() + "_" + postfix
    n2 = h2_phase.GetName() + "_" + postfix
    n3 = h2_delay.GetName() + "_" + postfix
    
    h2_noweight.SetName(n1) 
    h2_noweight.Write()
    
    h2_phase.SetName(n2)
    h2_phase.Write()
    
    h2_delay.SetName(n3)
    h2_delay.Write()
    
    f_out.Close()
    
    
    return 0
示例#5
0
h_final_prob_EE.Write()

import histLib as histL

## printing the 1-d summary plots for EE and EB
c = canvasL.EPCanvas(1)

#import histLib  as histL
## ENDCAP
h_final_prob_EE = histL.Set1DHistParameters(h_final_prob_EE,
                                            [0.0001, 10, 20, 1.10, 2, 1])
h_final_prob_EE.Draw("PC")
h_final_prob_EE.GetXaxis().SetTitle("time shift (ns)")
h_final_prob_EE.GetYaxis().SetTitle("mis-firing probability")
latexText = "Gap Flag data                                    " + Era + " 2018"
latexL.EPLatex(latexText)

latexL.EPLatex("EE (probability averaged over all TCCs)", 0.25, 0.80)
pdfname = h_final_prob_EE.GetName()
c.SaveAs("plots/" + Era + pdfname + ".pdf")

## BARREL
h_final_prob_EB = histL.Set1DHistParameters(h_final_prob_EB,
                                            [0.00001, 10, 20, 1.10, 2, 1])
h_final_prob_EB.Draw("PC")
h_final_prob_EB.GetXaxis().SetTitle("time shift (ns)")
h_final_prob_EB.GetYaxis().SetTitle("mis-firing probability")
latexText = "Gap Flag data                                     " + Era + " 2018"
latexL.EPLatex(latexText)

latexL.EPLatex("EB (probability averaged over all TCCs)", 0.25, 0.80)