ATLAS Offline Software
MuonTesterBranch.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 #include <GaudiKernel/MsgStream.h>
12 
13 #include <functional>
14 
15 #define SET_BRANCHSTRING(theType, thestring) \
16  template <> std::string ArrayBranch<theType>::tree_data_type() const { return thestring; }
17 namespace MuonVal {
18 SET_BRANCHSTRING(Char_t, "/B")
19 SET_BRANCHSTRING(std::string, "/C")
20 SET_BRANCHSTRING(UChar_t, "/b")
21 SET_BRANCHSTRING(Short_t, "/S")
22 SET_BRANCHSTRING(Int_t, "/I")
23 SET_BRANCHSTRING(Long64_t, "/L")
24 SET_BRANCHSTRING(long, "/I")
25 SET_BRANCHSTRING(unsigned long, "/i")
26 SET_BRANCHSTRING(UShort_t, "/s")
27 SET_BRANCHSTRING(UInt_t, "/i")
28 SET_BRANCHSTRING(ULong64_t, "/l")
29 SET_BRANCHSTRING(Float_t, "/F")
30 SET_BRANCHSTRING(Double_t, "/D")
31 SET_BRANCHSTRING(Bool_t, "/o")
32 
34  MuonTesterBranch(tree.tree(), br_name) {
35  m_parent = &tree;
36  m_parent->addBranch(this);
37 }
39  if (!m_parent) {
40  ATH_MSG_WARNING("The parent of " << name() << " is null.");
41  }
42  return *m_parent;
43 }
45  if (m_parent) {
46  m_parent->removeBranch(this);
47  }
48 }
49 MuonTesterBranch::MuonTesterBranch(TTree* tree, const std::string& br_name) :
50  AthMessaging{"MuonTesterBranch"}, m_tree(tree), m_name(br_name) {}
51 std::string MuonTesterBranch::name() const { return m_name; }
52 bool MuonTesterBranch::initialized() const { return m_init; }
53 TTree* MuonTesterBranch::tree() { return m_tree; }
54 const TTree* MuonTesterBranch::tree() const { return m_tree; }
55 
56 std::string MuonTesterBranch::eraseWhiteSpaces(const std::string& In) {
57  std::string out = In;
58  out.erase(std::remove_if(out.begin(), out.end(), isspace), out.end());
59  return out;
60 }
61 std::vector<MuonTesterBranch::DataDependency> MuonTesterBranch::data_dependencies() { return m_dependencies;}
62 
63 template <> bool& VectorBranch<bool>::get(size_t) {
64  THROW_EXCEPTION("For boolean branches the get() operator is cumbersome");
65  return m_default;
66 }
67 }
68 #undef SET_BRANCHSTRING
throwExcept.h
ArrayBranch.h
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
MuonVal::MuonTesterBranch
Definition: MuonTesterBranch.h:21
tree
TChain * tree
Definition: tile_monitor.h:30
MuonVal::MuonTesterBranch::m_dependencies
std::vector< DataDependency > m_dependencies
Definition: MuonTesterBranch.h:62
MuonVal::MuonTesterBranch::m_tree
TTree * m_tree
Definition: MuonTesterBranch.h:58
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
MuonTesterTree.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
MuonVal::MuonTesterBranch::MuonTesterBranch
MuonTesterBranch(MuonTesterTree &tree, const std::string &br_name)
Definition: MuonTesterBranch.cxx:33
THROW_EXCEPTION
#define THROW_EXCEPTION(MSG)
Definition: MMReadoutElement.cxx:48
MuonVal::MuonTesterBranch::tree
TTree * tree() override final
Returns the underlying TTree object.
Definition: MuonTesterBranch.cxx:53
MuonVal::MuonTesterBranch::m_parent
MuonTesterTree * m_parent
Definition: MuonTesterBranch.h:59
VectorBranch.h
MuonVal::MuonTesterBranch::eraseWhiteSpaces
static std::string eraseWhiteSpaces(const std::string &In)
Definition: MuonTesterBranch.cxx:56
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
SET_BRANCHSTRING
#define SET_BRANCHSTRING(theType, thestring)
Definition: MuonTesterBranch.cxx:15
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonVal::MuonTesterBranch::m_init
bool m_init
Definition: MuonTesterBranch.h:61
MuonVal::MuonTesterBranch::name
std::string name() const override final
Returns the name of the branch.
Definition: MuonTesterBranch.cxx:51
ScalarBranch.h
MuonVal
Class to store array like branches into the n-tuples.
Definition: MuonTPMetaDataAlg.cxx:25
MuonTesterBranch.h
MuonVal::MuonTesterBranch::~MuonTesterBranch
virtual ~MuonTesterBranch()
Definition: MuonTesterBranch.cxx:44
MuonVal::MuonTesterBranch::parent
MuonTesterTree & parent()
Returns the reference to the MuonTesterTree parent.
Definition: MuonTesterBranch.cxx:38
MuonVal::MuonTesterBranch::m_name
std::string m_name
Definition: MuonTesterBranch.h:60
MuonVal::MuonTesterBranch::initialized
bool initialized() const
Returns whether the object has been initialized or not The outcome of the variable is bound to a succ...
Definition: MuonTesterBranch.cxx:52
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonVal::VectorBranch::get
T & get(size_t idx)
MuonVal::MuonTesterBranch::data_dependencies
std::vector< DataDependency > data_dependencies() override final
Returns the data dependencies needed by the MuonTesterBranch.
Definition: MuonTesterBranch.cxx:61
MuonVal::MuonTesterTree::removeBranch
void removeBranch(IMuonTesterBranch *branch)
In case instances of a certain branch type are destroyed before hand.
Definition: MuonTesterTree.cxx:83