ATLAS Offline Software
ArrayBranch.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONTESTER_ARRAYBRANCH_H
5 #define MUONTESTER_ARRAYBRANCH_H
6 
9 #include <TTree.h>
11 
12 namespace MuonVal {
13 class MuonTesterTree;
14 template <class T> class ArrayBranch : public MuonTesterBranch, virtual public IMuonTesterBranch {
15 public:
17  ArrayBranch(TTree* tree, const std::string& name, size_t size);
18  ArrayBranch(MuonTesterTree& tree, const std::string& name, size_t size);
19 
21  ArrayBranch(TTree* tree, const std::string& name, size_t size, const T& def_val);
22  ArrayBranch(MuonTesterTree& tree, const std::string& name, size_t size, const T& def_val);
23 
24  virtual ~ArrayBranch() = default;
25 
27  bool fill(const EventContext&) override final;
29  bool init() override final;
30 
33 
35  size_t size() const;
36 
38  void set(size_t s, const T& val);
40  const T& get(size_t s) const;
41 
43  const T& operator[](size_t s) const;
45  T& operator[](size_t s);
46 
49 
50  void setDefault(const T& val);
51 
52 private:
54  std::string tree_data_type() const;
56  void reset();
57  size_t m_size{0};
58  std::vector<T> m_data{};
59  std::vector<bool> m_updated{};
60 
61  bool m_init{false};
62 
64  T m_default{};
65  bool m_failIfNotUpdated{true};
66 };
68 template <> std::string ArrayBranch<char*>::tree_data_type() const;
69 template <> std::string ArrayBranch<std::string>::tree_data_type() const;
70 template <> std::string ArrayBranch<Char_t>::tree_data_type() const;
71 template <> std::string ArrayBranch<UChar_t>::tree_data_type() const;
72 template <> std::string ArrayBranch<Short_t>::tree_data_type() const;
73 template <> std::string ArrayBranch<Int_t>::tree_data_type() const;
74 template <> std::string ArrayBranch<Long64_t>::tree_data_type() const;
75 template <> std::string ArrayBranch<UShort_t>::tree_data_type() const;
76 template <> std::string ArrayBranch<UInt_t>::tree_data_type() const;
77 template <> std::string ArrayBranch<ULong64_t>::tree_data_type() const;
78 template <> std::string ArrayBranch<Float_t>::tree_data_type() const;
79 template <> std::string ArrayBranch<Double_t>::tree_data_type() const;
80 template <> std::string ArrayBranch<Bool_t>::tree_data_type() const;
81 }
83 #endif
MuonVal::IMuonTesterBranch::tree
virtual TTree * tree()=0
Returns the pointer to the underlying TTree object.
MuonVal::ArrayBranch::fill
bool fill(const EventContext &) override final
Returns false if one of the array values is not updated.
MuonVal::ArrayBranch::init
bool init() override final
Connects the branch with the tree.
MuonVal::ArrayBranch::getDefault
const T & getDefault() const
default value in cases the branch is not updated
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
MuonVal::MuonTesterBranch
Definition: MuonTesterBranch.h:21
ArrayBranch.icc
MuonVal::ArrayBranch::m_failIfNotUpdated
bool m_failIfNotUpdated
Definition: ArrayBranch.h:65
MuonVal::ArrayBranch::ArrayBranch
ArrayBranch(MuonTesterTree &tree, const std::string &name, size_t size)
MuonVal::ArrayBranch::ArrayBranch
ArrayBranch(TTree *tree, const std::string &name, size_t size, const T &def_val)
Constructor with default value to be set in case an element is not updated.
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
MuonVal::ArrayBranch::m_init
bool m_init
Definition: ArrayBranch.h:61
MuonVal::ArrayBranch::ArrayBranch
ArrayBranch(TTree *tree, const std::string &name, size_t size)
Constructor.
MuonVal::ArrayBranch::m_data
std::vector< T > m_data
Definition: ArrayBranch.h:58
MuonVal::ArrayBranch::ArrayBranch
ArrayBranch(MuonTesterTree &tree, const std::string &name, size_t size, const T &def_val)
IMuonTesterBranch.h
MuonVal::ArrayBranch::~ArrayBranch
virtual ~ArrayBranch()=default
MuonVal::ArrayBranch::m_default
T m_default
Default value in cases where the part are not updated.
Definition: ArrayBranch.h:64
MuonVal::ArrayBranch::initialized
bool initialized() const
Is the branch initialized.
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
MuonVal::ArrayBranch::setDefault
void setDefault(const T &val)
MuonVal::ArrayBranch::reset
void reset()
Resets the check mask.
MuonVal::ArrayBranch::tree_data_type
std::string tree_data_type() const
Data type of the branch in the tree.
MuonVal::ArrayBranch
Definition: ArrayBranch.h:14
MuonVal
Class to store array like branches into the n-tuples.
Definition: MuonTPMetaDataAlg.cxx:25
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
MuonVal::ArrayBranch::size
size_t size() const
How large is the array.
MuonTesterBranch.h
MuonVal::ArrayBranch::set
void set(size_t s, const T &val)
Set's the i-th entry of the array to val.
MuonVal::IMuonTesterBranch::name
virtual std::string name() const =0
Returns the name of the branch.
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
MuonVal::ArrayBranch::get
const T & get(size_t s) const
Returns the i-th value.
MuonVal::IMuonTesterBranch
Most basic interface class used by the MuonTester tree.
Definition: IMuonTesterBranch.h:20
MuonVal::ArrayBranch::m_updated
std::vector< bool > m_updated
Definition: ArrayBranch.h:59
MuonVal::ArrayBranch::m_size
size_t m_size
Definition: ArrayBranch.h:57