ATLAS Offline Software
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 
14 from __future__ import print_function
15 import os,sys
16 import argparse
17 
18 runListDir = "./YearStats-common"
19 
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')
30 
31 args = parser.parse_args()
32 parser.print_help()
33 
34 systems = []
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"]
37 else:
38  systems.append(args.parser_system)
39 
40 b_createDeMoConfig = True
41 
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):
49  sys.exit()
50 
51 # Fill the various tags/description in a dat file to be read by DeMoLib
52 # DeMoConfig.dat is common to all systems
53 if b_createDeMoConfig:
54  print("=========== Treatment of tags")
55  config = open(configFilename, 'w')
56 
57  if (args.parser_description) == "":
58  tmp_d = args.parser_tag
59  print("No description provided. Tag name used -> %s"%tmp_d)
60  else:
61  tmp_d = args.parser_description
62  config.write("Description: %s\n"%tmp_d)
63 
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)
73  else:
74  tmp_d = args.parser_defectTag
75  config.write("Defect tag: %s\n"%tmp_d)
76 
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)
83  else:
84  tmp_d = args.parser_vetoTag
85  config.write("Veto tag: %s\n"%tmp_d)
86 
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)
96  else:
97  tmp_d = args.parser_oflLumiTag
98  config.write("OflLumi tag: %s\n"%tmp_d)
99 
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)
106  else:
107  tmp_d = args.parser_oflLumiAcctTag
108  config.write("OflLumiAcct tag: %s\n"%tmp_d)
109 
110  config.close()
111 
112 # Create the missing directories
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)
119 
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)
124 
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)
131 
132 
133 # When requested, generation of run list
134 print("=========== Treatment of run list")
135 newRunListName = "%s/%s/runlist-%s-%s.dat"%(runListDir,args.parser_year,args.parser_year,args.parser_tag)
136 
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]))
141  else:
142  file_xmlGRL = open(args.parser_xmlGRL)
143 
144  newRunList = open(newRunListName, 'w')
145 
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)
150 
151  newRunList.close()
152 
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)
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
Trk::open
@ open
Definition: BinningType.h:40
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
Trk::split
@ split
Definition: LayerMaterialProperties.h:38