ATLAS Offline Software
Loading...
Searching...
No Matches
check-daod-stats Namespace Reference

Classes

class  term

Functions

 get_ami_events (ami_client, dataset)
 get_xaod_name (dataset)
 get_cbk_events (root_file)
 get_local_events (files)
 check_sample_stats (ami_client, dataset, cbk_events)
 check_derivation_stats (ami_client, dataset, daod_events)
 load_files (opts)
 parse_opts ()
 main ()

Variables

 _orig_argv = sys.argv[:]
 argv

Function Documentation

◆ check_derivation_stats()

check-daod-stats.check_derivation_stats ( ami_client,
dataset,
daod_events )

Definition at line 110 of file check-daod-stats.py.

110def check_derivation_stats(ami_client, dataset, daod_events):
111 ami_events = get_ami_events(ami_client, dataset)
112
113 if ami_events == daod_events:
114 print term.GREEN + "Derviation events good: %d events" % ami_events, term.ENDC
115 else:
116 print term.RED + "Derviation events bad: %d events (local), %d events (AMI)" % (daod_events, ami_events), term.ENDC
117
118 return ami_events == daod_events
119

◆ check_sample_stats()

check-daod-stats.check_sample_stats ( ami_client,
dataset,
cbk_events )

Definition at line 99 of file check-daod-stats.py.

99def check_sample_stats(ami_client, dataset, cbk_events):
100 xaod = get_xaod_name(dataset)
101 ami_events = get_ami_events(ami_client, xaod)
102
103 if ami_events == cbk_events:
104 print term.GREEN + "CutBookkeepers good: %d events" % ami_events, term.ENDC
105 else:
106 print term.RED + "CutBookkeepers bad: %d events (local), %d events (AMI)" % (cbk_events, ami_events), term.ENDC
107
108 return ami_events == cbk_events
109

◆ get_ami_events()

check-daod-stats.get_ami_events ( ami_client,
dataset )

Definition at line 36 of file check-daod-stats.py.

36def get_ami_events(ami_client, dataset):
37 results = atlas_api.get_dataset_info(ami_client, dataset)
38 if len(results) != 1:
39 print "WARNING: %d results returned from AMI, expected 1" % len(results)
40
41 return int(results[0]["totalEvents"])
42

◆ get_cbk_events()

check-daod-stats.get_cbk_events ( root_file)

Definition at line 66 of file check-daod-stats.py.

66def get_cbk_events(root_file):
67 tree = xAOD.MakeTransientMetaTree(root_file)
68 tree.GetEntry(0)
69
70 max_cycle = -1
71 all_events_cbk = None
72 for cbk in tree.CutBookkeepers:
73 if cbk.cycle() > max_cycle and cbk.name() == "AllExecutedEvents" and cbk.inputStream() == "StreamAOD":
74 max_cycle = cbk.cycle()
75 all_events_cbk = cbk
76
77 return all_events_cbk.nAcceptedEvents()
78

◆ get_local_events()

check-daod-stats.get_local_events ( files)

Definition at line 79 of file check-daod-stats.py.

79def get_local_events(files):
80 num_files = len(files)
81
82 daod_events = 0
83 cbk_events = 0
84
85 for i in xrange(num_files):
86 sys.stdout.write("Reading local statistics, file %d/%d (%d events so far)..." % (i+1, num_files, daod_events))
87 sys.stdout.flush()
88
89 rf = TFile.Open(files[i])
90 daod_events += rf.Get("CollectionTree").GetEntries()
91 cbk_events += get_cbk_events(rf)
92 rf.Close()
93
94 sys.stdout.write(term.CLEAR_LINE)
95 sys.stdout.flush()
96
97 return daod_events, cbk_events
98
TGraphErrors * GetEntries(TH2F *histo)
void xrange(TH1 *h, bool symmetric)

◆ get_xaod_name()

check-daod-stats.get_xaod_name ( dataset)

Definition at line 43 of file check-daod-stats.py.

43def get_xaod_name(dataset):
44 if ":" in dataset:
45 dataset = dataset.split(":")[1]
46
47 parts = dataset.split(".")
48 xaod_parts = []
49 for p in parts:
50 if "DAOD" in p: # remove derivation type
51 p = "AOD"
52
53 if "deriv" in p: # recon.AOD instead of deriv.DAOD
54 p = "recon"
55
56 if "_p" in p: # remove p-tag
57 if p.endswith("/"):
58 p = p[:-7] # 7 == len("_p1234/")
59 else:
60 p = p[:-6] # 6 == len("_p1234")
61
62 xaod_parts.append(p)
63
64 return ".".join(xaod_parts)
65

◆ load_files()

check-daod-stats.load_files ( opts)

Definition at line 120 of file check-daod-stats.py.

120def load_files(opts):
121 infile = open(opts.file_list, "r")
122
123 files = []
124 for line in infile:
125 line = line.strip()
126 if line == "" or line.startswith("#"):
127 continue
128
129 files.append(line)
130
131 return files
132

◆ main()

check-daod-stats.main ( )

Definition at line 144 of file check-daod-stats.py.

144def main():
145 opts = parse_opts()
146
147 files = load_files(opts)
148
149 print "Initializing PyAMI"
150 ami_client = pyAMI.client.Client("atlas")
151 atlas_api.init()
152
153 print "Checking dataset %s with %d files" % (opts.dataset, len(files))
154
155 daod_events, cbk_events = get_local_events(files)
156
157 good = True
158 if not check_derivation_stats(ami_client, opts.dataset, daod_events):
159 good = False
160 if not check_sample_stats(ami_client, opts.dataset, cbk_events):
161 good = False
162
163 if not good:
164 sys.exit(1)
165
int main()
Definition hello.cxx:18

◆ parse_opts()

check-daod-stats.parse_opts ( )

Definition at line 133 of file check-daod-stats.py.

133def parse_opts():
134 import argparse
135
136 parser = argparse.ArgumentParser()
137 parser.add_argument("dataset", help="Name of the dataset, something like mc15_13TeV.123456.SomeGenerator.DAOD_SUSY5.e1234_p4321")
138 parser.add_argument("file_list", help="List of files, belonging to the dataset")
139
140 opts = parser.parse_args()
141
142 return opts
143

Variable Documentation

◆ _orig_argv

check-daod-stats._orig_argv = sys.argv[:]
protected

Definition at line 8 of file check-daod-stats.py.

◆ argv

check-daod-stats.argv

Definition at line 9 of file check-daod-stats.py.