Belle II Software development
Filter< Variable, RangeType, Observer > Class Template Reference

Basic Filter ///. More...

#include <Filter.h>

Inheritance diagram for Filter< Variable, RangeType, Observer >:
Filter< Variable, RangeType, Belle2::ActivatableFilter, Observer > Filter< Variable, RangeType, Belle2::BypassableFilter, Observer >

Public Types

typedef Variable::argumentType argumentType
 Handy typedef for arguments.
 
typedef Variable::functionType functionType
 Handy typedef for function.
 

Public Member Functions

 Filter (const RangeType &range)
 Constructor.
 
 Filter ()=default
 Empty constructor.
 
RangeType getRange (void) const
 Getter of the range.
 
template<typename ... argsType>
std::enable_if< all_same< argumentType, argsType... >::value, bool >::type accept (const argsType &... args) const
 The accept method of the filter: All the real computations are occuring in this method.
 
void persist (TTree *t, const std::string &branchName)
 Persist the range on a TTree.
 
void setBranchAddress (TTree *t, const std::string &branchName)
 Set the Branches addresses to this filter.
 
Filter< Variable, RangeType, BypassableFilter, Observerbypass (const bool &bypassVariable=false)
 This method creates a new bypassable Filter with the same range of *this E.g.:
 
Filter< Variable, RangeType, ActivatableFilter, Observerenable (const bool &enableVariable=true)
 Create a new activatable filter.
 
template<class otherObserver >
Filter< Variable, RangeType, otherObserver > observeLeaf (const otherObserver &) const
 Function to observer of a filter.
 
template<class otherObserver >
 Filter (const Filter< Variable, RangeType, otherObserver > &filter)
 Copy constructor for filter.
 
std::string getNameAndReference (std::vector< std::pair< char, void * > > *pointers=nullptr)
 Getter for name of and reference to the range of the filters.
 

Protected Attributes

RangeType m_range
 Member range of the filter.
 

Detailed Description

template<class Variable, class RangeType, class Observer>
class Belle2::Filter< Variable, RangeType, Observer >

Basic Filter ///.

Basic building block of the Filter tools Example usage:

#include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariable.h>
#include <tracking/trackFindingVXD/filterMap/filterFramework/UpperBoundedSet.h>
#include <tracking/trackFindingVXD/filterMap/filterFramework/Filter.h>
struct spacePoint{ float x; float y; float z; };
SquaredDistance2D: public SelectionVariable<TSpacePoint> {
value(const TSpacePoint & p1, const TSpacePoint &p2){
return pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2);
}
};
Filter<SquaredDistance2D, UpperBoundedSet, VoidObserver> filter(UpperBoundedSet( 1.1 ));
spacePoint a( {0,0,0} ), b( {1,0,0} );
cout << filter.accept(a,b) << endl;
Base class of the selection variable objects used for pair filtering.
std::map< ExpRun, std::pair< double, double > > filter(const std::map< ExpRun, std::pair< double, double > > &runs, double cut, std::map< ExpRun, std::pair< double, double > > &runsRemoved)
filter events to remove runs shorter than cut, it stores removed runs in runsRemoved
Definition: Splitter.cc:38

will produce the output: true The Variable class will provide the static method value x( arg1, arg2) The RangeType object will provide the method contains to decide if x(arg1, arg2) is good The Observer will be notified of the actions via its static method notify

Definition at line 113 of file Filter.h.

Member Typedef Documentation

◆ argumentType

typedef Variable::argumentType argumentType

Handy typedef for arguments.

Definition at line 116 of file Filter.h.

◆ functionType

typedef Variable::functionType functionType

Handy typedef for function.

Definition at line 119 of file Filter.h.

Constructor & Destructor Documentation

◆ Filter() [1/2]

Filter ( const RangeType &  range)
inlineexplicit

Constructor.

To construct the Filter we need a concrete RangeType. The variable and the observer are passed through the template type pack.

