Belle II Software light-2406-ragdoll
UnaryRelationalNode< AVariableManager > Class Template Reference

Nodeclass with a single AbstractExpressioNode as child. More...

#include <CutNodes.h>

Inheritance diagram for UnaryRelationalNode< AVariableManager >:
Collaboration diagram for UnaryRelationalNode< AVariableManager >:

Public Types

typedef AVariableManager::Var Var
 Template argument dependent Variable type definition.
 

Public Member Functions

bool check (const Object *p) const override
 Evaluate the Expression Node child and assert that it is boolean.
 
void print () const override
 Print node.
 
std::string decompile () const override
 Decompile Node back to a string.
 
 ~UnaryRelationalNode ()
 Destructor.
 

Private Types

typedef AVariableManager::Object Object
 Template argument dependent Particle type definition.
 

Private Member Functions

 UnaryRelationalNode (Nodetuple node)
 Constructor.
 

Private Attributes

std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_enode
 subexpression of a cut
 

Friends

class NodeFactory
 

Detailed Description

template<class AVariableManager>
class Belle2::UnaryRelationalNode< AVariableManager >

Nodeclass with a single AbstractExpressioNode as child.

Allows subexpressions consisting of a single boolean valued expression

Definition at line 351 of file CutNodes.h.

Member Typedef Documentation

◆ Object

typedef AVariableManager::Object Object
private

Template argument dependent Particle type definition.

Definition at line 355 of file CutNodes.h.

◆ Var

typedef AVariableManager::Var Var
inherited

Template argument dependent Variable type definition.

Definition at line 39 of file AbstractNodes.h.

Constructor & Destructor Documentation

◆ ~UnaryRelationalNode()

~UnaryRelationalNode ( )
inline

Destructor.

Definition at line 408 of file CutNodes.h.

408{}

◆ UnaryRelationalNode()

UnaryRelationalNode ( Nodetuple  node)
inlineexplicitprivate

Constructor.

Parameters
node(const boost::python::tuple&) tuple containing an expression node

Definition at line 416 of file CutNodes.h.

416 : m_enode{NodeFactory::compile_expression_node<AVariableManager>(node)}
417 {}
std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_enode
subexpression of a cut
Definition: CutNodes.h:418

Member Function Documentation

◆ check()

bool check ( const Object p) const
inlineoverridevirtual

Evaluate the Expression Node child and assert that it is boolean.

Parameters
ppointer to the object, that should be checked.

Implements AbstractBooleanNode< AVariableManager >.

Definition at line 361 of file CutNodes.h.

362 {
363 typename AVariableManager::VarVariant ret = m_enode->evaluate(p);
364 if (std::holds_alternative<bool>(ret)) {
365 return std::get<bool>(ret);
366 } else if (std::holds_alternative<int>(ret)) {
367 return static_cast<bool>(std::get<int>(ret));
368 } else if (std::holds_alternative<double>(ret)) {
369 if (static_cast<bool>(std::get<double>(ret))) {
370 // nan is considered false.
371 if (std::isnan(std::get<double>(ret))) {
372 return false;
373 }
374 if (std::get<double>(ret) != 1.0)
375 B2WARNING("Static casting of double value to bool in cutstring evaluation." << LogVar("Cut substring",
376 m_enode->decompile()) << LogVar(" Casted value", std::get<double>(ret)) << LogVar("Casted to", "true"));
377 } else {
378 if (std::get<double>(ret) != 0.0)
379 B2WARNING("Static casting of double value to bool in cutstring evaluation." << LogVar("Cut substring",
380 m_enode->decompile()) << LogVar(" Casted value", std::get<double>(ret)) << LogVar("Casted to", "false"));
381 }
382
383 return static_cast<bool>(std::get<double>(ret));
384 } else {
385 throw std::runtime_error("UnaryRelationalNode should evaluate to bool.");
386 }
387 }
Class to store variables with their name which were sent to the logging service.

◆ decompile()

std::string decompile ( ) const
inlineoverridevirtual

Decompile Node back to a string.

decompile(compile) should give the same result.

Implements AbstractBooleanNode< AVariableManager >.

Definition at line 401 of file CutNodes.h.

402 {
403 return m_enode->decompile();
404 }

◆ print()

void print ( ) const
inlineoverridevirtual

Print node.

Implements AbstractBooleanNode< AVariableManager >.

Definition at line 392 of file CutNodes.h.

393 {
394 m_enode->print();
395 }

Friends And Related Function Documentation

◆ NodeFactory

friend class NodeFactory
friend

Definition at line 411 of file CutNodes.h.

Member Data Documentation

◆ m_enode

std::unique_ptr<const AbstractExpressionNode<AVariableManager> > m_enode
private

subexpression of a cut

Definition at line 418 of file CutNodes.h.


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