ATLAS Offline Software
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
TRT_ConditionsAlgs
python
TRT_DBUpdate.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
import
subprocess
3
import
os
4
import
sys
5
6
def
run_command
(command):
7
"""Run a shell command and handle errors."""
8
print
(f
"\n>>> Running: {command}\n"
)
9
try
:
10
subprocess.run(command, shell=
True
)
11
except
subprocess.CalledProcessError
as
e:
12
print
(f
"Error: Command failed: {e}"
)
13
sys.exit(1)
14
15
def
nextstep
(text):
16
print
(
"\n"
+
"#"
*100)
17
print
(
"#"
)
18
print
(
"# %s"
% (text))
19
print
(
"#"
)
20
print
(
"#"
*100,
"\n"
)
21
22
if
__name__ ==
"__main__"
:
23
24
import
argparse
25
parser = argparse.ArgumentParser(prog=
'python -m TRT_ConditionsAlgs.TRT_DBUpdate'
, formatter_class=argparse.RawTextHelpFormatter,
26
description=
'''Update TRT conditions:
27
python -m TRT_ConditionsAlgs.TRT_DBUpdate -> for testing
28
python -m TRT_ConditionsAlgs.TRT_DBUpdate --prod -> for data production
29
python -m TRT_ConditionsAlgs.TRT_DBUpdate --prod --isMC -> for MC production'''
)
30
31
parser.add_argument(
'--prod'
, action=
'store_true'
, help=
"Meant for production only"
)
32
parser.add_argument(
'--isMC'
, action=
'store_true'
, help=
"By default is DATA. If set then MC"
)
33
parser.add_argument(
'--pwd'
, required=
True
, help=
"COOL DB password - used by experts only"
)
34
parser.add_argument(
'-s'
,
'--skipToken'
, action=
'store_true'
, help=
"Skips auth-get-user-token if provided (you must have one active)"
)
35
args = parser.parse_args()
36
37
# Export COOL_FLASK environment variable
38
os.environ[
"COOL_FLASK"
] =
"https://cool-proxy-app.cern.ch"
39
40
# Run auth-get-user-token
41
if
not
args.skipToken:
42
run_command
(
"auth-get-user-token -c cool-flask-client -o ~/.client-exchange-token.json"
)
43
else
:
44
print
(
"Token skipped. Is supposed to be active.."
)
45
46
if
not
args.prod
and
not
args.isMC:
47
48
nextstep
(
"Publishing: \033[31;5;7m TEST \033[0m upload"
)
49
50
tagt0=
"TrtCalibT0-Webtest-RUN2-UPD1-00-00"
51
tagrt=
"TrtCalibRt-Webtest-RUN2-UPD1-00-00"
52
53
if
input(
"Are you all set to upload test T0 and RT constants? (1=yes):"
) ==
"1"
:
54
print
(
"Uploading T0s:"
)
55
run_command
(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/T0 --tag=Textt0 --retag={tagt0} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}"
)
56
57
print
(
"Uploading RTs:"
)
58
run_command
(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/RT --tag=Textrt --retag={tagrt} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}"
)
59
else
:
60
print
(
"Skipping... set all the necessary"
)
61
62
elif
args.isMC:
63
64
nextstep
(
"Publishing: \033[31;5;7m MC \033[0m upload"
)
65
66
if
input(
"Are you all set to upload MC T0 and RT constants (1=yes)? "
) ==
"1"
:
67
tag = input(
"\nUploading T0s. What is the name of target tag (example: TrtCalibT0-MC-run3-test-00)? "
)
68
run_command
(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Calib/T0 --tag=Textt0 --retag={tag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}"
)
69
70
tag = input(
"\nUploading RTs. What is the name of target tag (example: TrtCalibRT-MC-run3-test-00)? "
)
71
run_command
(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Calib/RT --tag=Textrt --retag={tag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}"
)
72
73
print
(
"\n"
+
"#"
*100+
"\n"
)
74
print
(
"Note that for a new MC campaign with new TRT gas, you will need to make a new tag eg TrtCalibxx-MC-run2-run3-00-02"
)
75
print
(
"with all the IoVs from TrtCalib-MC-run2-run3-00-01 PLUS a new IoV with the payload of the tag just written"
)
76
print
(
"This way we have the entire MC history in one tag"
)
77
print
(
"\n"
+
"#"
*100+
"\n"
)
78
else
:
79
print
(
"Skipping... set all the necessary"
)
80
81
elif
args.prod:
82
83
nextstep
(
"Publishing: \033[31;5;7m PRODUCTION \033[0m upload"
)
84
85
if
input(
"Do you want to upload new T0s to the production ES1 tag (1=yes)? "
) ==
"1"
:
86
run_command
(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/T0 --tag=Textt0 --retag=TrtCalibT0-RUN2-Physics-UPD1-FieldOn-00-00 mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}"
)
87
else
:
88
print
(
"Skipping upload new T0s to the production ES1 tag\n"
)
89
90
if
input(
"Do you want to upload new RT relations to the production ES1 tag (1=yes)? "
) ==
"1"
:
91
run_command
(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/RT --tag=Textrt --retag=TrtCalibRt-RUN2-Physics-UPD1-FieldOn-00-00 mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}"
)
92
else
:
93
print
(
"Skipping upload new RT relations to the production ES1 tag\n"
)
94
95
if
input(
"Do you want to upload new T0s to the production BLK UPD4 tag (1=yes)? "
) ==
"1"
:
96
run_command
(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/T0 --tag=Textt0 --retag=TrtCalibT0-RUN2-Physics-BLK-UPD4-00-03 mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}"
)
97
else
:
98
print
(
"Skipping upload new T0s to the production BLK UPD4 tag\n"
)
99
100
if
input(
"Do you want to upload new RT constants to the BLK UPD4 tag (1=yes)? "
) ==
"1"
:
101
run_command
(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/RT --tag=Textrt --retag=TrtCalibRt-RUN2-Physics-BLK-UPD4-00-03 mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}"
)
102
else
:
103
print
(
"Skipping upload new RT constants to the BLK UPD4 tag\n"
)
104
105
106
print
(
"Environment setup complete."
)
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
python.TRT_DBUpdate.run_command
run_command(command)
Definition
TRT_DBUpdate.py:6
python.TRT_DBUpdate.nextstep
nextstep(text)
Definition
TRT_DBUpdate.py:15
Generated on
for ATLAS Offline Software by
1.14.0