ATLAS Offline Software
JetAnalysisAlgorithmsTest_EMTopo_eljob.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
4 #
5 # @author Nils Krumnack
6 
7 
8 # Read the submission directory as a command line argument. You can
9 # extend the list of arguments with your private ones later on.
10 import optparse
11 parser = optparse.OptionParser()
12 parser.add_option( '-d', '--data-type', dest = 'data_type',
13  action = 'store', type = 'string', default = 'data',
14  help = 'Type of data to run over. Valid options are data, mc, afii' )
15 parser.add_option( '-s', '--submission-dir', dest = 'submission_dir',
16  action = 'store', type = 'string', default = 'submitDir',
17  help = 'Submission directory for EventLoop' )
18 parser.add_option( '-u', '--unit-test', dest='unit_test',
19  action = 'store_true', default = False,
20  help = 'Run the job in "unit test mode"' )
21 ( options, args ) = parser.parse_args()
22 
23 # Set up (Py)ROOT.
24 import ROOT
25 ROOT.xAOD.Init().ignore()
26 
27 # ideally we'd run over all of them, but we don't have a mechanism to
28 # configure per-sample right now
29 
30 dataType = options.data_type
31 
32 inputfile = {"data": 'ASG_TEST_FILE_DATA',
33  "mc": 'ASG_TEST_FILE_MC',
34  "afii": 'ASG_TEST_FILE_MC_AFII'}
35 
36 jetContainer = "AntiKt4EMTopoJets"
37 
38 if dataType not in ["data", "mc", "afii"] :
39  raise ValueError ("invalid data type: " + dataType)
40 
41 # Set up the sample handler object. See comments from the C++ macro
42 # for the details about these lines.
43 import os
44 sh = ROOT.SH.SampleHandler()
45 sh.setMetaString( 'nc_tree', 'CollectionTree' )
46 sample = ROOT.SH.SampleLocal (dataType)
47 sample.add (os.getenv (inputfile[dataType]))
48 sh.add (sample)
49 sh.printContent()
50 
51 # Create an EventLoop job.
52 job = ROOT.EL.Job()
53 job.sampleHandler( sh )
54 job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 )
55 
56 from JetAnalysisAlgorithms.JetAnalysisAlgorithmsTest import makeSequence
57 algSeq = makeSequence (dataType, jetContainer)
58 print (algSeq) # For debugging
59 algSeq.addSelfToJob( job )
60 
61 # Set up an output file for the job:
62 job.outputAdd( ROOT.EL.OutputStream( 'ANALYSIS' ) )
63 
64 # Find the right output directory:
65 submitDir = options.submission_dir
66 if options.unit_test:
67  import os
68  import tempfile
69  submitDir = tempfile.mkdtemp( prefix = 'jetTest_'+dataType+'_EMTopo_', dir = os.getcwd() )
70  os.rmdir( submitDir )
71  pass
72 
73 # Run the job using the direct driver.
74 driver = ROOT.EL.DirectDriver()
75 driver.submit( job, submitDir )
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:54