ATLAS Offline Software
LArCalib_PedestalAutoCorrConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentFactory import CompFactory
4 
6 
7  #Get basic services and cond-algos
8  from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg
9  result=LArCalibBaseCfg(flags)
10 
11  #Add ByteStream reading
12  from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
13  result.merge(ByteStreamReadCfg(flags))
14 
15 
16  #Calibration runs are taken in fixed gain.
17  #The SG key of the digit-container is name of the gain
18  gainStrMap={0:"HIGH",1:"MEDIUM",2:"LOW"}
19 
20  if not flags.LArCalib.isSC:
21  digKey=gainStrMap[flags.LArCalib.Gain]
22  result.addEventAlgo(CompFactory.LArRawCalibDataReadingAlg(LArAccDigitKey=digKey,
23  LArFebHeaderKey="LArFebHeader",
24  FailOnCorruption=False,
25  SubCaloPreselection=flags.LArCalib.Input.SubDet,
26  PosNegPreselection=flags.LArCalib.Preselection.Side,
27  BEPreselection=flags.LArCalib.Preselection.BEC,
28  FTNumPreselection=flags.LArCalib.Preselection.FT))
29 
30  from LArROD.LArFebErrorSummaryMakerConfig import LArFebErrorSummaryMakerCfg
31  result.merge(LArFebErrorSummaryMakerCfg(flags))
32  result.getEventAlgo("LArFebErrorSummaryMaker").CheckAllFEB=False
33  result.addEventAlgo(CompFactory.LArBadEventCatcher(CheckAccCalibDigitCont=True,
34  CheckBSErrors=True,
35  KeyList=[digKey,],
36  StopOnError=False))
37 
38  else:
39  digKey="SC"
40  theLArLATOMEDecoder = CompFactory.LArLATOMEDecoder("LArLATOMEDecoder",
41  IgnoreBarrelChannels = flags.LArCalib.SCIgnoreBarrelChannels,
42  IgnoreEndcapChannels = flags.LArCalib.SCIgnoreEndcapChannels)
43 
44  if flags.LArCalib.Input.isRawData:
45  result.addEventAlgo(CompFactory.LArRawSCDataReadingAlg(adcCollKey = digKey, adcBasCollKey = "", etCollKey = "",
46  etIdCollKey = "", LATOMEDecoder = theLArLATOMEDecoder))
47  result.addEventAlgo(CompFactory.LArDigitsAccumulator("LArDigitsAccumulator", KeyList = [digKey],
48  LArAccuDigitContainerName = "", NTriggersPerStep = 100,
49  isSC = flags.LArCalib.isSC, DropPercentTrig = 0))
50  else:
51  # this needs also legacy maps
52  from LArCabling.LArCablingConfig import LArCalibIdMappingCfg,LArOnOffIdMappingCfg,LArCalibIdMappingSCCfg,LArOnOffIdMappingSCCfg
53  result.merge(LArOnOffIdMappingCfg(flags))
54  result.merge(LArCalibIdMappingSCCfg(flags))
55  result.merge(LArOnOffIdMappingSCCfg(flags))
56  result.merge(LArCalibIdMappingCfg(flags))
57 
58  result.addEventAlgo(CompFactory.LArRawSCCalibDataReadingAlg(LArSCAccDigitKey = digKey, LATOMEDecoder = theLArLATOMEDecoder))
59 
60  LArPedACBuilder=CompFactory.LArPedestalAutoCorrBuilder()
61  LArPedACBuilder.KeyList = [digKey,]
62  LArPedACBuilder.PedestalKey = "Pedestal"
63  LArPedACBuilder.AutoCorrKey = "LArAutoCorr"
64  LArPedACBuilder.GroupingType = flags.LArCalib.GroupingType
65 
66  result.addEventAlgo(LArPedACBuilder)
67 
68  #ROOT ntuple writing:
69  rootfile=flags.LArCalib.Output.ROOTFile
70  if flags.LArCalib.isSC:
71  bcKey = "LArBadChannelSC"
72  else:
73  bcKey = "LArBadChannel"
74 
75  if rootfile != "":
76  result.addEventAlgo(CompFactory.LArPedestals2Ntuple(ContainerKey = "Pedestal",
77  AddFEBTempInfo = False,
78  RealGeometry = True,
79  OffId = True,
80  AddCalib = True,
81  isSC = flags.LArCalib.isSC,
82  BadChanKey = bcKey
83  )
84  )
85 
86  result.addEventAlgo(CompFactory.LArAutoCorr2Ntuple(ContainerKey = "LArAutoCorr",
87  AddFEBTempInfo = False, isSC = flags.LArCalib.isSC,
88  BadChanKey = bcKey,
89  OffId=True,
90  AddCalib = True
91  )
92  )
93 
94  import os
95  if os.path.exists(rootfile):
96  os.remove(rootfile)
97  result.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+rootfile+"' OPT='NEW'" ]))
98  result.setAppProperty("HistogramPersistency","ROOT")
99  pass # end if ROOT ntuple writing
100 
101 
102 
103  #Get the current folder tag by interrogating the database:
104  from LArCalibProcessing.utils import FolderTagResolver
105  FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
106  tagResolver=FolderTagResolver()
107  pedestalTag=tagResolver.getFolderTag(flags.LArCalib.Pedestal.Folder)
108  autocorrTag=tagResolver.getFolderTag(flags.LArCalib.AutoCorr.Folder)
109  del tagResolver
110 
111 
112  #Output (POOL + sqlite) file writing:
113  from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
114  result.merge(OutputConditionsAlgCfg(flags,
115  outputFile=flags.LArCalib.Output.POOLFile,
116  ObjectList=["LArPedestalComplete#Pedestal#"+flags.LArCalib.Pedestal.Folder,
117  "LArAutoCorrComplete#LArAutoCorr#"+flags.LArCalib.AutoCorr.Folder],
118  IOVTagList=[pedestalTag,autocorrTag],
119  Run1=flags.LArCalib.IOVStart,
120  Run2=flags.LArCalib.IOVEnd
121  ))
122 
123  #RegistrationSvc
124  result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
125 
126 
127  #Validation (comparision with reference):
128  if flags.LArCalib.doValidation:
129  from IOVDbSvc.IOVDbSvcConfig import addFolders
130 
131  #result.merge(addFolders(flags,"/LAR/ElecCalibOnl/Pedestal<key>PedestalRef</key>","LAR_ONL"))
132  result.merge(addFolders(flags,"/LAR/ElecCalibFlat/Pedestal<key>PedestalRefIn</key>","LAR_ONL","CondAttrListCollection"))
133  LArPedestalCondAlg = CompFactory.getComp("LArFlatConditionsAlg<LArPedestalFlat>")
134  result.addCondAlgo(LArPedestalCondAlg("LArFlatPedCondAlg",ReadKey="PedestalRefIn", WriteKey="PedestalRef"))
135  from LArCalibDataQuality.Thresholds import pedThr,rmsThr, pedThrFEB,rmsThrFEB
136  from AthenaCommon.Constants import ERROR,WARNING
137 
138  thePedestalValidationAlg=CompFactory.LArPedestalValidationAlg("PedestalVal")
139  #thePedestalValidationAlg.BadChannelMaskingTool=theLArPedValBCMask
140  thePedestalValidationAlg.UseBadChannelInfo=False
141  thePedestalValidationAlg.ValidationKey="Pedestal"
142  thePedestalValidationAlg.ReferenceKey="PedestalRef"
143  thePedestalValidationAlg.PedestalTolerance=pedThr
144  thePedestalValidationAlg.PedestalRMSTolerance=rmsThr
145  thePedestalValidationAlg.PedestalToleranceFEB=pedThrFEB
146  thePedestalValidationAlg.PedestalRMSToleranceFEB=rmsThrFEB
147  thePedestalValidationAlg.MsgLevelForDeviations=WARNING
148  thePedestalValidationAlg.ListOfDevFEBs="pedFebs.txt"
149  thePedestalValidationAlg.CheckCompletness=True
150  thePedestalValidationAlg.PatchMissingFEBs=True
151  thePedestalValidationAlg.UseCorrChannels=False #Corrections go into the regular data channels
152  if flags.LArCalib.isSC:
153  thePedestalValidationAlg.CablingKey = "LArOnOffIdMapSC"
154  thePedestalValidationAlg.CalibLineKey = "LArCalibIdMapSC"
155  thePedestalValidationAlg.BadChanKey = bcKey
156  result.addEventAlgo(thePedestalValidationAlg)
157 
158 
159  theBadPedestal=CompFactory.LArPedestalValidationAlg("PedestalFail")
160  #theBadPedestal.BadChannelMaskingTool=theLArPedValBCMask
161  theBadPedestal.UseBadChannelInfo=False
162  theBadPedestal.ValidationKey="Pedestal"
163  theBadPedestal.ReferenceKey="PedestalRef"
164  theBadPedestal.PedestalTolerance = ["10,10,10"]
165  theBadPedestal.PedestalRMSTolerance = ["0.5, 0.5, 0.5"]
166  theBadPedestal.PedestalToleranceFEB = ["8, 8, 8"]
167  theBadPedestal.PedestalRMSToleranceFEB = ["1.2, 1.2, 1.2"]
168 
169  theBadPedestal.MsgLevelForDeviations=ERROR
170  theBadPedestal.CheckCompletness=False
171  theBadPedestal.ListOfDevFEBs="Bad_pedFebs.txt"
172  if flags.LArCalib.isSC:
173  theBadPedestal.CablingKey = "LArOnOffIdMapSC"
174  theBadPedestal.CalibLineKey = "LArCalibIdMapSC"
175  theBadPedestal.BadChanKey = bcKey
176  result.addEventAlgo(theBadPedestal)
177 
178 
179  result.merge(addFolders(flags,"/LAR/ElecCalibOfl/AutoCorrs/AutoCorr<key>LArAutoCorrRef</key>","LAR_OFL"))
180  from LArCalibDataQuality.Thresholds import acThr, acThrFEB
181  theAutoCorrValidationAlg=CompFactory.LArAutoCorrValidationAlg("AutoCorrVal")
182  theAutoCorrValidationAlg.UseBadChannelInfo=False
183  theAutoCorrValidationAlg.ValidationKey="LArAutoCorr"
184  theAutoCorrValidationAlg.ReferenceKey="LArAutoCorrRef"
185  theAutoCorrValidationAlg.AutoCorrTolerance=acThr
186  theAutoCorrValidationAlg.AutoCorrToleranceFEB=acThrFEB
187  theAutoCorrValidationAlg.MsgLevelForDeviations=WARNING
188  theAutoCorrValidationAlg.ListOfDevFEBs="ACFebs.txt"
189  theAutoCorrValidationAlg.CheckCompletness=True
190  theAutoCorrValidationAlg.PatchMissingFEBs=True
191  theAutoCorrValidationAlg.UseCorrChannels=False #Corrections go into the regular data channels
192  if flags.LArCalib.isSC:
193  theAutoCorrValidationAlg.CablingKey = "LArOnOffIdMapSC"
194  theAutoCorrValidationAlg.CalibLineKey = "LArCalibIdMapSC"
195  theAutoCorrValidationAlg.BadChanKey = bcKey
196  result.addEventAlgo(theAutoCorrValidationAlg)
197 
198 
199  theBadAutoCorr=CompFactory.LArAutoCorrValidationAlg("AutoCorrFail")
200  theBadAutoCorr.UseBadChannelInfo=False
201  theBadAutoCorr.ValidationKey="LArAutoCorr"
202  theBadAutoCorr.ReferenceKey="LArAutoCorrRef"
203  theBadAutoCorr.AutoCorrTolerance = ["0.15, 0.15, 0.15"]
204  theBadAutoCorr.AutoCorrToleranceFEB = ["0.15, 0.15, 0.15"]
205  theBadAutoCorr.MsgLevelForDeviations=ERROR
206  theBadAutoCorr.CheckFifthSample=True
207  theBadAutoCorr.ListOfDevFEBs="Bad_ACFebs.txt"
208  theBadAutoCorr.CheckCompletness=False
209  if flags.LArCalib.isSC:
210  theBadAutoCorr.CablingKey = "LArOnOffIdMapSC"
211  theBadAutoCorr.CalibLineKey = "LArCalibIdMapSC"
212  theBadAutoCorr.BadChanKey = bcKey
213  result.addEventAlgo(theBadAutoCorr)
214 
215  result.getService("IOVDbSvc").DBInstance=""
216 
217  from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
218  result.merge(PerfMonMTSvcCfg(flags))
219 
220 
221  return result
222 
223 
224 if __name__ == "__main__":
225 
226  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
227  from AthenaConfiguration.AllConfigFlags import initConfigFlags
228  from AthenaConfiguration.TestDefaults import defaultGeometryTags
229  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
230  import sys
231  ConfigFlags=initConfigFlags()
232  addLArCalibFlags(ConfigFlags)
233 
234  ConfigFlags.LArCalib.Input.Dir = "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/LArCalibProcessing"
235 
236  ConfigFlags.LArCalib.Input.Type="calibration_LArElec-Pedestal"
237  ConfigFlags.LArCalib.Input.RunNumbers=[441236,]
238 
239  ConfigFlags.Input.Files=ConfigFlags.LArCalib.Input.Files
240 
241  ConfigFlags.LArCalib.Output.ROOTFile="larpededest.root"
242  ConfigFlags.LArCalib.Output.POOLFile="larpedestal.pool.root"
243  ConfigFlags.IOVDb.DBConnection="sqlite://;schema=output.sqlite;dbname=CONDBR2"
244  ConfigFlags.IOVDb.GlobalTag="LARCALIB-RUN2-00"
245  ConfigFlags.IOVDb.DatabaseInstance="CONDBR2"
246  ConfigFlags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
247 
248  ConfigFlags.fillFromArgs()
249  ConfigFlags.lock()
250 
251  from AthenaCommon import Logging
252  log = Logging.logging.getLogger( 'Athena' )
253  log.info("Input files to be processed:")
254  for f in ConfigFlags.Input.Files:
255  log.info(f)
256 
257  cfg=MainServicesCfg(ConfigFlags)
258  cfg.merge(LArPedestalAutoCorrCfg(ConfigFlags))
259 
260  log.info("Start running...")
261  sys.exit(cfg.run().isFailure())
262 
LArCablingConfig.LArOnOffIdMappingSCCfg
def LArOnOffIdMappingSCCfg(configFlags)
Definition: LArCablingConfig.py:65
python.LArElecCalibDBConfig.LArPedestalCondAlg
LArPedestalCondAlg
Definition: LArElecCalibDBConfig.py:26
OutputConditionsAlgConfig.OutputConditionsAlgCfg
def OutputConditionsAlgCfg(flags, name="OutputConditionsAlg", outputFile='condobjs.root', **kwargs)
Definition: OutputConditionsAlgConfig.py:5
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
python.PerfMonCompsConfig.PerfMonMTSvcCfg
def PerfMonMTSvcCfg(flags, **kwargs)
A minimal new-style configuration for PerfMonMTSvc.
Definition: PerfMonCompsConfig.py:10
python.LArFebErrorSummaryMakerConfig.LArFebErrorSummaryMakerCfg
def LArFebErrorSummaryMakerCfg(flags)
Definition: LArFebErrorSummaryMakerConfig.py:7
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:252
Constants
some useful constants -------------------------------------------------—
python.LArCalib_PedestalAutoCorrConfig.LArPedestalAutoCorrCfg
def LArPedestalAutoCorrCfg(flags)
Definition: LArCalib_PedestalAutoCorrConfig.py:5
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
python.LArCalibBaseConfig.LArCalibBaseCfg
def LArCalibBaseCfg(flags)
Definition: LArCalibBaseConfig.py:5
LArCablingConfig.LArCalibIdMappingSCCfg
def LArCalibIdMappingSCCfg(configFlags)
Definition: LArCablingConfig.py:86
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3
LArCablingConfig.LArCalibIdMappingCfg
def LArCalibIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:83