ATLAS Offline Software
PileupAlgorithmsTest_eljob.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 #
4 # @author Jon Burr
5 # adapted from GeneratorAlgorithmsTest_eljob.py
6 
7 # Only test on 'mc'
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( '-s', '--submission-dir', dest = 'submission_dir',
13  action = 'store', type = 'string', default = 'submitDir',
14  help = 'Submission directory for EventLoop' )
15 parser.add_option( '-u', '--unit-test', dest='unit_test',
16  action = 'store_true', default = False,
17  help = 'Run the job in "unit test mode"' )
18 ( options, args ) = parser.parse_args()
19 
20 # Set up (Py)ROOT.
21 import ROOT
22 ROOT.xAOD.Init().ignore()
23 
24 dataType = "mc"
25 
26 # Set up the sample handler object. See comments from the C++ macro
27 # for the details about these lines.
28 import os
29 sh = ROOT.SH.SampleHandler()
30 sh.setMetaString( 'nc_tree', 'CollectionTree' )
31 sample = ROOT.SH.SampleLocal (dataType)
32 sample.add (os.getenv ("ASG_TEST_FILE_MC"))
33 sh.add (sample)
34 sh.printContent()
35 
36 # Create an EventLoop job.
37 job = ROOT.EL.Job()
38 job.sampleHandler( sh )
39 job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 )
40 
41 from AsgAnalysisAlgorithms.AsgAnalysisAlgorithmsTest import makePileupSequence
43 print( algSeq ) # For debugging
44 algSeq.addSelfToJob( job )
45 
46 # Set up an output file for the job:
47 job.outputAdd( ROOT.EL.OutputStream( 'ANALYSIS' ) )
48 
49 # Find the right output directory:
50 submitDir = options.submission_dir
51 if options.unit_test:
52  import os
53  import tempfile
54  submitDir = tempfile.mkdtemp( prefix = 'genTest_', dir = os.getcwd() )
55  os.rmdir( submitDir )
56  pass
57 
58 # Run the job using the direct driver.
59 driver = ROOT.EL.DirectDriver()
60 driver.submit( job, submitDir )
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:54
python.AsgAnalysisAlgorithmsTest.makePileupSequence
def makePileupSequence()
Definition: AsgAnalysisAlgorithmsTest.py:268
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28