9#include <analysis/variables/Variables.h>
10#include <analysis/variables/BasicParticleInformation.h>
11#include <analysis/variables/VertexVariables.h>
12#include <analysis/variables/PIDVariables.h>
13#include <analysis/variables/TrackVariables.h>
15#include <analysis/VariableManager/Manager.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/utility/ReferenceFrame.h>
23#include <framework/datastore/StoreArray.h>
24#include <framework/datastore/StoreObjPtr.h>
25#include <framework/utilities/TestHelpers.h>
26#include <framework/gearbox/Gearbox.h>
27#include <framework/gearbox/Const.h>
29#include <mdst/dataobjects/MCParticle.h>
30#include <mdst/dataobjects/MCParticleGraph.h>
31#include <mdst/dataobjects/PIDLikelihood.h>
32#include <mdst/dataobjects/Track.h>
33#include <mdst/dataobjects/V0.h>
34#include <mdst/dataobjects/ECLCluster.h>
36#include <gtest/gtest.h>
38#include <TMatrixFSym.h>
40#include <Math/Cartesian2D.h>
41#include <Math/Vector3D.h>
42#include <Math/Vector4D.h>
47using namespace Belle2::Variable;
48using namespace ROOT::Math;
53 TEST(KinematicVariableTest, Variable)
59 gearbox.setBackends({std::string(
"file:")});
61 gearbox.open(
"geometry/Belle2.xml",
false);
64 Particle pH({0.290582573157898, 0, 6.99796952744559, 7.004}, 11);
65 Particle pL({0.166035330010433, 0, -3.99855423973071, 4.002}, -11);
67 Particle p({0, 0.999999869440028, 0, 1.0}, -11);
68 const double eps = 1e-15;
71 EXPECT_NEAR(0.0, particlePx(&pH), eps);
72 EXPECT_NEAR(0.0, particlePy(&pH), eps);
73 EXPECT_NEAR(0.0, particlePx(&pL), eps);
74 EXPECT_NEAR(0.0, particlePy(&pL), eps);
75 EXPECT_FLOAT_EQ(5.289778893721573, particlePz(&pH));
76 EXPECT_FLOAT_EQ(-5.289778893721573, particlePz(&pL));
77 EXPECT_FLOAT_EQ(10.579557836806245064 / 2, particleE(&pH));
78 EXPECT_FLOAT_EQ(10.579557836806245064 / 2, particleE(&pL));
80 EXPECT_FLOAT_EQ(0.999999869440028, particlePy(&p));
84 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
93 p.setMomentumVertexErrorMatrix(error);
95 EXPECT_FLOAT_EQ(0.9, particleP(&p));
96 EXPECT_FLOAT_EQ(1.0, particleE(&p));
97 EXPECT_FLOAT_EQ(0.1, particlePx(&p));
98 EXPECT_FLOAT_EQ(-0.4, particlePy(&p));
99 EXPECT_FLOAT_EQ(0.8, particlePz(&p));
100 EXPECT_FLOAT_EQ(0.412310562, particlePt(&p));
101 EXPECT_FLOAT_EQ(0.8 / 0.9, particleCosTheta(&p));
102 EXPECT_FLOAT_EQ(-1.325817664, particlePhi(&p));
104 EXPECT_FLOAT_EQ(0.737446378, particlePErr(&p));
105 EXPECT_FLOAT_EQ(
sqrt(0.05), particlePxErr(&p));
106 EXPECT_FLOAT_EQ(
sqrt(0.2), particlePyErr(&p));
107 EXPECT_FLOAT_EQ(
sqrt(0.4), particlePzErr(&p));
108 EXPECT_FLOAT_EQ(0.488093530, particlePtErr(&p));
109 EXPECT_FLOAT_EQ(0.156402664, particleCosThetaErr(&p));
110 EXPECT_FLOAT_EQ(0.263066820, particlePhiErr(&p));
115 EXPECT_FLOAT_EQ(0.68174648, particleP(&p));
116 EXPECT_FLOAT_EQ(0.80918372, particleE(&p));
117 EXPECT_FLOAT_EQ(0.058562335, particlePx(&p));
118 EXPECT_FLOAT_EQ(-0.40000001, particlePy(&p));
119 EXPECT_FLOAT_EQ(0.5489524, particlePz(&p));
120 EXPECT_FLOAT_EQ(0.40426421, particlePt(&p));
121 EXPECT_FLOAT_EQ(0.80521482, particleCosTheta(&p));
122 EXPECT_FLOAT_EQ(-1.4254233, particlePhi(&p));
124 EXPECT_FLOAT_EQ(
sqrt(0.2), particlePyErr(&p));
129 EXPECT_ALL_NEAR(particleP(&p), 0.0, 1e-9);
130 EXPECT_FLOAT_EQ(0.4358899, particleE(&p));
131 EXPECT_ALL_NEAR(0.0, particlePx(&p), 1e-9);
132 EXPECT_ALL_NEAR(0.0, particlePy(&p), 1e-9);
133 EXPECT_ALL_NEAR(0.0, particlePz(&p), 1e-9);
134 EXPECT_ALL_NEAR(0.0, particlePt(&p), 1e-9);
140 EXPECT_FLOAT_EQ(0.9, particleP(&p));
141 EXPECT_FLOAT_EQ(1.0, particleE(&p));
142 EXPECT_FLOAT_EQ(0.1, particlePx(&p));
143 EXPECT_FLOAT_EQ(-0.4, particlePy(&p));
144 EXPECT_FLOAT_EQ(0.8, particlePz(&p));
145 EXPECT_FLOAT_EQ(0.412310562, particlePt(&p));
146 EXPECT_FLOAT_EQ(0.8 / 0.9, particleCosTheta(&p));
147 EXPECT_FLOAT_EQ(-1.325817664, particlePhi(&p));
149 EXPECT_FLOAT_EQ(0.737446378, particlePErr(&p));
150 EXPECT_FLOAT_EQ(
sqrt(0.05), particlePxErr(&p));
151 EXPECT_FLOAT_EQ(
sqrt(0.2), particlePyErr(&p));
152 EXPECT_FLOAT_EQ(
sqrt(0.4), particlePzErr(&p));
153 EXPECT_FLOAT_EQ(0.488093530, particlePtErr(&p));
154 EXPECT_FLOAT_EQ(0.156402664, particleCosThetaErr(&p));
155 EXPECT_FLOAT_EQ(0.263066820, particlePhiErr(&p));
160 EXPECT_FLOAT_EQ(0.9, particleP(&p));
161 EXPECT_FLOAT_EQ(1.0, particleE(&p));
162 EXPECT_FLOAT_EQ(0.1, particlePx(&p));
163 EXPECT_FLOAT_EQ(-0.4, particlePy(&p));
164 EXPECT_FLOAT_EQ(0.8, particlePz(&p));
165 EXPECT_FLOAT_EQ(0.412310562, particlePt(&p));
166 EXPECT_FLOAT_EQ(0.8 / 0.9, particleCosTheta(&p));
167 EXPECT_FLOAT_EQ(-1.325817664, particlePhi(&p));
169 EXPECT_FLOAT_EQ(0.737446378, particlePErr(&p));
170 EXPECT_FLOAT_EQ(
sqrt(0.05), particlePxErr(&p));
171 EXPECT_FLOAT_EQ(
sqrt(0.2), particlePyErr(&p));
172 EXPECT_FLOAT_EQ(
sqrt(0.4), particlePzErr(&p));
173 EXPECT_FLOAT_EQ(0.488093530, particlePtErr(&p));
174 EXPECT_FLOAT_EQ(0.156402664, particleCosThetaErr(&p));
175 EXPECT_FLOAT_EQ(0.263066820, particlePhiErr(&p));
178 EXPECT_FLOAT_EQ(-0.1, frame.getMomentumErrorMatrix(&p)(0, 1));
179 EXPECT_FLOAT_EQ(0.9, frame.getMomentumErrorMatrix(&p)(0, 2));
184 EXPECT_FLOAT_EQ(0.9, particleP(&p));
185 EXPECT_FLOAT_EQ(1.0, particleE(&p));
186 EXPECT_FLOAT_EQ(0.1, particlePx(&p));
187 EXPECT_FLOAT_EQ(-0.8, particlePy(&p));
188 EXPECT_FLOAT_EQ(-0.4, particlePz(&p));
190 EXPECT_FLOAT_EQ(0.737446378, particlePErr(&p));
191 EXPECT_FLOAT_EQ(
sqrt(0.05), particlePxErr(&p));
192 EXPECT_FLOAT_EQ(
sqrt(0.4), particlePyErr(&p));
193 EXPECT_FLOAT_EQ(
sqrt(0.2), particlePzErr(&p));
196 EXPECT_FLOAT_EQ(-0.9, frame.getMomentumErrorMatrix(&p)(0, 1));
197 EXPECT_FLOAT_EQ(-0.1, frame.getMomentumErrorMatrix(&p)(0, 2));
202 EXPECT_FLOAT_EQ(0.68174648, particleP(&p));
203 EXPECT_FLOAT_EQ(0.80918372, particleE(&p));
204 EXPECT_FLOAT_EQ(0.058562335, particlePx(&p));
205 EXPECT_FLOAT_EQ(-0.40000001, particlePy(&p));
206 EXPECT_FLOAT_EQ(0.5489524, particlePz(&p));
207 EXPECT_FLOAT_EQ(0.40426421, particlePt(&p));
208 EXPECT_FLOAT_EQ(0.80521482, particleCosTheta(&p));
209 EXPECT_FLOAT_EQ(-1.4254233, particlePhi(&p));
211 EXPECT_FLOAT_EQ(
sqrt(0.2), particlePyErr(&p));
215 Particle pinv({ -0.1, 0.4, -0.8, 1.0 }, 411);
217 Particle p2({ 0.0, 0.0, 0.0, 0.4358899}, 411);
218 EXPECT_FLOAT_EQ(0.9, particleP(&p2));
219 EXPECT_FLOAT_EQ(1.0, particleE(&p2));
220 EXPECT_FLOAT_EQ(0.1, particlePx(&p2));
221 EXPECT_FLOAT_EQ(-0.4, particlePy(&p2));
222 EXPECT_FLOAT_EQ(0.8, particlePz(&p2));
223 EXPECT_FLOAT_EQ(0.412310562, particlePt(&p2));
224 EXPECT_FLOAT_EQ(0.8 / 0.9, particleCosTheta(&p2));
225 EXPECT_FLOAT_EQ(-1.325817664, particlePhi(&p2));
230 Particle p({ 0.0, 0.0, 0.0, 0.0 }, 411);
231 EXPECT_FLOAT_EQ(0.0, particleP(&p));
232 EXPECT_FLOAT_EQ(0.0, particleE(&p));
233 EXPECT_FLOAT_EQ(0.0, particlePx(&p));
234 EXPECT_FLOAT_EQ(0.0, particlePy(&p));
235 EXPECT_FLOAT_EQ(0.0, particlePz(&p));
236 EXPECT_FLOAT_EQ(0.0, particlePt(&p));
237 EXPECT_FLOAT_EQ(1.0, particleCosTheta(&p));
238 EXPECT_FLOAT_EQ(0.0, particlePhi(&p));
241 EXPECT_FLOAT_EQ(0.0, particleP(&p));
242 EXPECT_FLOAT_EQ(0.0, particleE(&p));
243 EXPECT_FLOAT_EQ(0.0, particlePx(&p));
244 EXPECT_FLOAT_EQ(0.0, particlePy(&p));
245 EXPECT_FLOAT_EQ(0.0, particlePz(&p));
246 EXPECT_FLOAT_EQ(0.0, particlePt(&p));
247 EXPECT_FLOAT_EQ(1.0, particleCosTheta(&p));
248 EXPECT_FLOAT_EQ(0.0, particlePhi(&p));
254 particles.registerInDataStore();
258 PxPyPzEVector vec1 = {0.0, +0.332174566, 0.0, T.
getCMSEnergy() / 2.};
259 PxPyPzEVector vec2 = {0.0, -0.332174566, 0.0, T.
getCMSEnergy() / 2.};
267 EXPECT_ALL_NEAR(m2RecoilSignalSide(p0), 0.0, 1e-7);
274 TEST(VertexVariableTest, Variable)
280 gearbox.setBackends({std::string(
"file:")});
282 gearbox.open(
"geometry/Belle2.xml",
false);
284 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 11);
286 p.setVertex(XYZVector(1.0, 2.0, 2.0));
288 EXPECT_FLOAT_EQ(1.0, particleDX(&p));
289 EXPECT_FLOAT_EQ(2.0, particleDY(&p));
290 EXPECT_FLOAT_EQ(2.0, particleDZ(&p));
291 EXPECT_FLOAT_EQ(std::sqrt(5.0), particleDRho(&p));
292 EXPECT_FLOAT_EQ(3.0, particleDistance(&p));
293 EXPECT_FLOAT_EQ(0.5, particlePvalue(&p));
297 EXPECT_FLOAT_EQ(1.026177, particleDX(&p));
298 EXPECT_FLOAT_EQ(2.0, particleDY(&p));
299 EXPECT_FLOAT_EQ(2.2568872, particleDZ(&p));
300 EXPECT_FLOAT_EQ(hypot(2.0, 1.026177), particleDRho(&p));
301 EXPECT_FLOAT_EQ(3.1853695, particleDistance(&p));
302 EXPECT_FLOAT_EQ(0.5, particlePvalue(&p));
306 Particle p2({ 0.1, -0.4, 0.8, 1.0 }, 11);
308 p2.setVertex(XYZVector(1.0, 2.0, 2.0));
311 EXPECT_FLOAT_EQ(0.0, particleDX(&p));
312 EXPECT_FLOAT_EQ(0.0, particleDY(&p));
313 EXPECT_FLOAT_EQ(0.0, particleDZ(&p));
314 EXPECT_FLOAT_EQ(0.0, particleDRho(&p));
315 EXPECT_FLOAT_EQ(0.0, particleDistance(&p));
316 EXPECT_FLOAT_EQ(0.5, particlePvalue(&p));
339 TEST(TrackVariablesTest, Variable)
354 const float pValue = 0.5;
355 const float bField = 1.5;
360 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
361 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
362 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
365 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
366 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
368 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
382 EXPECT_TRUE(std::get<bool>(vIsFromTrack->
function(part)));
383 EXPECT_FALSE(std::get<bool>(vIsFromECL->
function(part)));
384 EXPECT_FALSE(std::get<bool>(vIsFromKLM->
function(part)));
385 EXPECT_FALSE(std::get<bool>(vIsFromV0->
function(part)));
386 EXPECT_FLOAT_EQ(0.5, trackPValue(part));
387 EXPECT_FLOAT_EQ(position.Z(), trackZ0(part));
388 EXPECT_FLOAT_EQ(position.Rho(), trackD0(part));
389 EXPECT_FLOAT_EQ(particleDRho(part), std::fabs(trackD0FromIP(part)));
390 EXPECT_FLOAT_EQ(particleDZ(part), trackZ0FromIP(part));
391 EXPECT_FLOAT_EQ(3, trackNCDCHits(part));
392 EXPECT_FLOAT_EQ(24, trackNSVDHits(part));
393 EXPECT_FLOAT_EQ(12, trackNPXDHits(part));
397 myResults.
appendNew(position, momentum, cov6, charge * -1,
403 myV0s.
appendNew(
V0(std::pair(savedTrack, myResults[0]), std::pair(savedTrack2, myResults[1]), 0.0, 0.0, 0.0));
404 const PxPyPzEVector v0Momentum(2 * momentum.X(), 2 * momentum.Y(), 2 * momentum.Z(), (momentum * 2).R());
405 auto v0particle = myParticles.
appendNew(v0Momentum, 22,
407 v0particle->appendDaughter(0,
false);
408 v0particle->appendDaughter(1,
false);
411 EXPECT_FALSE(std::get<bool>(vIsFromTrack->
function(v0particle)));
412 EXPECT_FALSE(std::get<bool>(vIsFromECL->
function(v0particle)));
413 EXPECT_FALSE(std::get<bool>(vIsFromKLM->
function(v0particle)));
414 EXPECT_TRUE(std::get<bool>(vIsFromV0->
function(v0particle)));
417 EXPECT_EQ(std::get<int>(vNDaughters->
function(v0particle)), 2);
420 class MCTruthVariablesTest :
public ::testing::Test {
438 tracks.registerInDataStore();
440 particles.registerInDataStore();
444 tracks.registerRelationTo(mcparticles);
445 particles.registerRelationTo(mcparticles);
449 tracks.registerRelationTo(clusters);
474 cl0->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
475 cl0->setClusterId(0);
479 cl1->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
480 cl1->setClusterId(1);
485 ROOT::Math::XYZVector(), ROOT::Math::XYZVector(), cov, -1,
Const::electron, 0.5, 1.5,
486 static_cast<unsigned long long int>(0x300000000000000), 16777215, 0);
487 auto* electron_tr = tracks.appendNew(
Track());
489 electron_tr->addRelationTo(cl1);
493 ROOT::Math::XYZVector(), ROOT::Math::XYZVector(), cov1, -1,
Const::pion, 0.51, 1.5,
494 static_cast<unsigned long long int>(0x300000000000000), 16777215, 0);
495 auto* pion_tr = tracks.appendNew(
Track());
497 pion_tr->addRelationTo(cl1);
500 cl0->addRelationTo(true_photon, 12.3);
501 cl0->addRelationTo(true_electron, 2.3);
502 cl1->addRelationTo(true_electron, 45.6);
503 cl1->addRelationTo(true_photon, 5.6);
504 cl1->addRelationTo(true_pion, 15.6);
506 electron_tr->addRelationTo(true_electron);
507 pion_tr->addRelationTo(true_pion);
510 const auto* photon = particles.appendNew(
Particle(cl0));
513 const auto* misid_photon = particles.appendNew(
Particle(cl1));
516 photon->addRelationTo(true_photon);
517 electron->addRelationTo(true_electron);
518 pion->addRelationTo(true_pion);
519 misid_photon->addRelationTo(true_electron);
522 virtual void TearDown()
528 TEST_F(MCTruthVariablesTest, mcCosThetaBetweenParticleAndNominalB)
534 particles.registerInDataStore();
536 particles.registerRelationTo(mcParticles);
549 graphParticleDaughter1.
comesFrom(graphParticleMother);
550 graphParticleDaughter2.
comesFrom(graphParticleMother);
551 graphParticleGranddaughter1.
comesFrom(graphParticleDaughter1);
552 graphParticleGranddaughter2.
comesFrom(graphParticleDaughter1);
553 graphParticleGranddaughter3.
comesFrom(graphParticleDaughter1);
555 graphParticleMother.
setPDG(-521);
556 graphParticleDaughter1.
setPDG(421);
560 graphParticleGranddaughter3.
setPDG(12);
567 graphParticleMother.
setMass(16.55294535724685);
570 PxPyPzEVector dummyP4(1, 2, 1, 5);
571 double dummyM = 4.3589;
573 graphParticleDaughter1.
setMass(dummyM);
575 graphParticleDaughter2.
setMass(dummyM);
576 graphParticleGranddaughter1.
set4Vector(dummyP4);
577 graphParticleGranddaughter1.
setMass(dummyM);
578 graphParticleGranddaughter2.
set4Vector(dummyP4);
579 graphParticleGranddaughter2.
setMass(dummyM);
584 auto* pMother = particles.appendNew(dummyP4, -521);
585 pMother->addRelationTo(mcParticles[0]);
587 particles.appendNew(dummyP4, 421)->addRelationTo(mcParticles[1]);
588 particles.appendNew(dummyP4, -211)->addRelationTo(mcParticles[2]);
589 particles.appendNew(dummyP4, -321)->addRelationTo(mcParticles[3]);
590 particles.appendNew(dummyP4, -11)->addRelationTo(mcParticles[4]);
591 particles.appendNew(dummyP4, 12)->addRelationTo(mcParticles[5]);
594 double M_B = pMother->getPDGMass();
595 double p_B = std::sqrt(E_B * E_B - M_B * M_B);
598 double E_Y = p4_Y_CMS.E();
599 double p_Y = p4_Y_CMS.P();
600 double M_Y = p4_Y_CMS.M();
602 double expectedCosBY = (2 * E_B * E_Y - M_B * M_B - M_Y * M_Y) / (2 * p_B * p_Y);
606 EXPECT_NEAR(std::get<double>(mcCosBY->function(pMother)), expectedCosBY, 1e-4);
609 TEST_F(MCTruthVariablesTest, ECLMCMatchWeightVariable)
612 const auto* photon = particles[0];
613 const auto* electron = particles[1];
614 const auto* pion = particles[2];
617 EXPECT_FLOAT_EQ(std::get<double>(weight->function(photon)), 12.3);
618 EXPECT_FLOAT_EQ(std::get<double>(weight->function(electron)), 45.6);
619 EXPECT_FLOAT_EQ(std::get<double>(weight->function(pion)), 15.6);
622 TEST_F(MCTruthVariablesTest, ECLBestMCMatchVariables)
625 const auto* photon = particles[0];
626 const auto* electron = particles[1];
627 const auto* pion = particles[2];
628 const auto* misid_photon = particles[3];
638 EXPECT_FLOAT_EQ(std::get<double>(weight->function(photon)), 12.3);
639 EXPECT_FLOAT_EQ(std::get<double>(weight->function(electron)), 45.6);
640 EXPECT_FLOAT_EQ(std::get<double>(weight->function(pion)), 45.6);
641 EXPECT_FLOAT_EQ(std::get<double>(weight->function(misid_photon)), 45.6);
645 class EventVariableTest :
public ::testing::Test {
648 void SetUp()
override
658 void TearDown()
override
664 TEST_F(EventVariableTest, ExperimentRunEventDateAndTime)
674 EXPECT_FALSE(std::get<double>(date->function(
nullptr)) == std::get<double>(date->function(
nullptr)));
675 EXPECT_FALSE(std::get<double>(year->
function(
nullptr)) == std::get<double>(year->
function(
nullptr)));
676 EXPECT_FALSE(std::get<double>(time->function(
nullptr)) == std::get<double>(time->function(
nullptr)));
683 evtMetaData->setExperiment(1337);
684 evtMetaData->setRun(12345);
685 evtMetaData->setEvent(54321);
686 evtMetaData->setTime(1288569600e9);
691 EXPECT_EQ(std::get<int>(exp->function(
nullptr)), 1337);
692 EXPECT_EQ(std::get<int>(run->function(
nullptr)), 12345);
693 EXPECT_EQ(std::get<int>(evt->
function(
nullptr)), 54321);
694 EXPECT_FLOAT_EQ(std::get<double>(date->function(
nullptr)), 20101101.);
695 EXPECT_FLOAT_EQ(std::get<double>(year->
function(
nullptr)), 2010.);
696 EXPECT_FLOAT_EQ(std::get<double>(time->function(
nullptr)), 1288569600);
699 TEST_F(EventVariableTest, TestGlobalCounters)
703 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 0);
705 for (
unsigned i = 0; i < 10; ++i)
708 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 10);
713 TEST_F(EventVariableTest, TestIfContinuumEvent_ForContinuumEvent)
718 particles.registerRelationTo(mcParticles);
721 auto* mcParticle = mcParticles.
appendNew();
724 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
725 p1->addRelationTo(mcParticle);
730 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
731 p2->addRelationTo(mcParticle);
734 ASSERT_NE(var,
nullptr);
735 EXPECT_TRUE(std::get<bool>(var->function(p1)));
736 EXPECT_TRUE(std::get<bool>(var->function(p2)));
738 ASSERT_NE(varN,
nullptr);
739 EXPECT_FALSE(std::get<bool>(varN->
function(p1)));
740 EXPECT_FALSE(std::get<bool>(varN->
function(p2)));
743 TEST_F(EventVariableTest, TestIfContinuumEvent_ForUpsilon4SEvent)
751 auto* mcParticle = mcParticles2.
appendNew();
754 auto* p3 = particles2.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
755 p3->addRelationTo(mcParticle);
758 mcParticle->setPDG(300553);
760 auto* p4 = particles2.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 300553);
761 p4->addRelationTo(mcParticle);
764 ASSERT_NE(var2,
nullptr);
765 EXPECT_FALSE(std::get<bool>(var2->
function(p3)));
766 EXPECT_FALSE(std::get<bool>(var2->
function(p4)));
768 ASSERT_NE(var2N,
nullptr);
769 EXPECT_TRUE(std::get<bool>(var2N->
function(p3)));
770 EXPECT_TRUE(std::get<bool>(var2N->
function(p4)));
773 TEST_F(EventVariableTest, TestIfContinuumEvent_ForWrongReconstructedUpsilon4SEvent)
781 auto* mcParticle = mcParticles3.
appendNew();
784 auto* p5 = particles3.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
785 p5->addRelationTo(mcParticle);
788 mcParticle->setPDG(300553);
790 auto* p6 = particles3.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 15);
791 p6->addRelationTo(mcParticle);
794 ASSERT_NE(var3,
nullptr);
795 EXPECT_FALSE(std::get<bool>(var3->
function(p5)));
796 EXPECT_FALSE(std::get<bool>(var3->
function(p6)));
798 ASSERT_NE(var3N,
nullptr);
799 EXPECT_TRUE(std::get<bool>(var3N->
function(p5)));
800 EXPECT_TRUE(std::get<bool>(var3N->
function(p6)));
804 class MetaVariableTest :
public ::testing::Test {
807 void SetUp()
override
818 void TearDown()
override
824 TEST_F(MetaVariableTest, countDaughters)
826 PxPyPzEVector momentum;
827 const int nDaughters = 6;
829 std::vector<int> daughterIndices;
830 for (
int i = 0; i < nDaughters; i++) {
831 Particle d(PxPyPzEVector(1, 0, 0, 3.0), (i % 2) ? 211 : -211);
832 momentum += d.get4Vector();
833 Particle* newDaughters = particles.appendNew(d);
839 ASSERT_NE(var,
nullptr);
840 EXPECT_EQ(std::get<int>(var->function(p)), 3);
843 ASSERT_NE(var,
nullptr);
844 EXPECT_EQ(std::get<int>(var->function(p)), 6);
848 TEST_F(MetaVariableTest, useRestFrame)
851 gearbox.setBackends({std::string(
"file:")});
853 gearbox.open(
"geometry/Belle2.xml",
false);
855 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
856 p.setVertex(XYZVector(1.0, 2.0, 2.0));
859 ASSERT_NE(var,
nullptr);
860 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
863 ASSERT_NE(var,
nullptr);
864 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
867 ASSERT_NE(var,
nullptr);
868 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
871 ASSERT_NE(var,
nullptr);
872 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.0, 1e-9);
875 ASSERT_NE(var,
nullptr);
876 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.4358899);
879 ASSERT_NE(var,
nullptr);
880 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.0);
883 TEST_F(MetaVariableTest, useLabFrame)
885 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
886 p.setVertex(XYZVector(1.0, 2.0, 2.0));
889 ASSERT_NE(var,
nullptr);
890 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
893 ASSERT_NE(var,
nullptr);
894 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
897 ASSERT_NE(var,
nullptr);
898 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
901 ASSERT_NE(var,
nullptr);
902 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
905 ASSERT_NE(var,
nullptr);
906 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
909 ASSERT_NE(var,
nullptr);
910 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
913 TEST_F(MetaVariableTest, useCMSFrame)
916 gearbox.setBackends({std::string(
"file:")});
918 gearbox.open(
"geometry/Belle2.xml",
false);
920 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
921 p.setVertex(XYZVector(1.0, 2.0, 2.0));
924 ASSERT_NE(var,
nullptr);
925 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
928 ASSERT_NE(var,
nullptr);
929 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
932 ASSERT_NE(var,
nullptr);
933 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
936 ASSERT_NE(var,
nullptr);
937 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.68174650327489894064);
940 ASSERT_NE(var,
nullptr);
941 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.80918372124478121776);
944 ASSERT_NE(var,
nullptr);
945 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.1853695);
948 TEST_F(MetaVariableTest, useTagSideRecoilRestFrame)
952 particles.registerInDataStore();
956 PxPyPzEVector vec1 = {0.0, +0.332174566, 0.0, T.
getCMSEnergy() / 2.};
957 PxPyPzEVector vec2 = {0.0, -0.332174566, 0.0, T.
getCMSEnergy() / 2.};
966 ASSERT_NE(var,
nullptr);
967 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
970 ASSERT_NE(var,
nullptr);
971 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
974 ASSERT_NE(var,
nullptr);
975 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
978 ASSERT_NE(var,
nullptr);
979 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
982 ASSERT_NE(var,
nullptr);
983 EXPECT_NEAR(std::get<double>(var->function(p0)), p1->getMass(), 1e-6);
986 TEST_F(MetaVariableTest, useMCancestorBRestFrame)
991 particles.registerInDataStore();
993 particles.registerRelationTo(mcparticles);
1002 Particle particle({ 0.1, -0.4, 0.8, 1.0 }, 411);
1003 auto* p = particles.appendNew(particle);
1004 p->setVertex(XYZVector(1.0, 2.0, 2.0));
1005 p->addRelationTo(mcparticles[1]);
1007 mcparticles[1]->setPDG(411);
1010 mcparticles[0]->setMomentum(XYZVector(0.0, 0.0, 0.1));
1012 mcparticles[0]->setPDG(511);
1013 mcparticles[0]->setMassFromPDG();
1017 ASSERT_NE(var,
nullptr);
1018 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0.88333338);
1021 ASSERT_NE(var,
nullptr);
1022 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0.98502684);
1025 ASSERT_NE(var,
nullptr);
1026 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 3.0007174);
1029 TEST_F(MetaVariableTest, extraInfo)
1031 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 11);
1032 p.addExtraInfo(
"pi", 3.14);
1035 ASSERT_NE(var,
nullptr);
1036 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.14);
1039 EXPECT_TRUE(std::isnan(std::get<double>(var->function(
nullptr))));
1042 TEST_F(MetaVariableTest, eventExtraInfo)
1045 if (not eventExtraInfo.isValid())
1046 eventExtraInfo.create();
1047 eventExtraInfo->addExtraInfo(
"pi", 3.14);
1049 ASSERT_NE(var,
nullptr);
1050 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1053 TEST_F(MetaVariableTest, eventCached)
1056 ASSERT_NE(var,
nullptr);
1057 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1059 EXPECT_TRUE(eventExtraInfo.isValid());
1060 EXPECT_TRUE(eventExtraInfo->hasExtraInfo(
"__constant__bo3__pt14__bc"));
1061 EXPECT_FLOAT_EQ(eventExtraInfo->getExtraInfo(
"__constant__bo3__pt14__bc"), 3.14);
1062 eventExtraInfo->addExtraInfo(
"__eventExtraInfo__bopi__bc", 3.14);
1064 ASSERT_NE(var,
nullptr);
1065 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1068 TEST_F(MetaVariableTest, particleCached)
1070 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1072 ASSERT_NE(var,
nullptr);
1073 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
1074 EXPECT_TRUE(p.hasExtraInfo(
"__px"));
1075 EXPECT_FLOAT_EQ(p.getExtraInfo(
"__px"), 0.1);
1076 p.addExtraInfo(
"__py", -0.5);
1078 ASSERT_NE(var,
nullptr);
1079 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.5);
1082 TEST_F(MetaVariableTest, basicMathTest)
1084 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1087 ASSERT_NE(var,
nullptr);
1088 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.4);
1091 ASSERT_NE(var,
nullptr);
1092 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.8);
1095 ASSERT_NE(var,
nullptr);
1096 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 2.0);
1099 ASSERT_NE(var,
nullptr);
1100 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1104 ASSERT_NE(var,
nullptr);
1105 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1109 ASSERT_NE(var,
nullptr);
1110 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1114 ASSERT_NE(var,
nullptr);
1115 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.5707963267948966);
1119 ASSERT_NE(var,
nullptr);
1120 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1124 ASSERT_NE(var,
nullptr);
1125 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.5707963267948966);
1129 TEST_F(MetaVariableTest, formula)
1136 Particle p({ 0.1, -0.4, 0.8, 2.0 }, -411);
1139 ASSERT_NE(var,
nullptr);
1140 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.3);
1143 ASSERT_NE(var,
nullptr);
1144 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1147 ASSERT_NE(var,
nullptr);
1148 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.04);
1151 ASSERT_NE(var,
nullptr);
1152 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -4.0);
1155 ASSERT_NE(var,
nullptr);
1156 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.01);
1159 ASSERT_NE(var,
nullptr);
1160 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1163 ASSERT_NE(var,
nullptr);
1164 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1167 ASSERT_NE(var,
nullptr);
1168 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.41231057);
1169 double pt = std::get<double>(var->function(&p));
1172 ASSERT_NE(var,
nullptr);
1173 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), pt);
1176 ASSERT_NE(var,
nullptr);
1177 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1180 ASSERT_NE(var,
nullptr);
1181 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1184 ASSERT_NE(var,
nullptr);
1185 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1188 ASSERT_NE(var,
nullptr);
1189 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 411.0);
1192 ASSERT_NE(var,
nullptr);
1193 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -168921.0);
1196 ASSERT_NE(var,
nullptr);
1197 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 8.33);
1200 ASSERT_NE(var,
nullptr);
1201 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -8.33);
1204 ASSERT_NE(var,
nullptr);
1205 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 411);
1208 TEST_F(MetaVariableTest, passesCut)
1210 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1211 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 411);
1214 ASSERT_NE(var,
nullptr);
1215 EXPECT_TRUE(std::get<bool>(var->function(&p)));
1216 EXPECT_FALSE(std::get<bool>(var->function(&p2)));
1221 TEST_F(MetaVariableTest, unmask)
1226 particles.registerInDataStore();
1228 particles.registerRelationTo(mcParticles);
1242 graphParticleGrandMother.
setPDG(-521);
1244 graphParticleAunt.
setPDG(-14);
1246 graphParticleDaughter2.
setPDG(14);
1248 graphParticleMother.
comesFrom(graphParticleGrandMother);
1249 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1250 graphParticleDaughter1.
comesFrom(graphParticleMother);
1251 graphParticleDaughter2.
comesFrom(graphParticleMother);
1256 auto* mcGrandMother = mcParticles[0];
1259 auto* mcMother = mcParticles[1];
1262 auto* mcAunt = mcParticles[2];
1265 auto* mcDaughter1 = mcParticles[3];
1268 auto* mcDaughter2 = mcParticles[4];
1271 auto* pGrandMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1272 pGrandMother->addRelationTo(mcGrandMother);
1274 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1275 pMother->addRelationTo(mcMother);
1278 pMother->writeExtraInfo(
"mcErrors", 8);
1279 pGrandMother->writeExtraInfo(
"mcErrors", 8 | 16);
1282 ASSERT_NE(var1,
nullptr);
1283 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pMother)), 0);
1284 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pGrandMother)), 16);
1285 ASSERT_NE(var2,
nullptr);
1286 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pMother)), 0);
1287 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pGrandMother)), 0);
1290 pMother->writeExtraInfo(
"mcErrors", 8 | 128);
1291 pGrandMother->writeExtraInfo(
"mcErrors", 8 | 16 | 512);
1292 ASSERT_NE(var1,
nullptr);
1293 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pMother)), 128);
1294 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pGrandMother)), 16 | 512);
1295 ASSERT_NE(var2,
nullptr);
1296 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pMother)), 128);
1297 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pGrandMother)), 512);
1306 TEST_F(MetaVariableTest, conditionalVariableSelector)
1308 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1311 ASSERT_NE(var,
nullptr);
1312 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
1315 ASSERT_NE(var,
nullptr);
1316 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.4);
1320 TEST_F(MetaVariableTest, nCleanedTracks)
1326 tracks.registerInDataStore();
1329 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1330 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 11);
1332 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.1, 0.0, 0.0),
1333 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1334 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.15, 0.0, 0.0),
1335 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1336 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.4, 0.0, 0.0),
1337 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1338 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.6, 0.0, 0.0),
1339 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1341 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 0);
1342 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 1);
1343 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 2);
1344 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 3);
1347 EXPECT_FLOAT_EQ(std::get<int>(var1->function(
nullptr)), 1);
1350 EXPECT_FLOAT_EQ(std::get<int>(var2->
function(
nullptr)), 2);
1353 EXPECT_FLOAT_EQ(std::get<int>(var3->
function(
nullptr)), 4);
1358 TEST_F(MetaVariableTest, NumberOfMCParticlesInEvent)
1360 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1361 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 11);
1364 auto* mcParticle = mcParticles.appendNew();
1367 mcParticle = mcParticles.appendNew();
1370 mcParticle = mcParticles.appendNew();
1373 mcParticle = mcParticles.appendNew();
1378 ASSERT_NE(var,
nullptr);
1379 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 2);
1383 TEST_F(MetaVariableTest, daughterInvM)
1385 PxPyPzEVector momentum;
1386 const int nDaughters = 6;
1388 std::vector<int> daughterIndices;
1389 for (
int i = 0; i < nDaughters; i++) {
1390 Particle d(PxPyPzEVector(2, 2, 2, 4.0), (i % 2) ? 213 : -213);
1391 momentum += d.get4Vector();
1392 Particle* newDaughters = particles.appendNew(d);
1398 ASSERT_NE(var,
nullptr);
1399 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1402 ASSERT_NE(var,
nullptr);
1403 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 4.0);
1406 ASSERT_NE(var,
nullptr);
1407 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 6.0);
1410 TEST_F(MetaVariableTest, daughter)
1412 PxPyPzEVector momentum;
1413 const int nDaughters = 6;
1415 std::vector<int> daughterIndices;
1416 for (
int i = 0; i < nDaughters; i++) {
1417 Particle d(PxPyPzEVector(i * 1.0, 1, 1, 1), (i % 2) ? 211 : -211);
1418 momentum += d.get4Vector();
1419 Particle* newDaughters = particles.appendNew(d);
1425 ASSERT_NE(var,
nullptr);
1426 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1429 ASSERT_NE(var,
nullptr);
1430 EXPECT_NEAR(std::get<double>(var->function(p)), 0.0, 1e-6);
1433 ASSERT_NE(var,
nullptr);
1434 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 1.0);
1437 ASSERT_NE(var,
nullptr);
1438 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 2.0);
1441 TEST_F(MetaVariableTest, mcDaughter)
1446 particles.registerInDataStore();
1448 particles.registerRelationTo(mcParticles);
1462 graphParticleGrandMother.
setPDG(-521);
1464 graphParticleAunt.
setPDG(-14);
1466 graphParticleDaughter2.
setPDG(14);
1468 graphParticleMother.
comesFrom(graphParticleGrandMother);
1469 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1470 graphParticleDaughter1.
comesFrom(graphParticleMother);
1471 graphParticleDaughter2.
comesFrom(graphParticleMother);
1475 auto* mcGrandMother = mcParticles[0];
1478 auto* mcMother = mcParticles[1];
1481 auto* mcAunt = mcParticles[2];
1484 auto* mcDaughter1 = mcParticles[3];
1487 auto* mcDaughter2 = mcParticles[4];
1490 auto* pGrandMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1491 pGrandMother->addRelationTo(mcGrandMother);
1493 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1494 pMother->addRelationTo(mcMother);
1497 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1500 auto* p_noDaughter = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1501 p_noDaughter->addRelationTo(mcDaughter1);
1504 ASSERT_NE(var,
nullptr);
1505 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 13);
1506 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), 11);
1507 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1508 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noDaughter))));
1510 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), -14);
1511 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), 14);
1514 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1515 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1518 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 11);
1519 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1521 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 14);
1523 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1525 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1528 TEST_F(MetaVariableTest, mcMother)
1533 particles.registerInDataStore();
1535 particles.registerRelationTo(mcParticles);
1549 graphParticleGrandMother.
setPDG(-521);
1551 graphParticleAunt.
setPDG(-14);
1553 graphParticleDaughter2.
setPDG(14);
1555 graphParticleMother.
comesFrom(graphParticleGrandMother);
1556 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1557 graphParticleDaughter1.
comesFrom(graphParticleMother);
1558 graphParticleDaughter2.
comesFrom(graphParticleMother);
1563 auto* mcGrandMother = mcParticles[0];
1566 auto* mcMother = mcParticles[1];
1569 auto* mcAunt = mcParticles[2];
1572 auto* mcDaughter1 = mcParticles[3];
1575 auto* mcDaughter2 = mcParticles[4];
1578 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1579 p1->addRelationTo(mcDaughter1);
1581 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 14);
1582 p2->addRelationTo(mcDaughter2);
1584 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1585 pMother->addRelationTo(mcMother);
1588 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1591 auto* p_noMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1592 p_noMother->addRelationTo(mcGrandMother);
1595 ASSERT_NE(var,
nullptr);
1596 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 13);
1597 EXPECT_FLOAT_EQ(std::get<double>(var->function(p2)), 13);
1598 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), -521);
1599 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1600 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMother))));
1604 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1607 TEST_F(MetaVariableTest, genParticle)
1612 particles.registerInDataStore();
1614 particles.registerRelationTo(mcParticles);
1628 graphParticleGrandMother.
setPDG(300553);
1629 graphParticleMother.
setPDG(-521);
1630 graphParticleAunt.
setPDG(521);
1632 graphParticleDaughter2.
setPDG(-12);
1634 graphParticleGrandMother.
setMomentum(0.0, 0.0, 0.4);
1637 graphParticleMother.
comesFrom(graphParticleGrandMother);
1638 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1639 graphParticleDaughter1.
comesFrom(graphParticleMother);
1640 graphParticleDaughter2.
comesFrom(graphParticleMother);
1645 auto* mcGrandMother = mcParticles[0];
1648 auto* mcMother = mcParticles[1];
1651 auto* mcAunt = mcParticles[2];
1654 auto* mcDaughter1 = mcParticles[3];
1657 auto* mcDaughter2 = mcParticles[4];
1660 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1661 p1->addRelationTo(mcDaughter1);
1664 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 211);
1667 ASSERT_NE(var,
nullptr);
1668 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 300553);
1669 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 300553);
1672 ASSERT_NE(var,
nullptr);
1673 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 0.4);
1674 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 0.4);
1677 ASSERT_NE(var,
nullptr);
1678 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1679 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1682 ASSERT_NE(var,
nullptr);
1683 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 1.1);
1684 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 1.1);
1687 ASSERT_NE(var,
nullptr);
1688 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1689 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1692 ASSERT_NE(var,
nullptr);
1693 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -12);
1694 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -12);
1697 ASSERT_NE(var,
nullptr);
1698 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p1))));
1699 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1702 TEST_F(MetaVariableTest, genUpsilon4S)
1707 particles.registerInDataStore();
1709 particles.registerRelationTo(mcParticles);
1723 graphParticleGrandMother.
setPDG(300553);
1724 graphParticleMother.
setPDG(-521);
1725 graphParticleAunt.
setPDG(521);
1727 graphParticleDaughter2.
setPDG(-12);
1729 graphParticleGrandMother.
setMomentum(0.0, 0.0, 0.4);
1732 graphParticleMother.
comesFrom(graphParticleGrandMother);
1733 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1734 graphParticleDaughter1.
comesFrom(graphParticleMother);
1735 graphParticleDaughter2.
comesFrom(graphParticleMother);
1740 auto* mcGrandMother = mcParticles[0];
1743 auto* mcMother = mcParticles[1];
1746 auto* mcAunt = mcParticles[2];
1749 auto* mcDaughter1 = mcParticles[3];
1752 auto* mcDaughter2 = mcParticles[4];
1755 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1756 p1->addRelationTo(mcDaughter1);
1759 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 211);
1762 ASSERT_NE(var,
nullptr);
1763 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 300553);
1764 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 300553);
1767 ASSERT_NE(var,
nullptr);
1768 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 0.4);
1769 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 0.4);
1772 ASSERT_NE(var,
nullptr);
1773 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1774 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1777 ASSERT_NE(var,
nullptr);
1778 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 1.1);
1779 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 1.1);
1782 mcParticles.
clear();
1797 auto* mcP1 = mcParticles[0];
1800 auto* mcP2 = mcParticles[1];
1803 auto* someParticle = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1804 someParticle->addRelationTo(mcP1);
1807 ASSERT_NE(var,
nullptr);
1808 EXPECT_TRUE(std::isnan(std::get<double>(var->function(someParticle))));
1811 TEST_F(MetaVariableTest, daughterProductOf)
1813 PxPyPzEVector momentum;
1814 const int nDaughters = 4;
1816 std::vector<int> daughterIndices;
1817 for (
int i = 0; i < nDaughters; i++) {
1818 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1819 momentum += d.get4Vector();
1820 Particle* newDaughters = particles.appendNew(d);
1826 ASSERT_NE(var,
nullptr);
1827 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 120.0);
1830 TEST_F(MetaVariableTest, daughterSumOf)
1832 PxPyPzEVector momentum;
1833 const int nDaughters = 4;
1835 std::vector<int> daughterIndices;
1836 for (
int i = 0; i < nDaughters; i++) {
1837 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1838 momentum += d.get4Vector();
1839 Particle* newDaughters = particles.appendNew(d);
1845 ASSERT_NE(var,
nullptr);
1846 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 14.0);
1849 TEST_F(MetaVariableTest, daughterLowest)
1851 PxPyPzEVector momentum;
1852 const int nDaughters = 4;
1854 std::vector<int> daughterIndices;
1855 for (
int i = 0; i < nDaughters; i++) {
1856 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1857 momentum += d.get4Vector();
1858 Particle* newDaughters = particles.appendNew(d);
1864 ASSERT_NE(var,
nullptr);
1865 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 2.0);
1868 TEST_F(MetaVariableTest, daughterHighest)
1870 PxPyPzEVector momentum;
1871 const int nDaughters = 4;
1873 std::vector<int> daughterIndices;
1874 for (
int i = 0; i < nDaughters; i++) {
1875 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? 213 : -213);
1876 momentum += d.get4Vector();
1877 Particle* newDaughters = particles.appendNew(d);
1883 ASSERT_NE(var,
nullptr);
1884 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 4.0);
1887 TEST_F(MetaVariableTest, daughterDiffOf)
1889 PxPyPzEVector momentum;
1890 const int nDaughters = 4;
1892 std::vector<int> daughterIndices;
1893 for (
int i = 0; i < nDaughters; i++) {
1894 Particle d(PxPyPzEVector(-1, 1.0 - 2 * (i % 2), 1, i * 1.0 + 2.0), (i % 2) ? -11 : 211);
1895 momentum += d.get4Vector();
1896 Particle* newDaughters = particles.appendNew(d);
1902 ASSERT_NE(var,
nullptr);
1903 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1906 ASSERT_NE(var,
nullptr);
1907 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1910 ASSERT_NE(var,
nullptr);
1911 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1914 ASSERT_NE(var,
nullptr);
1915 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1918 ASSERT_NE(var,
nullptr);
1919 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1922 ASSERT_NE(var,
nullptr);
1923 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1926 ASSERT_NE(var,
nullptr);
1927 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5707964);
1930 ASSERT_NE(var,
nullptr);
1931 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5004894);
1934 ASSERT_NE(var,
nullptr);
1935 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1939 TEST_F(MetaVariableTest, mcDaughterDiffOf)
1942 PxPyPzEVector momentum;
1943 const int nDaughters = 4;
1946 particles.registerRelationTo(mcParticles);
1947 std::vector<int> daughterIndices;
1950 for (
int i = 0; i < nDaughters; i++) {
1951 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
1952 momentum += d.get4Vector();
1953 Particle* newDaughters = particles.appendNew(d);
1955 auto* mcParticle = mcParticles.
appendNew();
1963 ASSERT_NE(var,
nullptr);
1964 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1967 ASSERT_NE(var,
nullptr);
1968 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1971 ASSERT_NE(var,
nullptr);
1972 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1975 ASSERT_NE(var,
nullptr);
1976 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1979 ASSERT_NE(var,
nullptr);
1980 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1983 ASSERT_NE(var,
nullptr);
1984 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1987 ASSERT_NE(var,
nullptr);
1988 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1993 TEST_F(MetaVariableTest, daughterClusterAngleInBetween)
1997 std::vector<int> daughterIndices, daughterIndices_noclst;
2003 particles.registerRelationTo(eclclusters);
2007 const float px_CM = 2.;
2008 const float py_CM = 1.;
2009 const float pz_CM = 3.;
2011 E_CM =
sqrt(pow(px_CM, 2) + pow(py_CM, 2) + pow(pz_CM, 2));
2012 PxPyPzEVector momentum, momentum_noclst;
2013 PxPyPzEVector dau0_4vec_CM(px_CM, py_CM, pz_CM, E_CM), dau1_4vec_CM(-px_CM, -py_CM, -pz_CM, E_CM);
2014 PxPyPzEVector dau0_4vec_Lab, dau1_4vec_Lab;
2020 Particle dau0_noclst(dau0_4vec_Lab, 22);
2021 momentum += dau0_noclst.get4Vector();
2022 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
2023 daughterIndices_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
2024 Particle dau1_noclst(dau1_4vec_Lab, 22);
2025 momentum += dau1_noclst.get4Vector();
2026 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
2027 daughterIndices_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
2035 ASSERT_NE(var,
nullptr);
2036 EXPECT_TRUE(std::isnan(std::get<double>(var->function(par_noclst))));
2041 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2043 eclst0->
setTheta(dau0_4vec_Lab.Theta());
2044 eclst0->
setPhi(dau0_4vec_Lab.Phi());
2045 eclst0->
setR(148.4);
2048 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2050 eclst1->
setTheta(dau1_4vec_Lab.Theta());
2051 eclst1->
setPhi(dau1_4vec_Lab.Phi());
2052 eclst1->
setR(148.5);
2054 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2056 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2062 EXPECT_FLOAT_EQ(std::get<double>(var->function(par)), 2.8613892);
2063 EXPECT_FLOAT_EQ(std::get<double>(varCMS->
function(par)), M_PI);
2066 TEST_F(MetaVariableTest, grandDaughterDiffOfs)
2070 std::vector<int> daughterIndices0_noclst, daughterIndices1_noclst, daughterIndices2_noclst;
2071 std::vector<int> daughterIndices0, daughterIndices1, daughterIndices2;
2077 particles.registerRelationTo(eclclusters);
2081 const float px_0 = 2.;
2082 const float py_0 = 1.;
2083 const float pz_0 = 3.;
2084 const float px_1 = 1.5;
2085 const float py_1 = 1.5;
2086 const float pz_1 = 2.5;
2088 E_0 =
sqrt(pow(px_0, 2) + pow(py_0, 2) + pow(pz_0, 2));
2089 E_1 =
sqrt(pow(px_1, 2) + pow(py_1, 2) + pow(pz_1, 2));
2090 PxPyPzEVector momentum_0, momentum_1, momentum;
2091 PxPyPzEVector dau0_4vec(px_0, py_0, pz_0, E_0), dau1_4vec(px_1, py_1, pz_1, E_1);
2104 Particle dau0_noclst(dau0_4vec, 22);
2105 momentum_0 = dau0_4vec;
2106 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
2107 daughterIndices0_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
2109 Particle dau1_noclst(dau1_4vec, 22);
2110 momentum_1 = dau1_4vec;
2111 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
2112 daughterIndices1_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
2115 momentum = momentum_0 + momentum_1;
2116 daughterIndices2_noclst.push_back(par0_noclst->
getArrayIndex());
2117 daughterIndices2_noclst.push_back(par1_noclst->
getArrayIndex());
2136 ASSERT_NE(var_ClusterPhi,
nullptr);
2137 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi->
function(parGranny_noclst))));
2138 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterTheta->
function(parGranny_noclst))));
2139 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE->
function(parGranny_noclst))));
2140 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny_noclst)), 0.32175055);
2141 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny_noclst)), 0.06311664);
2142 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny_noclst)), -0.46293807);
2143 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi_wrongIndexes->
function(parGranny_noclst))));
2144 EXPECT_TRUE(std::isnan(std::get<double>(var_Phi_wrongIndexes->
function(parGranny_noclst))));
2145 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE_wrongIndexes->
function(parGranny_noclst))));
2146 EXPECT_TRUE(std::isnan(std::get<double>(var_E_wrongIndexes->
function(parGranny_noclst))));
2151 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2153 eclst0->
setTheta(dau0_4vec.Theta());
2154 eclst0->
setPhi(dau0_4vec.Phi());
2155 eclst0->
setR(148.4);
2158 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2160 eclst1->
setTheta(dau1_4vec.Theta());
2161 eclst1->
setPhi(dau1_4vec.Phi());
2162 eclst1->
setR(148.5);
2164 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2168 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2178 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterPhi->
function(parGranny)), 0.32175055);
2179 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny)), 0.32175055);
2180 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterTheta->
function(parGranny)), 0.06311664);
2181 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny)), 0.06311664);
2182 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterE->
function(parGranny)), -0.46293831);
2183 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny)), -0.46293831);
2186 TEST_F(MetaVariableTest, daughterNormDiffOf)
2188 PxPyPzEVector momentum;
2189 const int nDaughters = 4;
2191 std::vector<int> daughterIndices;
2192 for (
int i = 0; i < nDaughters; i++) {
2193 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2194 momentum += d.get4Vector();
2195 Particle* newDaughters = particles.appendNew(d);
2201 ASSERT_NE(var,
nullptr);
2202 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222 / 200.);
2205 ASSERT_NE(var,
nullptr);
2206 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222 / 200.);
2209 ASSERT_NE(var,
nullptr);
2210 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200 / 222.);
2213 ASSERT_NE(var,
nullptr);
2214 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -0 / 22.);
2217 ASSERT_NE(var,
nullptr);
2218 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 22.);
2221 ASSERT_NE(var,
nullptr);
2222 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 422.);
2226 TEST_F(MetaVariableTest, daughterMotherDiffOf)
2228 PxPyPzEVector momentum;
2229 const int nDaughters = 4;
2231 std::vector<int> daughterIndices;
2232 for (
int i = 0; i < nDaughters; i++) {
2233 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2234 momentum += d.get4Vector();
2235 Particle* newDaughters = particles.appendNew(d);
2241 ASSERT_NE(var,
nullptr);
2242 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422);
2245 ASSERT_NE(var,
nullptr);
2246 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400);
2249 ASSERT_NE(var,
nullptr);
2250 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200);
2254 TEST_F(MetaVariableTest, daughterMotherNormDiffOf)
2256 PxPyPzEVector momentum;
2257 const int nDaughters = 4;
2259 std::vector<int> daughterIndices;
2260 for (
int i = 0; i < nDaughters; i++) {
2261 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2262 momentum += d.get4Vector();
2263 Particle* newDaughters = particles.appendNew(d);
2269 ASSERT_NE(var,
nullptr);
2270 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422 / 400.);
2273 ASSERT_NE(var,
nullptr);
2274 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400 / 422.);
2277 ASSERT_NE(var,
nullptr);
2278 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200 / 622.);
2282 TEST_F(MetaVariableTest, constant)
2286 ASSERT_NE(var,
nullptr);
2287 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 1.0);
2290 ASSERT_NE(var,
nullptr);
2291 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 0.0);
2295 TEST_F(MetaVariableTest, abs)
2297 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
2298 Particle p2({ -0.1, -0.4, 0.8, 4.0 }, -11);
2301 ASSERT_NE(var,
nullptr);
2302 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
2303 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 0.1);
2307 TEST_F(MetaVariableTest, sin)
2309 Particle p({ M_PI / 2.0, -0.4, 0.8, 1.0}, 11);
2310 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2313 ASSERT_NE(var,
nullptr);
2314 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
2315 EXPECT_NEAR(std::get<double>(var->function(&p2)), 0.0, 1e-6);
2319 TEST_F(MetaVariableTest, cos)
2321 Particle p({ M_PI / 2.0, -0.4, 0.8, 1.0}, 11);
2322 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2325 ASSERT_NE(var,
nullptr);
2326 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.0, 1e-6);
2327 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 1.0);
2331 TEST_F(MetaVariableTest, NBDeltaIfMissingDeathTest)
2338 TEST_F(MetaVariableTest, matchedMC)
2343 particles.registerRelationTo(mcParticles);
2346 auto* mcParticle = mcParticles.
appendNew();
2349 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2350 p1->addRelationTo(mcParticle);
2355 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2356 p2->addRelationTo(mcParticle);
2361 auto* p3 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2362 p3->addRelationTo(mcParticle);
2365 auto* p4 = particles.appendNew(mcParticle);
2368 ASSERT_NE(var,
nullptr);
2369 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -1);
2370 EXPECT_FLOAT_EQ(std::get<double>(var->function(p2)), 1);
2371 EXPECT_FLOAT_EQ(std::get<double>(var->function(p3)), 0);
2372 EXPECT_FLOAT_EQ(std::get<double>(var->function(p4)), 0);
2375 TEST_F(MetaVariableTest, countInList)
2382 outputList.registerInDataStore(flags);
2384 outputList.create();
2385 outputList->initialize(22,
"pList1");
2400 ASSERT_NE(var,
nullptr);
2401 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 2);
2404 ASSERT_NE(var,
nullptr);
2405 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2408 ASSERT_NE(var,
nullptr);
2409 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 0);
2412 ASSERT_NE(var,
nullptr);
2413 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2416 TEST_F(MetaVariableTest, isInList)
2425 gammalist.registerInDataStore(flags);
2428 gammalist->initialize(22,
"testGammaList");
2433 auto* inthelist = particles.appendNew(goingin);
2434 auto* notinthelist = particles.appendNew(notgoingin);
2444 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(notinthelist)));
2445 EXPECT_TRUE(std::get<bool>(vsensible->
function(inthelist)));
2446 EXPECT_FALSE(std::get<bool>(vsensible->
function(notinthelist)));
2450 TEST_F(MetaVariableTest, cutIsInList)
2456 const std::string listname {
"wil/d(-+)'':l*"};
2460 particlelist.registerInDataStore(flags);
2462 particlelist.create();
2463 particlelist->initialize(22, listname);
2467 auto* inthelist = particles.appendNew(goingin);
2468 auto* notinthelist = particles.appendNew(notgoingin);
2477 EXPECT_B2FATAL(std::get<bool>(nonexistlist->
function(inthelist)));
2478 EXPECT_FALSE(std::get<bool>(existlist->
function(notinthelist)));
2479 EXPECT_TRUE(std::get<bool>(existlist->
function(inthelist)));
2482 TEST_F(MetaVariableTest, sourceObjectIsInList)
2494 particles.registerInDataStore();
2496 gammalist.registerInDataStore(flags);
2503 gammalist->initialize(22,
"testGammaList");
2508 cl0->setEnergy(1.0);
2509 cl0->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2510 cl0->addHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2511 cl0->setClusterId(0);
2513 cl1->setEnergy(1.0);
2514 cl1->setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2515 cl1->setClusterId(1);
2523 auto* myphoton_ = particles.appendNew(myphoton);
2524 gammalist->addParticle(myphoton_);
2526 auto* iscopied = particles.appendNew(iscopiedin);
2527 auto* notcopied = particles.appendNew(notcopiedin);
2534 EXPECT_B2FATAL(std::get<int>(vnonsense->
function(iscopied)));
2535 EXPECT_EQ(std::get<int>(vsensible->
function(iscopied)), 1);
2536 EXPECT_EQ(std::get<int>(vsensible->
function(notcopied)), 0);
2541 auto* composite_ = particles.appendNew(undefined);
2542 auto* undefined_ = particles.appendNew(composite);
2543 EXPECT_EQ(std::get<int>(vsensible->
function(composite_)), -1);
2544 EXPECT_EQ(std::get<int>(vsensible->
function(undefined_)), -1);
2547 TEST_F(MetaVariableTest, mcParticleIsInMCList)
2560 particles.registerInDataStore();
2561 particles.registerRelationTo(mcparticles);
2563 list.registerInDataStore(flags);
2564 anotherlist.registerInDataStore(flags);
2570 list->initialize(22,
"testList");
2572 anotherlist.create();
2573 anotherlist->initialize(22,
"supplimentaryList");
2576 auto* mcphoton = mcparticles.
appendNew();
2580 auto* mcelectron = mcparticles.
appendNew();
2584 auto* mcanotherelectron = mcparticles.
appendNew();
2588 auto* mcyetanotherelectron = mcparticles.
appendNew();
2593 auto* photon = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2594 photon->addRelationTo(mcphoton);
2595 list->addParticle(photon);
2597 auto* electron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2598 electron->addRelationTo(mcelectron);
2599 list->addParticle(electron);
2601 auto* other = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2602 other->addRelationTo(mcanotherelectron);
2604 auto* yetanotherelectron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2605 yetanotherelectron->addRelationTo(mcyetanotherelectron);
2606 anotherlist->addParticle(yetanotherelectron);
2614 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(photon)));
2615 EXPECT_TRUE(std::get<bool>(vsensible->
function(photon)));
2616 EXPECT_TRUE(std::get<bool>(vsensible->
function(electron)));
2617 EXPECT_FALSE(std::get<bool>(vsensible->
function(other)));
2618 EXPECT_FALSE(std::get<bool>(vsensible->
function(yetanotherelectron)));
2623 auto* composite_ = particles.appendNew(undefined);
2624 auto* undefined_ = particles.appendNew(composite);
2625 EXPECT_FALSE(std::get<bool>(vsensible->
function(composite_)));
2626 EXPECT_FALSE(std::get<bool>(vsensible->
function(undefined_)));
2629 TEST_F(MetaVariableTest, mostB2BAndClosestParticles)
2639 gearbox.setBackends({std::string(
"file:")});
2641 gearbox.open(
"geometry/Belle2.xml",
false);
2651 gammalist.registerInDataStore(flags);
2652 emptylist.registerInDataStore(flags);
2655 gammalist->initialize(22,
"testGammaList");
2657 emptylist->initialize(22,
"testEmptyList");
2660 std::vector<Particle> gammavector = {
2667 for (
const auto& g : gammavector)
2668 particles.appendNew(g);
2671 for (
size_t i = 0; i < gammavector.size(); i++)
2675 const auto* electron = particles.appendNew(
2685 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2688 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2691 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 0.68014491);
2694 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 0.67901474);
2702 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2705 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2708 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 3.4);
2711 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 3.2732551);
2714 EXPECT_FLOAT_EQ(std::get<double>(closestCMSLabE->function(electron)), 3.4);
2722 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2725 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2728 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 2.2869499);
2731 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 2.8312778);
2739 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2742 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2745 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 1.7);
2748 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 1.5848758);
2751 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMSLabE->function(electron)), 1.7);
2755 TEST_F(MetaVariableTest, totalEnergyOfParticlesInList)
2764 gammalist.registerInDataStore(flags);
2767 gammalist->initialize(22,
"testGammaList");
2770 std::vector<Particle> gammavector = {
2779 for (
const auto& g : gammavector)
2780 particles.appendNew(g);
2783 for (
size_t i = 0; i < gammavector.size(); i++)
2788 "totalEnergyOfParticlesInList(NONEXISTANTLIST)");
2790 "totalEnergyOfParticlesInList(testGammaList)");
2793 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2794 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 4.3);
2796 TEST_F(MetaVariableTest, totalPxOfParticlesInList)
2805 gammalist.registerInDataStore(flags);
2808 gammalist->initialize(22,
"testGammaList");
2811 std::vector<Particle> gammavector = {
2820 for (
const auto& g : gammavector)
2821 particles.appendNew(g);
2824 for (
size_t i = 0; i < gammavector.size(); i++)
2829 "totalPxOfParticlesInList(NONEXISTANTLIST)");
2831 "totalPxOfParticlesInList(testGammaList)");
2834 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2835 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 2.2);
2837 TEST_F(MetaVariableTest, totalPyOfParticlesInList)
2846 gammalist.registerInDataStore(flags);
2849 gammalist->initialize(22,
"testGammaList");
2852 std::vector<Particle> gammavector = {
2861 for (
const auto& g : gammavector)
2862 particles.appendNew(g);
2865 for (
size_t i = 0; i < gammavector.size(); i++)
2870 "totalPyOfParticlesInList(NONEXISTANTLIST)");
2872 "totalPyOfParticlesInList(testGammaList)");
2875 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2876 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 1.5);
2878 TEST_F(MetaVariableTest, totalPzOfParticlesInList)
2887 gammalist.registerInDataStore(flags);
2890 gammalist->initialize(22,
"testGammaList");
2893 std::vector<Particle> gammavector = {
2902 for (
const auto& g : gammavector)
2903 particles.appendNew(g);
2906 for (
size_t i = 0; i < gammavector.size(); i++)
2911 "totalPzOfParticlesInList(NONEXISTANTLIST)");
2913 "totalPzOfParticlesInList(testGammaList)");
2916 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2917 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 3.1);
2919 TEST_F(MetaVariableTest, maxPtInList)
2928 gammalist.registerInDataStore(flags);
2931 gammalist->initialize(22,
"testGammaList");
2934 std::vector<Particle> gammavector = {
2943 for (
const auto& g : gammavector)
2944 particles.appendNew(g);
2947 for (
size_t i = 0; i < gammavector.size(); i++)
2952 "maxPtInList(NONEXISTANTLIST)");
2954 "maxPtInList(testGammaList)");
2957 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2958 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)),
sqrt(0.5 * 0.5 + 0.4 * 0.4));
2962 TEST_F(MetaVariableTest, numberOfNonOverlappingParticles)
2969 outputList.registerInDataStore(flags);
2971 outputList.create();
2972 outputList->initialize(22,
"pList1");
2982 ASSERT_NE(var,
nullptr);
2983 EXPECT_EQ(std::get<int>(var->function(p1)), 1);
2984 EXPECT_EQ(std::get<int>(var->function(p2)), 1);
2985 EXPECT_EQ(std::get<int>(var->function(p3)), 2);
2989 TEST_F(MetaVariableTest, veto)
2994 const Particle* p = particles.appendNew(
Particle({0.8, 0.8, 1.131370849898476039041351, 1.6}, 22,
2999 outputList.registerInDataStore(flags);
3001 outputList.create();
3002 outputList->initialize(22,
"pList1");
3004 particles.appendNew(
Particle({0.5, 0.4953406774856531014212777, 0.5609256753154148484773173, 0.9}, 22,
3019 outputList2.registerInDataStore(flags);
3021 outputList2.create();
3022 outputList2->initialize(22,
"pList2");
3037 ASSERT_NE(var,
nullptr);
3038 EXPECT_TRUE(std::get<bool>(var->function(p)));
3041 ASSERT_NE(var,
nullptr);
3042 EXPECT_FALSE(std::get<bool>(var->function(p)));
3046 TEST_F(MetaVariableTest, averageValueInList)
3055 gammalist.registerInDataStore(flags);
3058 gammalist->initialize(22,
"testGammaList");
3061 std::vector<Particle> gammavector = {
3070 for (
const auto& g : gammavector)
3071 particles.appendNew(g);
3074 for (
size_t i = 0; i < gammavector.size(); i++)
3079 "averageValueInList(testGammaList, px)");
3081 "averageValueInList(testGammaList, py)");
3083 "averageValueInList(testGammaList, pz)");
3085 "averageValueInList(testGammaList, E)");
3087 EXPECT_FLOAT_EQ(std::get<double>(vmeanpx->
function(
nullptr)), 0.44);
3088 EXPECT_FLOAT_EQ(std::get<double>(vmeanpy->
function(
nullptr)), 0.3);
3089 EXPECT_FLOAT_EQ(std::get<double>(vmeanpz->
function(
nullptr)), 0.6);
3090 EXPECT_FLOAT_EQ(std::get<double>(vmeanE->
function(
nullptr)), 0.86);
3093 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"averageValueInList(testGammaList)"));
3096 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"averageValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3100 "averageValueInList(NONEXISTANTLIST, px)");
3102 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3105 TEST_F(MetaVariableTest, medianValueInList)
3114 oddgammalist.registerInDataStore(flags);
3116 oddgammalist.create();
3117 oddgammalist->initialize(22,
"oddGammaList");
3120 evengammalist.registerInDataStore(flags);
3122 evengammalist.create();
3123 evengammalist->initialize(22,
"evenGammaList");
3126 std::vector<Particle> gammavector = {
3135 for (
const auto& g : gammavector)
3136 particles.appendNew(g);
3140 for (
size_t i = 1; i < gammavector.size(); i++) {
3147 "medianValueInList(oddGammaList, px)");
3149 "medianValueInList(oddGammaList, py)");
3151 "medianValueInList(oddGammaList, pz)");
3153 "medianValueInList(oddGammaList, E)");
3155 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpx->
function(
nullptr)), 0.5);
3156 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpy->
function(
nullptr)), 0.3);
3157 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpz->
function(
nullptr)), 0.7);
3158 EXPECT_FLOAT_EQ(std::get<double>(voddmedianE->
function(
nullptr)), 0.9);
3162 "medianValueInList(evenGammaList, px)");
3164 "medianValueInList(evenGammaList, py)");
3166 "medianValueInList(evenGammaList, pz)");
3168 "medianValueInList(evenGammaList, E)");
3170 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpx->
function(
nullptr)), 0.45);
3171 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpy->
function(
nullptr)), 0.25);
3172 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpz->
function(
nullptr)), 0.7);
3173 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianE->
function(
nullptr)), 0.9);
3176 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"medianValueInList(oddGammaList)"));
3179 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"medianValueInList(oddGammaList, NONEXISTANTVARIABLE)"));
3183 "medianValueInList(NONEXISTANTLIST, px)");
3185 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3188 TEST_F(MetaVariableTest, productValueInList)
3197 gammalist.registerInDataStore(flags);
3200 gammalist->initialize(22,
"testGammaList");
3203 std::vector<Particle> gammavector = {
3212 for (
const auto& g : gammavector)
3213 particles.appendNew(g);
3216 for (
size_t i = 0; i < gammavector.size(); i++)
3221 "productValueInList(testGammaList, px)");
3223 "productValueInList(testGammaList, py)");
3225 "productValueInList(testGammaList, pz)");
3227 "productValueInList(testGammaList, E)");
3229 EXPECT_FLOAT_EQ(std::get<double>(vproductpx->
function(
nullptr)), 0.015);
3230 EXPECT_FLOAT_EQ(std::get<double>(vproductpy->
function(
nullptr)), 0.00192);
3231 EXPECT_FLOAT_EQ(std::get<double>(vproductpz->
function(
nullptr)), 0.06272);
3232 EXPECT_FLOAT_EQ(std::get<double>(vproductE->
function(
nullptr)), 0.42768);
3235 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"productValueInList(testGammaList)"));
3238 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"productValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3242 "productValueInList(NONEXISTANTLIST, px)");
3244 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3247 TEST_F(MetaVariableTest, sumValueInList)
3256 gammalist.registerInDataStore(flags);
3259 gammalist->initialize(22,
"testGammaList");
3262 std::vector<Particle> gammavector = {
3271 for (
const auto& g : gammavector)
3272 particles.appendNew(g);
3275 for (
size_t i = 0; i < gammavector.size(); i++)
3280 "sumValueInList(testGammaList, px)");
3282 "sumValueInList(testGammaList, py)");
3284 "sumValueInList(testGammaList, pz)");
3286 "sumValueInList(testGammaList, E)");
3288 EXPECT_FLOAT_EQ(std::get<double>(vsumpx->
function(
nullptr)), 2.2);
3289 EXPECT_FLOAT_EQ(std::get<double>(vsumpy->
function(
nullptr)), 1.5);
3290 EXPECT_FLOAT_EQ(std::get<double>(vsumpz->
function(
nullptr)), 3.0);
3291 EXPECT_FLOAT_EQ(std::get<double>(vsumE->
function(
nullptr)), 4.3);
3294 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"sumValueInList(testGammaList)"));
3297 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"sumValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3301 "sumValueInList(NONEXISTANTLIST, px)");
3303 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3306 TEST_F(MetaVariableTest, pValueCombination)
3308 PxPyPzEVector momentum;
3310 std::vector<int> daughterIndices;
3313 momentum += KS.get4Vector();
3314 Particle* newDaughters = particles.appendNew(KS);
3317 Jpsi.setPValue(0.9);
3318 momentum += Jpsi.get4Vector();
3319 newDaughters = particles.appendNew(Jpsi);
3325 ASSERT_NE(singlePvalue,
nullptr);
3326 EXPECT_FLOAT_EQ(std::get<double>(singlePvalue->
function(B)), 0.5);
3329 ASSERT_NE(twoPvalues,
nullptr);
3330 EXPECT_FLOAT_EQ(std::get<double>(twoPvalues->
function(B)), 0.05 * (1 - log(0.05)));
3334 ASSERT_NE(threePvalues,
nullptr);
3335 EXPECT_FLOAT_EQ(std::get<double>(threePvalues->
function(B)), 0.045 * (1 - log(0.045) + 0.5 * log(0.045) * log(0.045)));
3341 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"pValueCombination(chiProb, NONEXISTANTVARIABLE)"));
3345 TEST_F(MetaVariableTest, daughterCombinationOneGeneration)
3347 const int nDaughters = 5;
3348 PxPyPzEVector momentum(0, 0, 0, 0);
3350 std::vector<int> daughterIndices;
3351 std::vector<PxPyPzEVector> daughterMomenta;
3353 for (
int i = 0; i < nDaughters; i++) {
3354 PxPyPzEVector mom(1, i * 0.5, 1, i * 1.0 + 2.0);
3355 Particle d(mom, (i % 2) ? 111 : 113);
3356 Particle* newDaughters = particles.appendNew(d);
3358 daughterMomenta.push_back(mom);
3359 momentum = momentum + mom;
3365 double M_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[2]).mag();
3366 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3369 M_test = (daughterMomenta[0] + daughterMomenta[4]).mag();
3370 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3375 double p_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[4]).P();
3376 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), p_test);
3380 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"daughterCombination(aVeryNonExistingVariableSillyName, 1, 0, 4)"));
3383 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3384 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3388 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3389 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3393 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3394 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3399 TEST_F(MetaVariableTest, daughterCombinationTwoGenerations)
3405 PxPyPzEVector momentum_1(0, 0, 0, 0);
3406 std::vector<PxPyPzEVector> daughterMomenta_1;
3407 std::vector<int> daughterIndices_1;
3409 for (
int i = 0; i < 3; i++) {
3410 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3411 Particle d(mom, (i % 2) ? 111 : 113);
3412 Particle* newDaughters = particles.appendNew(d);
3414 daughterMomenta_1.push_back(mom);
3415 momentum_1 = momentum_1 + mom;
3423 PxPyPzEVector momentum_2(0, 0, 0, 0);
3424 std::vector<PxPyPzEVector> daughterMomenta_2;
3425 std::vector<int> daughterIndices_2;
3427 for (
int i = 0; i < 2; i++) {
3428 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3429 Particle d(mom, (i % 2) ? 111 : 113);
3430 Particle* newDaughters = particles.appendNew(d);
3432 daughterMomenta_2.push_back(mom);
3433 momentum_2 = momentum_2 + mom;
3447 double M_test = (momentum_1 + momentum_2).mag();
3448 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3452 M_test = (momentum_1).mag();
3453 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3457 M_test = (daughterMomenta_1[0] + daughterMomenta_1[1] + daughterMomenta_2[0]).mag();
3458 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3463 TEST_F(MetaVariableTest, useAlternativeDaughterHypothesis)
3465 const int nDaughters = 5;
3469 PxPyPzEVector momentum(0, 0, 0, 0);
3470 std::vector<int> daughterIndices;
3471 for (
int i = 0; i < nDaughters; i++) {
3472 double px = i * 0.1;
3473 double py = i * 0.3;
3474 double pz = -i * 0.1 - 0.2;
3476 PxPyPzEVector mom(px, py, pz, 1);
3480 d.updateMass(pdgCode);
3481 mom = d.get4Vector();
3483 Particle* daughters = particles.appendNew(d);
3485 momentum = momentum + mom;
3491 PxPyPzEVector momentumAlt(0, 0, 0, 0);
3492 std::vector<int> daughterIndicesAlt;
3493 for (
int i = 0; i < nDaughters; i++) {
3494 double px = i * 0.1;
3495 double py = i * 0.3;
3496 double pz = -i * 0.1 - 0.2;
3498 PxPyPzEVector mom(px, py, pz, 1);
3506 d.updateMass(pdgCode);
3507 mom = d.get4Vector();
3509 Particle* daughters = particles.appendNew(d);
3511 momentumAlt = momentumAlt + mom;
3517 std::cout <<
"mass test" << std::endl;
3520 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3523 std::cout <<
"charge test" << std::endl;
3525 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3528 std::cout <<
"momentum test" << std::endl;
3531 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3532 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(p)));
3533 EXPECT_FLOAT_EQ(std::get<double>(var->function(pAlt)), std::get<double>(varAlt->
function(pAlt)));
3539 TEST_F(MetaVariableTest, daughterAngle)
3545 PxPyPzEVector momentum_1(0, 0, 0, 0);
3546 std::vector<PxPyPzEVector> daughterMomenta_1;
3547 std::vector<int> daughterIndices_1;
3549 for (
int i = 0; i < 3; i++) {
3550 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3551 Particle d(mom, (i % 2) ? -11 : 211);
3552 Particle* newDaughters = particles.appendNew(d);
3554 daughterMomenta_1.push_back(mom);
3555 momentum_1 = momentum_1 + mom;
3563 PxPyPzEVector momentum_2(0, 0, 0, 0);
3564 std::vector<PxPyPzEVector> daughterMomenta_2;
3565 std::vector<int> daughterIndices_2;
3567 for (
int i = 0; i < 2; i++) {
3568 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3569 Particle d(mom, (i % 2) ? -11 : 211);
3570 Particle* newDaughters = particles.appendNew(d);
3572 daughterMomenta_2.push_back(mom);
3573 momentum_2 = momentum_2 + mom;
3586 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3588 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3592 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3593 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3596 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3597 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3600 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3601 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3605 TEST_F(MetaVariableTest, mcDaughterVariables)
3611 particles.registerRelationTo(mcParticles);
3615 PxPyPzEVector momentum_1(0, 0, 0, 0);
3616 std::vector<PxPyPzEVector> daughterMomenta_1;
3617 std::vector<int> daughterIndices_1;
3619 for (
int i = 0; i < 3; i++) {
3620 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3621 Particle d(mom, (i % 2) ? -11 : 211);
3622 Particle* newDaughters = particles.appendNew(d);
3624 daughterMomenta_1.push_back(mom);
3625 momentum_1 = momentum_1 + mom;
3627 auto* mcParticle = mcParticles.
appendNew();
3635 auto* mcCompositeDau_1 = mcParticles.
appendNew();
3636 mcCompositeDau_1->setPDG(411);
3638 mcCompositeDau_1->set4Vector(momentum_1);
3643 PxPyPzEVector momentum_2(0, 0, 0, 0);
3644 std::vector<PxPyPzEVector> daughterMomenta_2;
3645 std::vector<int> daughterIndices_2;
3647 for (
int i = 0; i < 2; i++) {
3648 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3649 Particle d(mom, (i % 2) ? -11 : 211);
3650 Particle* newDaughters = particles.appendNew(d);
3652 daughterMomenta_2.push_back(mom);
3653 momentum_2 = momentum_2 + mom;
3655 auto* mcParticle = mcParticles.
appendNew();
3663 auto* mcCompositeDau_2 = mcParticles.
appendNew();
3664 mcCompositeDau_2->setPDG(411);
3666 mcCompositeDau_2->set4Vector(momentum_2);
3676 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3677 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3680 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3681 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3684 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3685 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3688 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3689 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3693 ASSERT_NE(var,
nullptr);
3694 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
3697 ASSERT_NE(var,
nullptr);
3698 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3702 ASSERT_NE(var,
nullptr);
3703 v_test = momentum_2.Phi() - momentum_1.Phi();
3704 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3708 TEST_F(MetaVariableTest, varForFirstMCAncestorOfType)
3713 particles.registerInDataStore();
3715 particles.registerRelationTo(mcParticles);
3717 DList.registerInDataStore();
3719 DList->initialize(421,
"D0:vartest");
3721 PxPyPzEVector momentum;
3722 PxPyPzEVector momentum_0;
3723 PxPyPzEVector momentum_1;
3724 std::vector<int> D_daughterIndices;
3725 std::vector<int> D_grandDaughterIndices_0;
3726 std::vector<int> D_grandDaughterIndices_1;
3744 mcg_d_0.
set4Vector(PxPyPzEVector(6, 6, 6, 6));
3746 mcg_d_1.
set4Vector(PxPyPzEVector(5, 5, 5, 5));
3748 mcg_gd_0_0.
set4Vector(PxPyPzEVector(4, 4, 4, 4));
3750 mcg_gd_0_1.
set4Vector(PxPyPzEVector(3, 3, 3, 3));
3752 mcg_gd_1_0.
set4Vector(PxPyPzEVector(2, 1, 2, 2));
3754 mcg_gd_1_1.
set4Vector(PxPyPzEVector(1, 1, 1, 1));
3756 mcg_not_child.
set4Vector(PxPyPzEVector(10, 10, 10, 10));
3768 auto* mc_not_child = mcParticles[0];
3769 auto* mc_m = mcParticles[1];
3770 auto* mc_d_0 = mcParticles[2];
3771 auto* mc_d_1 = mcParticles[3];
3772 auto* mc_gd_0_0 = mcParticles[4];
3773 auto* mc_gd_0_1 = mcParticles[5];
3774 auto* mc_gd_1_0 = mcParticles[6];
3775 auto* mc_gd_1_1 = mcParticles[7];
3789 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
3790 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
3791 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
3792 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
3794 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3795 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3796 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3797 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3811 DList->addParticle(D_m);
3814 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
3817 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
3831 ASSERT_NE(var_d,
nullptr);
3832 EXPECT_TRUE(std::get<double>(var_d->
function(D_gd_0_0)) >= 0);
3833 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_0_1)));
3834 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_1_0)), std::get<double>(var_d->
function(D_gd_1_1)));
3835 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_1_0)));
3836 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_1)), std::get<double>(var_d->
function(D_gd_1_1)));
3837 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child))));
3838 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child_2))));
3843 ASSERT_NE(var_310,
nullptr);
3844 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_0_1)));
3845 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_1_0)), std::get<double>(var_310->
function(D_gd_1_1)));
3846 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_1_0)));
3847 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_1)), std::get<double>(var_310->
function(D_gd_1_1)));
3848 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child))));
3849 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child_2))));
3850 EXPECT_FLOAT_EQ(
int(std::get<double>(
Manager::Instance().getVariable(
"varForFirstMCAncestorOfType(310, E)")->function(D_gd_0_0))),
3854 TEST_F(MetaVariableTest, isDescendantOfList)
3858 DList.registerInDataStore();
3860 DList->initialize(421,
"D0:vartest");
3862 BList.registerInDataStore();
3864 BList->initialize(521,
"B:vartest");
3867 PxPyPzEVector momentum;
3868 PxPyPzEVector momentum_0;
3869 PxPyPzEVector momentum_1;
3871 std::vector<int> D_daughterIndices;
3872 std::vector<int> D_grandDaughterIndices_0;
3873 std::vector<int> D_grandDaughterIndices_1;
3874 std::vector<int> B_daughterIndices;
3875 std::vector<int> B_grandDaughterIndices;
3876 std::vector<int> B_grandGrandDaughterIndices;
3885 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3886 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3887 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3888 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3902 DList->addParticle(D_m);
3911 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_0->
getArrayIndex());
3912 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_1->
getArrayIndex());
3916 B_grandDaughterIndices.push_back(B_gd_0_0->
getArrayIndex());
3917 B_grandDaughterIndices.push_back(B_gd_0_1->
getArrayIndex());
3925 BList->addParticle(B_m);
3932 ASSERT_NE(var_0,
nullptr);
3933 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_0)));
3934 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_1)));
3935 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_0)));
3936 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_1)));
3937 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_0)));
3938 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_1)));
3939 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_0)));
3940 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_1)));
3941 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_0)));
3942 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_1)));
3943 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_0)));
3944 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_1)));
3945 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
3948 ASSERT_NE(var_0a,
nullptr);
3949 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_0)));
3950 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_1)));
3951 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_0)));
3952 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_1)));
3953 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_0)));
3954 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_1)));
3955 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_0)));
3956 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_1)));
3957 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_0)));
3958 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_1)));
3959 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_0)));
3960 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_1)));
3961 EXPECT_FALSE(std::get<bool>(var_0a->
function(not_child)));
3964 ASSERT_NE(var_0b,
nullptr);
3965 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_0)));
3966 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_1)));
3967 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_0)));
3968 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_1)));
3969 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_0)));
3970 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_1)));
3971 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_0)));
3972 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_1)));
3973 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_0)));
3974 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_1)));
3975 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_0)));
3976 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_1)));
3977 EXPECT_FALSE(std::get<bool>(var_0b->
function(not_child)));
3980 ASSERT_NE(var_1,
nullptr);
3981 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
3982 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
3983 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
3984 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
3985 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_0)));
3986 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_1)));
3987 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_0)));
3988 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_1)));
3989 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_0)));
3990 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_1)));
3991 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_0)));
3992 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_1)));
3993 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
3996 ASSERT_NE(var_2,
nullptr);
3997 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_0)));
3998 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_1)));
3999 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_0)));
4000 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_1)));
4001 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
4002 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
4003 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_0)));
4004 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_1)));
4005 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_0)));
4006 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_1)));
4007 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_0)));
4008 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_1)));
4009 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
4012 ASSERT_NE(var_3,
nullptr);
4013 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_0)));
4014 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_1)));
4015 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_0)));
4016 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_1)));
4017 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_0)));
4018 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_1)));
4019 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_0)));
4020 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_1)));
4021 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_0)));
4022 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_1)));
4023 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_0)));
4024 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_1)));
4025 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
4028 ASSERT_NE(var_4,
nullptr);
4029 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_0)));
4030 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_1)));
4031 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_0)));
4032 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_1)));
4033 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_0)));
4034 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_1)));
4035 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_0)));
4036 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_1)));
4037 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_0)));
4038 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_1)));
4039 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_0)));
4040 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_1)));
4041 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
4044 ASSERT_NE(var_5,
nullptr);
4045 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
4046 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
4047 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
4048 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
4049 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_0)));
4050 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_1)));
4051 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_0)));
4052 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_1)));
4053 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_0)));
4054 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_1)));
4055 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_0)));
4056 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_1)));
4057 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
4060 ASSERT_NE(var_6,
nullptr);
4061 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_0)));
4062 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_1)));
4063 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_0)));
4064 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_1)));
4065 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_0)));
4066 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_1)));
4067 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_0)));
4068 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_1)));
4069 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_0)));
4070 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_1)));
4071 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_0)));
4072 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_1)));
4073 EXPECT_FALSE(std::get<bool>(var_6->
function(not_child)));
4076 ASSERT_NE(var_7,
nullptr);
4077 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_0)));
4078 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_1)));
4079 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_0)));
4080 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_1)));
4081 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_0)));
4082 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_1)));
4083 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_0)));
4084 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_1)));
4085 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_0)));
4086 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_1)));
4087 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_0)));
4088 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_1)));
4089 EXPECT_FALSE(std::get<bool>(var_7->
function(not_child)));
4093 TEST_F(MetaVariableTest, isMCDescendantOfList)
4098 particles.registerInDataStore();
4100 particles.registerRelationTo(mcParticles);
4102 BList.registerInDataStore();
4104 BList->initialize(521,
"B:vartest");
4106 DList.registerInDataStore();
4108 DList->initialize(421,
"D0:vartest");
4110 PxPyPzEVector momentum;
4111 PxPyPzEVector momentum_0;
4112 PxPyPzEVector momentum_1;
4113 std::vector<int> daughterIndices;
4114 std::vector<int> grandDaughterIndices;
4115 std::vector<int> grandGrandDaughterIndices;
4116 std::vector<int> D_daughterIndices;
4117 std::vector<int> D_grandDaughterIndices_0;
4118 std::vector<int> D_grandDaughterIndices_1;
4152 auto* mc_m = mcParticles[0];
4153 auto* mc_d_0 = mcParticles[1];
4154 auto* mc_d_1 = mcParticles[2];
4155 auto* mc_gd_0_0 = mcParticles[3];
4156 auto* mc_gd_0_1 = mcParticles[4];
4157 auto* mc_ggd_0_0_0 = mcParticles[5];
4158 auto* mc_ggd_0_0_1 = mcParticles[6];
4159 auto* mc_not_child = mcParticles[7];
4172 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4173 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4174 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4175 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4177 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
4178 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
4179 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
4180 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
4194 DList->addParticle(D_m);
4197 const Particle* d_1 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4198 const Particle* gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4199 const Particle* ggd_0_0_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4200 const Particle* ggd_0_0_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4202 grandGrandDaughterIndices.push_back(ggd_0_0_0->
getArrayIndex());
4203 grandGrandDaughterIndices.push_back(ggd_0_0_1->
getArrayIndex());
4216 BList->addParticle(m);
4219 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
4222 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
4230 m->addRelationTo(mc_m);
4234 ASSERT_NE(var_0,
nullptr);
4235 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_0)));
4236 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_1)));
4237 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_0)));
4238 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_1)));
4239 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_0)));
4240 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_1)));
4241 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_0)));
4242 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_1)));
4243 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_0)));
4244 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_1)));
4245 EXPECT_TRUE(std::get<bool>(var_0->
function(d_0)));
4246 EXPECT_TRUE(std::get<bool>(var_0->
function(d_1)));
4247 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
4248 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child_2)));
4251 ASSERT_NE(var_1,
nullptr);
4252 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
4253 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
4254 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
4255 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
4256 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_0)));
4257 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_1)));
4258 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_0)));
4259 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_1)));
4260 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_0)));
4261 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_1)));
4262 EXPECT_TRUE(std::get<bool>(var_1->
function(d_0)));
4263 EXPECT_TRUE(std::get<bool>(var_1->
function(d_1)));
4264 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
4265 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child_2)));
4268 ASSERT_NE(var_2,
nullptr);
4269 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_0)));
4270 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_1)));
4271 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_0)));
4272 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_1)));
4273 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
4274 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
4275 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_0)));
4276 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_1)));
4277 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_0)));
4278 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_1)));
4279 EXPECT_TRUE(std::get<bool>(var_2->
function(d_0)));
4280 EXPECT_TRUE(std::get<bool>(var_2->
function(d_1)));
4281 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
4282 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child_2)));
4285 ASSERT_NE(var_3,
nullptr);
4286 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_0)));
4287 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_1)));
4288 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_0)));
4289 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_1)));
4290 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_0)));
4291 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_1)));
4292 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_0)));
4293 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_1)));
4294 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_0)));
4295 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_1)));
4296 EXPECT_TRUE(std::get<bool>(var_3->
function(d_0)));
4297 EXPECT_TRUE(std::get<bool>(var_3->
function(d_1)));
4298 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
4299 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child_2)));
4302 ASSERT_NE(var_4,
nullptr);
4303 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_0)));
4304 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_1)));
4305 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_0)));
4306 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_1)));
4307 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_0)));
4308 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_1)));
4309 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_0)));
4310 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_1)));
4311 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_0)));
4312 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_1)));
4313 EXPECT_FALSE(std::get<bool>(var_4->
function(d_0)));
4314 EXPECT_FALSE(std::get<bool>(var_4->
function(d_1)));
4315 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
4316 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child_2)));
4320 ASSERT_NE(var_5,
nullptr);
4321 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
4322 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
4323 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
4324 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
4325 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_0)));
4326 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_1)));
4327 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_0)));
4328 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_1)));
4329 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_0)));
4330 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_1)));
4331 EXPECT_FALSE(std::get<bool>(var_5->
function(d_0)));
4332 EXPECT_FALSE(std::get<bool>(var_5->
function(d_1)));
4333 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
4334 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child_2)));
4341 class PIDVariableTest :
public ::testing::Test {
4344 void SetUp()
override
4357 particles.registerInDataStore();
4358 tracks.registerInDataStore();
4359 particles.registerRelationTo(likelihood);
4360 tracks.registerRelationTo(likelihood);
4365 void TearDown()
override
4371 TEST_F(PIDVariableTest, LogLikelihood)
4380 const float pValue = 0.5;
4381 const float bField = 1.5;
4383 TMatrixDSym cov6(6);
4385 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4386 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4387 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4389 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4390 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4392 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4396 Track* allTrack = tracks.appendNew(mytrack);
4397 Track* noSVDTrack = tracks.appendNew(mytrack);
4398 Track* noPIDTrack = tracks.appendNew(mytrack);
4399 Track* dEdxTrack = tracks.appendNew(mytrack);
4412 lAll->setLogLikelihood(Const::TOP,
Const::muon, 0.5);
4413 lAll->setLogLikelihood(Const::ARICH,
Const::muon, 0.52);
4414 lAll->setLogLikelihood(Const::ECL,
Const::muon, 0.54);
4415 lAll->setLogLikelihood(Const::CDC,
Const::muon, 0.56);
4416 lAll->setLogLikelihood(Const::SVD,
Const::muon, 0.58);
4417 lAll->setLogLikelihood(Const::KLM,
Const::muon, 0.8);
4419 lAll->setLogLikelihood(Const::TOP,
Const::pion, 0.2);
4420 lAll->setLogLikelihood(Const::ARICH,
Const::pion, 0.22);
4421 lAll->setLogLikelihood(Const::ECL,
Const::pion, 0.24);
4422 lAll->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4423 lAll->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4424 lAll->setLogLikelihood(Const::KLM,
Const::pion, 0.2);
4426 lAll->setLogLikelihood(Const::TOP,
Const::kaon, 0.3);
4427 lAll->setLogLikelihood(Const::ARICH,
Const::kaon, 0.32);
4428 lAll->setLogLikelihood(Const::ECL,
Const::kaon, 0.34);
4429 lAll->setLogLikelihood(Const::CDC,
Const::kaon, 0.36);
4430 lAll->setLogLikelihood(Const::SVD,
Const::kaon, 0.38);
4431 lAll->setLogLikelihood(Const::KLM,
Const::kaon, 0.2);
4448 auto* lAllNoSVD = likelihood.
appendNew();
4452 if (det != Const::SVD) {
4453 lAllNoSVD->setLogLikelihood(det, hypo, lAll->getLogL(hypo, det));
4463 ldEdx->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4464 ldEdx->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4466 ldEdx->setLogLikelihood(Const::CDC,
Const::kaon, 0.36);
4467 ldEdx->setLogLikelihood(Const::SVD,
Const::kaon, 0.38);
4472 ldEdx->setLogLikelihood(Const::CDC,
Const::muon, 0.56);
4473 ldEdx->setLogLikelihood(Const::SVD,
Const::muon, 0.58);
4491 auto* particleAll = particles.appendNew(allTrack,
Const::pion);
4492 auto* particleNoSVD = particles.appendNew(noSVDTrack,
Const::pion);
4493 auto* particledEdx = particles.appendNew(dEdxTrack,
Const::pion);
4494 auto* particleNoID = particles.appendNew(noPIDTrack,
Const::pion);
4496 double numsumexp = std::exp(0.71) + std::exp(3.5) + std::exp(1.4) + std::exp(1.9) + std::exp(2.22) + std::exp(3.22);
4497 double numsumexp_noSVD = std::exp(0.61) + std::exp(2.92) + std::exp(1.12) + std::exp(1.52) + std::exp(1.74) + std::exp(2.54);
4500 EXPECT_FLOAT_EQ(electronID(particleAll), std::exp(0.71) / numsumexp);
4501 EXPECT_FLOAT_EQ(muonID(particleAll), std::exp(3.5) / numsumexp);
4502 EXPECT_FLOAT_EQ(pionID(particleAll), std::exp(1.4) / numsumexp);
4503 EXPECT_FLOAT_EQ(kaonID(particleAll), std::exp(1.9) / numsumexp);
4504 EXPECT_FLOAT_EQ(protonID(particleAll), std::exp(2.22) / numsumexp);
4505 EXPECT_FLOAT_EQ(deuteronID(particleAll), std::exp(3.22) / numsumexp);
4508 auto* particleElectron = particles.appendNew(allTrack,
Const::electron);
4509 auto* particleMuon = particles.appendNew(allTrack,
Const::muon);
4510 auto* particleKaon = particles.appendNew(allTrack,
Const::kaon);
4511 auto* particleProton = particles.appendNew(allTrack,
Const::proton);
4512 auto* particleDeuteron = particles.appendNew(allTrack,
Const::deuteron);
4514 EXPECT_FLOAT_EQ(particleID(particleAll), std::exp(1.4) / numsumexp);
4515 EXPECT_FLOAT_EQ(particleID(particleElectron), std::exp(0.71) / numsumexp);
4516 EXPECT_FLOAT_EQ(particleID(particleMuon), std::exp(3.5) / numsumexp);
4517 EXPECT_FLOAT_EQ(particleID(particleKaon), std::exp(1.9) / numsumexp);
4518 EXPECT_FLOAT_EQ(particleID(particleProton), std::exp(2.22) / numsumexp);
4519 EXPECT_FLOAT_EQ(particleID(particleDeuteron), std::exp(3.22) / numsumexp);
4522 EXPECT_FLOAT_EQ(electronID_noSVD(particleNoSVD), std::exp(0.61) / numsumexp_noSVD);
4523 EXPECT_FLOAT_EQ(muonID_noSVD(particleNoSVD), std::exp(2.92) / numsumexp_noSVD);
4524 EXPECT_FLOAT_EQ(pionID_noSVD(particleNoSVD), std::exp(1.12) / numsumexp_noSVD);
4525 EXPECT_FLOAT_EQ(kaonID_noSVD(particleNoSVD), std::exp(1.52) / numsumexp_noSVD);
4526 EXPECT_FLOAT_EQ(protonID_noSVD(particleNoSVD), std::exp(1.74) / numsumexp_noSVD);
4527 EXPECT_FLOAT_EQ(deuteronID_noSVD(particleNoSVD), std::exp(2.54) / numsumexp_noSVD);
4530 std::vector<double> v_pi_K {211., 321.};
4531 std::vector<double> v_pi_p {211., 2212.};
4532 std::vector<double> v_K_p {321., 2212.};
4533 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_K), std::exp(1.4) / (std::exp(1.4) + std::exp(1.9)));
4534 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_p), std::exp(1.4) / (std::exp(1.4) + std::exp(2.22)));
4535 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_K_p), std::exp(1.9) / (std::exp(1.9) + std::exp(2.22)));
4538 EXPECT_TRUE(std::isnan(electronID(particleNoID)));
4539 EXPECT_TRUE(std::isnan(muonID(particleNoID)));
4540 EXPECT_TRUE(std::isnan(pionID(particleNoID)));
4541 EXPECT_TRUE(std::isnan(kaonID(particleNoID)));
4542 EXPECT_TRUE(std::isnan(protonID(particleNoID)));
4543 EXPECT_TRUE(std::isnan(deuteronID(particleNoID)));
4546 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->function(particleAll)),
4548 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, ALL)")->function(particleAll)),
4550 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(2212, TOP, CDC)")->function(
4551 particleAll)), 0.86);
4554 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(1000010020, ALL)")->function(particleAll)),
4555 std::exp(3.22) / numsumexp);
4556 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(2212, ALL)")->function(particleAll)),
4557 std::exp(2.22) / numsumexp);
4558 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particleAll)),
4559 std::exp(1.4) / numsumexp);
4560 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(321, ALL)")->function(particleAll)),
4561 std::exp(1.9) / numsumexp);
4562 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(13, ALL)")->function(particleAll)),
4563 std::exp(3.5) / numsumexp);
4564 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(11, ALL)")->function(particleAll)),
4565 std::exp(0.71) / numsumexp);
4566 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particledEdx)),
4567 std::exp(0.54) / (std::exp(0.22) + std::exp(1.14) + std::exp(0.54) + std::exp(0.74) + std::exp(0.94) + std::exp(1.34)));
4568 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particledEdx)),
4569 std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC, SVD)")->function(particleAll)));
4570 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->function(particledEdx)),
4571 std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->function(particleAll)));
4572 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(321, CDC)")->function(particleAll)),
4573 std::exp(0.36) / (std::exp(0.12) + std::exp(0.26) + std::exp(0.36) + std::exp(0.46) + std::exp(0.56) + std::exp(0.66)));
4576 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->function(
4578 1.0 / (1.0 + std::exp(2.22 - 1.9)));
4579 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->function(
4581 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4582 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, CDC, SVD)")->function(
4584 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4587 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->function(
4589 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP, CDC, SVD)")->function(
4591 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->function(
4593 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->function(
4595 EXPECT_TRUE(std::isnan(std::get<double>
4596 (
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH)")->function(
4598 EXPECT_FALSE(std::isnan(std::get<double>
4599 (
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH, SVD)")->function(
4602 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG()")->function(particledEdx)), 1.00001e+09);
4603 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.5, 0.1, 0.1, 0.1, 0.1, 0.1)")->function(
4606 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.5, 0.1, 0.1, 0.1, 0.1)")->function(
4609 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.5, 0.1, 0.1, 0.1)")->function(
4612 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.5, 0.1, 0.1)")->function(
4615 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.1, 0.5, 0.1)")->function(
4618 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0, 1., 0, 0, 0, 0)")->function(particledEdx)),
4622 TEST_F(PIDVariableTest, MissingLikelihood)
4631 const float pValue = 0.5;
4632 const float bField = 1.5;
4634 TMatrixDSym cov6(6);
4636 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4637 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4638 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4640 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4641 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4643 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4647 Track* savedTrack1 = tracks.appendNew(mytrack);
4648 Track* savedTrack2 = tracks.appendNew(mytrack);
4649 Track* savedTrack3 = tracks.appendNew(mytrack);
4650 Track* savedTrack4 = tracks.appendNew(mytrack);
4660 l2->setLogLikelihood(Const::TOP,
Const::pion, 0.2);
4661 l2->setLogLikelihood(Const::ARICH,
Const::pion, 0.22);
4662 l2->setLogLikelihood(Const::ECL,
Const::pion, 0.24);
4663 l2->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4664 l2->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4667 auto* pion = particles.appendNew(savedTrack2,
Const::pion);
4670 l3->setLogLikelihood(Const::TOP,
Const::kaon, 0.3);
4671 l3->setLogLikelihood(Const::ARICH,
Const::kaon, 0.32);
4674 auto* kaon = particles.appendNew(savedTrack3,
Const::kaon);
4683 auto* proton = particles.appendNew(savedTrack4,
Const::proton);
4690 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(electron)), 0.0);
4691 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(pion)), 0.0);
4692 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(kaon)), 0.0);
4693 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(proton)), 1.0);
4695 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(electron)), 1.0);
4696 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(pion)), 0.0);
4697 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(kaon)), 0.0);
4698 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(proton)), 0.0);
4700 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(electron)), 0.0);
4701 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(pion)), 0.0);
4702 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(kaon)), 1.0);
4703 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(proton)), 0.0);
4706 class FlightInfoTest :
public ::testing::Test {
4709 void SetUp()
override
4716 particles.registerRelationTo(mcParticles);
4744 PxPyPzEVector momentum;
4745 TMatrixFSym error(7);
4752 error(5, 5) = 0.00875;
4754 Particle pi(PxPyPzEVector(1.59607, 1.19705, 0, 2), 211);
4755 momentum += pi.get4Vector();
4756 Particle* newpi = particles.appendNew(pi);
4760 Ks.setVertex(XYZVector(4.0, 5.0, 0.0));
4761 Ks.setMomentumVertexErrorMatrix(error);
4762 momentum += Ks.get4Vector();
4763 Ks.addExtraInfo(
"prodVertX", 1.0);
4764 Ks.addExtraInfo(
"prodVertY", 1.0);
4765 Ks.addExtraInfo(
"prodVertZ", 0.0);
4766 Ks.addExtraInfo(
"prodVertSxx", 0.04);
4767 Ks.addExtraInfo(
"prodVertSxy", 0.0);
4768 Ks.addExtraInfo(
"prodVertSxz", 0.0);
4769 Ks.addExtraInfo(
"prodVertSyx", 0.0);
4770 Ks.addExtraInfo(
"prodVertSyy", 0.00875);
4771 Ks.addExtraInfo(
"prodVertSyz", 0.0);
4772 Ks.addExtraInfo(
"prodVertSzx", 0.0);
4773 Ks.addExtraInfo(
"prodVertSzy", 0.0);
4774 Ks.addExtraInfo(
"prodVertSzz", 0.01);
4775 Particle* newKs = particles.appendNew(Ks);
4780 Dp.appendDaughter(newpi);
4781 Dp.appendDaughter(newKs);
4782 XYZVector motherVtx(1.0, 1.0, 0.0);
4783 Dp.setVertex(motherVtx);
4784 Dp.setMomentumVertexErrorMatrix(error);
4785 Dp.addExtraInfo(
"prodVertX", 0.0);
4786 Dp.addExtraInfo(
"prodVertY", 1.0);
4787 Dp.addExtraInfo(
"prodVertZ", -2.0);
4788 Dp.addExtraInfo(
"prodVertSxx", 0.04);
4789 Dp.addExtraInfo(
"prodVertSxy", 0.0);
4790 Dp.addExtraInfo(
"prodVertSxz", 0.0);
4791 Dp.addExtraInfo(
"prodVertSyx", 0.0);
4792 Dp.addExtraInfo(
"prodVertSyy", 0.01);
4793 Dp.addExtraInfo(
"prodVertSyz", 0.0);
4794 Dp.addExtraInfo(
"prodVertSzx", 0.0);
4795 Dp.addExtraInfo(
"prodVertSzy", 0.0);
4796 Dp.addExtraInfo(
"prodVertSzz", 0.1575);
4797 Particle* newDp = particles.appendNew(Dp);
4803 void TearDown()
override
4808 TEST_F(FlightInfoTest, flightDistance)
4811 const Particle* newKs = particles[1];
4814 ASSERT_NE(var,
nullptr);
4815 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
4817 TEST_F(FlightInfoTest, flightDistanceErr)
4820 const Particle* newKs = particles[1];
4823 ASSERT_NE(var,
nullptr);
4824 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4826 TEST_F(FlightInfoTest, flightTime)
4829 const Particle* newKs = particles[1];
4832 ASSERT_NE(var,
nullptr);
4836 TEST_F(FlightInfoTest, flightTimeErr)
4839 const Particle* newKs = particles[1];
4842 ASSERT_NE(var,
nullptr);
4843 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4846 TEST_F(FlightInfoTest, flightDistanceOfDaughter)
4849 const Particle* newDp = particles[2];
4852 ASSERT_NE(var,
nullptr);
4853 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4856 ASSERT_NE(var,
nullptr);
4857 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4859 TEST_F(FlightInfoTest, flightDistanceOfDaughterErr)
4862 const Particle* newDp = particles[2];
4865 ASSERT_NE(var,
nullptr);
4866 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4869 ASSERT_NE(var,
nullptr);
4870 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4872 TEST_F(FlightInfoTest, flightTimeOfDaughter)
4875 const Particle* newDp = particles[2];
4878 ASSERT_NE(var,
nullptr);
4884 ASSERT_NE(var,
nullptr);
4885 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4887 TEST_F(FlightInfoTest, flightTimeOfDaughterErr)
4890 const Particle* newDp = particles[2];
4893 ASSERT_NE(var,
nullptr);
4894 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4897 ASSERT_NE(var,
nullptr);
4898 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4900 TEST_F(FlightInfoTest, mcFlightDistanceOfDaughter)
4903 const Particle* newDp = particles[2];
4906 ASSERT_NE(var,
nullptr);
4908 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4911 ASSERT_NE(var,
nullptr);
4912 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4914 TEST_F(FlightInfoTest, mcFlightTimeOfDaughter)
4917 const Particle* newDp = particles[2];
4920 ASSERT_NE(var,
nullptr);
4925 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), Ks->getLifetime() / Ks->
getEnergy()*Ks->
getMass());
4928 ASSERT_NE(var,
nullptr);
4929 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4932 TEST_F(FlightInfoTest, vertexDistance)
4935 const Particle* newKS = particles[1];
4938 ASSERT_NE(var,
nullptr);
4939 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 5.0);
4942 TEST_F(FlightInfoTest, vertexDistanceError)
4945 const Particle* newKS = particles[1];
4948 ASSERT_NE(var,
nullptr);
4949 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 0.2);
4952 TEST_F(FlightInfoTest, vertexDistanceSignificance)
4955 const Particle* newKS = particles[1];
4958 ASSERT_NE(var,
nullptr);
4959 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 25);
4962 TEST_F(FlightInfoTest, vertexDistanceOfDaughter)
4965 const Particle* newDp = particles[2];
4968 ASSERT_NE(var,
nullptr);
4969 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4972 ASSERT_NE(var,
nullptr);
4973 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 6.0);
4976 ASSERT_NE(var,
nullptr);
4977 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4980 TEST_F(FlightInfoTest, vertexDistanceOfDaughterError)
4983 const Particle* newDp = particles[2];
4986 ASSERT_NE(var,
nullptr);
4987 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.2);
4990 ASSERT_NE(var,
nullptr);
4991 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.25);
4994 TEST_F(FlightInfoTest, vertexDistanceOfDaughterSignificance)
4997 const Particle* newDp = particles[2];
5000 ASSERT_NE(var,
nullptr);
5001 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 25);
5004 ASSERT_NE(var,
nullptr);
5005 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 24);
5008 class VertexVariablesTest :
public ::testing::Test {
5011 void SetUp()
override
5018 particles.registerRelationTo(mcParticles);
5033 Particle Ks(PxPyPzEVector(1.164, 1.55200, 0, 2), 310);
5047 Particle* newKs = particles.appendNew(Ks);
5052 void TearDown()
override
5059 TEST_F(VertexVariablesTest, mcDecayVertexX)
5062 const Particle* newKs = particles[0];
5065 ASSERT_NE(var,
nullptr);
5066 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 4.0);
5069 TEST_F(VertexVariablesTest, mcDecayVertexY)
5072 const Particle* newKs = particles[0];
5075 ASSERT_NE(var,
nullptr);
5076 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
5079 TEST_F(VertexVariablesTest, mcDecayVertexZ)
5082 const Particle* newKs = particles[0];
5085 ASSERT_NE(var,
nullptr);
5086 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.0);
5090 TEST_F(VertexVariablesTest, mcDecayVertexFromIPDistance)
5093 const Particle* newKs = particles[0];
5096 ASSERT_NE(var,
nullptr);
5097 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(4.0 * 4.0 + 5.0 * 5.0));
5100 TEST_F(VertexVariablesTest, mcDecayVertexRho)
5103 const Particle* newKs = particles[0];
5106 ASSERT_NE(var,
nullptr);
5107 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(4.0 * 4.0 + 5.0 * 5.0));
5110 TEST_F(VertexVariablesTest, mcProductionVertexX)
5113 const Particle* newKs = particles[0];
5116 ASSERT_NE(var,
nullptr);
5117 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
5120 TEST_F(VertexVariablesTest, mcProductionVertexY)
5123 const Particle* newKs = particles[0];
5126 ASSERT_NE(var,
nullptr);
5127 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
5130 TEST_F(VertexVariablesTest, mcProductionVertexZ)
5133 const Particle* newKs = particles[0];
5136 ASSERT_NE(var,
nullptr);
5137 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
5142 TEST_F(VertexVariablesTest, prodVertexX)
5145 const Particle* newKs = particles[0];
5148 ASSERT_NE(var,
nullptr);
5149 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
5151 TEST_F(VertexVariablesTest, prodVertexY)
5154 const Particle* newKs = particles[0];
5157 ASSERT_NE(var,
nullptr);
5158 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
5160 TEST_F(VertexVariablesTest, prodVertexZ)
5163 const Particle* newKs = particles[0];
5166 ASSERT_NE(var,
nullptr);
5167 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
5172 TEST_F(VertexVariablesTest, prodVertexCov)
5175 const Particle* newKs = particles[0];
5179 ASSERT_NE(var,
nullptr);
5180 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.1);
5182 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.2);
5184 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.3);
5186 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.4);
5188 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.5);
5190 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.6);
5192 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.7);
5194 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.8);
5196 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.9);
5198 ASSERT_NE(var,
nullptr);
5199 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.1));
5201 ASSERT_NE(var,
nullptr);
5202 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.5));
5204 ASSERT_NE(var,
nullptr);
5205 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.9));
5210 TEST_F(MetaVariableTest, KSFWVariables)
5221 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5224 EXPECT_B2ERROR(
Manager::Instance().getVariable(
"KSFWVariables(et, mask, FS1)"));
5227 TEST_F(MetaVariableTest, CleoConeCS)
5238 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5242 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5248 TEST_F(MetaVariableTest, TransformedNetworkOutput)
5251 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONSENSE)"));
5254 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, 0, NOTDOUBLE)"));
5255 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, NOTDOUBLE, 1)"));
5261 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle))));
5263 if (not eventExtraInfo.isValid())
5264 eventExtraInfo.create();
5266 EXPECT_TRUE(std::isnan(std::get<double>(var->function(
nullptr))));
Provides a type-safe way to pass members of the chargedStableSet set.
int getPDGCode() const
PDG code.
static DetectorSet set()
Accessor for the set of valid detector IDs.
static const ChargedStable muon
muon particle
static const ParticleSet chargedStableSet
set of charged stable particles
static const ChargedStable pion
charged pion particle
static const ParticleType Klong
K^0_L particle.
static const double speedOfLight
[cm/ns]
static const ChargedStable proton
proton particle
static const ParticleType Kshort
K^0_S particle.
static const ChargedStable kaon
charged kaon particle
static const ParticleType photon
photon particle
static const ChargedStable electron
electron particle
static const ChargedStable deuteron
deuteron particle
EStoreFlags
Flags describing behaviours of objects etc.
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
static DataStore & Instance()
Instance of singleton Store.
void setInitializeActive(bool active)
Setter for m_initializeActive.
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
void setTheta(double theta)
Set Theta of Shower (radian).
void setPhi(double phi)
Set Phi of Shower (radian).
void setClusterId(int clusterid)
Set cluster id.
void setHypothesis(EHypothesisBit hypothesis)
Set hypotheses.
void setEnergy(double energy)
Set Corrected Energy (GeV).
void setR(double r)
Set R (in cm).
Singleton class responsible for loading detector parameters from an XML file.
Class to represent Particle data in graph.
void comesFrom(GraphParticle &mother)
Tells the graph that this particle is a decay product of mother.
Class to build, validate and sort a particle decay chain.
void generateList(const std::string &name="", int options=c_setNothing)
Generates the MCParticle list and stores it in the StoreArray with the given name.
A Class to store the Monte Carlo particle information.
float getEnergy() const
Return particle energy in GeV.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
void setDecayTime(float time)
Set decay time.
void setMass(float mass)
Set particle mass.
void setDecayVertex(const ROOT::Math::XYZVector &vertex)
Set decay vertex.
float getMass() const
Return the particle mass in GeV.
void setProductionVertex(const ROOT::Math::XYZVector &vertex)
Set production vertex position.
ROOT::Math::PxPyPzEVector get4Vector() const
Return 4Vector of particle.
void setPDG(int pdg)
Set PDG code of the particle.
void set4Vector(const ROOT::Math::PxPyPzEVector &p4)
Sets the 4Vector of particle.
void setMomentum(const ROOT::Math::XYZVector &momentum)
Set particle momentum.
void setStatus(unsigned short int status)
Set Status code for the particle.
void setProductionTime(float time)
Set production time.
void setMassFromPDG()
Sets the mass for the particle from the particle's PDG code.
Class to store reconstructed particles.
void appendDaughter(const Particle *daughter, const bool updateType=true, const int daughterProperty=c_Ordinary)
Appends index of daughter to daughters index array.
void setVertex(const ROOT::Math::XYZVector &vertex)
Sets position (decay vertex)
double getEnergy() const
Returns total energy.
double getPDGMass(void) const
Returns uncertainty on the invariant mass (requires valid momentum error matrix)
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
void addExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
@ c_Unflavored
Is its own antiparticle or we don't know whether it is a particle/antiparticle.
@ c_Flavored
Is either particle or antiparticle.
double getP() const
Returns momentum magnitude (same as getMomentumMagnitude but with shorter name)
const Particle * getDaughter(unsigned i) const
Returns a pointer to the i-th daughter particle.
double getMass() const
Returns invariant mass (= nominal for FS particles)
static const ReferenceFrame & GetCurrent()
Get current rest frame.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
void clear() override
Delete all entries in this array.
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.
Type-safe access to single objects in the data store.
Class that bundles various TrackFitResults.
void setTrackFitResultIndex(const Const::ChargedStable &chargedStable, short index)
Set an index (for positive values) or unavailability-code (index = -1) for a specific mass hypothesis...
A template class to apply the reference frame.
Object holding information for V0s.
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
static Manager & Instance()
get singleton instance.
static Gearbox & getInstance()
Return reference to the Gearbox instance.
double sqrt(double a)
sqrt for double
GraphParticle & addParticle()
Add new particle to the graph.
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Abstract base class for different kinds of events.
A variable returning a floating-point value for a given Particle.
FunctionPtr function
Pointer to function.