ATLAS Offline Software
Loading...
Searching...
No Matches
DeMoSetup.py
Go to the documentation of this file.
1#! /usr/bin/env python
2# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3# Author : Benjamin Trocme (CNRS/IN2P3 - LPSC Grenoble)- 2017 - 2023
4# Python 3 migration by Miaoran Lu (University of Iowa)- 2022
5#
6# For each year/tag/system, an output directory YearStats-[system]/[year]/[tag] is required.
7# This directory also contains some subdirectories
8# This script creates all needed directories for a new set of system/year/tag.
9# If the set already exists, the script simply exits
10#
11# Documentation: https://twiki.cern.ch/twiki/bin/viewauth/Atlas/DataQualityDemo
12
13
14import os,sys
15import argparse
16
17runListDir = "./YearStats-common"
18
19parser = argparse.ArgumentParser(description='')
20parser.add_argument('-y','--year',dest='parser_year',default = "2024",help='Year [Default: 2024].',action='store')
21parser.add_argument('-t','--tag',dest='parser_tag',help='DeMo tag',action='store')
22parser.add_argument('-s','--system',dest='parser_system',default="",help='System: LAr, CaloCP... [Default : all systems : LAr,Pixel,SCT,TRT,Tile,MDT,TGC,RPC,Trig_L1,Trig_HLT,Lumi,Global,ALFA,AFP,LUCID,ZDC,IDGlobal,BTag,CaloCP,MuonCP]',action='store')
23parser.add_argument('--description',dest='parser_description',default = "",help='Short description for DeMo plots',action='store')
24parser.add_argument('--defectTag',dest='parser_defectTag',default = "",help='Defect tag',action='store')
25parser.add_argument('--vetoTag',dest='parser_vetoTag',default = "",help='Veto tag (relevant only for LAr)',action='store')
26parser.add_argument('--oflLumiTag',dest='parser_oflLumiTag',default = "",help='Veto tag (relevant only for LAr)',action='store')
27parser.add_argument('--oflLumiAcctTag',dest='parser_oflLumiAcctTag',default = "",help='Veto tag (relevant only for LAr)',action='store')
28parser.add_argument('--xmlGRL',dest='parser_xmlGRL',default = "",help='xml good run list used to create a run list in YearStats-common. Files stored on the web (starting with https) are allowed',action='store')
29
30args = parser.parse_args()
31parser.print_help()
32
33systems = []
34if args.parser_system == "":
35 systems = ["LAr","Pixel","SCT","TRT","Tile","MDT","TGC","RPC","Trig_L1","Trig_HLT","Lumi","Global","ALFA","AFP","LUCID","ZDC","IDGlobal","BTag","CaloCP","MuonCP"]
36else:
37 systems.append(args.parser_system)
38
39b_createDeMoConfig = True
40
41configFilename = "%s/%s/DeMoConfig-%s-%s.dat"%(runListDir,args.parser_year,args.parser_year,args.parser_tag)
42if os.path.exists(configFilename):
43 print("Warning: this year/tag apparently already exists. As the database tags must be uniform among systems, I will keep the already defined tags:")
44 os.system("cat %s"%configFilename)
45 confirm = input("Please type OK to agree and proceed with the creation of missing system directories: ")
46 b_createDeMoConfig = False
47 if ("OK" not in confirm):
48 sys.exit()
49
50# Fill the various tags/description in a dat file to be read by DeMoLib
51# DeMoConfig.dat is common to all systems
52if b_createDeMoConfig:
53 print("=========== Treatment of tags")
54 config = open(configFilename, 'w')
55
56 if (args.parser_description) == "":
57 tmp_d = args.parser_tag
58 print("No description provided. Tag name used -> %s"%tmp_d)
59 else:
60 tmp_d = args.parser_description
61 config.write("Description: %s\n"%tmp_d)
62
63 if (args.parser_defectTag) == "":
64 if (args.parser_year == "2015"): tmp_d = "DetStatus-v105-pro22-13"
65 elif (args.parser_year == "2016"): tmp_d = "DetStatus-v105-pro22-13"
66 elif (args.parser_year == "2017"): tmp_d = "DetStatus-v105-pro22-13"
67 elif (args.parser_year == "2018"): tmp_d = "DetStatus-v105-pro22-13"
68 elif (args.parser_year == "2022"): tmp_d = "HEAD"
69 elif (args.parser_year == "2023"): tmp_d = "HEAD"
70 elif (args.parser_year == "2024"): tmp_d = "HEAD"
71 print("No defect tag provided. Default year tag used -> %s"%tmp_d)
72 else:
73 tmp_d = args.parser_defectTag
74 config.write("Defect tag: %s\n"%tmp_d)
75
76 if (args.parser_vetoTag) == "":
77 if (args.parser_year == "2015" or args.parser_year == "2016" or args.parser_year == "2017" or args.parser_year == "2018"): tmp_d = "LARBadChannelsOflEventVeto-RUN2-UPD4-11"
78 elif (args.parser_year == "2022"): tmp_d = "LARBadChannelsOflEventVeto-RUN2-UPD4-11"
79 elif (args.parser_year == "2023"): tmp_d = "LARBadChannelsOflEventVeto-RUN2-UPD4-11"
80 elif (args.parser_year == "2024"): tmp_d = "LARBadChannelsOflEventVeto-RUN2-UPD4-13"
81 print("No veto tag provided. Default year tag used -> %s"%tmp_d)
82 else:
83 tmp_d = args.parser_vetoTag
84 config.write("Veto tag: %s\n"%tmp_d)
85
86 if (args.parser_oflLumiTag) == "":
87 if (args.parser_year == "2015"): tmp_d = "OflLumi-13TeV-004"
88 elif (args.parser_year == "2016"): tmp_d = "OflLumi-13TeV-009"
89 elif (args.parser_year == "2017"): tmp_d = "OflLumi-13TeV-010"
90 elif (args.parser_year == "2018"): tmp_d = "OflLumi-13TeV-010"
91 elif (args.parser_year == "2022"): tmp_d = "OflLumi-Run3-002"
92 elif (args.parser_year == "2023"): tmp_d = "OflLumi-Run3-002"
93 elif (args.parser_year == "2024"): tmp_d = "OflPrefLumi-RUN3-UPD4-02"
94 print("No oflLumi tag provided. Default year tag used -> %s"%tmp_d)
95 else:
96 tmp_d = args.parser_oflLumiTag
97 config.write("OflLumi tag: %s\n"%tmp_d)
98
99 if (args.parser_oflLumiAcctTag) == "":
100 if (args.parser_year == "2015" or args.parser_year == "2016" or args.parser_year == "2017" or args.parser_year == "2018"): tmp_d = "Unknown"
101 elif (args.parser_year == "2022"): tmp_d = "OflLumiAcct-Run3-002"
102 elif (args.parser_year == "2023"): tmp_d = "OflLumiAcct-Run3-002"
103 elif (args.parser_year == "2024"): tmp_d = "OflLumiAcct-Run3-005"
104 print("No OflLumiAcct tag provided. Default year tag used -> %s"%tmp_d)
105 else:
106 tmp_d = args.parser_oflLumiAcctTag
107 config.write("OflLumiAcct tag: %s\n"%tmp_d)
108
109 config.close()
110
111# Create the missing directories
112for iSystem in systems:
113 print("== System: %s"%iSystem)
114 direct = "YearStats-%s"%iSystem
115 if not os.path.exists(direct):
116 print("%s system directory does not exists. Creating it"%direct)
117 os.system("mkdir %s"%direct)
118
119 direct = "YearStats-%s/%s"%(iSystem,args.parser_year)
120 if not os.path.exists(direct):
121 print("%s year directory does not exists. Creating it"%direct)
122 os.system("mkdir %s"%direct)
123
124 direct = "YearStats-%s/%s/%s"%(iSystem,args.parser_year,args.parser_tag)
125 if not os.path.exists(direct):
126 print("%s tag directory does not exists. Creating it"%direct)
127 os.system("mkdir %s"%direct)
128 os.system("mkdir %s/Run"%direct)
129 os.system("mkdir %s/Weekly"%direct)
130
131
132# When requested, generation of run list
133print("=========== Treatment of run list")
134newRunListName = "%s/%s/runlist-%s-%s.dat"%(runListDir,args.parser_year,args.parser_year,args.parser_tag)
135
136if args.parser_xmlGRL != "":
137 if "https" in args.parser_xmlGRL:
138 os.system("wget %s -P %s"%(args.parser_xmlGRL,runListDir))
139 file_xmlGRL = open("%s/%s"%(runListDir,args.parser_xmlGRL.split("/")[-1]))
140 else:
141 file_xmlGRL = open(args.parser_xmlGRL)
142
143 newRunList = open(newRunListName, 'w')
144
145 for iline in file_xmlGRL.readlines():
146 if ("<Run>" in iline and "</Run>" in iline):
147 runNumber = (iline.split("<Run>")[1]).split("</Run>")[0]
148 newRunList.write("%s\n"%runNumber)
149
150 newRunList.close()
151
152if not os.path.exists(newRunListName):
153 print("Warning: the %s file does not exist yet. Please create it by hand or with the --xmlGRL option."%newRunListName)
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177