Parameters
rangea class that provides a method contains such as:
bool contains(Variable::returnType x)

Definition at line 128 of file Filter.h.

128 :
129 m_range(range) { };
RangeType m_range
Member range of the filter.
Definition: Filter.h:259

◆ Filter() [2/2]

Filter ( const Filter< Variable, RangeType, otherObserver > &  filter)
inline

Copy constructor for filter.

Template Parameters
otherObserverobserver type
Parameters
filterfilter to be copied

Definition at line 243 of file Filter.h.

243 :
244 m_range(filter.getRange()) {};

Member Function Documentation

◆ accept()

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

The accept method of the filter: All the real computations are occuring in this method.

Template Parameters
argsTypetemplate arguments depending on the filter
Parameters
argsvalues to be tested by the filters
Returns
boolean indicating if filter is passed This typename expands to bool only if all the argsType are of the same type of the argument of the filter

Definition at line 149 of file Filter.h.

150 {
151 typename Variable::variableType value = Variable::value(args ...);
152 Observer::notify(Variable(), value, m_range, args ...);
153 return m_range.contains(value);
154 }
static void notify(T, double, someRangeType, const someHitType &, const someHitType &)
exemplary draft for a notify-function of an observer
Definition: Observer.h:23

◆ bypass()

Filter< Variable, RangeType, BypassableFilter, Observer > bypass ( const bool &  bypassVariable = false)
inline

This method creates a new bypassable Filter with the same range of *this E.g.:

#include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariable.h>
#include <tracking/trackFindingVXD/filterMap/filterFramework/UpperBoundedSet.h>
#include <tracking/trackFindingVXD/filterMap/filterFramework/Filter.h>
struct spacePoint{ float x; float y; float z; };
SquaredDistance2D: public SelectionVariable<TSpacePoint> {
value(const TSpacePoint & p1, const TSpacePoint &p2){
return pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2);
}
};
Filter<SquaredDistance2D, UpperBoundedSet, VoidObserver> filter(UpperBoundedSet( 1.1 ));
bool bypassVariable(false);
auto bypassableFilter( filter.bypass( bypassVariable ) );
spacePoint a( {0,0,0} ), b( {10,0,0} );
cout << bypassableFilter.accept(a,b) << endl;
bypassVariable = true;
cout << bypassableFilter.accept(a,b) << endl;

will produce: false true

Definition at line 208 of file Filter.h.

209 {
210 return Filter<Variable, RangeType, BypassableFilter, Observer>(m_range, bypassVariable);
211 }

◆ enable()

Filter< Variable, RangeType, ActivatableFilter, Observer > enable ( const bool &  enableVariable = true)
inline

Create a new activatable filter.

Parameters
enableVariableIf the filter is active
Returns
filter

Definition at line 220 of file Filter.h.

221 {
222 return Filter<Variable, RangeType, ActivatableFilter, Observer>(m_range, enableVariable);
223 }

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

Definition at line 252 of file Filter.h.

253 {
254 return m_range.getNameAndReference(pointers, Variable::name());
255 }

◆ getRange()

RangeType getRange ( void  ) const
inline

Getter of the range.

Definition at line 136 of file Filter.h.

136{ return m_range; }

◆ observeLeaf()

Filter< Variable, RangeType, otherObserver > observeLeaf ( const otherObserver &  ) const
inline

Function to observer of a filter.

Template Parameters
otherObserverobserver to be used
Returns
filter with the respective observer

Definition at line 232 of file Filter.h.

233 {
234 return Filter<Variable, RangeType, otherObserver>(m_range);
235 }

◆ persist()

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

Persist the range 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 161 of file Filter.h.

162 {
163 m_range.persist(t, branchName, Variable().name());
164 }

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

172 {
173 m_range.setBranchAddress(t, branchName, Variable().name());
174 }

Member Data Documentation

◆ m_range

RangeType m_range
protected

Member range of the filter.

Definition at line 259 of file Filter.h.


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