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