![]() |
Belle II Software
release-06-01-15
|
This class implements a common way to implement cut/selection functionality for arbitrary objects. More...
#include <GeneralCut.h>
Public Member Functions | |
bool | check (const Object *p) const |
Check if the current cuts are passed by the given object. More... | |
void | print () const |
Print cut tree. | |
std::string | decompile () const |
Do the compilation from a string in return. More... | |
Static Public Member Functions | |
static std::unique_ptr< GeneralCut > | compile (const std::string &cut) |
Creates an instance of a cut and returns a unique_ptr to it, if you need a copy-able object instead you can cast it to a shared_ptr using std::shared_ptr<Variable::Cut>(Cut::compile(cutString)) More... | |
Private Types | |
enum | Operation { EMPTY = 0 , NONE , AND , OR , LT , LE , GT , GE , EQ , NE } |
Enum with the allowed operations of the Cut Tree. | |
typedef AVariableManager::Object | Object |
Object, that can be checked. This depends on the VariableManager, as the returned variables from the manager must calculate their values on pointers of these objects. | |
typedef AVariableManager::Var | Var |
Variable returned by the variable manager. | |
Private Member Functions | |
GeneralCut (std::string str) | |
Constructor of the cut. More... | |
GeneralCut (const GeneralCut &)=delete | |
Delete Copy constructor. | |
GeneralCut & | operator= (const GeneralCut &)=delete |
Delete assign operator. | |
std::string | preprocess (std::string str) const |
Preprocess cut string. More... | |
bool | processLogicConditions (std::string str) |
Look for logical conditions in the given cut string. | |
bool | processBinaryNumericConditions (std::string str) |
Look for numeric binary conditions (e.g. More... | |
bool | processTernaryNumericConditions (std::string str) |
Look for numeric ternary conditions (e.g. More... | |
void | processVariable (const std::string &str) |
Get a variable with the given name from the variable manager using its getVariable(name) function. | |
double | get (const Object *p) const |
Returns stored number or Variable value for the given object. | |
Private Attributes | |
enum Belle2::GeneralCut::Operation | m_operation |
Operation which connects left and right cut. | |
const Var * | m_var |
set if there was a valid variable in this cut | |
double | m_number |
literal number contained in the cut | |
bool | m_isNumeric |
if there was a literal number in this cut | |
std::unique_ptr< GeneralCut > | m_left |
Left-side cut. | |
std::unique_ptr< GeneralCut > | m_right |
Right-side cut. | |
This class implements a common way to implement cut/selection functionality for arbitrary objects.
Every module which wants to perform cuts should use this object. As a parameter the module requires a std::string with the written cut. This std::string has to be passed as an argument to the static Compile method of the Cut class, which returns a unique_ptr to the Cut object. Cuts can be performed via the check method.
Valid cuts can contain:
For example when using the analysis VariableManager for particles, valid cuts are: 1.2 < M < 1.5 daughter0(M) < daughter1(M) [M > 1.5 or M < 0.5] and 0.2 < getExtraInfo(SignalProbability) < 0.7
== and != conditions are evaluated not exactly because we deal with floating point values instead two floating point number are equal if their distance in their integral ordering is less than 3.
The general "Variable Manager" passed as a template argument to this class has to have some properties:
The best example for a VariableManager, that has all these parameters, is probably the analysis VariableManager with VariableManager::var equals to the analysis variable and the VariableManager::Object equal to a Particle. For a more slim example of a valid variable manager, see the generalCut.cc test, where a mock variable manager is created.
Definition at line 91 of file GeneralCut.h.
|
inlineexplicitprivate |
Constructor of the cut.
Call init with given string
str | Cut is initalized with the specified cuts. Default are no cuts |
Definition at line 224 of file GeneralCut.h.
|
inline |
Check if the current cuts are passed by the given object.
p | pointer to the object, that should be checked. All formerly received variables from the variable manager (from the type Var), are asked for their value using var->function(p). |
Definition at line 113 of file GeneralCut.h.
|
inlinestatic |
Creates an instance of a cut and returns a unique_ptr to it, if you need a copy-able object instead you can cast it to a shared_ptr using std::shared_ptr<Variable::Cut>(Cut::compile(cutString))
cut | the string defining the cut |
Definition at line 104 of file GeneralCut.h.
|
inline |
Do the compilation from a string in return.
In principle, compile(decompile()) should give the same result again.
Definition at line 173 of file GeneralCut.h.
|
inlineprivate |
Preprocess cut string.
Trim string and delete global parenthesis
Definition at line 261 of file GeneralCut.h.
|
inlineprivate |
Look for numeric binary conditions (e.g.
1.2 < M ) in the given cut string
Definition at line 301 of file GeneralCut.h.
|
inlineprivate |
Look for numeric ternary conditions (e.g.
1.2 < M < 1.5 ) in the given cut string
Definition at line 347 of file GeneralCut.h.