ATLAS Offline Software
Loading...
Searching...
No Matches
LArDSPThresholdTopOptions.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3tagList = [
4 'LARConfigurationDSPThresholdFlatTemplates-Qt1sigma-samp1sigma',
5 'LARConfigurationDSPThresholdFlatTemplates-Qt2sigma-samp2sigma',
6 'LARConfigurationDSPThresholdFlatTemplates-Qt3sigma-samp3sigma',
7 'LARConfigurationDSPThresholdFlatTemplates-Qt4sigma-samp4sigma',
8 'LARConfigurationDSPThresholdFlatTemplates-Qt5sigma-samp5sigma',
9 'LARConfigurationDSPThresholdFlatTemplates-Qt3sigmamuPileup-samp3sigmamuPileup',
10 'LARConfigurationDSPThresholdFlatTemplates-Qt4sigmamuPileup-samp4sigmamuPileup',
11 'LARConfigurationDSPThresholdFlatTemplates-Qt5sigmamuPileup-samp5sigmamuPileup'
12 ]
13
14
15def LArDSPThresholdCfg(flags,tag="",ModeType="noise",RunSince=0,fill=True,
16 Sampval=0, Qtval=0, Samppileup=False, Qtpileup=False,scale=0.):
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 theLArDSPThresholdFillAlg.ScaleIW=scale
50
51 if ModeType=="fixed":
52 theLArDSPThresholdFillAlg.tQThreshold=Qtval
53 theLArDSPThresholdFillAlg.samplesThreshold=Sampval
54
55 if ModeType=="noise":
56 theLArDSPThresholdFillAlg.sigmaNoiseSamples=Sampval
57 theLArDSPThresholdFillAlg.sigmaNoiseQt=Qtval
58 theLArDSPThresholdFillAlg.usePileupNoiseSamples=Samppileup
59 theLArDSPThresholdFillAlg.usePileupNoiseQt=Qtpileup
60
61 if fill:
62 theLArDSPThresholdFillAlg.Fill=True
63 theLArDSPThresholdFillAlg.Dump=True
64 else:
65 theLArDSPThresholdFillAlg.Fill=False
66 theLArDSPThresholdFillAlg.Dump=True
67
68 cfg.addEventAlgo(theLArDSPThresholdFillAlg)
69
70 if fill:
71 OutputList=[ "AthenaAttributeList#"+folder ]
72 OutputTagList=[tag]
73
74 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
75 cfg.merge(OutputConditionsAlgCfg(flags,outputFile="LArDSPthresholdTemplates.pool.root",
76 ObjectList=OutputList,IOVTagList=OutputTagList,WriteIOV=True, Run1=RunSince))
77
78 cfg.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False,
79 OverrideNames = ["tQThr","samplesThr","trigSumThr",],
80 OverrideTypes = ["Blob16M","Blob16M","Blob16M",] ))
81
82
83 else:
84 from IOVDbSvc.IOVDbSvcConfig import addFolders
85 cfg.merge(addFolders(flags,folder+"<tag>"+tag+"</tag>"))
86
87 cfg.getService("PoolSvc").WriteCatalog="xmlcatalog_file:PoolFileCatalog_LARConfigurationDSPThresholdTemplates.xml"
88
89 #MC Event selector since we have no input data file
90 from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
91 cfg.merge(McEventSelectorCfg(flags,
92 RunNumber = flags.Input.RunNumbers[0],
93 EventsPerRun = 1,
94 FirstEvent = 1,
95 InitialTimeStamp = 0,
96 TimeStampInterval = 1))
97
98 return cfg
99
100if __name__ == "__main__":
101
102 import argparse
103 import sys
104
105 # now process the CL options and assign defaults
106 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
107
108 parser.add_argument('-r','--run', dest='run', default=500000, help='Run to read the noise')
109 parser.add_argument('-s','--since', dest='since', default=480000, help='Run to start IOV')
110 parser.add_argument('-t','--tagnum', dest='tagnum', default=0, help='Which tag to compute')
111 parser.add_argument('-x','--tagstr', dest='tagstr', default='', help='Tag string to compute')
112 parser.add_argument('-n','--noisetag', dest='noisetag', default="", help='Which noise tag to use')
113 parser.add_argument('-p','--pileuptag', dest='pileuptag', default="", help='Which pileup tag to use')
114 parser.add_argument('--sqlite', dest='sql', default="", help='Sqlite file with noise folder')
115 parser.add_argument('-a','--localnoise', dest='localnoise', default=False, action="store_true", help='read the noise from local sqlite')
116 parser.add_argument('-l','--localpileup', dest='localpileup', default=False, action="store_true", help='read the pileup from local sqlite')
117 parser.add_argument('--scaleIW', dest='scaleIW', default=0., help='scale ther IW')
118
119 args = parser.parse_args()
120 if help in args and args.help is not None and args.help:
121 parser.print_help()
122 sys.exit(0)
123
124 for _, value in args._get_kwargs():
125 if value is not None:
126 print(value)
127
128 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
129 from AthenaConfiguration.AllConfigFlags import initConfigFlags
130 from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
131 flags=initConfigFlags()
132 addLArCalibFlags(flags)
133
134 if args.tagstr != '':
135 if 'LARConfigurationDSPThresholdFlatTemplates-Qt' not in args.tagstr or '-samp' not in args.tagstr:
136 tagstr = tagList[0]
137 else:
138 tagstr = args.tagstr
139 else:
140 tagstr = tagList[int(args.tagnum)] if int(args.tagnum)<len(tagList) else tagList[0]
141
142 print(tagstr)
143
144 Qtstr=tagstr.split("Qt")[1]
145 Sampstr=tagstr.split("samp")[1]
146
147 if "sigma" in tagstr:
148 ModeType = "noise"
149
150 QtPileup = False
151 SampPileup = False
152
153 if len(Qtstr.split("sigma")) > 1:
154 print(Qtstr.split("sigma")[1])
155 if Qtstr.split("sigma")[1].find("Pileup") > -1:
156 QtPileup = True
157
158 if len(Sampstr.split("sigma")) > 1:
159 print(Sampstr.split("sigma")[1])
160 if Sampstr.split("sigma")[1].find("Pileup") > -1:
161 SampPileup = True
162
163 print("Setting pileup noise to (Qt,Samp) = ",QtPileup,SampPileup)
164
165 Qtstr=Qtstr.split("sigma")[0]
166 Sampstr=Sampstr.split("sigma")[0]
167
168 elif "HECFCAL" in tagstr:
169 ModeType = "group"
170 Qtstr="0"
171 Sampstr="0"
172
173 else:
174 ModeType = "fixed"
175 Qtstr=Qtstr.split("-")[0]
176
177 QtVal=float(Qtstr)
178 SampVal=float(Sampstr)
179 print(QtVal,SampVal)
180
181 flags.Input.Files=[]
182 flags.Input.RunNumbers = [int(args.run),]
183
184 flags.IOVDb.DBConnection = "sqlite://;schema=DSPThresholdTemplates.db;dbname=CONDBR2"
185 flags.IOVDb.DatabaseInstance="CONDBR2"
186
187 from AthenaConfiguration.TestDefaults import defaultGeometryTags
188 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
189
190 flags.Detector.EnableID=False
191 flags.Detector.EnableMuon=False
192 flags.Detector.EnableForward=False
193
194 flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-2026-01'
195
196 flags.Debug.DumpDetStore=True
197 flags.Debug.DumpEvtStore=True
198 flags.Debug.DumpCondStore=True
199
200 if args.sql != "":
201 flags.IOVDb.SqliteInput=args.sql
202 fldrs=set()
203 if args.localpileup:
204 fldrs.add("/CALO/Ofl/Noise/PileUpNoiseLumi")
205 if args.localpileup:
206 fldrs.add("/LAR/NoiseOfl/CellNoise")
207 flags.IOVDb.SqliteFolders=tuple(fldrs)
208
209 flags.LAr.doHVCorr=False
210
211 flags.lock()
212 flags.dump()
213
214 cfg=MainServicesCfg(flags)
215
216 cfg.merge(LArDSPThresholdCfg(flags,tag=tagstr,ModeType="noise",RunSince=0,fill=True,
217 Sampval=SampVal, Qtval=QtVal, Samppileup=SampPileup, Qtpileup=QtPileup,scale=float(args.scaleIW)))
218
219 from IOVDbSvc.IOVDbSvcConfig import addOverride
220 if args.pileuptag!="":
221 cfg.merge(addOverride(flags,"/CALO/Ofl/Noise/PileUpNoiseLumi",args.pileuptag))
222 else:
223 cfg.merge(addOverride(flags,"/CALO/Ofl/Noise/PileUpNoiseLumi","CALOOflNoisePileUpNoiseLumi-RUN2-UPD1-00"))
224 if args.noisetag!="":
225 cfg.merge(addOverride(flags,"/LAR/NoiseOfl/CellNoise",args.noisetag))
226
227
228 cfg.run(2)
void print(char *figname, TCanvas *c1)
STL class.
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140
LArDSPThresholdCfg(flags, tag="", ModeType="noise", RunSince=0, fill=True, Sampval=0, Qtval=0, Samppileup=False, Qtpileup=False, scale=0.)