ATLAS Offline Software
LArBadChannel2Ascii.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentFactory import CompFactory
3 from IOVDbSvc.IOVDbSvcConfig import addFolders
4 
5 def LArBadChannel2AsciiCfg(flags,OutputFile,dbname="LAR_OFL",folder=None,tag=None,summaryfile=""):
6  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
7  result=LArGMCfg(flags)
8 
9  if flags.LArCalib.isSC:
10  #Setup SuperCell cabling
11  from LArCabling.LArCablingConfig import LArOnOffIdMappingSCCfg
12  result.merge(LArOnOffIdMappingSCCfg(flags))
13  else:
14  #Setup regular cabling
15  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
16  result.merge(LArOnOffIdMappingCfg(flags))
17 
18 
19  if folder is None:
20  if dbname in ("LAR","LAR_ONL"):
21  folder="/LAR/BadChannels/BadChannels"
22  else:
23  folder="/LAR/BadChannelsOfl/BadChannels"
24 
25  if flags.LArCalib.isSC:
26  folder+="SC"
27 
28  if tag is not None:
29  if not tag.startswith("LAR"):
30  if not tag.startswith("-"): tag= "-"+tag
31  tag="".join(folder.split("/"))+tag
32 
33  print("Tag=",tag)
34 
35  result.merge(addFolders(flags,folder,dbname,tag=tag,
36  className="CondAttrListCollection"))
37  theLArBadChannelCondAlgo=CompFactory.LArBadChannelCondAlg(ReadKey=folder)
38  if flags.LArCalib.isSC:
39  theLArBadChannelCondAlgo.CablingKey="LArOnOffIdMapSC"
40  theLArBadChannelCondAlgo.isSC=True
41 
42  result.addCondAlgo(theLArBadChannelCondAlgo)
43 
44  if summaryfile!="":
45  if (not flags.LArCalib.isSC):
46  from LArBadChannelTool.LArBadFebsConfig import LArKnownBadFebCfg
47  result.merge(LArKnownBadFebCfg(flags))
48 
49  theLArBadChannels2Ascii=CompFactory.LArBadChannel2Ascii(SkipDisconnected=True)
50  theLArBadChannels2Ascii.FileName=OutputFile
51  theLArBadChannels2Ascii.WithMissing=False if (summaryfile=="" and not flags.LArCalib.isSC) else True
52  theLArBadChannels2Ascii.ExecutiveSummaryFile=summaryfile
53  theLArBadChannels2Ascii.BFKey="LArKnownBadFEBs"
54  if (flags.LArCalib.isSC):
55  theLArBadChannels2Ascii.LArOnOffIdMapKey="LArOnOffIdMapSC"
56  theLArBadChannels2Ascii.SuperCell=True
57  result.addEventAlgo(theLArBadChannels2Ascii)
58 
59  return result
60 
61 
62 
63 if __name__=="__main__":
64  import sys,argparse
65  parser= argparse.ArgumentParser()
66  parser.add_argument("--loglevel", default=None, help="logging level (ALL, VERBOSE, DEBUG,INFO, WARNING, ERROR, or FATAL")
67  parser.add_argument("-r","--runnumber",default=0x7fffffff, type=int, help="run number to query the DB")
68  parser.add_argument("-l","--lbnumber",default=1, type=int, help="LB number to query the DB")
69  parser.add_argument("-d","--database",default="LAR_OFL", help="Database name or sqlite file name")
70  parser.add_argument("-o","--output",default="bc_output.txt", help="output file name")
71  parser.add_argument("-f","--folder",default=None, help="database folder to read")
72  parser.add_argument("-t","--tag",default=None, help="folder-level tag to read")
73  parser.add_argument("-s","--summary",default="", help="Executive summary file")
74  parser.add_argument("--SC", action='store_true', help="Work on SuperCells")
75 
76  (args,leftover)=parser.parse_known_args(sys.argv[1:])
77 
78  if len(leftover)>0:
79  print("ERROR, unhandled argument(s):",leftover)
80  sys.exit(-1)
81 
82  from AthenaConfiguration.AllConfigFlags import initConfigFlags
83  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
85  addLArCalibFlags(flags)
86 
87  flags.Input.isMC = False
88  flags.IOVDb.DatabaseInstance="CONDBR2"
89  flags.LAr.doAlign=False
90  flags.Input.RunNumbers=[args.runnumber]
91  flags.IOVDb.GlobalTag="CONDBR2-ES1PA-2023-02"
92  from AthenaConfiguration.TestDefaults import defaultGeometryTags
93  flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
94  flags.LArCalib.isSC=args.SC
95 
96  if args.loglevel:
97  from AthenaCommon import Constants
98  if hasattr(Constants,args.loglevel):
99  flags.Exec.OutputLevel=getattr(Constants,args.loglevel)
100  else:
101  raise ValueError("Unknown log-level, allowed values are ALL, VERBOSE, DEBUG,INFO, WARNING, ERROR, FATAL")
102 
103  flags.lock()
104 
105  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
106  cfg=MainServicesCfg(flags)
107  #MC Event selector since we have no input data file
108  from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
109  cfg.merge(McEventSelectorCfg(flags,
110  FirstLB=args.lbnumber,
111  EventsPerRun = 1,
112  FirstEvent = 1,
113  InitialTimeStamp = 0,
114  TimeStampInterval = 1))
115 
116  cfg.merge(LArBadChannel2AsciiCfg(flags,args.output,
117  dbname=args.database,
118  folder=args.folder,
119  tag=args.tag,
120  summaryfile=args.summary))
121 
122 
123 
124  sc=cfg.run(1)
125  if sc.isSuccess():
126  sys.exit(0)
127  else:
128  sys.exit(1)
LArCablingConfig.LArOnOffIdMappingSCCfg
def LArOnOffIdMappingSCCfg(configFlags)
Definition: LArCablingConfig.py:65
python.LArBadChannel2Ascii.LArBadChannel2AsciiCfg
def LArBadChannel2AsciiCfg(flags, OutputFile, dbname="LAR_OFL", folder=None, tag=None, summaryfile="")
Definition: LArBadChannel2Ascii.py:5
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
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
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
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3