Belle II Software  release-08-01-10
VariableTBranch.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <TTree.h>
12 #include <tracking/trackFindingVXD/filterMap/filterFramework/TBranchLeafType.h>
13 
14 namespace Belle2 {
22  template <class Variable>
25  typename Variable::variableType m_storedValue;
27  TBranch* m_branch;
28  public:
32  explicit VariableTBranch(TTree* tree);
33 
37  void setValue(const typename Variable::variableType& var)
38  { m_storedValue = var;}
39 
44  template<class ... SpacePoints>
45  void evaluateOn(const SpacePoints& ... sps)
46  {
47  m_storedValue = Variable::value(sps ...);
48  }
49  };
50 
52  template <class Variable>
54  {
55  if (tree != nullptr && tree -> GetBranch(Variable::name().c_str()) == nullptr)
56  m_branch = tree->Branch(Variable::name().c_str(), & m_storedValue,
57  TBranchLeafType(m_storedValue));
58  }
60 }
This class contains.
void evaluateOn(const SpacePoints &... sps)
Evaluate the variable for the given SpacePoints.
void setValue(const typename Variable::variableType &var)
Set the value to be stored in the TTree.
TBranch * m_branch
Member for the pointer to the TBranch.
Variable::variableType m_storedValue
The value to be stored in tha branch.
char TBranchLeafType(const char *)
Overloading TBranchLeafType to be able to get identifier 'C' for type char*.
VariableTBranch(TTree *tree)
Add to the TTree.
Abstract base class for different kinds of events.