ATLAS Offline Software
Loading...
Searching...
No Matches
SetBranch.h
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONTESTER_MUONSetBranch_H
5#define MUONTESTER_MUONSetBranch_H
6
8
9// Implementation to store vector like variables
10namespace MuonVal {
11class MuonTesterTree;
12template <class T> class SetBranch : public MuonTesterBranch, virtual public IMuonTesterBranch {
13public:
15 SetBranch(TTree* tree, const std::string& name);
16 SetBranch(MuonTesterTree& tree, const std::string& name);
17
18 virtual ~SetBranch() = default;
21 bool fill(const EventContext& ctx) override;
23 bool init() override;
24
26 inline size_t size() const;
27
29 inline void insert(const T& value);
30 inline void operator+=(const T& value);
31
33 std::set<T>& operator->();
34 std::set<T>& get();
35 const std::set<T>& operator->() const;
36 const std::set<T>& get() const;
38 void operator=(const std::set<T>& other);
39
40 inline friend std::ostream& operator<<(std::ostream& ostr, const SetBranch& br) {
41 ostr<<br.name()<<": ";
42 if (br.isUpdated()){
43 ostr<<br.m_variable;
44 } else ostr<<"{}";
45 return ostr;
46 };
47
48 inline bool isUpdated() const;
49
50private:
51 std::set<T> m_variable{};
52 bool m_updated{false};
53};
54}
56#endif
Most basic interface class used by the MuonTester tree.
virtual std::string name() const =0
Returns the name of the branch.
virtual TTree * tree()=0
Returns the pointer to the underlying TTree object.
MuonTesterBranch(MuonTesterTree &tree, const std::string &br_name)
friend std::ostream & operator<<(std::ostream &ostr, const SetBranch &br)
Definition SetBranch.h:40
const std::set< T > & get() const
bool isUpdated() const
std::set< T > & get()
void operator+=(const T &value)
std::set< T > m_variable
Definition SetBranch.h:51
std::set< T > & operator->()
Getter methods.
size_t size() const
Returns the number of actual saved elements.
void insert(const T &value)
Adds a new element at the end of the vector.
virtual ~SetBranch()=default
const std::set< T > & operator->() const
void operator=(const std::set< T > &other)
Assignment operator.
SetBranch(MuonTesterTree &tree, const std::string &name)
bool fill(const EventContext &ctx) override
Clears vector in cases that it has not been updated in this event Retursn falls if the vector has not...
SetBranch(TTree *tree, const std::string &name)
Standard constructor.
bool init() override
Initialized the Branch.
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19