ATLAS Offline Software
Loading...
Searching...
No Matches
Control
AthenaCommon
python
GlobalFlags.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2
3
8
9
""" GlobalFlags
10
Python module to hold common global flags
11
12
13
+ The module has been re-written in terms of the new JobProperties and the
14
original class implementation was modified to allow a smooth transition.
15
For example:
16
GlobalFlags.DetGeo.set_atlas()
17
will internally do:
18
jobproperties.Global.DetGeo='atlas'
19
At some point "GlobalFlags.DetGeo.set_atlas()" we will add a warning
20
message and later on we declare them obsolete
21
22
23
"""
24
25
__author__ =
"S.Binet, M.Gallas, David Rousseau"
26
__version__=
"$Revision: 1.14 $"
27
__doc__ =
"Global job properties"
28
29
__all__ = [
"GlobalFlags"
,
"globalflags"
]
30
31
33
from
AthenaCommon.JobProperties
import
JobProperty, JobPropertyContainer
34
from
AthenaCommon.JobProperties
import
jobproperties
35
36
37
#
38
class
DetGeo
(JobProperty):
39
""" Which detector configuration : atlas, combined test beam or commisisoning
40
"""
41
statusOn=
True
42
allowedTypes=[
'str'
]
43
allowedValues=[
'atlas'
,
'ctbh8'
,
'ctbh6'
,
'commis'
]
44
StoredValue=
'atlas'
45
46
# automatically generate is_xyz() helpers
47
for
v
in
allowedValues:
48
exec(
"def is_%s(self): return self() == '%s'"
% (v,v) )
49
50
#
51
class
DetDescrVersion
(JobProperty):
52
""" Detector geometry DB tag
53
see https://twiki.cern.ch/twiki/bin/view/Atlas/DetDescrVersion.
54
"""
55
statusOn=
True
56
allowedTypes=[
'str'
]
57
# allowedValues=['DC1','DC2','DC2-Final','DC2-Initial','Rome-Initial',\
58
# 'Rome-Initial-v00','Rome-Final','DC1-Initial',\
59
# 'DC1-Final','CTB','Commissioning-Calo','Commissioning-Muon'\
60
# 'ATLAS-DC3-01','ATLAS-DC3-02','Default']
61
StoredValue=
'ATLAS-R2-2016-01-00-01'
62
63
class
ConditionsTag
(JobProperty):
64
""" See https://twiki.cern.ch/twiki/bin/view/Atlas/CoolProdTags
65
"""
66
statusOn=
True
67
allowedTypes=[
'str'
]
68
StoredValue=
'OFLCOND-MC16-SDR-RUN2-09'
69
70
#
71
class
DatabaseInstance
(JobProperty):
72
"""Switch between run1/run2 database instance"""
73
statusOn=
True
74
allowedTypes=[
'str'
]
75
allowedValues=[
'auto'
,
'COMP200'
,
'CONDBR2'
]
76
StoredValue=
'auto'
77
#
78
class
DataSource
(JobProperty):
79
""" Where does the data comes from : real data, geant3 or geant4
80
"""
81
statusOn=
True
82
allowedTypes=[
'str'
]
83
allowedValues=[
'data'
,
'geant3'
,
'geant4'
]
84
StoredValue=
'geant4'
85
86
# automatically generate is_xyz() helpers
87
for
v
in
allowedValues:
88
exec(
"def is_%s(self): return self() == '%s'"
% (v,v) )
89
90
#
91
class
InputFormat
(JobProperty):
92
""" Input format of the data
93
"""
94
statusOn=
True
95
allowedTypes=[
'str'
]
96
allowedValues=[
'zebra'
,
'pool'
,
'bytestream'
]
97
StoredValue=
'pool'
98
99
# automatically generate is_xyz() helpers
100
for
v
in
allowedValues:
101
exec(
"def is_%s(self): return self() == '%s'"
% (v,v) )
102
103
#
104
class
Luminosity
(JobProperty):
105
""" Luminosity
106
107
zero -> no pile up at all
108
verylow -> 10^33
109
low -> 2 10^33
110
high -> 10^34
111
112
"""
113
statusOn=
False
114
allowedTypes=[
'str'
]
115
allowedValues=[
'zero'
,
'verylow'
,
'low'
,
'high'
]
116
StoredValue=
'low'
117
118
# automatically generate is_xyz() helpers
119
for
v
in
allowedValues:
120
exec(
"def is_%s(self): return self() == '%s'"
% (v,v) )
121
122
# prepare removal for Luminosity
123
#def _undo_action(self):
124
# print ("WARNING GlobalFlags.Luminosity is OBSOLETE. Please use beamFlags instead.")
125
126
#def _do_action(self):
127
# print ("WARNING GlobalFlags.Luminosity is OBSOLETE. Please use beamFlags instead.")
128
129
#def get_Value(self):
130
# print ("WARNING GlobalFlags.Luminosity is OBSOLETE. Please use beamFlags instead.")
131
# return self.statusOn
132
133
#
134
class
isOverlay
(JobProperty):
135
""" if data is overlayed
136
"""
137
statusOn=
True
138
allowedTypes=[
'bool'
]
139
StoredValue=
False
140
141
142
# Defines the container for the reconstruction flags
143
class
Global
(JobPropertyContainer):
144
""" The global flag/job property container.
145
"""
146
147
# add the reconstruction flags container to the top container
148
jobproperties.add_Container(Global)
149
150
151
# I want always the following flags in the Global container
152
list_jobproperties=[DetGeo,DataSource,InputFormat,Luminosity,DetDescrVersion,ConditionsTag,DatabaseInstance,isOverlay]
153
for
i
in
list_jobproperties:
154
jobproperties.Global.add_JobProperty(i)
155
156
# The short name (carefull do not select same name as shot name as well.
157
# otherwise problems with pickle)
158
globalflags=jobproperties.Global
159
160
161
185
186
class
GlobalFlags
:
187
188
# prefix of flag member
189
_flagPrefix =
'_flag_'
190
191
# Detector geometry
192
class
DetGeo
:
193
_name =
'DetGeo'
194
_beenSet =
False
195
196
_flag_atlas =
False
197
_flag_ctbh6 =
False
198
_flag_ctbh8 =
False
199
_flag_commis =
False
200
201
# special is-method
202
def
is_ctb
(cls):
203
# stop if any flags have not been set yet
204
if
not
cls.
_beenSet
:
205
raise
RuntimeError(
'ERROR : GlobalFlags.%s has not been set!'
% cls.
__name__
)
206
return
cls.
_flag_ctbh6
| cls.
_flag_ctbh8
207
is_ctb = classmethod(is_ctb)
208
209
# Data source
210
class
DataSource
:
211
_name =
'DataSource'
212
_beenSet =
False
213
214
_flag_data =
False
215
_flag_geant3 =
False
216
_flag_geant4 =
False
217
218
# Data input format
219
class
InputFormat
:
220
_name =
'InputFormat'
221
_beenSet =
False
222
223
_flag_zebra =
False
224
_flag_pool =
False
225
_flag_bytestream =
False
226
227
# Data luminosity
228
class
Luminosity
:
229
_name =
'Luminosity'
230
_beenSet =
False
231
# no pile up at all
232
_flag_zero =
False
233
# 10^33
234
_flag_verylow =
False
235
# 2 10^33
236
_flag_low =
False
237
# 1 10^34
238
_flag_high =
False
239
240
# class list
241
_classObjList = [DetGeo,DataSource,InputFormat,Luminosity]
242
243
# append set- and is-method
244
for
_classObj
in
_classObjList:
245
for
_attr
in
dir(_classObj)[:]:
246
# look for flag member
247
if
0 == _attr.find(_flagPrefix):
248
# temporary class for function object
249
class
_TmpC
:
250
def
__init__
(self,clsObj,flagName):
251
self.
_clsObj
= clsObj
252
self.
_flagName
= flagName
253
def
set
(self):
254
# stop if already set
255
if
self.
_clsObj
._beenSet:
256
raise
RuntimeError(
'ERROR : GlobalFlags.%s has been already set!'
% self.
_clsObj
.__name__)
257
# set flags true
258
setattr(self.
_clsObj
, self.
_flagName
,
True
)
259
self.
_clsObj
._beenSet =
True
260
raise
RuntimeError(
"ERROR GlobalFlags.set_%s() deprecated ! Use globalflags.%s.set_Value_and_Lock(blah) instead !"
% (self.
_clsObj
.__name__+
"."
+self.
_flagName
[6:],self.
_clsObj
.__name__))
261
# setting at the same time jobproperties value
262
data={
'JobProperties.Global'
:{self.
_clsObj
._name:self.
_flagName
.
replace
(
'_flag_'
,
''
)}}
263
jobproperties.set_JobProperties(data)
264
def
is_xyz
(self):
265
raise
RuntimeError(
"ERROR GlobalFlags.is_%s() deprecated ! Use if globalflags.%s == blah instead !"
% (self.
_flagName
[6:],self.
_clsObj
.__name__))
266
# stop if any flags have not been set yet
267
if
not
self.
_clsObj
._beenSet:
268
raise
RuntimeError(
'ERROR : GlobalFlags.%s has not been set!'
% self.
_clsObj
.__name__)
269
return
getattr(self.
_clsObj
, self.
_flagName
)
270
271
_tmpC =
_TmpC
(_classObj,_attr)
272
# register methods
273
_setMethod = _attr.replace(_flagPrefix,
'set_'
)
274
setattr(_classObj,_setMethod, _tmpC.set)
275
_isMethod = _attr.replace(_flagPrefix,
'is_'
)
276
setattr(_classObj,_isMethod, _tmpC.is_xyz)
277
278
# dump Setting
279
def
Print
(cls):
280
format =
"%12s : %s"
281
for
classObj
in
cls.
_classObjList
:
282
flagName =
'----'
283
for
attr
in
dir(classObj):
284
# look for flag member
285
if
0 == attr.find(cls.
_flagPrefix
):
286
# test if this flag on
287
if
classObj.__dict__[attr]:
288
flagName = attr.replace(cls.
_flagPrefix
,
''
)
289
print
(format % (classObj.__name__, flagName))
290
291
# class method
292
Print = classmethod(Print)
python.GlobalFlags.ConditionsTag
Definition
GlobalFlags.py:63
python.GlobalFlags.DataSource
Definition
GlobalFlags.py:78
python.GlobalFlags.DatabaseInstance
Definition
GlobalFlags.py:71
python.GlobalFlags.DetDescrVersion
Definition
GlobalFlags.py:51
python.GlobalFlags.DetGeo
Definition
GlobalFlags.py:38
python.GlobalFlags.GlobalFlags.DataSource
Definition
GlobalFlags.py:210
python.GlobalFlags.GlobalFlags.DetGeo
Definition
GlobalFlags.py:192
python.GlobalFlags.GlobalFlags.DetGeo._beenSet
bool _beenSet
Definition
GlobalFlags.py:194
python.GlobalFlags.GlobalFlags.DetGeo.__name__
__name__
Definition
GlobalFlags.py:205
python.GlobalFlags.GlobalFlags.DetGeo._flag_ctbh6
bool _flag_ctbh6
Definition
GlobalFlags.py:197
python.GlobalFlags.GlobalFlags.DetGeo.is_ctb
is_ctb
Definition
GlobalFlags.py:207
python.GlobalFlags.GlobalFlags.DetGeo._flag_ctbh8
bool _flag_ctbh8
Definition
GlobalFlags.py:198
python.GlobalFlags.GlobalFlags.InputFormat
Definition
GlobalFlags.py:219
python.GlobalFlags.GlobalFlags.Luminosity
Definition
GlobalFlags.py:228
python.GlobalFlags.GlobalFlags._TmpC
Definition
GlobalFlags.py:249
python.GlobalFlags.GlobalFlags._TmpC._flagName
_flagName
Definition
GlobalFlags.py:252
python.GlobalFlags.GlobalFlags._TmpC._clsObj
_clsObj
Definition
GlobalFlags.py:251
python.GlobalFlags.GlobalFlags._TmpC.__init__
__init__(self, clsObj, flagName)
Definition
GlobalFlags.py:250
python.GlobalFlags.GlobalFlags._TmpC.is_xyz
is_xyz(self)
Definition
GlobalFlags.py:264
python.GlobalFlags.GlobalFlags._TmpC.set
set(self)
Definition
GlobalFlags.py:253
python.GlobalFlags.GlobalFlags
OLD code that will be completely replaced by globalflags based on JobProperties.
Definition
GlobalFlags.py:186
python.GlobalFlags.GlobalFlags.Print
Print
Definition
GlobalFlags.py:292
python.GlobalFlags.GlobalFlags._classObjList
list _classObjList
Definition
GlobalFlags.py:241
python.GlobalFlags.GlobalFlags._flagPrefix
str _flagPrefix
Definition
GlobalFlags.py:189
python.GlobalFlags.Global
Definition
GlobalFlags.py:143
python.GlobalFlags.InputFormat
Definition
GlobalFlags.py:91
python.GlobalFlags.Luminosity
Definition
GlobalFlags.py:104
python.GlobalFlags.isOverlay
Definition
GlobalFlags.py:134
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition
hcg.cxx:310
Generated on
for ATLAS Offline Software by
1.14.0