Belle II Software  release-05-01-25
VariableTBranch.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Eugenio Paoloni *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <TTree.h>
14 #include <tracking/trackFindingVXD/filterMap/filterFramework/TBranchLeafType.h>
15 
16 namespace Belle2 {
24  template <class Variable>
25  class VariableTBranch {
27  typename Variable::variableType m_storedValue;
29  TBranch* m_branch;
30  public:
34  explicit VariableTBranch(TTree* tree);
35 
39  void setValue(const typename Variable::variableType& var)
40  { m_storedValue = var;}
41 
46  template<class ... SpacePoints>
47  void evaluateOn(const SpacePoints& ... sps)
48  {
49  m_storedValue = Variable::value(sps ...);
50  }
51  };
52 
54  template <class Variable>
56  {
57  if (tree != nullptr && tree -> GetBranch(Variable::name().c_str()) == nullptr)
58  m_branch = tree->Branch(Variable::name().c_str() , & m_storedValue,
59  TBranchLeafType(m_storedValue));
60  }
62 }
Belle2::TBranchLeafType
char TBranchLeafType(const char *)
Overloading TBranchLeafType to be able to get identifier 'C' for type char*.
Definition: TBranchLeafType.h:29
Belle2::VariableTBranch::setValue
void setValue(const typename Variable::variableType &var)
Set the value to be stored in the TTree.
Definition: VariableTBranch.h:47
Belle2::VariableTBranch::m_branch
TBranch * m_branch
Member for the pointer to the TBranch.
Definition: VariableTBranch.h:37
Belle2::VariableTBranch::VariableTBranch
VariableTBranch(TTree *tree)
Add to the TTree.
Definition: VariableTBranch.h:63
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::VariableTBranch::evaluateOn
void evaluateOn(const SpacePoints &... sps)
Evaluate the variable for the given SpacePoints.
Definition: VariableTBranch.h:55
Belle2::VariableTBranch::m_storedValue
Variable::variableType m_storedValue
The value to be stored in tha branch.
Definition: VariableTBranch.h:35