ATLAS Offline Software
AFPRecConfig.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4 
5 # file AFPRecConfig.py
6 # author Petr Balek <petr.balek@cern.ch>
7 # date 2022-03-31
8 
9 # brief A script that provides setup for AFP reconstruction included in RecJobTransforms/RecoSteering.py.
10 # It also allows to run standalone AFP reconstruction. To use it:
11 # 0. setup athena enviroment
12 # 1a. run this script:
13 # $ python AFPRecConfig.py
14 # 1b. feel free to change the input file:
15 # $ python AFPRecConfig.py --filesInput=/afs/cern.ch/user/p/pbalek/workspace/public/data17_13TeV.00338480.physics_Main.daq.RAW/data17_13TeV.00338480.physics_Main.daq.RAW._lb0275._SFO-7._0007.data
16 # 1c. run the whole reconstruction with:
17 # $ RecoSteeringTest.py --filesInput=/afs/cern.ch/user/p/pbalek/workspace/public/data17_13TeV.00338480.physics_Main.daq.RAW/data17_13TeV.00338480.physics_Main.daq.RAW._lb0275._SFO-7._0007.data --RAW
18 
19 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
20 from AthenaConfiguration.Enums import Format
21 
22 def AFPRecOutputCfg(flags):
23  """defines outputs for ESD and AOD; provides the same information as in ForwardRec/AFP_Rec_OutputItemList_jobOptions.py"""
24  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
25  acc = ComponentAccumulator()
26 
27  AFP_ItemList=[]
28 
29  if flags.Input.Format is Format.BS:
30  # AFP Silicon hits containers
31  AFP_ItemList.append("xAOD::AFPSiHitContainer#AFPSiHitContainer")
32  AFP_ItemList.append("xAOD::AFPSiHitAuxContainer#AFPSiHitContainerAux.")
33  AFP_ItemList.append("xAOD::AFPSiHitsClusterContainer#AFPSiHitsClusterContainer")
34  AFP_ItemList.append("xAOD::AFPSiHitsClusterAuxContainer#AFPSiHitsClusterContainerAux.")
35 
36  # for runs with more BCX ids i.e. before timing in the detectors
37  for bcIDshift in range (1, 6):
38  name = "AFPSiHitContainerBcIDplus" + str(bcIDshift)
39  AFP_ItemList.append("xAOD::AFPSiHitContainer#" + name)
40  AFP_ItemList.append("xAOD::AFPSiHitAuxContainer#" + name + "Aux.")
41 
42  AFP_ItemList.append("xAOD::AFPTrackContainer#AFPTrackContainer")
43  AFP_ItemList.append("xAOD::AFPTrackAuxContainer#AFPTrackContainerAux.")
44  AFP_ItemList.append("xAOD::AFPToFHitContainer#AFPToFHitContainer")
45  AFP_ItemList.append("xAOD::AFPToFHitAuxContainer#AFPToFHitContainerAux.")
46  AFP_ItemList.append("xAOD::AFPProtonContainer#AFPProtonContainer")
47  AFP_ItemList.append("xAOD::AFPProtonAuxContainer#AFPProtonContainerAux.")
48  AFP_ItemList.append("xAOD::AFPToFTrackContainer#AFPToFTrackContainer")
49  AFP_ItemList.append("xAOD::AFPToFTrackAuxContainer#AFPToFTrackContainerAux.")
50  AFP_ItemList.append("xAOD::AFPVertexContainer#AFPVertexContainer")
51  AFP_ItemList.append("xAOD::AFPVertexAuxContainer#AFPVertexContainerAux.")
52 
53 
54  if flags.Output.doWriteESD:
55  acc.merge(OutputStreamCfg(flags, "ESD", AFP_ItemList))
56  if flags.Output.doWriteAOD:
57  acc.merge(OutputStreamCfg(flags, "AOD", AFP_ItemList))
58  return acc
59 
60 
61 def AFPRecCfg(flags):
62  """defines AFP reconstruction; provides the same setup as used to be in ForwardRec/ForwardRec_jobOptions.py"""
63  acc = ComponentAccumulator()
64 
65  if flags.Input.Format is Format.BS:
66  from AthenaConfiguration.ComponentFactory import CompFactory
67 
68  acc.addEventAlgo(CompFactory.AFP_RawDataProvider("AFP_RawDataProvider"))
69  acc.addEventAlgo(CompFactory.AFP_Raw2Digi("AFP_Raw2Digi"))
70 
71  #cluster reconstruction
72  from AFP_SiClusterTools.AFP_SiClusterTools import AFP_SiClusterTools_Cfg
73  acc.merge(AFP_SiClusterTools_Cfg(flags))
74 
75  # tracks reconstruction
76  from AFP_LocReco.AFP_LocReco import AFP_LocReco_SiD_Cfg, AFP_LocReco_TD_Cfg
77  acc.merge(AFP_LocReco_SiD_Cfg(flags))
78  acc.merge(AFP_LocReco_TD_Cfg(flags))
79 
80  # protons reconstruction
81  from AFP_GlobReco.AFP_GlobReco import AFP_GlobReco_Cfg
82  acc.merge(AFP_GlobReco_Cfg(flags))
83 
84  # vertex reconstruction
85  from AFP_VertexReco.AFP_VertexReco import AFP_VertexReco_Cfg
86  acc.merge(AFP_VertexReco_Cfg(flags))
87 
88  # Setup output
89  if flags.Output.doWriteESD or flags.Output.doWriteAOD:
90  acc.merge(AFPRecOutputCfg(flags))
91 
92  return acc
93 
94 
95 if __name__ == "__main__":
96 
97  from AthenaConfiguration.AllConfigFlags import initConfigFlags
98  flags = initConfigFlags()
99  flags.Scheduler.CheckDependencies = True
100  flags.Scheduler.ShowDataDeps = True
101  flags.Scheduler.ShowDataFlow = True
102  flags.Scheduler.ShowControlFlow = True
103  flags.Scheduler.EnableVerboseViews = True
104 
105  flags.Input.Files = ["/afs/cern.ch/work/p/pbalek/public/data17_13TeV.00338480.physics_Main.daq.RAW/data17_13TeV.00338480.physics_Main.daq.RAW._lb0275._SFO-7._0007.data"]
106 
107  flags.Output.doWriteAOD = True
108  flags.Output.AODFileName = "AOD.pool.root"
109  flags.Exec.MaxEvents = 500
110  flags.Concurrency.NumThreads = 4
111 
112  flags.fillFromArgs() # enable unit tests to switch only parts of reco: python -m HIRecConfig.HIRecConfig HeavyIon.doGlobal = 0 and so on
113  flags.lock()
114  flags.dump()
115 
116  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
117  acc = MainServicesCfg(flags)
118 
119  from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
120  acc.merge(ByteStreamReadCfg(flags))
121 
122  acc.merge(AFPRecCfg(flags))
123 
124  from AthenaCommon.Constants import DEBUG
125  acc.foreach_component("*AFP*").OutputLevel=DEBUG
126 
127  acc.printConfig(withDetails=True, summariseProps=True)
128 
129  status = acc.run()
130  if status.isFailure():
131  import sys
132  sys.exit(-1)
133 
AFP_VertexReco.AFP_VertexReco_Cfg
def AFP_VertexReco_Cfg(flags, kwargs={})
Definition: AFP_VertexReco.py:13
AFPRecConfig.AFPRecCfg
def AFPRecCfg(flags)
Definition: AFPRecConfig.py:61
AFP_GlobReco.AFP_GlobReco_Cfg
def AFP_GlobReco_Cfg(flags, kwargs={})
Definition: AFP_GlobReco.py:11
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
AFP_LocReco.AFP_LocReco_TD_Cfg
def AFP_LocReco_TD_Cfg(flags, kwargs={})
Definition: AFP_LocReco.py:61
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:259
Constants
some useful constants -------------------------------------------------—
AFP_SiClusterTools.AFP_SiClusterTools_Cfg
def AFP_SiClusterTools_Cfg(flags, kwargs={})
Definition: AFP_SiClusterTools.py:14
AFP_LocReco.AFP_LocReco_SiD_Cfg
def AFP_LocReco_SiD_Cfg(flags, kwargs={})
Definition: AFP_LocReco.py:13
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
AFPRecConfig.AFPRecOutputCfg
def AFPRecOutputCfg(flags)
Definition: AFPRecConfig.py:22