ATLAS Offline Software
Classes | Functions | Variables
check-daod-stats Namespace Reference

Classes

class  term
 

Functions

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

Variables

 _orig_argv = sys.argv[:]
 
 argv
 

Function Documentation

◆ check_derivation_stats()

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

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

110 def 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()

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

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

99 def 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()

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

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

36 def 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()

def check-daod-stats.get_cbk_events (   root_file)

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

66 def 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()

def check-daod-stats.get_local_events (   files)

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

79 def 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 

◆ get_xaod_name()

def check-daod-stats.get_xaod_name (   dataset)

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

43 def 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()

def check-daod-stats.load_files (   opts)

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

120 def 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()

def check-daod-stats.main ( )

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

144 def 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 

◆ parse_opts()

def check-daod-stats.parse_opts ( )

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

133 def 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[:]
private

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.

xrange
void xrange(TH1 *h, bool symmetric)
Definition: computils.cxx:516
check-daod-stats.get_xaod_name
def get_xaod_name(dataset)
Definition: check-daod-stats.py:43
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
check-daod-stats.check_derivation_stats
def check_derivation_stats(ami_client, dataset, daod_events)
Definition: check-daod-stats.py:110
check-daod-stats.get_ami_events
def get_ami_events(ami_client, dataset)
Definition: check-daod-stats.py:36
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
check-daod-stats.parse_opts
def parse_opts()
Definition: check-daod-stats.py:133
check-daod-stats.get_cbk_events
def get_cbk_events(root_file)
Definition: check-daod-stats.py:66
check-daod-stats.get_local_events
def get_local_events(files)
Definition: check-daod-stats.py:79
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
check-daod-stats.load_files
def load_files(opts)
Definition: check-daod-stats.py:120
check-daod-stats.main
def main()
Definition: check-daod-stats.py:144
Trk::open
@ open
Definition: BinningType.h:40
check-daod-stats.check_sample_stats
def check_sample_stats(ami_client, dataset, cbk_events)
Definition: check-daod-stats.py:99