8 #include <gtest/gtest.h>
10 #include <TMatrixFSym.h>
14 #include <analysis/VariableManager/Manager.h>
15 #include <analysis/VariableManager/Utility.h>
17 #include <analysis/dataobjects/Particle.h>
18 #include <analysis/dataobjects/ParticleExtraInfoMap.h>
19 #include <analysis/dataobjects/ParticleList.h>
20 #include <framework/dataobjects/EventExtraInfo.h>
21 #include <analysis/dataobjects/RestOfEvent.h>
22 #include <analysis/utility/ReferenceFrame.h>
23 #include <framework/datastore/StoreArray.h>
24 #include <framework/datastore/StoreObjPtr.h>
25 #include <framework/utilities/TestHelpers.h>
26 #include <framework/logging/Logger.h>
27 #include <framework/gearbox/Gearbox.h>
29 #include <mdst/dataobjects/Track.h>
30 #include <mdst/dataobjects/ECLCluster.h>
31 #include <mdst/dataobjects/KLMCluster.h>
33 #include <analysis/variables/Variables.h>
35 #include "utilities/TestParticleFactory.h"
38 using namespace Belle2::Variable;
43 class InclusiveVariablesTest :
public ::testing::Test {
49 DataStore::Instance().setInitializeActive(
true);
66 DataStore::Instance().setInitializeActive(
false);
69 ROOT::Math::XYZVector ipposition(0, 0, 0);
70 ROOT::Math::PxPyPzEVector b0momentum(3, 0, 0, 5);
71 factory.
produceParticle(
string(
"^B0 -> [^K*0 -> [^K_S0 -> ^pi+ ^pi-] [^pi0 -> ^gamma ^gamma]] ^e+ ^e-"),
72 b0momentum, ipposition);
76 void TearDown()
override
78 DataStore::Instance().reset();
81 TEST_F(InclusiveVariablesTest, nCompositeDaughters)
84 auto* var = Manager::Instance().getVariable(
"nCompositeDaughters()");
85 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 1);
86 var = Manager::Instance().getVariable(
"nCompositeDaughters(313)");
87 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 1);
88 var = Manager::Instance().getVariable(
"nCompositeDaughters(111)");
89 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 0);
90 var = Manager::Instance().getVariable(
"nCompositeDaughters(310)");
91 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 0);
93 TEST_F(InclusiveVariablesTest, nCompositeAllGenerationDaughters)
96 auto* var = Manager::Instance().getVariable(
"nCompositeAllGenerationDaughters()");
97 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 3);
98 var = Manager::Instance().getVariable(
"nCompositeAllGenerationDaughters(313)");
99 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 1);
100 var = Manager::Instance().getVariable(
"nCompositeAllGenerationDaughters(111)");
101 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 1);
102 var = Manager::Instance().getVariable(
"nCompositeAllGenerationDaughters(310)");
103 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 1);
105 TEST_F(InclusiveVariablesTest, nPhotonDaughters)
108 auto* var = Manager::Instance().getVariable(
"nDaughterPhotons");
109 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 2);
111 TEST_F(InclusiveVariablesTest, nDaughterNeutralHadrons)
114 auto* var = Manager::Instance().getVariable(
"nDaughterNeutralHadrons");
115 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 0);
117 TEST_F(InclusiveVariablesTest, nChargedDaughters)
120 auto* var = Manager::Instance().getVariable(
"nDaughterCharged()");
121 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 4);
122 var = Manager::Instance().getVariable(
"nDaughterCharged(11)");
123 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 2);
124 var = Manager::Instance().getVariable(
"nDaughterCharged(211)");
125 EXPECT_EQ(std::get<int>(var->function(myParticles[9])), 2);
128 TEST_F(InclusiveVariablesTest, daughterAverageOf)
131 auto* var = Manager::Instance().getVariable(
"daughterAverageOf(PDG)");
132 EXPECT_FLOAT_EQ(std::get<double>(var->function(myParticles[9])),
float(313 + 11 - 11) / 3);
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
This is a class, which generates DataStore particles, according to the provided decay string e....
const Belle2::Particle * produceParticle(const std::string &decayString, const ROOT::Math::PxPyPzEVector &momentum, const ROOT::Math::XYZVector &vertex)
Main method to produce particles.
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Abstract base class for different kinds of events.