Page MenuHomeHEPForge

No OneTemporary

diff --git a/Tests/python/merge-LHC-EW b/Tests/python/merge-LHC-EW
--- a/Tests/python/merge-LHC-EW
+++ b/Tests/python/merge-LHC-EW
@@ -1,161 +1,158 @@
#! /usr/bin/env python
import lighthisto
import logging
import sys
import os, copy, re
"""%prog
Script for merging aida files
"""
import sys
if sys.version_info[:3] < (2,4,0):
print "rivet scripts require Python version >= 2.4.0... exiting"
sys.exit(1)
## Try to load faster but non-standard cElementTree module
try:
import xml.etree.cElementTree as ET
except ImportError:
try:
import cElementTree as ET
except ImportError:
try:
import xml.etree.ElementTree as ET
except:
sys.stderr.write("Can't load the ElementTree XML parser: please install it!\n")
sys.exit(1)
if __name__ == "__main__":
import logging
from optparse import OptionParser, OptionGroup
parser = OptionParser(usage="%prog aidafile aidafile2 [...]")
parser.add_option("-o", "--out", dest="OUTFILE", default="-")
parser.add_option("--append", dest="APPEND_OUTPUT", action="store_true", default=False)
verbgroup = OptionGroup(parser, "Verbosity control")
verbgroup.add_option("-v", "--verbose", action="store_const", const=logging.DEBUG, dest="LOGLEVEL",
default=logging.INFO, help="print debug (very verbose) messages")
verbgroup.add_option("-q", "--quiet", action="store_const", const=logging.WARNING, dest="LOGLEVEL",
default=logging.INFO, help="be very quiet")
parser.add_option_group(verbgroup)
(opts, args) = parser.parse_args()
logging.basicConfig(level=opts.LOGLEVEL, format="%(message)s")
## Prefix used in dat file headers
headerprefix = "# "
## Check args
if len(args) < 1:
logging.error("Must specify at least one AIDA histogram file")
sys.exit(1)
## Get histos
outhistos={}
for file in args:
if not os.access(file, os.R_OK):
logging.error("%s can not be read" % file)
break
try:
tree = ET.parse(file)
except:
logging.error("%s can not be parsed as XML" % file)
break
- print file
tree = ET.parse(file)
## Get histos from this AIDA file
for dps in tree.findall("dataPointSet"):
h = lighthisto.Histo.fromDPS(dps)
if(h.fullPath().find("ATLAS_2010_S8919674")>0) :
if((h.fullPath().find("d01")>0 or h.fullPath().find("d05")>0 or
h.fullPath().find("d07")>0) and file.find("-e")>0) :
outhistos[h.fullPath()] = h
elif((h.fullPath().find("d02")>0 or h.fullPath().find("d06")>0 or
h.fullPath().find("d08")>0) and file.find("-mu")>0) :
outhistos[h.fullPath()] = h
elif (h.fullPath().find("ATLAS_2011_S9131140")>0) :
if(h.fullPath().find("d01")>0 and file.find("-e")>0) :
outhistos[h.fullPath()] = h
elif(h.fullPath().find("d02")>0 and file.find("-mu")>0) :
outhistos[h.fullPath()] = h
elif (h.fullPath().find("ATLAS_2011_I925932")>0) :
if(h.fullPath().find("d01")>0 and file.find("-e")>0) :
outhistos[h.fullPath()] = h
elif(h.fullPath().find("d02")>0 and file.find("-mu")>0) :
outhistos[h.fullPath()] = h
elif (h.fullPath().find("ATLAS_2011_I945498")>0) :
if(h.fullPath().find("y01")>0 and file.find("-e")>0) :
outhistos[h.fullPath()] = h
elif(h.fullPath().find("y02")>0 and file.find("-mu")>0) :
outhistos[h.fullPath()] = h
elif(h.fullPath().find("y03")>0 and file.find("-mu")>0) :
outhistos[h.fullPath()] = h
elif (h.fullPath().find("ATLAS_2013_I1217867")>0) :
if(h.fullPath().find("y01")>0 and file.find("-e")>0) :
outhistos[h.fullPath()] = h
elif(h.fullPath().find("y02")>0 and file.find("-mu")>0) :
outhistos[h.fullPath()] = h
elif (h.fullPath().find("ATLAS_2012_I1204784" )>0) :
if( file.find("-e")>0 and
( h.fullPath().find("d03")>0 or
((h.fullPath().find("d01")>0 or h.fullPath().find("d02")>0) and h.fullPath().find("y01")>0))) :
outhistos[h.fullPath()] = h
elif(file.find("-mu")>0 and
( h.fullPath().find("d04")>0 or
((h.fullPath().find("d01")>0 or h.fullPath().find("d02")>0) and h.fullPath().find("y02")>0))) :
outhistos[h.fullPath()] = h
elif (h.fullPath().find("CMS_2013_I1224539_WJET" )>0) :
- print 'found A',h.fullPath()
if(file.find("-1-e")>0 and (h.fullPath().find("d52")>0 or h.fullPath().find("d53")>0 or h.fullPath().find("d56")>0 or h.fullPath().find("d57")>0 or h.fullPath().find("d60")>0 or h.fullPath().find("d61")>0 or h.fullPath().find("d64")>0 or h.fullPath().find("d65")>0 or h.fullPath().find("d68")>0 or h.fullPath().find("d69")>0 or h.fullPath().find("d72")>0)) :
outhistos[h.fullPath()] = h
elif(file.find("-2-e")>0 and (h.fullPath().find("d54")>0 or h.fullPath().find("d58")>0 or h.fullPath().find("d62")>0 or h.fullPath().find("d66")>0 or h.fullPath().find("d70")>0 or h.fullPath().find("d73")>0)) :
outhistos[h.fullPath()] = h
elif(file.find("-3-e")>0 and (h.fullPath().find("d55")>0 or h.fullPath().find("d59")>0 or h.fullPath().find("d63")>0 or h.fullPath().find("d67")>0 or h.fullPath().find("d71")>0 or h.fullPath().find("d74")>0)) :
outhistos[h.fullPath()] = h
elif (h.fullPath().find("CMS_2013_I1224539_ZJET" )>0) :
- print 'found B',h.fullPath()
if(file.find("-1-e")>0 and (h.fullPath().find("d29")>0 or h.fullPath().find("d30")>0 or h.fullPath().find("d33")>0 or h.fullPath().find("d34")>0 or h.fullPath().find("d37")>0 or h.fullPath().find("d38")>0 or h.fullPath().find("d41")>0 or h.fullPath().find("d42")>0 or h.fullPath().find("d45")>0 or h.fullPath().find("d46")>0 or h.fullPath().find("d49")>0)) :
outhistos[h.fullPath()] = h
elif(file.find("-2-e")>0 and (h.fullPath().find("d31")>0 or h.fullPath().find("d35")>0 or h.fullPath().find("d39")>0 or h.fullPath().find("d43")>0 or h.fullPath().find("d47")>0 or h.fullPath().find("d50")>0)) :
outhistos[h.fullPath()] = h
elif(file.find("-3-e")>0 and (h.fullPath().find("d32")>0 or h.fullPath().find("d36")>0 or h.fullPath().find("d40")>0 or h.fullPath().find("d44")>0 or h.fullPath().find("d48")>0 or h.fullPath().find("d51")>0)) :
outhistos[h.fullPath()] = h
elif (h.fullPath().find("CMS_2013_I1258128")>0) :
if(h.fullPath().find("d01")>0 or h.fullPath().find("d02")>0 or
h.fullPath().find("d03")>0 or h.fullPath().find("d04")>0) :
outhistos[h.fullPath()] = h
else :
outhistos[h.fullPath()] = h
## Choose output file
out = None
if opts.OUTFILE == "-":
out = sys.stdout
else:
if opts.APPEND_OUTPUT:
out = open(opts.OUTFILE, "a")
else:
out = open(opts.OUTFILE, "w")
# Choose output file
out = None
if opts.OUTFILE == "-":
out = sys.stdout
else:
if opts.APPEND_OUTPUT:
out = open(opts.OUTFILE, "a")
else:
out = open(opts.OUTFILE, "w")
## Write out merged histos
out.write('<?xml version="1.0" encoding="ISO-8859-1" ?>\n')
out.write('<!DOCTYPE aida SYSTEM "http://aida.freehep.org/schemas/3.3/aida.dtd">\n')
out.write('<aida version="3.3">\n')
out.write(' <implementation version="1.1" package="FreeHEP"/>\n')
for hpath, h in sorted(outhistos.iteritems()):
logging.debug("hpath = %s" % hpath)
out.write(h.asAIDA() + "\n\n")
out.write('</aida>\n')
sys.exit(0)

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 6:10 PM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3799915
Default Alt Text
(8 KB)

Event Timeline