CMS 3D CMS Logo

Functions | Variables
addLHEnumbers Namespace Reference

Functions

def number_events (input_file, output_file=None, offset=0)
 

Variables

 args
 
 default
 
 description
 
 help
 
 None
 
 parser
 
 type
 

Function Documentation

◆ number_events()

def addLHEnumbers.number_events (   input_file,
  output_file = None,
  offset = 0 
)

Definition at line 11 of file addLHEnumbers.py.

References str.

Referenced by mergeLHE.main().

11 def number_events(input_file, output_file=None, offset=0):
12  if output_file is None:
13  output_file = input_file
14  if not os.path.exists(os.path.dirname(os.path.realpath(output_file))):
15  os.makedirs(os.path.dirname(os.path.realpath(output_file)))
16 
17  nevent = offset
18  with open('tmp.txt', 'w') as fw:
19  with open(input_file, 'r') as ftmp:
20  for line in ftmp:
21  if re.search('\s*</event>', line):
22  nevent += 1
23  fw.write('<event_num num="' + str(nevent) + '"> ' + str(nevent) + '</event_num>\n')
24  fw.write(line)
25  if output_file is not None:
26  os.rename("tmp.txt", output_file)
27  else:
28  os.rename("tmp.txt", input_file)
29  return nevent
30 
31 
def number_events(input_file, output_file=None, offset=0)
#define str(s)

Variable Documentation

◆ args

addLHEnumbers.args

Definition at line 40 of file addLHEnumbers.py.

◆ default

addLHEnumbers.default

Definition at line 38 of file addLHEnumbers.py.

◆ description

addLHEnumbers.description

Definition at line 35 of file addLHEnumbers.py.

◆ help

addLHEnumbers.help

Definition at line 37 of file addLHEnumbers.py.

◆ None

addLHEnumbers.None

Definition at line 38 of file addLHEnumbers.py.

◆ parser

addLHEnumbers.parser

Definition at line 34 of file addLHEnumbers.py.

◆ type

addLHEnumbers.type

Definition at line 36 of file addLHEnumbers.py.