ATLAS Offline Software
Loading...
Searching...
No Matches
OutputStreamAthenaRoot.py
Go to the documentation of this file.
1# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3
7
8import AthenaCommon.CfgMgr as CfgMgr
9from AthenaCommon.AppMgr import theApp
10from AthenaRootComps.AthenaRootCompsConf import Athena__RootOutputStreamTool as AthenaRootOutputStreamTool
11
12def createNtupleOutputStream(streamName, fileName, tupleName="physics", asAlg = False):
13 if asAlg:
14 from AthenaCommon.AlgSequence import AlgSequence
15 topSequence = AlgSequence()
16
17 # Now do standard output stream
18 writingTool1 = AthenaRootOutputStreamTool( streamName + "Tool" )
19 writingTool1.TreeName = tupleName
20 writingTool1.OutputFile = fileName
21 #writingTool1.
22 cls = AthenaRootNtupleOutputStreamProtect
23 #cls = CfgMgr.Athena__RootNtupleOutputStream
24 outputStream = cls(
25 streamName,
26 WritingTool = writingTool1,
27 ItemList = ["RunNumber",
28 "EventNumber",],
29 #StrictClidMatching = False,
30 )
31 if asAlg:
32 from AthenaCommon.AlgSequence import AlgSequence
33 topSequence += outputStream
34 else:
35 theApp.addOutputStream( outputStream )
36
37 if fileName != "":
38 outputStream.OutputFile = fileName
39 return outputStream
40
41def createOutputStream( streamName, fileName = "", asAlg = False ):
42 from AthenaServices.AthenaServicesConf import AthenaOutputStream
43 if asAlg:
44 from AthenaCommon.AlgSequence import AlgSequence
45 topSequence = AlgSequence()
46
47 # Now do standard output stream
48 writingTool1 = AthenaRootOutputStreamTool( streamName + "Tool" )
49 writingTool1.TreeName = "CollectionTree"
50 outputStream = AthenaOutputStream(
51 streamName,
52 WritingTool = writingTool1,
53 ItemList = [ "EventInfo#*" ]
54 )
55 if asAlg:
56 from AthenaCommon.AlgSequence import AlgSequence
57 topSequence += outputStream
58 else:
59 theApp.addOutputStream( outputStream )
60
61 if fileName != "":
62 outputStream.OutputFile = fileName
63
64 return outputStream
65
66
67
70
71"""
72from AthenaCommon import CfgMgr
73class AthenaRootOutputStreamProtect(CfgMgr.AthenaOutputStream):
74 def __init__(self, name='Stream1', **kw):
75 kw['name'] = kw.get('name', name)
76 super(AthenaRootOutputStreamProtect, self).__init__(**kw)
77 return
78
79 def _set_output_file(self, fname):
80 self._properties['OutputFile'].__set__(self, fname)
81 from AthenaServices.AthenaServicesConf import AthenaOutputStream
82 AthenaOutputStream("%s_FH" % (self._name,)).OutputFile = fname
83 return
84
85 def _get_output_file(self):
86 return self._properties['OutputFile'].__get__(self)
87
88 OutputFile = property(_get_output_file, _set_output_file, "fwd doc...")
89 pass
90"""
91
92class AthenaRootNtupleOutputStreamProtect(CfgMgr.Athena__RootNtupleOutputStream):
93 def __init__(self, name='Stream1', **kw):
94 kw['name'] = kw.get('name', name)
95 super(AthenaRootNtupleOutputStreamProtect, self).__init__(**kw)
96 return
97
98 def _set_output_file(self, fname):
99 self._properties['OutputFile'].__set__(self, fname)
100 CfgMgr.Athena__RootNtupleOutputStream("%s_FH" % (self._name,)).OutputFile = fname
101 return
102
104 return self._properties['OutputFile'].__get__(self)
105
106 OutputFile = property(_get_output_file, _set_output_file, "fwd doc...")
107 pass
algorithm that marks for write data objects in SG
backward compat AthenaRootOutputStream = createOutputStream AthenaRootOutputConditionStream = createO...
createOutputStream(streamName, fileName="", asAlg=False)
createNtupleOutputStream(streamName, fileName, tupleName="physics", asAlg=False)