Belle II Software light-2509-fornax
sk_variables.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#include <gtest/gtest.h>
9#include "utilities/TestParticleFactory.h"
10
11#include <analysis/dataobjects/Particle.h>
12#include <mdst/dataobjects/Track.h>
13#include <mdst/dataobjects/ECLCluster.h>
14#include <framework/datastore/StoreArray.h>
15#include <analysis/utility/PCmsLabTransform.h>
16
17#include <analysis/variables/SpecificKinematicVariables.h>
18#include <analysis/variables/Variables.h>
19
20using namespace std;
21using namespace Belle2;
22using namespace Belle2::Variable;
23using namespace ROOT::Math;
24
25namespace {
26 class SpecificKinematicVariablesTest : public ::testing::Test {
27 protected:
29 void SetUp() override
30 {
31
33 StoreArray<ECLCluster> myECLClusters;
34 StoreArray<TrackFitResult> myTFRs;
35 StoreArray<Track> myTracks;
36 StoreArray<Particle> myParticles;
37 myECLClusters.registerInDataStore();
38 myTFRs.registerInDataStore();
39 myTracks.registerInDataStore();
40 myParticles.registerInDataStore();
42
43 TestUtilities::TestParticleFactory factory;
44 PCmsLabTransform T;
45 PxPyPzEVector b0momentum(.20, 0., 0., 4.85);
46 b0momentum = T.rotateCmsToLab() * b0momentum;
47 PxPyPzEVector pimomentum(0.1, 0, 2.5, sqrt(0.139 * 0.139 + 2.5 * 2.5));
48 PxPyPzEVector emomentum(0., 0, 1., 1.);
49 ROOT::Math::XYZVector ipposition(0, 0, 0);
50 factory.produceParticle(string("^B0 -> pi- e+"), b0momentum, ipposition);
51 myParticles[0]->set4Vector(pimomentum); //pion
52 myParticles[1]->set4Vector(emomentum); //electron
53 }
54
56 void TearDown() override
57 {
59 }
60 };
61
62 TEST_F(SpecificKinematicVariablesTest, REC_q2BhSimple)
63 {
64 StoreArray<Particle> myParticles;
65 B2INFO("Cos: " << cosThetaBetweenParticleAndNominalB(myParticles[2]));
66 EXPECT_FLOAT_EQ(7.90905, REC_q2BhSimple(myParticles[2])); // B-meson
67 }
68 TEST_F(SpecificKinematicVariablesTest, REC_q2Bh)
69 {
70 StoreArray<Particle> myParticles;
71 EXPECT_FLOAT_EQ(7.8716288, REC_q2Bh(myParticles[2])); // B-meson
72 }
73 TEST_F(SpecificKinematicVariablesTest, REC_MissM2)
74 {
75 StoreArray<Particle> myParticles;
76 EXPECT_FLOAT_EQ(0.1534055, REC_MissM2(myParticles[2])); // B-meson
77 }
78
79}
static DataStore & Instance()
Instance of singleton Store.
Definition DataStore.cc:53
void setInitializeActive(bool active)
Setter for m_initializeActive.
Definition DataStore.cc:93
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
Definition DataStore.cc:85
const ROOT::Math::LorentzRotation rotateCmsToLab() const
Returns Lorentz transformation from CMS to Lab.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
const Belle2::Particle * produceParticle(const std::string &decayString, const ROOT::Math::PxPyPzEVector &momentum, const ROOT::Math::XYZVector &vertex)
Main method to produce particles.
Abstract base class for different kinds of events.
STL namespace.