ATLAS Offline Software
Loading...
Searching...
No Matches
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
8namespace 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 }
22 StatusCode TreeTestAlg::execute() {
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 }
36 ATH_CHECK(m_tree.write());
37 return StatusCode::SUCCESS;
38 }
39 }
40}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
virtual StatusCode initialize() override final
MuonVal::ArrayBranch< unsigned > * m_arrayTest
MuonVal::VectorBranch< unsigned > & m_vectorTest
virtual StatusCode finalize() override final
MuonVal::MatrixBranch< unsigned > & m_matrixTest
virtual StatusCode execute() override final
MuonVal::ScalarBranch< unsigned > & m_scalarTest
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19