ATLAS Offline Software
LArDSPThresholdTopOptions.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 tagList = [
4  'LARConfigurationDSPThresholdFlatTemplates-Qt1sigma-samp1sigma',
5  'LARConfigurationDSPThresholdFlatTemplates-Qt1.5sigma-samp1.5sigma',
6  'LARConfigurationDSPThresholdFlatTemplates-Qt2sigma-samp2sigma',
7  'LARConfigurationDSPThresholdFlatTemplates-Qt3sigma-samp3sigma',
8  'LARConfigurationDSPThresholdFlatTemplates-Qt5sigma-samp5sigma',
9  'LARConfigurationDSPThresholdFlatTemplates-Qt3sigmamuPileup-samp3sigmamuPileup',
10  'LARConfigurationDSPThresholdFlatTemplates-Qt4sigmamuPileup-samp4sigmamuPileup',
11  'LARConfigurationDSPThresholdFlatTemplates-Qt5sigmamuPileup-samp5sigmamuPileup'
12  ]
13 
14 
15 def LArDSPThresholdCfg(flags,tag="",ModeType="noise",RunSince=0,fill=True,
16  Sampval=0, Qtval=0, Samppileup=False, Qtpileup=False):
17 
18  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
19  cfg=LArGMCfg(flags)
20 
21  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
22  cfg.merge(LArOnOffIdMappingCfg(flags))
23  # setup bad chan and missing febs
24  from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg,LArBadFebCfg
25  cfg.merge(LArBadChannelCfg(flags))
26  cfg.merge(LArBadFebCfg(flags))
27 
28  folder="/LAR/Configuration/DSPThresholdFlat/Templates"
29 
30  fileName=ModeType+tag
31 
32  setName="-".join(tag.split("-")[1:])
33 
34  from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
35  cfg.merge(CaloNoiseCondAlgCfg(flags,"totalNoise"))
36  cfg.merge(CaloNoiseCondAlgCfg(flags,"electronicNoise"))
37  cfg.merge(CaloNoiseCondAlgCfg(flags,"pileupNoise"))
38 
39  from AthenaConfiguration.ComponentFactory import CompFactory
40  theLArDSPThresholdFillAlg=CompFactory.LArDSPThresholdFillInline("LArDSPThresholdFillInline")
41  from AthenaCommon.Constants import INFO
42  theLArDSPThresholdFillAlg.OutputLevel=INFO
43  theLArDSPThresholdFillAlg.Key=folder
44  theLArDSPThresholdFillAlg.OutFile=fileName+".txt"
45  theLArDSPThresholdFillAlg.mode=ModeType
46  theLArDSPThresholdFillAlg.MaskBadChannels=True
47  theLArDSPThresholdFillAlg.ProblemsToMask=[ "highNoiseHG","highNoiseMG","highNoiseLG" ]
48  theLArDSPThresholdFillAlg.NameOfSet=setName
49 
50  if ModeType=="fixed":
51  theLArDSPThresholdFillAlg.tQThreshold=Qtval
52  theLArDSPThresholdFillAlg.samplesThreshold=Sampval
53 
54  if ModeType=="noise":
55  theLArDSPThresholdFillAlg.sigmaNoiseSamples=Sampval
56  theLArDSPThresholdFillAlg.sigmaNoiseQt=Qtval
57  theLArDSPThresholdFillAlg.usePileupNoiseSamples=Samppileup
58  theLArDSPThresholdFillAlg.usePileupNoiseQt=Qtpileup
59 
60  if fill:
61  theLArDSPThresholdFillAlg.Fill=True
62  theLArDSPThresholdFillAlg.Dump=True
63  else:
64  theLArDSPThresholdFillAlg.Fill=False
65  theLArDSPThresholdFillAlg.Dump=True
66 
67  cfg.addEventAlgo(theLArDSPThresholdFillAlg)
68 
69  if fill:
70  OutputList=[ "AthenaAttributeList#"+folder ]
71  OutputTagList=[tag]
72 
73  from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
74  cfg.merge(OutputConditionsAlgCfg(flags,outputFile="LArDSPthresholdTemplates.pool.root",
75  ObjectList=OutputList,IOVTagList=OutputTagList,WriteIOV=True, Run1=RunSince))
76 
77  cfg.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False,
78  OverrideNames = ["tQThr","samplesThr","trigSumThr",],
79  OverrideTypes = ["Blob16M","Blob16M","Blob16M",] ))
80 
81 
82  else:
83  from IOVDbSvc.IOVDbSvcConfig import addFolders
84  cfg.merge(addFolders(flags,folder+"<tag>"+tag+"</tag>"))
85 
86  cfg.getService("PoolSvc").WriteCatalog="xmlcatalog_file:PoolFileCatalog_LARConfigurationDSPThresholdTemplates.xml"
87 
88  #MC Event selector since we have no input data file
89  from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
90  cfg.merge(McEventSelectorCfg(flags,
91  RunNumber = flags.Input.RunNumbers[0],
92  EventsPerRun = 1,
93  FirstEvent = 1,
94  InitialTimeStamp = 0,
95  TimeStampInterval = 1))
96 
97  return cfg
98 
99 if __name__ == "__main__":
100 
101  import argparse
102  import sys
103 
104  # now process the CL options and assign defaults
105  parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
106 
107  parser.add_argument('-r','--run', dest='run', default=500000, help='Run to read the noise')
108  parser.add_argument('-s','--since', dest='since', default=480000, help='Run to start IOV')
109  parser.add_argument('-t','--tagnum', dest='tagnum', default=0, help='Which tag to compute')
110  parser.add_argument('-x','--tagstr', dest='tagstr', default='', help='Tag string to compute')
111  parser.add_argument('-n','--noisetag', dest='noisetag', default="", help='Which noise tag to use')
112  parser.add_argument('--sqlite', dest='sql', default="", help='Sqlite file with noise folder')
113  parser.add_argument('-a','--localnoise', dest='localnoise', default=False, action="store_true", help='read the noise from local sqlite')
114  parser.add_argument('-p','--localpileup', dest='localpileup', default=False, action="store_true", help='read the pileup from local sqlite')
115 
116  args = parser.parse_args()
117  if help in args and args.help is not None and args.help:
118  parser.print_help()
119  sys.exit(0)
120 
121  for _, value in args._get_kwargs():
122  if value is not None:
123  print(value)
124 
125  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
126  from AthenaConfiguration.AllConfigFlags import initConfigFlags
127  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
129  addLArCalibFlags(flags)
130 
131  if args.tagstr != '':
132  if 'LARConfigurationDSPThresholdFlatTemplates-Qt' not in args.tagstr or '-samp' not in args.tagstr:
133  tagstr = tagList[0]
134  else:
135  tagstr = args.tagstr
136  else:
137  tagstr = tagList[int(args.tagnum)] if int(args.tagnum)<len(tagList) else tagList[0]
138 
139  print(tagstr)
140 
141  Qtstr=tagstr.split("Qt")[1]
142  Sampstr=tagstr.split("samp")[1]
143 
144  if "sigma" in tagstr:
145  ModeType = "noise"
146 
147  QtPileup = False
148  SampPileup = False
149 
150  if len(Qtstr.split("sigma")) > 1:
151  print(Qtstr.split("sigma")[1])
152  if Qtstr.split("sigma")[1].find("Pileup") > -1:
153  QtPileup = True
154 
155  if len(Sampstr.split("sigma")) > 1:
156  print(Sampstr.split("sigma")[1])
157  if Sampstr.split("sigma")[1].find("Pileup") > -1:
158  SampPileup = True
159 
160  print("Setting pileup noise to (Qt,Samp) = ",QtPileup,SampPileup)
161 
162  Qtstr=Qtstr.split("sigma")[0]
163  Sampstr=Sampstr.split("sigma")[0]
164 
165  elif "HECFCAL" in tagstr:
166  ModeType = "group"
167  Qtstr="0"
168  Sampstr="0"
169 
170  else:
171  ModeType = "fixed"
172  Qtstr=Qtstr.split("-")[0]
173 
174  QtVal=float(Qtstr)
175  SampVal=float(Sampstr)
176  print(QtVal,SampVal)
177 
178  flags.Input.Files=[]
179  flags.Input.RunNumbers = [int(args.run),]
180 
181  flags.IOVDb.DBConnection = "sqlite://;schema=DSPThresholdTemplates.db;dbname=CONDBR2"
182 
183  from AthenaConfiguration.TestDefaults import defaultGeometryTags
184  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
185 
186  flags.Detector.EnableID=False
187  flags.Detector.EnableMuon=False
188  flags.Detector.EnableForward=False
189 
190  flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-2024-03'
191 
192  flags.Debug.DumpDetStore=True
193  flags.Debug.DumpEvtStore=True
194  flags.Debug.DumpCondStore=True
195 
196  if args.sql != "":
197  flags.IOVDb.SqliteInput=args.sql
198  fldrs=[]
199  if args.localpileup:
200  fldrs += ["/CALO/Ofl/Noise/PileUpNoiseLumi"]
201  if args.localpileup:
202  fldrs += ["/LAR/NoiseOfl/CellNoise"]
203  flags.IOVDb.SqliteFolders=fldrs
204 
205  flags.LAr.doHVCorr=False
206 
207  flags.lock()
208  flags.dump()
209 
210  cfg=MainServicesCfg(flags)
211 
212  cfg.merge(LArDSPThresholdCfg(flags,tag=tagstr,ModeType="noise",RunSince=0,fill=True,
213  Sampval=SampVal, Qtval=QtVal, Samppileup=SampPileup, Qtpileup=QtPileup))
214 
215  from IOVDbSvc.IOVDbSvcConfig import addOverride
216  cfg.merge(addOverride(flags,"/CALO/Ofl/Noise/PileUpNoiseLumi","CALOOflNoisePileUpNoiseLumi-RUN2-UPD1-00"))
217  if args.noisetag!="":
218  cfg.merge(addOverride(flags,"/LAR/NoiseOfl/CellNoise",args.noisetag))
219 
220 
221  cfg.run(2)
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
python.LArBadChannelConfig.LArBadFebCfg
def LArBadFebCfg(configFlags, tag=None, dbname=None)
Definition: LArBadChannelConfig.py:43
OutputConditionsAlgConfig.OutputConditionsAlgCfg
def OutputConditionsAlgCfg(flags, name="OutputConditionsAlg", outputFile='condobjs.root', **kwargs)
Definition: OutputConditionsAlgConfig.py:5
python.LArBadChannelConfig.LArBadChannelCfg
def LArBadChannelCfg(configFlags, tag=None, isSC=False)
Definition: LArBadChannelConfig.py:8
python.CaloNoiseCondAlgConfig.CaloNoiseCondAlgCfg
def CaloNoiseCondAlgCfg(flags, noisetype="totalNoise")
Definition: CaloNoiseCondAlgConfig.py:11
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
LArDSPThresholdTopOptions.LArDSPThresholdCfg
def LArDSPThresholdCfg(flags, tag="", ModeType="noise", RunSince=0, fill=True, Sampval=0, Qtval=0, Samppileup=False, Qtpileup=False)
Definition: LArDSPThresholdTopOptions.py:15
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:86
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.IOVDbSvcConfig.addOverride
def addOverride(flags, folder, tag, tagType="tag", db=None)
Definition: IOVDbSvcConfig.py:238
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65