3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
9 from LArCalibProcessing.LArCalibBaseConfig
import LArCalibBaseCfg,chanSelStr
13 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
18 gainStrMap={0:
"HIGH",1:
"MEDIUM",2:
"LOW"}
19 digKey=gainStrMap[flags.LArCalib.Gain]
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)
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)))
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
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))
49 from LArROD.LArFebErrorSummaryMakerConfig
import LArFebErrorSummaryMakerCfg
51 result.getEventAlgo(
"LArFebErrorSummaryMaker").CheckAllFEB=
False
53 if flags.LArCalib.Input.SubDet ==
"EM":
54 theLArCalibShortCorrector = CompFactory.LArCalibShortCorrector(KeyList = [digKey,])
55 result.addEventAlgo(theLArCalibShortCorrector)
57 from LArCalibProcessing.LArStripsXtalkCorrConfig
import LArStripsXtalkCorrCfg
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
70 from LArCabling.LArCablingConfig
import LArCalibIdMappingCfg,LArOnOffIdMappingCfg
73 result.addEventAlgo(CompFactory.LArRawSCCalibDataReadingAlg(LArSCAccCalibDigitKey = digKey,
74 CalibCablingKeyLeg=
"LArCalibLineMap",
75 OnOffMapLeg=
"LArOnOffIdMap",
76 LATOMEDecoder = theLArLATOMEDecoder, ))
78 bcKey =
"LArBadChannelSC" if flags.LArCalib.isSC
else "LArBadChannel"
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)
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" ]
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" ]
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" ]
112 result.addEventAlgo(theLArCaliWaveSelector)
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
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"
128 theLArCaliWavePatcher.ProblemsToPatch = [
129 "deadCalib",
"deadReadout",
"deadPhys",
"almostDead",
"short", ]
131 result.addEventAlgo(theLArCaliWavePatcher)
134 if flags.LArCalib.doValidation:
136 result.merge(
addFolders(flags,flags.LArCalib.CaliWave.Folder+
"<key>LArCaliWaveRef</key>",
"LAR_OFL"))
138 from LArCalibDataQuality.Thresholds
import cwAmpThr,cwFWHMThr,cwAmpThrFEB,cwFWHMThrFEB
141 theCaliWaveValidationAlg=CompFactory.LArCaliWaveValidationAlg(
"CaliWaveVal")
142 if flags.LArCalib.isSC:
143 theCaliWaveValidationAlg.ProblemsToMask=[
"deadCalib",
"deadReadout",
"deadPhys",
"maskedOSUM",
144 "OffOFCs",
"transmissionErrorFibre",]
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
162 if flags.LArCalib.isSC:
163 theCaliWaveValidationAlg.CablingKey =
"LArOnOffIdMapSC"
164 theCaliWaveValidationAlg.CalibLineKey =
"LArCalibIdMapSC"
166 result.addEventAlgo(theCaliWaveValidationAlg)
169 if flags.LArCalib.doOFCCali:
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
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)
191 rootfile=flags.LArCalib.Output.ROOTFile
192 rootfile2=flags.LArCalib.Output.ROOTFile2
194 result.addEventAlgo(CompFactory.LArCaliWaves2Ntuple(KeyList = [
"LArCaliWave",],
195 NtupleName =
"CALIWAVE",
196 AddFEBTempInfo =
False,
198 SaveDerivedInfo =
True,
199 ApplyCorrection =
True,
200 isSC = flags.LArCalib.isSC,
204 SaveJitter=
True if flags.LArCalib.CaliWave.Nsteps >= 24
else False
207 if rootfile2 ==
"" and flags.LArCalib.OFCCali:
208 result.addEventAlgo(CompFactory.LArOFC2Ntuple(ContainerKey =
"LArOFC",
209 AddFEBTempInfo =
False,
211 isSC = flags.LArCalib.isSC,
217 if os.path.exists(rootfile):
219 result.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+rootfile+
"' OPT='NEW'" ]))
220 result.setAppProperty(
"HistogramPersistency",
"ROOT")
223 if rootfile2 !=
"" and flags.LArCalib.doOFCCali:
224 result.addEventAlgo(CompFactory.LArOFC2Ntuple(ContainerKey =
"LArOFC",
225 AddFEBTempInfo =
False,
226 NtupleFile =
"FILE2",
228 isSC = flags.LArCalib.isSC,
233 if os.path.exists(rootfile2):
236 result.addService(CompFactory.NTupleSvc(Output = [
"FILE2 DATAFILE='"+rootfile2+
"' OPT='NEW'" ]))
238 result.getService(
"NTupleSvc").Output += [
"FILE2 DATAFILE='"+rootfile2+
"' OPT='NEW'" ]
239 result.setAppProperty(
"HistogramPersistency",
"ROOT")
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)
252 from RegistrationServices.OutputConditionsAlgConfig
import OutputConditionsAlgCfg
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
260 if flags.LArCalib.doOFCCali:
261 result.getEventAlgo(
"OutputConditionsAlg").ObjectList += [
"LArOFCComplete#LArOFC#"+flags.LArCalib.OFCCali.Folder]
262 result.getEventAlgo(
"OutputConditionsAlg").IOVTagList += [caliOFCTag]
265 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders =
False))
268 from PerfMonComps.PerfMonCompsConfig
import PerfMonMTSvcCfg
276 from LArCalibProcessing.LArCalibBaseConfig
import LArCalibBaseCfg
279 bcKey =
"LArBadChannelSC" if flags.LArCalib.isSC
else "LArBadChannel"
282 from EventSelectorAthenaPool.CondProxyProviderConfig
import CondProxyProviderCfg
283 result.merge (CondProxyProviderCfg (flags, flags.LArCalib.Input.Files))
286 rootfile=flags.LArCalib.Output.ROOTFile
287 rootfile2=flags.LArCalib.Output.ROOTFile2
289 result.addEventAlgo(CompFactory.LArCaliWaves2Ntuple(KeyList = [
"CaliWave",]
if flags.LArCalib.isSC
else [
"LArCaliWave",],
290 NtupleName =
"CALIWAVE",
291 AddFEBTempInfo =
False,
292 SaveDerivedInfo =
True,
293 ApplyCorrection =
True,
296 SaveJitter=
True if flags.LArCalib.CaliWave.Nsteps >= 24
else False,
297 isSC=flags.LArCalib.isSC
301 result.addEventAlgo(CompFactory.LArOFC2Ntuple(ContainerKey =
"LArOFC",
302 AddFEBTempInfo =
False,
305 isSC=flags.LArCalib.isSC
309 if os.path.exists(rootfile):
311 result.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+rootfile+
"' OPT='NEW'" ]))
312 result.setAppProperty(
"HistogramPersistency",
"ROOT")
315 if rootfile == rootfile2:
316 result.addEventAlgo(CompFactory.LArOFC2Ntuple(ContainerKey =
"LArOFC",
317 AddFEBTempInfo =
False,
318 NtupleFile =
"FILE1",
321 isSC=flags.LArCalib.isSC
324 result.addEventAlgo(CompFactory.LArOFC2Ntuple(ContainerKey =
"LArOFC",
325 AddFEBTempInfo =
False,
326 NtupleFile =
"FILE2",
329 isSC=flags.LArCalib.isSC
333 if os.path.exists(rootfile2):
336 result.addService(CompFactory.NTupleSvc(Output = [
"FILE2 DATAFILE='"+rootfile2+
"' OPT='NEW'" ]))
338 result.getService(
"NTupleSvc").Output += [
"FILE2 DATAFILE='"+rootfile2+
"' OPT='NEW'" ]
339 result.setAppProperty(
"HistogramPersistency",
"ROOT")
345 if __name__ ==
"__main__":
346 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
347 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
348 from LArCalibProcessing.LArCalibConfigFlags
import addLArCalibFlags
353 ConfigFlags.LArCalib.Input.Dir =
"/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/LArCalibProcessing"
354 ConfigFlags.LArCalib.Input.Type=
"calibration_LArElec-Delay"
355 ConfigFlags.LArCalib.Input.RunNumbers=[441251,]
356 ConfigFlags.LArCalib.Input.Database=
"output.sqlite"
357 ConfigFlags.Input.Files=ConfigFlags.LArCalib.Input.Files
360 ConfigFlags.LArCalib.Output.ROOTFile=
"ofccali.root"
361 ConfigFlags.LArCalib.Output.POOLFile=
"ofccali.pool.root"
363 ConfigFlags.IOVDb.DBConnection=
"sqlite://;schema=output.sqlite;dbname=CONDBR2"
364 ConfigFlags.IOVDb.GlobalTag=
"LARCALIB-RUN2-02"
365 ConfigFlags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
368 ConfigFlags.fillFromArgs()
369 print (
"Input files to be processed:")
370 for f
in ConfigFlags.Input.Files:
376 print(
"Start running...")
377 sys.exit(cfg.run().isFailure())