Belle II Software light-2406-ragdoll
b2variable-cut-parser.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <analysis/VariableManager/Utility.h>
10#include <analysis/dataobjects/Particle.h>
11#include <framework/logging/Logger.h>
12#include <iostream>
13#include <string>
14#include <memory>
15
16using namespace Belle2;
17
18int main()
19{
20 std::string condition;
21 std::cout <<
22 "This program allows you to test variable conditions (see the VariableManager section at https://software.belle2.org/).\n";
23 std::cout << "Please input a condition " << std::flush;
24 std::getline(std::cin, condition);
25 try {
26 std::unique_ptr<Variable::Cut> cut = Variable::Cut::compile(condition);
27 cut->print();
28
29 ROOT::Math::PxPyPzEVector momentum(1, 2, 3, 4);
30 Particle p(momentum, 421);
31 std::cout << "This condition is: " << (cut->check(&p) ? "True" : "False") << std::endl;
32
33 return 0;
34 } catch (std::runtime_error& e) {
35 B2FATAL(e.what());
36 return 1;
37 }
38}
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 y...
Definition: GeneralCut.h:84
Class to store reconstructed particles.
Definition: Particle.h:75
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24