14 from __future__
import print_function
18 runListDir =
"./YearStats-common"
20 parser = argparse.ArgumentParser(description=
'')
21 parser.add_argument(
'-y',
'--year',dest=
'parser_year',default =
"2024",help=
'Year [Default: 2024].',action=
'store')
22 parser.add_argument(
'-t',
'--tag',dest=
'parser_tag',help=
'DeMo tag',action=
'store')
23 parser.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')
24 parser.add_argument(
'--description',dest=
'parser_description',default =
"",help=
'Short description for DeMo plots',action=
'store')
25 parser.add_argument(
'--defectTag',dest=
'parser_defectTag',default =
"",help=
'Defect tag',action=
'store')
26 parser.add_argument(
'--vetoTag',dest=
'parser_vetoTag',default =
"",help=
'Veto tag (relevant only for LAr)',action=
'store')
27 parser.add_argument(
'--oflLumiTag',dest=
'parser_oflLumiTag',default =
"",help=
'Veto tag (relevant only for LAr)',action=
'store')
28 parser.add_argument(
'--oflLumiAcctTag',dest=
'parser_oflLumiAcctTag',default =
"",help=
'Veto tag (relevant only for LAr)',action=
'store')
29 parser.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')
31 args = parser.parse_args()
35 if args.parser_system ==
"":
36 systems = [
"LAr",
"Pixel",
"SCT",
"TRT",
"Tile",
"MDT",
"TGC",
"RPC",
"Trig_L1",
"Trig_HLT",
"Lumi",
"Global",
"ALFA",
"AFP",
"LUCID",
"ZDC",
"IDGlobal",
"BTag",
"CaloCP",
"MuonCP"]
38 systems.append(args.parser_system)
40 b_createDeMoConfig =
True
42 configFilename =
"%s/%s/DeMoConfig-%s-%s.dat"%(runListDir,args.parser_year,args.parser_year,args.parser_tag)
43 if os.path.exists(configFilename):
44 print(
"Warning: this year/tag apparently already exists. As the database tags must be uniform among systems, I will keep the already defined tags:")
45 os.system(
"cat %s"%configFilename)
46 confirm =
input(
"Please type OK to agree and proceed with the creation of missing system directories: ")
47 b_createDeMoConfig =
False
48 if (
"OK" not in confirm):
53 if b_createDeMoConfig:
54 print(
"=========== Treatment of tags")
55 config =
open(configFilename,
'w')
57 if (args.parser_description) ==
"":
58 tmp_d = args.parser_tag
59 print(
"No description provided. Tag name used -> %s"%tmp_d)
61 tmp_d = args.parser_description
62 config.write(
"Description: %s\n"%tmp_d)
64 if (args.parser_defectTag) ==
"":
65 if (args.parser_year ==
"2015"): tmp_d =
"DetStatus-v105-pro22-13"
66 elif (args.parser_year ==
"2016"): tmp_d =
"DetStatus-v105-pro22-13"
67 elif (args.parser_year ==
"2017"): tmp_d =
"DetStatus-v105-pro22-13"
68 elif (args.parser_year ==
"2018"): tmp_d =
"DetStatus-v105-pro22-13"
69 elif (args.parser_year ==
"2022"): tmp_d =
"HEAD"
70 elif (args.parser_year ==
"2023"): tmp_d =
"HEAD"
71 elif (args.parser_year ==
"2024"): tmp_d =
"HEAD"
72 print(
"No defect tag provided. Default year tag used -> %s"%tmp_d)
74 tmp_d = args.parser_defectTag
75 config.write(
"Defect tag: %s\n"%tmp_d)
77 if (args.parser_vetoTag) ==
"":
78 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"
79 elif (args.parser_year ==
"2022"): tmp_d =
"LARBadChannelsOflEventVeto-RUN2-UPD4-11"
80 elif (args.parser_year ==
"2023"): tmp_d =
"LARBadChannelsOflEventVeto-RUN2-UPD4-11"
81 elif (args.parser_year ==
"2024"): tmp_d =
"LARBadChannelsOflEventVeto-RUN2-UPD4-13"
82 print(
"No veto tag provided. Default year tag used -> %s"%tmp_d)
84 tmp_d = args.parser_vetoTag
85 config.write(
"Veto tag: %s\n"%tmp_d)
87 if (args.parser_oflLumiTag) ==
"":
88 if (args.parser_year ==
"2015"): tmp_d =
"OflLumi-13TeV-004"
89 elif (args.parser_year ==
"2016"): tmp_d =
"OflLumi-13TeV-009"
90 elif (args.parser_year ==
"2017"): tmp_d =
"OflLumi-13TeV-010"
91 elif (args.parser_year ==
"2018"): tmp_d =
"OflLumi-13TeV-010"
92 elif (args.parser_year ==
"2022"): tmp_d =
"OflLumi-Run3-002"
93 elif (args.parser_year ==
"2023"): tmp_d =
"OflLumi-Run3-002"
94 elif (args.parser_year ==
"2024"): tmp_d =
"OflPrefLumi-RUN3-UPD4-02"
95 print(
"No oflLumi tag provided. Default year tag used -> %s"%tmp_d)
97 tmp_d = args.parser_oflLumiTag
98 config.write(
"OflLumi tag: %s\n"%tmp_d)
100 if (args.parser_oflLumiAcctTag) ==
"":
101 if (args.parser_year ==
"2015" or args.parser_year ==
"2016" or args.parser_year ==
"2017" or args.parser_year ==
"2018"): tmp_d =
"Unknown"
102 elif (args.parser_year ==
"2022"): tmp_d =
"OflLumiAcct-Run3-002"
103 elif (args.parser_year ==
"2023"): tmp_d =
"OflLumiAcct-Run3-002"
104 elif (args.parser_year ==
"2024"): tmp_d =
"OflLumiAcct-Run3-005"
105 print(
"No OflLumiAcct tag provided. Default year tag used -> %s"%tmp_d)
107 tmp_d = args.parser_oflLumiAcctTag
108 config.write(
"OflLumiAcct tag: %s\n"%tmp_d)
113 for iSystem
in systems:
114 print(
"== System: %s"%iSystem)
115 direct =
"YearStats-%s"%iSystem
116 if not os.path.exists(direct):
117 print(
"%s system directory does not exists. Creating it"%direct)
118 os.system(
"mkdir %s"%direct)
120 direct =
"YearStats-%s/%s"%(iSystem,args.parser_year)
121 if not os.path.exists(direct):
122 print(
"%s year directory does not exists. Creating it"%direct)
123 os.system(
"mkdir %s"%direct)
125 direct =
"YearStats-%s/%s/%s"%(iSystem,args.parser_year,args.parser_tag)
126 if not os.path.exists(direct):
127 print(
"%s tag directory does not exists. Creating it"%direct)
128 os.system(
"mkdir %s"%direct)
129 os.system(
"mkdir %s/Run"%direct)
130 os.system(
"mkdir %s/Weekly"%direct)
134 print(
"=========== Treatment of run list")
135 newRunListName =
"%s/%s/runlist-%s-%s.dat"%(runListDir,args.parser_year,args.parser_year,args.parser_tag)
137 if args.parser_xmlGRL !=
"":
138 if "https" in args.parser_xmlGRL:
139 os.system(
"wget %s -P %s"%(args.parser_xmlGRL,runListDir))
140 file_xmlGRL =
open(
"%s/%s"%(runListDir,args.parser_xmlGRL.split(
"/")[-1]))
142 file_xmlGRL =
open(args.parser_xmlGRL)
144 newRunList =
open(newRunListName,
'w')
146 for iline
in file_xmlGRL.readlines():
147 if (
"<Run>" in iline
and "</Run>" in iline):
148 runNumber = (iline.split(
"<Run>")[1]).
split(
"</Run>")[0]
149 newRunList.write(
"%s\n"%runNumber)
153 if not os.path.exists(newRunListName):
154 print(
"Warning: the %s file does not exist yet. Please create it by hand or with the --xmlGRL option."%newRunListName)