ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_DBStatusUpdate.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2import subprocess
3import os
4import sys
5
6def 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
15def nextstep(text):
16 print("\n"+"#"*100)
17 print("#")
18 print("# %s" % (text))
19 print("#")
20 print("#"*100,"\n")
21
22if __name__ == "__main__":
23
24 import argparse
25 parser = argparse.ArgumentParser(prog='python -m TRT_ConditionsAlgs.TRT_DBStatusUpdate', formatter_class=argparse.RawTextHelpFormatter,
26 description='''Update TRT conditions:
27 python -m TRT_ConditionsAlgs.TRT_DBStatusUpdate -> for testing
28 python -m TRT_ConditionsAlgs.TRT_DBStatusUpdate --prod -> for data production
29 python -m TRT_ConditionsAlgs.TRT_DBStatusUpdate --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('--tag', default="" ,help="COOL DB password - used by experts only")
35 parser.add_argument('-s','--skipToken',action='store_true' ,help="Skips auth-get-user-token if provided (you must have one active)")
36 args = parser.parse_args()
37
38 # Export COOL_FLASK environment variable
39 os.environ["COOL_FLASK"] = "https://cool-proxy-app.cern.ch"
40
41 # Run auth-get-user-token
42 if not args.skipToken:
43 run_command("auth-get-user-token -c cool-flask-client -o ~/.client-exchange-token.json")
44 else:
45 print("Token skipped. Is supposed to be active..")
46
47 if not args.prod and not args.isMC:
48
49 nextstep("Publishing: \033[31;5;7m TEST \033[0m upload")
50
51 if input("Do you want to upload new Status constants as a test tag (enter 1)? ") == "1":
52 retag= (args.tag if args.tag else "TrtStrawStatus-WebTest-RUN2-UPD2-00-01")
53 print(f"Uploading constants to tag {retag} :")
54 run_command(f"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/Status --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
55 else:
56 print("Different input provided. It should be 1 to run the actions.")
57
58 elif args.isMC:
59
60 nextstep("Publishing: \033[31;5;7m MC \033[0m upload")
61 myupload = input("Uploading MC constants to /TRT/Cond/. Is it for Status (enter 1), is it for StatusHT (2) or is it for StatusPermanent (3)? ")
62
63 if myupload == "1":
64 retag = input("Uploading Status. What is the name of target tag (example: TRTCondStatus-MC-run2-run3_00-02)? ")
65 run_command(f"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Cond/Status --tag=TextStatus --retag={retag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
66
67 elif myupload == "2":
68 retag = input("Uploading StatusHT. What is the name of target tag (example: TrtStrawStatusHT-MC-run2-run3-01)? ")
69 run_command(f"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Cond/StatusHT --tag=Textrt --retag={retag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
70
71 elif myupload == "3":
72 retag = input("Uploading StatusPermanent. What is the name of target tag (example: TrtStrawStatusPermCol-02)? ")
73 run_command(f"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Cond/StatusPermanent --tag=TextStatus --retag={retag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
74
75 else:
76 print("Different input provided. It should be 1 (Status), 2 (StatusHT) or 3 (StatusPermanent)")
77
78 print("\n"+"#"*100+"\n")
79 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")
80 print("with all the IoVs from TrtCalib-MC-run2-run3-00-01 PLUS a new IoV with the payload of the tag just written")
81 print("This way we have the entire MC history in one tag" )
82 print("\n"+"#"*100+"\n")
83
84 elif args.prod:
85
86 nextstep("Publishing: \033[31;5;7m PRODUCTION \033[0m upload")
87
88 myupload = input("Uploading data production constants to /TRT/Cond/. Is it for Status (enter 1), is it for StatusHT (2) or is it for StatusPermanent (3)? ")
89
90 if myupload == "1":
91
92 if input("Do you want to upload new Status constants to the production ES1 tag (enter 1)? ") == "1":
93 retag= args.tag if args.tag else "TRTCondStatus-RUN2-ES1-UPD1-00-00"
94 run_command(f"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/Status --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
95
96 if input("Do you want to upload new Status constants to the production BLK tag (enter 1)? ") == "1":
97 retag= args.tag if args.tag else "TRTCondStatus-RUN2-BLK-UPD4-00-00"
98 run_command(f"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/Status --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
99
100 elif myupload == "2":
101
102 if input("Do you want to upload new StatusHT constants to the production ES1 tag (enter 1)? ") == "1":
103 retag= args.tag if args.tag else "TRTCondStatusHT-RUN2-UPD1-00-00"
104 run_command(f"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/StatusHT --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
105
106 if input("Do you want to upload new Status constants to the production BLK tag (enter 1)? ") == "1":
107 retag= args.tag if args.tag else "TrtStrawStatusHT-RUN2-UPD4-02-00"
108 run_command(f"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/StatusHT --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
109
110 elif myupload == "3":
111
112 if input("Do you want to upload new StatusPermanent constants to the production BLK tag (enter 1)? ") == "1":
113 retag= args.tag if args.tag else "TRTCondStatusPermanent-RUN2-BLK-UPD4-02-00"
114 run_command(f"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/StatusPermanent --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
115
116 else:
117 print("Different input provided. It should be 1 (Status), 2 (StatusHT) or 3 (StatusPermanent)")
118
119
120 print("Environment setup complete.")
void print(char *figname, TCanvas *c1)