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(const EventContext& ctx) {
23 for (unsigned int n = 0; n < 100; ++n) {
24 m_scalarTest = n;
25 m_vectorTest[n] = n +1;
26 m_matrixTest[n+1] = std::vector<unsigned>{n,n+1,n+3};
27 (*m_arrayTest)[0] = n +1;
28 (*m_arrayTest)[1] = n+5;
29 ATH_CHECK(m_tree.fill(ctx));
30 }
31
32 return StatusCode::SUCCESS;
33 }
35 ATH_CHECK(m_tree.write());
36 return StatusCode::SUCCESS;
37 }
38 }
39}
#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
MuonVal::ScalarBranch< unsigned > & m_scalarTest
virtual StatusCode execute(const EventContext &ctx) override final
Execute method.
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19