ATLAS Offline Software
LArMissingFebsDBAlg.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentFactory import CompFactory
3 from AthenaCommon.Logging import logging
4 
5 
6 def LArBadFebDBAlgCfg(flags,InputFile,dbname="LAR_OFL",folder=None,tag=None,
7  IOVStart=[0,0],IOVEnd=[0x7FFFFFFF,0xFFFFFFFF]):
8 
9  logger = logging.getLogger( "LArBadFebDBAlgCfg" )
10  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
11  result=LArGMCfg(flags)
12 
13  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
14  result.merge(LArOnOffIdMappingCfg(flags))
15 
16  if folder is None:
17  if dbname == "LAR_ONL":
18  folder="/LAR/BadChannels/KnownBADFEBs"
19  else:
20  folder="/LAR/BadChannelsOfl/KnownBADFEBs"
21 
22  if tag is not None:
23  if not tag.startswith("LAR"):
24  if not tag.startswith("-"): tag= "-"+tag
25  tag="".join(folder.split("/"))+tag
26 
27  print("Tag=",tag)
28 
29 
30  logger.info("Writing to folder %s, tag %s",folder,tag)
31  result.addCondAlgo(CompFactory.LArBadFebCondAlg("LArKnownBadFebAlg",ReadKey="",InputFileName=InputFile,WriteKey="LArBadFeb"))
32 
33  #Thats the registration algo
34  theLArDBAlg=CompFactory.LArBadChannelDBAlg()
35  theLArDBAlg.WritingMode = 1
36  theLArDBAlg.FEBFolder=folder
37  result.addEventAlgo(theLArDBAlg)
38 
39  from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
40  result.merge(OutputConditionsAlgCfg(flags,"dummy.pool.root",
41  ObjectList=["AthenaAttributeList#"+folder],
42  IOVTagList=[tag],
43  Run1=IOVStart[0],LB1=IOVStart[1],
44  Run2=IOVEnd[0],LB2=IOVEnd[1]))
45 
46  return result
47 
48 
49 if __name__=="__main__":
50  import sys,argparse
51  parser= argparse.ArgumentParser()
52  parser.add_argument("inputfile")
53  parser.add_argument("--loglevel", default=None, help="logging level (ALL, VERBOSE, DEBUG,INFO, WARNING, ERROR, or FATAL")
54  parser.add_argument("-r","--runnumber",default=0, type=int, help="IOV start (runnumber)")
55  parser.add_argument("-l","--lbnumber",default=0, type=int, help="IOV start (LB number)")
56  parser.add_argument("--runnumber2",default=0x7FFFFFFF, type=int, help="IOV start (runnumber)")
57  parser.add_argument("--lbnumber2",default=0xFFFFFFFF, type=int, help="IOV start (LB number)")
58  parser.add_argument("-o","--output",default="BadFebs.db", help="sqlite output file name")
59  parser.add_argument("-f","--folder",default=None, help="database folder to create")
60  parser.add_argument("-t","--tag",default=None, help="folder-level tag (or tag-suffix) to create")
61 
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 if args.runnumber>0 else 300000]
78  flags.IOVDb.GlobalTag="CONDBR2-ES1PA-2022-06"
79  from AthenaConfiguration.TestDefaults import defaultGeometryTags
80  flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
81 
82  flags.IOVDb.DBConnection="sqlite://;schema="+args.output+";dbname=CONDBR2"
83 
84  if args.loglevel:
85  from AthenaCommon import Constants
86  if hasattr(Constants,args.loglevel):
87  flags.Exec.OutputLevel=getattr(Constants,args.loglevel)
88  else:
89  raise ValueError("Unknown log-level, allowed values are ALL, VERBOSE, DEBUG,INFO, WARNING, ERROR, FATAL")
90 
91  flags.lock()
92 
93  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
94  cfg=MainServicesCfg(flags)
95  #MC Event selector since we have no input data file
96  from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
97  cfg.merge(McEventSelectorCfg(flags,
98  FirstLB=args.lbnumber,
99  EventsPerRun = 1,
100  FirstEvent = 1,
101  InitialTimeStamp = 0,
102  TimeStampInterval = 1))
103 
104  cfg.merge(LArBadFebDBAlgCfg(flags,
105  args.inputfile,
106  folder=args.folder,
107  tag=args.tag,
108  IOVStart=[args.runnumber,args.lbnumber],
109  IOVEnd=[args.runnumber2,args.lbnumber2]
110  ))
111 
112 
113 
114  sc=cfg.run(1)
115  if sc.isSuccess():
116  sys.exit(0)
117  else:
118  sys.exit(1)
OutputConditionsAlgConfig.OutputConditionsAlgCfg
def OutputConditionsAlgCfg(flags, name="OutputConditionsAlg", outputFile='condobjs.root', **kwargs)
Definition: OutputConditionsAlgConfig.py:5
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
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
python.LArMissingFebsDBAlg.LArBadFebDBAlgCfg
def LArBadFebDBAlgCfg(flags, InputFile, dbname="LAR_OFL", folder=None, tag=None, IOVStart=[0, 0], IOVEnd=[0x7FFFFFFF, 0xFFFFFFFF])
Definition: LArMissingFebsDBAlg.py:6