ATLAS Offline Software
Functions | Variables
merge_lhe_files Namespace Reference

Functions

def merge_lhe_files (listOfFiles, outputFile)
 

Variables

bool inHeader = False
 Reading first event signals that we are done with all the header information Using this approach means the script will properly handle any metadata stored at the beginning of the file. More...
 
 holdHeader = header
 
 tmp = line.split("=")
 each input file ends with "</LesHouchesEvents>". More...
 
 line = line.replace(tmp[0],str(nevents))
 
 nnn = str(nevents)
 

Function Documentation

◆ merge_lhe_files()

def merge_lhe_files.merge_lhe_files (   listOfFiles,
  outputFile 
)

Definition at line 4 of file merge_lhe_files.py.

4 def merge_lhe_files(listOfFiles,outputFile):
5  if(os.path.exists(outputFile)):
6  print ("outputFile ",outputFile," already exists. Will rename to ",outputFile,".OLD")
7  os.rename(outputFile,outputFile+".OLD")
8  output = open(outputFile,'w')
9  holdHeader = ""
10  nevents=0
11  for file in listOfFiles:
12  cmd = "grep /event "+file+" | wc -l"
13  nevents+=int(subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True))
14 
15  for file in listOfFiles:
16  inHeader = True
17  header = ""
18  print ("*** Starting file ",file)
19  for line in open(file,"r"):

Variable Documentation

◆ holdHeader

merge_lhe_files.holdHeader = header

Definition at line 28 of file merge_lhe_files.py.

◆ inHeader

bool merge_lhe_files.inHeader = False

Reading first event signals that we are done with all the header information Using this approach means the script will properly handle any metadata stored at the beginning of the file.

Note: aside from the number of events, no metadata is updated after the first header is read (eg the random number seed recorded will be that of the first file.

Definition at line 26 of file merge_lhe_files.py.

◆ line

merge_lhe_files.line = line.replace(tmp[0],str(nevents))

Definition at line 40 of file merge_lhe_files.py.

◆ nnn

merge_lhe_files.nnn = str(nevents)

Definition at line 44 of file merge_lhe_files.py.

◆ tmp

merge_lhe_files.tmp = line.split("=")

each input file ends with "</LesHouchesEvents>".

Powheg format is numevts n.

We don't want to write this out until all the files have been read. The elif below writes out all the events. Format for storing number of events different in MG and Powheg MG5 format is "n = nevents"

Definition at line 39 of file merge_lhe_files.py.

CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Trk::open
@ open
Definition: BinningType.h:40
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
merge_lhe_files.merge_lhe_files
def merge_lhe_files(listOfFiles, outputFile)
Definition: merge_lhe_files.py:4