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>
16#include <analysis/VariableManager/Utility.h>
18#include <analysis/dataobjects/Particle.h>
19#include <analysis/dataobjects/ParticleExtraInfoMap.h>
20#include <analysis/dataobjects/ParticleList.h>
21#include <framework/dataobjects/EventExtraInfo.h>
22#include <analysis/dataobjects/RestOfEvent.h>
23#include <analysis/utility/ReferenceFrame.h>
25#include <framework/datastore/StoreArray.h>
26#include <framework/datastore/StoreObjPtr.h>
27#include <framework/utilities/TestHelpers.h>
28#include <framework/logging/Logger.h>
29#include <framework/gearbox/Gearbox.h>
30#include <framework/gearbox/Const.h>
32#include <mdst/dataobjects/MCParticle.h>
33#include <mdst/dataobjects/MCParticleGraph.h>
34#include <mdst/dataobjects/PIDLikelihood.h>
35#include <mdst/dataobjects/Track.h>
36#include <mdst/dataobjects/V0.h>
37#include <mdst/dataobjects/ECLCluster.h>
38#include <mdst/dataobjects/KLMCluster.h>
40#include <gtest/gtest.h>
42#include <TMatrixFSym.h>
44#include <Math/Cartesian2D.h>
45#include <Math/Vector3D.h>
46#include <Math/Vector4D.h>
52using namespace Belle2::Variable;
53using namespace ROOT::Math;
58 TEST(KinematicVariableTest, Variable)
64 gearbox.setBackends({std::string(
"file:")});
66 gearbox.open(
"geometry/Belle2.xml",
false);
69 Particle pH({0.290582573157898, 0, 6.99796952744559, 7.004}, 11);
70 Particle pL({0.166035330010433, 0, -3.99855423973071, 4.002}, -11);
72 Particle p({0, 0.999999869440028, 0, 1.0}, -11);
73 const double eps = 1e-15;
76 EXPECT_NEAR(0.0, particlePx(&pH), eps);
77 EXPECT_NEAR(0.0, particlePy(&pH), eps);
78 EXPECT_NEAR(0.0, particlePx(&pL), eps);
79 EXPECT_NEAR(0.0, particlePy(&pL), eps);
80 EXPECT_FLOAT_EQ(5.289778893721573, particlePz(&pH));
81 EXPECT_FLOAT_EQ(-5.289778893721573, particlePz(&pL));
82 EXPECT_FLOAT_EQ(10.579557836806245064 / 2, particleE(&pH));
83 EXPECT_FLOAT_EQ(10.579557836806245064 / 2, particleE(&pL));
85 EXPECT_FLOAT_EQ(0.999999869440028, particlePy(&p));
89 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
98 p.setMomentumVertexErrorMatrix(error);
100 EXPECT_FLOAT_EQ(0.9, particleP(&p));
101 EXPECT_FLOAT_EQ(1.0, particleE(&p));
102 EXPECT_FLOAT_EQ(0.1, particlePx(&p));
103 EXPECT_FLOAT_EQ(-0.4, particlePy(&p));
104 EXPECT_FLOAT_EQ(0.8, particlePz(&p));
105 EXPECT_FLOAT_EQ(0.412310562, particlePt(&p));
106 EXPECT_FLOAT_EQ(0.8 / 0.9, particleCosTheta(&p));
107 EXPECT_FLOAT_EQ(-1.325817664, particlePhi(&p));
109 EXPECT_FLOAT_EQ(0.737446378, particlePErr(&p));
110 EXPECT_FLOAT_EQ(sqrt(0.05), particlePxErr(&p));
111 EXPECT_FLOAT_EQ(sqrt(0.2), particlePyErr(&p));
112 EXPECT_FLOAT_EQ(sqrt(0.4), particlePzErr(&p));
113 EXPECT_FLOAT_EQ(0.488093530, particlePtErr(&p));
114 EXPECT_FLOAT_EQ(0.156402664, particleCosThetaErr(&p));
115 EXPECT_FLOAT_EQ(0.263066820, particlePhiErr(&p));
120 EXPECT_FLOAT_EQ(0.68174648, particleP(&p));
121 EXPECT_FLOAT_EQ(0.80918372, particleE(&p));
122 EXPECT_FLOAT_EQ(0.058562335, particlePx(&p));
123 EXPECT_FLOAT_EQ(-0.40000001, particlePy(&p));
124 EXPECT_FLOAT_EQ(0.5489524, particlePz(&p));
125 EXPECT_FLOAT_EQ(0.40426421, particlePt(&p));
126 EXPECT_FLOAT_EQ(0.80521482, particleCosTheta(&p));
127 EXPECT_FLOAT_EQ(-1.4254233, particlePhi(&p));
129 EXPECT_FLOAT_EQ(sqrt(0.2), particlePyErr(&p));
134 EXPECT_ALL_NEAR(particleP(&p), 0.0, 1e-9);
135 EXPECT_FLOAT_EQ(0.4358899, particleE(&p));
136 EXPECT_ALL_NEAR(0.0, particlePx(&p), 1e-9);
137 EXPECT_ALL_NEAR(0.0, particlePy(&p), 1e-9);
138 EXPECT_ALL_NEAR(0.0, particlePz(&p), 1e-9);
139 EXPECT_ALL_NEAR(0.0, particlePt(&p), 1e-9);
145 EXPECT_FLOAT_EQ(0.9, particleP(&p));
146 EXPECT_FLOAT_EQ(1.0, particleE(&p));
147 EXPECT_FLOAT_EQ(0.1, particlePx(&p));
148 EXPECT_FLOAT_EQ(-0.4, particlePy(&p));
149 EXPECT_FLOAT_EQ(0.8, particlePz(&p));
150 EXPECT_FLOAT_EQ(0.412310562, particlePt(&p));
151 EXPECT_FLOAT_EQ(0.8 / 0.9, particleCosTheta(&p));
152 EXPECT_FLOAT_EQ(-1.325817664, particlePhi(&p));
154 EXPECT_FLOAT_EQ(0.737446378, particlePErr(&p));
155 EXPECT_FLOAT_EQ(sqrt(0.05), particlePxErr(&p));
156 EXPECT_FLOAT_EQ(sqrt(0.2), particlePyErr(&p));
157 EXPECT_FLOAT_EQ(sqrt(0.4), particlePzErr(&p));
158 EXPECT_FLOAT_EQ(0.488093530, particlePtErr(&p));
159 EXPECT_FLOAT_EQ(0.156402664, particleCosThetaErr(&p));
160 EXPECT_FLOAT_EQ(0.263066820, particlePhiErr(&p));
165 EXPECT_FLOAT_EQ(0.9, particleP(&p));
166 EXPECT_FLOAT_EQ(1.0, particleE(&p));
167 EXPECT_FLOAT_EQ(0.1, particlePx(&p));
168 EXPECT_FLOAT_EQ(-0.4, particlePy(&p));
169 EXPECT_FLOAT_EQ(0.8, particlePz(&p));
170 EXPECT_FLOAT_EQ(0.412310562, particlePt(&p));
171 EXPECT_FLOAT_EQ(0.8 / 0.9, particleCosTheta(&p));
172 EXPECT_FLOAT_EQ(-1.325817664, particlePhi(&p));
174 EXPECT_FLOAT_EQ(0.737446378, particlePErr(&p));
175 EXPECT_FLOAT_EQ(sqrt(0.05), particlePxErr(&p));
176 EXPECT_FLOAT_EQ(sqrt(0.2), particlePyErr(&p));
177 EXPECT_FLOAT_EQ(sqrt(0.4), particlePzErr(&p));
178 EXPECT_FLOAT_EQ(0.488093530, particlePtErr(&p));
179 EXPECT_FLOAT_EQ(0.156402664, particleCosThetaErr(&p));
180 EXPECT_FLOAT_EQ(0.263066820, particlePhiErr(&p));
183 EXPECT_FLOAT_EQ(-0.1, frame.getMomentumErrorMatrix(&p)(0, 1));
184 EXPECT_FLOAT_EQ(0.9, frame.getMomentumErrorMatrix(&p)(0, 2));
189 EXPECT_FLOAT_EQ(0.9, particleP(&p));
190 EXPECT_FLOAT_EQ(1.0, particleE(&p));
191 EXPECT_FLOAT_EQ(0.1, particlePx(&p));
192 EXPECT_FLOAT_EQ(-0.8, particlePy(&p));
193 EXPECT_FLOAT_EQ(-0.4, particlePz(&p));
195 EXPECT_FLOAT_EQ(0.737446378, particlePErr(&p));
196 EXPECT_FLOAT_EQ(sqrt(0.05), particlePxErr(&p));
197 EXPECT_FLOAT_EQ(sqrt(0.4), particlePyErr(&p));
198 EXPECT_FLOAT_EQ(sqrt(0.2), particlePzErr(&p));
201 EXPECT_FLOAT_EQ(-0.9, frame.getMomentumErrorMatrix(&p)(0, 1));
202 EXPECT_FLOAT_EQ(-0.1, frame.getMomentumErrorMatrix(&p)(0, 2));
207 EXPECT_FLOAT_EQ(0.68174648, particleP(&p));
208 EXPECT_FLOAT_EQ(0.80918372, particleE(&p));
209 EXPECT_FLOAT_EQ(0.058562335, particlePx(&p));
210 EXPECT_FLOAT_EQ(-0.40000001, particlePy(&p));
211 EXPECT_FLOAT_EQ(0.5489524, particlePz(&p));
212 EXPECT_FLOAT_EQ(0.40426421, particlePt(&p));
213 EXPECT_FLOAT_EQ(0.80521482, particleCosTheta(&p));
214 EXPECT_FLOAT_EQ(-1.4254233, particlePhi(&p));
216 EXPECT_FLOAT_EQ(sqrt(0.2), particlePyErr(&p));
220 Particle pinv({ -0.1, 0.4, -0.8, 1.0 }, 411);
222 Particle p2({ 0.0, 0.0, 0.0, 0.4358899}, 411);
223 EXPECT_FLOAT_EQ(0.9, particleP(&p2));
224 EXPECT_FLOAT_EQ(1.0, particleE(&p2));
225 EXPECT_FLOAT_EQ(0.1, particlePx(&p2));
226 EXPECT_FLOAT_EQ(-0.4, particlePy(&p2));
227 EXPECT_FLOAT_EQ(0.8, particlePz(&p2));
228 EXPECT_FLOAT_EQ(0.412310562, particlePt(&p2));
229 EXPECT_FLOAT_EQ(0.8 / 0.9, particleCosTheta(&p2));
230 EXPECT_FLOAT_EQ(-1.325817664, particlePhi(&p2));
235 Particle p({ 0.0, 0.0, 0.0, 0.0 }, 411);
236 EXPECT_FLOAT_EQ(0.0, particleP(&p));
237 EXPECT_FLOAT_EQ(0.0, particleE(&p));
238 EXPECT_FLOAT_EQ(0.0, particlePx(&p));
239 EXPECT_FLOAT_EQ(0.0, particlePy(&p));
240 EXPECT_FLOAT_EQ(0.0, particlePz(&p));
241 EXPECT_FLOAT_EQ(0.0, particlePt(&p));
242 EXPECT_FLOAT_EQ(1.0, particleCosTheta(&p));
243 EXPECT_FLOAT_EQ(0.0, particlePhi(&p));
246 EXPECT_FLOAT_EQ(0.0, particleP(&p));
247 EXPECT_FLOAT_EQ(0.0, particleE(&p));
248 EXPECT_FLOAT_EQ(0.0, particlePx(&p));
249 EXPECT_FLOAT_EQ(0.0, particlePy(&p));
250 EXPECT_FLOAT_EQ(0.0, particlePz(&p));
251 EXPECT_FLOAT_EQ(0.0, particlePt(&p));
252 EXPECT_FLOAT_EQ(1.0, particleCosTheta(&p));
253 EXPECT_FLOAT_EQ(0.0, particlePhi(&p));
259 particles.registerInDataStore();
263 PxPyPzEVector vec1 = {0.0, +0.332174566, 0.0, T.
getCMSEnergy() / 2.};
264 PxPyPzEVector vec2 = {0.0, -0.332174566, 0.0, T.
getCMSEnergy() / 2.};
272 EXPECT_ALL_NEAR(m2RecoilSignalSide(p0), 0.0, 1e-7);
279 TEST(VertexVariableTest, Variable)
285 gearbox.setBackends({std::string(
"file:")});
287 gearbox.open(
"geometry/Belle2.xml",
false);
289 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 11);
291 p.setVertex(XYZVector(1.0, 2.0, 2.0));
293 EXPECT_FLOAT_EQ(1.0, particleDX(&p));
294 EXPECT_FLOAT_EQ(2.0, particleDY(&p));
295 EXPECT_FLOAT_EQ(2.0, particleDZ(&p));
296 EXPECT_FLOAT_EQ(std::sqrt(5.0), particleDRho(&p));
297 EXPECT_FLOAT_EQ(3.0, particleDistance(&p));
298 EXPECT_FLOAT_EQ(0.5, particlePvalue(&p));
302 EXPECT_FLOAT_EQ(1.026177, particleDX(&p));
303 EXPECT_FLOAT_EQ(2.0, particleDY(&p));
304 EXPECT_FLOAT_EQ(2.2568872, particleDZ(&p));
305 EXPECT_FLOAT_EQ(hypot(2.0, 1.026177), particleDRho(&p));
306 EXPECT_FLOAT_EQ(3.1853695, particleDistance(&p));
307 EXPECT_FLOAT_EQ(0.5, particlePvalue(&p));
311 Particle p2({ 0.1, -0.4, 0.8, 1.0 }, 11);
313 p2.setVertex(XYZVector(1.0, 2.0, 2.0));
316 EXPECT_FLOAT_EQ(0.0, particleDX(&p));
317 EXPECT_FLOAT_EQ(0.0, particleDY(&p));
318 EXPECT_FLOAT_EQ(0.0, particleDZ(&p));
319 EXPECT_FLOAT_EQ(0.0, particleDRho(&p));
320 EXPECT_FLOAT_EQ(0.0, particleDistance(&p));
321 EXPECT_FLOAT_EQ(0.5, particlePvalue(&p));
344 TEST(TrackVariablesTest, Variable)
359 const float pValue = 0.5;
360 const float bField = 1.5;
365 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
366 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
367 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
370 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
371 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
373 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
387 EXPECT_TRUE(std::get<bool>(vIsFromTrack->
function(part)));
388 EXPECT_FALSE(std::get<bool>(vIsFromECL->
function(part)));
389 EXPECT_FALSE(std::get<bool>(vIsFromKLM->
function(part)));
390 EXPECT_FALSE(std::get<bool>(vIsFromV0->
function(part)));
391 EXPECT_FLOAT_EQ(0.5, trackPValue(part));
392 EXPECT_FLOAT_EQ(position.Z(), trackZ0(part));
393 EXPECT_FLOAT_EQ(position.Rho(), trackD0(part));
394 EXPECT_FLOAT_EQ(3, trackNCDCHits(part));
395 EXPECT_FLOAT_EQ(24, trackNSVDHits(part));
396 EXPECT_FLOAT_EQ(12, trackNPXDHits(part));
400 myResults.
appendNew(position, momentum, cov6, charge * -1,
406 myV0s.
appendNew(
V0(std::pair(savedTrack, myResults[0]), std::pair(savedTrack2, myResults[1]), 0.0, 0.0, 0.0));
407 const PxPyPzEVector v0Momentum(2 * momentum.X(), 2 * momentum.Y(), 2 * momentum.Z(), (momentum * 2).R());
408 auto v0particle = myParticles.
appendNew(v0Momentum, 22,
410 v0particle->appendDaughter(0,
false);
411 v0particle->appendDaughter(1,
false);
414 EXPECT_FALSE(std::get<bool>(vIsFromTrack->
function(v0particle)));
415 EXPECT_FALSE(std::get<bool>(vIsFromECL->
function(v0particle)));
416 EXPECT_FALSE(std::get<bool>(vIsFromKLM->
function(v0particle)));
417 EXPECT_TRUE(std::get<bool>(vIsFromV0->
function(v0particle)));
420 EXPECT_EQ(std::get<int>(vNDaughters->
function(v0particle)), 2);
423 class MCTruthVariablesTest :
public ::testing::Test {
443 particles.registerInDataStore();
448 particles.registerRelationTo(mcparticles);
477 cl0->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
478 cl0->setClusterId(0);
482 cl1->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
483 cl1->setClusterId(1);
488 ROOT::Math::XYZVector(), ROOT::Math::XYZVector(), cov, -1,
Const::electron, 0.5, 1.5,
489 static_cast<unsigned long long int>(0x300000000000000), 16777215, 0);
492 electron_tr->addRelationTo(cl1);
496 ROOT::Math::XYZVector(), ROOT::Math::XYZVector(), cov1, -1,
Const::pion, 0.51, 1.5,
497 static_cast<unsigned long long int>(0x300000000000000), 16777215, 0);
500 pion_tr->addRelationTo(cl1);
503 cl0->addRelationTo(true_photon, 12.3);
504 cl0->addRelationTo(true_electron, 2.3);
505 cl1->addRelationTo(true_electron, 45.6);
506 cl1->addRelationTo(true_photon, 5.6);
507 cl1->addRelationTo(true_pion, 15.6);
509 electron_tr->addRelationTo(true_electron);
510 pion_tr->addRelationTo(true_pion);
513 const auto* photon = particles.appendNew(
Particle(cl0));
516 const auto* misid_photon = particles.appendNew(
Particle(cl1));
519 photon->addRelationTo(true_photon);
520 electron->addRelationTo(true_electron);
521 pion->addRelationTo(true_pion);
522 misid_photon->addRelationTo(true_electron);
525 virtual void TearDown()
531 TEST_F(MCTruthVariablesTest, mcCosThetaBetweenParticleAndNominalB)
537 particles.registerInDataStore();
539 particles.registerRelationTo(mcParticles);
552 graphParticleDaughter1.
comesFrom(graphParticleMother);
553 graphParticleDaughter2.
comesFrom(graphParticleMother);
554 graphParticleGranddaughter1.
comesFrom(graphParticleDaughter1);
555 graphParticleGranddaughter2.
comesFrom(graphParticleDaughter1);
556 graphParticleGranddaughter3.
comesFrom(graphParticleDaughter1);
558 graphParticleMother.
setPDG(-521);
559 graphParticleDaughter1.
setPDG(421);
563 graphParticleGranddaughter3.
setPDG(12);
570 graphParticleMother.
setMass(16.55294535724685);
573 PxPyPzEVector dummyP4(1, 2, 1, 5);
574 double dummyM = 4.3589;
576 graphParticleDaughter1.
setMass(dummyM);
578 graphParticleDaughter2.
setMass(dummyM);
579 graphParticleGranddaughter1.
set4Vector(dummyP4);
580 graphParticleGranddaughter1.
setMass(dummyM);
581 graphParticleGranddaughter2.
set4Vector(dummyP4);
582 graphParticleGranddaughter2.
setMass(dummyM);
587 auto* pMother = particles.appendNew(dummyP4, -521);
588 pMother->addRelationTo(mcParticles[0]);
590 particles.appendNew(dummyP4, 421)->addRelationTo(mcParticles[1]);
591 particles.appendNew(dummyP4, -211)->addRelationTo(mcParticles[2]);
592 particles.appendNew(dummyP4, -321)->addRelationTo(mcParticles[3]);
593 particles.appendNew(dummyP4, -11)->addRelationTo(mcParticles[4]);
594 particles.appendNew(dummyP4, 12)->addRelationTo(mcParticles[5]);
597 double M_B = pMother->getPDGMass();
598 double p_B = std::sqrt(E_B * E_B - M_B * M_B);
601 double E_Y = p4_Y_CMS.E();
602 double p_Y = p4_Y_CMS.P();
603 double M_Y = p4_Y_CMS.M();
605 double expectedCosBY = (2 * E_B * E_Y - M_B * M_B - M_Y * M_Y) / (2 * p_B * p_Y);
609 EXPECT_NEAR(std::get<double>(mcCosBY->function(pMother)), expectedCosBY, 1e-4);
612 TEST_F(MCTruthVariablesTest, ECLMCMatchWeightVariable)
615 const auto* photon = particles[0];
616 const auto* electron = particles[1];
617 const auto* pion = particles[2];
620 EXPECT_FLOAT_EQ(std::get<double>(weight->function(photon)), 12.3);
621 EXPECT_FLOAT_EQ(std::get<double>(weight->function(electron)), 45.6);
622 EXPECT_FLOAT_EQ(std::get<double>(weight->function(pion)), 15.6);
625 TEST_F(MCTruthVariablesTest, ECLBestMCMatchVariables)
628 const auto* photon = particles[0];
629 const auto* electron = particles[1];
630 const auto* pion = particles[2];
631 const auto* misid_photon = particles[3];
641 EXPECT_FLOAT_EQ(std::get<double>(weight->function(photon)), 12.3);
642 EXPECT_FLOAT_EQ(std::get<double>(weight->function(electron)), 45.6);
643 EXPECT_FLOAT_EQ(std::get<double>(weight->function(pion)), 45.6);
644 EXPECT_FLOAT_EQ(std::get<double>(weight->function(misid_photon)), 45.6);
648 class EventVariableTest :
public ::testing::Test {
651 void SetUp()
override
661 void TearDown()
override
667 TEST_F(EventVariableTest, ExperimentRunEventDateAndTime)
677 EXPECT_FALSE(std::get<double>(date->
function(
nullptr)) == std::get<double>(date->
function(
nullptr)));
678 EXPECT_FALSE(std::get<double>(year->
function(
nullptr)) == std::get<double>(year->
function(
nullptr)));
679 EXPECT_FALSE(std::get<double>(time->function(
nullptr)) == std::get<double>(time->function(
nullptr)));
686 evtMetaData->setExperiment(1337);
687 evtMetaData->setRun(12345);
688 evtMetaData->setEvent(54321);
689 evtMetaData->setTime(1288569600e9);
694 EXPECT_EQ(std::get<int>(exp->function(
nullptr)), 1337);
695 EXPECT_EQ(std::get<int>(run->function(
nullptr)), 12345);
696 EXPECT_EQ(std::get<int>(evt->
function(
nullptr)), 54321);
697 EXPECT_FLOAT_EQ(std::get<double>(date->
function(
nullptr)), 20101101.);
698 EXPECT_FLOAT_EQ(std::get<double>(year->
function(
nullptr)), 2010.);
699 EXPECT_FLOAT_EQ(std::get<double>(time->function(
nullptr)), 1288569600);
702 TEST_F(EventVariableTest, TestGlobalCounters)
706 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 0);
708 for (
unsigned i = 0; i < 10; ++i)
711 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 10);
716 TEST_F(EventVariableTest, TestIfContinuumEvent_ForContinuumEvent)
721 particles.registerRelationTo(mcParticles);
724 auto* mcParticle = mcParticles.
appendNew();
727 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
728 p1->addRelationTo(mcParticle);
733 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
734 p2->addRelationTo(mcParticle);
737 ASSERT_NE(var,
nullptr);
738 EXPECT_TRUE(std::get<bool>(var->function(p1)));
739 EXPECT_TRUE(std::get<bool>(var->function(p2)));
741 ASSERT_NE(varN,
nullptr);
742 EXPECT_FALSE(std::get<bool>(varN->
function(p1)));
743 EXPECT_FALSE(std::get<bool>(varN->
function(p2)));
746 TEST_F(EventVariableTest, TestIfContinuumEvent_ForUpsilon4SEvent)
754 auto* mcParticle = mcParticles2.
appendNew();
757 auto* p3 = particles2.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
758 p3->addRelationTo(mcParticle);
761 mcParticle->setPDG(300553);
763 auto* p4 = particles2.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 300553);
764 p4->addRelationTo(mcParticle);
767 ASSERT_NE(var2,
nullptr);
768 EXPECT_FALSE(std::get<bool>(var2->
function(p3)));
769 EXPECT_FALSE(std::get<bool>(var2->
function(p4)));
771 ASSERT_NE(var2N,
nullptr);
772 EXPECT_TRUE(std::get<bool>(var2N->
function(p3)));
773 EXPECT_TRUE(std::get<bool>(var2N->
function(p4)));
776 TEST_F(EventVariableTest, TestIfContinuumEvent_ForWrongReconstructedUpsilon4SEvent)
784 auto* mcParticle = mcParticles3.
appendNew();
787 auto* p5 = particles3.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
788 p5->addRelationTo(mcParticle);
791 mcParticle->setPDG(300553);
793 auto* p6 = particles3.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 15);
794 p6->addRelationTo(mcParticle);
797 ASSERT_NE(var3,
nullptr);
798 EXPECT_FALSE(std::get<bool>(var3->
function(p5)));
799 EXPECT_FALSE(std::get<bool>(var3->
function(p6)));
801 ASSERT_NE(var3N,
nullptr);
802 EXPECT_TRUE(std::get<bool>(var3N->
function(p5)));
803 EXPECT_TRUE(std::get<bool>(var3N->
function(p6)));
807 class MetaVariableTest :
public ::testing::Test {
810 void SetUp()
override
821 void TearDown()
override
827 TEST_F(MetaVariableTest, countDaughters)
829 PxPyPzEVector momentum;
830 const int nDaughters = 6;
832 std::vector<int> daughterIndices;
833 for (
int i = 0; i < nDaughters; i++) {
834 Particle d(PxPyPzEVector(1, 0, 0, 3.0), (i % 2) ? 211 : -211);
835 momentum += d.get4Vector();
836 Particle* newDaughters = particles.appendNew(d);
842 ASSERT_NE(var,
nullptr);
843 EXPECT_EQ(std::get<int>(var->function(p)), 3);
846 ASSERT_NE(var,
nullptr);
847 EXPECT_EQ(std::get<int>(var->function(p)), 6);
851 TEST_F(MetaVariableTest, useRestFrame)
854 gearbox.setBackends({std::string(
"file:")});
856 gearbox.open(
"geometry/Belle2.xml",
false);
858 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
859 p.setVertex(XYZVector(1.0, 2.0, 2.0));
862 ASSERT_NE(var,
nullptr);
863 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
866 ASSERT_NE(var,
nullptr);
867 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
870 ASSERT_NE(var,
nullptr);
871 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
874 ASSERT_NE(var,
nullptr);
875 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.0, 1e-9);
878 ASSERT_NE(var,
nullptr);
879 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.4358899);
882 ASSERT_NE(var,
nullptr);
883 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.0);
886 TEST_F(MetaVariableTest, useLabFrame)
888 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
889 p.setVertex(XYZVector(1.0, 2.0, 2.0));
892 ASSERT_NE(var,
nullptr);
893 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
896 ASSERT_NE(var,
nullptr);
897 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
900 ASSERT_NE(var,
nullptr);
901 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
904 ASSERT_NE(var,
nullptr);
905 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
908 ASSERT_NE(var,
nullptr);
909 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
912 ASSERT_NE(var,
nullptr);
913 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
916 TEST_F(MetaVariableTest, useCMSFrame)
919 gearbox.setBackends({std::string(
"file:")});
921 gearbox.open(
"geometry/Belle2.xml",
false);
923 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
924 p.setVertex(XYZVector(1.0, 2.0, 2.0));
927 ASSERT_NE(var,
nullptr);
928 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
931 ASSERT_NE(var,
nullptr);
932 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
935 ASSERT_NE(var,
nullptr);
936 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
939 ASSERT_NE(var,
nullptr);
940 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.68174650327489894064);
943 ASSERT_NE(var,
nullptr);
944 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.80918372124478121776);
947 ASSERT_NE(var,
nullptr);
948 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.1853695);
951 TEST_F(MetaVariableTest, useTagSideRecoilRestFrame)
955 particles.registerInDataStore();
959 PxPyPzEVector vec1 = {0.0, +0.332174566, 0.0, T.
getCMSEnergy() / 2.};
960 PxPyPzEVector vec2 = {0.0, -0.332174566, 0.0, T.
getCMSEnergy() / 2.};
969 ASSERT_NE(var,
nullptr);
970 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
973 ASSERT_NE(var,
nullptr);
974 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
977 ASSERT_NE(var,
nullptr);
978 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
981 ASSERT_NE(var,
nullptr);
982 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
985 ASSERT_NE(var,
nullptr);
986 EXPECT_NEAR(std::get<double>(var->function(p0)), p1->getMass(), 1e-6);
990 TEST_F(MetaVariableTest, extraInfo)
992 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 11);
993 p.addExtraInfo(
"pi", 3.14);
996 ASSERT_NE(var,
nullptr);
997 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.14);
1000 EXPECT_TRUE(std::isnan(std::get<double>(var->function(
nullptr))));
1003 TEST_F(MetaVariableTest, eventExtraInfo)
1006 if (not eventExtraInfo.isValid())
1007 eventExtraInfo.create();
1008 eventExtraInfo->addExtraInfo(
"pi", 3.14);
1010 ASSERT_NE(var,
nullptr);
1011 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1014 TEST_F(MetaVariableTest, eventCached)
1017 ASSERT_NE(var,
nullptr);
1018 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1020 EXPECT_TRUE(eventExtraInfo.isValid());
1021 EXPECT_TRUE(eventExtraInfo->hasExtraInfo(
"__constant__bo3__pt14__bc"));
1022 EXPECT_FLOAT_EQ(eventExtraInfo->getExtraInfo(
"__constant__bo3__pt14__bc"), 3.14);
1023 eventExtraInfo->addExtraInfo(
"__eventExtraInfo__bopi__bc", 3.14);
1025 ASSERT_NE(var,
nullptr);
1026 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1029 TEST_F(MetaVariableTest, particleCached)
1031 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1033 ASSERT_NE(var,
nullptr);
1034 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
1035 EXPECT_TRUE(p.hasExtraInfo(
"__px"));
1036 EXPECT_FLOAT_EQ(p.getExtraInfo(
"__px"), 0.1);
1037 p.addExtraInfo(
"__py", -0.5);
1039 ASSERT_NE(var,
nullptr);
1040 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.5);
1043 TEST_F(MetaVariableTest, basicMathTest)
1045 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1048 ASSERT_NE(var,
nullptr);
1049 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.4);
1052 ASSERT_NE(var,
nullptr);
1053 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.8);
1056 ASSERT_NE(var,
nullptr);
1057 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 2.0);
1060 ASSERT_NE(var,
nullptr);
1061 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1065 ASSERT_NE(var,
nullptr);
1066 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1070 ASSERT_NE(var,
nullptr);
1071 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1075 ASSERT_NE(var,
nullptr);
1076 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.5707963267948966);
1080 ASSERT_NE(var,
nullptr);
1081 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1085 ASSERT_NE(var,
nullptr);
1086 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.5707963267948966);
1090 TEST_F(MetaVariableTest, formula)
1097 Particle p({ 0.1, -0.4, 0.8, 2.0 }, -411);
1100 ASSERT_NE(var,
nullptr);
1101 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.3);
1104 ASSERT_NE(var,
nullptr);
1105 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1108 ASSERT_NE(var,
nullptr);
1109 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.04);
1112 ASSERT_NE(var,
nullptr);
1113 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -4.0);
1116 ASSERT_NE(var,
nullptr);
1117 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.01);
1120 ASSERT_NE(var,
nullptr);
1121 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1124 ASSERT_NE(var,
nullptr);
1125 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1128 ASSERT_NE(var,
nullptr);
1129 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.41231057);
1130 double pt = std::get<double>(var->function(&p));
1133 ASSERT_NE(var,
nullptr);
1134 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), pt);
1137 ASSERT_NE(var,
nullptr);
1138 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1141 ASSERT_NE(var,
nullptr);
1142 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1145 ASSERT_NE(var,
nullptr);
1146 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1149 ASSERT_NE(var,
nullptr);
1150 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 411.0);
1153 ASSERT_NE(var,
nullptr);
1154 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -168921.0);
1157 ASSERT_NE(var,
nullptr);
1158 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 8.33);
1161 ASSERT_NE(var,
nullptr);
1162 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -8.33);
1165 ASSERT_NE(var,
nullptr);
1166 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 411);
1169 TEST_F(MetaVariableTest, passesCut)
1171 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1172 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 411);
1175 ASSERT_NE(var,
nullptr);
1176 EXPECT_TRUE(std::get<bool>(var->function(&p)));
1177 EXPECT_FALSE(std::get<bool>(var->function(&p2)));
1182 TEST_F(MetaVariableTest, unmask)
1187 particles.registerInDataStore();
1189 particles.registerRelationTo(mcParticles);
1203 graphParticleGrandMother.
setPDG(-521);
1205 graphParticleAunt.
setPDG(-14);
1207 graphParticleDaughter2.
setPDG(14);
1209 graphParticleMother.
comesFrom(graphParticleGrandMother);
1210 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1211 graphParticleDaughter1.
comesFrom(graphParticleMother);
1212 graphParticleDaughter2.
comesFrom(graphParticleMother);
1217 auto* mcGrandMother = mcParticles[0];
1220 auto* mcMother = mcParticles[1];
1223 auto* mcAunt = mcParticles[2];
1226 auto* mcDaughter1 = mcParticles[3];
1229 auto* mcDaughter2 = mcParticles[4];
1232 auto* pGrandMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1233 pGrandMother->addRelationTo(mcGrandMother);
1235 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1236 pMother->addRelationTo(mcMother);
1239 pMother->writeExtraInfo(
"mcErrors", 8);
1240 pGrandMother->writeExtraInfo(
"mcErrors", 8 | 16);
1243 ASSERT_NE(var1,
nullptr);
1244 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pMother)), 0);
1245 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pGrandMother)), 16);
1246 ASSERT_NE(var2,
nullptr);
1247 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pMother)), 0);
1248 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pGrandMother)), 0);
1251 pMother->writeExtraInfo(
"mcErrors", 8 | 128);
1252 pGrandMother->writeExtraInfo(
"mcErrors", 8 | 16 | 512);
1253 ASSERT_NE(var1,
nullptr);
1254 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pMother)), 128);
1255 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pGrandMother)), 16 | 512);
1256 ASSERT_NE(var2,
nullptr);
1257 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pMother)), 128);
1258 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pGrandMother)), 512);
1267 TEST_F(MetaVariableTest, conditionalVariableSelector)
1269 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1272 ASSERT_NE(var,
nullptr);
1273 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
1276 ASSERT_NE(var,
nullptr);
1277 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.4);
1281 TEST_F(MetaVariableTest, nCleanedTracks)
1290 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1291 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 11);
1293 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.1, 0.0, 0.0),
1294 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1295 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.15, 0.0, 0.0),
1296 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1297 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.4, 0.0, 0.0),
1298 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1299 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.6, 0.0, 0.0),
1300 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1308 EXPECT_FLOAT_EQ(std::get<int>(var1->function(
nullptr)), 1);
1311 EXPECT_FLOAT_EQ(std::get<int>(var2->
function(
nullptr)), 2);
1314 EXPECT_FLOAT_EQ(std::get<int>(var3->
function(
nullptr)), 4);
1319 TEST_F(MetaVariableTest, NumberOfMCParticlesInEvent)
1321 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1322 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 11);
1325 auto* mcParticle = mcParticles.
appendNew();
1328 mcParticle = mcParticles.appendNew();
1331 mcParticle = mcParticles.appendNew();
1334 mcParticle = mcParticles.appendNew();
1339 ASSERT_NE(var,
nullptr);
1340 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 2);
1344 TEST_F(MetaVariableTest, daughterInvM)
1346 PxPyPzEVector momentum;
1347 const int nDaughters = 6;
1349 std::vector<int> daughterIndices;
1350 for (
int i = 0; i < nDaughters; i++) {
1351 Particle d(PxPyPzEVector(2, 2, 2, 4.0), (i % 2) ? 213 : -213);
1352 momentum += d.get4Vector();
1353 Particle* newDaughters = particles.appendNew(d);
1359 ASSERT_NE(var,
nullptr);
1360 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1363 ASSERT_NE(var,
nullptr);
1364 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 4.0);
1367 ASSERT_NE(var,
nullptr);
1368 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 6.0);
1371 TEST_F(MetaVariableTest, daughter)
1373 PxPyPzEVector momentum;
1374 const int nDaughters = 6;
1376 std::vector<int> daughterIndices;
1377 for (
int i = 0; i < nDaughters; i++) {
1378 Particle d(PxPyPzEVector(i * 1.0, 1, 1, 1), (i % 2) ? 211 : -211);
1379 momentum += d.get4Vector();
1380 Particle* newDaughters = particles.appendNew(d);
1386 ASSERT_NE(var,
nullptr);
1387 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1390 ASSERT_NE(var,
nullptr);
1391 EXPECT_NEAR(std::get<double>(var->function(p)), 0.0, 1e-6);
1394 ASSERT_NE(var,
nullptr);
1395 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 1.0);
1398 ASSERT_NE(var,
nullptr);
1399 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 2.0);
1402 TEST_F(MetaVariableTest, mcDaughter)
1407 particles.registerInDataStore();
1409 particles.registerRelationTo(mcParticles);
1423 graphParticleGrandMother.
setPDG(-521);
1425 graphParticleAunt.
setPDG(-14);
1427 graphParticleDaughter2.
setPDG(14);
1429 graphParticleMother.
comesFrom(graphParticleGrandMother);
1430 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1431 graphParticleDaughter1.
comesFrom(graphParticleMother);
1432 graphParticleDaughter2.
comesFrom(graphParticleMother);
1436 auto* mcGrandMother = mcParticles[0];
1439 auto* mcMother = mcParticles[1];
1442 auto* mcAunt = mcParticles[2];
1445 auto* mcDaughter1 = mcParticles[3];
1448 auto* mcDaughter2 = mcParticles[4];
1451 auto* pGrandMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1452 pGrandMother->addRelationTo(mcGrandMother);
1454 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1455 pMother->addRelationTo(mcMother);
1458 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1461 auto* p_noDaughter = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1462 p_noDaughter->addRelationTo(mcDaughter1);
1465 ASSERT_NE(var,
nullptr);
1466 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 13);
1467 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), 11);
1468 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1469 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noDaughter))));
1471 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), -14);
1472 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), 14);
1475 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1476 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1479 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 11);
1480 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1482 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 14);
1484 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1486 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1489 TEST_F(MetaVariableTest, mcMother)
1494 particles.registerInDataStore();
1496 particles.registerRelationTo(mcParticles);
1510 graphParticleGrandMother.
setPDG(-521);
1512 graphParticleAunt.
setPDG(-14);
1514 graphParticleDaughter2.
setPDG(14);
1516 graphParticleMother.
comesFrom(graphParticleGrandMother);
1517 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1518 graphParticleDaughter1.
comesFrom(graphParticleMother);
1519 graphParticleDaughter2.
comesFrom(graphParticleMother);
1524 auto* mcGrandMother = mcParticles[0];
1527 auto* mcMother = mcParticles[1];
1530 auto* mcAunt = mcParticles[2];
1533 auto* mcDaughter1 = mcParticles[3];
1536 auto* mcDaughter2 = mcParticles[4];
1539 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1540 p1->addRelationTo(mcDaughter1);
1542 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 14);
1543 p2->addRelationTo(mcDaughter2);
1545 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1546 pMother->addRelationTo(mcMother);
1549 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1552 auto* p_noMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1553 p_noMother->addRelationTo(mcGrandMother);
1556 ASSERT_NE(var,
nullptr);
1557 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 13);
1558 EXPECT_FLOAT_EQ(std::get<double>(var->function(p2)), 13);
1559 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), -521);
1560 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1561 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMother))));
1565 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1568 TEST_F(MetaVariableTest, genParticle)
1573 particles.registerInDataStore();
1575 particles.registerRelationTo(mcParticles);
1589 graphParticleGrandMother.
setPDG(300553);
1590 graphParticleMother.
setPDG(-521);
1591 graphParticleAunt.
setPDG(521);
1593 graphParticleDaughter2.
setPDG(-12);
1595 graphParticleGrandMother.
setMomentum(0.0, 0.0, 0.4);
1598 graphParticleMother.
comesFrom(graphParticleGrandMother);
1599 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1600 graphParticleDaughter1.
comesFrom(graphParticleMother);
1601 graphParticleDaughter2.
comesFrom(graphParticleMother);
1606 auto* mcGrandMother = mcParticles[0];
1609 auto* mcMother = mcParticles[1];
1612 auto* mcAunt = mcParticles[2];
1615 auto* mcDaughter1 = mcParticles[3];
1618 auto* mcDaughter2 = mcParticles[4];
1621 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1622 p1->addRelationTo(mcDaughter1);
1625 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 211);
1628 ASSERT_NE(var,
nullptr);
1629 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 300553);
1630 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 300553);
1633 ASSERT_NE(var,
nullptr);
1634 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 0.4);
1635 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 0.4);
1638 ASSERT_NE(var,
nullptr);
1639 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1640 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1643 ASSERT_NE(var,
nullptr);
1644 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 1.1);
1645 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 1.1);
1648 ASSERT_NE(var,
nullptr);
1649 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1650 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1653 ASSERT_NE(var,
nullptr);
1654 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -12);
1655 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -12);
1658 ASSERT_NE(var,
nullptr);
1659 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p1))));
1660 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1663 TEST_F(MetaVariableTest, genUpsilon4S)
1668 particles.registerInDataStore();
1670 particles.registerRelationTo(mcParticles);
1684 graphParticleGrandMother.
setPDG(300553);
1685 graphParticleMother.
setPDG(-521);
1686 graphParticleAunt.
setPDG(521);
1688 graphParticleDaughter2.
setPDG(-12);
1690 graphParticleGrandMother.
setMomentum(0.0, 0.0, 0.4);
1693 graphParticleMother.
comesFrom(graphParticleGrandMother);
1694 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1695 graphParticleDaughter1.
comesFrom(graphParticleMother);
1696 graphParticleDaughter2.
comesFrom(graphParticleMother);
1701 auto* mcGrandMother = mcParticles[0];
1704 auto* mcMother = mcParticles[1];
1707 auto* mcAunt = mcParticles[2];
1710 auto* mcDaughter1 = mcParticles[3];
1713 auto* mcDaughter2 = mcParticles[4];
1716 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1717 p1->addRelationTo(mcDaughter1);
1720 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 211);
1723 ASSERT_NE(var,
nullptr);
1724 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 300553);
1725 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 300553);
1728 ASSERT_NE(var,
nullptr);
1729 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 0.4);
1730 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 0.4);
1733 ASSERT_NE(var,
nullptr);
1734 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1735 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1738 ASSERT_NE(var,
nullptr);
1739 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 1.1);
1740 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 1.1);
1743 mcParticles.
clear();
1758 auto* mcP1 = mcParticles[0];
1761 auto* mcP2 = mcParticles[1];
1764 auto* someParticle = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1765 someParticle->addRelationTo(mcP1);
1768 ASSERT_NE(var,
nullptr);
1769 EXPECT_TRUE(std::isnan(std::get<double>(var->function(someParticle))));
1772 TEST_F(MetaVariableTest, daughterProductOf)
1774 PxPyPzEVector momentum;
1775 const int nDaughters = 4;
1777 std::vector<int> daughterIndices;
1778 for (
int i = 0; i < nDaughters; i++) {
1779 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1780 momentum += d.get4Vector();
1781 Particle* newDaughters = particles.appendNew(d);
1787 ASSERT_NE(var,
nullptr);
1788 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 120.0);
1791 TEST_F(MetaVariableTest, daughterSumOf)
1793 PxPyPzEVector momentum;
1794 const int nDaughters = 4;
1796 std::vector<int> daughterIndices;
1797 for (
int i = 0; i < nDaughters; i++) {
1798 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1799 momentum += d.get4Vector();
1800 Particle* newDaughters = particles.appendNew(d);
1806 ASSERT_NE(var,
nullptr);
1807 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 14.0);
1810 TEST_F(MetaVariableTest, daughterLowest)
1812 PxPyPzEVector momentum;
1813 const int nDaughters = 4;
1815 std::vector<int> daughterIndices;
1816 for (
int i = 0; i < nDaughters; i++) {
1817 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1818 momentum += d.get4Vector();
1819 Particle* newDaughters = particles.appendNew(d);
1825 ASSERT_NE(var,
nullptr);
1826 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 2.0);
1829 TEST_F(MetaVariableTest, daughterHighest)
1831 PxPyPzEVector momentum;
1832 const int nDaughters = 4;
1834 std::vector<int> daughterIndices;
1835 for (
int i = 0; i < nDaughters; i++) {
1836 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? 213 : -213);
1837 momentum += d.get4Vector();
1838 Particle* newDaughters = particles.appendNew(d);
1844 ASSERT_NE(var,
nullptr);
1845 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 4.0);
1848 TEST_F(MetaVariableTest, daughterDiffOf)
1850 PxPyPzEVector momentum;
1851 const int nDaughters = 4;
1853 std::vector<int> daughterIndices;
1854 for (
int i = 0; i < nDaughters; i++) {
1855 Particle d(PxPyPzEVector(-1, 1.0 - 2 * (i % 2), 1, i * 1.0 + 2.0), (i % 2) ? -11 : 211);
1856 momentum += d.get4Vector();
1857 Particle* newDaughters = particles.appendNew(d);
1863 ASSERT_NE(var,
nullptr);
1864 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1867 ASSERT_NE(var,
nullptr);
1868 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1871 ASSERT_NE(var,
nullptr);
1872 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1875 ASSERT_NE(var,
nullptr);
1876 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1879 ASSERT_NE(var,
nullptr);
1880 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1883 ASSERT_NE(var,
nullptr);
1884 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1887 ASSERT_NE(var,
nullptr);
1888 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5707964);
1891 ASSERT_NE(var,
nullptr);
1892 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5004894);
1895 ASSERT_NE(var,
nullptr);
1896 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1900 TEST_F(MetaVariableTest, mcDaughterDiffOf)
1903 PxPyPzEVector momentum;
1904 const int nDaughters = 4;
1907 particles.registerRelationTo(mcParticles);
1908 std::vector<int> daughterIndices;
1911 for (
int i = 0; i < nDaughters; i++) {
1912 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
1913 momentum += d.get4Vector();
1914 Particle* newDaughters = particles.appendNew(d);
1916 auto* mcParticle = mcParticles.
appendNew();
1924 ASSERT_NE(var,
nullptr);
1925 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1928 ASSERT_NE(var,
nullptr);
1929 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1932 ASSERT_NE(var,
nullptr);
1933 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1936 ASSERT_NE(var,
nullptr);
1937 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1940 ASSERT_NE(var,
nullptr);
1941 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1944 ASSERT_NE(var,
nullptr);
1945 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1948 ASSERT_NE(var,
nullptr);
1949 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1954 TEST_F(MetaVariableTest, daughterClusterAngleInBetween)
1958 std::vector<int> daughterIndices, daughterIndices_noclst;
1964 particles.registerRelationTo(eclclusters);
1968 const float px_CM = 2.;
1969 const float py_CM = 1.;
1970 const float pz_CM = 3.;
1972 E_CM = sqrt(pow(px_CM, 2) + pow(py_CM, 2) + pow(pz_CM, 2));
1973 PxPyPzEVector momentum, momentum_noclst;
1974 PxPyPzEVector dau0_4vec_CM(px_CM, py_CM, pz_CM, E_CM), dau1_4vec_CM(-px_CM, -py_CM, -pz_CM, E_CM);
1975 PxPyPzEVector dau0_4vec_Lab, dau1_4vec_Lab;
1981 Particle dau0_noclst(dau0_4vec_Lab, 22);
1982 momentum += dau0_noclst.get4Vector();
1983 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
1984 daughterIndices_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
1985 Particle dau1_noclst(dau1_4vec_Lab, 22);
1986 momentum += dau1_noclst.get4Vector();
1987 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
1988 daughterIndices_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
1996 ASSERT_NE(var,
nullptr);
1997 EXPECT_TRUE(std::isnan(std::get<double>(var->function(par_noclst))));
2002 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2004 eclst0->
setTheta(dau0_4vec_Lab.Theta());
2005 eclst0->
setPhi(dau0_4vec_Lab.Phi());
2006 eclst0->
setR(148.4);
2009 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2011 eclst1->
setTheta(dau1_4vec_Lab.Theta());
2012 eclst1->
setPhi(dau1_4vec_Lab.Phi());
2013 eclst1->
setR(148.5);
2015 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2017 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2023 EXPECT_FLOAT_EQ(std::get<double>(var->function(par)), 2.8613892);
2024 EXPECT_FLOAT_EQ(std::get<double>(varCMS->
function(par)), M_PI);
2027 TEST_F(MetaVariableTest, grandDaughterDiffOfs)
2031 std::vector<int> daughterIndices0_noclst, daughterIndices1_noclst, daughterIndices2_noclst;
2032 std::vector<int> daughterIndices0, daughterIndices1, daughterIndices2;
2038 particles.registerRelationTo(eclclusters);
2042 const float px_0 = 2.;
2043 const float py_0 = 1.;
2044 const float pz_0 = 3.;
2045 const float px_1 = 1.5;
2046 const float py_1 = 1.5;
2047 const float pz_1 = 2.5;
2049 E_0 = sqrt(pow(px_0, 2) + pow(py_0, 2) + pow(pz_0, 2));
2050 E_1 = sqrt(pow(px_1, 2) + pow(py_1, 2) + pow(pz_1, 2));
2051 PxPyPzEVector momentum_0, momentum_1, momentum;
2052 PxPyPzEVector dau0_4vec(px_0, py_0, pz_0, E_0), dau1_4vec(px_1, py_1, pz_1, E_1);
2065 Particle dau0_noclst(dau0_4vec, 22);
2066 momentum_0 = dau0_4vec;
2067 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
2068 daughterIndices0_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
2070 Particle dau1_noclst(dau1_4vec, 22);
2071 momentum_1 = dau1_4vec;
2072 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
2073 daughterIndices1_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
2076 momentum = momentum_0 + momentum_1;
2077 daughterIndices2_noclst.push_back(par0_noclst->
getArrayIndex());
2078 daughterIndices2_noclst.push_back(par1_noclst->
getArrayIndex());
2097 ASSERT_NE(var_ClusterPhi,
nullptr);
2098 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi->
function(parGranny_noclst))));
2099 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterTheta->
function(parGranny_noclst))));
2100 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE->
function(parGranny_noclst))));
2101 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny_noclst)), 0.32175055);
2102 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny_noclst)), 0.06311664);
2103 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny_noclst)), -0.46293807);
2104 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi_wrongIndexes->
function(parGranny_noclst))));
2105 EXPECT_TRUE(std::isnan(std::get<double>(var_Phi_wrongIndexes->
function(parGranny_noclst))));
2106 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE_wrongIndexes->
function(parGranny_noclst))));
2107 EXPECT_TRUE(std::isnan(std::get<double>(var_E_wrongIndexes->
function(parGranny_noclst))));
2112 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2114 eclst0->
setTheta(dau0_4vec.Theta());
2115 eclst0->
setPhi(dau0_4vec.Phi());
2116 eclst0->
setR(148.4);
2119 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2121 eclst1->
setTheta(dau1_4vec.Theta());
2122 eclst1->
setPhi(dau1_4vec.Phi());
2123 eclst1->
setR(148.5);
2125 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2129 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2139 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterPhi->
function(parGranny)), 0.32175055);
2140 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny)), 0.32175055);
2141 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterTheta->
function(parGranny)), 0.06311664);
2142 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny)), 0.06311664);
2143 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterE->
function(parGranny)), -0.46293831);
2144 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny)), -0.46293831);
2147 TEST_F(MetaVariableTest, daughterNormDiffOf)
2149 PxPyPzEVector momentum;
2150 const int nDaughters = 4;
2152 std::vector<int> daughterIndices;
2153 for (
int i = 0; i < nDaughters; i++) {
2154 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2155 momentum += d.get4Vector();
2156 Particle* newDaughters = particles.appendNew(d);
2162 ASSERT_NE(var,
nullptr);
2163 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222 / 200.);
2166 ASSERT_NE(var,
nullptr);
2167 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222 / 200.);
2170 ASSERT_NE(var,
nullptr);
2171 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200 / 222.);
2174 ASSERT_NE(var,
nullptr);
2175 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -0 / 22.);
2178 ASSERT_NE(var,
nullptr);
2179 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 22.);
2182 ASSERT_NE(var,
nullptr);
2183 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 422.);
2187 TEST_F(MetaVariableTest, daughterMotherDiffOf)
2189 PxPyPzEVector momentum;
2190 const int nDaughters = 4;
2192 std::vector<int> daughterIndices;
2193 for (
int i = 0; i < nDaughters; i++) {
2194 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2195 momentum += d.get4Vector();
2196 Particle* newDaughters = particles.appendNew(d);
2202 ASSERT_NE(var,
nullptr);
2203 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422);
2206 ASSERT_NE(var,
nullptr);
2207 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400);
2210 ASSERT_NE(var,
nullptr);
2211 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200);
2215 TEST_F(MetaVariableTest, daughterMotherNormDiffOf)
2217 PxPyPzEVector momentum;
2218 const int nDaughters = 4;
2220 std::vector<int> daughterIndices;
2221 for (
int i = 0; i < nDaughters; i++) {
2222 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2223 momentum += d.get4Vector();
2224 Particle* newDaughters = particles.appendNew(d);
2230 ASSERT_NE(var,
nullptr);
2231 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422 / 400.);
2234 ASSERT_NE(var,
nullptr);
2235 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400 / 422.);
2238 ASSERT_NE(var,
nullptr);
2239 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200 / 622.);
2243 TEST_F(MetaVariableTest, constant)
2247 ASSERT_NE(var,
nullptr);
2248 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 1.0);
2251 ASSERT_NE(var,
nullptr);
2252 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 0.0);
2256 TEST_F(MetaVariableTest, abs)
2258 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
2259 Particle p2({ -0.1, -0.4, 0.8, 4.0 }, -11);
2262 ASSERT_NE(var,
nullptr);
2263 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
2264 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 0.1);
2268 TEST_F(MetaVariableTest, sin)
2270 Particle p({ 3.14159265359 / 2.0, -0.4, 0.8, 1.0}, 11);
2271 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2274 ASSERT_NE(var,
nullptr);
2275 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
2276 EXPECT_NEAR(std::get<double>(var->function(&p2)), 0.0, 1e-6);
2280 TEST_F(MetaVariableTest, cos)
2282 Particle p({ 3.14159265359 / 2.0, -0.4, 0.8, 1.0}, 11);
2283 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2286 ASSERT_NE(var,
nullptr);
2287 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.0, 1e-6);
2288 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 1.0);
2292 TEST_F(MetaVariableTest, NBDeltaIfMissingDeathTest)
2299 TEST_F(MetaVariableTest, matchedMC)
2304 particles.registerRelationTo(mcParticles);
2307 auto* mcParticle = mcParticles.
appendNew();
2310 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2311 p1->addRelationTo(mcParticle);
2316 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2317 p2->addRelationTo(mcParticle);
2322 auto* p3 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2323 p3->addRelationTo(mcParticle);
2326 auto* p4 = particles.appendNew(mcParticle);
2329 ASSERT_NE(var,
nullptr);
2330 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -1);
2331 EXPECT_FLOAT_EQ(std::get<double>(var->function(p2)), 1);
2332 EXPECT_FLOAT_EQ(std::get<double>(var->function(p3)), 0);
2333 EXPECT_FLOAT_EQ(std::get<double>(var->function(p4)), 0);
2336 TEST_F(MetaVariableTest, countInList)
2343 outputList.registerInDataStore(flags);
2345 outputList.create();
2346 outputList->initialize(22,
"pList1");
2361 ASSERT_NE(var,
nullptr);
2362 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 2);
2365 ASSERT_NE(var,
nullptr);
2366 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2369 ASSERT_NE(var,
nullptr);
2370 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 0);
2373 ASSERT_NE(var,
nullptr);
2374 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2377 TEST_F(MetaVariableTest, isInList)
2386 gammalist.registerInDataStore(flags);
2389 gammalist->initialize(22,
"testGammaList");
2394 auto* inthelist = particles.appendNew(goingin);
2395 auto* notinthelist = particles.appendNew(notgoingin);
2405 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(notinthelist)));
2406 EXPECT_TRUE(std::get<bool>(vsensible->
function(inthelist)));
2407 EXPECT_FALSE(std::get<bool>(vsensible->
function(notinthelist)));
2411 TEST_F(MetaVariableTest, cutIsInList)
2417 const std::string listname {
"wil/d(-+)'':l*"};
2421 particlelist.registerInDataStore(flags);
2423 particlelist.create();
2424 particlelist->initialize(22, listname);
2428 auto* inthelist = particles.appendNew(goingin);
2429 auto* notinthelist = particles.appendNew(notgoingin);
2438 EXPECT_B2FATAL(std::get<bool>(nonexistlist->
function(inthelist)));
2439 EXPECT_FALSE(std::get<bool>(existlist->
function(notinthelist)));
2440 EXPECT_TRUE(std::get<bool>(existlist->
function(inthelist)));
2443 TEST_F(MetaVariableTest, sourceObjectIsInList)
2455 particles.registerInDataStore();
2457 gammalist.registerInDataStore(flags);
2464 gammalist->initialize(22,
"testGammaList");
2469 cl0->setEnergy(1.0);
2470 cl0->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2471 cl0->addHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2472 cl0->setClusterId(0);
2474 cl1->setEnergy(1.0);
2475 cl1->setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2476 cl1->setClusterId(1);
2484 auto* myphoton_ = particles.appendNew(myphoton);
2485 gammalist->addParticle(myphoton_);
2487 auto* iscopied = particles.appendNew(iscopiedin);
2488 auto* notcopied = particles.appendNew(notcopiedin);
2495 EXPECT_B2FATAL(std::get<int>(vnonsense->
function(iscopied)));
2496 EXPECT_EQ(std::get<int>(vsensible->
function(iscopied)), 1);
2497 EXPECT_EQ(std::get<int>(vsensible->
function(notcopied)), 0);
2502 auto* composite_ = particles.appendNew(undefined);
2503 auto* undefined_ = particles.appendNew(composite);
2504 EXPECT_EQ(std::get<int>(vsensible->
function(composite_)), -1);
2505 EXPECT_EQ(std::get<int>(vsensible->
function(undefined_)), -1);
2508 TEST_F(MetaVariableTest, mcParticleIsInMCList)
2521 particles.registerInDataStore();
2522 particles.registerRelationTo(mcparticles);
2524 list.registerInDataStore(flags);
2525 anotherlist.registerInDataStore(flags);
2531 list->initialize(22,
"testList");
2533 anotherlist.create();
2534 anotherlist->initialize(22,
"supplimentaryList");
2537 auto* mcphoton = mcparticles.
appendNew();
2541 auto* mcelectron = mcparticles.
appendNew();
2545 auto* mcanotherelectron = mcparticles.
appendNew();
2549 auto* mcyetanotherelectron = mcparticles.
appendNew();
2554 auto* photon = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2555 photon->addRelationTo(mcphoton);
2556 list->addParticle(photon);
2558 auto* electron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2559 electron->addRelationTo(mcelectron);
2560 list->addParticle(electron);
2562 auto* other = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2563 other->addRelationTo(mcanotherelectron);
2565 auto* yetanotherelectron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2566 yetanotherelectron->addRelationTo(mcyetanotherelectron);
2567 anotherlist->addParticle(yetanotherelectron);
2575 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(photon)));
2576 EXPECT_TRUE(std::get<bool>(vsensible->
function(photon)));
2577 EXPECT_TRUE(std::get<bool>(vsensible->
function(electron)));
2578 EXPECT_FALSE(std::get<bool>(vsensible->
function(other)));
2579 EXPECT_FALSE(std::get<bool>(vsensible->
function(yetanotherelectron)));
2584 auto* composite_ = particles.appendNew(undefined);
2585 auto* undefined_ = particles.appendNew(composite);
2586 EXPECT_FALSE(std::get<bool>(vsensible->
function(composite_)));
2587 EXPECT_FALSE(std::get<bool>(vsensible->
function(undefined_)));
2590 TEST_F(MetaVariableTest, mostB2BAndClosestParticles)
2600 gearbox.setBackends({std::string(
"file:")});
2602 gearbox.open(
"geometry/Belle2.xml",
false);
2612 gammalist.registerInDataStore(flags);
2613 emptylist.registerInDataStore(flags);
2616 gammalist->initialize(22,
"testGammaList");
2618 emptylist->initialize(22,
"testEmptyList");
2621 std::vector<Particle> gammavector = {
2628 for (
const auto& g : gammavector)
2629 particles.appendNew(g);
2632 for (
size_t i = 0; i < gammavector.size(); i++)
2636 const auto* electron = particles.appendNew(
2646 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2649 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2652 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 0.68014491);
2655 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 0.67901474);
2663 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2666 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2669 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 3.4);
2672 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 3.2732551);
2675 EXPECT_FLOAT_EQ(std::get<double>(closestCMSLabE->function(electron)), 3.4);
2683 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2686 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2689 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 2.2869499);
2692 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 2.8312778);
2700 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2703 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2706 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 1.7);
2709 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 1.5848758);
2712 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMSLabE->function(electron)), 1.7);
2716 TEST_F(MetaVariableTest, totalEnergyOfParticlesInList)
2725 gammalist.registerInDataStore(flags);
2728 gammalist->initialize(22,
"testGammaList");
2731 std::vector<Particle> gammavector = {
2740 for (
const auto& g : gammavector)
2741 particles.appendNew(g);
2744 for (
size_t i = 0; i < gammavector.size(); i++)
2749 "totalEnergyOfParticlesInList(NONEXISTANTLIST)");
2751 "totalEnergyOfParticlesInList(testGammaList)");
2754 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2755 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 4.3);
2757 TEST_F(MetaVariableTest, totalPxOfParticlesInList)
2766 gammalist.registerInDataStore(flags);
2769 gammalist->initialize(22,
"testGammaList");
2772 std::vector<Particle> gammavector = {
2781 for (
const auto& g : gammavector)
2782 particles.appendNew(g);
2785 for (
size_t i = 0; i < gammavector.size(); i++)
2790 "totalPxOfParticlesInList(NONEXISTANTLIST)");
2792 "totalPxOfParticlesInList(testGammaList)");
2795 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2796 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 2.2);
2798 TEST_F(MetaVariableTest, totalPyOfParticlesInList)
2807 gammalist.registerInDataStore(flags);
2810 gammalist->initialize(22,
"testGammaList");
2813 std::vector<Particle> gammavector = {
2822 for (
const auto& g : gammavector)
2823 particles.appendNew(g);
2826 for (
size_t i = 0; i < gammavector.size(); i++)
2831 "totalPyOfParticlesInList(NONEXISTANTLIST)");
2833 "totalPyOfParticlesInList(testGammaList)");
2836 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2837 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 1.5);
2839 TEST_F(MetaVariableTest, totalPzOfParticlesInList)
2848 gammalist.registerInDataStore(flags);
2851 gammalist->initialize(22,
"testGammaList");
2854 std::vector<Particle> gammavector = {
2863 for (
const auto& g : gammavector)
2864 particles.appendNew(g);
2867 for (
size_t i = 0; i < gammavector.size(); i++)
2872 "totalPzOfParticlesInList(NONEXISTANTLIST)");
2874 "totalPzOfParticlesInList(testGammaList)");
2877 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2878 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 3.1);
2880 TEST_F(MetaVariableTest, maxPtInList)
2889 gammalist.registerInDataStore(flags);
2892 gammalist->initialize(22,
"testGammaList");
2895 std::vector<Particle> gammavector = {
2904 for (
const auto& g : gammavector)
2905 particles.appendNew(g);
2908 for (
size_t i = 0; i < gammavector.size(); i++)
2913 "maxPtInList(NONEXISTANTLIST)");
2915 "maxPtInList(testGammaList)");
2918 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2919 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), sqrt(0.5 * 0.5 + 0.4 * 0.4));
2923 TEST_F(MetaVariableTest, numberOfNonOverlappingParticles)
2930 outputList.registerInDataStore(flags);
2932 outputList.create();
2933 outputList->initialize(22,
"pList1");
2943 ASSERT_NE(var,
nullptr);
2944 EXPECT_EQ(std::get<int>(var->function(p1)), 1);
2945 EXPECT_EQ(std::get<int>(var->function(p2)), 1);
2946 EXPECT_EQ(std::get<int>(var->function(p3)), 2);
2950 TEST_F(MetaVariableTest, veto)
2955 const Particle* p = particles.appendNew(
Particle({0.8, 0.8, 1.131370849898476039041351, 1.6}, 22,
2960 outputList.registerInDataStore(flags);
2962 outputList.create();
2963 outputList->initialize(22,
"pList1");
2965 particles.appendNew(
Particle({0.5, 0.4953406774856531014212777, 0.5609256753154148484773173, 0.9}, 22,
2980 outputList2.registerInDataStore(flags);
2982 outputList2.create();
2983 outputList2->initialize(22,
"pList2");
2998 ASSERT_NE(var,
nullptr);
2999 EXPECT_TRUE(std::get<bool>(var->function(p)));
3002 ASSERT_NE(var,
nullptr);
3003 EXPECT_FALSE(std::get<bool>(var->function(p)));
3007 TEST_F(MetaVariableTest, averageValueInList)
3016 gammalist.registerInDataStore(flags);
3019 gammalist->initialize(22,
"testGammaList");
3022 std::vector<Particle> gammavector = {
3031 for (
const auto& g : gammavector)
3032 particles.appendNew(g);
3035 for (
size_t i = 0; i < gammavector.size(); i++)
3040 "averageValueInList(testGammaList, px)");
3042 "averageValueInList(testGammaList, py)");
3044 "averageValueInList(testGammaList, pz)");
3046 "averageValueInList(testGammaList, E)");
3048 EXPECT_FLOAT_EQ(std::get<double>(vmeanpx->
function(
nullptr)), 0.44);
3049 EXPECT_FLOAT_EQ(std::get<double>(vmeanpy->
function(
nullptr)), 0.3);
3050 EXPECT_FLOAT_EQ(std::get<double>(vmeanpz->
function(
nullptr)), 0.6);
3051 EXPECT_FLOAT_EQ(std::get<double>(vmeanE->
function(
nullptr)), 0.86);
3054 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"averageValueInList(testGammaList)"));
3057 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"averageValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3061 "averageValueInList(NONEXISTANTLIST, px)");
3063 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3066 TEST_F(MetaVariableTest, medianValueInList)
3075 oddgammalist.registerInDataStore(flags);
3077 oddgammalist.create();
3078 oddgammalist->initialize(22,
"oddGammaList");
3081 evengammalist.registerInDataStore(flags);
3083 evengammalist.create();
3084 evengammalist->initialize(22,
"evenGammaList");
3087 std::vector<Particle> gammavector = {
3096 for (
const auto& g : gammavector)
3097 particles.appendNew(g);
3101 for (
size_t i = 1; i < gammavector.size(); i++) {
3108 "medianValueInList(oddGammaList, px)");
3110 "medianValueInList(oddGammaList, py)");
3112 "medianValueInList(oddGammaList, pz)");
3114 "medianValueInList(oddGammaList, E)");
3116 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpx->
function(
nullptr)), 0.5);
3117 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpy->
function(
nullptr)), 0.3);
3118 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpz->
function(
nullptr)), 0.7);
3119 EXPECT_FLOAT_EQ(std::get<double>(voddmedianE->
function(
nullptr)), 0.9);
3123 "medianValueInList(evenGammaList, px)");
3125 "medianValueInList(evenGammaList, py)");
3127 "medianValueInList(evenGammaList, pz)");
3129 "medianValueInList(evenGammaList, E)");
3131 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpx->
function(
nullptr)), 0.45);
3132 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpy->
function(
nullptr)), 0.25);
3133 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpz->
function(
nullptr)), 0.7);
3134 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianE->
function(
nullptr)), 0.9);
3137 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"medianValueInList(oddGammaList)"));
3140 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"medianValueInList(oddGammaList, NONEXISTANTVARIABLE)"));
3144 "medianValueInList(NONEXISTANTLIST, px)");
3146 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3149 TEST_F(MetaVariableTest, productValueInList)
3158 gammalist.registerInDataStore(flags);
3161 gammalist->initialize(22,
"testGammaList");
3164 std::vector<Particle> gammavector = {
3173 for (
const auto& g : gammavector)
3174 particles.appendNew(g);
3177 for (
size_t i = 0; i < gammavector.size(); i++)
3182 "productValueInList(testGammaList, px)");
3184 "productValueInList(testGammaList, py)");
3186 "productValueInList(testGammaList, pz)");
3188 "productValueInList(testGammaList, E)");
3190 EXPECT_FLOAT_EQ(std::get<double>(vproductpx->
function(
nullptr)), 0.015);
3191 EXPECT_FLOAT_EQ(std::get<double>(vproductpy->
function(
nullptr)), 0.00192);
3192 EXPECT_FLOAT_EQ(std::get<double>(vproductpz->
function(
nullptr)), 0.06272);
3193 EXPECT_FLOAT_EQ(std::get<double>(vproductE->
function(
nullptr)), 0.42768);
3196 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"productValueInList(testGammaList)"));
3199 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"productValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3203 "productValueInList(NONEXISTANTLIST, px)");
3205 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3208 TEST_F(MetaVariableTest, sumValueInList)
3217 gammalist.registerInDataStore(flags);
3220 gammalist->initialize(22,
"testGammaList");
3223 std::vector<Particle> gammavector = {
3232 for (
const auto& g : gammavector)
3233 particles.appendNew(g);
3236 for (
size_t i = 0; i < gammavector.size(); i++)
3241 "sumValueInList(testGammaList, px)");
3243 "sumValueInList(testGammaList, py)");
3245 "sumValueInList(testGammaList, pz)");
3247 "sumValueInList(testGammaList, E)");
3249 EXPECT_FLOAT_EQ(std::get<double>(vsumpx->
function(
nullptr)), 2.2);
3250 EXPECT_FLOAT_EQ(std::get<double>(vsumpy->
function(
nullptr)), 1.5);
3251 EXPECT_FLOAT_EQ(std::get<double>(vsumpz->
function(
nullptr)), 3.0);
3252 EXPECT_FLOAT_EQ(std::get<double>(vsumE->
function(
nullptr)), 4.3);
3255 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"sumValueInList(testGammaList)"));
3258 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"sumValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3262 "sumValueInList(NONEXISTANTLIST, px)");
3264 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3267 TEST_F(MetaVariableTest, pValueCombination)
3269 PxPyPzEVector momentum;
3271 std::vector<int> daughterIndices;
3274 momentum += KS.get4Vector();
3275 Particle* newDaughters = particles.appendNew(KS);
3278 Jpsi.setPValue(0.9);
3279 momentum += Jpsi.get4Vector();
3280 newDaughters = particles.appendNew(Jpsi);
3286 ASSERT_NE(singlePvalue,
nullptr);
3287 EXPECT_FLOAT_EQ(std::get<double>(singlePvalue->
function(B)), 0.5);
3290 ASSERT_NE(twoPvalues,
nullptr);
3291 EXPECT_FLOAT_EQ(std::get<double>(twoPvalues->
function(B)), 0.05 * (1 - log(0.05)));
3295 ASSERT_NE(threePvalues,
nullptr);
3296 EXPECT_FLOAT_EQ(std::get<double>(threePvalues->
function(B)), 0.045 * (1 - log(0.045) + 0.5 * log(0.045) * log(0.045)));
3302 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"pValueCombination(chiProb, NONEXISTANTVARIABLE)"));
3306 TEST_F(MetaVariableTest, daughterCombinationOneGeneration)
3308 const int nDaughters = 5;
3309 PxPyPzEVector momentum(0, 0, 0, 0);
3311 std::vector<int> daughterIndices;
3312 std::vector<PxPyPzEVector> daughterMomenta;
3314 for (
int i = 0; i < nDaughters; i++) {
3315 PxPyPzEVector mom(1, i * 0.5, 1, i * 1.0 + 2.0);
3316 Particle d(mom, (i % 2) ? 111 : 113);
3317 Particle* newDaughters = particles.appendNew(d);
3319 daughterMomenta.push_back(mom);
3320 momentum = momentum + mom;
3326 double M_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[2]).mag();
3327 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3330 M_test = (daughterMomenta[0] + daughterMomenta[4]).mag();
3331 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3336 double p_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[4]).P();
3337 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), p_test);
3341 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"daughterCombination(aVeryNonExistingVariableSillyName, 1, 0, 4)"));
3344 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3345 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3349 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3350 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3354 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3355 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3360 TEST_F(MetaVariableTest, daughterCombinationTwoGenerations)
3366 PxPyPzEVector momentum_1(0, 0, 0, 0);
3367 std::vector<PxPyPzEVector> daughterMomenta_1;
3368 std::vector<int> daughterIndices_1;
3370 for (
int i = 0; i < 3; i++) {
3371 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3372 Particle d(mom, (i % 2) ? 111 : 113);
3373 Particle* newDaughters = particles.appendNew(d);
3375 daughterMomenta_1.push_back(mom);
3376 momentum_1 = momentum_1 + mom;
3384 PxPyPzEVector momentum_2(0, 0, 0, 0);
3385 std::vector<PxPyPzEVector> daughterMomenta_2;
3386 std::vector<int> daughterIndices_2;
3388 for (
int i = 0; i < 2; i++) {
3389 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3390 Particle d(mom, (i % 2) ? 111 : 113);
3391 Particle* newDaughters = particles.appendNew(d);
3393 daughterMomenta_2.push_back(mom);
3394 momentum_2 = momentum_2 + mom;
3408 double M_test = (momentum_1 + momentum_2).mag();
3409 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3413 M_test = (momentum_1).mag();
3414 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3418 M_test = (daughterMomenta_1[0] + daughterMomenta_1[1] + daughterMomenta_2[0]).mag();
3419 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3424 TEST_F(MetaVariableTest, useAlternativeDaughterHypothesis)
3426 const int nDaughters = 5;
3430 PxPyPzEVector momentum(0, 0, 0, 0);
3431 std::vector<int> daughterIndices;
3432 for (
int i = 0; i < nDaughters; i++) {
3433 double px = i * 0.1;
3434 double py = i * 0.3;
3435 double pz = -i * 0.1 - 0.2;
3437 PxPyPzEVector mom(px, py, pz, 1);
3441 d.updateMass(pdgCode);
3442 mom = d.get4Vector();
3444 Particle* daughters = particles.appendNew(d);
3446 momentum = momentum + mom;
3452 PxPyPzEVector momentumAlt(0, 0, 0, 0);
3453 std::vector<int> daughterIndicesAlt;
3454 for (
int i = 0; i < nDaughters; i++) {
3455 double px = i * 0.1;
3456 double py = i * 0.3;
3457 double pz = -i * 0.1 - 0.2;
3459 PxPyPzEVector mom(px, py, pz, 1);
3467 d.updateMass(pdgCode);
3468 mom = d.get4Vector();
3470 Particle* daughters = particles.appendNew(d);
3472 momentumAlt = momentumAlt + mom;
3478 std::cout <<
"mass test" << std::endl;
3481 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3484 std::cout <<
"charge test" << std::endl;
3486 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3489 std::cout <<
"momentum test" << std::endl;
3492 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3493 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(p)));
3494 EXPECT_FLOAT_EQ(std::get<double>(var->function(pAlt)), std::get<double>(varAlt->
function(pAlt)));
3500 TEST_F(MetaVariableTest, daughterAngle)
3506 PxPyPzEVector momentum_1(0, 0, 0, 0);
3507 std::vector<PxPyPzEVector> daughterMomenta_1;
3508 std::vector<int> daughterIndices_1;
3510 for (
int i = 0; i < 3; i++) {
3511 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3512 Particle d(mom, (i % 2) ? -11 : 211);
3513 Particle* newDaughters = particles.appendNew(d);
3515 daughterMomenta_1.push_back(mom);
3516 momentum_1 = momentum_1 + mom;
3524 PxPyPzEVector momentum_2(0, 0, 0, 0);
3525 std::vector<PxPyPzEVector> daughterMomenta_2;
3526 std::vector<int> daughterIndices_2;
3528 for (
int i = 0; i < 2; i++) {
3529 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3530 Particle d(mom, (i % 2) ? -11 : 211);
3531 Particle* newDaughters = particles.appendNew(d);
3533 daughterMomenta_2.push_back(mom);
3534 momentum_2 = momentum_2 + mom;
3547 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3549 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3553 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3554 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3557 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3558 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3561 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3562 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3566 TEST_F(MetaVariableTest, mcDaughterVariables)
3572 particles.registerRelationTo(mcParticles);
3576 PxPyPzEVector momentum_1(0, 0, 0, 0);
3577 std::vector<PxPyPzEVector> daughterMomenta_1;
3578 std::vector<int> daughterIndices_1;
3580 for (
int i = 0; i < 3; i++) {
3581 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3582 Particle d(mom, (i % 2) ? -11 : 211);
3583 Particle* newDaughters = particles.appendNew(d);
3585 daughterMomenta_1.push_back(mom);
3586 momentum_1 = momentum_1 + mom;
3588 auto* mcParticle = mcParticles.
appendNew();
3591 mcParticle->set4Vector(mom);
3596 auto* mcCompositeDau_1 = mcParticles.
appendNew();
3597 mcCompositeDau_1->setPDG(411);
3599 mcCompositeDau_1->set4Vector(momentum_1);
3604 PxPyPzEVector momentum_2(0, 0, 0, 0);
3605 std::vector<PxPyPzEVector> daughterMomenta_2;
3606 std::vector<int> daughterIndices_2;
3608 for (
int i = 0; i < 2; i++) {
3609 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3610 Particle d(mom, (i % 2) ? -11 : 211);
3611 Particle* newDaughters = particles.appendNew(d);
3613 daughterMomenta_2.push_back(mom);
3614 momentum_2 = momentum_2 + mom;
3616 auto* mcParticle = mcParticles.
appendNew();
3619 mcParticle->set4Vector(mom);
3624 auto* mcCompositeDau_2 = mcParticles.
appendNew();
3625 mcCompositeDau_2->setPDG(411);
3627 mcCompositeDau_2->set4Vector(momentum_2);
3637 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3638 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3641 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3642 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3645 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3646 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3649 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3650 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3654 ASSERT_NE(var,
nullptr);
3655 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
3658 ASSERT_NE(var,
nullptr);
3659 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3663 ASSERT_NE(var,
nullptr);
3664 v_test = momentum_2.Phi() - momentum_1.Phi();
3665 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3669 TEST_F(MetaVariableTest, varForFirstMCAncestorOfType)
3674 particles.registerInDataStore();
3676 particles.registerRelationTo(mcParticles);
3678 DList.registerInDataStore();
3680 DList->initialize(421,
"D0:vartest");
3682 PxPyPzEVector momentum;
3683 PxPyPzEVector momentum_0;
3684 PxPyPzEVector momentum_1;
3685 std::vector<int> D_daughterIndices;
3686 std::vector<int> D_grandDaughterIndices_0;
3687 std::vector<int> D_grandDaughterIndices_1;
3705 mcg_d_0.
set4Vector(PxPyPzEVector(6, 6, 6, 6));
3707 mcg_d_1.
set4Vector(PxPyPzEVector(5, 5, 5, 5));
3709 mcg_gd_0_0.
set4Vector(PxPyPzEVector(4, 4, 4, 4));
3711 mcg_gd_0_1.
set4Vector(PxPyPzEVector(3, 3, 3, 3));
3713 mcg_gd_1_0.
set4Vector(PxPyPzEVector(2, 1, 2, 2));
3715 mcg_gd_1_1.
set4Vector(PxPyPzEVector(1, 1, 1, 1));
3717 mcg_not_child.
set4Vector(PxPyPzEVector(10, 10, 10, 10));
3729 auto* mc_not_child = mcParticles[0];
3730 auto* mc_m = mcParticles[1];
3731 auto* mc_d_0 = mcParticles[2];
3732 auto* mc_d_1 = mcParticles[3];
3733 auto* mc_gd_0_0 = mcParticles[4];
3734 auto* mc_gd_0_1 = mcParticles[5];
3735 auto* mc_gd_1_0 = mcParticles[6];
3736 auto* mc_gd_1_1 = mcParticles[7];
3750 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
3751 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
3752 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
3753 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
3755 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3756 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3757 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3758 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3772 DList->addParticle(D_m);
3775 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
3778 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
3792 ASSERT_NE(var_d,
nullptr);
3793 EXPECT_TRUE(std::get<double>(var_d->
function(D_gd_0_0)) >= 0);
3794 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_0_1)));
3795 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_1_0)), std::get<double>(var_d->
function(D_gd_1_1)));
3796 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_1_0)));
3797 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_1)), std::get<double>(var_d->
function(D_gd_1_1)));
3798 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child))));
3799 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child_2))));
3804 ASSERT_NE(var_310,
nullptr);
3805 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_0_1)));
3806 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_1_0)), std::get<double>(var_310->
function(D_gd_1_1)));
3807 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_1_0)));
3808 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_1)), std::get<double>(var_310->
function(D_gd_1_1)));
3809 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child))));
3810 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child_2))));
3811 EXPECT_FLOAT_EQ(
int(std::get<double>(
Manager::Instance().getVariable(
"varForFirstMCAncestorOfType(310, E)")->function(D_gd_0_0))),
3815 TEST_F(MetaVariableTest, isDescendantOfList)
3819 DList.registerInDataStore();
3821 DList->initialize(421,
"D0:vartest");
3823 BList.registerInDataStore();
3825 BList->initialize(521,
"B:vartest");
3828 PxPyPzEVector momentum;
3829 PxPyPzEVector momentum_0;
3830 PxPyPzEVector momentum_1;
3832 std::vector<int> D_daughterIndices;
3833 std::vector<int> D_grandDaughterIndices_0;
3834 std::vector<int> D_grandDaughterIndices_1;
3835 std::vector<int> B_daughterIndices;
3836 std::vector<int> B_grandDaughterIndices;
3837 std::vector<int> B_grandGrandDaughterIndices;
3846 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3847 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3848 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3849 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3863 DList->addParticle(D_m);
3872 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_0->
getArrayIndex());
3873 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_1->
getArrayIndex());
3877 B_grandDaughterIndices.push_back(B_gd_0_0->
getArrayIndex());
3878 B_grandDaughterIndices.push_back(B_gd_0_1->
getArrayIndex());
3886 BList->addParticle(B_m);
3893 ASSERT_NE(var_0,
nullptr);
3894 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_0)));
3895 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_1)));
3896 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_0)));
3897 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_1)));
3898 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_0)));
3899 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_1)));
3900 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_0)));
3901 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_1)));
3902 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_0)));
3903 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_1)));
3904 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_0)));
3905 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_1)));
3906 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
3909 ASSERT_NE(var_0a,
nullptr);
3910 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_0)));
3911 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_1)));
3912 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_0)));
3913 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_1)));
3914 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_0)));
3915 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_1)));
3916 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_0)));
3917 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_1)));
3918 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_0)));
3919 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_1)));
3920 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_0)));
3921 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_1)));
3922 EXPECT_FALSE(std::get<bool>(var_0a->
function(not_child)));
3925 ASSERT_NE(var_0b,
nullptr);
3926 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_0)));
3927 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_1)));
3928 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_0)));
3929 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_1)));
3930 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_0)));
3931 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_1)));
3932 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_0)));
3933 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_1)));
3934 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_0)));
3935 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_1)));
3936 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_0)));
3937 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_1)));
3938 EXPECT_FALSE(std::get<bool>(var_0b->
function(not_child)));
3941 ASSERT_NE(var_1,
nullptr);
3942 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
3943 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
3944 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
3945 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
3946 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_0)));
3947 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_1)));
3948 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_0)));
3949 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_1)));
3950 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_0)));
3951 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_1)));
3952 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_0)));
3953 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_1)));
3954 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
3957 ASSERT_NE(var_2,
nullptr);
3958 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_0)));
3959 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_1)));
3960 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_0)));
3961 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_1)));
3962 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
3963 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
3964 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_0)));
3965 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_1)));
3966 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_0)));
3967 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_1)));
3968 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_0)));
3969 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_1)));
3970 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
3973 ASSERT_NE(var_3,
nullptr);
3974 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_0)));
3975 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_1)));
3976 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_0)));
3977 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_1)));
3978 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_0)));
3979 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_1)));
3980 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_0)));
3981 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_1)));
3982 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_0)));
3983 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_1)));
3984 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_0)));
3985 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_1)));
3986 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
3989 ASSERT_NE(var_4,
nullptr);
3990 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_0)));
3991 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_1)));
3992 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_0)));
3993 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_1)));
3994 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_0)));
3995 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_1)));
3996 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_0)));
3997 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_1)));
3998 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_0)));
3999 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_1)));
4000 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_0)));
4001 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_1)));
4002 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
4005 ASSERT_NE(var_5,
nullptr);
4006 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
4007 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
4008 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
4009 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
4010 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_0)));
4011 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_1)));
4012 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_0)));
4013 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_1)));
4014 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_0)));
4015 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_1)));
4016 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_0)));
4017 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_1)));
4018 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
4021 ASSERT_NE(var_6,
nullptr);
4022 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_0)));
4023 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_1)));
4024 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_0)));
4025 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_1)));
4026 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_0)));
4027 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_1)));
4028 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_0)));
4029 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_1)));
4030 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_0)));
4031 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_1)));
4032 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_0)));
4033 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_1)));
4034 EXPECT_FALSE(std::get<bool>(var_6->
function(not_child)));
4037 ASSERT_NE(var_7,
nullptr);
4038 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_0)));
4039 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_1)));
4040 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_0)));
4041 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_1)));
4042 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_0)));
4043 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_1)));
4044 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_0)));
4045 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_1)));
4046 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_0)));
4047 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_1)));
4048 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_0)));
4049 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_1)));
4050 EXPECT_FALSE(std::get<bool>(var_7->
function(not_child)));
4054 TEST_F(MetaVariableTest, isMCDescendantOfList)
4059 particles.registerInDataStore();
4061 particles.registerRelationTo(mcParticles);
4063 BList.registerInDataStore();
4065 BList->initialize(521,
"B:vartest");
4067 DList.registerInDataStore();
4069 DList->initialize(421,
"D0:vartest");
4071 PxPyPzEVector momentum;
4072 PxPyPzEVector momentum_0;
4073 PxPyPzEVector momentum_1;
4074 std::vector<int> daughterIndices;
4075 std::vector<int> grandDaughterIndices;
4076 std::vector<int> grandGrandDaughterIndices;
4077 std::vector<int> D_daughterIndices;
4078 std::vector<int> D_grandDaughterIndices_0;
4079 std::vector<int> D_grandDaughterIndices_1;
4113 auto* mc_m = mcParticles[0];
4114 auto* mc_d_0 = mcParticles[1];
4115 auto* mc_d_1 = mcParticles[2];
4116 auto* mc_gd_0_0 = mcParticles[3];
4117 auto* mc_gd_0_1 = mcParticles[4];
4118 auto* mc_ggd_0_0_0 = mcParticles[5];
4119 auto* mc_ggd_0_0_1 = mcParticles[6];
4120 auto* mc_not_child = mcParticles[7];
4133 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4134 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4135 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4136 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4138 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
4139 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
4140 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
4141 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
4155 DList->addParticle(D_m);
4158 const Particle* d_1 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4159 const Particle* gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4160 const Particle* ggd_0_0_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4161 const Particle* ggd_0_0_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4163 grandGrandDaughterIndices.push_back(ggd_0_0_0->
getArrayIndex());
4164 grandGrandDaughterIndices.push_back(ggd_0_0_1->
getArrayIndex());
4177 BList->addParticle(m);
4180 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
4183 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
4191 m->addRelationTo(mc_m);
4195 ASSERT_NE(var_0,
nullptr);
4196 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_0)));
4197 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_1)));
4198 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_0)));
4199 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_1)));
4200 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_0)));
4201 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_1)));
4202 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_0)));
4203 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_1)));
4204 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_0)));
4205 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_1)));
4206 EXPECT_TRUE(std::get<bool>(var_0->
function(d_0)));
4207 EXPECT_TRUE(std::get<bool>(var_0->
function(d_1)));
4208 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
4209 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child_2)));
4212 ASSERT_NE(var_1,
nullptr);
4213 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
4214 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
4215 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
4216 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
4217 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_0)));
4218 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_1)));
4219 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_0)));
4220 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_1)));
4221 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_0)));
4222 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_1)));
4223 EXPECT_TRUE(std::get<bool>(var_1->
function(d_0)));
4224 EXPECT_TRUE(std::get<bool>(var_1->
function(d_1)));
4225 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
4226 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child_2)));
4229 ASSERT_NE(var_2,
nullptr);
4230 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_0)));
4231 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_1)));
4232 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_0)));
4233 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_1)));
4234 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
4235 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
4236 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_0)));
4237 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_1)));
4238 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_0)));
4239 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_1)));
4240 EXPECT_TRUE(std::get<bool>(var_2->
function(d_0)));
4241 EXPECT_TRUE(std::get<bool>(var_2->
function(d_1)));
4242 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
4243 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child_2)));
4246 ASSERT_NE(var_3,
nullptr);
4247 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_0)));
4248 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_1)));
4249 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_0)));
4250 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_1)));
4251 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_0)));
4252 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_1)));
4253 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_0)));
4254 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_1)));
4255 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_0)));
4256 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_1)));
4257 EXPECT_TRUE(std::get<bool>(var_3->
function(d_0)));
4258 EXPECT_TRUE(std::get<bool>(var_3->
function(d_1)));
4259 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
4260 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child_2)));
4263 ASSERT_NE(var_4,
nullptr);
4264 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_0)));
4265 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_1)));
4266 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_0)));
4267 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_1)));
4268 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_0)));
4269 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_1)));
4270 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_0)));
4271 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_1)));
4272 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_0)));
4273 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_1)));
4274 EXPECT_FALSE(std::get<bool>(var_4->
function(d_0)));
4275 EXPECT_FALSE(std::get<bool>(var_4->
function(d_1)));
4276 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
4277 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child_2)));
4281 ASSERT_NE(var_5,
nullptr);
4282 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
4283 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
4284 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
4285 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
4286 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_0)));
4287 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_1)));
4288 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_0)));
4289 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_1)));
4290 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_0)));
4291 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_1)));
4292 EXPECT_FALSE(std::get<bool>(var_5->
function(d_0)));
4293 EXPECT_FALSE(std::get<bool>(var_5->
function(d_1)));
4294 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
4295 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child_2)));
4302 class PIDVariableTest :
public ::testing::Test {
4305 void SetUp()
override
4318 particles.registerInDataStore();
4320 particles.registerRelationTo(likelihood);
4326 void TearDown()
override
4332 TEST_F(PIDVariableTest, LogLikelihood)
4341 const float pValue = 0.5;
4342 const float bField = 1.5;
4344 TMatrixDSym cov6(6);
4346 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4347 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4348 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4350 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4351 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4353 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4373 lAll->setLogLikelihood(Const::TOP,
Const::muon, 0.5);
4374 lAll->setLogLikelihood(Const::ARICH,
Const::muon, 0.52);
4375 lAll->setLogLikelihood(Const::ECL,
Const::muon, 0.54);
4376 lAll->setLogLikelihood(Const::CDC,
Const::muon, 0.56);
4377 lAll->setLogLikelihood(Const::SVD,
Const::muon, 0.58);
4378 lAll->setLogLikelihood(Const::KLM,
Const::muon, 0.8);
4380 lAll->setLogLikelihood(Const::TOP,
Const::pion, 0.2);
4381 lAll->setLogLikelihood(Const::ARICH,
Const::pion, 0.22);
4382 lAll->setLogLikelihood(Const::ECL,
Const::pion, 0.24);
4383 lAll->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4384 lAll->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4385 lAll->setLogLikelihood(Const::KLM,
Const::pion, 0.2);
4387 lAll->setLogLikelihood(Const::TOP,
Const::kaon, 0.3);
4388 lAll->setLogLikelihood(Const::ARICH,
Const::kaon, 0.32);
4389 lAll->setLogLikelihood(Const::ECL,
Const::kaon, 0.34);
4390 lAll->setLogLikelihood(Const::CDC,
Const::kaon, 0.36);
4391 lAll->setLogLikelihood(Const::SVD,
Const::kaon, 0.38);
4392 lAll->setLogLikelihood(Const::KLM,
Const::kaon, 0.2);
4409 auto* lAllNoSVD = likelihood.
appendNew();
4413 if (det != Const::SVD) {
4414 lAllNoSVD->setLogLikelihood(det, hypo, lAll->getLogL(hypo, det));
4424 ldEdx->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4425 ldEdx->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4427 ldEdx->setLogLikelihood(Const::CDC,
Const::kaon, 0.36);
4428 ldEdx->setLogLikelihood(Const::SVD,
Const::kaon, 0.38);
4433 ldEdx->setLogLikelihood(Const::CDC,
Const::muon, 0.56);
4434 ldEdx->setLogLikelihood(Const::SVD,
Const::muon, 0.58);
4452 auto* particleAll = particles.appendNew(allTrack,
Const::pion);
4453 auto* particleNoSVD = particles.appendNew(noSVDTrack,
Const::pion);
4454 auto* particledEdx = particles.appendNew(dEdxTrack,
Const::pion);
4455 auto* particleNoID = particles.appendNew(noPIDTrack,
Const::pion);
4457 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);
4458 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);
4461 EXPECT_FLOAT_EQ(electronID(particleAll), std::exp(0.71) / numsumexp);
4462 EXPECT_FLOAT_EQ(muonID(particleAll), std::exp(3.5) / numsumexp);
4463 EXPECT_FLOAT_EQ(pionID(particleAll), std::exp(1.4) / numsumexp);
4464 EXPECT_FLOAT_EQ(kaonID(particleAll), std::exp(1.9) / numsumexp);
4465 EXPECT_FLOAT_EQ(protonID(particleAll), std::exp(2.22) / numsumexp);
4466 EXPECT_FLOAT_EQ(deuteronID(particleAll), std::exp(3.22) / numsumexp);
4469 auto* particleElectron = particles.appendNew(allTrack,
Const::electron);
4470 auto* particleMuon = particles.appendNew(allTrack,
Const::muon);
4471 auto* particleKaon = particles.appendNew(allTrack,
Const::kaon);
4472 auto* particleProton = particles.appendNew(allTrack,
Const::proton);
4473 auto* particleDeuteron = particles.appendNew(allTrack,
Const::deuteron);
4475 EXPECT_FLOAT_EQ(particleID(particleAll), std::exp(1.4) / numsumexp);
4476 EXPECT_FLOAT_EQ(particleID(particleElectron), std::exp(0.71) / numsumexp);
4477 EXPECT_FLOAT_EQ(particleID(particleMuon), std::exp(3.5) / numsumexp);
4478 EXPECT_FLOAT_EQ(particleID(particleKaon), std::exp(1.9) / numsumexp);
4479 EXPECT_FLOAT_EQ(particleID(particleProton), std::exp(2.22) / numsumexp);
4480 EXPECT_FLOAT_EQ(particleID(particleDeuteron), std::exp(3.22) / numsumexp);
4483 EXPECT_FLOAT_EQ(electronID_noSVD(particleNoSVD), std::exp(0.61) / numsumexp_noSVD);
4484 EXPECT_FLOAT_EQ(muonID_noSVD(particleNoSVD), std::exp(2.92) / numsumexp_noSVD);
4485 EXPECT_FLOAT_EQ(pionID_noSVD(particleNoSVD), std::exp(1.12) / numsumexp_noSVD);
4486 EXPECT_FLOAT_EQ(kaonID_noSVD(particleNoSVD), std::exp(1.52) / numsumexp_noSVD);
4487 EXPECT_FLOAT_EQ(protonID_noSVD(particleNoSVD), std::exp(1.74) / numsumexp_noSVD);
4488 EXPECT_FLOAT_EQ(deuteronID_noSVD(particleNoSVD), std::exp(2.54) / numsumexp_noSVD);
4491 std::vector<double> v_pi_K {211., 321.};
4492 std::vector<double> v_pi_p {211., 2212.};
4493 std::vector<double> v_K_p {321., 2212.};
4494 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_K), std::exp(1.4) / (std::exp(1.4) + std::exp(1.9)));
4495 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_p), std::exp(1.4) / (std::exp(1.4) + std::exp(2.22)));
4496 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_K_p), std::exp(1.9) / (std::exp(1.9) + std::exp(2.22)));
4499 EXPECT_TRUE(std::isnan(electronID(particleNoID)));
4500 EXPECT_TRUE(std::isnan(muonID(particleNoID)));
4501 EXPECT_TRUE(std::isnan(pionID(particleNoID)));
4502 EXPECT_TRUE(std::isnan(kaonID(particleNoID)));
4503 EXPECT_TRUE(std::isnan(protonID(particleNoID)));
4504 EXPECT_TRUE(std::isnan(deuteronID(particleNoID)));
4507 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->function(particleAll)),
4509 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, ALL)")->function(particleAll)),
4511 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(2212, TOP, CDC)")->function(
4512 particleAll)), 0.86);
4515 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(1000010020, ALL)")->function(particleAll)),
4516 std::exp(3.22) / numsumexp);
4517 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(2212, ALL)")->function(particleAll)),
4518 std::exp(2.22) / numsumexp);
4519 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particleAll)),
4520 std::exp(1.4) / numsumexp);
4521 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(321, ALL)")->function(particleAll)),
4522 std::exp(1.9) / numsumexp);
4523 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(13, ALL)")->function(particleAll)),
4524 std::exp(3.5) / numsumexp);
4525 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(11, ALL)")->function(particleAll)),
4526 std::exp(0.71) / numsumexp);
4527 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particledEdx)),
4528 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)));
4529 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particledEdx)),
4530 std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC, SVD)")->function(particleAll)));
4531 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->function(particledEdx)),
4532 std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->function(particleAll)));
4533 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(321, CDC)")->function(particleAll)),
4534 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)));
4537 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->function(
4539 1.0 / (1.0 + std::exp(2.22 - 1.9)));
4540 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->function(
4542 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4543 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, CDC, SVD)")->function(
4545 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4548 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->function(
4550 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP, CDC, SVD)")->function(
4552 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->function(
4554 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->function(
4556 EXPECT_TRUE(std::isnan(std::get<double>
4557 (
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH)")->function(
4559 EXPECT_FALSE(std::isnan(std::get<double>
4560 (
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH, SVD)")->function(
4563 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG()")->function(particledEdx)), 1.00001e+09);
4564 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.5, 0.1, 0.1, 0.1, 0.1, 0.1)")->function(
4567 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.5, 0.1, 0.1, 0.1, 0.1)")->function(
4570 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.5, 0.1, 0.1, 0.1)")->function(
4573 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.5, 0.1, 0.1)")->function(
4576 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.1, 0.5, 0.1)")->function(
4579 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0, 1., 0, 0, 0, 0)")->function(particledEdx)),
4583 TEST_F(PIDVariableTest, MissingLikelihood)
4592 const float pValue = 0.5;
4593 const float bField = 1.5;
4595 TMatrixDSym cov6(6);
4597 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4598 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4599 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4601 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4602 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4604 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4621 l2->setLogLikelihood(Const::TOP,
Const::pion, 0.2);
4622 l2->setLogLikelihood(Const::ARICH,
Const::pion, 0.22);
4623 l2->setLogLikelihood(Const::ECL,
Const::pion, 0.24);
4624 l2->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4625 l2->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4628 auto* pion = particles.appendNew(savedTrack2,
Const::pion);
4631 l3->setLogLikelihood(Const::TOP,
Const::kaon, 0.3);
4632 l3->setLogLikelihood(Const::ARICH,
Const::kaon, 0.32);
4635 auto* kaon = particles.appendNew(savedTrack3,
Const::kaon);
4644 auto* proton = particles.appendNew(savedTrack4,
Const::proton);
4651 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(electron)), 0.0);
4652 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(pion)), 0.0);
4653 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(kaon)), 0.0);
4654 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(proton)), 1.0);
4656 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(electron)), 1.0);
4657 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(pion)), 0.0);
4658 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(kaon)), 0.0);
4659 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(proton)), 0.0);
4661 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(electron)), 0.0);
4662 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(pion)), 0.0);
4663 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(kaon)), 1.0);
4664 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(proton)), 0.0);
4667 class FlightInfoTest :
public ::testing::Test {
4670 void SetUp()
override
4677 particles.registerRelationTo(mcParticles);
4705 PxPyPzEVector momentum;
4706 TMatrixFSym error(7);
4713 error(5, 5) = 0.00875;
4715 Particle pi(PxPyPzEVector(1.59607, 1.19705, 0, 2), 211);
4716 momentum += pi.get4Vector();
4717 Particle* newpi = particles.appendNew(pi);
4721 Ks.setVertex(XYZVector(4.0, 5.0, 0.0));
4722 Ks.setMomentumVertexErrorMatrix(error);
4723 momentum += Ks.get4Vector();
4724 Ks.addExtraInfo(
"prodVertX", 1.0);
4725 Ks.addExtraInfo(
"prodVertY", 1.0);
4726 Ks.addExtraInfo(
"prodVertZ", 0.0);
4727 Ks.addExtraInfo(
"prodVertSxx", 0.04);
4728 Ks.addExtraInfo(
"prodVertSxy", 0.0);
4729 Ks.addExtraInfo(
"prodVertSxz", 0.0);
4730 Ks.addExtraInfo(
"prodVertSyx", 0.0);
4731 Ks.addExtraInfo(
"prodVertSyy", 0.00875);
4732 Ks.addExtraInfo(
"prodVertSyz", 0.0);
4733 Ks.addExtraInfo(
"prodVertSzx", 0.0);
4734 Ks.addExtraInfo(
"prodVertSzy", 0.0);
4735 Ks.addExtraInfo(
"prodVertSzz", 0.01);
4736 Particle* newKs = particles.appendNew(Ks);
4741 Dp.appendDaughter(newpi);
4742 Dp.appendDaughter(newKs);
4743 XYZVector motherVtx(1.0, 1.0, 0.0);
4744 Dp.setVertex(motherVtx);
4745 Dp.setMomentumVertexErrorMatrix(error);
4746 Dp.addExtraInfo(
"prodVertX", 0.0);
4747 Dp.addExtraInfo(
"prodVertY", 1.0);
4748 Dp.addExtraInfo(
"prodVertZ", -2.0);
4749 Dp.addExtraInfo(
"prodVertSxx", 0.04);
4750 Dp.addExtraInfo(
"prodVertSxy", 0.0);
4751 Dp.addExtraInfo(
"prodVertSxz", 0.0);
4752 Dp.addExtraInfo(
"prodVertSyx", 0.0);
4753 Dp.addExtraInfo(
"prodVertSyy", 0.01);
4754 Dp.addExtraInfo(
"prodVertSyz", 0.0);
4755 Dp.addExtraInfo(
"prodVertSzx", 0.0);
4756 Dp.addExtraInfo(
"prodVertSzy", 0.0);
4757 Dp.addExtraInfo(
"prodVertSzz", 0.1575);
4758 Particle* newDp = particles.appendNew(Dp);
4764 void TearDown()
override
4769 TEST_F(FlightInfoTest, flightDistance)
4772 const Particle* newKs = particles[1];
4775 ASSERT_NE(var,
nullptr);
4776 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
4778 TEST_F(FlightInfoTest, flightDistanceErr)
4781 const Particle* newKs = particles[1];
4784 ASSERT_NE(var,
nullptr);
4785 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4787 TEST_F(FlightInfoTest, flightTime)
4790 const Particle* newKs = particles[1];
4793 ASSERT_NE(var,
nullptr);
4797 TEST_F(FlightInfoTest, flightTimeErr)
4800 const Particle* newKs = particles[1];
4803 ASSERT_NE(var,
nullptr);
4804 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4807 TEST_F(FlightInfoTest, flightDistanceOfDaughter)
4810 const Particle* newDp = particles[2];
4813 ASSERT_NE(var,
nullptr);
4814 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4817 ASSERT_NE(var,
nullptr);
4818 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4820 TEST_F(FlightInfoTest, flightDistanceOfDaughterErr)
4823 const Particle* newDp = particles[2];
4826 ASSERT_NE(var,
nullptr);
4827 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4830 ASSERT_NE(var,
nullptr);
4831 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4833 TEST_F(FlightInfoTest, flightTimeOfDaughter)
4836 const Particle* newDp = particles[2];
4839 ASSERT_NE(var,
nullptr);
4845 ASSERT_NE(var,
nullptr);
4846 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4848 TEST_F(FlightInfoTest, flightTimeOfDaughterErr)
4851 const Particle* newDp = particles[2];
4854 ASSERT_NE(var,
nullptr);
4855 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4858 ASSERT_NE(var,
nullptr);
4859 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4861 TEST_F(FlightInfoTest, mcFlightDistanceOfDaughter)
4864 const Particle* newDp = particles[2];
4867 ASSERT_NE(var,
nullptr);
4869 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4872 ASSERT_NE(var,
nullptr);
4873 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4875 TEST_F(FlightInfoTest, mcFlightTimeOfDaughter)
4878 const Particle* newDp = particles[2];
4881 ASSERT_NE(var,
nullptr);
4886 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), Ks->getLifetime() / Ks->
getEnergy()*Ks->
getMass());
4889 ASSERT_NE(var,
nullptr);
4890 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4893 TEST_F(FlightInfoTest, vertexDistance)
4896 const Particle* newKS = particles[1];
4899 ASSERT_NE(var,
nullptr);
4900 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 5.0);
4903 TEST_F(FlightInfoTest, vertexDistanceError)
4906 const Particle* newKS = particles[1];
4909 ASSERT_NE(var,
nullptr);
4910 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 0.2);
4913 TEST_F(FlightInfoTest, vertexDistanceSignificance)
4916 const Particle* newKS = particles[1];
4919 ASSERT_NE(var,
nullptr);
4920 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 25);
4923 TEST_F(FlightInfoTest, vertexDistanceOfDaughter)
4926 const Particle* newDp = particles[2];
4929 ASSERT_NE(var,
nullptr);
4930 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4933 ASSERT_NE(var,
nullptr);
4934 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 6.0);
4937 ASSERT_NE(var,
nullptr);
4938 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4941 TEST_F(FlightInfoTest, vertexDistanceOfDaughterError)
4944 const Particle* newDp = particles[2];
4947 ASSERT_NE(var,
nullptr);
4948 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.2);
4951 ASSERT_NE(var,
nullptr);
4952 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.25);
4955 TEST_F(FlightInfoTest, vertexDistanceOfDaughterSignificance)
4958 const Particle* newDp = particles[2];
4961 ASSERT_NE(var,
nullptr);
4962 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 25);
4965 ASSERT_NE(var,
nullptr);
4966 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 24);
4969 class VertexVariablesTest :
public ::testing::Test {
4972 void SetUp()
override
4979 particles.registerRelationTo(mcParticles);
4994 Particle Ks(PxPyPzEVector(1.164, 1.55200, 0, 2), 310);
5008 Particle* newKs = particles.appendNew(Ks);
5013 void TearDown()
override
5020 TEST_F(VertexVariablesTest, mcDecayVertexX)
5023 const Particle* newKs = particles[0];
5026 ASSERT_NE(var,
nullptr);
5027 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 4.0);
5030 TEST_F(VertexVariablesTest, mcDecayVertexY)
5033 const Particle* newKs = particles[0];
5036 ASSERT_NE(var,
nullptr);
5037 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
5040 TEST_F(VertexVariablesTest, mcDecayVertexZ)
5043 const Particle* newKs = particles[0];
5046 ASSERT_NE(var,
nullptr);
5047 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.0);
5051 TEST_F(VertexVariablesTest, mcDecayVertexFromIPDistance)
5054 const Particle* newKs = particles[0];
5057 ASSERT_NE(var,
nullptr);
5058 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), sqrt(4.0 * 4.0 + 5.0 * 5.0));
5061 TEST_F(VertexVariablesTest, mcDecayVertexRho)
5064 const Particle* newKs = particles[0];
5067 ASSERT_NE(var,
nullptr);
5068 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), sqrt(4.0 * 4.0 + 5.0 * 5.0));
5071 TEST_F(VertexVariablesTest, mcProductionVertexX)
5074 const Particle* newKs = particles[0];
5077 ASSERT_NE(var,
nullptr);
5078 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
5081 TEST_F(VertexVariablesTest, mcProductionVertexY)
5084 const Particle* newKs = particles[0];
5087 ASSERT_NE(var,
nullptr);
5088 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
5091 TEST_F(VertexVariablesTest, mcProductionVertexZ)
5094 const Particle* newKs = particles[0];
5097 ASSERT_NE(var,
nullptr);
5098 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
5103 TEST_F(VertexVariablesTest, prodVertexX)
5106 const Particle* newKs = particles[0];
5109 ASSERT_NE(var,
nullptr);
5110 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
5112 TEST_F(VertexVariablesTest, prodVertexY)
5115 const Particle* newKs = particles[0];
5118 ASSERT_NE(var,
nullptr);
5119 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
5121 TEST_F(VertexVariablesTest, prodVertexZ)
5124 const Particle* newKs = particles[0];
5127 ASSERT_NE(var,
nullptr);
5128 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
5133 TEST_F(VertexVariablesTest, prodVertexCov)
5136 const Particle* newKs = particles[0];
5140 ASSERT_NE(var,
nullptr);
5141 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.1);
5143 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.2);
5145 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.3);
5147 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.4);
5149 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.5);
5151 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.6);
5153 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.7);
5155 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.8);
5157 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.9);
5159 ASSERT_NE(var,
nullptr);
5160 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), sqrt(0.1));
5162 ASSERT_NE(var,
nullptr);
5163 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), sqrt(0.5));
5165 ASSERT_NE(var,
nullptr);
5166 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), sqrt(0.9));
5171 TEST_F(MetaVariableTest, KSFWVariables)
5182 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5185 EXPECT_B2ERROR(
Manager::Instance().getVariable(
"KSFWVariables(et, mask, FS1)"));
5188 TEST_F(MetaVariableTest, CleoConeCS)
5199 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5203 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5209 TEST_F(MetaVariableTest, TransformedNetworkOutput)
5212 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONSENSE)"));
5215 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, 0, NOTDOUBLE)"));
5216 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, NOTDOUBLE, 1)"));
5222 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle))));
5224 if (not eventExtraInfo.isValid())
5225 eventExtraInfo.create();
5227 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.
void setPValue(double pValue)
Sets chi^2 probability of fit.
@ 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.
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.