ATLAS Offline Software
TrkG4UserActionsConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2 
3 """Define methods to configure TrkG4UserActions"""
4 
5 def MaterialStepRecorderCfg(configFlags, name="G4UA::UserActionSvc.MaterialStepRecorderTool", **kwargs):
6  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7  from AthenaConfiguration.ComponentFactory import CompFactory
8  result = ComponentAccumulator()
9  result.setPrivateTools(CompFactory.G4UA.MaterialStepRecorderTool(name, **kwargs))
10  return result
11 
12 
13 def MaterialStepRecorderUserActionSvcCfg(configFlags, name="G4UA::MaterialStepRecorderUserActionSvc", **kwargs):
14  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
15  from AthenaConfiguration.ComponentFactory import CompFactory
16 
17  result = ComponentAccumulator()
18 
19  #Setting up the CA for the MaterialStepRecorder
20  actionAcc = ComponentAccumulator()
21  actions = []
22  actions += [actionAcc.popToolsAndMerge(MaterialStepRecorderCfg(configFlags))]
23  actionAcc.setPrivateTools(actions)
24  MaterialStepRecorderAction = result.popToolsAndMerge(actionAcc)
25 
26  #Retrieving the default action list
27  from G4AtlasServices.G4AtlasUserActionConfig import getDefaultActions
28  defaultActions = result.popToolsAndMerge(getDefaultActions(configFlags))
29 
30  #Adding LengthIntegrator to defaults
31  actionList = (defaultActions + MaterialStepRecorderAction)
32 
33  #Setting up UserActionsService
34 
36  kwargs_UATools = {}
37  kwargs_UATools.setdefault("UserActionTools",actionList)
38  result.addService(CompFactory.G4UA.UserActionSvc(name,**kwargs_UATools))
39 
40  return result
41 
42 def MaterialStepRecorder(configFlags, name="G4UA::ISFFullUserActionSvc", **kwargs):
43 
44  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
45  from AthenaConfiguration.ComponentFactory import CompFactory
46 
47  result = ComponentAccumulator()
48  #Setting up the CA
49  actionAcc = ComponentAccumulator()
50  actions = []
51  actions += [actionAcc.popToolsAndMerge(MaterialStepRecorderCfg(configFlags,**kwargs))]
52  actionAcc.setPrivateTools(actions)
53  MaterialStepRecorderAction = result.popToolsAndMerge(actionAcc)
54 
55  actionList = MaterialStepRecorderAction
56  #We clear it here because UserActionsTools also wants kwargs, different
57  #from the tool above - probably this caq be improved...
58  kwargs_UATools = {}
59  kwargs_UATools.setdefault("UserActionTools",actionList)
60  result.addService(CompFactory.G4UA.UserActionSvc(name,**kwargs_UATools))
61 
62  AthenaOutputStream=CompFactory.AthenaOutputStream
63  AthenaOutputStreamTool=CompFactory.AthenaOutputStreamTool
64  writingTool = AthenaOutputStreamTool( "MaterialStepCollectionStreamTool" )
65 
66  outputStream = AthenaOutputStream(name = "MaterialStepCollectionStream",
67  WritingTool = writingTool,
68  ItemList=['EventInfo#*', 'Trk::MaterialStepCollection#*'],
69  MetadataItemList = [ "EventStreamInfo#MaterialStepCollectionStream", "IOVMetaDataContainer#*" ],
70  OutputFile = "MaterialStepCollection.root")
71 
72  StoreGateSvc=CompFactory.StoreGateSvc
73  result.addService(StoreGateSvc("MetaDataStore"))
74  outputStream.MetadataStore = result.getService("MetaDataStore")
75 
76  MakeEventStreamInfo=CompFactory.MakeEventStreamInfo
77  streamInfoTool = MakeEventStreamInfo( "MaterialStepCollectionStream_MakeEventStreamInfo" )
78  streamInfoTool.Key = "MaterialStepCollectionStream"
79  streamInfoTool.EventInfoKey = "EventInfo"
80  outputStream.HelperTools.append(streamInfoTool)
81 
82  result.addEventAlgo(outputStream)
83 
84  return result
85 
86 def GeantFollowerMSToolCfg(configFlags, name="G4UA::GeantFollowerMSTool", **kwargs):
87  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
88  from AthenaConfiguration.ComponentFactory import CompFactory
89 
90  THistSvc= CompFactory.THistSvc
91  result = ComponentAccumulator()
92  histsvc = THistSvc(name="THistSvc")
93  histsvc.Output = ["val DATAFILE='GeantFollowing.root' OPT='RECREATE'"]
94  result.addService(histsvc)
95  result.setPrivateTools(CompFactory.G4UA.GeantFollowerMSTool(name, **kwargs))
96 
97  return result
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
python.TrkG4UserActionsConfig.MaterialStepRecorderCfg
def MaterialStepRecorderCfg(configFlags, name="G4UA::UserActionSvc.MaterialStepRecorderTool", **kwargs)
Definition: TrkG4UserActionsConfig.py:5
MakeEventStreamInfo
This class provides an algorithm to make the EventStreamInfo object and update it.
Definition: MakeEventStreamInfo.h:27
Lb2Lll.THistSvc
THistSvc
Definition: Lb2Lll.py:216
AthenaOutputStream
algorithm that marks for write data objects in SG
Definition: AthenaOutputStream.h:58
G4AtlasUserActionConfig.getDefaultActions
def getDefaultActions(flags)
Definition: G4AtlasUserActionConfig.py:106
python.TrkG4UserActionsConfig.GeantFollowerMSToolCfg
def GeantFollowerMSToolCfg(configFlags, name="G4UA::GeantFollowerMSTool", **kwargs)
Definition: TrkG4UserActionsConfig.py:86
python.TrkG4UserActionsConfig.MaterialStepRecorder
def MaterialStepRecorder(configFlags, name="G4UA::ISFFullUserActionSvc", **kwargs)
Definition: TrkG4UserActionsConfig.py:42
AthenaOutputStreamTool
This is the implementation of IAthenaOutputStreamTool.
Definition: AthenaOutputStreamTool.h:31
python.TrkG4UserActionsConfig.MaterialStepRecorderUserActionSvcCfg
def MaterialStepRecorderUserActionSvcCfg(configFlags, name="G4UA::MaterialStepRecorderUserActionSvc", **kwargs)
Definition: TrkG4UserActionsConfig.py:13