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