ATLAS Offline Software
LArMissingFeb2Ascii.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentFactory import CompFactory
4 
5 def LArMissingFeb2AsciiCfg(flags,OutputFile,dbname="LAR_OFL",folder=None,tag=None,summaryfile=""):
6  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
7  result=LArGMCfg(flags)
8 
9  #Setup regular cabling
10  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
11  result.merge(LArOnOffIdMappingCfg(flags))
12 
13 
14  if folder is None:
15  if dbname in ("LAR","LAR_ONL"):
16  folder="/LAR/BadChannels/MissingFEBs"
17  else:
18  folder="/LAR/BadChannelsOfl/MissingFEBs"
19 
20  if tag is not None:
21  if not tag.startswith("LAR"):
22  if not tag.startswith("-"): tag= "-"+tag
23  tag="".join(folder.split("/"))+tag
24 
25  print("Tag=",tag)
26 
27  if 'MissingFEBs' in folder:
28  from LArBadChannelTool.LArBadChannelConfig import LArBadFebCfg
29  result.merge(LArBadFebCfg(flags))
30  ReadKey='LArBadFeb'
31  elif 'KnownBADFEBs' in folder:
32  from LArBadChannelTool.LArBadFebsConfig import LArKnownBadFebCfg
33  result.merge(LArKnownBadFebCfg(flags))
34  ReadKey='LArKnownBadFEBs'
35  elif 'KnownMNBFEBs' in folder:
36  from LArBadChannelTool.LArBadFebsConfig import LArKnownMNBFebCfg
37  result.merge(LArKnownMNBFebCfg(flags))
38  ReadKey='LArKnownMNBFEBs'
39  else:
40  print('Unknown folder: ',folder,' exiting !!!')
41  import sys
42  sys.exit(-1)
43 
44  theLArMF2Ascii=CompFactory.LArBadFeb2Ascii(FileName=OutputFile,BFKey=ReadKey)
45  result.addEventAlgo(theLArMF2Ascii)
46 
47  return result
48 
49 
50 
51 if __name__=="__main__":
52  import sys,argparse
53  parser= argparse.ArgumentParser()
54  parser.add_argument("--loglevel", default=None, help="logging level (ALL, VERBOSE, DEBUG,INFO, WARNING, ERROR, or FATAL")
55  parser.add_argument("-r","--runnumber",default=0x7fffffff, type=int, help="run number to query the DB")
56  parser.add_argument("-l","--lbnumber",default=1, type=int, help="LB number to query the DB")
57  parser.add_argument("-d","--database",default="LAR_OFL", help="Database name or sqlite file name")
58  parser.add_argument("-o","--output",default="bc_output.txt", help="output file name")
59  parser.add_argument("-f","--folder",default=None, help="database folder to read")
60  parser.add_argument("-t","--tag",default=None, help="folder-level tag to read")
61  parser.add_argument("-s","--summary",default="", help="Executive summary file")
62 
63  (args,leftover)=parser.parse_known_args(sys.argv[1:])
64 
65  if len(leftover)>0:
66  print("ERROR, unhandled argument(s):",leftover)
67  sys.exit(-1)
68 
69  from AthenaConfiguration.AllConfigFlags import initConfigFlags
70  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
72  addLArCalibFlags(flags)
73 
74  flags.Input.isMC = False
75  flags.IOVDb.DatabaseInstance="CONDBR2"
76  flags.LAr.doAlign=False
77  flags.Input.RunNumbers=[args.runnumber]
78  flags.IOVDb.GlobalTag="CONDBR2-ES1PA-2022-06"
79  from AthenaConfiguration.TestDefaults import defaultGeometryTags
80  flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
81 
82  if args.loglevel:
83  from AthenaCommon import Constants
84  if hasattr(Constants,args.loglevel):
85  flags.Exec.OutputLevel=getattr(Constants,args.loglevel)
86  else:
87  raise ValueError("Unknown log-level, allowed values are ALL, VERBOSE, DEBUG,INFO, WARNING, ERROR, FATAL")
88 
89  flags.lock()
90 
91  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
92  cfg=MainServicesCfg(flags)
93  #MC Event selector since we have no input data file
94  from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
95  cfg.merge(McEventSelectorCfg(flags,
96  FirstLB=args.lbnumber,
97  EventsPerRun = 1,
98  FirstEvent = 1,
99  InitialTimeStamp = 0,
100  TimeStampInterval = 1))
101 
102  cfg.merge(LArMissingFeb2AsciiCfg(flags,args.output,
103  dbname=args.database,
104  folder=args.folder,
105  tag=args.tag,
106  summaryfile=args.summary))
107 
108 
109 
110  sc=cfg.run(1)
111  if sc.isSuccess():
112  sys.exit(0)
113  else:
114  sys.exit(1)
python.LArBadFebsConfig.LArKnownMNBFebCfg
def LArKnownMNBFebCfg(configFlags, tag=None)
Definition: LArBadFebsConfig.py:25
python.LArMissingFeb2Ascii.LArMissingFeb2AsciiCfg
def LArMissingFeb2AsciiCfg(flags, OutputFile, dbname="LAR_OFL", folder=None, tag=None, summaryfile="")
Definition: LArMissingFeb2Ascii.py:5
python.LArBadChannelConfig.LArBadFebCfg
def LArBadFebCfg(configFlags, tag=None)
Definition: LArBadChannelConfig.py:45
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.LArBadFebsConfig.LArKnownBadFebCfg
def LArKnownBadFebCfg(configFlags, tag=None)
Definition: LArBadFebsConfig.py:11
python.McEventSelectorConfig.McEventSelectorCfg
def McEventSelectorCfg(flags, **kwargs)
Definition: McEventSelectorConfig.py:5
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3