ATLAS Offline Software
Loading...
Searching...
No Matches
CheckDAODCompleteness.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
4
18
19# argument for the SQL request
20def MakeArg( DSidentifier, InputType):
21
22 arg='-gLiteEntity=\"prodsys_task\" -gLiteQuery=\"SELECT prodsys_task.prodsysIdentifier, prodsys_task.nInputEvents, prodsys_task.nInputEventsUsed, prodsys_task.datasetFK, prodsys_task.identifier , prodsys_task.taskStatus WHERE dataset.identifier=\'%s\'\", -processingStep=\"production\" -project=\"mc15_001\" -sql=\"SELECT prodsys_task.prodsysIdentifier, prodsys_task.nInputEvents, prodsys_task.nInputEventsUsed, prodsys_task.datasetFK, prodsys_task.identifier ,\'mc15_001\' as PROJECT,\'production\' as PROCESS, \'prodsys_task\' as AMIENTITYNAME, prodsys_task.identifier as AMIELEMENTID , FROM dataset,prodsys_task WHERE (dataset.identifier IN (SELECT dataset.identifier FROM dataset WHERE dataset.identifier = \'%s\')) AND (dataset.identifier = prodsys_task.datasetFK ) AND (\'DATA_DELETED\' <> prodsys_task.taskStatus)\" -stats=\"prodsys_task.%s\"' % (DSidentifier, DSidentifier, InputType)
23
24 return arg
25
26
27from sys import argv
28import pyAMI.client
29
30client = pyAMI.client.Client('atlas')
31
32if len(argv) != 2:
33 print "Error: please pass the script an input file containing a list of MC15 DAODs:"
34 print "CheckDAODCompleteness.py list_of_datasets.txt"
35 exit(0)
36
37print "Reading list of DAODs from file %s" % argv[1]
38
39infile = open(argv[1],"r")
40
41import time
42outfilenom = 'for_reprocessing_'+time.strftime('%y%m%d_%H%M%S')+'.txt'
43outfile = open(outfilenom,'w')
44found_a_file = False
45
46for asample in infile.readlines():
47 # Get rid of comments
48 sample = asample.split('#')[0].strip()
49 # Skip blank linkes
50 if ''==sample: continue
51
52 if 'mc15_13TeV' not in sample or '_p' not in sample or not 'merge.DAOD_' in sample:
53 print "unexpected input %s, the script only runs over MC15 DAODs" % sample
54 continue
55
56 # strip mc15_13TeV: if present
57 sample = sample.replace('mc15_13TeV:','')
58
59 print 'Checking sample',sample
60
61 result_DAOD = client.execute(['GetDatasetInfo', '-logicalDatasetName=%s'%sample], format = 'dict_object')
62
63 identifier=result_DAOD.get_rows('Element_Info')[0]['identifier']
64
65 # SQL query to retrieve nInputEvents and nInputEventsUsed for that DAOD
66 nInputEvents_DAOD = int(client.execute(['SearchQuery', MakeArg(identifier,'nInputEvents')], format = 'dict_object').get_rows('Element_Info')[0]['SUM'])
67 nInputEventsUsed_DAOD = int(client.execute(['SearchQuery', MakeArg(identifier,'nInputEventsUsed')], format = 'dict_object').get_rows('Element_Info')[0]['SUM'])
68
69 # this checks whether some derivation jobs have failed
70 if nInputEventsUsed_DAOD < nInputEvents_DAOD:
71 print "\nWarning: nInputEvents_DAOD = %i, nInputEventsUsed_DAOD = %i, likely some failed derivation jobs\n"%(nInputEvents_DAOD,nInputEventsUsed_DAOD)
72 elif nInputEventsUsed_DAOD > nInputEvents_DAOD:
73 print "\nERROR: INCONSISTENT RESULT, nInputEvents_DAOD = %i, nInputEventsUsed_DAOD = %i\n"%(nInputEvents_DAOD,nInputEventsUsed_DAOD)
74
75 # retrieve number of events in xAOD
76 result_xAOD = client.execute(['GetDatasetProv', '-logicalDatasetName=%s'%sample], format = 'dict_object')
77 nEvents_xAOD = int(result_xAOD.get_rows('node')[1]['events'])
78
79 # this checks whether the derivation job was run over the full xAOD
80 if nInputEvents_DAOD < nEvents_xAOD:
81 print "\nWARNING !!! NOT ALL xAOD EVENTS WERE PROCESSED: number of events in xAOD = %i, number of input events for DAOD = %i"%(nEvents_xAOD,nInputEvents_DAOD)
82 print "This DAOD should be reprocessed (with the same ptag) to pick up the remaining statistics\n"
83 outfile.write(sample+'\n')
84 found_a_file=True
85 elif nInputEvents_DAOD > nEvents_xAOD:
86 print "\nERROR: INCONSISTENT RESULT, number of event in xAOD = %i, number of input events for DAOD = %i\n"%(nEvents_xAOD,nInputEvents_DAOD)
87
88infile.close()
89outfile.close()
90
91if found_a_file:
92 print 'You can find all samples that should be reprocessed in the file',outfilenom
93 print 'Please request derivations for these samples at http://its.cern.ch/jira/browse/ATLSUSYDPD'
94else:
95 import os
96 os.remove( outfilenom )
97
MakeArg(DSidentifier, InputType)
B.