Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena_MET
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Plebani
athena_MET
Commits
43a7b5f0
Commit
43a7b5f0
authored
1 year ago
by
Walter Lampl
Browse files
Options
Downloads
Patches
Plain Diff
improve error handling, avoid code-duplication
parent
a365c0d9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MagneticField/MagFieldConfig/python/BFieldConfigFlags.py
+13
-16
13 additions, 16 deletions
MagneticField/MagFieldConfig/python/BFieldConfigFlags.py
with
13 additions
and
16 deletions
MagneticField/MagFieldConfig/python/BFieldConfigFlags.py
+
13
−
16
View file @
43a7b5f0
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
from
AthenaConfiguration.AthConfigFlags
import
AthConfigFlags
from
AthenaCommon.Logging
import
logging
msg
=
logging
.
getLogger
(
'
BFieldConfigFlags
'
)
#So far no attempt to auto-config field for MC or online-running
#
#The old-style config did auto-config the field for online based on IS
#(see https://gitlab.cern.ch/atlas/athena/-/bl
ame
/1802605a4ab69cab7ee3e53d75f162c7da99a944/Reconstruction/RecExample/RecExOnline/python/OnlineISConfiguration.py#L52)
#(see https://gitlab.cern.ch/atlas/athena/-/bl
ob
/1802605a4ab69cab7ee3e53d75f162c7da99a944/Reconstruction/RecExample/RecExOnline/python/OnlineISConfiguration.py#L52)
#
#The old-sytle config tried to auto-config the field based on in-file metadata, falling back to Geometry and Conditions tags. See
#(see https://gitlab.cern.ch/atlas/athena/-/bl
ame
/1802605a4ab69cab7ee3e53d75f162c7da99a944/Reconstruction/RecExample/RecExConfig/python/AutoConfiguration.py#L181
#(see https://gitlab.cern.ch/atlas/athena/-/bl
ob
/1802605a4ab69cab7ee3e53d75f162c7da99a944/Reconstruction/RecExample/RecExConfig/python/AutoConfiguration.py#L181
def
_
toroidF
ieldAutoCfg
(
prevFlags
):
def
_
f
ieldAutoCfg
(
prevFlags
):
if
prevFlags
.
Input
.
isMC
or
prevFlags
.
Common
.
isOnline
:
return
True
return
[
True
,
True
]
from
CoolConvUtilities.MagFieldUtils
import
getFieldForRun
lbs
=
prevFlags
.
Input
.
LumiBlockNumbers
fieldStat
=
getFieldForRun
(
run
=
prevFlags
.
Input
.
RunNumbers
[
0
],
lumiblock
=
0
if
len
(
lbs
)
==
0
else
lbs
[
0
],
quiet
=
True
)
return
(
fieldStat
.
toroidCurrent
()
>
1
)
if
fieldStat
is
None
:
msg
.
error
(
"
Unable to get field status from DCS, assume both magnets ON
"
)
return
[
True
,
True
]
return
[
fieldStat
.
solenoidCurrent
()
>
1
,
fieldStat
.
toroidCurrent
()
>
1
]
def
_solenoidFieldAutoCfg
(
prevFlags
):
if
prevFlags
.
Input
.
isMC
or
prevFlags
.
Common
.
isOnline
:
return
True
from
CoolConvUtilities.MagFieldUtils
import
getFieldForRun
lbs
=
prevFlags
.
Input
.
LumiBlockNumbers
fieldStat
=
getFieldForRun
(
run
=
prevFlags
.
Input
.
RunNumbers
[
0
],
lumiblock
=
0
if
len
(
lbs
)
==
0
else
lbs
[
0
],
quiet
=
True
)
return
(
fieldStat
.
solenoidCurrent
()
>
1
)
def
createBFieldConfigFlags
():
bcf
=
AthConfigFlags
()
# True when solenoid is on
bcf
.
addFlag
(
"
BField.solenoidOn
"
,
_solenoidFieldAutoCfg
)
bcf
.
addFlag
(
"
BField.solenoidOn
"
,
lambda
prevFlags
:
_fieldAutoCfg
(
prevFlags
)[
0
]
)
# True when barrel toroid is on
bcf
.
addFlag
(
"
BField.barrelToroidOn
"
,
_toroidFieldAutoCfg
)
bcf
.
addFlag
(
"
BField.barrelToroidOn
"
,
lambda
prevFlags
:
_fieldAutoCfg
(
prevFlags
)[
1
]
)
# True when endcap toroid is on
bcf
.
addFlag
(
"
BField.endcapToroidOn
"
,
_toroidFieldAutoCfg
)
bcf
.
addFlag
(
"
BField.endcapToroidOn
"
,
lambda
prevFlags
:
_fieldAutoCfg
(
prevFlags
)[
1
]
)
return
bcf
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment