ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Athena::RootOutputStreamTool Class Reference

This is the AthenaRoot version of AthenaServices/AthenaOutputStreamTool. More...

#include <RootOutputStreamTool.h>

Inheritance diagram for Athena::RootOutputStreamTool:
Collaboration diagram for Athena::RootOutputStreamTool:

Public Member Functions

 RootOutputStreamTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard AlgTool Constructor. More...
 
virtual ~RootOutputStreamTool ()
 Destructor. More...
 
StatusCode initialize ()
 Gaudi AlgTool Interface method implementations: More...
 
StatusCode finalize ()
 
StatusCode connectServices (const std::string &dataStore, const std::string &cnvSvc, bool extendProvenenceRecord)
 Specify which data store and conversion service to use and whether to extend provenence Only use if one wants to override jobOptions. More...
 
StatusCode connectOutput (const std::string &outputName)
 Connect to the output stream Must connectOutput BEFORE streaming Only specify "outputName" if one wants to override jobOptions. More...
 
StatusCode commitOutput (bool doCommit=false)
 Commit the output stream after having streamed out objects Must commitOutput AFTER streaming. More...
 
StatusCode finalizeOutput ()
 Finalize the output stream after the last commit, e.g. More...
 
StatusCode streamObjects (const IAthenaOutputStreamTool::TypeKeyPairs &typeKeys, const std::string &outputName="")
 Stream out objects. More...
 
StatusCode streamObjects (const IAthenaOutputStreamTool::DataObjectVec &dataObjects, const std::string &outputName="")
 Stream out a vector of objects Must convert to DataObject, e.g. More...
 
StatusCode fillObjectRefs (const IAthenaOutputStreamTool::DataObjectVec &dataObjects)
 Fill refs of an object - done as second iteration over objects, after streamObject. More...
 
StatusCode getInputItemList (SG::IFolder *m_p2BWrittenFromTool)
 

Private Member Functions

 RootOutputStreamTool ()
 Default constructor: More...
 
 RootOutputStreamTool (const RootOutputStreamTool &)
 
RootOutputStreamTooloperator= (const RootOutputStreamTool &)
 

Private Attributes

ServiceHandle< ::StoreGateSvcm_storeSvc
 ServiceHandle to the data store service. More...
 
ServiceHandle< ::IConversionSvc > m_conversionSvc
 ServiceHandle to the data conversion service. More...
 
ServiceHandle< ::IClassIDSvc > m_clidSvc
 ServiceHandle to clid service. More...
 
std::string m_outputName
 Name of the output file. More...
 
std::string m_treeName
 Name of the output tuple. More...
 

Detailed Description

This is the AthenaRoot version of AthenaServices/AthenaOutputStreamTool.

Definition at line 33 of file RootOutputStreamTool.h.

Constructor & Destructor Documentation

◆ RootOutputStreamTool() [1/3]

Athena::RootOutputStreamTool::RootOutputStreamTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Standard AlgTool Constructor.

Definition at line 33 of file RootOutputStreamTool.cxx.

33  :
34  base_class(type, name, parent),
35  m_storeSvc("StoreGateSvc", name),
36  m_conversionSvc("Athena::RootCnvSvc/AthenaRootCnvSvc", name),
37  m_clidSvc("ClassIDSvc", name) {
38  // Declare IAthenaOutputStreamTool interface
39  declareInterface<IAthenaOutputStreamTool>(this);
40  // Properties
41  declareProperty("Store", m_storeSvc, "Store from which to stream out event data");
42  declareProperty("TreeName", m_treeName = "CollectionTree", "Name of the output event tree");
43  declareProperty("OutputFile", m_outputName, "Name of the output file");
44 }

◆ ~RootOutputStreamTool()

Athena::RootOutputStreamTool::~RootOutputStreamTool ( )
virtual

Destructor.

Definition at line 46 of file RootOutputStreamTool.cxx.

46  {
47 }

◆ RootOutputStreamTool() [2/3]

Athena::RootOutputStreamTool::RootOutputStreamTool ( )
private

Default constructor:

◆ RootOutputStreamTool() [3/3]

Athena::RootOutputStreamTool::RootOutputStreamTool ( const RootOutputStreamTool )
private

Member Function Documentation

◆ commitOutput()

StatusCode Athena::RootOutputStreamTool::commitOutput ( bool  doCommit = false)

Commit the output stream after having streamed out objects Must commitOutput AFTER streaming.

Definition at line 112 of file RootOutputStreamTool.cxx.

112  {
113  ATH_MSG_VERBOSE("commitOutput");
114  if (m_outputName.empty()) {
115  ATH_MSG_ERROR("Unable to commit, no output connected.");
116  return StatusCode::FAILURE;
117  }
118  // Connect the output file to the service
119  if (!m_conversionSvc->commitOutput(m_outputName, false).isSuccess()) {
120  ATH_MSG_ERROR("Unable to commit output " << m_outputName);
121  return StatusCode::FAILURE;
122  } else {
123  ATH_MSG_DEBUG("Committed: " << m_outputName);
124  }
125  m_outputName.clear();
126  return StatusCode::SUCCESS;
127 }

