ATLAS Offline Software
Loading...
Searching...
No Matches
readjo.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3import sys, os, glob
4
5
6def include(filename):
7 #needed for the inclusion of additional files in the joboptions
8 if "Filter" in filename:
9 return None
10 if os.path.exists(filename):
11 exec(compile(open(filename, "rb").read(), filename, 'exec'), globals())
12 else:
13 found = False
14 for jopath in os.environ['JOBOPTSEARCHPATH'].split(":"):
15 fullpath = jopath+"/"+filename
16 if os.path.exists(fullpath):
17 found = True
18 exec(compile(open(fullpath, "rb").read(), fullpath, 'exec'), globals())
19 if not found:
20 print ("Did not find "+fullpath)
21 print ("ERROR: file not found. Possibly no cvmfs access.")
22 sys.exit(10)
23
24#general functions
25class dotdict(dict):
26 """dot.notation access to dictionary attributes"""
27 __getattr__ = dict.get
28 __setattr__ = dict.__setitem__
29 __delattr__ = dict.__delitem__
30 def __iadd__(self, val):
31 return self
32
33def readJO(options):
34 mainJOfile = glob.glob("mc.*.py")
35 if len(mainJOfile)!=1:
36 print ("ERROR: found 0 or multiple mc.*.py files in main jobOptionDir")
37 sys.exit(2)
38 options.mainJOfile = mainJOfile[0]
39
40 #load job option file and additional option file with execfile
41 #important output variables
42 global genSeq
43 global evgenConfig
44 genSeq = dotdict({"Sherpa_i":dotdict({
45 "Parameters":[],
46 "OpenLoopsLibs":[],
47 "NCores":24,
48 "RunCard":"",
49 "ExtraFiles":[],
50 "MemoryMB":1,
51 "PluginCode":"",
52 })})
53 evgenConfig = dotdict({"generators":[]})
54
55 #some input variables which effect genSeq.Sherpa_i.Parameters
56 global runArgs
57 global pdfgridpath
58 configname = "Sherpa.yaml" if os.environ["SHERPAVER"].startswith('3.') else "Run.dat"
59 runArgs = dotdict({"jobConfig":[configname],"ecmEnergy":1000.*float(options.ecm[0])})
60 pdfgridpath = "todo"
61
62 #some dummy variables
63 global testSeq
64 global filtSeq
65 global HeavyFlavorBHadronFilter
66 HeavyFlavorBHadronFilter = True
67 global HeavyFlavorCHadronPt4Eta3_Filter
68 HeavyFlavorCHadronPt4Eta3_Filter = True
69 testSeq = dotdict({
70 "TestHepMC":dotdict({
71 "NoDecayVertexStatuses":[]
72 }),
73 })
74 testSeq = 0 # temp workaround as long as base fragment still removes TestHepMC
75 filtSeq = dotdict({
76 "DecaysFinalStateFilter":dotdict({
77 "NChargedLeptons":True,
78 "NQuarks":2,
79 "PDGAllowedParents":[23]
80 }),
81 "Expression":"",
82 })
83
84 #import dummy.py which is later included as replacement for Sherpa_i.Sherpa_iConf
85 from . import dummy
86 sys.modules["Sherpa_i.Sherpa_iConf"] = dummy
87 sys.modules["Sherpa_i"] = dummy
88
89 sys.modules["GeneratorFilters.GeneratorFiltersConf"] = dummy
90 sys.modules["GeneratorFilters"] = dummy
91
92 exec(compile(open(options.mainJOfile, "rb").read(), options.mainJOfile, 'exec'), globals())
93
94 if genSeq.Sherpa_i.RunCard == "":
95 print ("ERROR: no runCard found in the JO-File")
96 sys.exit(11)
97
98 # output information into options
99 options.Sherpa_i = genSeq.Sherpa_i
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
include(filename)
Definition readjo.py:6
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)