예제 #1
0
def MakePieCharts(input, key, root_file=None, output=None):
    ROOT.gStyle.SetTitleFillColor(10)
    created_files = []
    if key != 'BW':
        print 'Sorry, only bandwidth groups are currently supported'
        return created_files

    results = TrigCostXML.ReadXmlFile(input)
    L2_pie_groups = []
    EF_pie_groups = []
    for chain in results.GetChains():
        if chain.GetName().find(key) != -1:
            if chain.GetName().find('L2') != -1:
                L2_pie_groups.append(results.GetChain(chain.GetName()))
            if chain.GetName().find('EF') != -1:
                EF_pie_groups.append(results.GetChain(chain.GetName()))

    rfile = None
    if root_file != None:
        rfile = ROOT.TFile(root_file, 'RECREATE')

    pies = []

    pies += MakeChart(L2_pie_groups, 'L2')
    pies += MakeChart(EF_pie_groups, 'EF')

    if root_file:
        for p in pies:
            p.Write()
    if output:
        for p in pies:
            can = ROOT.TCanvas(p.GetName(), p.GetName())
            can.SetFillColor(10)
            can.SetFrameFillColor(10)
            p.Draw('3d')
            can.SaveAs('%s/%s.png' % (output, p.GetName()))

    return pies
예제 #2
0
if options.key_list == "physics":
    key_list = ['L1_EM3', 'L1_TAU', 'L1_MU', 'L1_XE', 'L1_J', 'L1_TE']
elif options.key_list == "minbias":
    key_list = ['L1_MBTS']
else:
    key_list = options.key_list.split(',')
    
# Parse the input files
# Need to deal with key_list and options.ignore after reading the xml 
input_results = []
for i in args :
    if i.count(".txt") > 0 : 
        input_results.append(ReadTextFile(i))
    elif i.count(".xml") > 0 :
        input_results.append(TrigCostXML.ReadXmlFile(i))
    elif i.count("http") > 0 :
        if i.count('TriggerCosts.xml') == 0 :
            i += '/TriggerCosts.xml'
        input_results.append(TrigCostXML.ReadXmlFile(i))

gpath = options.output_path+"/"



# Copy the xml if requested
if options.copy_xml :
    counter = 0
    for i in args :
        if i.count("http") == 0  :
            shutil.copyfile(i, gpath+'TriggerRates_%d.xml' %counter)
예제 #3
0
full_usage='checkOptPS.py '+usage

p = OptionParser(usage)
    

(opts, args) = p.parse_args()

if len(args) != 1:
    print "Must have exactly one argument"
    print full_usage
    sys.exit(-1)

#-----------------------------------------------------------------------
#  Read in XML file
#-----------------------------------------------------------------------
results = TrigCostXML.ReadXmlFile(args[0])

#-----------------------------------------------------------------------
#  Make L1 -> L2 and L2 -> EF maps
#-----------------------------------------------------------------------
daughter_map = {}
for ch in results.GetChains():

    if ch.GetLevel()=='L1':
        continue
    
    lower_chain = ''
    try:
        lower_chain = ch.GetLowerChain()
    except TrigCostAnalysis.VarNotAvailable,e:
        if not (TrigCostTRP.NonChainTRP(ch.GetName()) or 
예제 #4
0
rngs = {}

dom = xml.dom.minidom.parse(open(opts.ranges))

rngsxml = dom.getElementsByTagName("ranges")
for rng in rngsxml[0].getElementsByTagName("range"):
    chain = rng.getAttribute("chain")
    minv = string.atof(rng.getAttribute("min"))
    maxv = string.atof(rng.getAttribute("max"))
    rngs[chain] = (minv, maxv)

#
# Read in rates from XML
#   rates will a "CostResult" object which lists all the chains
rates = TrigCostXML.ReadXmlFile(infile)

if rngs.has_key("DEFAULT"):
    #
    # Do default, loop over all chains
    #
    for lvl in ["L1", "L2", "EF"]:
        chnames = rates.GetChainNames(lvl)
        chnames.sort()
        for chname in chnames:
            # get range, fill in with default
            rng = rngs.get(chname, rngs["DEFAULT"])

            ch = rates.GetChain(chname)
            if ch.GetRate() < rng[0] or ch.GetRate() > rng[1]:
                print "The rate for %s is %8.2f  which is not in the range (%8.2f,%8.2f)" %\
예제 #5
0
    if opts.run < 0:
        print 'COOL needs valid run number'
        sys.exit(2)

    if opts.doconfig: config = TrigCostCool.GetConfig(opts.run, options)
    if opts.dorates:
        ratecoll = TrigCostCool.GetRates(opts.run, opts.lbbeg, opts.lbend,
                                         options)

# INPUT OPTION 3: XML
if opts.xml:
    if len(opts.file) == 0:
        print 'XML needs valid input file'
        sys.exit(2)

    rates = TrigCostXML.ReadXmlFile(opts.file)

# INPUT OPTION 4: IS -- Information Service only runs in a release for AtlasCAFHLT or AtlasP1HLT.
if opts.IS:
    if not opts.timebeg:
        print 'IS option needs at least a time start of form "hh:mm"'
        sys.exit(2)

    collections = TrigCostIS.ReadISRates(
        opts.timebeg,
        opts.timeend)  #for now we always look at mirror partition (default)
    if not collections:
        print 'No data found in the specified interval [%s to %s]' % (
            opts.timebeg, opts.timeend)
        sys.exit(2)
    runs = collections.keys()
예제 #6
0
if not os.path.isfile(htmlpath.rstrip('/') + '/sorttable.js'):
    from subprocess import Popen

    try:
        print "argv0 ", sys.argv[0]
        sortPath = sys.argv[0].replace("costxml2html.py",
                                       "../TrigCostPython/sorttable.js")
        pCt = Popen('cp ' + sortPath + ' ' + htmlpath, shell=True)
        pCt.wait()
    except TypeError:
        print 'Could not get TestArea to locate sorttable.js - it will not be copied to output location.'

#
# Read XML file
#
result = TrigCostXML.ReadXmlFile(xmlin)

#
# Write index
#
levels = ['L1', 'L2', 'EF']
file = open(htmlpath + '/index.html', 'w')
if opts.header != "":
    file.write('<h2>' + opts.header + '</h2>\n')
for level in levels:
    file.write('<a href="chain_rates_' + level + '.html">' + level +
               ' Chains</a> &nbsp;&nbsp;&nbsp; <a href="group_rates_' + level +
               '.html">' + level + ' Groups</a></br>')

#
# Write HTML
예제 #7
0
    if len(ratelist) != len(ratenames):
        print "ratenames must have the same number of entries are ratelist"
        sys.exit(-1)
else:
    ratenames = ratelist

plotlabels = []
if opts.plotlabel != "":
    plotlabels = string.split(opts.plotlabel, '\\\\')

#-----------------------------------------------------------------------
#  Read in XML files
#-----------------------------------------------------------------------
results = []
for i in xrange(len(args)):
    results.append(TrigCostXML.ReadXmlFile(args[i]))

#-----------------------------------------------------------------------
#  Make plot
#-----------------------------------------------------------------------
canvas = ROOT.TCanvas('rates_' + opts.outname, 'rates_' + opts.outname, 10, 10,
                      700, 90 * len(ratelist))
canvas.SetFillColor(10)
canvas.SetLogx(1)

legend = ROOT.TLegend(0.725, 0.16, 1.00, 0.280)
legend.SetFillColor(10)
legend.SetFillStyle(0)
legend.SetTextSize(0.035)
legend.SetBorderSize(0)