ATLAS Offline Software
Loading...
Searching...
No Matches
copySelective Namespace Reference

Functions

 copyHist (indir, outdir, dirfilt)

Variables

str dirfilt = 'run_.*|GLOBAL|lb_.*|lowStat_LB.*|DQTGlobalWZFinder'
str source = 'test.root'
str target = 'copy.root'
 infile = ROOT.TFile(source)
 outfile = ROOT.TFile.Open(target, "RECREATE")

Function Documentation

◆ copyHist()

copySelective.copyHist ( indir,
outdir,
dirfilt )

Definition at line 5 of file copySelective.py.

5def copyHist(indir, outdir, dirfilt):
6 print("Decending into directory", indir.GetName())
7 for key in indir.GetListOfKeys():
8 obj = indir.Get(key.GetName())
9
10 isdir = obj.InheritsFrom("TDirectory")
11 ishist = obj.InheritsFrom("TH1")
12
13 match = True
14 if isdir: match = re.match(dirfilt, obj.GetName()) != None
15
16 #print(key.GetName(), match, isdir, ishist)
17 if not match: continue
18
19 outdir.cd()
20 if isdir:
21 newoutdir = outdir.mkdir(obj.GetName())
22 newindir = obj
23 copyHist(newindir, newoutdir, dirfilt)
24
25 if ishist:
26 obj.Write()
27
28
void print(char *figname, TCanvas *c1)

Variable Documentation

◆ dirfilt

str copySelective.dirfilt = 'run_.*|GLOBAL|lb_.*|lowStat_LB.*|DQTGlobalWZFinder'

Definition at line 29 of file copySelective.py.

◆ infile

copySelective.infile = ROOT.TFile(source)

Definition at line 43 of file copySelective.py.

◆ outfile

copySelective.outfile = ROOT.TFile.Open(target, "RECREATE")

Definition at line 48 of file copySelective.py.

◆ source

copySelective.source = 'test.root'

Definition at line 31 of file copySelective.py.

◆ target

copySelective.target = 'copy.root'

Definition at line 36 of file copySelective.py.