ATLAS Offline Software
Functions | Variables
PrepareReferenceFile Namespace Reference

Functions

def iterate (ROOT.TDirectory thisdir, ROOT.TDirectory targetdir, str prefix, typing.Pattern regex, bool excludeTrees)
 

Variables

 parser = argparse.ArgumentParser()
 
 default
 
 args = parser.parse_args()
 
 infile = ROOT.TFile.Open(args.infile, "READ")
 
 outfile = ROOT.TFile.Open(args.outfile, "RECREATE")
 
 regex = re.compile(args.excludeRegex)
 

Function Documentation

◆ iterate()

def PrepareReferenceFile.iterate ( ROOT.TDirectory  thisdir,
ROOT.TDirectory  targetdir,
str  prefix,
typing.Pattern  regex,
bool  excludeTrees 
)
Recurse to copy all objects except those of regex

Definition at line 10 of file PrepareReferenceFile.py.

10 def iterate(thisdir: ROOT.TDirectory, targetdir: ROOT.TDirectory, prefix: str, regex: typing.Pattern,
11  excludeTrees: bool):
12  """Recurse to copy all objects except those of regex"""
13  for k in thisdir.GetListOfKeys():
14  if k.GetClassName().startswith('TDirectory'):
15  targetsubdirname = thisdir.GetPath()[len(prefix):] + '/' + k.GetName()
16  if regex.fullmatch(targetsubdirname):
17  print('Now skipping', targetsubdirname)
18  continue
19  targetsubdir = targetdir.mkdir(k.GetName())
20  iterate(o := k.ReadObj(), targetsubdir, prefix, regex, excludeTrees)
21  ROOT.SetOwnership(o, True)
22  else:
23  if k.GetClassName().startswith('TTree'):
24  if not args.excludeTrees or k.GetName() == 'metadata':
25  targetdir.WriteObject(o := k.ReadObj().CloneTree(), k.GetName())
26  ROOT.SetOwnership(o, True)
27  else:
28  targetdir.WriteObject(o := k.ReadObj(), k.GetName())
29  ROOT.SetOwnership(o, True)
30 

Variable Documentation

◆ args

PrepareReferenceFile.args = parser.parse_args()

Definition at line 39 of file PrepareReferenceFile.py.

◆ default

PrepareReferenceFile.default

Definition at line 36 of file PrepareReferenceFile.py.

◆ infile

PrepareReferenceFile.infile = ROOT.TFile.Open(args.infile, "READ")

Definition at line 41 of file PrepareReferenceFile.py.

◆ outfile

PrepareReferenceFile.outfile = ROOT.TFile.Open(args.outfile, "RECREATE")

Definition at line 42 of file PrepareReferenceFile.py.

◆ parser

PrepareReferenceFile.parser = argparse.ArgumentParser()

Definition at line 33 of file PrepareReferenceFile.py.

◆ regex

PrepareReferenceFile.regex = re.compile(args.excludeRegex)

Definition at line 43 of file PrepareReferenceFile.py.

dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
PrepareReferenceFile.iterate
def iterate(ROOT.TDirectory thisdir, ROOT.TDirectory targetdir, str prefix, typing.Pattern regex, bool excludeTrees)
Definition: PrepareReferenceFile.py:10