◆ connectOutput()

StatusCode Athena::RootOutputStreamTool::connectOutput ( const std::string &  outputName)

Connect to the output stream Must connectOutput BEFORE streaming Only specify "outputName" if one wants to override jobOptions.

Definition at line 94 of file RootOutputStreamTool.cxx.

94  {
95  ATH_MSG_VERBOSE("connectOutput outputName = [" << outputName <<"]");
96  // Set output file name property
97  if (!outputName.empty()) {
99  } else {
100  return StatusCode::FAILURE;
101  }
102  // Connect the output file to the service
103  if (!m_conversionSvc->connectOutput(m_outputName + "(" + m_treeName + ")", "recreate").isSuccess()) {
104  ATH_MSG_ERROR("Unable to connect output " << m_outputName);
105  return StatusCode::FAILURE;
106  } else {
107  ATH_MSG_DEBUG("Connected to " << m_outputName);
108  }
109  return StatusCode::SUCCESS;
110 }

◆ connectServices()

StatusCode Athena::RootOutputStreamTool::connectServices ( const std::string &  dataStore,
const std::string &  cnvSvc,
bool  extendProvenenceRecord 
)

Specify which data store and conversion service to use and whether to extend provenence Only use if one wants to override jobOptions.

Definition at line 80 of file RootOutputStreamTool.cxx.

80  {
81  ATH_MSG_VERBOSE("connectServices dataStore = " << dataStore << ", cnvSvc = " << cnvSvc << ", extendProv = " << extendProvenenceRecord);
82  // Release the old data store service
83  if (m_storeSvc != 0) {
84  if (!m_storeSvc.release().isSuccess()) {
85  ATH_MSG_WARNING("Could not release " << m_storeSvc.type() << " store.");
86  }
87  }
88  m_storeSvc = ServiceHandle<StoreGateSvc>(dataStore, this->name());
89  // Get the data store service
90  ATH_CHECK(m_storeSvc.retrieve());
91  return StatusCode::SUCCESS;
92 }

◆ fillObjectRefs()

StatusCode Athena::RootOutputStreamTool::fillObjectRefs ( const IAthenaOutputStreamTool::DataObjectVec dataObjects)

Fill refs of an object - done as second iteration over objects, after streamObject.

Definition at line 223 of file RootOutputStreamTool.cxx.

223  {
224  ATH_MSG_VERBOSE("fillObjectRefs");
225  return StatusCode::SUCCESS;
226 }

◆ finalize()

StatusCode Athena::RootOutputStreamTool::finalize ( )

Definition at line 62 of file RootOutputStreamTool.cxx.

62  {
63  // Release the data store service
64  if (m_storeSvc != 0) {
65  if (!m_storeSvc.release().isSuccess()) {
66  ATH_MSG_WARNING("Could not release " << m_storeSvc.type() << " store.");
67  }
68  }
69  // Release the conversion service
70  if (!m_conversionSvc.release().isSuccess()) {
71  ATH_MSG_WARNING("Cannot release conversion service.");
72  }
73  // Release the ClassID service
74  if (!m_clidSvc.release().isSuccess()) {
75  ATH_MSG_WARNING("Cannot release ClassID service.");
76  }
78 }

◆ finalizeOutput()

StatusCode Athena::RootOutputStreamTool::finalizeOutput ( )

Finalize the output stream after the last commit, e.g.

in finalize

Definition at line 129 of file RootOutputStreamTool.cxx.

129  {
130  ATH_MSG_VERBOSE("finalizeOutput");
131  return StatusCode::SUCCESS;
132 }

◆ getInputItemList()

StatusCode Athena::RootOutputStreamTool::getInputItemList ( SG::IFolder m_p2BWrittenFromTool)

Definition at line 228 of file RootOutputStreamTool.cxx.

228  {
229  ATH_MSG_VERBOSE("getInputItemList");
230  return StatusCode::SUCCESS;
231 }

◆ initialize()

StatusCode Athena::RootOutputStreamTool::initialize ( )

Gaudi AlgTool Interface method implementations:

Definition at line 49 of file RootOutputStreamTool.cxx.

49  {
50  ATH_MSG_INFO("Initializing " << name());
51  if (!::AthAlgTool::initialize().isSuccess()) {
52  ATH_MSG_FATAL("Cannot initialize AlgTool base class.");
53  return StatusCode::FAILURE;
54  }
55  // Get the ClassID service
56  ATH_CHECK(m_clidSvc.retrieve());
57  // Get the conversion service
58  ATH_CHECK(m_conversionSvc.retrieve());
59  return StatusCode::SUCCESS;
60 }

◆ operator=()

RootOutputStreamTool& Athena::RootOutputStreamTool::operator= ( const RootOutputStreamTool )
private

◆ streamObjects() [1/2]

