Belle II Software development
variablesOnTTree.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 <gtest/gtest.h>
10#include <tracking/trackFindingVXD/filterMap/filterFramework/Shortcuts.h>
11#include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariable.h>
12#include <tracking/trackFindingVXD/filterMap/filterFramework/Filter.h>
13
14#include <tracking/trackFindingVXD/filterMap/training/VariablesTTree.h>
15#include <TTree.h>
16
17
18namespace Belle2 {
25 SELECTION_VARIABLE(Difference, 2, double,
26 static double value(const double& t1,
27 const double& t2)
28 // cppcheck-suppress unknownMacro
29 { return t1 - t2; };
30 );
31
33 SELECTION_VARIABLE(Sum, 2, double,
34 static double value(const double& t1,
35 const double& t2)
36 { return t1 + t2; };
37 );
38
40 class VariablesOnTTree: public ::testing::Test {
41 protected:
42
43 public:
44 TTree* tree1;
45 TTree* tree2;
46 VariablesOnTTree() : tree1(nullptr), tree2(nullptr)
47 {
48 tree1 = new TTree("t1", "t1");
49 tree2 = new TTree("t2", "t2");
50
51 }
52
54 {
55 delete tree1;
56 delete tree2;
57 }
58 };
59
61 TEST_F(VariablesOnTTree, basic_test)
62 {
63 auto filter1 = 0 < Difference() < 1 && 0 < Sum() < 1;
64 auto variables1 = VariablesTTree<>::build(filter1, tree1);
65
66 auto filter2 = 0 < Difference() < 1 && 0 < Sum() < 1;
67 auto variables2 = VariablesTTree<>::build(filter2, tree2);
68
69 double a(0.), b(1.0);
70 variables1.evaluateOn(a, b);
71 tree1->Fill();
72
73 double c(1.), d(0.0);
74 variables2.evaluateOn(c, d);
75 tree2->Fill();
76
77 tree1->Scan();
78 tree2->Scan();
79 }
81}
Test for VariablesTTree.
TTree * tree2
another TTree
Dump on a TTree the values of all the variables in a filter.
#define SELECTION_VARIABLE(variableName, nArgs, argumentType, implementation)
Template to define a selection-variable class.
Abstract base class for different kinds of events.