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('-p','--pileuptag', dest='pileuptag', default="", help='Which pileup tag to use')
113  parser.add_argument('--sqlite', dest='sql', default="", help='Sqlite file with noise folder')
114  parser.add_argument('-a','--localnoise', dest='localnoise', default=False, action="store_true", help='read the noise from local sqlite')
115  parser.add_argument('-l','--localpileup', dest='localpileup', default=False, action="store_true", help='read the pileup from local sqlite')
116 
117  args = parser.parse_args()
118  if help in args and args.help is not None and args.help:
119  parser.print_help()
120  sys.exit(0)
121 
122  for _, value in args._get_kwargs():
123  if value is not None:
124  print(value)
125 
126  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
127  from AthenaConfiguration.AllConfigFlags import initConfigFlags
128  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
130  addLArCalibFlags(flags)
131 
132  if args.tagstr != '':
133  if 'LARConfigurationDSPThresholdFlatTemplates-Qt' not in args.tagstr or '-samp' not in args.tagstr:
134  tagstr = tagList[0]
135  else:
136  tagstr = args.tagstr
137  else:
138  tagstr = tagList[int(args.tagnum)] if int(args.tagnum)<len(tagList) else tagList[0]
139 
140  print(tagstr)
141 
142  Qtstr=tagstr.split("Qt")[1]
143  Sampstr=tagstr.split("samp")[1]
144 
145  if "sigma" in tagstr:
146  ModeType = "noise"
147 
148  QtPileup = False
149  SampPileup = False
150 
151  if len(Qtstr.split("sigma")) > 1:
152  print(Qtstr.split("sigma")[1])
153  if Qtstr.split("sigma")[1].find("Pileup") > -1:
154  QtPileup = True
155 
156  if len(Sampstr.split("sigma")) > 1:
157  print(Sampstr.split("sigma")[1])
158  if Sampstr.split("sigma")[1].find("Pileup") > -1:
159  SampPileup = True
160 
161  print("Setting pileup noise to (Qt,Samp) = ",QtPileup,SampPileup)
162 
163  Qtstr=Qtstr.split("sigma")[0]
164  Sampstr=Sampstr.split("sigma")[0]
165 
166  elif "HECFCAL" in tagstr:
167  ModeType = "group"
168  Qtstr="0"
169  Sampstr="0"
170 
171  else:
172  ModeType = "fixed"
173  Qtstr=Qtstr.split("-")[0]
174 
175  QtVal=float(Qtstr)
176  SampVal=float(Sampstr)
177  print(QtVal,SampVal)
178 
179  flags.Input.Files=[]
180  flags.Input.RunNumbers = [int(args.run),]
181 
182  flags.IOVDb.DBConnection = "sqlite://;schema=DSPThresholdTemplates.db;dbname=CONDBR2"
183  flags.IOVDb.DatabaseInstance="CONDBR2"
184 
185  from AthenaConfiguration.TestDefaults import defaultGeometryTags
186  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
187 
188  flags.Detector.EnableID=False
189  flags.Detector.EnableMuon=False
190  flags.Detector.EnableForward=False
191 
192  flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-2024-03'
193 
194  flags.Debug.DumpDetStore=True
195  flags.Debug.DumpEvtStore=True
196  flags.Debug.DumpCondStore=True
197 
198  if args.sql != "":
199  flags.IOVDb.SqliteInput=args.sql
200  fldrs=set()
201  if args.localpileup:
202  fldrs.add("/CALO/Ofl/Noise/PileUpNoiseLumi")
203  if args.localpileup:
204  fldrs.add("/LAR/NoiseOfl/CellNoise")
205  flags.IOVDb.SqliteFolders=tuple(fldrs)
206 
207  flags.LAr.doHVCorr=False
208 
209  flags.lock()
210  flags.dump()
211 
212  cfg=MainServicesCfg(flags)
213 
214  cfg.merge(LArDSPThresholdCfg(flags,tag=tagstr,ModeType="noise",RunSince=0,fill=True,
215  Sampval=SampVal, Qtval=QtVal, Samppileup=SampPileup, Qtpileup=QtPileup))
216 
217  from IOVDbSvc.IOVDbSvcConfig import addOverride
218  if args.pileuptag!="":
219  cfg.merge(addOverride(flags,"/CALO/Ofl/Noise/PileUpNoiseLumi",args.pileuptag))
220  else:
221  cfg.merge(addOverride(flags,"/CALO/Ofl/Noise/PileUpNoiseLumi","CALOOflNoisePileUpNoiseLumi-RUN2-UPD1-00"))
222  if args.noisetag!="":
223  cfg.merge(addOverride(flags,"/LAR/NoiseOfl/CellNoise",args.noisetag))
224 
225 
226  cfg.run(2)
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:138
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:310
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
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
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:66