StatusCode Athena::RootOutputStreamTool::streamObjects ( const IAthenaOutputStreamTool::DataObjectVec dataObjects,
const std::string &  outputName = "" 
)

Stream out a vector of objects Must convert to DataObject, e.g.

#include "AthenaKernel/StorableConversions.h" T* obj = xxx; DataObject* dataObject = SG::asStorable(obj);

◆ streamObjects() [2/2]

StatusCode Athena::RootOutputStreamTool::streamObjects ( const IAthenaOutputStreamTool::TypeKeyPairs typeKeys,
const std::string &  outputName = "" 
)

Stream out objects.

Provide vector of typeName/key pairs. If key is empty, assumes only one object and this will fail if there is more than one

Definition at line 134 of file RootOutputStreamTool.cxx.

134  {
135  ATH_MSG_VERBOSE("streamObjects(type/keys)...");
136  // Now iterate over the type/key pairs and stream out each object
137  std::vector<DataObject*> dataObjects;
138  dataObjects.reserve(typeKeys.size());
139  for (IAthenaOutputStreamTool::TypeKeyPairs::const_iterator first = typeKeys.begin(), last = typeKeys.end();
140  first != last; ++first) {
141  const std::string& type = (*first).first;
142  const std::string& key = (*first).second;
143  // Find the clid for type name from the classIDSvc
144  CLID clid = 0;
145  if (!m_clidSvc->getIDOfTypeName(type, clid).isSuccess()) {
146  ATH_MSG_ERROR("Could not get clid for typeName " << type);
147  return StatusCode::FAILURE;
148  }
149  DataObject* dObj = 0;
150  // Two options: no key or explicit key
151  if (key.empty()) {
152  ATH_MSG_DEBUG("Get data object with no key");
153  // Get DataObject without key
154  dObj = m_storeSvc->accessData(clid);
155  } else {
156  ATH_MSG_DEBUG("Get data object with key");
157  // Get DataObjects with key
158  dObj = m_storeSvc->accessData(clid, key);
159  }
160  if (dObj == 0) {
161  // No object - print warning and continue with next object
162  ATH_MSG_WARNING("No object found for type " << type << " key " << key);
163  continue;
164  } else {
165  ATH_MSG_DEBUG("Found object for type " << type << " key " << key);
166  }
167  // Save the dObj
168  dataObjects.push_back(dObj);
169  }
170  return this->streamObjects(dataObjects, outputName);
171 }

Member Data Documentation

◆ m_clidSvc

ServiceHandle< ::IClassIDSvc> Athena::RootOutputStreamTool::m_clidSvc
private

ServiceHandle to clid service.

Definition at line 93 of file RootOutputStreamTool.h.

◆ m_conversionSvc

ServiceHandle< ::IConversionSvc> Athena::RootOutputStreamTool::m_conversionSvc
private

ServiceHandle to the data conversion service.

Definition at line 91 of file RootOutputStreamTool.h.

◆ m_outputName

std::string Athena::RootOutputStreamTool::m_outputName
private

Name of the output file.

Definition at line 96 of file RootOutputStreamTool.h.

◆ m_storeSvc

ServiceHandle< ::StoreGateSvc> Athena::RootOutputStreamTool::m_storeSvc
private

ServiceHandle to the data store service.

Definition at line 89 of file RootOutputStreamTool.h.

◆ m_treeName

std::string Athena::RootOutputStreamTool::m_treeName
private

Name of the output tuple.

Definition at line 99 of file RootOutputStreamTool.h.


The documentation for this class was generated from the following files:
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
initialize
void initialize()
Definition: run_EoverP.cxx:894
Athena::RootOutputStreamTool::m_outputName
std::string m_outputName
Name of the output file.
Definition: RootOutputStreamTool.h:96
Athena::RootOutputStreamTool::m_storeSvc
ServiceHandle< ::StoreGateSvc > m_storeSvc
ServiceHandle to the data store service.
Definition: RootOutputStreamTool.h:89
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Athena::RootOutputStreamTool::m_clidSvc
ServiceHandle< ::IClassIDSvc > m_clidSvc
ServiceHandle to clid service.
Definition: RootOutputStreamTool.h:93
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
lumiFormat.outputName
string outputName
Definition: lumiFormat.py:65
Athena::RootOutputStreamTool::streamObjects
StatusCode streamObjects(const IAthenaOutputStreamTool::TypeKeyPairs &typeKeys, const std::string &outputName="")
Stream out objects.
Definition: RootOutputStreamTool.cxx:134
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DeMoScan.first
bool first
Definition: DeMoScan.py:536
Athena::RootOutputStreamTool::m_treeName
std::string m_treeName
Name of the output tuple.
Definition: RootOutputStreamTool.h:99
Athena::RootOutputStreamTool::m_conversionSvc
ServiceHandle< ::IConversionSvc > m_conversionSvc
ServiceHandle to the data conversion service.
Definition: RootOutputStreamTool.h:91
ServiceHandle< StoreGateSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37