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