Belle II Software development
Filter< Belle2::OperatorOr, FilterA, FilterB, templateObserverType > Class Template Reference

Realization of the OR operator between two objects of the Filter class. More...

#include <Filter.h>

Public Types

typedef FilterA::argumentType argumentType
 Handy typedef for arguments type A.
 
typedef FilterB::argumentType argumentTypeB
 Handy typedef for arguments type B.
 
typedef FilterA::functionType functionTypeA
 Handy typedef for function type A.
 
typedef FilterB::functionType functionTypeB
 Handy typedef for function type B.
 
typedef std::enable_if< all_same< functionTypeA, functionTypeB >::value, functionTypeA >::type functionType
 Handy typedef for the combined function type.
 

Public Member Functions

 Filter (const FilterA &filterA, const FilterB &filterB)
 Constructor creating a filter representing the boolean OR combination of two filters.
 
 Filter ()
 Empty constructor.
 
template<typename ... argsType>
std::enable_if< all_same< argumentType, argumentTypeB, argsType... >::value, bool >::type accept (const argsType &... args) const
 The accept method for the combination of two filters with the OR Operator: This will return the combined result of the accept method for the two filters using the OR logic.
 
template<class otherObserver >
Filter< Belle2::OperatorOr, decltype(FilterA().observeLeaf(otherObserver())), decltype(FilterB().observeLeaf(otherObserver())), otherObserver > observe (const otherObserver &) const
 Will set the observer for this and both via the OR operator combined filters it contains, all subsequent Boolean Filters will not be observed (VoidObserver)
 
template<class otherObserver >
Filter< Belle2::OperatorOr, decltype(FilterA().observeLeaf(otherObserver())), decltype(FilterB().observeLeaf(otherObserver())), VoidObserverobserveLeaf (const otherObserver &) const
 Will set the observer for both via the OR operation combined filters it contains, this filter itself will not be observed (VoidObserver).
 
void persist (TTree *t, const std::string &branchName)
 Persist the filter on a TTree.
 
void setBranchAddress (TTree *t, const std::string &branchName)
 Set the Branches addresses to this filter.
 
std::string getNameAndReference (std::vector< std::pair< char, void * > > *pointers=nullptr)
 Getter for name of and reference to the range of the filters.
 

Private Attributes

const char * c_orSuffixA = "_or_A"
 Char suffix to be used in the filter name for ROOT to indicate the filter A of the combination A OR B.
 
const char * c_orSuffixB = "_or_B"
 Char suffix to be used in the filter name for ROOT to indicate the filter B of the combination A OR B.
 
FilterA m_filterA
 Member containing the filter A of the combination A OR B.
 
FilterB m_filterB
 Member containing the filter B of the combination A OR B.
 

Detailed Description

template<class FilterA, class FilterB, class templateObserverType>
class Belle2::Filter< Belle2::OperatorOr, FilterA, FilterB, templateObserverType >

Realization of the OR operator between two objects of the Filter class.

Template Parameters
FilterA: a filter
FilterB: another filter
templateObserverType: the observer type to be used

Definition at line 775 of file Filter.h.

Member Typedef Documentation

◆ argumentType

typedef FilterA::argumentType argumentType

Handy typedef for arguments type A.

Definition at line 783 of file Filter.h.

◆ argumentTypeB

typedef FilterB::argumentType argumentTypeB

Handy typedef for arguments type B.

Definition at line 785 of file Filter.h.

◆ functionType

typedef std::enable_if<all_same<functionTypeA,functionTypeB>::value,functionTypeA>::type functionType

Handy typedef for the combined function type.

Definition at line 791 of file Filter.h.

◆ functionTypeA

typedef FilterA::functionType functionTypeA

Handy typedef for function type A.

Definition at line 787 of file Filter.h.

◆ functionTypeB

typedef FilterB::functionType functionTypeB

Handy typedef for function type B.

Definition at line 789 of file Filter.h.

Constructor & Destructor Documentation

◆ Filter() [1/2]

Filter ( const FilterA &  filterA,
const FilterB &  filterB 
)
inline

Constructor creating a filter representing the boolean OR combination of two filters.

Parameters
filterA: a filter
filterB: another filter

Definition at line 798 of file Filter.h.

798 :
799 m_filterA(filterA), m_filterB(filterB) { };
FilterB m_filterB
Member containing the filter B of the combination A OR B.
Definition: Filter.h:909
FilterA m_filterA
Member containing the filter A of the combination A OR B.
Definition: Filter.h:907

◆ Filter() [2/2]

Filter ( )
inline

Empty constructor.

Definition at line 803 of file Filter.h.

803{ };

Member Function Documentation

◆ accept()

std::enable_if< all_same< argumentType, argumentTypeB, argsType... >::value, bool >::type accept ( const argsType &...  args) const
inline

The accept method for the combination of two filters with the OR Operator: This will return the combined result of the accept method for the two filters using the OR logic.

Template Parameters
argsTypetemplate arguments depending on the filters
Parameters
argsvalues to be tested by the filters
Returns
boolean indicating if one of the filters is passed

Definition at line 815 of file Filter.h.

