ATLAS Offline Software
PoolReadConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from AthenaConfiguration.Enums import ProductionStep
6 
7 
9  result = ComponentAccumulator()
10  evSel = CompFactory.EventSelectorAthenaPool("EventSelector",
11  InputCollections=flags.Input.Files,
12  SkipEvents=flags.Exec.SkipEvents)
13  if flags.Input.OverrideRunNumber:
14  if not flags.Input.RunAndLumiOverrideList:
15  DataRunNumber = -1
16  FirstLB = 1
17  InitialTimeStamp = 1
18  OldRunNumber = -1
19  if flags.Input.ConditionsRunNumber > 0:
20  # Behaviour for Digitization jobs using DataRunNumber
21  DataRunNumber = flags.Input.ConditionsRunNumber
22  FirstLB = 1
23  InitialTimeStamp = flags.IOVDb.RunToTimestampDict.get(DataRunNumber, 1) # TODO fix repeated configuration
24  if not flags.Sim.DoFullChain:
25  OldRunNumber = flags.Input.RunNumbers[0] # CHECK this should be the Run Number from the HITS file
26  elif flags.Input.RunNumbers:
27  # Behaviour for Simulation jobs
28  DataRunNumber = flags.Input.RunNumbers[0]
29  FirstLB = flags.Input.LumiBlockNumbers[0]
30  InitialTimeStamp = flags.Input.TimeStamps[0]
31  assert DataRunNumber >= 0, (
32  "flags.Input.OverrideRunNumber was True, but provided DataRunNumber (%d) is negative. "
33  "Use a real run number from data." % DataRunNumber)
34  evSel.OverrideRunNumber = flags.Input.OverrideRunNumber
35  evSel.RunNumber = DataRunNumber
36  evSel.FirstLB = FirstLB
37  evSel.InitialTimeStamp = InitialTimeStamp # Necessary to avoid a crash
38  if hasattr(evSel, "OverrideRunNumberFromInput"):
39  evSel.OverrideRunNumberFromInput = flags.Input.OverrideRunNumber
40  if OldRunNumber > 0:
41  evSel.OldRunNumber = OldRunNumber
42  elif flags.Common.ProductionStep in [ProductionStep.Simulation, ProductionStep.FastChain]:
43  # Behaviour for Simulation and FastChain jobs using RunAndLumiOverrideList
44  from AthenaKernel.EventIdOverrideConfig import getMinMaxRunNumbers, getFirstLumiBlock
45  minMax = getMinMaxRunNumbers(flags)
46  evSel.OverrideRunNumber = flags.Input.OverrideRunNumber
47  evSel.RunNumber = minMax[0]
48  evSel.FirstLB = getFirstLumiBlock(flags, minMax[0])
49  evSel.InitialTimeStamp = flags.IOVDb.RunToTimestampDict.get(minMax[0], 1) # TODO fix repeated configuration
50  if hasattr(evSel, "OverrideRunNumberFromInput"):
51  evSel.OverrideRunNumberFromInput = flags.Input.OverrideRunNumber
52  else:
53  # Behaviour for Digitization jobs using RunAndLumiOverrideList
54  pass
55  from AthenaKernel.EventIdOverrideConfig import EvtIdModifierSvcCfg
56  result.merge(EvtIdModifierSvcCfg(flags))
57  elif flags.Common.ProductionStep in [ProductionStep.Simulation] and len(flags.Input.RunNumbers) and flags.Sim.ISF.ReSimulation:
58  # ReSimulation case
59  evSel.OverrideRunNumber = True
60  evSel.RunNumber = flags.Input.RunNumbers[0]
61  if flags.Input.LumiBlockNumbers:
62  evSel.FirstLB = flags.Input.LumiBlockNumbers[0]
63  evSel.InitialTimeStamp = flags.IOVDb.RunToTimestampDict.get(flags.Input.RunNumbers[0], 1)
64 
65  result.addService(evSel)
66  return result
67 
68 
69 def PoolReadCfg(flags):
70  """
71  Creates a ComponentAccumulator instance containing the
72  athena services required for POOL file reading
73  """
74 
75  result = ComponentAccumulator()
76 
77  from AthenaPoolCnvSvc.PoolCommonConfig import AthenaPoolCnvSvcCfg, AthenaPoolAddressProviderSvcCfg
78  result.merge(AthenaPoolCnvSvcCfg(flags, InputPoolAttributes=["DatabaseName = '*'; ContainerName = 'CollectionTree'; TREE_CACHE = '-1'"]))
79 
80  if flags.Input.SecondaryFiles:
81  skipEventsPrimary = flags.Exec.SkipEvents
82  skipEventsSecondary = flags.Exec.SkipEvents
83  if flags.Overlay.SkipSecondaryEvents >= 0:
84  skipEventsSecondary = flags.Overlay.SkipSecondaryEvents
85 
86  # Create DoubleEventSelector (universal for any seconday input type)
87  evSel = CompFactory.DoubleEventSelectorAthenaPool("EventSelector",
88  InputCollections=flags.Input.Files)
89 
90  if flags.Overlay.DataOverlay:
91  # In case of data overlay HITS are primary input
92  evSel.SkipEvents = skipEventsPrimary
93 
94  # We have to check if we're running data overlay - BS is needed in this case
95  from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
96  result.merge(ByteStreamReadCfg(flags))
97 
98  # We still have to add primary address provider
99  result.merge(AthenaPoolAddressProviderSvcCfg(flags,
100  name="AthenaPoolAddressProviderSvcPrimary",
101  DataHeaderKey="EventSelector"))
102  else:
103  # In case of MC overlay RDOs are primary input
104  evSel.SkipEvents = skipEventsSecondary
105  # Do not process secondary input metadata
106  evSel.ProcessMetadata = False
107 
108  # We have primary and secondary pool inputs, create two address providers
109  result.merge(AthenaPoolAddressProviderSvcCfg(flags,
110  name="AthenaPoolAddressProviderSvcPrimary",
111  DataHeaderKey="EventSelector",
112  AttributeListKey="Input"))
113  result.merge(AthenaPoolAddressProviderSvcCfg(flags,
114  name="AthenaPoolAddressProviderSvcSecondary",
115  DataHeaderKey="SecondaryEventSelector"))
116 
117  secondarySel = CompFactory.EventSelectorAthenaPool("SecondaryEventSelector",
118  IsSecondary=True,
119  InputCollections=flags.Input.SecondaryFiles,
120  SkipEvents=skipEventsPrimary)
121  result.addService(secondarySel)
122  result.addService(evSel)
123  else:
124  # We have only primary inputs
125  result.merge(AthenaPoolAddressProviderSvcCfg(flags))
126  result.merge(EventSelectorAthenaPoolCfg(flags))
127  evSel = result.getService("EventSelector")
128 
129  #Schedule a (potential) AODFix ...
130  processingTags=flags.Input.ProcessingTags
131  if "StreamAOD" in processingTags:
132  try:
133  from RecJobTransforms.AODFixConfig import AODFixCfg
134  result.merge(AODFixCfg(flags))
135  except ImportError:
136  #Looks like running on AthSimulation or AthAnalysis ... ignore AODFix
137  pass
138 
139 
140 
141  result.setAppProperty("EvtSel", evSel.getFullJobOptName())
142 
143  return result
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.AODFixConfig.AODFixCfg
def AODFixCfg(flags)
Definition: AODFixConfig.py:11
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
python.PoolCommonConfig.AthenaPoolCnvSvcCfg
def AthenaPoolCnvSvcCfg(flags, **kwargs)
Definition: PoolCommonConfig.py:29
python.EventIdOverrideConfig.getFirstLumiBlock
def getFirstLumiBlock(flags, run)
Definition: EventIdOverrideConfig.py:89
python.EventIdOverrideConfig.EvtIdModifierSvcCfg
def EvtIdModifierSvcCfg(flags, name="EvtIdModifierSvc", **kwargs)
Definition: EventIdOverrideConfig.py:130
python.PoolReadConfig.EventSelectorAthenaPoolCfg
def EventSelectorAthenaPoolCfg(flags)
Definition: PoolReadConfig.py:8
python.EventIdOverrideConfig.getMinMaxRunNumbers
def getMinMaxRunNumbers(flags)
Definition: EventIdOverrideConfig.py:101
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
python.PoolCommonConfig.AthenaPoolAddressProviderSvcCfg
def AthenaPoolAddressProviderSvcCfg(flags, **kwargs)
Definition: PoolCommonConfig.py:39