32def LArPedestalAutoCorrCfg(flags):
33
34
35 from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg
36 result=LArCalibBaseCfg(flags)
37
38
39 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
40 result.merge(ByteStreamReadCfg(flags))
41
42
43
44
45 gainStrMap={0:"HIGH",1:"MEDIUM",2:"LOW"}
46
47 if not flags.LArCalib.isSC:
48 digKey=gainStrMap[flags.LArCalib.Gain]
49 if flags.LArCalib.Input.isRawData:
50 result.addEventAlgo(CompFactory.LArRawCalibDataReadingAlg(LArDigitKey=digKey,
51 LArFebHeaderKey="LArFebHeader",
52 FailOnCorruption=False,
53 SubCaloPreselection=flags.LArCalib.Input.SubDet,
54 PosNegPreselection=flags.LArCalib.Preselection.Side,
55 BEPreselection=flags.LArCalib.Preselection.BEC,
56 FTNumPreselection=flags.LArCalib.Preselection.FT))
57
58 result.addEventAlgo(CompFactory.LArDigitsAccumulator("LArDigitsAccumulator", KeyList = [digKey],
59 LArAccuDigitContainerName = "", NTriggersPerStep = 100,
60 isSC = flags.LArCalib.isSC, DropPercentTrig = 0))
61 else:
62 result.merge(AccCalibDataReadingCfg(flags, digKey))
63
64 from LArROD.LArFebErrorSummaryMakerConfig import LArFebErrorSummaryMakerCfg
65 result.merge(LArFebErrorSummaryMakerCfg(flags))
66 result.getEventAlgo("LArFebErrorSummaryMaker").CheckAllFEB=False
67 result.addEventAlgo(CompFactory.LArBadEventCatcher(CheckAccCalibDigitCont=True,
68 CheckBSErrors=True,
69 KeyList=[digKey,],
70 StopOnError=False))
71
72 else:
73 digKey="SC"
74 theLArLATOMEDecoder = CompFactory.LArLATOMEDecoder("LArLATOMEDecoder",
75 IgnoreBarrelChannels = flags.LArCalib.SCIgnoreBarrelChannels,
76 IgnoreEndcapChannels = flags.LArCalib.SCIgnoreEndcapChannels)
77
78 if flags.LArCalib.Input.isRawData:
79 result.addEventAlgo(CompFactory.LArRawSCDataReadingAlg(adcCollKey = digKey, adcBasCollKey = "", etCollKey = "",
80 etIdCollKey = "", LATOMEDecoder = theLArLATOMEDecoder))
81 result.addEventAlgo(CompFactory.LArDigitsAccumulator("LArDigitsAccumulator", KeyList = [digKey],
82 LArAccuDigitContainerName = "", NTriggersPerStep = 100,
83 isSC = flags.LArCalib.isSC, DropPercentTrig = 0))
84 else:
85
86 from LArCabling.LArCablingConfig import LArCalibIdMappingCfg,LArOnOffIdMappingCfg,LArCalibIdMappingSCCfg,LArOnOffIdMappingSCCfg
87 result.merge(LArOnOffIdMappingCfg(flags))
88 result.merge(LArCalibIdMappingSCCfg(flags))
89 result.merge(LArOnOffIdMappingSCCfg(flags))
90 result.merge(LArCalibIdMappingCfg(flags))
91
92 result.addEventAlgo(CompFactory.LArRawSCCalibDataReadingAlg(LArSCAccDigitKey = digKey, LATOMEDecoder = theLArLATOMEDecoder))
93
94 LArPedACBuilder=CompFactory.LArPedestalAutoCorrBuilder()
95 LArPedACBuilder.KeyList = [digKey,]
96 LArPedACBuilder.PedestalKey = "Pedestal"
97 LArPedACBuilder.AutoCorrKey = "LArAutoCorr"
98 LArPedACBuilder.GroupingType = flags.LArCalib.GroupingType
99
100 result.addEventAlgo(LArPedACBuilder)
101
102 if flags.LArCalib.isSC:
103 bcKey = "LArBadChannelSC"
104 else:
105 bcKey = "LArBadChannel"
106
107 if flags.LArCalib.CorrectBadChannels:
108 theLArAcorrPatcher=CompFactory.getComp("LArCalibPatchingAlg<LArAutoCorrComplete>")("LArAcorrPatch")
109 theLArAcorrPatcher.ContainerKey = "LArAutoCorr"
110 theLArAcorrPatcher.BadChanKey = bcKey
111 theLArAcorrPatcher.SuperCells = flags.LArCalib.isSC
112 theLArAcorrPatcher.PatchMethod="FEBNeighbor"
114 if flags.LArCalib.isSC:
115 theLArAcorrPatcher.ProblemsToPatch = [ "problematicForUnknownReason","transmissionErrorFibre"]
116 theLArAcorrPatcher.OnOffMap="LArOnOffIdMapSC"
117 theLArAcorrPatcher.CalibLineKey="LArCalibIdMapSC"
118 else:
119 theLArAcorrPatcher.ProblemsToPatch = [ "badAutoCorr", ]
120
121 theLArAcorrPatcher.UseCorrChannels=False
122 result.addEventAlgo(theLArAcorrPatcher)
123 pass
124
125
126 rootfile=flags.LArCalib.Output.ROOTFile
127 if rootfile != "":
128 result.addEventAlgo(CompFactory.LArPedestals2Ntuple(ContainerKey = "Pedestal",
129 AddFEBTempInfo = False,
130 RealGeometry = True,
131 OffId = True,
132 AddCalib = True,
133 isSC = flags.LArCalib.isSC,
134 BadChanKey = bcKey
135 )
136 )
137
138 result.addEventAlgo(CompFactory.LArAutoCorr2Ntuple(ContainerKey = "LArAutoCorr",
139 AddFEBTempInfo = False, isSC = flags.LArCalib.isSC,
140 BadChanKey = bcKey,
141 OffId=True,
142 ApplyCorrection = True,
143 AddCorrUndo = True,
144 AddCalib = True
145 )
146 )
147
148 import os
149 if os.path.exists(rootfile):
150 os.remove(rootfile)
151 result.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+rootfile+"' OPT='NEW'" ]))
152 result.setAppProperty("HistogramPersistency","ROOT")
153 pass
154
155
156
157
158 from LArCalibProcessing.utils import FolderTagResolver
159 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
160 tagResolver=FolderTagResolver()
161 pedestalTag=tagResolver.getFolderTag(flags.LArCalib.Pedestal.Folder)
162 autocorrTag=tagResolver.getFolderTag(flags.LArCalib.AutoCorr.Folder)
163 del tagResolver
164
165
166
167 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
168 result.merge(OutputConditionsAlgCfg(flags,
169 outputFile=flags.LArCalib.Output.POOLFile,
170 ObjectList=["LArPedestalComplete#Pedestal#"+flags.LArCalib.Pedestal.Folder,
171 "LArAutoCorrComplete#LArAutoCorr#"+flags.LArCalib.AutoCorr.Folder],
172 IOVTagList=[pedestalTag,autocorrTag],
173 Run1=flags.LArCalib.IOVStart,
174 Run2=flags.LArCalib.IOVEnd
175 ))
176
177
178 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
179
180
181 if flags.LArCalib.doValidation:
182 from IOVDbSvc.IOVDbSvcConfig import addFolders
183
184
185 result.merge(addFolders(flags,"/LAR/ElecCalibFlat/Pedestal<key>PedestalRefIn</key>","LAR_ONL","CondAttrListCollection"))
186 LArPedestalCondAlg = CompFactory.getComp("LArFlatConditionsAlg<LArPedestalFlat>")
187 result.addCondAlgo(LArPedestalCondAlg("LArFlatPedCondAlg",ReadKey="PedestalRefIn", WriteKey="PedestalRef"))
188 from LArCalibDataQuality.Thresholds import pedThr,rmsThr, pedThrFEB,rmsThrFEB
190
191 thePedestalValidationAlg=CompFactory.LArPedestalValidationAlg("PedestalVal")
192
193 thePedestalValidationAlg.UseBadChannelInfo=False
194 thePedestalValidationAlg.ValidationKey="Pedestal"
195 thePedestalValidationAlg.ReferenceKey="PedestalRef"
196 thePedestalValidationAlg.PedestalTolerance=pedThr
197 thePedestalValidationAlg.PedestalRMSTolerance=rmsThr
198 thePedestalValidationAlg.PedestalToleranceFEB=pedThrFEB
199 thePedestalValidationAlg.PedestalRMSToleranceFEB=rmsThrFEB
200 thePedestalValidationAlg.MsgLevelForDeviations=WARNING
201 thePedestalValidationAlg.ListOfDevFEBs="pedFebs.txt"
202 thePedestalValidationAlg.CheckCompletness=True
203 thePedestalValidationAlg.PatchMissingFEBs=True
204 thePedestalValidationAlg.UseCorrChannels=False
205 if flags.LArCalib.isSC:
206 thePedestalValidationAlg.CablingKey = "LArOnOffIdMapSC"
207 thePedestalValidationAlg.CalibLineKey = "LArCalibIdMapSC"
208 thePedestalValidationAlg.BadChanKey = bcKey
209 result.addEventAlgo(thePedestalValidationAlg)
210
211
212 theBadPedestal=CompFactory.LArPedestalValidationAlg("PedestalFail")
213
214 theBadPedestal.UseBadChannelInfo=False
215 theBadPedestal.ValidationKey="Pedestal"
216 theBadPedestal.ReferenceKey="PedestalRef"
217 theBadPedestal.PedestalTolerance = ["10,10,10"]
218 theBadPedestal.PedestalRMSTolerance = ["0.5, 0.5, 0.5"]
219 theBadPedestal.PedestalToleranceFEB = ["8, 8, 8"]
220 theBadPedestal.PedestalRMSToleranceFEB = ["1.2, 1.2, 1.2"]
221
222 theBadPedestal.MsgLevelForDeviations=ERROR
223 theBadPedestal.CheckCompletness=False
224 theBadPedestal.ListOfDevFEBs="Bad_pedFebs.txt"
225 if flags.LArCalib.isSC:
226 theBadPedestal.CablingKey = "LArOnOffIdMapSC"
227 theBadPedestal.CalibLineKey = "LArCalibIdMapSC"
228 theBadPedestal.BadChanKey = bcKey
229 result.addEventAlgo(theBadPedestal)
230
231
232 result.merge(addFolders(flags,"/LAR/ElecCalibOfl/AutoCorrs/AutoCorr<key>LArAutoCorrRef</key>","LAR_OFL"))
233 from LArCalibDataQuality.Thresholds import acThr, acThrFEB
234 theAutoCorrValidationAlg=CompFactory.LArAutoCorrValidationAlg("AutoCorrVal")
235 theAutoCorrValidationAlg.UseBadChannelInfo=False
236 theAutoCorrValidationAlg.ValidationKey="LArAutoCorr"
237 theAutoCorrValidationAlg.ReferenceKey="LArAutoCorrRef"
238 theAutoCorrValidationAlg.AutoCorrTolerance=acThr
239 theAutoCorrValidationAlg.AutoCorrToleranceFEB=acThrFEB
240 theAutoCorrValidationAlg.MsgLevelForDeviations=WARNING
241 theAutoCorrValidationAlg.ListOfDevFEBs="ACFebs.txt"
242 theAutoCorrValidationAlg.CheckCompletness=True
243 theAutoCorrValidationAlg.PatchMissingFEBs=True
244 theAutoCorrValidationAlg.UseCorrChannels=False
245 if flags.LArCalib.isSC:
246 theAutoCorrValidationAlg.CablingKey = "LArOnOffIdMapSC"
247 theAutoCorrValidationAlg.CalibLineKey = "LArCalibIdMapSC"
248 theAutoCorrValidationAlg.BadChanKey = bcKey
249 result.addEventAlgo(theAutoCorrValidationAlg)
250
251
252 theBadAutoCorr=CompFactory.LArAutoCorrValidationAlg("AutoCorrFail")
253 theBadAutoCorr.UseBadChannelInfo=False
254 theBadAutoCorr.ValidationKey="LArAutoCorr"
255 theBadAutoCorr.ReferenceKey="LArAutoCorrRef"
256 theBadAutoCorr.AutoCorrTolerance = ["0.15, 0.15, 0.15"]
257 theBadAutoCorr.AutoCorrToleranceFEB = ["0.15, 0.15, 0.15"]
258 theBadAutoCorr.MsgLevelForDeviations=ERROR
259 theBadAutoCorr.CheckFifthSample=True
260 theBadAutoCorr.ListOfDevFEBs="Bad_ACFebs.txt"
261 theBadAutoCorr.CheckCompletness=False
262 if flags.LArCalib.isSC:
263 theBadAutoCorr.CablingKey = "LArOnOffIdMapSC"
264 theBadAutoCorr.CalibLineKey = "LArCalibIdMapSC"
265 theBadAutoCorr.BadChanKey = bcKey
266 result.addEventAlgo(theBadAutoCorr)
267
268 result.getService("IOVDbSvc").DBInstance=""
269
270 from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
271 result.merge(PerfMonMTSvcCfg(flags))
272
273
274 return result
275
276