ATLAS Offline Software
LArHVPathology2Ascii.py
Go to the documentation of this file.
1 #!/bin/env python
2 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 from AthenaConfiguration.ComponentFactory import CompFactory
4 from IOVDbSvc.IOVDbSvcConfig import addFolders
5 
6 def LArHVPathology2AsciiCfg(flags,OutputFile="",InputFile="",folder="/LAR/HVPathologiesOfl/Pathologies",tag=None):
7  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
8  result=LArGMCfg(flags)
9  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
10  result.merge(LArOnOffIdMappingCfg(flags))
11  from LArCabling.LArHVCablingConfig import LArHVCablingCfg
12  result.merge(LArHVCablingCfg(flags))
13 
14 
15  if tag is not None:
16  if not tag.startswith("LAR"):
17  if not tag.startswith("-"): tag= "-"+tag
18  tag="".join(folder.split("/"))+tag
19 
20  if (InputFile==""):
21  #Reading case
22  result.merge(addFolders(flags,folder,"LAR_OFL",tag=tag,
23  className="AthenaAttributeList"))
24 
25 
26 
27  LArHVPathologyDbCondAlg=CompFactory.LArHVPathologyDbCondAlg
28  hvpath = LArHVPathologyDbCondAlg(PathologyFolder=folder,
29  HVMappingKey="LArHVIdMap",
30  HVPAthologyKey="LArHVPathology")
31 
32 
33 
34  result.addCondAlgo(hvpath)
35 
36 
37  result.addEventAlgo(CompFactory.LArHVPathologyDbAlg(OutFile=OutputFile,
38  InpFile=InputFile,
39  Folder=folder,
40  WriteCondObjs=(InputFile!=""),
41  HVPAthologyKey="LArHVPathology"))
42 
43  if (InputFile!=""):
44  #Writing case:
45  from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
46  result.merge(OutputConditionsAlgCfg(flags,
47  name="AttrListOutputAlg",
48  outputFile="dummy.pool.root",
49  ObjectList=["AthenaAttributeList#"+folder+"#"+folder],
50  IOVTagList=[tag,],
51  WriteIOV = True,
52  Run1=flags.Input.RunNumbers[0],
53  LB1=0,
54  Run2=0x7FFFFFFF,
55  LB2=0xFFFFFFFF
56  ))
57  result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = True))
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=0x1fffffff, 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","--sqlite",default="", help="Sqlite file name (for conditions-creation)")
70  parser.add_argument("-o","--output",default="", help="output text file name (for dumping)")
71  parser.add_argument("-f","--folder",default="/LAR/HVPathologiesOfl/Pathologies", help="database folder to read or write")
72  parser.add_argument("-t","--tag",default=None, help="folder-level tag to read or write")
73  parser.add_argument("-i","--input",default="",help="Input Text file (for conditions-creation)")
74 
75  (args,leftover)=parser.parse_known_args(sys.argv[1:])
76 
77  if len(leftover)>0:
78  print("ERROR, unhandled argument(s):",leftover)
79  sys.exit(-1)
80 
81  from AthenaConfiguration.AllConfigFlags import initConfigFlags
83 
84  flags.Input.isMC = False
85  flags.IOVDb.DatabaseInstance="CONDBR2"
86  flags.LAr.doAlign=False
87  flags.Input.RunNumbers=[args.runnumber]
88  from AthenaConfiguration.TestDefaults import defaultGeometryTags, defaultConditionsTags
89  flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
90  flags.IOVDb.GlobalTag=defaultConditionsTags.RUN3_DATA
91  #flags.Debug.DumpDetStore=True
92  if (args.sqlite!=""):
93  flags.IOVDb.DBConnection="sqlite://;schema="+args.sqlite+";dbname=CONDBR2"
94 
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(LArHVPathology2AsciiCfg(flags,
117  args.output,
118  folder=args.folder,
119  tag=args.tag,
120  InputFile=args.input
121  ))
122 
123 
124 
125  #cfg.setDebugStage("exec")
126  sc=cfg.run(1)
127  if sc.isSuccess():
128  sys.exit(0)
129  else:
130  sys.exit(1)
LArHVCablingConfig.LArHVCablingCfg
def LArHVCablingCfg(flags)
Definition: LArHVCablingConfig.py:7
OutputConditionsAlgConfig.OutputConditionsAlgCfg
def OutputConditionsAlgCfg(flags, name="OutputConditionsAlg", outputFile='condobjs.root', **kwargs)
Definition: OutputConditionsAlgConfig.py:5
LArHVPathologyDbCondAlg
Definition: LArHVPathologyDbCondAlg.h:30
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
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:86
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArHVPathology2Ascii.LArHVPathology2AsciiCfg
def LArHVPathology2AsciiCfg(flags, OutputFile="", InputFile="", folder="/LAR/HVPathologiesOfl/Pathologies", tag=None)
Definition: LArHVPathology2Ascii.py:6
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