ATLAS Offline Software
TileTestBeamRecoConfig.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 '''
6 @file TileTestBeamRecoConfig.py
7 '''
8 
9 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10 from AthenaConfiguration.ComponentFactory import CompFactory
11 
12 import sys
13 
14 
15 def TileTestBeamRawChannelMakerCfg(flags, nsamples, useFELIX=False, **kwargs):
16 
17  ''' Function to configure reconstruction of Tile raw channels from digits.'''
18 
19  acc = ComponentAccumulator()
20 
21  suffix = "Flx" if useFELIX else ""
22  kwargs.setdefault('name', f'TileRCh{suffix}Maker')
23  kwargs.setdefault('TileDigitsContainer', f'TileDigits{suffix}Cnt')
24  kwargs.setdefault('Cardinality', flags.Concurrency.NumThreads)
25  kwargs.setdefault('TileInfoName', f'TileInfo{suffix}')
26 
27  from TileRecUtils.TileRawChannelMakerConfig import TileRawChannelMakerCfg
28  rawChMaker = acc.getPrimaryAndMerge(TileRawChannelMakerCfg(flags, **kwargs))
29  if flags.Tile.doFit:
30  rawChannelBuilderFitFilter = rawChMaker.TileRawChannelBuilder['TileRawChannelBuilderFitFilter']
31  rawChannelBuilderFitFilter.FrameLength = nsamples
32  rawChannelBuilderFitFilter.SaturatedSample = 4095 if useFELIX else -1
33  for tool in rawChMaker.TileRawChannelBuilder:
34  tool.TileRawChannelContainer = str(tool.TileRawChannelContainer).replace('TileRawChannel', f'TileRawChannel{suffix}')
35  tool.TileInfoName = f'TileInfo{suffix}'
36 
37  # Configure TileInfoLoader to set up number of samples
38  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
39  acc.merge(TileInfoLoaderCfg(flags, name=f'TileInfoLoader{suffix}', TileInfo=f'TileInfo{suffix}',
40  NSamples=nsamples, TrigSample=((nsamples-1)//2) ))
41 
42  return acc
43 
44 
45 def TileTestBeamRecoCfg(flags, useDemoCabling, nsamples, useFELIX=False, filterDigits=False, filterChannels=True):
46 
47  ''' Function to configure reconstruction of Tile TestBeam data.'''
48 
49  acc = ComponentAccumulator()
50 
51  suffix = "Flx" if useFELIX else ""
52  digitsContainer = f'TileDigits{suffix}Cnt'
53  rawChannelContainer = flags.Tile.RawChannelContainer.replace('TileRawChannel', f'TileRawChannel{suffix}')
54 
55  # =====> For FELIX configure the algorithm to select one gain
56  if useFELIX and filterDigits:
57  digitsContainer = 'TileDigitsFlxFiltered'
58  TileDigitsGainFilter = CompFactory.TileDigitsGainFilter
59  acc.addEventAlgo( TileDigitsGainFilter(HighGainThreshold=4095,
60  InputDigitsContainer='TileDigitsFlxCnt',
61  OutputDigitsContainer=digitsContainer) )
62 
63  # =====> Configure reconstruction of Tile raw channels from digits
64  acc.merge(TileTestBeamRawChannelMakerCfg(flags, nsamples, useFELIX, TileDigitsContainer=digitsContainer))
65 
66  if useFELIX and filterChannels:
67  rawChannelContainerFiltered = f'{rawChannelContainer}Filtered'
68  TileRawChannelGainFilter = CompFactory.TileRawChannelGainFilter
69  acc.addEventAlgo( TileRawChannelGainFilter(InputRawChannelContainer=rawChannelContainer,
70  OutputRawChannelContainer=rawChannelContainerFiltered) )
71  rawChannelContainer = rawChannelContainerFiltered
72 
73  # =====> Configure reconstruction of Tile cells from raw channels
74  from TileRecUtils.TileCellMakerConfig import TileCellMakerCfg
75  skipGains = [0, 1] if flags.Tile.RunType.isBiGain() else [-1]
76  gainName = {-1 : "", 0 : "HG", 1 : "LG"} # Skip gain to actually used gain name mapping
77  for skipGain in skipGains:
78  cellMaker = acc.getPrimaryAndMerge(TileCellMakerCfg(flags, name=f'TileCell{suffix}Maker{gainName[skipGain]}',
79  CaloCellsOutputName=f'AllCalo{suffix}{gainName[skipGain]}',
80  mergeChannels=False, SkipGain=skipGain))
81  cellBuilder = cellMaker.CaloCellMakerToolNames['TileCellBuilder']
82  cellBuilder.TileRawChannelContainer = rawChannelContainer
83  cellBuilder.UseDemoCabling = useDemoCabling
84  cellBuilder.maskBadChannels = False
85  cellBuilder.MBTSContainer = ""
86  cellBuilder.E4prContainer = ""
87 
88 
89  # Configure TileInfoLoader to set up number of samples
90  ADCmax = 4095 if useFELIX else 1023
91  ADCmaskValue = 4800 if useFELIX else 2047
92  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
93  acc.merge(TileInfoLoaderCfg(flags, name=f'TileInfoLoader{suffix}', TileInfo=f'TileInfo{suffix}',
94  NSamples=nsamples, TrigSample=((nsamples-1)//2),
95  ADCmax=ADCmax, ADCmaskValue=ADCmaskValue))
96 
97  return acc
98 
99 
100 if __name__ == '__main__':
101 
102  # Setup logs
103  from AthenaCommon.Logging import log
104  from AthenaCommon.Constants import INFO
105  log.setLevel(INFO)
106 
107  # Set the Athena configuration flags
108  from AthenaConfiguration.AllConfigFlags import initConfigFlags
109  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
110 
111  flags = initConfigFlags()
112  parser = flags.getArgumentParser()
113  parser.add_argument('--demo-cabling', dest='demoCabling', type=int, default=2018, help='Time Demonatrator cabling to be used')
114  parser.add_argument('--nsamples', type=int, default=15, help='Number of samples')
115  args, _ = parser.parse_known_args()
116 
117  flags.Exec.MaxEvents = 3
118  flags.Common.isOnline = True
119  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
120  flags.Input.Files = defaultTestFiles.RAW_RUN3
121  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN3_DATA
122 
123  flags.Tile.doFit = True
124  flags.Tile.useDCS = False
125  flags.Tile.NoiseFilter = 0
126  flags.Tile.correctTime = False
127  flags.Tile.correctTimeJumps = False
128  flags.Tile.BestPhaseFromCOOL = False
129  flags.Tile.doOverflowFit = False
130 
131  flags.fillFromArgs(parser=parser)
132  flags.lock()
133 
134  flags.dump()
135 
136  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
137  cfg = MainServicesCfg(flags)
138 
139  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
140  cfg.merge( TileRawDataReadingCfg(flags, readMuRcv=False,
141  readDigits=True,
142  readRawChannel=True,
143  readDigitsFlx=True,
144  readBeamElem=True) )
145 
146  cfg.merge( TileTestBeamRecoCfg(flags, useDemoCabling=args.demoCabling, nsamples=args.nsamples) )
147  cfg.merge( TileTestBeamRecoCfg(flags, useDemoCabling=args.demoCabling, nsamples=16, useFELIX=True) )
148 
149  # Scan first event for all fragments to create proper ROD to ROB map
150  cfg.getCondAlgo('TileHid2RESrcIDCondAlg').RODStatusProxy = None
151 
152  cfg.printConfig(withDetails=True, summariseProps=True, printDefaults=True)
153 
154  sc = cfg.run()
155  # Success should be 0
156  sys.exit(not sc.isSuccess())
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
TileDigitsGainFilter
This algorithm copies TileDigits from input container to output container.
Definition: TileDigitsGainFilter.h:40
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
TileCellMakerConfig.TileCellMakerCfg
def TileCellMakerCfg(flags, mergeChannels=True, **kwargs)
Definition: TileCellMakerConfig.py:32
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
TileTestBeamRecoConfig.TileTestBeamRawChannelMakerCfg
def TileTestBeamRawChannelMakerCfg(flags, nsamples, useFELIX=False, **kwargs)
Definition: TileTestBeamRecoConfig.py:15
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileByteStreamConfig.TileRawDataReadingCfg
def TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True, readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False, readBeamElem=None, readLaserObj=None, readDigitsFlx=False, readL2=False, stateless=False, **kwargs)
Definition: TileByteStreamConfig.py:87
TileRawChannelMakerConfig.TileRawChannelMakerCfg
def TileRawChannelMakerCfg(flags, **kwargs)
Definition: TileRawChannelMakerConfig.py:10
TileTestBeamRecoConfig.TileTestBeamRecoCfg
def TileTestBeamRecoCfg(flags, useDemoCabling, nsamples, useFELIX=False, filterDigits=False, filterChannels=True)
Definition: TileTestBeamRecoConfig.py:45
str
Definition: BTagTrackIpAccessor.cxx:11
TileRawChannelGainFilter
This algorithm copies TileRawChannel from input container to output container.
Definition: TileRawChannelGainFilter.h:20