ATLAS Offline Software
LArNNChannelBuilder.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentFactory import CompFactory
3 from AthenaConfiguration.Enums import LHCPeriod, ProductionStep
4 from LArRecUtils.LArADC2MeVCondAlgConfig import LArADC2MeVCondAlgCfg
5 from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
6 from LArRecUtils.LArRecUtilsConfig import LArOFCCondAlgCfg
7 from LArConfiguration.LArConfigFlags import RawChannelSource
8 
9 
10 
11 def LArNNRawChannelBuilderCfg(configFlags, name="LArNNRawChannelBuilder", **kwargs):
12 
13  acc = LArADC2MeVCondAlgCfg(configFlags)
14 
15  # the NN always requires 1 sample in the past
16  kwargs.setdefault("firstSample", (configFlags.LAr.ROD.nPreceedingSamples-1) if configFlags.LAr.ROD.nPreceedingSamples!=0 else configFlags.LAr.ROD.FirstSample)
17  obj = "AthenaAttributeList"
18  dspkey = 'Run2DSPThresholdsKey'
19  from IOVDbSvc.IOVDbSvcConfig import addFolders
20 
21  if configFlags.Input.isMC:
22  acc.merge(LArOFCCondAlgCfg(configFlags))
23  kwargs.setdefault("LArRawChannelKey", "LArRawChannels")
24 
25  if configFlags.GeoModel.Run is LHCPeriod.Run1: # back to flat threshold
26  kwargs.setdefault("useDB", False)
27  dspkey = ''
28  else:
29  fld="/LAR/NoiseOfl/DSPThresholds"
30  sgkey=fld
31  dbString="OFLP200"
32  dbInstance="LAR_OFL"
33  acc.merge(addFolders(configFlags,fld, dbInstance, className=obj, db=dbString))
34 
35  if configFlags.Common.ProductionStep is ProductionStep.PileUpPresampling:
36  kwargs.setdefault("LArDigitKey", configFlags.Overlay.BkgPrefix + "LArDigitContainer_MC")
37  else:
38  kwargs.setdefault("LArDigitKey", "LArDigitContainer_MC")
39  else:
40  acc.merge(LArElecCalibDBCfg(configFlags,("OFC","Shape","Pedestal")))
41  if configFlags.Overlay.DataOverlay:
42  kwargs.setdefault("LArDigitKey", "LArDigitContainer_MC")
43  kwargs.setdefault("LArRawChannelKey", "LArRawChannels")
44  else:
45  kwargs.setdefault("LArRawChannelKey", "LArRawChannels_FromDigits")
46 
47  if 'COMP200' in configFlags.IOVDb.DatabaseInstance:
48  fld='/LAR/Configuration/DSPThreshold/Thresholds'
49  obj='LArDSPThresholdsComplete'
50  dspkey = 'Run1DSPThresholdsKey'
51  sgkey='LArDSPThresholds'
52  dbString = 'COMP200'
53  else:
54  fld="/LAR/Configuration/DSPThresholdFlat/Thresholds"
55  sgkey=fld
56  dbString="CONDBR2"
57  dbInstance="LAR_ONL"
58  acc.merge(addFolders(configFlags,fld, dbInstance, className=obj, db=dbString))
59 
60  kwargs.setdefault(dspkey, sgkey)
61 
62  if configFlags.LAr.ROD.forceIter or configFlags.LAr.RawChannelSource is RawChannelSource.Calculated:
63  # iterative OFC procedure
64  LArRawChannelBuilderIterAlg=CompFactory.LArRawChannelBuilderIterAlg
65  kwargs.setdefault('minSample',2)
66  kwargs.setdefault('maxSample',12)
67  kwargs.setdefault('minADCforIterInSigma',4)
68  kwargs.setdefault('minADCforIter',15)
69  kwargs.setdefault('defaultPhase',12)
70  nominalPeakSample=2
71  from LArConditionsCommon.LArRunFormat import getLArFormatForRun
72  larformat=getLArFormatForRun(configFlags.Input.RunNumbers[0],connstring="COOLONL_LAR/"+configFlags.IOVDb.DatabaseInstance)
73  if larformat is not None:
74  nominalPeakSample = larformat.firstSample()
75  else:
76  print("WARNING: larformat not found, use nominalPeakSample = 2")
77  nominalPeakSample = 2
78  if (nominalPeakSample > 1) :
79  kwargs.setdefault('DefaultShiftTimeSample',nominalPeakSample-2)
80  else :
81  kwargs.setdefault('DefaultShiftTimeSample',0)
82 
83  acc.addEventAlgo(LArRawChannelBuilderIterAlg(**kwargs))
84  else:
85 
86  kwargs.setdefault('NNJsonPath', configFlags.LAr.ROD.nnJson)
87  kwargs.setdefault('NetworkOutputNode', configFlags.LAr.ROD.nnOutputNode)
88  kwargs.setdefault('NetworkInputNode', configFlags.LAr.ROD.nnInputNode)
89 
90  acc.addEventAlgo(CompFactory.LArNNRawChannelBuilder(name, **kwargs))
91 
92  return acc
python.LArElecCalibDBConfig.LArElecCalibDBCfg
def LArElecCalibDBCfg(flags, condObjs)
Definition: LArElecCalibDBConfig.py:47
python.LArRecUtilsConfig.LArOFCCondAlgCfg
def LArOFCCondAlgCfg(flags, name='LArOFCCondAlg', **kwargs)
Definition: LArRecUtilsConfig.py:33
python.LArADC2MeVCondAlgConfig.LArADC2MeVCondAlgCfg
def LArADC2MeVCondAlgCfg(flags)
Definition: LArADC2MeVCondAlgConfig.py:6
python.LArNNChannelBuilder.LArNNRawChannelBuilderCfg
def LArNNRawChannelBuilderCfg(configFlags, name="LArNNRawChannelBuilder", **kwargs)
Definition: LArNNChannelBuilder.py:11
LArRawChannelBuilderIterAlg
Definition: LArRawChannelBuilderIterAlg.h:29
LArRunFormat
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.LArRunFormat.getLArFormatForRun
def getLArFormatForRun(run, quiet=False, connstring="COOLONL_LAR/CONDBR2")
Definition: LArRunFormat.py:58