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

Realization of the AND 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 combined function type.
 

Public Member Functions

 Filter (const FilterA &filterA, const FilterB &filterB)
 Constructor creating a filter representing the boolean AND 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 AND Operator: This will return the combined result of the accept method for the two filters using the AND logic.
 
template<class otherObserver >
Filter< Belle2::OperatorAnd, decltype(FilterA().observeLeaf(otherObserver())), decltype(FilterB().observeLeaf(otherObserver())), otherObserver > observe (const otherObserver &) const
 Will set the observer for this and both of the via the AND operation combined filters it contains.
 
template<class otherObserver >
Filter< Belle2::OperatorAnd, decltype(FilterA().observeLeaf(otherObserver())), decltype(FilterB().observeLeaf(otherObserver())), VoidObserverobserveLeaf (const otherObserver &) const
 will set the observer for the Leaves of this filter, this AND filter will not be observed.
 
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_andSuffixA = "_and_A"
 Char suffix to be used in the filter name for ROOT to indicate the filter A of the combination A AND B.
 
const char * c_andSuffixB = "_and_B"
 Char suffix to be used in the filter name for ROOT to indicate the filter B of the combination A AND B.
 
FilterA m_filterA
 Member containing the filter A of the combination A AND B.
 
FilterB m_filterB
 Member containing the filter B of the combination A AND B.
 

Detailed Description

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

Realization of the AND 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 604 of file Filter.h.

Member Typedef Documentation

◆ argumentType

typedef FilterA::argumentType argumentType

Handy typedef for arguments type A.

Definition at line 611 of file Filter.h.

◆ argumentTypeB

typedef FilterB::argumentType argumentTypeB

Handy typedef for arguments type B.

Definition at line 613 of file Filter.h.

◆ functionType

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

Handy typedef for combined function type.

Definition at line 619 of file Filter.h.

◆ functionTypeA

typedef FilterA::functionType functionTypeA

Handy typedef for function type A.

Definition at line 615 of file Filter.h.

◆ functionTypeB

typedef FilterB::functionType functionTypeB

Handy typedef for function type B.

Definition at line 617 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 AND combination of two filters.

Parameters
filterA: a filter
filterB: another filter

Definition at line 626 of file Filter.h.

626 :
627 m_filterA(filterA), m_filterB(filterB) { };
FilterB m_filterB
Member containing the filter B of the combination A AND B.
Definition: Filter.h:737
FilterA m_filterA
Member containing the filter A of the combination A AND B.
Definition: Filter.h:735

◆ Filter() [2/2]

Filter ( )
inline

Empty constructor.

Definition at line 631 of file Filter.h.

631{ };

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 AND Operator: This will return the combined result of the accept method for the two filters using the AND logic.

Template Parameters
argsTypetemplate arguments depending on the filters
Parameters
argsvalues to be tested by the filters
Returns
boolean indicating if both filters are passed

Definition at line 643 of file Filter.h.

644 {
645 templateObserverType::prepare(args ...);
646 bool returnValue = m_filterA.accept(args ...) && m_filterB.accept(args ...);
647 templateObserverType::collect(args ...);
648 return returnValue;
649 }

◆ 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 AND-combined variable and the bounds of the range (see RangeTypes)

Definition at line 728 of file Filter.h.

729 {
730 return "(" + m_filterA.getNameAndReference(pointers) + " AND " + m_filterB.getNameAndReference(pointers) + ")";
731 }

◆ observe()

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

Will set the observer for this and both of the via the AND operation combined filters it contains.

Only the top level AND filter will have the new observer, all subsequent Boolean filters will NOT be observed (VoidObserver).

Template Parameters
otherObserver
Returns
: filter with the new observer

Definition at line 661 of file Filter.h.

662 {
663 // this will recursively loop over all AND Filters and set the SAME observer
664 return Filter<Belle2::OperatorAnd,
665 decltype(FilterA().observeLeaf(otherObserver())),
666 decltype(FilterB().observeLeaf(otherObserver())),
667 otherObserver>(m_filterA.observeLeaf(otherObserver()), m_filterB.observeLeaf(otherObserver()));
668 }

◆ observeLeaf()

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

will set the observer for the Leaves of this filter, this AND filter will not be observed.

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
Returns
filter with new observer

Definition at line 680 of file Filter.h.

681 {
682 // This will recursively loop over all lower level Filters of the AND combination and set the SAME observer.
683 // For the top level filter the void observer is used.
684 return Filter<Belle2::OperatorAnd,
685 decltype(FilterA().observeLeaf(otherObserver())),
686 decltype(FilterB().observeLeaf(otherObserver())),
687 VoidObserver>(m_filterA.observeLeaf(otherObserver()), m_filterB.observeLeaf(otherObserver()));
688 }

◆ 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 695 of file Filter.h.

696 {
697 std::string nameOfFilterA(branchName);
698 nameOfFilterA += c_andSuffixA;
699 m_filterA.persist(t, nameOfFilterA);
700
701 std::string nameOfFilterB(branchName);
702 nameOfFilterB += c_andSuffixB;
703 m_filterB.persist(t, nameOfFilterB);
704 }
const char * c_andSuffixA
Char suffix to be used in the filter name for ROOT to indicate the filter A of the combination A AND ...
Definition: Filter.h:606
const char * c_andSuffixB
Char suffix to be used in the filter name for ROOT to indicate the filter B of the combination A AND ...
Definition: Filter.h:608

◆ 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 711 of file Filter.h.

712 {
713 std::string nameOfFilterA(branchName);
714 nameOfFilterA += c_andSuffixA;
715 m_filterA.setBranchAddress(t, nameOfFilterA);
716
717 std::string nameOfFilterB(branchName);
718 nameOfFilterB += c_andSuffixB;
719 m_filterB.setBranchAddress(t, nameOfFilterB);
720 }

Member Data Documentation

◆ c_andSuffixA

const char* c_andSuffixA = "_and_A"
private

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

Definition at line 606 of file Filter.h.

◆ c_andSuffixB

const char* c_andSuffixB = "_and_B"
private

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

Definition at line 608 of file Filter.h.

◆ m_filterA

FilterA m_filterA
private

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

Definition at line 735 of file Filter.h.

◆ m_filterB

FilterB m_filterB
private

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

Definition at line 737 of file Filter.h.


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