ATLAS Offline Software
LArCalib_ToCoolInlineConfig.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 
6 def LArToCoolInlineCfg(flags,inputFolders,singleV=True):
7 
8  from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg
9  result=LArCalibBaseCfg(flags)
10  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
11  result.merge(LArOnOffIdMappingCfg(flags))
12  if flags.LArCalib.isSC:
13  from LArCabling.LArCablingConfig import LArOnOffIdMappingSCCfg
14  result.merge(LArOnOffIdMappingSCCfg(flags))
15 
16  theLArCompleteToFlat = CompFactory.LArCompleteToFlat(FakeEMBPSLowGain = not flags.LArCalib.isSC, isSC=flags.LArCalib.isSC)
17  theLArCompleteToFlat.OutputLevel = 2
18 
19  outTypes = []
20  overrides = []
21  outTags=[]
22  for (fldr,ftag,key,classtype) in inputFolders:
23  if "Pedestal" in fldr:
24  outTypes.append("Pedestal")
25  theLArCompleteToFlat.PedestalInput=key
26  overrides.extend(["Pedestal", "PedestalRMS"])
27  elif "Ramp" in fldr:
28  outTypes.append("Ramp")
29  theLArCompleteToFlat.RampInput=key
30  overrides.extend(["RampVec"])
31  elif "OFC" in fldr:
32  if 'CaliWave' in fldr:
33  outTypes.append("OFCCali")
34  theLArCompleteToFlat.OFCCaliInput=key
35  else:
36  outTypes.append("OFC")
37  theLArCompleteToFlat.OFCInput=key
38  overrides.extend(["OFCa", "OFCb","TimeOffset"])
39  elif "MphysOverMcal" in fldr:
40  outTypes.append("MphysOverMcal")
41  theLArCompleteToFlat.MphysOverMcalInput=key
42  overrides.extend(["MphysOverMcal"])
43  elif "Shape" in fldr:
44  outTypes.append("Shape")
45  theLArCompleteToFlat.ShapeInput=key
46  overrides.extend(["Shape","ShapeDer"])
47 
48  from IOVDbSvc.IOVDbSvcConfig import addFolders
49  if len(ftag):
50  result.merge(addFolders(flags,fldr,detDb=flags.LArCalib.Input.Database,tag=ftag))
51  if not singleV:
52  outTags.append(ftag)
53  else:
54  outTags.append("")
55  else:
56  result.merge(addFolders(flags,fldr,detDb=flags.LArCalib.Input.Database))
57  outTags.append("")
58  pass
59 
60  result.addEventAlgo(theLArCompleteToFlat)
61 
62  flatName="ElecCalibFlat"
63  if flags.LArCalib.isSC:
64  flatName+="SC"
65  if "outObjects" not in dir():
66  outObjects=["CondAttrListCollection#/LAR/"+flatName+"/"+ot for ot in outTypes]
67 
68  print("outObjects are: ",outObjects)
69 
70  from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
71  result.merge(OutputConditionsAlgCfg(flags,
72  outputFile="dummy.root",
73  ObjectList=outObjects,
74  IOVTagList=outTags,
75  Run1=flags.LArCalib.IOVStart,
76  Run2=flags.LArCalib.IOVEnd
77  ))
78  #RegistrationSvc
79  print("OVERRIDES ARE:",overrides)
80  types=[]
81  for i in range(len(overrides)):
82  types.append("Blob16M")
83  result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = True, SVFolder=True,OverrideNames = overrides, OverrideTypes = types))
84  result.getService("IOVDbSvc").DBInstance=""
85 
86  #MC Event selector since we have no input data file
87  from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
88  result.merge(McEventSelectorCfg(flags,
89  RunNumber = flags.LArCalib.Input.RunNumbers[0],
90  EventsPerRun = 1,
91  FirstEvent = 1,
92  InitialTimeStamp = 0,
93  TimeStampInterval = 1))
94 
95 
96  return result
97 
98 if __name__=="__main__":
99  import sys,os
100  import argparse
101 
102  # now process the CL options and assign defaults
103  parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
104  parser.add_argument('-r','--run', dest='run', default=str(0x7FFFFFFF), help='Run number to query input DB', type=str)
105  parser.add_argument('-i','--insqlite', dest='insql', default="freshConstants_AP.db", help='Input sqlite file containing the (merged) output of the AP.', type=str)
106  parser.add_argument('-f','--infolders', dest='infold', default="ConvertToInline.py", help='python file with inputFolders definition', type=str)
107  parser.add_argument('-o','--outsqlite', dest='outsql', default="freshConstants_merged.db", help='Output sqlite file', type=str)
108  parser.add_argument('--iovstart',dest="iovstart", default=0, help="IOV start (run-number)", type=int)
109  parser.add_argument('--isSC', dest='supercells', default=False, help='is SC data ?', action="store_true")
110  parser.add_argument('--poolcat', dest='poolcat', default="freshConstants.xml", help='Catalog of POOL files', type=str)
111  args = parser.parse_args()
112  if help in args and args.help is not None and args.help:
113  parser.print_help()
114  sys.exit(0)
115 
116 
117 
118 
119  #Import the MainServices (boilerplate)
120  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
121 
122  #Import the flag-container that is the arguemnt to the configuration methods
123  from AthenaConfiguration.AllConfigFlags import initConfigFlags
124  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
126  addLArCalibFlags(flags, args.supercells)
127 
128  #Now we set the flags as required for this particular job:
129  flags.LArCalib.Input.Database = args.insql
130 
131  flags.IOVDb.DBConnection="sqlite://;schema="+args.outsql +";dbname=CONDBR2"
132 
133  #The global tag we are working with
134  flags.IOVDb.GlobalTag = "LARCALIB-RUN2-00"
135  # geometry
136  from AthenaConfiguration.TestDefaults import defaultGeometryTags
137  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
138 
139  flags.Input.Files=[]
140  flags.LArCalib.Input.Files = [ ]
141  flags.LArCalib.IOVStart = args.iovstart
142 
143  flags.LArCalib.Input.RunNumbers=[int(args.run),]
144  flags.Input.RunNumbers=flags.LArCalib.Input.RunNumbers
145 
146  flags.Debug.DumpDetStore=True
147  flags.Debug.DumpCondStore=True
148  flags.Debug.DumpEvtStore=True
149 
150  from AthenaCommon.Constants import DEBUG
151  flags.Exec.OutputLevel=DEBUG
152  flags.dump()
153  flags.lock()
154 
155  try:
156  import importlib
157  from pathlib import Path
158  to_import = args.infold
159  if "/" not in args.infold:
160  mypath=os.getcwd()
161  path=Path(mypath)
162  else:
163  path=Path(args.infold)
164  to_import = path.name
165  sys.path.append(str(path.parent))
166  module = importlib.import_module(to_import)#, package=str(path.name))
167  except Exception as e:
168  print(e)
169  sys.exit(-1)
170 
171  print("Input Folders: ",module.inputFolders)
172  cfg=MainServicesCfg(flags)
173  cfg.merge(LArToCoolInlineCfg(flags,module.inputFolders))
174 
175  cfg.getService("PoolSvc").WriteCatalog=("xmlcatalog_file:%s"%args.poolcat)
176  cfg.getService("PoolSvc").ReadCatalog+=["xmlcatalog_file:PoolFileCatalog.xml",]
177  cfg.getService("PoolSvc").SortReplicas = False
178 
179  cfg.getService("MessageSvc").debugLimit=9999999
180 
181  cfg.run(1)
LArCablingConfig.LArOnOffIdMappingSCCfg
def LArOnOffIdMappingSCCfg(configFlags)
Definition: LArCablingConfig.py:65
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
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
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
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
beamspotman.dir
string dir
Definition: beamspotman.py:623
python.LArCalib_ToCoolInlineConfig.LArToCoolInlineCfg
def LArToCoolInlineCfg(flags, inputFolders, singleV=True)
Definition: LArCalib_ToCoolInlineConfig.py:6
python.LArCalibBaseConfig.LArCalibBaseCfg
def LArCalibBaseCfg(flags)
Definition: LArCalibBaseConfig.py:5
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
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