예제 #1
0
파일: EMC.py 프로젝트: chughes90/OVERWATCH
def patchAmpOptions(subsystem, hist, processingOptions):
    # Setup canvas as desired
    hist.canvas.SetLogy(True)
    hist.canvas.SetGrid(1, 1)

    # Check for the corresponding hist
    #if "DCal" in hist.GetName():
    #    nameToCheck = hist.GetName().replace("DCal", "EMCal")
    #else:
    #    nameToCheck = hist.GetName().replace("EMCal", "DCal")
    #otherHist = qaContainer.getHist(nameToCheck)

    # Plot both on the same canvas if they both exist
    #if otherHist is not None:
    if hist.hist.InheritsFrom(THStack.Class()):
        # Add legend
        legend = TLegend(0.6, 0.9, 0.9, 0.7)
        legend.SetBorderSize(0)
        legend.SetFillStyle(0)
        SetOwnership(legend, False)

        # Lists to use to plot
        detectors = ["EMCal", "DCal"]
        colors = [kRed + 1, kBlue + 1]
        markers = [kFullCircle, kOpenCircle]
        options = ["", ""]

        # Plot elements
        for tempHist, detector, color, marker, option in zip(
                hist.hist.GetHists(), detectors, colors, markers, options):
            tempHist.Sumw2()
            tempHist.SetMarkerSize(0.8)
            tempHist.SetMarkerStyle(marker)
            tempHist.SetLineColor(color)
            tempHist.SetMarkerColor(color)

            if processingOptions["scaleHists"]:
                tempHist.Scale(1. / subsystem.nEvents)
            tempHist.GetYaxis().SetTitle("entries / events")

            # Draw hists
            # This is not the usual philosophy. We are clearing the canvas and then plotting
            # the second hist on it
            #tempHist.Draw(option)
            legend.AddEntry(tempHist, detector, "pe")

        # Add legend
        legend.Draw()

        # Ensure that canvas is updated to account for the new object colors
        hist.canvas.Update()

        # Add energy axis
        addEnergyAxisToPatches(subsystem, hist, processingOptions)
예제 #2
0
 def fixXExponent(self, canvas):
     '''
     If there's an exponent on the Y axis, it will either be in a weird 
     place or it will overlap with the axis title. We fix the placement in
     __init__(), but we still have to move the title if need be.        
     Recursive, so we find histograms in pads in pads.
     '''
     for obj in canvas.GetListOfPrimitives():
         if obj.InheritsFrom(TH1.Class()) or obj.InheritsFrom(
                 THStack.Class()):
             axis = obj.GetXaxis()
             if axis.GetXmax() >= 10**TGaxis.GetMaxDigits():
                 # has exponent
                 axis.CenterTitle()
         if obj.InheritsFrom(TPad.Class()):
             self.fixXExponent(obj)