This is the AthenaRoot version of AthenaServices/AthenaOutputStreamTool.
More...
#include <RootNtupleOutputMetadataTool.h>
This is the AthenaRoot version of AthenaServices/AthenaOutputStreamTool.
Definition at line 35 of file RootNtupleOutputMetadataTool.h.
◆ RootNtupleOutputMetadataTool() [1/3]
Athena::RootNtupleOutputMetadataTool::RootNtupleOutputMetadataTool |
( |
const std::string & |
type, |
|
|
const std::string & |
name, |
|
|
const IInterface * |
parent |
|
) |
| |
Standard AlgTool Constructor.
Definition at line 39 of file RootNtupleOutputMetadataTool.cxx.
49 declareProperty(
"InputStore",
51 "Input metadata store");
52 declareProperty(
"OutputStore",
54 "Output metadata store");
55 declareProperty(
"StreamName",
57 "Name of the output stream tool associated with FIXME");
58 declareProperty(
"TupleName",
60 "Name of the output n-tuple FIXME");
61 declareProperty(
"OutputFile",
63 "Name of the output file FIXME");
◆ ~RootNtupleOutputMetadataTool()
Athena::RootNtupleOutputMetadataTool::~RootNtupleOutputMetadataTool |
( |
| ) |
|
|
virtual |
◆ RootNtupleOutputMetadataTool() [2/3]
Athena::RootNtupleOutputMetadataTool::RootNtupleOutputMetadataTool |
( |
| ) |
|
|
private |
◆ RootNtupleOutputMetadataTool() [3/3]
◆ addMetadata()
StatusCode Athena::RootNtupleOutputMetadataTool::addMetadata |
( |
const std::string & |
key, |
|
|
const void * |
obj, |
|
|
const std::type_info & |
ti |
|
) |
| |
|
private |
Definition at line 279 of file RootNtupleOutputMetadataTool.cxx.
285 REPORT_MESSAGE (MSG::ERROR) <<
"Attempt to write null pointer metadata";
286 return StatusCode::FAILURE;
292 std::string metaname;
295 dir = m_tree->GetDirectory();
301 REPORT_MESSAGE (MSG::ERROR) <<
"No file directory to navigate from";
302 return StatusCode::FAILURE;
305 std::string thekey =
key;
306 std::string::size_type
sep =
key.find(
'/');
307 if (
sep != std::string::npos) {
308 metaname =
key.substr (0,
sep);
312 while (
dynamic_cast<TDirectoryFile*
> (
dir) != 0 &&
314 dir =
dir->GetMotherDir();
315 thekey = m_tree->GetName();
320 metaname = m_tree->GetName();
323 metaname =
"eventless";
328 TDirectory::TContext ctx (
dir);
329 TDirectory* metadir =
dir->GetDirectory (metaname.c_str());
331 metadir =
dir->mkdir (metaname.c_str());
334 <<
"Can't create metadata dir " << metaname
335 <<
"in dir " <<
dir->GetName();
336 return StatusCode::RECOVERABLE;
341 TClass*
cls = gROOT->GetClass(ti);
343 return StatusCode::RECOVERABLE;
346 if (ti ==
typeid(TString) || ti ==
typeid(std::string)) {
348 if (ti ==
typeid(TString)) {
349 ostmp.String() = *
reinterpret_cast<const TString*
> (
obj);
351 cls = gROOT->GetClass (
"TObjString");
353 else if (ti ==
typeid(std::string)) {
354 ostmp.String() = *
reinterpret_cast<const std::string*
> (
obj);
356 cls = gROOT->GetClass (
"TObjString");
358 if (
key.size() > 0 &&
key[
key.size()-1] ==
'/') {
360 while (metadir->FindObject (thekey.c_str())) {
362 std::ostringstream
ss;
364 ss << m_tree->GetName();
366 ss <<
dir->GetName();
373 if (metadir->WriteObjectAny (
obj,
cls, thekey.c_str(),
"new") == 0) {
375 <<
"Can't write metadata object " << thekey
376 <<
" for file " << metadir->GetFile()->GetName();
377 return StatusCode::RECOVERABLE;
380 else if (ti ==
typeid(TTree)) {
385 if (
key.size() > 0) {
386 TTree* outTree = (TTree*)metadir->FindObject (thekey.c_str());
393 Long64_t temp = outTree->Merge((TCollection*)&tc);
395 REPORT_MESSAGE (MSG::ERROR) <<
"Unable to merge with existing tree in file";
396 return StatusCode::RECOVERABLE;
402 REPORT_MESSAGE (MSG::ERROR) <<
"Did not use proper key for metadata tree ";
403 return StatusCode::RECOVERABLE;
407 REPORT_MESSAGE (MSG::ERROR) <<
"addMetadata typeid not supported";
408 return StatusCode::FAILURE;
410 return(StatusCode::SUCCESS);
◆ copyMetadata()
StatusCode Athena::RootNtupleOutputMetadataTool::copyMetadata |
( |
| ) |
|
Connect to the output stream Must writeMetadata BEFORE streaming Only specify "outputName" if one wants to override jobOptions.
Definition at line 239 of file RootNtupleOutputMetadataTool.cxx.
244 bool failure =
false;
245 if (
pc.isSuccess()) {
246 for (; iter !=
end; ++iter) {
248 std::string* toCopy =
new std::string(*iter);
255 return StatusCode::FAILURE;
261 if (
pc.isSuccess()) {
262 for (; titer !=
tend; ++titer) {
263 auto toCopy = std::make_unique<TransferTree>(*titer);
265 if (
m_ometaStore->record(std::move(toCopy),titer.
key()).isFailure()) failure=
true;
267 else ATH_MSG_INFO(
"Retrieve TTree with null pointer from input metadata store");
272 return StatusCode::FAILURE;
275 return(StatusCode::SUCCESS);
◆ finalize()
StatusCode Athena::RootNtupleOutputMetadataTool::finalize |
( |
| ) |
|
|
overridevirtual |
◆ handle()
void Athena::RootNtupleOutputMetadataTool::handle |
( |
const Incident & |
incident | ) |
|
|
overridevirtual |
Incident service handle listening for Begin/End InputFile incidents.
Definition at line 153 of file RootNtupleOutputMetadataTool.cxx.
156 if (inc.type()==
"BeginInputFile") {
161 if (
pc.isSuccess()) {
162 for (; titer !=
tend; ++titer) {
163 if (
m_ometaStore->removeDataAndProxy(&*titer).isFailure()) {
164 ATH_MSG_ERROR(
"Unable to remove TransferTree after writing");
170 else if (inc.type()==
"EndInputFile") {
◆ initialize()
StatusCode Athena::RootNtupleOutputMetadataTool::initialize |
( |
| ) |
|
|
overridevirtual |
Gaudi AlgTool Interface method implementations:
Definition at line 70 of file RootNtupleOutputMetadataTool.cxx.
76 return(StatusCode::FAILURE);
80 ATH_MSG_FATAL(
"Cannot get ClassID service via IClassIDSvc interface.");
81 return(StatusCode::FAILURE);
88 return(StatusCode::FAILURE);
94 return(StatusCode::FAILURE);
99 if (!incSvc.retrieve().isSuccess()) {
101 return StatusCode::FAILURE;
105 incSvc->addListener(
this,
"BeginInputFile", 50);
106 incSvc->addListener(
this,
"EndInputFile", 50);
109 return(StatusCode::SUCCESS);
◆ operator=()
◆ postExecute()
StatusCode Athena::RootNtupleOutputMetadataTool::postExecute |
( |
| ) |
|
|
overridevirtual |
◆ postInitialize()
StatusCode Athena::RootNtupleOutputMetadataTool::postInitialize |
( |
| ) |
|
|
overridevirtual |
◆ preExecute()
StatusCode Athena::RootNtupleOutputMetadataTool::preExecute |
( |
| ) |
|
|
overridevirtual |
◆ preFinalize()
StatusCode Athena::RootNtupleOutputMetadataTool::preFinalize |
( |
| ) |
|
|
overridevirtual |
◆ preStream()
StatusCode Athena::RootNtupleOutputMetadataTool::preStream |
( |
| ) |
|
|
overridevirtual |
◆ stop()
StatusCode Athena::RootNtupleOutputMetadataTool::stop |
( |
| ) |
|
|
overridevirtual |
◆ writeMetadata()
StatusCode Athena::RootNtupleOutputMetadataTool::writeMetadata |
( |
| ) |
|
Definition at line 177 of file RootNtupleOutputMetadataTool.cxx.
179 ATH_MSG_INFO(
"RootNtupleOutputMetadataTool::writeMetadata outputName = ["
183 if (!iosvc.retrieve().isSuccess()) {
185 return StatusCode::FAILURE;
190 return StatusCode::FAILURE;
197 bool failure =
false;
198 if (
pc.isSuccess()) {
199 for (; iter !=
end; ++iter) {
200 std::string
key = iter.
key();
201 if (this->
addMetadata(key,&(*iter),
typeid(std::string)).isFailure()) failure=
true;
206 return StatusCode::FAILURE;
213 bool failure =
false;
214 if (
pc.isSuccess()) {
215 for (; titer !=
tend; ++titer) {
216 std::string
key = titer.
key();
218 const TTree*
x = (TTree*)titer->tree();
220 if (this->
addMetadata(key,
x,
typeid(TTree)).isFailure()) failure=
true;
232 return StatusCode::FAILURE;
235 return(StatusCode::SUCCESS);
◆ m_clidSvc
ServiceHandle<IClassIDSvc> Athena::RootNtupleOutputMetadataTool::m_clidSvc |
|
private |
◆ m_imetaStore
◆ m_metaWritten
bool Athena::RootNtupleOutputMetadataTool::m_metaWritten |
|
private |
◆ m_ometaStore
◆ m_outputName
std::string Athena::RootNtupleOutputMetadataTool::m_outputName |
|
private |
◆ m_streamName
std::string Athena::RootNtupleOutputMetadataTool::m_streamName |
|
private |
◆ m_treesWritten
std::set<std::string> Athena::RootNtupleOutputMetadataTool::m_treesWritten |
|
private |
◆ m_tupleName
std::string Athena::RootNtupleOutputMetadataTool::m_tupleName |
|
private |
The documentation for this class was generated from the following files:
void readTree(AccumulateMap &map, TTree *tree, size_t nLayers, size_t nCoords)
Reads a matrix tree, accumulating its entries into a map.