ATLAS Offline Software
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 
8 import AthenaCommon.CfgMgr as CfgMgr
9 from AthenaCommon.AppMgr import theApp
10 from AthenaRootComps.AthenaRootCompsConf import Athena__RootOutputStreamTool as AthenaRootOutputStreamTool
11 
12 def 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 
41 def 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 """
72 from AthenaCommon import CfgMgr
73 class 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 
92 class 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 
103  def _get_output_file(self):
104  return self._properties['OutputFile'].__get__(self)
105 
106  OutputFile = property(_get_output_file, _set_output_file, "fwd doc...")
107  pass
python.OutputStreamAthenaRoot.AthenaRootNtupleOutputStreamProtect._get_output_file
def _get_output_file(self)
Definition: OutputStreamAthenaRoot.py:103
python.AlgSequence.AlgSequence
AlgSequence
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py:7
CaloClusterListBadChannel.cls
cls
Definition: CaloClusterListBadChannel.py:8
python.OutputStreamAthenaRoot.AthenaRootNtupleOutputStreamProtect.__init__
def __init__(self, name='Stream1', **kw)
Definition: OutputStreamAthenaRoot.py:93
python.OutputStreamAthenaRoot.createOutputStream
def createOutputStream(streamName, fileName="", asAlg=False)
Definition: OutputStreamAthenaRoot.py:41
python.OutputStreamAthenaRoot.createNtupleOutputStream
def createNtupleOutputStream(streamName, fileName, tupleName="physics", asAlg=False)
Definition: OutputStreamAthenaRoot.py:12
python.OutputStreamAthenaRoot.AthenaRootNtupleOutputStreamProtect._set_output_file
def _set_output_file(self, fname)
Definition: OutputStreamAthenaRoot.py:98
python.OutputStreamAthenaRoot.AthenaRootNtupleOutputStreamProtect
backward compat AthenaRootOutputStream = createOutputStream AthenaRootOutputConditionStream = createO...
Definition: OutputStreamAthenaRoot.py:92
AthenaOutputStream
algorithm that marks for write data objects in SG
Definition: AthenaOutputStream.h:58