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