3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
8 from LArCalibProcessing.LArCalibBaseConfig
import LArCalibBaseCfg,chanSelStr
12 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
17 gainStrMap={0:
"HIGH",1:
"MEDIUM",2:
"LOW"}
18 digKey=gainStrMap[flags.LArCalib.Gain]
20 from LArCalibProcessing.utils
import FolderTagResolver
21 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
22 tagResolver=FolderTagResolver()
23 pedestalTag=tagResolver.getFolderTag(flags.LArCalib.Pedestal.Folder)
24 caliOFCTag=tagResolver.getFolderTag(flags.LArCalib.OFCCali.Folder)
26 rampTag=tagResolver.getFolderTag(flags.LArCalib.Ramp.Folder)
29 print(
"pedestalTag",pedestalTag)
30 print(
"rampTag",rampTag)
33 from IOVDbSvc.IOVDbSvcConfig
import addFolders
34 result.merge(
addFolders(flags,flags.LArCalib.Pedestal.Folder,detDb=flags.LArCalib.Input.Database, tag=pedestalTag, modifiers=
chanSelStr(flags),
35 className=
"LArPedestalComplete"))
36 result.merge(
addFolders(flags,flags.LArCalib.OFCCali.Folder,detDb=flags.LArCalib.Input.Database2, tag=caliOFCTag, modifiers=
chanSelStr(flags)))
39 if not flags.LArCalib.isSC:
40 result.addEventAlgo(CompFactory.LArRawCalibDataReadingAlg(LArAccCalibDigitKey=digKey,
41 LArFebHeaderKey=
"LArFebHeader",
42 SubCaloPreselection=flags.LArCalib.Input.SubDet,
43 PosNegPreselection=flags.LArCalib.Preselection.Side,
44 BEPreselection=flags.LArCalib.Preselection.BEC,
45 FTNumPreselection=flags.LArCalib.Preselection.FT))
47 from LArROD.LArFebErrorSummaryMakerConfig
import LArFebErrorSummaryMakerCfg
49 result.getEventAlgo(
"LArFebErrorSummaryMaker").CheckAllFEB=
False
51 if flags.LArCalib.Input.SubDet ==
"EM":
52 from LArCalibProcessing.LArStripsXtalkCorrConfig
import LArStripsXtalkCorrCfg
55 theLArCalibShortCorrector = CompFactory.LArCalibShortCorrector(KeyList = [digKey,])
56 result.addEventAlgo(theLArCalibShortCorrector)
59 theLArLATOMEDecoder = CompFactory.LArLATOMEDecoder(
"LArLATOMEDecoder")
60 if flags.LArCalib.Input.isRawData:
61 result.addEventAlgo(CompFactory.LArRawSCDataReadingAlg(adcCollKey = digKey, adcBasCollKey =
"", etCollKey =
"",
62 etIdCollKey =
"", LATOMEDecoder = theLArLATOMEDecoder))
63 from LArCalibProcessing.LArCalib_CalibDigitsMakerConfig
import LArCalibDigitsMakerCfg
68 from LArCabling.LArCablingConfig
import LArCalibIdMappingCfg,LArOnOffIdMappingCfg
72 result.addEventAlgo(CompFactory.LArRawSCCalibDataReadingAlg(LArSCAccCalibDigitKey = digKey, LATOMEDecoder = theLArLATOMEDecoder))
77 bcKey =
"LArBadChannelSC" if flags.LArCalib.isSC
else "LArBadChannel"
80 theLArRampBuilder = CompFactory.LArRampBuilder()
81 theLArRampBuilder.KeyList = [digKey,]
82 theLArRampBuilder.SubtractDac0 =
False
83 if flags.LArCalib.isSC:
84 theLArRampBuilder.ProblemsToMask=[
"deadCalib",
"deadReadout",
"deadPhys",
"maskedOSUM",
"OffOFCs",
"transmissionErrorFibre",]
86 theLArRampBuilder.ProblemsToMask=[
"deadCalib",
"deadReadout",
"deadPhys",
"almostDead",
"short"]
88 theLArRampBuilder.RecoType =
"OF"
89 theLArRampBuilder.PeakOFTool=CompFactory.LArOFPeakRecoTool(UseShape =
False,OutputLevel=2)
91 theLArRampBuilder.DAC0 = 4294967294
92 theLArRampBuilder.StoreRawRamp =
True
93 theLArRampBuilder.StoreRecRamp =
True
94 theLArRampBuilder.Polynom = 1
95 theLArRampBuilder.RampRange = 3600
96 theLArRampBuilder.correctBias =
False
98 theLArRampBuilder.minDAC = 10
99 theLArRampBuilder.KeyOutput =
"LArRamp"
100 theLArRampBuilder.DeadChannelCut = -9999
101 theLArRampBuilder.GroupingType = flags.LArCalib.GroupingType
104 theLArRampBuilder.isSC = flags.LArCalib.isSC
105 theLArRampBuilder.BadChanKey = bcKey
107 if "HEC" in flags.LArCalib.Input.SubDet:
108 theLArRampBuilder.isHEC =
True
109 theLArRampBuilder.HECKey =
"LArHEC_PAmap"
110 result.merge(
addFolders(flags,
'/LAR/ElecCalibOfl/HecPAMap',
'LAR_OFL'))
112 result.addEventAlgo(theLArRampBuilder)
116 if flags.LArCalib.CorrectBadChannels:
117 LArRampPatcher=CompFactory.getComp(
"LArCalibPatchingAlg<LArRampComplete>")
119 theLArRampPatcher.ContainerKey=
"LArRamp"
120 theLArRampPatcher.BadChanKey=bcKey
121 theLArRampPatcher.PatchMethod=
"PhiAverage"
122 theLArRampPatcher.SuperCells=flags.LArCalib.isSC
124 if flags.LArCalib.isSC:
125 theLArRampPatcher.ProblemsToPatch=[
"deadCalib",
"deadReadout",
"deadPhys",
"maskedOSUM",
"OffOFCs",
"transmissionErrorFibre"]
126 theLArRampPatcher.OnOffMap=
"LArOnOffIdMapSC"
127 theLArRampPatcher.CalibLineKey=
"LArCalibIdMapSC"
129 theLArRampPatcher.ProblemsToPatch=[
"deadCalib",
"deadReadout",
"deadPhys",
"almostDead",
"short"]
130 theLArRampPatcher.UseCorrChannels=
False
131 result.addEventAlgo(theLArRampPatcher)
134 if flags.LArCalib.doValidation:
136 if flags.LArCalib.isSC:
137 fldr=
"/LAR/ElecCalibFlatSC/Ramp"
138 rmpFlt=CompFactory.getComp(
"LArFlatConditionsAlg<LArRampSC>")(
"RampFltVal")
140 fldr=
"/LAR/ElecCalibFlat/Ramp"
141 rmpFlt=CompFactory.getComp(
"LArFlatConditionsAlg<LArRampFlat>")(
"RampFltVal")
142 result.merge(
addFolders(flags,fldr,
"LAR_ONL"))
143 condLoader=result.getCondAlgo(
"CondInputLoader")
144 condLoader.Load.add((
"CondAttrListCollection",fldr))
147 rmpFlt.WriteKey=
"LArRampRef"
148 result.addCondAlgo(rmpFlt)
150 from LArCalibDataQuality.Thresholds
import rampThr, rampThrFEB
153 theRampValidationAlg=CompFactory.LArRampValidationAlg(
"RampVal")
154 theRampValidationAlg.RampTolerance=rampThr
155 theRampValidationAlg.RampToleranceFEB=rampThrFEB
156 if flags.LArCalib.isSC:
157 theRampValidationAlg.ProblemsToMask=[
"deadCalib",
"deadReadout",
"deadPhys",
"maskedOSUM",
158 "OffOFCs",
"transmissionErrorFibre"]
160 theRampValidationAlg.ProblemsToMask=[
"deadReadout",
"deadCalib",
"deadPhys",
"almostDead",
161 "highNoiseHG",
"highNoiseMG",
"highNoiseLG"]
162 theRampValidationAlg.KeyList=[
"LArRamp"+digKey,]
163 if flags.LArCalib.isSC:
164 theRampValidationAlg.PatchMissingFEBs =
False
165 theRampValidationAlg.CheckCompletness =
False
167 theRampValidationAlg.PatchMissingFEBs=
True
168 theRampValidationAlg.UseCorrChannels=
False
169 theRampValidationAlg.ValidationKey=
"LArRamp"
170 theRampValidationAlg.ReferenceKey=
"LArRampRef"
172 theRampValidationAlg.MsgLevelForDeviations=WARNING
173 theRampValidationAlg.ListOfDevFEBs=
"rampFebs.txt"
175 theRampValidationAlg.BadChanKey = bcKey
176 theRampValidationAlg.SuperCells = flags.LArCalib.isSC
178 if flags.LArCalib.isSC:
179 theRampValidationAlg.CablingKey =
"LArOnOffIdMapSC"
180 theRampValidationAlg.CalibLineKey =
"LArCalibIdMapSC"
182 result.addEventAlgo(theRampValidationAlg)
185 from RegistrationServices.OutputConditionsAlgConfig
import OutputConditionsAlgCfg
187 outputFile=flags.LArCalib.Output.POOLFile,
188 ObjectList=[
"LArRampComplete#LArRamp#"+flags.LArCalib.Ramp.Folder,],
189 IOVTagList=[rampTag,],
190 Run1=flags.LArCalib.IOVStart,
191 Run2=flags.LArCalib.IOVEnd
195 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders =
False))
199 rootfile=flags.LArCalib.Output.ROOTFile
202 if flags.LArCalib.isSC:
205 result.addEventAlgo(CompFactory.LArRamps2Ntuple( ContainerKey = [
"LArRamp"+ntupKey],
206 AddFEBTempInfo =
False,
211 SaveAllSamples =
True,
214 isSC = flags.LArCalib.isSC
216 if flags.LArCalib.Output.SaveAverages:
217 result.addEventAlgo(CompFactory.LArAverages2Ntuple(
"LArAverages2Ntuple"+digKey,
218 ContainerKey =
"SC" if flags.LArCalib.isSC
else digKey,
220 isSC = flags.LArCalib.isSC
224 if os.path.exists(rootfile):
226 result.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+rootfile+
"' OPT='NEW'" ]))
227 result.setAppProperty(
"HistogramPersistency",
"ROOT")
231 from PerfMonComps.PerfMonCompsConfig
import PerfMonMTSvcCfg
237 if __name__ ==
"__main__":
238 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
239 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
240 from LArCalibProcessing.LArCalibConfigFlags
import addLArCalibFlags
245 ConfigFlags.LArCalib.Input.Dir =
"/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/LArCalibProcessing"
246 ConfigFlags.LArCalib.Input.Type=
"calibration_LArElec-Ramp"
247 ConfigFlags.LArCalib.Input.RunNumbers=[441252,]
248 ConfigFlags.LArCalib.Input.SubDet=
"EM"
249 ConfigFlags.Input.Files=ConfigFlags.LArCalib.Input.Files
250 ConfigFlags.LArCalib.Input.Database=
"output.sqlite"
251 ConfigFlags.LArCalib.Output.POOLFile=
"larramp.pool.root"
252 ConfigFlags.LArCalib.Output.ROOTFile=
"larramp.root"
254 ConfigFlags.IOVDb.DBConnection=
"sqlite://;schema=output.sqlite;dbname=CONDBR2"
255 ConfigFlags.IOVDb.GlobalTag=
"LARCALIB-RUN2-02"
256 ConfigFlags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
258 ConfigFlags.fillFromArgs()
260 print (
"Input files to be processed:")
261 for f
in ConfigFlags.Input.Files:
268 print(
"Start running...")
269 sys.exit(cfg.run().isFailure())