7def LArDelay_OFCCaliCfg(flags):
8
9
10 from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg,chanSelStr
11 result=LArCalibBaseCfg(flags)
12
13
14 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
15 result.merge(ByteStreamReadCfg(flags))
16
17
18
19 gainStrMap={0:"HIGH",1:"MEDIUM",2:"LOW"}
20 digKey=gainStrMap[flags.LArCalib.Gain]
21
22 from LArCalibProcessing.utils import FolderTagResolver
23 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
24 tagResolver=FolderTagResolver()
25 pedestalTag=tagResolver.getFolderTag(flags.LArCalib.Pedestal.Folder)
26 caliWaveTag=tagResolver.getFolderTag(flags.LArCalib.CaliWave.Folder)
27 caliOFCTag=tagResolver.getFolderTag(flags.LArCalib.OFCCali.Folder)
28 acTag=tagResolver.getFolderTag(flags.LArCalib.AutoCorr.Folder)
29 del tagResolver
30
31 from IOVDbSvc.IOVDbSvcConfig import addFolders
32 result.merge(addFolders(flags,flags.LArCalib.Pedestal.Folder,detDb=flags.LArCalib.Input.Database, tag=pedestalTag, modifiers=chanSelStr(flags),
33 className="LArPedestalComplete"))
34 result.merge(addFolders(flags,flags.LArCalib.AutoCorr.Folder,detDb=flags.LArCalib.Input.Database, tag=acTag,modifiers=chanSelStr(flags)))
35
36
37 if not flags.LArCalib.isSC:
38 if flags.LArCalib.Input.isRawData:
39 result.addEventAlgo(CompFactory.LArRawDataReadingAlg(LArRawChannelKey="", LArDigitKey=digKey, LArFebHeaderKey="LArFebHeader"))
40 from LArCalibProcessing.LArCalib_CalibDigitsMakerConfig import LArCalibDigitsMakerCfg
41 result.merge(LArCalibDigitsMakerCfg(flags,digKey))
42 else:
43 result.addEventAlgo(CompFactory.LArRawCalibDataReadingAlg(LArAccCalibDigitKey=digKey,
44 LArFebHeaderKey="LArFebHeader",
45 SubCaloPreselection=flags.LArCalib.Input.SubDet,
46 PosNegPreselection=flags.LArCalib.Preselection.Side,
47 BEPreselection=flags.LArCalib.Preselection.BEC,
48 FTNumPreselection=flags.LArCalib.Preselection.FT))
49
50 from LArROD.LArFebErrorSummaryMakerConfig import LArFebErrorSummaryMakerCfg
51 result.merge(LArFebErrorSummaryMakerCfg(flags))
52 result.getEventAlgo("LArFebErrorSummaryMaker").CheckAllFEB=False
53
54 if flags.LArCalib.Input.SubDet == "EM":
55 theLArCalibShortCorrector = CompFactory.LArCalibShortCorrector(KeyList = [digKey,])
56 result.addEventAlgo(theLArCalibShortCorrector)
57
58 from LArCalibProcessing.LArStripsXtalkCorrConfig import LArStripsXtalkCorrCfg
59 result.merge(LArStripsXtalkCorrCfg(flags,[digKey,]))
60 else:
61 digKey="SC"
62 theLArLATOMEDecoder = CompFactory.LArLATOMEDecoder("LArLATOMEDecoder")
63 if flags.LArCalib.Input.isRawData:
64 result.addEventAlgo(CompFactory.LArRawSCDataReadingAlg(adcCollKey = digKey, adcBasCollKey = "", etCollKey = "",
65 etIdCollKey = "", LATOMEDecoder = theLArLATOMEDecoder))
66 from LArCalibProcessing.LArCalib_CalibDigitsMakerConfig import LArCalibDigitsMakerCfg
67 result.merge(LArCalibDigitsMakerCfg(flags,digKey))
68
69 else:
70
71 from LArCabling.LArCablingConfig import LArCalibIdMappingCfg,LArOnOffIdMappingCfg
72 result.merge(LArOnOffIdMappingCfg(flags))
73 result.merge(LArCalibIdMappingCfg(flags))
74 result.addEventAlgo(CompFactory.LArRawSCCalibDataReadingAlg(LArSCAccCalibDigitKey = digKey,
75 CalibCablingKeyLeg="LArCalibLineMap",
76 OnOffMapLeg="LArOnOffIdMap",
77 LATOMEDecoder = theLArLATOMEDecoder, ))
78
79 bcKey = "LArBadChannelSC" if flags.LArCalib.isSC else "LArBadChannel"
80
81 theLArCaliWaveBuilder = CompFactory.LArCaliWaveBuilder()
82 theLArCaliWaveBuilder.KeyList= [digKey,]
83 theLArCaliWaveBuilder.KeyOutput="LArCaliWave"
84 theLArCaliWaveBuilder.GroupingType = flags.LArCalib.GroupingType
85 theLArCaliWaveBuilder.SubtractPed = True
86 theLArCaliWaveBuilder.NSteps = flags.LArCalib.CaliWave.Nsteps
87 theLArCaliWaveBuilder.CheckEmptyPhases = not flags.LArCalib.isSC
88 theLArCaliWaveBuilder.NBaseline = 0
89 theLArCaliWaveBuilder.UseDacAndIsPulsedIndex = False
90 theLArCaliWaveBuilder.RecAllCells = False
91 theLArCaliWaveBuilder.isSC = flags.LArCalib.isSC
92 result.addEventAlgo(theLArCaliWaveBuilder)
93
94
95 if flags.LArCalib.Input.SubDet == "HEC" or flags.LArCalib.Input.SubDet == "HECFCAL":
96 theLArCaliWaveBuilder.KeyOutput="LArCaliWave_multi"
97 theLArCaliWaveSelector = CompFactory.LArCaliWaveSelector("LArCaliWaveSelector")
98 theLArCaliWaveSelector.KeyList = ["LArCaliWave_multi",]
99 theLArCaliWaveSelector.KeyOutput = "LArCaliWave"
100 theLArCaliWaveSelector.GroupingType = flags.LArCalib.GroupingType
101 if flags.LArCalib.Gain==0:
102 theLArCaliWaveSelector.SelectionList = [ "HEC/0/0/460","HEC/1/0/460","HEC/2/0/230","HEC/3/0/230" ]
103 theLArCaliWaveSelector.SelectionList += [ "FCAL/0/0/500","FCAL/1/0/500","FCAL/2/0/500","FCAL/3/0/500" ]
104
105 elif flags.LArCalib.Gain==1:
106 theLArCaliWaveSelector.SelectionList = [ "HEC/0/1/3600","HEC/1/1/3600","HEC/2/1/1800","HEC/3/1/1800"]
107 theLArCaliWaveSelector.SelectionList += [ "FCAL/0/1/5000","FCAL/1/1/5000","FCAL/2/1/5000","FCAL/3/1/5000" ]
108
109 elif flags.LArCalib.Gain==2:
110 theLArCaliWaveSelector.SelectionList = [ "HEC/0/2/24000","HEC/1/2/24000","HEC/2/2/18000","HEC/3/2/18000" ]
111 theLArCaliWaveSelector.SelectionList += [ "FCAL/0/2/40000","FCAL/1/2/40000","FCAL/2/2/40000","FCAL/3/2/40000" ]
112
113 result.addEventAlgo(theLArCaliWaveSelector)
114 pass
115
116 if flags.LArCalib.CorrectBadChannels:
117 theLArCaliWavePatcher=CompFactory.getComp("LArCalibPatchingAlg<LArCaliWaveContainer>")("LArCaliWavePatch")
118 theLArCaliWavePatcher.ContainerKey = "LArCaliWave"
119 theLArCaliWavePatcher.BadChanKey = bcKey
120 theLArCaliWavePatcher.SuperCells = flags.LArCalib.isSC
121
122 theLArCaliWavePatcher.PatchMethod = "PhiAverage"
123 if flags.LArCalib.isSC:
124 theLArCaliWavePatcher.ProblemsToPatch = [
125 "deadCalib","deadReadout","deadPhys","maskedOSUM","OffOFCs","transmissionErrorFibre",]
126 theLArCaliWavePatcher.OnOffMap="LArOnOffIdMapSC"
127 theLArCaliWavePatcher.CalibLineKey="LArCalibIdMapSC"
128 else:
129 theLArCaliWavePatcher.ProblemsToPatch = [
130 "deadCalib","deadReadout","deadPhys","almostDead","short", ]
131
132 result.addEventAlgo(theLArCaliWavePatcher)
133 pass
134
135 if flags.LArCalib.doValidation:
136
137 result.merge(addFolders(flags,flags.LArCalib.CaliWave.Folder+"<key>LArCaliWaveRef</key>","LAR_OFL"))
138
139 from LArCalibDataQuality.Thresholds import cwAmpThr,cwFWHMThr,cwAmpThrFEB,cwFWHMThrFEB
141
142 theCaliWaveValidationAlg=CompFactory.LArCaliWaveValidationAlg("CaliWaveVal")
143 if flags.LArCalib.isSC:
144 theCaliWaveValidationAlg.ProblemsToMask=["deadCalib","deadReadout","deadPhys","maskedOSUM",
145 "OffOFCs","transmissionErrorFibre",]
146 else:
147 theCaliWaveValidationAlg.ProblemsToMask=["deadReadout","deadCalib","deadPhys","almostDead",
148 "highNoiseHG","highNoiseMG","highNoiseLG"]
149 theCaliWaveValidationAlg.ValidationKey="LArCaliWave"
150 theCaliWaveValidationAlg.ReferenceKey="LArCaliWaveRef"
151 theCaliWaveValidationAlg.MsgLevelForDeviations=WARNING
152 theCaliWaveValidationAlg.ListOfDevFEBs="caliWaveFebs.txt"
153 theCaliWaveValidationAlg.AmplitudeTolerance=cwAmpThr
154 theCaliWaveValidationAlg.CaliWaveFWHMTolerance=cwFWHMThr
155 theCaliWaveValidationAlg.AmplitudeToleranceFEB=cwAmpThrFEB
156 theCaliWaveValidationAlg.CaliWaveFWHMToleranceFEB=cwFWHMThrFEB
157 theCaliWaveValidationAlg.TimeShiftDetection=True
158 theCaliWaveValidationAlg.PatchMissingFEBs=True
159 theCaliWaveValidationAlg.UseCorrChannels=False
160 theCaliWaveValidationAlg.BadChanKey = bcKey
161 theCaliWaveValidationAlg.SuperCells = flags.LArCalib.isSC
162
163 if flags.LArCalib.isSC:
164 theCaliWaveValidationAlg.CablingKey = "LArOnOffIdMapSC"
165 theCaliWaveValidationAlg.CalibLineKey = "LArCalibIdMapSC"
166
167 result.addEventAlgo(theCaliWaveValidationAlg)
168
169
170 if flags.LArCalib.doOFCCali:
171
172 LArCaliOFCAlg = CompFactory.LArOFCAlg("LArCaliOFCAlg")
173 LArCaliOFCAlg.ReadCaliWave = True
174 LArCaliOFCAlg.KeyList = [ "LArCaliWave" ]
175 LArCaliOFCAlg.Nphase = 50
176 LArCaliOFCAlg.Dphase = 1
177 LArCaliOFCAlg.Ndelay = 24
178 LArCaliOFCAlg.Nsample = 5
179 LArCaliOFCAlg.Normalize = True
180 LArCaliOFCAlg.TimeShift = False
181 LArCaliOFCAlg.TimeShiftByIndex = -1
182 LArCaliOFCAlg.Verify = True
183 LArCaliOFCAlg.FillShape = False
184
185 LArCaliOFCAlg.GroupingType = flags.LArCalib.GroupingType
186 LArCaliOFCAlg.isSC = flags.LArCalib.isSC
187 LArCaliOFCAlg.DecoderTool=CompFactory.LArAutoCorrDecoderTool(isSC=flags.LArCalib.isSC)
188 result.addEventAlgo(LArCaliOFCAlg)
189
190
191
192 rootfile=flags.LArCalib.Output.ROOTFile
193 rootfile2=flags.LArCalib.Output.ROOTFile2
194 if rootfile != "":
195 result.addEventAlgo(CompFactory.LArCaliWaves2Ntuple(KeyList = ["LArCaliWave",],
196 NtupleName = "CALIWAVE",
197 AddFEBTempInfo = False,
198 RealGeometry = True,
199 SaveDerivedInfo = True,
200 ApplyCorrection = True,
201 isSC = flags.LArCalib.isSC,
202 BadChanKey = bcKey,
203 OffId=True,
204 AddCalib=True,
205 SaveJitter=True if flags.LArCalib.CaliWave.Nsteps >= 24 else False
206 ))
207
208 import os
209 if os.path.exists(rootfile):
210 os.remove(rootfile)
211 result.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+rootfile+"' OPT='NEW'" ]))
212 result.setAppProperty("HistogramPersistency","ROOT")
213 pass
214
215 if rootfile2 != "" and flags.LArCalib.doOFCCali:
216 result.addEventAlgo(CompFactory.LArOFC2Ntuple(ContainerKey = "LArOFC",
217 AddFEBTempInfo = False,
218 NtupleFile = "FILE2",
219 BadChanKey = bcKey,
220 isSC = flags.LArCalib.isSC,
221 AddCalib=True
222 ))
223
224 import os
225 if os.path.exists(rootfile2):
226 os.remove(rootfile2)
227 if rootfile == "":
228 result.addService(CompFactory.NTupleSvc(Output = [ "FILE2 DATAFILE='"+rootfile2+"' OPT='NEW'" ]))
229 else:
230 result.getService("NTupleSvc").Output += [ "FILE2 DATAFILE='"+rootfile2+"' OPT='NEW'" ]
231 result.setAppProperty("HistogramPersistency","ROOT")
232 pass
233
234
235
236 from LArCalibProcessing.utils import FolderTagResolver
237 tagResolver=FolderTagResolver()
238 caliWaveTag=tagResolver.getFolderTag(flags.LArCalib.CaliWave.Folder)
239 caliOFCTag=tagResolver.getFolderTag(flags.LArCalib.OFCCali.Folder)
240 del tagResolver
241
242
243
244 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
245 result.merge(OutputConditionsAlgCfg(flags,
246 outputFile=flags.LArCalib.Output.POOLFile,
247 ObjectList=["LArCaliWaveContainer#LArCaliWave#"+flags.LArCalib.CaliWave.Folder,],
248 IOVTagList=[caliWaveTag,],
249 Run1=flags.LArCalib.IOVStart,
250 Run2=flags.LArCalib.IOVEnd
251 ))
252 if flags.LArCalib.doOFCCali:
253 result.getEventAlgo("OutputConditionsAlg").ObjectList += ["LArOFCComplete#LArOFC#"+flags.LArCalib.OFCCali.Folder]
254 result.getEventAlgo("OutputConditionsAlg").IOVTagList += [caliOFCTag]
255
256
257 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
258
259
260 from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
261 result.merge(PerfMonMTSvcCfg(flags))
262
263 return result
264