8 from datetime
import date
12 parser = optparse.OptionParser()
14 parser.add_option(
'--driver', dest =
'driver', choices = [
'direct',
'grid',
'lxplus'], default =
'direct')
15 parser.add_option(
'--gridTag', dest =
'gridTag')
16 parser.add_option(
'--submitFlags', dest =
'submitFlags')
17 parser.add_option(
'--express', dest =
'express', default =
False, action =
'store_true' )
18 parser.add_option(
'-n',
'--dryrun', dest =
'dryrun', default=
False, action =
'store_true' )
20 parser.add_option(
'--log-level', dest =
'log_level', default =
'INFO', choices = [
'ALWAYS',
'FATAL',
'ERROR',
'WARNING',
'INFO',
'DEBUG',
'VERBOSE'])
21 parser.add_option(
'--dosyst', dest =
'dosyst', default =
False, action =
'store_true')
22 parser.add_option(
'-s',
'--submission-dir', dest =
'submission_dir', default =
'submitDir', help =
'Submission directory for EventLoop' )
23 parser.add_option(
'-t',
'--type', dest =
'type', default =
'mc20e', help =
'Job type. (mc20a, mc20d, mc20e, mc23a, mc23d, data18, data22, data23)', choices = [
'mc20a',
'mc20d',
'mc20e',
'mc23a',
'mc23d',
'data18',
'data22',
'data23'])
24 parser.add_option(
'--AF', dest =
'AF', default =
False, action =
'store_true' )
25 parser.add_option(
'-f',
'--flav', dest =
'flav', default =
'PHYS', choices = [
"PHYS",
"PHYSLITE"], help =
'input DAOD flavour' )
26 parser.add_option(
'-m',
'--maxEvts', dest =
'maxEvts', type =
'int', default = -1, help =
'Max events (-1 is all)' )
27 parser.add_option(
'-M',
'--maxEvtsManual', dest =
'maxEvtsManual', type =
'int')
28 parser.add_option(
'-p',
'--ptag', dest =
'ptag', default =
'p6266', help =
'ptag' )
29 parser.add_option(
'--grl', dest =
'grl')
30 parser.add_option(
'--inputDir', dest =
'inputDir')
31 parser.add_option(
'--inputFile', dest =
'inputFile')
32 parser.add_option(
'--inputGrid', dest =
'inputGrid')
33 parser.add_option(
'--inputXRD', dest =
'inputXRD')
34 parser.add_option(
'--overwrite', dest =
'overwrite', default =
False, action =
'store_true' )
35 ( options, args ) = parser.parse_args()
38 print(
"Configured input data ptag: %s"%(options.ptag))
39 ptageqdata = {
'p6266' :
'p6269'}
40 if 'data2' in options.type
and options.ptag
in ptageqdata:
41 options.ptag = ptageqdata[options.ptag]
42 print(
"Overriding ptag to equivalent data ptag: -> %s"%(options.ptag))
43 print(
"Configured input data type: %s"%(options.type))
44 print(
"Configured input data DAOD flavour: %s"%(options.flav))
45 print(
"Configured input data sim type: %s"%(
'FullSim' if not options.AF
else 'AF'))
52 outputlvl = {
'INFO':ROOT.MSG.INFO,
'DEBUG':ROOT.MSG.DEBUG,
'VERBOSE':ROOT.MSG.VERBOSE,
'FATAL':ROOT.MSG.FATAL,
'ALWAYS':ROOT.MSG.ALWAYS,
'ERROR':ROOT.MSG.ERROR,
'WARNING':ROOT.MSG.WARNING}
57 sh = ROOT.SH.SampleHandler()
58 sh.setMetaString(
'nc_tree',
'CollectionTree' )
61 if options.overwrite
and os.path.exists(options.submission_dir): shutil.rmtree(options.submission_dir)
64 cvmfsInputArea =
'/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SUSYTools'
65 sim_type =
"FS" if not options.AF
else "AF3"
67 inputFiles[
'mc20e'] =
'DAOD_%s.mc20_13TeV.410470.%s_mc20e_%s.%s.pool.root'%(options.flav, sim_type, options.ptag, options.flav)
68 inputFiles[
'mc23a'] =
'mc23_13p6TeV.601229.%s_mc23a_%s.%s.pool.root'%(sim_type, options.ptag, options.flav)
69 inputFiles[
'mc23d'] =
'mc23_13p6TeV.601229.%s_mc23d_%s.%s.pool.root'%(sim_type, options.ptag, options.flav)
70 inputFiles[
'data18'] =
'data18_13TeV.39757132_%s.%s.pool.root'%(options.ptag,options.flav)
71 inputFiles[
'data22'] =
'data22_13p6TeV.39672246_%s.%s.pool.root'%(options.ptag,options.flav)
72 inputFiles[
'data23'] =
'data23_13p6TeV.39756993_%s.%s.pool.root'%(options.ptag,options.flav)
79 print(
"Using inputXRD: ",options.inputXRD)
80 pref,server,fname = options.inputXrootd.plit(
'//')
81 dl = ROOT.SH.DiskListXRD(server,fname)
82 ROOT.SH.ScanDir().
scan(sh,dl)
83 elif options.inputGrid:
84 print(
"Using inputGrid: ",options.inputGrid)
85 dsname = options.inputGrid.split(
':')[-1].rstrip()
86 ROOT.SH.addGrid(sh,dsname)
88 inputDir = cvmfsInputArea
89 inputFile = inputFiles[options.type]
if options.type
in inputFiles
else ''
91 if options.inputDir: inputDir = options.inputDir
92 if options.inputFile: inputFile = options.inputFile
94 print(
"Using inputDir: ",inputDir)
95 print(
"Using inputFile:",inputFile)
101 job.sampleHandler( sh )
102 job.options().setDouble( ROOT.EL.Job.optMaxEvents, options.maxEvts )
106 from AnaAlgorithm.AnaAlgorithmConfig
import AnaAlgorithmConfig
107 config = AnaAlgorithmConfig(
'SUSYToolsAlg' )
108 config.addPrivateTool(
"SUSYTools",
"ST::SUSYObjDef_xAOD")
110 config.SUSYTools.ConfigFile =
"SUSYTools/SUSYTools_Default.conf"
111 if (
"data2" in options.type
or "mc23" in options.type): config.SUSYTools.ConfigFile =
"SUSYTools/SUSYTools_Default_Run3.conf"
112 if (
"data" not in options.type): config.DoSyst = options.dosyst
113 config.SUSYTools.DataSource = 1
114 config.OutputLevel = outputlvl[options.log_level]
115 config.SUSYTools.OutputLevel = outputlvl[options.log_level]
116 config.SUSYTools.PRWLumiCalcFiles = []
117 config.SUSYTools.AutoconfigurePRWTool =
True
118 config.SUSYTools.PRWUseCommonMCFiles =
True
119 if options.flav ==
"PHYSLITE":
120 print(
"Running on PHYSLITE : ", inputFile)
121 STconfig_lite =
str(config.SUSYTools.ConfigFile).
replace(
".conf",
"_LITE.conf")
122 config.SUSYTools.ConfigFile = STconfig_lite
123 config.SUSYTools.IsPHYSLITE =
True
127 config.SUSYTools.DataSource = 2
130 if 'mc' in options.type:
131 mcCampaign = options.type
132 config.SUSYTools.mcCampaign = options.type
133 elif options.type ==
'data18':
135 config.SUSYTools.mcCampaign = options.type
136 config.SUSYTools.DataSource = 0
137 elif options.type ==
'data22':
139 config.SUSYTools.mcCampaign = options.type
140 config.SUSYTools.DataSource = 0
141 elif options.type ==
'data23':
143 config.SUSYTools.mcCampaign = options.type
144 config.SUSYTools.DataSource = 0
149 PRWLumiCalc[
'mc20a'] = [
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data16_13TeV/20180129/PHYS_StandardGRL_All_Good_25ns_297730-311481_OflLumi-13TeV-009.root',
150 '/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data15_13TeV/20170619/PHYS_StandardGRL_All_Good_25ns_276262-284484_OflLumi-13TeV-008.root']
151 PRWLumiCalc[
'mc20d'] = [
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data17_13TeV/20180619/physics_25ns_Triggerno17e33prim.lumicalc.OflLumi-13TeV-010.root']
152 PRWLumiCalc[
'mc20e'] = [
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data18_13TeV/20190318/ilumicalc_histograms_None_348885-364292_OflLumi-13TeV-010.root']
153 PRWLumiCalc[
'mc23a'] = [
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data22_13p6TeV/20230207/ilumicalc_histograms_None_431810-440613_OflLumi-Run3-003.root']
154 PRWLumiCalc[
'mc23d'] = [
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data23_13p6TeV/20230828/ilumicalc_histograms_None_451587-456749_OflLumi-Run3-003.root']
156 config.SUSYTools.PRWLumiCalcFiles = PRWLumiCalc[mcCampaign]
158 if options.grl: config.GRLFiles = options.grl.split(
',')
159 if options.maxEvtsManual: config.maxEvts = options.maxEvtsManual
162 job.algsAdd( config )
163 if options.driver ==
'direct':
165 driver = ROOT.EL.DirectDriver()
166 if not options.dryrun:
167 driver.submit( job, options.submission_dir )
168 elif options.driver ==
'grid':
169 driver = ROOT.EL.PrunDriver()
170 submitFlags = [
'--addNthFieldOfInDSToLFN=2,6']
171 if options.submitFlags: submitFlags += [options.submitFlags]
172 if not options.gridTag: options.gridTag = date.today().strftime(
'%y%m%d')
173 outName =
'user.%s.%%in:name[1]%%.%%in:name[2]%%.%%in:name[3]%%.STAlg_%s'%(os.environ[
'USER'],options.gridTag)
174 driver.options().setString(
"nc_outputSampleName", outName );
175 driver.options().setString(
"nc_EventLoop_SubmitFlags",
' '.
join(submitFlags))
176 driver.options().setDouble(ROOT.EL.Job.optGridMergeOutput, 0)
177 if not options.dryrun:
178 if options.express: driver.options().setDouble(ROOT.EL.Job.optGridExpress, 1)
179 driver.submitOnly( job, options.submission_dir )