9 Python module to hold common flags to configure JobOptions.
11 From the python prompt:
12 >>> from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
13 >>> print athenaCommonFlags.EvtMax()
14 >>> athenaCommonFlags.EvtMax = 50
15 >>> assert( athenaCommonFlags.EvtMax() == 50 )
16 >>> athenaCommonFlags.print_JobProperties('tree&value')
20 __author__ =
"S.Binet, M.Gallas"
21 __version__=
"$Revision: 1.11 $"
22 __doc__ =
"AthenaCommonFlags"
24 __all__ = [
"athenaCommonFlags" ]
29 from AthenaCommon.JobProperties
import JobProperty, JobPropertyContainer
30 from AthenaCommon.JobProperties
import jobproperties
36 """Number of events to process or generate"""
38 allowedTypes = [
'int']
42 """Number of events to skip when reading an input POOL file. This should
43 be given to the EventSelector service.
46 allowedTypes = [
'int']
50 """The list of input data files (if not empty override all the specific XYZInput) """
52 allowedTypes = [
'list']
59 from AthenaCommon
import AppMgr
60 if hasattr(AppMgr.ServiceMgr,
"EventSelector")
and hasattr(AppMgr.ServiceMgr.EventSelector,
"InputCollections"):
61 AppMgr.ServiceMgr.EventSelector.InputCollections = self.
StoredValue
66 """The name of the ttree in the input file"""
69 StoredValue =
"CollectionTree"
72 from AthenaCommon
import AppMgr
73 if not hasattr(AppMgr.ServiceMgr,
"EventSelector"):
75 jobproperties.AthenaCommonFlags.AccessMode=
"TreeAccess"
77 if not hasattr(AppMgr.ServiceMgr.EventSelector,
"TupleName"):
79 raise ValueError(
"TreeName can only be CollectionTree if you are not using AccessMode=TreeAccess")
81 AppMgr.ServiceMgr.EventSelector.TupleName = self.
StoredValue
85 """The type of read mechanism to use in this athena job"""
88 allowedValues = [
"TreeAccess",
"TreeAccessWithEventInfo",
"BranchAccess",
"ClassAccess",
"AthenaAccess",
"POOLAccess"]
89 StoredValue =
"ClassAccess"
92 from AthenaCommon
import AppMgr
94 if self.
StoredValue in [
"ClassAccess",
"AthenaAccess",
"BranchAccess"]:
95 if hasattr(AppMgr.ServiceMgr,
"EventSelector"):
96 if AppMgr.ServiceMgr.EventSelector.getType()!=
"Athena::xAODEventSelector":
97 raise ValueError(
"Cannot switch to %s mode with existing EventSelector of type %s" % (self.
StoredValue,AppMgr.ServiceMgr.EventSelector.getType()) )
99 import AthenaRootComps.ReadAthenaxAODHybrid
100 if self.
StoredValue==
"ClassAccess": AppMgr.ServiceMgr.EventSelector.AccessMode = 1
101 elif self.
StoredValue==
"BranchAccess": AppMgr.ServiceMgr.EventSelector.AccessMode = 0
102 elif self.
StoredValue==
"AthenaAccess": AppMgr.ServiceMgr.EventSelector.AccessMode = 2
104 if hasattr(AppMgr.ServiceMgr,
"EventSelector"):
105 if AppMgr.ServiceMgr.EventSelector.getType()!=
"EventSelectorAthenaPool":
106 raise ValueError(
"Cannot switch to %s mode with existing EventSelector of type %s" % (self.
StoredValue,AppMgr.ServiceMgr.EventSelector.getType()) )
108 import AthenaPoolCnvSvc.ReadAthenaPool
110 if hasattr(AppMgr.ServiceMgr,
"EventSelector"):
111 if AppMgr.ServiceMgr.EventSelector.getType()!=
"Athena::RootNtupleEventSelector":
112 raise ValueError(
"Cannot switch to %s mode with existing EventSelector of type %s" % (self.
StoredValue,AppMgr.ServiceMgr.EventSelector.getType()) )
114 import AthenaRootComps.ReadAthenaRoot
115 AppMgr.ServiceMgr.EventSelector.TupleName = jobproperties.AthenaCommonFlags.TreeName()
117 AppMgr.ServiceMgr.EventSelector.CreateEventInfo =
True
118 AppMgr.ServiceMgr.AthenaEventLoopMgr.DoLiteLoop =
False
122 """A list of outputs to be produced by THistSvc in the format <streamName>:<fileName>"""
124 allowedTypes = [
'list']
128 from AthenaCommon
import CfgMgr
129 from AthenaCommon
import AppMgr
130 if not hasattr(AppMgr.ServiceMgr,
"THistSvc"):
131 AppMgr.ServiceMgr += CfgMgr.THistSvc()
134 if ":" not in output:
136 raise ValueError(
"HistOutputs: %s must be in format '<streamName>:<fileName>'" % output)
138 streamName = output.split(
":",1)[0]
139 fileName = output.split(
":",1)[1]
142 outputs = AppMgr.ServiceMgr.THistSvc.Output
144 for hsOutput
in outputs:
145 hsStreamName = hsOutput.split(
" ",1)[0]
146 if hsStreamName==streamName:
150 AppMgr.ServiceMgr.THistSvc.Output += [
"%s DATAFILE='%s' OPT='RECREATE'" % (streamName,fileName)]
154 """Allow an algorithm to ignore return error code from upstream algorithm
158 allowedTypes = [
'bool']
162 """ Set to True when running online
165 allowedTypes = [
'bool']
173 """Container for the common flags
180 jobproperties.add_Container(AthenaCommonFlags)
185 jobproperties.AthenaCommonFlags.add_JobProperty(EvtMax)
186 jobproperties.AthenaCommonFlags.add_JobProperty(SkipEvents)
187 jobproperties.AthenaCommonFlags.add_JobProperty(FilesInput )
188 jobproperties.AthenaCommonFlags.add_JobProperty(TreeName)
189 jobproperties.AthenaCommonFlags.add_JobProperty(AccessMode)
190 jobproperties.AthenaCommonFlags.add_JobProperty(HistOutputs)
191 jobproperties.AthenaCommonFlags.add_JobProperty(AllowIgnoreConfigError)
192 jobproperties.AthenaCommonFlags.add_JobProperty(isOnline)
201 athenaCommonFlags = jobproperties.AthenaCommonFlags