ATLAS Offline Software
Loading...
Searching...
No Matches
BunchCrossingCondAlgConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5from AthenaConfiguration.Enums import BunchStructureSource
6
7
9 result=ComponentAccumulator()
10
11 run1 = flags.IOVDb.DatabaseInstance == 'COMP200'
12 cfgsvc = None
13 folder = ''
14 bgkey = ''
15
16 if flags.Beam.BunchStructureSource == BunchStructureSource.MC:
17 # Only read digitization parameters from conditions DB if NOT ByteStream input
18 # For ByteStream input, the metadata will be read from BS metadata instead
19 from AthenaConfiguration.Enums import Format
20 # Special case: if no input files, treat as non-BS even if format defaults to BS
21 if flags.Input.Format != Format.BS or not flags.Input.Files:
22 folder = '/Digitization/Parameters'
23 from DigitizationConfig.DigitizationParametersConfig import readDigitizationParameters
24 result.merge(readDigitizationParameters(flags))
25 else:
26 # For ByteStream input, don't set folder key - will read from BS metadata
27 folder = ''
28 elif flags.Beam.BunchStructureSource == BunchStructureSource.FILLPARAMS:
29 folder = '/TDAQ/OLC/LHC/FILLPARAMS'
30 from IOVDbSvc.IOVDbSvcConfig import addFolders
31 result.merge(addFolders(flags,folder,'TDAQ',className = 'AthenaAttributeList',tag='HEAD'))
32 elif flags.Beam.BunchStructureSource == BunchStructureSource.TrigConf:
33 from TrigConfxAOD.TrigConfxAODConfig import getxAODConfigSvc
34 cfgsvc = result.getPrimaryAndMerge(getxAODConfigSvc(flags))
35 if cfgsvc.UseInFileMetadata:
36 if 'TriggerMenuJson_BG' not in flags.Input.MetadataItems:
37 # this is for when we need to configure the BunchGroupCondAlg with info extracted from converted JSON
38 # in this case avoid using the xAODConfigSvc, because it will be set up incorrectly
39 from TrigConfigSvc.TrigConfigSvcCfg import BunchGroupCondAlgCfg
40 flagsWithFile = flags.clone()
41 flagsWithFile.Trigger.triggerConfig = 'FILE'
42 flagsWithFile.lock()
43 result.merge(BunchGroupCondAlgCfg(flagsWithFile))
44 bgkey = 'L1BunchGroup'
45 else: # trust that we can use the in-file metadata
46 bgkey = ''
47 else:
48 from TrigConfigSvc.TrigConfigSvcCfg import BunchGroupCondAlgCfg
49 result.merge(BunchGroupCondAlgCfg(flags))
50 bgkey = 'L1BunchGroup'
51 elif flags.Beam.BunchStructureSource == BunchStructureSource.Lumi:
52 from .LuminosityCondAlgConfig import LuminosityCondAlgCfg
53 result.merge(LuminosityCondAlgCfg(flags))
54
55 alg = CompFactory.BunchCrossingCondAlg('BunchCrossingCondAlgDefault',
56 Run1=run1,
57 FillParamsFolderKey=folder,
58 Mode=flags.Beam.BunchStructureSource.value,
59 TrigConfigSvc=cfgsvc,
60 L1BunchGroupCondData=bgkey)
61
62 result.addCondAlgo(alg)
63
64 return result
65
66
67
68if __name__=="__main__":
69 from AthenaConfiguration.AllConfigFlags import initConfigFlags
70 flags = initConfigFlags()
71 flags.Input.Files = []
72 flags.Input.isMC=False
73 flags.IOVDb.DatabaseInstance="CONDBR2"
74 flags.IOVDb.GlobalTag="CONDBR2-BLKPA-2017-05"
75 flags.lock()
76
77 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
78 result=MainServicesCfg(flags)
79
80 from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
81 result.merge(McEventSelectorCfg(flags,
82 RunNumber=330470,
83 EventsPerRun=1,
84 FirstEvent=1183722158,
85 FirstLB=310,
86 EventsPerLB=1,
87 InitialTimeStamp=1500867637,
88 TimeStampInterval=1))
89
90 result.merge(BunchCrossingCondAlgCfg(flags))
91
92 BunchCrossingCondTest=CompFactory.BunchCrossingCondTest
93 result.addEventAlgo(BunchCrossingCondTest(FileName="BCData1.txt"))
94
95 result.run(1)
96
97 #f=open("test.pkl","wb")
98 #result.store(f)
99 #f.close()