816 {
817 templateObserverType::prepare(args ...);
818 bool returnValue = m_filterA.accept(args ...) || m_filterB.accept(args ...);
819 templateObserverType::collect(args ...);
820 return returnValue;
821 }

◆ getNameAndReference()

std::string getNameAndReference ( std::vector< std::pair< char, void * > > *  pointers = nullptr)
inline

Getter for name of and reference to the range of the filters.

Calls getNameAndReference of RangeType.

Parameters
pointerspointer to vector of pairs of names of and pointers to the filters
Returns
string containing name of the OR-combined variable and the bounds of the range (see RangeTypes)

Definition at line 900 of file Filter.h.

901 {
902 return "(" + m_filterA.getNameAndReference(pointers) + " OR " + m_filterB.getNameAndReference(pointers) + ")";
903 }

◆ observe()

Filter< Belle2::OperatorOr, decltype(FilterA().observeLeaf(otherObserver())), decltype(FilterB().observeLeaf(otherObserver())), otherObserver > observe ( const otherObserver &  ) const
inline

Will set the observer for this and both via the OR operator combined filters it contains, all subsequent Boolean Filters will not be observed (VoidObserver)

Template Parameters
otherObserver: the new type observer to be used
Returns
filter with the new observer

Definition at line 832 of file Filter.h.

833 {
834 // this will recursively loop over all "and" Filters and set the SAME observer
835 return Filter<Belle2::OperatorOr,
836 decltype(FilterA().observeLeaf(otherObserver())),
837 decltype(FilterB().observeLeaf(otherObserver())),
838 otherObserver>(m_filterA.observeLeaf(otherObserver()), m_filterB.observeLeaf(otherObserver()));
839 }

◆ observeLeaf()

Filter< Belle2::OperatorOr, decltype(FilterA().observeLeaf(otherObserver())), decltype(FilterB().observeLeaf(otherObserver())), VoidObserver > observeLeaf ( const otherObserver &  ) const
inline

Will set the observer for both via the OR operation combined filters it contains, this filter itself will not be observed (VoidObserver).

NOTE: If this function is used on the top level Boolean filter, the whole filter will NOT be observed! See accept function!

Template Parameters
otherObserver: the new observer type to be used
Returns
filter with the new observer

Definition at line 852 of file Filter.h.

853 {
854 // This will recursively loop over all lower level Filters of the AND combination and set the SAME observer.
855 // For the top level filter the void observer is used.
856 return Filter<Belle2::OperatorOr,
857 decltype(FilterA().observeLeaf(otherObserver())),
858 decltype(FilterB().observeLeaf(otherObserver())),
859 VoidObserver>(m_filterA.observeLeaf(otherObserver()), m_filterB.observeLeaf(otherObserver()));
860 }

◆ persist()

void persist ( TTree *  t,
const std::string &  branchName 
)
inline

Persist the filter on a TTree.

Parameters
tis the TTree under which the TBranch will be created
branchNameis the name of the TBranch holding m_range

Definition at line 867 of file Filter.h.

868 {
869 std::string nameOfFilterA(branchName);
870 nameOfFilterA += c_orSuffixA;
871 m_filterA.persist(t, nameOfFilterA);
872
873 std::string nameOfFilterB(branchName);
874 nameOfFilterB += c_orSuffixB;
875 m_filterB.persist(t, nameOfFilterB);
876 }
const char * c_orSuffixB
Char suffix to be used in the filter name for ROOT to indicate the filter B of the combination A OR B...
Definition: Filter.h:779
const char * c_orSuffixA
Char suffix to be used in the filter name for ROOT to indicate the filter A of the combination A OR B...
Definition: Filter.h:777

◆ setBranchAddress()

void setBranchAddress ( TTree *  t,
const std::string &  branchName 
)
inline

Set the Branches addresses to this filter.

Parameters
tis the TTree containing the TBranch
branchNameis the name of the TBranch holding the m_range

Definition at line 883 of file Filter.h.

884 {
885 std::string nameOfFilterA(branchName);
886 nameOfFilterA += c_orSuffixA;
887 m_filterA.setBranchAddress(t, nameOfFilterA);
888
889 std::string nameOfFilterB(branchName);
890 nameOfFilterB += c_orSuffixB;
891 m_filterB.setBranchAddress(t, nameOfFilterB);
892 }

Member Data Documentation

◆ c_orSuffixA

const char* c_orSuffixA = "_or_A"
private

Char suffix to be used in the filter name for ROOT to indicate the filter A of the combination A OR B.

Definition at line 777 of file Filter.h.

◆ c_orSuffixB

const char* c_orSuffixB = "_or_B"
private

Char suffix to be used in the filter name for ROOT to indicate the filter B of the combination A OR B.

Definition at line 779 of file Filter.h.

◆ m_filterA

FilterA m_filterA
private

Member containing the filter A of the combination A OR B.

Definition at line 907 of file Filter.h.

◆ m_filterB

FilterB m_filterB
private

Member containing the filter B of the combination A OR B.

Definition at line 909 of file Filter.h.


The documentation for this class was generated from the following file: