Belle II Software development
SingleElementSet.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 <tracking/trackFindingVXD/filterMap/filterFramework/TBranchLeafType.h>
12#include <TBranch.h>
13#include <TTree.h>
14
15namespace Belle2 {
26 template<typename Type>
30 public:
32 explicit SingleElementSet(Type element): m_element(element) {};
33
39 template< class VariableType >
40 inline bool contains(const VariableType& x) const { return x == m_element;};
41
51 void persist(TTree* t, const std::string& branchName, const std::string& variableName)
52 {
53
54 std::string leafList;
55 leafList += variableName;
56 leafList += "_sup/";
57 leafList += TBranchLeafType(m_element);
58
59 TBranch* branch = new TBranch(t, branchName.c_str(), & m_element, leafList.c_str());
60 t->GetListOfBranches()->Add(branch);
61 }
62
64 Type getElement(void) const { return m_element; } ;
65
71 std::string getNameAndReference(std::vector<std::pair<char, void*>>* pointers = nullptr, const std::string& varname = "x")
72 {
73 std::string val = std::to_string(m_element);
74 // if pointer to vector is provided fill it
75 if (pointers != nullptr) {
76 // use the position in the vector as unique identifier
77 val = "#" + std::to_string(pointers->size());
78 (*pointers).push_back({TBranchLeafType(m_element), &m_element});
79 }
80 return ("(" + val + " == " + varname + ")");
81 }
82 };
84}
Represents a set containing a single element;.
Type getElement(void) const
Accessor to the sup of the set.
void persist(TTree *t, const std::string &branchName, const std::string &variableName)
Creates and sets the addresses of the leaves to store the min and max values.
Type m_element
Member variable for the single element of the set.
std::string getNameAndReference(std::vector< std::pair< char, void * > > *pointers=nullptr, const std::string &varname="x")
generates a "name" and fills the vector with the variable references
SingleElementSet(Type element)
Constructor.
bool contains(const VariableType &x) const
Method used by the filter tools to decide on the fate of the pair.
char TBranchLeafType(const char *)
Overloading TBranchLeafType to be able to get identifier 'C' for type char*.
Abstract base class for different kinds of events.