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 = "2023",help='Year [Default: 2023].',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  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  print("No veto tag provided. Default year tag used -> %s"%tmp_d)
81  else:
82  tmp_d = args.parser_vetoTag
83  config.write("Veto tag: %s\n"%tmp_d)
84 
85  if (args.parser_oflLumiTag) == "":
86  if (args.parser_year == "2015"): tmp_d = "OflLumi-13TeV-004"
87  elif (args.parser_year == "2016"): tmp_d = "OflLumi-13TeV-009"
88  elif (args.parser_year == "2017"): tmp_d = "OflLumi-13TeV-010"
89  elif (args.parser_year == "2018"): tmp_d = "OflLumi-13TeV-010"
90  elif (args.parser_year == "2022"): tmp_d = "OflLumi-Run3-002"
91  elif (args.parser_year == "2023"): tmp_d = "OflLumi-Run3-002"
92  print("No oflLumi tag provided. Default year tag used -> %s"%tmp_d)
93  else:
94  tmp_d = args.parser_oflLumiTag
95  config.write("OflLumi tag: %s\n"%tmp_d)
96 
97  if (args.parser_oflLumiAcctTag) == "":
98  if (args.parser_year == "2015" or args.parser_year == "2016" or args.parser_year == "2017" or args.parser_year == "2018"): tmp_d = "Unknown"
99  elif (args.parser_year == "2022"): tmp_d = "OflLumiAcct-Run3-002"
100  elif (args.parser_year == "2023"): tmp_d = "OflLumiAcct-Run3-002"
101  print("No OflLumiAcct tag provided. Default year tag used -> %s"%tmp_d)
102  else:
103  tmp_d = args.parser_oflLumiAcctTag
104  config.write("OflLumiAcct tag: %s\n"%tmp_d)
105 
106  config.close()
107 
108 # Create the missing directories
109 for iSystem in systems:
110  print("== System: %s"%iSystem)
111  direct = "YearStats-%s"%iSystem
112  if not os.path.exists(direct):
113  print("%s system directory does not exists. Creating it"%direct)
114  os.system("mkdir %s"%direct)
115 
116  direct = "YearStats-%s/%s"%(iSystem,args.parser_year)
117  if not os.path.exists(direct):
118  print("%s year directory does not exists. Creating it"%direct)
119  os.system("mkdir %s"%direct)
120 
121  direct = "YearStats-%s/%s/%s"%(iSystem,args.parser_year,args.parser_tag)
122  if not os.path.exists(direct):
123  print("%s tag directory does not exists. Creating it"%direct)
124  os.system("mkdir %s"%direct)
125  os.system("mkdir %s/Run"%direct)
126  os.system("mkdir %s/Weekly"%direct)
127 
128 
129 # When requested, generation of run list
130 print("=========== Treatment of run list")
131 newRunListName = "%s/%s/runlist-%s-%s.dat"%(runListDir,args.parser_year,args.parser_year,args.parser_tag)
132 
133 if args.parser_xmlGRL != "":
134  if "https" in args.parser_xmlGRL:
135  os.system("wget %s -P %s"%(args.parser_xmlGRL,runListDir))
136  file_xmlGRL = open("%s/%s"%(runListDir,args.parser_xmlGRL.split("/")[-1]))
137  else:
138  file_xmlGRL = open(args.parser_xmlGRL)
139 
140  newRunList = open(newRunListName, 'w')
141 
142  for iline in file_xmlGRL.readlines():
143  if ("<Run>" in iline and "</Run>" in iline):
144  runNumber = (iline.split("<Run>")[1]).split("</Run>")[0]
145  newRunList.write("%s\n"%runNumber)
146 
147  newRunList.close()
148 
149 if not os.path.exists(newRunListName):
150  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
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
Trk::split
@ split
Definition: LayerMaterialProperties.h:38