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

Activatable Filter /// TODO: Remove, as it is no longer used...? More...

#include <Filter.h>

Inheritance diagram for Filter< Variable, RangeType, Belle2::ActivatableFilter, Observer >:
Filter< Variable, RangeType, 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, const bool &enable)
 Constructor.
 
 Filter ()=default
 Empty constructor.
 
template<typename ... argsType>
std::enable_if< all_same< argumentType, argsType... >::value, bool >::type accept (const argsType &... args) const
 The accept method of the activatable filter: All the real computations are occuring in this method.
 
std::string getNameAndReference (std::vector< std::pair< char, void * > > *pointers=nullptr)
 Getter for name of and reference to the range of the filters.
 
RangeType getRange (void) const
 Getter of the range.
 
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.
 

Protected Attributes

RangeType m_range
 Member range of the filter.
 

Private Attributes

const bool * m_enable
 Member pointer to boolean indicating if filters are active (true) or inactive (false).
 

Detailed Description

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

Activatable Filter /// TODO: Remove, as it is no longer used...?

Extended implementation of the Filter tools, adding a boolean to activate the filter. An external bool variable enables or disables the Filter. 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);
}
};
bool enable(false);
Filter<Distance3D, UpperBoundedSet, ActivatableFilter, VoidObserver>
filter(UpperBoundedSet( 1.1 ), enable);
enable = false;
spacePoint a( {0,0,0} ), b( {10,0,0} );
cout << filter.accept(a,b) << endl;
enable = true;
cout << filter.accept(a,b) << endl;
Filter< Variable, RangeType, ActivatableFilter, Observer > enable(const bool &enableVariable=true)
Create a new activatable filter.
Definition: Filter.h:220
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: true false

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

Member Typedef Documentation

◆ argumentType

typedef Variable::argumentType argumentType

Handy typedef for arguments.

Definition at line 416 of file Filter.h.

◆ functionType

typedef Variable::functionType functionType

Handy typedef for function.

Definition at line 418 of file Filter.h.

Constructor & Destructor Documentation

◆ Filter()

Filter ( const RangeType &  range,
const bool &  enable 
)
inline

Constructor.

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

Parameters
rangea class that provides a method contain such as
bool contains(Variable::returnType x)
enableis a bool value controlling the behaviour of accept: if enable is set to true the filter is active and the actual result of the range check accept will be returned, if set to false the filter is inaactive ant the method accept will return always true.

Definition at line 431 of file Filter.h.

431 :
432 Filter<Variable, RangeType, Observer>(range)
433 {
434 m_enable = & enable ;
435 };
const bool * m_enable
Member pointer to boolean indicating if filters are active (true) or inactive (false).
Definition: Filter.h:471

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 activatable 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

Definition at line 449 of file Filter.h.

450 {
451 typename Variable::variableType value = Variable::value(args ...);
452 Observer::notify(Variable(), value, Filter< Variable, RangeType, Observer >::m_range,
453 args ...);
454 return (!(*m_enable)) || Filter<Variable, RangeType, Observer>::m_range.contains(value);
455 }
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)
inlineinherited

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 }
RangeType m_range
Member range of the filter.
Definition: Filter.h:259

◆ enable()

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

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

464 {
465 return "(!(" + std::to_string(*m_enable) + ") OR "
466 + Filter<Variable, RangeType, Observer>::m_range.getNameAndReference(pointers, Variable::name()) + ")";
467 }

◆ getRange()

RangeType getRange ( void  ) const
inlineinherited

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
inlineinherited

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 
)
inlineinherited

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 
)
inlineinherited

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_enable

const bool* m_enable
private

Member pointer to boolean indicating if filters are active (true) or inactive (false).

Definition at line 471 of file Filter.h.

◆ m_range

RangeType m_range
protectedinherited

Member range of the filter.

Definition at line 259 of file Filter.h.


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