ATLAS Offline Software
TreeTesterAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "TreeTesterAlg.h"
5 #include <memory>
6 #include <vector>
7 
8 namespace MuonVal{
9  namespace MuonTester{
10 
12  auto arrayTest = std::make_unique<ArrayBranch<unsigned>>(m_tree.tree(), "testArray", 2);
13  m_arrayTest = arrayTest.get();
14  bool ok = m_tree.addBranch(std::move(arrayTest));
15  if (not ok){
16  ATH_MSG_ERROR("addBranch failed in TreeTestAlg::initialize");
17  return StatusCode::FAILURE;
18  }
19  ATH_CHECK(m_tree.init(this));
20  return StatusCode::SUCCESS;
21  }
23  const EventContext& ctx{Gaudi::Hive::currentContext()};
24  for (unsigned int n = 0; n < 100; ++n) {
25  m_scalarTest = n;
26  m_vectorTest[n] = n +1;
27  m_matrixTest[n+1] = std::vector<unsigned>{n,n+1,n+3};
28  (*m_arrayTest)[0] = n +1;
29  (*m_arrayTest)[1] = n+5;
30  ATH_CHECK(m_tree.fill(ctx));
31  }
32 
33  return StatusCode::SUCCESS;
34  }
37  return StatusCode::SUCCESS;
38  }
39  }
40 }
MuonVal::MuonTesterTree::init
StatusCode init(OWNER *instance)
Initialize method.
MuonVal::MuonTester::TreeTestAlg::m_tree
MuonTesterTree m_tree
Definition: TreeTesterAlg.h:19
MuonVal::MuonTester::TreeTestAlg::finalize
virtual StatusCode finalize() override final
Definition: TreeTesterAlg.cxx:35
MuonVal::MuonTester::TreeTestAlg::m_vectorTest
MuonVal::VectorBranch< unsigned > & m_vectorTest
Definition: TreeTesterAlg.h:22
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TreeTesterAlg.h
MuonVal::MuonTester::TreeTestAlg::initialize
virtual StatusCode initialize() override final
Definition: TreeTesterAlg.cxx:11
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonVal::MuonTester::TreeTestAlg::m_scalarTest
MuonVal::ScalarBranch< unsigned > & m_scalarTest
Definition: TreeTesterAlg.h:21
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonVal
Class to store array like branches into the n-tuples.
Definition: MuonTPMetaDataAlg.cxx:25
MuonVal::MuonTester::TreeTestAlg::execute
virtual StatusCode execute() override final
Definition: TreeTesterAlg.cxx:22
MuonVal::MuonTester::TreeTestAlg::m_arrayTest
MuonVal::ArrayBranch< unsigned > * m_arrayTest
Definition: TreeTesterAlg.h:24
MuonVal::MuonTesterTree::fill
bool fill(const EventContext &ctx)
Fills the tree per call.
Definition: MuonTesterTree.cxx:89
MuonVal::MuonTesterTree::write
StatusCode write()
Finally write the TTree objects.
Definition: MuonTesterTree.cxx:178
MuonVal::ArrayBranch::get
const T & get(size_t s) const
Returns the i-th value.
MuonVal::MuonTester::TreeTestAlg::m_matrixTest
MuonVal::MatrixBranch< unsigned > & m_matrixTest
Definition: TreeTesterAlg.h:23
MuonVal::MuonTesterTree::tree
TTree * tree()
TTree object.
Definition: MuonTesterTree.cxx:22
MuonVal::MuonTesterTree::addBranch
bool addBranch(std::shared_ptr< IMuonTesterBranch > branch)
Branch is added to the tree without transferring the ownership.
Definition: MuonTesterTree.cxx:61