Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:46

0001 import xml.etree.cElementTree as ET
0002 import re
0003 #import lxml.etree.ElementTree as ET
0004 
0005 
0006 class JobReport:
0007     def __init__(self):
0008         self.fjr = ET.Element("FrameworkJobReport")
0009         self.readbranches = ET.SubElement(self.fjr, "ReadBranches")
0010         self.performancereport = ET.SubElement(self.fjr, "PerformanceReport")
0011         self.performancesummary = ET.SubElement(
0012             self.performancereport, "PerformanceSummary", Metric="StorageStatistics")
0013         ET.SubElement(self.performancesummary, "Metric",
0014                       Name="Parameter-untracked-bool-enabled", Value="true")
0015         ET.SubElement(self.performancesummary, "Metric",
0016                       Name="Parameter-untracked-bool-stats", Value="true")
0017         ET.SubElement(self.performancesummary, "Metric",
0018                       Name="Parameter-untracked-string-cacheHint", Value="application-only")
0019         ET.SubElement(self.performancesummary, "Metric",
0020                       Name="Parameter-untracked-string-readHint", Value="auto-detect")
0021         ET.SubElement(self.performancesummary, "Metric",
0022                       Name="ROOT-tfile-read-totalMegabytes", Value="0")
0023         ET.SubElement(self.performancesummary, "Metric",
0024                       Name="ROOT-tfile-write-totalMegabytes", Value="0")
0025  # <Metric Name="Parameter-untracked-bool-enabled" Value="true"/>
0026  # <Metric Name="Parameter-untracked-bool-stats" Value="true"/>
0027  # <Metric Name="Parameter-untracked-string-cacheHint" Value="application-only"/>
0028  # <Metric Name="Parameter-untracked-string-readHint" Value="auto-detect"/>
0029  # <Metric Name="ROOT-tfile-read-totalMegabytes" Value="0"/>
0030  # <Metric Name="ROOT-tfile-write-totalMegabytes" Value="0"/>
0031 
0032 # likely not needed
0033 # <GeneratorInfo>
0034 # </GeneratorInfo>
0035 
0036     def addInputFile(self, filename, eventsRead=1, runsAndLumis={"1": [1]}):
0037         infile = ET.SubElement(self.fjr, "InputFile")
0038         ET.SubElement(infile, "LFN").text = re.sub(
0039             r".*?(/store/.*\.root)(\?.*)?", r"\1", filename)
0040         ET.SubElement(infile, "PFN").text = ""
0041         ET.SubElement(infile, "Catalog").text = ""
0042         ET.SubElement(infile, "InputType").text = "primaryFiles"
0043         ET.SubElement(infile, "ModuleLabel").text = "source"
0044         ET.SubElement(infile, "InputSourceClass").text = "PoolSource"
0045         ET.SubElement(infile, "GUID").text = ""
0046         ET.SubElement(infile, "EventsRead").text = "%s" % eventsRead
0047         runs = ET.SubElement(infile, "Runs")
0048         for r, ls in runsAndLumis.items():
0049             run = ET.SubElement(runs, "Run", ID="%s" % r)
0050             for l in ls:
0051                 ET.SubElement(run, "LumiSection", ID="%s" % l)
0052 
0053     def addOutputFile(self, filename, events=1, runsAndLumis={"1": [1]}):
0054         infile = ET.SubElement(self.fjr, "File")
0055         ET.SubElement(infile, "LFN").text = ""
0056         ET.SubElement(infile, "PFN").text = filename
0057         ET.SubElement(infile, "Catalog").text = ""
0058         ET.SubElement(infile, "ModuleLabel").text = "NANO"
0059         ET.SubElement(infile, "OutputModuleClass").text = "PoolOutputModule"
0060         ET.SubElement(infile, "GUID").text = ""
0061         ET.SubElement(infile, "DataType").text = ""
0062         ET.SubElement(
0063             infile, "BranchHash").text = "dc90308e392b2fa1e0eff46acbfa24bc"
0064         ET.SubElement(infile, "TotalEvents").text = "%s" % events
0065         runs = ET.SubElement(infile, "Runs")
0066         for r, ls in runsAndLumis.items():
0067             run = ET.SubElement(runs, "Run", ID="%s" % r)
0068             for l in ls:
0069                 ET.SubElement(run, "LumiSection", ID="%s" % l)
0070 
0071     def save(self, filename="FrameworkJobReport.xml"):
0072         tree = ET.ElementTree(self.fjr)
0073         tree.write(filename)  # , pretty_print=True)
0074         pass