Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
amanmdesai committed Nov 18, 2023
1 parent 34c0ad8 commit b0588c7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions LHEReader.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# LHE READER code to read MG5 LHE output

# Author Aman Desai
# https://github.com/amanmdesai/LHEReader

import xml.etree.ElementTree as ET
import ROOT
from ROOT import TFile, TTree, std
from array import array
import argparse

import pathlib

def read_xml(filename):

Expand Down Expand Up @@ -131,6 +132,13 @@ def build_TTree(data, outputname):
parser.add_argument("--input", type=str,help='Input file path and Name')
parser.add_argument("--output", type=str,help='Output file path and Name')
args = parser.parse_args()
root = read_xml(filename=args.input)
data_collect = read_xml_child(root)
build_TTree(data_collect, outputname=args.output)
if pathlib.PurePosixPath(args.input).suffix != ".lhe":
print('ONLY .lhe FILES ARE ACCEPTED AS INPUT')

if pathlib.PurePosixPath(args.output).suffix != ".root":
print('ONLY .root FILES ARE ACCEPTED AS OUTPUT')

if pathlib.PurePosixPath(args.input).suffix == ".lhe" and pathlib.PurePosixPath(args.output).suffix == ".root":
root = read_xml(filename=args.input)
data_collect = read_xml_child(root)
build_TTree(data_collect, outputname=args.output)

0 comments on commit b0588c7

Please sign in to comment.