ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
ZLumiScripts
scripts
Pandas_scripts
copySelective.py
Go to the documentation of this file.
1
import
sys, os, glob
2
import
ROOT
3
import
re
4
5
def
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
29
dirfilt =
'run_.*|GLOBAL|lb_.*|lowStat_LB.*|DQTGlobalWZFinder'
30
31
source =
'test.root'
32
if
len(sys.argv) > 1:
33
source = sys.argv[1]
34
35
# output file
36
target =
'copy.root'
37
if
len(sys.argv) > 2:
38
target = sys.argv[2]
39
40
print
(
"Copy from"
, source,
"to"
, target,
"with directory filter"
, dirfilt)
41
42
# open source file
43
infile = ROOT.TFile(source)
44
if
not
infile.IsOpen():
45
print
(
'Problem with input file'
, source)
46
exit(1)
47
# open output file
48
outfile = ROOT.TFile.Open(target,
"RECREATE"
)
49
if
not
outfile.IsOpen():
50
print
(
'Problem with output file'
, target)
51
exit(1)
52
53
copyHist
(infile, outfile, dirfilt)
54
55
infile.Close()
56
outfile.Close()
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
copySelective.copyHist
copyHist(indir, outdir, dirfilt)
Definition
copySelective.py:5
Generated on
for ATLAS Offline Software by
1.17.0