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(particleDRho(part), std::fabs(trackD0FromIP(part)));
395 EXPECT_FLOAT_EQ(particleDZ(part), trackZ0FromIP(part));
396 EXPECT_FLOAT_EQ(3, trackNCDCHits(part));
397 EXPECT_FLOAT_EQ(24, trackNSVDHits(part));
398 EXPECT_FLOAT_EQ(12, trackNPXDHits(part));
402 myResults.
appendNew(position, momentum, cov6, charge * -1,
408 myV0s.
appendNew(
V0(std::pair(savedTrack, myResults[0]), std::pair(savedTrack2, myResults[1]), 0.0, 0.0, 0.0));
409 const PxPyPzEVector v0Momentum(2 * momentum.X(), 2 * momentum.Y(), 2 * momentum.Z(), (momentum * 2).R());
410 auto v0particle = myParticles.
appendNew(v0Momentum, 22,
412 v0particle->appendDaughter(0,
false);
413 v0particle->appendDaughter(1,
false);
416 EXPECT_FALSE(std::get<bool>(vIsFromTrack->
function(v0particle)));
417 EXPECT_FALSE(std::get<bool>(vIsFromECL->
function(v0particle)));
418 EXPECT_FALSE(std::get<bool>(vIsFromKLM->
function(v0particle)));
419 EXPECT_TRUE(std::get<bool>(vIsFromV0->
function(v0particle)));
422 EXPECT_EQ(std::get<int>(vNDaughters->
function(v0particle)), 2);
425 class MCTruthVariablesTest :
public ::testing::Test {
443 tracks.registerInDataStore();
445 particles.registerInDataStore();
449 tracks.registerRelationTo(mcparticles);
450 particles.registerRelationTo(mcparticles);
454 tracks.registerRelationTo(clusters);
479 cl0->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
480 cl0->setClusterId(0);
484 cl1->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
485 cl1->setClusterId(1);
490 ROOT::Math::XYZVector(), ROOT::Math::XYZVector(), cov, -1,
Const::electron, 0.5, 1.5,
491 static_cast<unsigned long long int>(0x300000000000000), 16777215, 0);
492 auto* electron_tr = tracks.appendNew(
Track());
494 electron_tr->addRelationTo(cl1);
498 ROOT::Math::XYZVector(), ROOT::Math::XYZVector(), cov1, -1,
Const::pion, 0.51, 1.5,
499 static_cast<unsigned long long int>(0x300000000000000), 16777215, 0);
500 auto* pion_tr = tracks.appendNew(
Track());
502 pion_tr->addRelationTo(cl1);
505 cl0->addRelationTo(true_photon, 12.3);
506 cl0->addRelationTo(true_electron, 2.3);
507 cl1->addRelationTo(true_electron, 45.6);
508 cl1->addRelationTo(true_photon, 5.6);
509 cl1->addRelationTo(true_pion, 15.6);
511 electron_tr->addRelationTo(true_electron);
512 pion_tr->addRelationTo(true_pion);
515 const auto* photon = particles.appendNew(
Particle(cl0));
518 const auto* misid_photon = particles.appendNew(
Particle(cl1));
521 photon->addRelationTo(true_photon);
522 electron->addRelationTo(true_electron);
523 pion->addRelationTo(true_pion);
524 misid_photon->addRelationTo(true_electron);
527 virtual void TearDown()
533 TEST_F(MCTruthVariablesTest, mcCosThetaBetweenParticleAndNominalB)
539 particles.registerInDataStore();
541 particles.registerRelationTo(mcParticles);
554 graphParticleDaughter1.
comesFrom(graphParticleMother);
555 graphParticleDaughter2.
comesFrom(graphParticleMother);
556 graphParticleGranddaughter1.
comesFrom(graphParticleDaughter1);
557 graphParticleGranddaughter2.
comesFrom(graphParticleDaughter1);
558 graphParticleGranddaughter3.
comesFrom(graphParticleDaughter1);
560 graphParticleMother.
setPDG(-521);
561 graphParticleDaughter1.
setPDG(421);
565 graphParticleGranddaughter3.
setPDG(12);
572 graphParticleMother.
setMass(16.55294535724685);
575 PxPyPzEVector dummyP4(1, 2, 1, 5);
576 double dummyM = 4.3589;
578 graphParticleDaughter1.
setMass(dummyM);
580 graphParticleDaughter2.
setMass(dummyM);
581 graphParticleGranddaughter1.
set4Vector(dummyP4);
582 graphParticleGranddaughter1.
setMass(dummyM);
583 graphParticleGranddaughter2.
set4Vector(dummyP4);
584 graphParticleGranddaughter2.
setMass(dummyM);
589 auto* pMother = particles.appendNew(dummyP4, -521);
590 pMother->addRelationTo(mcParticles[0]);
592 particles.appendNew(dummyP4, 421)->addRelationTo(mcParticles[1]);
593 particles.appendNew(dummyP4, -211)->addRelationTo(mcParticles[2]);
594 particles.appendNew(dummyP4, -321)->addRelationTo(mcParticles[3]);
595 particles.appendNew(dummyP4, -11)->addRelationTo(mcParticles[4]);
596 particles.appendNew(dummyP4, 12)->addRelationTo(mcParticles[5]);
599 double M_B = pMother->getPDGMass();
600 double p_B = std::sqrt(E_B * E_B - M_B * M_B);
603 double E_Y = p4_Y_CMS.E();
604 double p_Y = p4_Y_CMS.P();
605 double M_Y = p4_Y_CMS.M();
607 double expectedCosBY = (2 * E_B * E_Y - M_B * M_B - M_Y * M_Y) / (2 * p_B * p_Y);
611 EXPECT_NEAR(std::get<double>(mcCosBY->function(pMother)), expectedCosBY, 1e-4);
614 TEST_F(MCTruthVariablesTest, ECLMCMatchWeightVariable)
617 const auto* photon = particles[0];
618 const auto* electron = particles[1];
619 const auto* pion = particles[2];
622 EXPECT_FLOAT_EQ(std::get<double>(weight->function(photon)), 12.3);
623 EXPECT_FLOAT_EQ(std::get<double>(weight->function(electron)), 45.6);
624 EXPECT_FLOAT_EQ(std::get<double>(weight->function(pion)), 15.6);
627 TEST_F(MCTruthVariablesTest, ECLBestMCMatchVariables)
630 const auto* photon = particles[0];
631 const auto* electron = particles[1];
632 const auto* pion = particles[2];
633 const auto* misid_photon = particles[3];
643 EXPECT_FLOAT_EQ(std::get<double>(weight->function(photon)), 12.3);
644 EXPECT_FLOAT_EQ(std::get<double>(weight->function(electron)), 45.6);
645 EXPECT_FLOAT_EQ(std::get<double>(weight->function(pion)), 45.6);
646 EXPECT_FLOAT_EQ(std::get<double>(weight->function(misid_photon)), 45.6);
650 class EventVariableTest :
public ::testing::Test {
653 void SetUp()
override
663 void TearDown()
override
669 TEST_F(EventVariableTest, ExperimentRunEventDateAndTime)
679 EXPECT_FALSE(std::get<double>(date->function(
nullptr)) == std::get<double>(date->function(
nullptr)));
680 EXPECT_FALSE(std::get<double>(year->
function(
nullptr)) == std::get<double>(year->
function(
nullptr)));
681 EXPECT_FALSE(std::get<double>(time->function(
nullptr)) == std::get<double>(time->function(
nullptr)));
688 evtMetaData->setExperiment(1337);
689 evtMetaData->setRun(12345);
690 evtMetaData->setEvent(54321);
691 evtMetaData->setTime(1288569600e9);
696 EXPECT_EQ(std::get<int>(exp->function(
nullptr)), 1337);
697 EXPECT_EQ(std::get<int>(run->function(
nullptr)), 12345);
698 EXPECT_EQ(std::get<int>(evt->
function(
nullptr)), 54321);
699 EXPECT_FLOAT_EQ(std::get<double>(date->function(
nullptr)), 20101101.);
700 EXPECT_FLOAT_EQ(std::get<double>(year->
function(
nullptr)), 2010.);
701 EXPECT_FLOAT_EQ(std::get<double>(time->function(
nullptr)), 1288569600);
704 TEST_F(EventVariableTest, TestGlobalCounters)
708 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 0);
710 for (
unsigned i = 0; i < 10; ++i)
713 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 10);
718 TEST_F(EventVariableTest, TestIfContinuumEvent_ForContinuumEvent)
723 particles.registerRelationTo(mcParticles);
726 auto* mcParticle = mcParticles.
appendNew();
729 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
730 p1->addRelationTo(mcParticle);
735 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
736 p2->addRelationTo(mcParticle);
739 ASSERT_NE(var,
nullptr);
740 EXPECT_TRUE(std::get<bool>(var->function(p1)));
741 EXPECT_TRUE(std::get<bool>(var->function(p2)));
743 ASSERT_NE(varN,
nullptr);
744 EXPECT_FALSE(std::get<bool>(varN->
function(p1)));
745 EXPECT_FALSE(std::get<bool>(varN->
function(p2)));
748 TEST_F(EventVariableTest, TestIfContinuumEvent_ForUpsilon4SEvent)
756 auto* mcParticle = mcParticles2.
appendNew();
759 auto* p3 = particles2.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
760 p3->addRelationTo(mcParticle);
763 mcParticle->setPDG(300553);
765 auto* p4 = particles2.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 300553);
766 p4->addRelationTo(mcParticle);
769 ASSERT_NE(var2,
nullptr);
770 EXPECT_FALSE(std::get<bool>(var2->
function(p3)));
771 EXPECT_FALSE(std::get<bool>(var2->
function(p4)));
773 ASSERT_NE(var2N,
nullptr);
774 EXPECT_TRUE(std::get<bool>(var2N->
function(p3)));
775 EXPECT_TRUE(std::get<bool>(var2N->
function(p4)));
778 TEST_F(EventVariableTest, TestIfContinuumEvent_ForWrongReconstructedUpsilon4SEvent)
786 auto* mcParticle = mcParticles3.
appendNew();
789 auto* p5 = particles3.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
790 p5->addRelationTo(mcParticle);
793 mcParticle->setPDG(300553);
795 auto* p6 = particles3.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 15);
796 p6->addRelationTo(mcParticle);
799 ASSERT_NE(var3,
nullptr);
800 EXPECT_FALSE(std::get<bool>(var3->
function(p5)));
801 EXPECT_FALSE(std::get<bool>(var3->
function(p6)));
803 ASSERT_NE(var3N,
nullptr);
804 EXPECT_TRUE(std::get<bool>(var3N->
function(p5)));
805 EXPECT_TRUE(std::get<bool>(var3N->
function(p6)));
809 class MetaVariableTest :
public ::testing::Test {
812 void SetUp()
override
823 void TearDown()
override
829 TEST_F(MetaVariableTest, countDaughters)
831 PxPyPzEVector momentum;
832 const int nDaughters = 6;
834 std::vector<int> daughterIndices;
835 for (
int i = 0; i < nDaughters; i++) {
836 Particle d(PxPyPzEVector(1, 0, 0, 3.0), (i % 2) ? 211 : -211);
837 momentum += d.get4Vector();
838 Particle* newDaughters = particles.appendNew(d);
844 ASSERT_NE(var,
nullptr);
845 EXPECT_EQ(std::get<int>(var->function(p)), 3);
848 ASSERT_NE(var,
nullptr);
849 EXPECT_EQ(std::get<int>(var->function(p)), 6);
853 TEST_F(MetaVariableTest, useRestFrame)
856 gearbox.setBackends({std::string(
"file:")});
858 gearbox.open(
"geometry/Belle2.xml",
false);
860 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
861 p.setVertex(XYZVector(1.0, 2.0, 2.0));
864 ASSERT_NE(var,
nullptr);
865 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
868 ASSERT_NE(var,
nullptr);
869 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
872 ASSERT_NE(var,
nullptr);
873 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
876 ASSERT_NE(var,
nullptr);
877 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.0, 1e-9);
880 ASSERT_NE(var,
nullptr);
881 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.4358899);
884 ASSERT_NE(var,
nullptr);
885 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.0);
888 TEST_F(MetaVariableTest, useLabFrame)
890 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
891 p.setVertex(XYZVector(1.0, 2.0, 2.0));
894 ASSERT_NE(var,
nullptr);
895 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
898 ASSERT_NE(var,
nullptr);
899 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
902 ASSERT_NE(var,
nullptr);
903 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
906 ASSERT_NE(var,
nullptr);
907 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
910 ASSERT_NE(var,
nullptr);
911 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
914 ASSERT_NE(var,
nullptr);
915 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
918 TEST_F(MetaVariableTest, useCMSFrame)
921 gearbox.setBackends({std::string(
"file:")});
923 gearbox.open(
"geometry/Belle2.xml",
false);
925 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 411);
926 p.setVertex(XYZVector(1.0, 2.0, 2.0));
929 ASSERT_NE(var,
nullptr);
930 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
933 ASSERT_NE(var,
nullptr);
934 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
937 ASSERT_NE(var,
nullptr);
938 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
941 ASSERT_NE(var,
nullptr);
942 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.68174650327489894064);
945 ASSERT_NE(var,
nullptr);
946 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.80918372124478121776);
949 ASSERT_NE(var,
nullptr);
950 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.1853695);
953 TEST_F(MetaVariableTest, useTagSideRecoilRestFrame)
957 particles.registerInDataStore();
961 PxPyPzEVector vec1 = {0.0, +0.332174566, 0.0, T.
getCMSEnergy() / 2.};
962 PxPyPzEVector vec2 = {0.0, -0.332174566, 0.0, T.
getCMSEnergy() / 2.};
971 ASSERT_NE(var,
nullptr);
972 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
975 ASSERT_NE(var,
nullptr);
976 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
979 ASSERT_NE(var,
nullptr);
980 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
983 ASSERT_NE(var,
nullptr);
984 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
987 ASSERT_NE(var,
nullptr);
988 EXPECT_NEAR(std::get<double>(var->function(p0)), p1->getMass(), 1e-6);
991 TEST_F(MetaVariableTest, useMCancestorBRestFrame)
996 particles.registerInDataStore();
998 particles.registerRelationTo(mcparticles);
1007 Particle particle({ 0.1, -0.4, 0.8, 1.0 }, 411);
1008 auto* p = particles.appendNew(particle);
1009 p->setVertex(XYZVector(1.0, 2.0, 2.0));
1010 p->addRelationTo(mcparticles[1]);
1012 mcparticles[1]->setPDG(411);
1015 mcparticles[0]->setMomentum(XYZVector(0.0, 0.0, 0.1));
1017 mcparticles[0]->setPDG(511);
1018 mcparticles[0]->setMassFromPDG();
1022 ASSERT_NE(var,
nullptr);
1023 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0.88333338);
1026 ASSERT_NE(var,
nullptr);
1027 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0.98502684);
1030 ASSERT_NE(var,
nullptr);
1031 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 3.0007174);
1034 TEST_F(MetaVariableTest, extraInfo)
1036 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 11);
1037 p.addExtraInfo(
"pi", 3.14);
1040 ASSERT_NE(var,
nullptr);
1041 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.14);
1044 EXPECT_TRUE(std::isnan(std::get<double>(var->function(
nullptr))));
1047 TEST_F(MetaVariableTest, eventExtraInfo)
1050 if (not eventExtraInfo.isValid())
1051 eventExtraInfo.create();
1052 eventExtraInfo->addExtraInfo(
"pi", 3.14);
1054 ASSERT_NE(var,
nullptr);
1055 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1058 TEST_F(MetaVariableTest, eventCached)
1061 ASSERT_NE(var,
nullptr);
1062 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1064 EXPECT_TRUE(eventExtraInfo.isValid());
1065 EXPECT_TRUE(eventExtraInfo->hasExtraInfo(
"__constant__bo3__pt14__bc"));
1066 EXPECT_FLOAT_EQ(eventExtraInfo->getExtraInfo(
"__constant__bo3__pt14__bc"), 3.14);
1067 eventExtraInfo->addExtraInfo(
"__eventExtraInfo__bopi__bc", 3.14);
1069 ASSERT_NE(var,
nullptr);
1070 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1073 TEST_F(MetaVariableTest, particleCached)
1075 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1077 ASSERT_NE(var,
nullptr);
1078 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
1079 EXPECT_TRUE(p.hasExtraInfo(
"__px"));
1080 EXPECT_FLOAT_EQ(p.getExtraInfo(
"__px"), 0.1);
1081 p.addExtraInfo(
"__py", -0.5);
1083 ASSERT_NE(var,
nullptr);
1084 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.5);
1087 TEST_F(MetaVariableTest, basicMathTest)
1089 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1092 ASSERT_NE(var,
nullptr);
1093 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.4);
1096 ASSERT_NE(var,
nullptr);
1097 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.8);
1100 ASSERT_NE(var,
nullptr);
1101 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 2.0);
1104 ASSERT_NE(var,
nullptr);
1105 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1109 ASSERT_NE(var,
nullptr);
1110 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1114 ASSERT_NE(var,
nullptr);
1115 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1119 ASSERT_NE(var,
nullptr);
1120 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.5707963267948966);
1124 ASSERT_NE(var,
nullptr);
1125 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1129 ASSERT_NE(var,
nullptr);
1130 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.5707963267948966);
1134 TEST_F(MetaVariableTest, formula)
1141 Particle p({ 0.1, -0.4, 0.8, 2.0 }, -411);
1144 ASSERT_NE(var,
nullptr);
1145 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.3);
1148 ASSERT_NE(var,
nullptr);
1149 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1152 ASSERT_NE(var,
nullptr);
1153 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.04);
1156 ASSERT_NE(var,
nullptr);
1157 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -4.0);
1160 ASSERT_NE(var,
nullptr);
1161 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.01);
1164 ASSERT_NE(var,
nullptr);
1165 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1168 ASSERT_NE(var,
nullptr);
1169 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1172 ASSERT_NE(var,
nullptr);
1173 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.41231057);
1174 double pt = std::get<double>(var->function(&p));
1177 ASSERT_NE(var,
nullptr);
1178 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), pt);
1181 ASSERT_NE(var,
nullptr);
1182 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1185 ASSERT_NE(var,
nullptr);
1186 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1189 ASSERT_NE(var,
nullptr);
1190 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1193 ASSERT_NE(var,
nullptr);
1194 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 411.0);
1197 ASSERT_NE(var,
nullptr);
1198 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -168921.0);
1201 ASSERT_NE(var,
nullptr);
1202 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 8.33);
1205 ASSERT_NE(var,
nullptr);
1206 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -8.33);
1209 ASSERT_NE(var,
nullptr);
1210 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 411);
1213 TEST_F(MetaVariableTest, passesCut)
1215 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1216 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 411);
1219 ASSERT_NE(var,
nullptr);
1220 EXPECT_TRUE(std::get<bool>(var->function(&p)));
1221 EXPECT_FALSE(std::get<bool>(var->function(&p2)));
1226 TEST_F(MetaVariableTest, unmask)
1231 particles.registerInDataStore();
1233 particles.registerRelationTo(mcParticles);
1247 graphParticleGrandMother.
setPDG(-521);
1249 graphParticleAunt.
setPDG(-14);
1251 graphParticleDaughter2.
setPDG(14);
1253 graphParticleMother.
comesFrom(graphParticleGrandMother);
1254 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1255 graphParticleDaughter1.
comesFrom(graphParticleMother);
1256 graphParticleDaughter2.
comesFrom(graphParticleMother);
1261 auto* mcGrandMother = mcParticles[0];
1264 auto* mcMother = mcParticles[1];
1267 auto* mcAunt = mcParticles[2];
1270 auto* mcDaughter1 = mcParticles[3];
1273 auto* mcDaughter2 = mcParticles[4];
1276 auto* pGrandMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1277 pGrandMother->addRelationTo(mcGrandMother);
1279 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1280 pMother->addRelationTo(mcMother);
1283 pMother->writeExtraInfo(
"mcErrors", 8);
1284 pGrandMother->writeExtraInfo(
"mcErrors", 8 | 16);
1287 ASSERT_NE(var1,
nullptr);
1288 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pMother)), 0);
1289 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pGrandMother)), 16);
1290 ASSERT_NE(var2,
nullptr);
1291 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pMother)), 0);
1292 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pGrandMother)), 0);
1295 pMother->writeExtraInfo(
"mcErrors", 8 | 128);
1296 pGrandMother->writeExtraInfo(
"mcErrors", 8 | 16 | 512);
1297 ASSERT_NE(var1,
nullptr);
1298 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pMother)), 128);
1299 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pGrandMother)), 16 | 512);
1300 ASSERT_NE(var2,
nullptr);
1301 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pMother)), 128);
1302 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pGrandMother)), 512);
1311 TEST_F(MetaVariableTest, conditionalVariableSelector)
1313 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1316 ASSERT_NE(var,
nullptr);
1317 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
1320 ASSERT_NE(var,
nullptr);
1321 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.4);
1325 TEST_F(MetaVariableTest, nCleanedTracks)
1331 tracks.registerInDataStore();
1334 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1335 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 11);
1337 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.1, 0.0, 0.0),
1338 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1339 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.15, 0.0, 0.0),
1340 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1341 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.4, 0.0, 0.0),
1342 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1343 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.6, 0.0, 0.0),
1344 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1346 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 0);
1347 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 1);
1348 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 2);
1349 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 3);
1352 EXPECT_FLOAT_EQ(std::get<int>(var1->function(
nullptr)), 1);
1355 EXPECT_FLOAT_EQ(std::get<int>(var2->
function(
nullptr)), 2);
1358 EXPECT_FLOAT_EQ(std::get<int>(var3->
function(
nullptr)), 4);
1363 TEST_F(MetaVariableTest, NumberOfMCParticlesInEvent)
1365 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1366 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 11);
1369 auto* mcParticle = mcParticles.appendNew();
1372 mcParticle = mcParticles.appendNew();
1375 mcParticle = mcParticles.appendNew();
1378 mcParticle = mcParticles.appendNew();
1383 ASSERT_NE(var,
nullptr);
1384 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 2);
1388 TEST_F(MetaVariableTest, daughterInvM)
1390 PxPyPzEVector momentum;
1391 const int nDaughters = 6;
1393 std::vector<int> daughterIndices;
1394 for (
int i = 0; i < nDaughters; i++) {
1395 Particle d(PxPyPzEVector(2, 2, 2, 4.0), (i % 2) ? 213 : -213);
1396 momentum += d.get4Vector();
1397 Particle* newDaughters = particles.appendNew(d);
1403 ASSERT_NE(var,
nullptr);
1404 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1407 ASSERT_NE(var,
nullptr);
1408 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 4.0);
1411 ASSERT_NE(var,
nullptr);
1412 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 6.0);
1415 TEST_F(MetaVariableTest, daughter)
1417 PxPyPzEVector momentum;
1418 const int nDaughters = 6;
1420 std::vector<int> daughterIndices;
1421 for (
int i = 0; i < nDaughters; i++) {
1422 Particle d(PxPyPzEVector(i * 1.0, 1, 1, 1), (i % 2) ? 211 : -211);
1423 momentum += d.get4Vector();
1424 Particle* newDaughters = particles.appendNew(d);
1430 ASSERT_NE(var,
nullptr);
1431 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1434 ASSERT_NE(var,
nullptr);
1435 EXPECT_NEAR(std::get<double>(var->function(p)), 0.0, 1e-6);
1438 ASSERT_NE(var,
nullptr);
1439 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 1.0);
1442 ASSERT_NE(var,
nullptr);
1443 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 2.0);
1446 TEST_F(MetaVariableTest, mcDaughter)
1451 particles.registerInDataStore();
1453 particles.registerRelationTo(mcParticles);
1467 graphParticleGrandMother.
setPDG(-521);
1469 graphParticleAunt.
setPDG(-14);
1471 graphParticleDaughter2.
setPDG(14);
1473 graphParticleMother.
comesFrom(graphParticleGrandMother);
1474 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1475 graphParticleDaughter1.
comesFrom(graphParticleMother);
1476 graphParticleDaughter2.
comesFrom(graphParticleMother);
1480 auto* mcGrandMother = mcParticles[0];
1483 auto* mcMother = mcParticles[1];
1486 auto* mcAunt = mcParticles[2];
1489 auto* mcDaughter1 = mcParticles[3];
1492 auto* mcDaughter2 = mcParticles[4];
1495 auto* pGrandMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1496 pGrandMother->addRelationTo(mcGrandMother);
1498 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1499 pMother->addRelationTo(mcMother);
1502 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1505 auto* p_noDaughter = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1506 p_noDaughter->addRelationTo(mcDaughter1);
1509 ASSERT_NE(var,
nullptr);
1510 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 13);
1511 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), 11);
1512 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1513 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noDaughter))));
1515 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), -14);
1516 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), 14);
1519 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1520 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1523 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 11);
1524 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1526 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 14);
1528 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1530 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1533 TEST_F(MetaVariableTest, mcMother)
1538 particles.registerInDataStore();
1540 particles.registerRelationTo(mcParticles);
1554 graphParticleGrandMother.
setPDG(-521);
1556 graphParticleAunt.
setPDG(-14);
1558 graphParticleDaughter2.
setPDG(14);
1560 graphParticleMother.
comesFrom(graphParticleGrandMother);
1561 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1562 graphParticleDaughter1.
comesFrom(graphParticleMother);
1563 graphParticleDaughter2.
comesFrom(graphParticleMother);
1568 auto* mcGrandMother = mcParticles[0];
1571 auto* mcMother = mcParticles[1];
1574 auto* mcAunt = mcParticles[2];
1577 auto* mcDaughter1 = mcParticles[3];
1580 auto* mcDaughter2 = mcParticles[4];
1583 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1584 p1->addRelationTo(mcDaughter1);
1586 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 14);
1587 p2->addRelationTo(mcDaughter2);
1589 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1590 pMother->addRelationTo(mcMother);
1593 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1596 auto* p_noMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1597 p_noMother->addRelationTo(mcGrandMother);
1600 ASSERT_NE(var,
nullptr);
1601 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 13);
1602 EXPECT_FLOAT_EQ(std::get<double>(var->function(p2)), 13);
1603 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), -521);
1604 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1605 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMother))));
1609 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1612 TEST_F(MetaVariableTest, genParticle)
1617 particles.registerInDataStore();
1619 particles.registerRelationTo(mcParticles);
1633 graphParticleGrandMother.
setPDG(300553);
1634 graphParticleMother.
setPDG(-521);
1635 graphParticleAunt.
setPDG(521);
1637 graphParticleDaughter2.
setPDG(-12);
1639 graphParticleGrandMother.
setMomentum(0.0, 0.0, 0.4);
1642 graphParticleMother.
comesFrom(graphParticleGrandMother);
1643 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1644 graphParticleDaughter1.
comesFrom(graphParticleMother);
1645 graphParticleDaughter2.
comesFrom(graphParticleMother);
1650 auto* mcGrandMother = mcParticles[0];
1653 auto* mcMother = mcParticles[1];
1656 auto* mcAunt = mcParticles[2];
1659 auto* mcDaughter1 = mcParticles[3];
1662 auto* mcDaughter2 = mcParticles[4];
1665 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1666 p1->addRelationTo(mcDaughter1);
1669 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 211);
1672 ASSERT_NE(var,
nullptr);
1673 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 300553);
1674 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 300553);
1677 ASSERT_NE(var,
nullptr);
1678 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 0.4);
1679 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 0.4);
1682 ASSERT_NE(var,
nullptr);
1683 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1684 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1687 ASSERT_NE(var,
nullptr);
1688 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 1.1);
1689 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 1.1);
1692 ASSERT_NE(var,
nullptr);
1693 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1694 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1697 ASSERT_NE(var,
nullptr);
1698 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -12);
1699 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -12);
1702 ASSERT_NE(var,
nullptr);
1703 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p1))));
1704 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1707 TEST_F(MetaVariableTest, genUpsilon4S)
1712 particles.registerInDataStore();
1714 particles.registerRelationTo(mcParticles);
1728 graphParticleGrandMother.
setPDG(300553);
1729 graphParticleMother.
setPDG(-521);
1730 graphParticleAunt.
setPDG(521);
1732 graphParticleDaughter2.
setPDG(-12);
1734 graphParticleGrandMother.
setMomentum(0.0, 0.0, 0.4);
1737 graphParticleMother.
comesFrom(graphParticleGrandMother);
1738 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1739 graphParticleDaughter1.
comesFrom(graphParticleMother);
1740 graphParticleDaughter2.
comesFrom(graphParticleMother);
1745 auto* mcGrandMother = mcParticles[0];
1748 auto* mcMother = mcParticles[1];
1751 auto* mcAunt = mcParticles[2];
1754 auto* mcDaughter1 = mcParticles[3];
1757 auto* mcDaughter2 = mcParticles[4];
1760 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1761 p1->addRelationTo(mcDaughter1);
1764 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 211);
1767 ASSERT_NE(var,
nullptr);
1768 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 300553);
1769 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 300553);
1772 ASSERT_NE(var,
nullptr);
1773 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 0.4);
1774 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 0.4);
1777 ASSERT_NE(var,
nullptr);
1778 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1779 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1782 ASSERT_NE(var,
nullptr);
1783 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 1.1);
1784 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 1.1);
1787 mcParticles.
clear();
1802 auto* mcP1 = mcParticles[0];
1805 auto* mcP2 = mcParticles[1];
1808 auto* someParticle = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1809 someParticle->addRelationTo(mcP1);
1812 ASSERT_NE(var,
nullptr);
1813 EXPECT_TRUE(std::isnan(std::get<double>(var->function(someParticle))));
1816 TEST_F(MetaVariableTest, daughterProductOf)
1818 PxPyPzEVector momentum;
1819 const int nDaughters = 4;
1821 std::vector<int> daughterIndices;
1822 for (
int i = 0; i < nDaughters; i++) {
1823 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1824 momentum += d.get4Vector();
1825 Particle* newDaughters = particles.appendNew(d);
1831 ASSERT_NE(var,
nullptr);
1832 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 120.0);
1835 TEST_F(MetaVariableTest, daughterSumOf)
1837 PxPyPzEVector momentum;
1838 const int nDaughters = 4;
1840 std::vector<int> daughterIndices;
1841 for (
int i = 0; i < nDaughters; i++) {
1842 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1843 momentum += d.get4Vector();
1844 Particle* newDaughters = particles.appendNew(d);
1850 ASSERT_NE(var,
nullptr);
1851 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 14.0);
1854 TEST_F(MetaVariableTest, daughterLowest)
1856 PxPyPzEVector momentum;
1857 const int nDaughters = 4;
1859 std::vector<int> daughterIndices;
1860 for (
int i = 0; i < nDaughters; i++) {
1861 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1862 momentum += d.get4Vector();
1863 Particle* newDaughters = particles.appendNew(d);
1869 ASSERT_NE(var,
nullptr);
1870 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 2.0);
1873 TEST_F(MetaVariableTest, daughterHighest)
1875 PxPyPzEVector momentum;
1876 const int nDaughters = 4;
1878 std::vector<int> daughterIndices;
1879 for (
int i = 0; i < nDaughters; i++) {
1880 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? 213 : -213);
1881 momentum += d.get4Vector();
1882 Particle* newDaughters = particles.appendNew(d);
1888 ASSERT_NE(var,
nullptr);
1889 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 4.0);
1892 TEST_F(MetaVariableTest, daughterDiffOf)
1894 PxPyPzEVector momentum;
1895 const int nDaughters = 4;
1897 std::vector<int> daughterIndices;
1898 for (
int i = 0; i < nDaughters; i++) {
1899 Particle d(PxPyPzEVector(-1, 1.0 - 2 * (i % 2), 1, i * 1.0 + 2.0), (i % 2) ? -11 : 211);
1900 momentum += d.get4Vector();
1901 Particle* newDaughters = particles.appendNew(d);
1907 ASSERT_NE(var,
nullptr);
1908 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1911 ASSERT_NE(var,
nullptr);
1912 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1915 ASSERT_NE(var,
nullptr);
1916 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1919 ASSERT_NE(var,
nullptr);
1920 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1923 ASSERT_NE(var,
nullptr);
1924 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1927 ASSERT_NE(var,
nullptr);
1928 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1931 ASSERT_NE(var,
nullptr);
1932 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5707964);
1935 ASSERT_NE(var,
nullptr);
1936 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5004894);
1939 ASSERT_NE(var,
nullptr);
1940 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1944 TEST_F(MetaVariableTest, mcDaughterDiffOf)
1947 PxPyPzEVector momentum;
1948 const int nDaughters = 4;
1951 particles.registerRelationTo(mcParticles);
1952 std::vector<int> daughterIndices;
1955 for (
int i = 0; i < nDaughters; i++) {
1956 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
1957 momentum += d.get4Vector();
1958 Particle* newDaughters = particles.appendNew(d);
1960 auto* mcParticle = mcParticles.
appendNew();
1968 ASSERT_NE(var,
nullptr);
1969 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1972 ASSERT_NE(var,
nullptr);
1973 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1976 ASSERT_NE(var,
nullptr);
1977 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1980 ASSERT_NE(var,
nullptr);
1981 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1984 ASSERT_NE(var,
nullptr);
1985 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1988 ASSERT_NE(var,
nullptr);
1989 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1992 ASSERT_NE(var,
nullptr);
1993 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1998 TEST_F(MetaVariableTest, daughterClusterAngleInBetween)
2002 std::vector<int> daughterIndices, daughterIndices_noclst;
2008 particles.registerRelationTo(eclclusters);
2012 const float px_CM = 2.;
2013 const float py_CM = 1.;
2014 const float pz_CM = 3.;
2016 E_CM =
sqrt(pow(px_CM, 2) + pow(py_CM, 2) + pow(pz_CM, 2));
2017 PxPyPzEVector momentum, momentum_noclst;
2018 PxPyPzEVector dau0_4vec_CM(px_CM, py_CM, pz_CM, E_CM), dau1_4vec_CM(-px_CM, -py_CM, -pz_CM, E_CM);
2019 PxPyPzEVector dau0_4vec_Lab, dau1_4vec_Lab;
2025 Particle dau0_noclst(dau0_4vec_Lab, 22);
2026 momentum += dau0_noclst.get4Vector();
2027 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
2028 daughterIndices_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
2029 Particle dau1_noclst(dau1_4vec_Lab, 22);
2030 momentum += dau1_noclst.get4Vector();
2031 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
2032 daughterIndices_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
2040 ASSERT_NE(var,
nullptr);
2041 EXPECT_TRUE(std::isnan(std::get<double>(var->function(par_noclst))));
2046 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2048 eclst0->
setTheta(dau0_4vec_Lab.Theta());
2049 eclst0->
setPhi(dau0_4vec_Lab.Phi());
2050 eclst0->
setR(148.4);
2053 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2055 eclst1->
setTheta(dau1_4vec_Lab.Theta());
2056 eclst1->
setPhi(dau1_4vec_Lab.Phi());
2057 eclst1->
setR(148.5);
2059 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2061 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2067 EXPECT_FLOAT_EQ(std::get<double>(var->function(par)), 2.8613892);
2068 EXPECT_FLOAT_EQ(std::get<double>(varCMS->
function(par)), M_PI);
2071 TEST_F(MetaVariableTest, grandDaughterDiffOfs)
2075 std::vector<int> daughterIndices0_noclst, daughterIndices1_noclst, daughterIndices2_noclst;
2076 std::vector<int> daughterIndices0, daughterIndices1, daughterIndices2;
2082 particles.registerRelationTo(eclclusters);
2086 const float px_0 = 2.;
2087 const float py_0 = 1.;
2088 const float pz_0 = 3.;
2089 const float px_1 = 1.5;
2090 const float py_1 = 1.5;
2091 const float pz_1 = 2.5;
2093 E_0 =
sqrt(pow(px_0, 2) + pow(py_0, 2) + pow(pz_0, 2));
2094 E_1 =
sqrt(pow(px_1, 2) + pow(py_1, 2) + pow(pz_1, 2));
2095 PxPyPzEVector momentum_0, momentum_1, momentum;
2096 PxPyPzEVector dau0_4vec(px_0, py_0, pz_0, E_0), dau1_4vec(px_1, py_1, pz_1, E_1);
2109 Particle dau0_noclst(dau0_4vec, 22);
2110 momentum_0 = dau0_4vec;
2111 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
2112 daughterIndices0_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
2114 Particle dau1_noclst(dau1_4vec, 22);
2115 momentum_1 = dau1_4vec;
2116 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
2117 daughterIndices1_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
2120 momentum = momentum_0 + momentum_1;
2121 daughterIndices2_noclst.push_back(par0_noclst->
getArrayIndex());
2122 daughterIndices2_noclst.push_back(par1_noclst->
getArrayIndex());
2141 ASSERT_NE(var_ClusterPhi,
nullptr);
2142 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi->
function(parGranny_noclst))));
2143 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterTheta->
function(parGranny_noclst))));
2144 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE->
function(parGranny_noclst))));
2145 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny_noclst)), 0.32175055);
2146 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny_noclst)), 0.06311664);
2147 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny_noclst)), -0.46293807);
2148 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi_wrongIndexes->
function(parGranny_noclst))));
2149 EXPECT_TRUE(std::isnan(std::get<double>(var_Phi_wrongIndexes->
function(parGranny_noclst))));
2150 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE_wrongIndexes->
function(parGranny_noclst))));
2151 EXPECT_TRUE(std::isnan(std::get<double>(var_E_wrongIndexes->
function(parGranny_noclst))));
2156 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2158 eclst0->
setTheta(dau0_4vec.Theta());
2159 eclst0->
setPhi(dau0_4vec.Phi());
2160 eclst0->
setR(148.4);
2163 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2165 eclst1->
setTheta(dau1_4vec.Theta());
2166 eclst1->
setPhi(dau1_4vec.Phi());
2167 eclst1->
setR(148.5);
2169 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2173 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2183 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterPhi->
function(parGranny)), 0.32175055);
2184 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny)), 0.32175055);
2185 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterTheta->
function(parGranny)), 0.06311664);
2186 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny)), 0.06311664);
2187 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterE->
function(parGranny)), -0.46293831);
2188 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny)), -0.46293831);
2191 TEST_F(MetaVariableTest, daughterNormDiffOf)
2193 PxPyPzEVector momentum;
2194 const int nDaughters = 4;
2196 std::vector<int> daughterIndices;
2197 for (
int i = 0; i < nDaughters; i++) {
2198 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2199 momentum += d.get4Vector();
2200 Particle* newDaughters = particles.appendNew(d);
2206 ASSERT_NE(var,
nullptr);
2207 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222 / 200.);
2210 ASSERT_NE(var,
nullptr);
2211 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222 / 200.);
2214 ASSERT_NE(var,
nullptr);
2215 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200 / 222.);
2218 ASSERT_NE(var,
nullptr);
2219 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -0 / 22.);
2222 ASSERT_NE(var,
nullptr);
2223 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 22.);
2226 ASSERT_NE(var,
nullptr);
2227 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 422.);
2231 TEST_F(MetaVariableTest, daughterMotherDiffOf)
2233 PxPyPzEVector momentum;
2234 const int nDaughters = 4;
2236 std::vector<int> daughterIndices;
2237 for (
int i = 0; i < nDaughters; i++) {
2238 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2239 momentum += d.get4Vector();
2240 Particle* newDaughters = particles.appendNew(d);
2246 ASSERT_NE(var,
nullptr);
2247 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422);
2250 ASSERT_NE(var,
nullptr);
2251 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400);
2254 ASSERT_NE(var,
nullptr);
2255 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200);
2259 TEST_F(MetaVariableTest, daughterMotherNormDiffOf)
2261 PxPyPzEVector momentum;
2262 const int nDaughters = 4;
2264 std::vector<int> daughterIndices;
2265 for (
int i = 0; i < nDaughters; i++) {
2266 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2267 momentum += d.get4Vector();
2268 Particle* newDaughters = particles.appendNew(d);
2274 ASSERT_NE(var,
nullptr);
2275 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422 / 400.);
2278 ASSERT_NE(var,
nullptr);
2279 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400 / 422.);
2282 ASSERT_NE(var,
nullptr);
2283 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200 / 622.);
2287 TEST_F(MetaVariableTest, constant)
2291 ASSERT_NE(var,
nullptr);
2292 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 1.0);
2295 ASSERT_NE(var,
nullptr);
2296 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 0.0);
2300 TEST_F(MetaVariableTest, abs)
2302 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
2303 Particle p2({ -0.1, -0.4, 0.8, 4.0 }, -11);
2306 ASSERT_NE(var,
nullptr);
2307 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
2308 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 0.1);
2312 TEST_F(MetaVariableTest, sin)
2314 Particle p({ 3.14159265359 / 2.0, -0.4, 0.8, 1.0}, 11);
2315 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2318 ASSERT_NE(var,
nullptr);
2319 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
2320 EXPECT_NEAR(std::get<double>(var->function(&p2)), 0.0, 1e-6);
2324 TEST_F(MetaVariableTest, cos)
2326 Particle p({ 3.14159265359 / 2.0, -0.4, 0.8, 1.0}, 11);
2327 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2330 ASSERT_NE(var,
nullptr);
2331 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.0, 1e-6);
2332 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 1.0);
2336 TEST_F(MetaVariableTest, NBDeltaIfMissingDeathTest)
2343 TEST_F(MetaVariableTest, matchedMC)
2348 particles.registerRelationTo(mcParticles);
2351 auto* mcParticle = mcParticles.
appendNew();
2354 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2355 p1->addRelationTo(mcParticle);
2360 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2361 p2->addRelationTo(mcParticle);
2366 auto* p3 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2367 p3->addRelationTo(mcParticle);
2370 auto* p4 = particles.appendNew(mcParticle);
2373 ASSERT_NE(var,
nullptr);
2374 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -1);
2375 EXPECT_FLOAT_EQ(std::get<double>(var->function(p2)), 1);
2376 EXPECT_FLOAT_EQ(std::get<double>(var->function(p3)), 0);
2377 EXPECT_FLOAT_EQ(std::get<double>(var->function(p4)), 0);
2380 TEST_F(MetaVariableTest, countInList)
2387 outputList.registerInDataStore(flags);
2389 outputList.create();
2390 outputList->initialize(22,
"pList1");
2405 ASSERT_NE(var,
nullptr);
2406 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 2);
2409 ASSERT_NE(var,
nullptr);
2410 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2413 ASSERT_NE(var,
nullptr);
2414 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 0);
2417 ASSERT_NE(var,
nullptr);
2418 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2421 TEST_F(MetaVariableTest, isInList)
2430 gammalist.registerInDataStore(flags);
2433 gammalist->initialize(22,
"testGammaList");
2438 auto* inthelist = particles.appendNew(goingin);
2439 auto* notinthelist = particles.appendNew(notgoingin);
2449 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(notinthelist)));
2450 EXPECT_TRUE(std::get<bool>(vsensible->
function(inthelist)));
2451 EXPECT_FALSE(std::get<bool>(vsensible->
function(notinthelist)));
2455 TEST_F(MetaVariableTest, cutIsInList)
2461 const std::string listname {
"wil/d(-+)'':l*"};
2465 particlelist.registerInDataStore(flags);
2467 particlelist.create();
2468 particlelist->initialize(22, listname);
2472 auto* inthelist = particles.appendNew(goingin);
2473 auto* notinthelist = particles.appendNew(notgoingin);
2482 EXPECT_B2FATAL(std::get<bool>(nonexistlist->
function(inthelist)));
2483 EXPECT_FALSE(std::get<bool>(existlist->
function(notinthelist)));
2484 EXPECT_TRUE(std::get<bool>(existlist->
function(inthelist)));
2487 TEST_F(MetaVariableTest, sourceObjectIsInList)
2499 particles.registerInDataStore();
2501 gammalist.registerInDataStore(flags);
2508 gammalist->initialize(22,
"testGammaList");
2513 cl0->setEnergy(1.0);
2514 cl0->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2515 cl0->addHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2516 cl0->setClusterId(0);
2518 cl1->setEnergy(1.0);
2519 cl1->setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2520 cl1->setClusterId(1);
2528 auto* myphoton_ = particles.appendNew(myphoton);
2529 gammalist->addParticle(myphoton_);
2531 auto* iscopied = particles.appendNew(iscopiedin);
2532 auto* notcopied = particles.appendNew(notcopiedin);
2539 EXPECT_B2FATAL(std::get<int>(vnonsense->
function(iscopied)));
2540 EXPECT_EQ(std::get<int>(vsensible->
function(iscopied)), 1);
2541 EXPECT_EQ(std::get<int>(vsensible->
function(notcopied)), 0);
2546 auto* composite_ = particles.appendNew(undefined);
2547 auto* undefined_ = particles.appendNew(composite);
2548 EXPECT_EQ(std::get<int>(vsensible->
function(composite_)), -1);
2549 EXPECT_EQ(std::get<int>(vsensible->
function(undefined_)), -1);
2552 TEST_F(MetaVariableTest, mcParticleIsInMCList)
2565 particles.registerInDataStore();
2566 particles.registerRelationTo(mcparticles);
2568 list.registerInDataStore(flags);
2569 anotherlist.registerInDataStore(flags);
2575 list->initialize(22,
"testList");
2577 anotherlist.create();
2578 anotherlist->initialize(22,
"supplimentaryList");
2581 auto* mcphoton = mcparticles.
appendNew();
2585 auto* mcelectron = mcparticles.
appendNew();
2589 auto* mcanotherelectron = mcparticles.
appendNew();
2593 auto* mcyetanotherelectron = mcparticles.
appendNew();
2598 auto* photon = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2599 photon->addRelationTo(mcphoton);
2600 list->addParticle(photon);
2602 auto* electron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2603 electron->addRelationTo(mcelectron);
2604 list->addParticle(electron);
2606 auto* other = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2607 other->addRelationTo(mcanotherelectron);
2609 auto* yetanotherelectron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2610 yetanotherelectron->addRelationTo(mcyetanotherelectron);
2611 anotherlist->addParticle(yetanotherelectron);
2619 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(photon)));
2620 EXPECT_TRUE(std::get<bool>(vsensible->
function(photon)));
2621 EXPECT_TRUE(std::get<bool>(vsensible->
function(electron)));
2622 EXPECT_FALSE(std::get<bool>(vsensible->
function(other)));
2623 EXPECT_FALSE(std::get<bool>(vsensible->
function(yetanotherelectron)));
2628 auto* composite_ = particles.appendNew(undefined);
2629 auto* undefined_ = particles.appendNew(composite);
2630 EXPECT_FALSE(std::get<bool>(vsensible->
function(composite_)));
2631 EXPECT_FALSE(std::get<bool>(vsensible->
function(undefined_)));
2634 TEST_F(MetaVariableTest, mostB2BAndClosestParticles)
2644 gearbox.setBackends({std::string(
"file:")});
2646 gearbox.open(
"geometry/Belle2.xml",
false);
2656 gammalist.registerInDataStore(flags);
2657 emptylist.registerInDataStore(flags);
2660 gammalist->initialize(22,
"testGammaList");
2662 emptylist->initialize(22,
"testEmptyList");
2665 std::vector<Particle> gammavector = {
2672 for (
const auto& g : gammavector)
2673 particles.appendNew(g);
2676 for (
size_t i = 0; i < gammavector.size(); i++)
2680 const auto* electron = particles.appendNew(
2690 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2693 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2696 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 0.68014491);
2699 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 0.67901474);
2707 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2710 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2713 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 3.4);
2716 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 3.2732551);
2719 EXPECT_FLOAT_EQ(std::get<double>(closestCMSLabE->function(electron)), 3.4);
2727 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2730 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2733 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 2.2869499);
2736 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 2.8312778);
2744 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2747 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2750 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 1.7);
2753 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 1.5848758);
2756 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMSLabE->function(electron)), 1.7);
2760 TEST_F(MetaVariableTest, totalEnergyOfParticlesInList)
2769 gammalist.registerInDataStore(flags);
2772 gammalist->initialize(22,
"testGammaList");
2775 std::vector<Particle> gammavector = {
2784 for (
const auto& g : gammavector)
2785 particles.appendNew(g);
2788 for (
size_t i = 0; i < gammavector.size(); i++)
2793 "totalEnergyOfParticlesInList(NONEXISTANTLIST)");
2795 "totalEnergyOfParticlesInList(testGammaList)");
2798 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2799 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 4.3);
2801 TEST_F(MetaVariableTest, totalPxOfParticlesInList)
2810 gammalist.registerInDataStore(flags);
2813 gammalist->initialize(22,
"testGammaList");
2816 std::vector<Particle> gammavector = {
2825 for (
const auto& g : gammavector)
2826 particles.appendNew(g);
2829 for (
size_t i = 0; i < gammavector.size(); i++)
2834 "totalPxOfParticlesInList(NONEXISTANTLIST)");
2836 "totalPxOfParticlesInList(testGammaList)");
2839 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2840 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 2.2);
2842 TEST_F(MetaVariableTest, totalPyOfParticlesInList)
2851 gammalist.registerInDataStore(flags);
2854 gammalist->initialize(22,
"testGammaList");
2857 std::vector<Particle> gammavector = {
2866 for (
const auto& g : gammavector)
2867 particles.appendNew(g);
2870 for (
size_t i = 0; i < gammavector.size(); i++)
2875 "totalPyOfParticlesInList(NONEXISTANTLIST)");
2877 "totalPyOfParticlesInList(testGammaList)");
2880 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2881 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 1.5);
2883 TEST_F(MetaVariableTest, totalPzOfParticlesInList)
2892 gammalist.registerInDataStore(flags);
2895 gammalist->initialize(22,
"testGammaList");
2898 std::vector<Particle> gammavector = {
2907 for (
const auto& g : gammavector)
2908 particles.appendNew(g);
2911 for (
size_t i = 0; i < gammavector.size(); i++)
2916 "totalPzOfParticlesInList(NONEXISTANTLIST)");
2918 "totalPzOfParticlesInList(testGammaList)");
2921 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2922 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 3.1);
2924 TEST_F(MetaVariableTest, maxPtInList)
2933 gammalist.registerInDataStore(flags);
2936 gammalist->initialize(22,
"testGammaList");
2939 std::vector<Particle> gammavector = {
2948 for (
const auto& g : gammavector)
2949 particles.appendNew(g);
2952 for (
size_t i = 0; i < gammavector.size(); i++)
2957 "maxPtInList(NONEXISTANTLIST)");
2959 "maxPtInList(testGammaList)");
2962 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2963 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)),
sqrt(0.5 * 0.5 + 0.4 * 0.4));
2967 TEST_F(MetaVariableTest, numberOfNonOverlappingParticles)
2974 outputList.registerInDataStore(flags);
2976 outputList.create();
2977 outputList->initialize(22,
"pList1");
2987 ASSERT_NE(var,
nullptr);
2988 EXPECT_EQ(std::get<int>(var->function(p1)), 1);
2989 EXPECT_EQ(std::get<int>(var->function(p2)), 1);
2990 EXPECT_EQ(std::get<int>(var->function(p3)), 2);
2994 TEST_F(MetaVariableTest, veto)
2999 const Particle* p = particles.appendNew(
Particle({0.8, 0.8, 1.131370849898476039041351, 1.6}, 22,
3004 outputList.registerInDataStore(flags);
3006 outputList.create();
3007 outputList->initialize(22,
"pList1");
3009 particles.appendNew(
Particle({0.5, 0.4953406774856531014212777, 0.5609256753154148484773173, 0.9}, 22,
3024 outputList2.registerInDataStore(flags);
3026 outputList2.create();
3027 outputList2->initialize(22,
"pList2");
3042 ASSERT_NE(var,
nullptr);
3043 EXPECT_TRUE(std::get<bool>(var->function(p)));
3046 ASSERT_NE(var,
nullptr);
3047 EXPECT_FALSE(std::get<bool>(var->function(p)));
3051 TEST_F(MetaVariableTest, averageValueInList)
3060 gammalist.registerInDataStore(flags);
3063 gammalist->initialize(22,
"testGammaList");
3066 std::vector<Particle> gammavector = {
3075 for (
const auto& g : gammavector)
3076 particles.appendNew(g);
3079 for (
size_t i = 0; i < gammavector.size(); i++)
3084 "averageValueInList(testGammaList, px)");
3086 "averageValueInList(testGammaList, py)");
3088 "averageValueInList(testGammaList, pz)");
3090 "averageValueInList(testGammaList, E)");
3092 EXPECT_FLOAT_EQ(std::get<double>(vmeanpx->
function(
nullptr)), 0.44);
3093 EXPECT_FLOAT_EQ(std::get<double>(vmeanpy->
function(
nullptr)), 0.3);
3094 EXPECT_FLOAT_EQ(std::get<double>(vmeanpz->
function(
nullptr)), 0.6);
3095 EXPECT_FLOAT_EQ(std::get<double>(vmeanE->
function(
nullptr)), 0.86);
3098 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"averageValueInList(testGammaList)"));
3101 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"averageValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3105 "averageValueInList(NONEXISTANTLIST, px)");
3107 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3110 TEST_F(MetaVariableTest, medianValueInList)
3119 oddgammalist.registerInDataStore(flags);
3121 oddgammalist.create();
3122 oddgammalist->initialize(22,
"oddGammaList");
3125 evengammalist.registerInDataStore(flags);
3127 evengammalist.create();
3128 evengammalist->initialize(22,
"evenGammaList");
3131 std::vector<Particle> gammavector = {
3140 for (
const auto& g : gammavector)
3141 particles.appendNew(g);
3145 for (
size_t i = 1; i < gammavector.size(); i++) {
3152 "medianValueInList(oddGammaList, px)");
3154 "medianValueInList(oddGammaList, py)");
3156 "medianValueInList(oddGammaList, pz)");
3158 "medianValueInList(oddGammaList, E)");
3160 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpx->
function(
nullptr)), 0.5);
3161 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpy->
function(
nullptr)), 0.3);
3162 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpz->
function(
nullptr)), 0.7);
3163 EXPECT_FLOAT_EQ(std::get<double>(voddmedianE->
function(
nullptr)), 0.9);
3167 "medianValueInList(evenGammaList, px)");
3169 "medianValueInList(evenGammaList, py)");
3171 "medianValueInList(evenGammaList, pz)");
3173 "medianValueInList(evenGammaList, E)");
3175 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpx->
function(
nullptr)), 0.45);
3176 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpy->
function(
nullptr)), 0.25);
3177 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpz->
function(
nullptr)), 0.7);
3178 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianE->
function(
nullptr)), 0.9);
3181 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"medianValueInList(oddGammaList)"));
3184 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"medianValueInList(oddGammaList, NONEXISTANTVARIABLE)"));
3188 "medianValueInList(NONEXISTANTLIST, px)");
3190 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3193 TEST_F(MetaVariableTest, productValueInList)
3202 gammalist.registerInDataStore(flags);
3205 gammalist->initialize(22,
"testGammaList");
3208 std::vector<Particle> gammavector = {
3217 for (
const auto& g : gammavector)
3218 particles.appendNew(g);
3221 for (
size_t i = 0; i < gammavector.size(); i++)
3226 "productValueInList(testGammaList, px)");
3228 "productValueInList(testGammaList, py)");
3230 "productValueInList(testGammaList, pz)");
3232 "productValueInList(testGammaList, E)");
3234 EXPECT_FLOAT_EQ(std::get<double>(vproductpx->
function(
nullptr)), 0.015);
3235 EXPECT_FLOAT_EQ(std::get<double>(vproductpy->
function(
nullptr)), 0.00192);
3236 EXPECT_FLOAT_EQ(std::get<double>(vproductpz->
function(
nullptr)), 0.06272);
3237 EXPECT_FLOAT_EQ(std::get<double>(vproductE->
function(
nullptr)), 0.42768);
3240 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"productValueInList(testGammaList)"));
3243 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"productValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3247 "productValueInList(NONEXISTANTLIST, px)");
3249 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3252 TEST_F(MetaVariableTest, sumValueInList)
3261 gammalist.registerInDataStore(flags);
3264 gammalist->initialize(22,
"testGammaList");
3267 std::vector<Particle> gammavector = {
3276 for (
const auto& g : gammavector)
3277 particles.appendNew(g);
3280 for (
size_t i = 0; i < gammavector.size(); i++)
3285 "sumValueInList(testGammaList, px)");
3287 "sumValueInList(testGammaList, py)");
3289 "sumValueInList(testGammaList, pz)");
3291 "sumValueInList(testGammaList, E)");
3293 EXPECT_FLOAT_EQ(std::get<double>(vsumpx->
function(
nullptr)), 2.2);
3294 EXPECT_FLOAT_EQ(std::get<double>(vsumpy->
function(
nullptr)), 1.5);
3295 EXPECT_FLOAT_EQ(std::get<double>(vsumpz->
function(
nullptr)), 3.0);
3296 EXPECT_FLOAT_EQ(std::get<double>(vsumE->
function(
nullptr)), 4.3);
3299 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"sumValueInList(testGammaList)"));
3302 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"sumValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3306 "sumValueInList(NONEXISTANTLIST, px)");
3308 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3311 TEST_F(MetaVariableTest, pValueCombination)
3313 PxPyPzEVector momentum;
3315 std::vector<int> daughterIndices;
3318 momentum += KS.get4Vector();
3319 Particle* newDaughters = particles.appendNew(KS);
3322 Jpsi.setPValue(0.9);
3323 momentum += Jpsi.get4Vector();
3324 newDaughters = particles.appendNew(Jpsi);
3330 ASSERT_NE(singlePvalue,
nullptr);
3331 EXPECT_FLOAT_EQ(std::get<double>(singlePvalue->
function(B)), 0.5);
3334 ASSERT_NE(twoPvalues,
nullptr);
3335 EXPECT_FLOAT_EQ(std::get<double>(twoPvalues->
function(B)), 0.05 * (1 - log(0.05)));
3339 ASSERT_NE(threePvalues,
nullptr);
3340 EXPECT_FLOAT_EQ(std::get<double>(threePvalues->
function(B)), 0.045 * (1 - log(0.045) + 0.5 * log(0.045) * log(0.045)));
3346 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"pValueCombination(chiProb, NONEXISTANTVARIABLE)"));
3350 TEST_F(MetaVariableTest, daughterCombinationOneGeneration)
3352 const int nDaughters = 5;
3353 PxPyPzEVector momentum(0, 0, 0, 0);
3355 std::vector<int> daughterIndices;
3356 std::vector<PxPyPzEVector> daughterMomenta;
3358 for (
int i = 0; i < nDaughters; i++) {
3359 PxPyPzEVector mom(1, i * 0.5, 1, i * 1.0 + 2.0);
3360 Particle d(mom, (i % 2) ? 111 : 113);
3361 Particle* newDaughters = particles.appendNew(d);
3363 daughterMomenta.push_back(mom);
3364 momentum = momentum + mom;
3370 double M_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[2]).mag();
3371 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3374 M_test = (daughterMomenta[0] + daughterMomenta[4]).mag();
3375 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3380 double p_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[4]).P();
3381 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), p_test);
3385 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"daughterCombination(aVeryNonExistingVariableSillyName, 1, 0, 4)"));
3388 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3389 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3393 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3394 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3398 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3399 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3404 TEST_F(MetaVariableTest, daughterCombinationTwoGenerations)
3410 PxPyPzEVector momentum_1(0, 0, 0, 0);
3411 std::vector<PxPyPzEVector> daughterMomenta_1;
3412 std::vector<int> daughterIndices_1;
3414 for (
int i = 0; i < 3; i++) {
3415 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3416 Particle d(mom, (i % 2) ? 111 : 113);
3417 Particle* newDaughters = particles.appendNew(d);
3419 daughterMomenta_1.push_back(mom);
3420 momentum_1 = momentum_1 + mom;
3428 PxPyPzEVector momentum_2(0, 0, 0, 0);
3429 std::vector<PxPyPzEVector> daughterMomenta_2;
3430 std::vector<int> daughterIndices_2;
3432 for (
int i = 0; i < 2; i++) {
3433 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3434 Particle d(mom, (i % 2) ? 111 : 113);
3435 Particle* newDaughters = particles.appendNew(d);
3437 daughterMomenta_2.push_back(mom);
3438 momentum_2 = momentum_2 + mom;
3452 double M_test = (momentum_1 + momentum_2).mag();
3453 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3457 M_test = (momentum_1).mag();
3458 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3462 M_test = (daughterMomenta_1[0] + daughterMomenta_1[1] + daughterMomenta_2[0]).mag();
3463 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3468 TEST_F(MetaVariableTest, useAlternativeDaughterHypothesis)
3470 const int nDaughters = 5;
3474 PxPyPzEVector momentum(0, 0, 0, 0);
3475 std::vector<int> daughterIndices;
3476 for (
int i = 0; i < nDaughters; i++) {
3477 double px = i * 0.1;
3478 double py = i * 0.3;
3479 double pz = -i * 0.1 - 0.2;
3481 PxPyPzEVector mom(px, py, pz, 1);
3485 d.updateMass(pdgCode);
3486 mom = d.get4Vector();
3488 Particle* daughters = particles.appendNew(d);
3490 momentum = momentum + mom;
3496 PxPyPzEVector momentumAlt(0, 0, 0, 0);
3497 std::vector<int> daughterIndicesAlt;
3498 for (
int i = 0; i < nDaughters; i++) {
3499 double px = i * 0.1;
3500 double py = i * 0.3;
3501 double pz = -i * 0.1 - 0.2;
3503 PxPyPzEVector mom(px, py, pz, 1);
3511 d.updateMass(pdgCode);
3512 mom = d.get4Vector();
3514 Particle* daughters = particles.appendNew(d);
3516 momentumAlt = momentumAlt + mom;
3522 std::cout <<
"mass test" << std::endl;
3525 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3528 std::cout <<
"charge test" << std::endl;
3530 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3533 std::cout <<
"momentum test" << std::endl;
3536 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3537 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(p)));
3538 EXPECT_FLOAT_EQ(std::get<double>(var->function(pAlt)), std::get<double>(varAlt->
function(pAlt)));
3544 TEST_F(MetaVariableTest, daughterAngle)
3550 PxPyPzEVector momentum_1(0, 0, 0, 0);
3551 std::vector<PxPyPzEVector> daughterMomenta_1;
3552 std::vector<int> daughterIndices_1;
3554 for (
int i = 0; i < 3; i++) {
3555 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3556 Particle d(mom, (i % 2) ? -11 : 211);
3557 Particle* newDaughters = particles.appendNew(d);
3559 daughterMomenta_1.push_back(mom);
3560 momentum_1 = momentum_1 + mom;
3568 PxPyPzEVector momentum_2(0, 0, 0, 0);
3569 std::vector<PxPyPzEVector> daughterMomenta_2;
3570 std::vector<int> daughterIndices_2;
3572 for (
int i = 0; i < 2; i++) {
3573 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3574 Particle d(mom, (i % 2) ? -11 : 211);
3575 Particle* newDaughters = particles.appendNew(d);
3577 daughterMomenta_2.push_back(mom);
3578 momentum_2 = momentum_2 + mom;
3591 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3593 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3597 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3598 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3601 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3602 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3605 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3606 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3610 TEST_F(MetaVariableTest, mcDaughterVariables)
3616 particles.registerRelationTo(mcParticles);
3620 PxPyPzEVector momentum_1(0, 0, 0, 0);
3621 std::vector<PxPyPzEVector> daughterMomenta_1;
3622 std::vector<int> daughterIndices_1;
3624 for (
int i = 0; i < 3; i++) {
3625 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3626 Particle d(mom, (i % 2) ? -11 : 211);
3627 Particle* newDaughters = particles.appendNew(d);
3629 daughterMomenta_1.push_back(mom);
3630 momentum_1 = momentum_1 + mom;
3632 auto* mcParticle = mcParticles.
appendNew();
3640 auto* mcCompositeDau_1 = mcParticles.
appendNew();
3641 mcCompositeDau_1->setPDG(411);
3643 mcCompositeDau_1->set4Vector(momentum_1);
3648 PxPyPzEVector momentum_2(0, 0, 0, 0);
3649 std::vector<PxPyPzEVector> daughterMomenta_2;
3650 std::vector<int> daughterIndices_2;
3652 for (
int i = 0; i < 2; i++) {
3653 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3654 Particle d(mom, (i % 2) ? -11 : 211);
3655 Particle* newDaughters = particles.appendNew(d);
3657 daughterMomenta_2.push_back(mom);
3658 momentum_2 = momentum_2 + mom;
3660 auto* mcParticle = mcParticles.
appendNew();
3668 auto* mcCompositeDau_2 = mcParticles.
appendNew();
3669 mcCompositeDau_2->setPDG(411);
3671 mcCompositeDau_2->set4Vector(momentum_2);
3681 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3682 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3685 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3686 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3689 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3690 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3693 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3694 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3698 ASSERT_NE(var,
nullptr);
3699 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
3702 ASSERT_NE(var,
nullptr);
3703 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3707 ASSERT_NE(var,
nullptr);
3708 v_test = momentum_2.Phi() - momentum_1.Phi();
3709 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3713 TEST_F(MetaVariableTest, varForFirstMCAncestorOfType)
3718 particles.registerInDataStore();
3720 particles.registerRelationTo(mcParticles);
3722 DList.registerInDataStore();
3724 DList->initialize(421,
"D0:vartest");
3726 PxPyPzEVector momentum;
3727 PxPyPzEVector momentum_0;
3728 PxPyPzEVector momentum_1;
3729 std::vector<int> D_daughterIndices;
3730 std::vector<int> D_grandDaughterIndices_0;
3731 std::vector<int> D_grandDaughterIndices_1;
3749 mcg_d_0.
set4Vector(PxPyPzEVector(6, 6, 6, 6));
3751 mcg_d_1.
set4Vector(PxPyPzEVector(5, 5, 5, 5));
3753 mcg_gd_0_0.
set4Vector(PxPyPzEVector(4, 4, 4, 4));
3755 mcg_gd_0_1.
set4Vector(PxPyPzEVector(3, 3, 3, 3));
3757 mcg_gd_1_0.
set4Vector(PxPyPzEVector(2, 1, 2, 2));
3759 mcg_gd_1_1.
set4Vector(PxPyPzEVector(1, 1, 1, 1));
3761 mcg_not_child.
set4Vector(PxPyPzEVector(10, 10, 10, 10));
3773 auto* mc_not_child = mcParticles[0];
3774 auto* mc_m = mcParticles[1];
3775 auto* mc_d_0 = mcParticles[2];
3776 auto* mc_d_1 = mcParticles[3];
3777 auto* mc_gd_0_0 = mcParticles[4];
3778 auto* mc_gd_0_1 = mcParticles[5];
3779 auto* mc_gd_1_0 = mcParticles[6];
3780 auto* mc_gd_1_1 = mcParticles[7];
3794 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
3795 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
3796 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
3797 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
3799 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3800 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3801 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3802 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3816 DList->addParticle(D_m);
3819 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
3822 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
3836 ASSERT_NE(var_d,
nullptr);
3837 EXPECT_TRUE(std::get<double>(var_d->
function(D_gd_0_0)) >= 0);
3838 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_0_1)));
3839 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_1_0)), std::get<double>(var_d->
function(D_gd_1_1)));
3840 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_1_0)));
3841 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_1)), std::get<double>(var_d->
function(D_gd_1_1)));
3842 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child))));
3843 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child_2))));
3848 ASSERT_NE(var_310,
nullptr);
3849 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_0_1)));
3850 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_1_0)), std::get<double>(var_310->
function(D_gd_1_1)));
3851 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_1_0)));
3852 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_1)), std::get<double>(var_310->
function(D_gd_1_1)));
3853 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child))));
3854 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child_2))));
3855 EXPECT_FLOAT_EQ(
int(std::get<double>(
Manager::Instance().getVariable(
"varForFirstMCAncestorOfType(310, E)")->function(D_gd_0_0))),
3859 TEST_F(MetaVariableTest, isDescendantOfList)
3863 DList.registerInDataStore();
3865 DList->initialize(421,
"D0:vartest");
3867 BList.registerInDataStore();
3869 BList->initialize(521,
"B:vartest");
3872 PxPyPzEVector momentum;
3873 PxPyPzEVector momentum_0;
3874 PxPyPzEVector momentum_1;
3876 std::vector<int> D_daughterIndices;
3877 std::vector<int> D_grandDaughterIndices_0;
3878 std::vector<int> D_grandDaughterIndices_1;
3879 std::vector<int> B_daughterIndices;
3880 std::vector<int> B_grandDaughterIndices;
3881 std::vector<int> B_grandGrandDaughterIndices;
3890 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3891 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3892 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3893 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3907 DList->addParticle(D_m);
3916 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_0->
getArrayIndex());
3917 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_1->
getArrayIndex());
3921 B_grandDaughterIndices.push_back(B_gd_0_0->
getArrayIndex());
3922 B_grandDaughterIndices.push_back(B_gd_0_1->
getArrayIndex());
3930 BList->addParticle(B_m);
3937 ASSERT_NE(var_0,
nullptr);
3938 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_0)));
3939 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_1)));
3940 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_0)));
3941 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_1)));
3942 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_0)));
3943 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_1)));
3944 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_0)));
3945 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_1)));
3946 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_0)));
3947 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_1)));
3948 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_0)));
3949 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_1)));
3950 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
3953 ASSERT_NE(var_0a,
nullptr);
3954 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_0)));
3955 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_1)));
3956 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_0)));
3957 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_1)));
3958 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_0)));
3959 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_1)));
3960 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_0)));
3961 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_1)));
3962 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_0)));
3963 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_1)));
3964 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_0)));
3965 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_1)));
3966 EXPECT_FALSE(std::get<bool>(var_0a->
function(not_child)));
3969 ASSERT_NE(var_0b,
nullptr);
3970 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_0)));
3971 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_1)));
3972 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_0)));
3973 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_1)));
3974 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_0)));
3975 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_1)));
3976 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_0)));
3977 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_1)));
3978 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_0)));
3979 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_1)));
3980 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_0)));
3981 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_1)));
3982 EXPECT_FALSE(std::get<bool>(var_0b->
function(not_child)));
3985 ASSERT_NE(var_1,
nullptr);
3986 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
3987 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
3988 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
3989 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
3990 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_0)));
3991 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_1)));
3992 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_0)));
3993 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_1)));
3994 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_0)));
3995 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_1)));
3996 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_0)));
3997 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_1)));
3998 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
4001 ASSERT_NE(var_2,
nullptr);
4002 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_0)));
4003 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_1)));
4004 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_0)));
4005 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_1)));
4006 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
4007 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
4008 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_0)));
4009 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_1)));
4010 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_0)));
4011 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_1)));
4012 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_0)));
4013 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_1)));
4014 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
4017 ASSERT_NE(var_3,
nullptr);
4018 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_0)));
4019 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_1)));
4020 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_0)));
4021 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_1)));
4022 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_0)));
4023 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_1)));
4024 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_0)));
4025 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_1)));
4026 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_0)));
4027 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_1)));
4028 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_0)));
4029 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_1)));
4030 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
4033 ASSERT_NE(var_4,
nullptr);
4034 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_0)));
4035 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_1)));
4036 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_0)));
4037 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_1)));
4038 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_0)));
4039 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_1)));
4040 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_0)));
4041 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_1)));
4042 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_0)));
4043 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_1)));
4044 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_0)));
4045 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_1)));
4046 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
4049 ASSERT_NE(var_5,
nullptr);
4050 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
4051 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
4052 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
4053 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
4054 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_0)));
4055 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_1)));
4056 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_0)));
4057 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_1)));
4058 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_0)));
4059 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_1)));
4060 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_0)));
4061 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_1)));
4062 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
4065 ASSERT_NE(var_6,
nullptr);
4066 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_0)));
4067 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_1)));
4068 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_0)));
4069 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_1)));
4070 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_0)));
4071 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_1)));
4072 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_0)));
4073 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_1)));
4074 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_0)));
4075 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_1)));
4076 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_0)));
4077 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_1)));
4078 EXPECT_FALSE(std::get<bool>(var_6->
function(not_child)));
4081 ASSERT_NE(var_7,
nullptr);
4082 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_0)));
4083 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_1)));
4084 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_0)));
4085 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_1)));
4086 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_0)));
4087 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_1)));
4088 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_0)));
4089 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_1)));
4090 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_0)));
4091 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_1)));
4092 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_0)));
4093 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_1)));
4094 EXPECT_FALSE(std::get<bool>(var_7->
function(not_child)));
4098 TEST_F(MetaVariableTest, isMCDescendantOfList)
4103 particles.registerInDataStore();
4105 particles.registerRelationTo(mcParticles);
4107 BList.registerInDataStore();
4109 BList->initialize(521,
"B:vartest");
4111 DList.registerInDataStore();
4113 DList->initialize(421,
"D0:vartest");
4115 PxPyPzEVector momentum;
4116 PxPyPzEVector momentum_0;
4117 PxPyPzEVector momentum_1;
4118 std::vector<int> daughterIndices;
4119 std::vector<int> grandDaughterIndices;
4120 std::vector<int> grandGrandDaughterIndices;
4121 std::vector<int> D_daughterIndices;
4122 std::vector<int> D_grandDaughterIndices_0;
4123 std::vector<int> D_grandDaughterIndices_1;
4157 auto* mc_m = mcParticles[0];
4158 auto* mc_d_0 = mcParticles[1];
4159 auto* mc_d_1 = mcParticles[2];
4160 auto* mc_gd_0_0 = mcParticles[3];
4161 auto* mc_gd_0_1 = mcParticles[4];
4162 auto* mc_ggd_0_0_0 = mcParticles[5];
4163 auto* mc_ggd_0_0_1 = mcParticles[6];
4164 auto* mc_not_child = mcParticles[7];
4177 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4178 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4179 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4180 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4182 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
4183 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
4184 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
4185 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
4199 DList->addParticle(D_m);
4202 const Particle* d_1 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4203 const Particle* gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4204 const Particle* ggd_0_0_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4205 const Particle* ggd_0_0_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4207 grandGrandDaughterIndices.push_back(ggd_0_0_0->
getArrayIndex());
4208 grandGrandDaughterIndices.push_back(ggd_0_0_1->
getArrayIndex());
4221 BList->addParticle(m);
4224 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
4227 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
4235 m->addRelationTo(mc_m);
4239 ASSERT_NE(var_0,
nullptr);
4240 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_0)));
4241 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_1)));
4242 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_0)));
4243 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_1)));
4244 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_0)));
4245 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_1)));
4246 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_0)));
4247 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_1)));
4248 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_0)));
4249 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_1)));
4250 EXPECT_TRUE(std::get<bool>(var_0->
function(d_0)));
4251 EXPECT_TRUE(std::get<bool>(var_0->
function(d_1)));
4252 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
4253 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child_2)));
4256 ASSERT_NE(var_1,
nullptr);
4257 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
4258 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
4259 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
4260 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
4261 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_0)));
4262 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_1)));
4263 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_0)));
4264 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_1)));
4265 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_0)));
4266 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_1)));
4267 EXPECT_TRUE(std::get<bool>(var_1->
function(d_0)));
4268 EXPECT_TRUE(std::get<bool>(var_1->
function(d_1)));
4269 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
4270 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child_2)));
4273 ASSERT_NE(var_2,
nullptr);
4274 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_0)));
4275 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_1)));
4276 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_0)));
4277 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_1)));
4278 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
4279 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
4280 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_0)));
4281 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_1)));
4282 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_0)));
4283 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_1)));
4284 EXPECT_TRUE(std::get<bool>(var_2->
function(d_0)));
4285 EXPECT_TRUE(std::get<bool>(var_2->
function(d_1)));
4286 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
4287 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child_2)));
4290 ASSERT_NE(var_3,
nullptr);
4291 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_0)));
4292 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_1)));
4293 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_0)));
4294 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_1)));
4295 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_0)));
4296 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_1)));
4297 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_0)));
4298 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_1)));
4299 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_0)));
4300 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_1)));
4301 EXPECT_TRUE(std::get<bool>(var_3->
function(d_0)));
4302 EXPECT_TRUE(std::get<bool>(var_3->
function(d_1)));
4303 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
4304 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child_2)));
4307 ASSERT_NE(var_4,
nullptr);
4308 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_0)));
4309 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_1)));
4310 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_0)));
4311 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_1)));
4312 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_0)));
4313 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_1)));
4314 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_0)));
4315 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_1)));
4316 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_0)));
4317 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_1)));
4318 EXPECT_FALSE(std::get<bool>(var_4->
function(d_0)));
4319 EXPECT_FALSE(std::get<bool>(var_4->
function(d_1)));
4320 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
4321 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child_2)));
4325 ASSERT_NE(var_5,
nullptr);
4326 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
4327 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
4328 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
4329 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
4330 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_0)));
4331 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_1)));
4332 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_0)));
4333 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_1)));
4334 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_0)));
4335 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_1)));
4336 EXPECT_FALSE(std::get<bool>(var_5->
function(d_0)));
4337 EXPECT_FALSE(std::get<bool>(var_5->
function(d_1)));
4338 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
4339 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child_2)));
4346 class PIDVariableTest :
public ::testing::Test {
4349 void SetUp()
override
4362 particles.registerInDataStore();
4363 tracks.registerInDataStore();
4364 particles.registerRelationTo(likelihood);
4365 tracks.registerRelationTo(likelihood);
4370 void TearDown()
override
4376 TEST_F(PIDVariableTest, LogLikelihood)
4385 const float pValue = 0.5;
4386 const float bField = 1.5;
4388 TMatrixDSym cov6(6);
4390 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4391 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4392 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4394 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4395 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4397 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4401 Track* allTrack = tracks.appendNew(mytrack);
4402 Track* noSVDTrack = tracks.appendNew(mytrack);
4403 Track* noPIDTrack = tracks.appendNew(mytrack);
4404 Track* dEdxTrack = tracks.appendNew(mytrack);
4417 lAll->setLogLikelihood(Const::TOP,
Const::muon, 0.5);
4418 lAll->setLogLikelihood(Const::ARICH,
Const::muon, 0.52);
4419 lAll->setLogLikelihood(Const::ECL,
Const::muon, 0.54);
4420 lAll->setLogLikelihood(Const::CDC,
Const::muon, 0.56);
4421 lAll->setLogLikelihood(Const::SVD,
Const::muon, 0.58);
4422 lAll->setLogLikelihood(Const::KLM,
Const::muon, 0.8);
4424 lAll->setLogLikelihood(Const::TOP,
Const::pion, 0.2);
4425 lAll->setLogLikelihood(Const::ARICH,
Const::pion, 0.22);
4426 lAll->setLogLikelihood(Const::ECL,
Const::pion, 0.24);
4427 lAll->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4428 lAll->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4429 lAll->setLogLikelihood(Const::KLM,
Const::pion, 0.2);
4431 lAll->setLogLikelihood(Const::TOP,
Const::kaon, 0.3);
4432 lAll->setLogLikelihood(Const::ARICH,
Const::kaon, 0.32);
4433 lAll->setLogLikelihood(Const::ECL,
Const::kaon, 0.34);
4434 lAll->setLogLikelihood(Const::CDC,
Const::kaon, 0.36);
4435 lAll->setLogLikelihood(Const::SVD,
Const::kaon, 0.38);
4436 lAll->setLogLikelihood(Const::KLM,
Const::kaon, 0.2);
4453 auto* lAllNoSVD = likelihood.
appendNew();
4457 if (det != Const::SVD) {
4458 lAllNoSVD->setLogLikelihood(det, hypo, lAll->getLogL(hypo, det));
4468 ldEdx->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4469 ldEdx->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4471 ldEdx->setLogLikelihood(Const::CDC,
Const::kaon, 0.36);
4472 ldEdx->setLogLikelihood(Const::SVD,
Const::kaon, 0.38);
4477 ldEdx->setLogLikelihood(Const::CDC,
Const::muon, 0.56);
4478 ldEdx->setLogLikelihood(Const::SVD,
Const::muon, 0.58);
4496 auto* particleAll = particles.appendNew(allTrack,
Const::pion);
4497 auto* particleNoSVD = particles.appendNew(noSVDTrack,
Const::pion);
4498 auto* particledEdx = particles.appendNew(dEdxTrack,
Const::pion);
4499 auto* particleNoID = particles.appendNew(noPIDTrack,
Const::pion);
4501 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);
4502 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);
4505 EXPECT_FLOAT_EQ(electronID(particleAll), std::exp(0.71) / numsumexp);
4506 EXPECT_FLOAT_EQ(muonID(particleAll), std::exp(3.5) / numsumexp);
4507 EXPECT_FLOAT_EQ(pionID(particleAll), std::exp(1.4) / numsumexp);
4508 EXPECT_FLOAT_EQ(kaonID(particleAll), std::exp(1.9) / numsumexp);
4509 EXPECT_FLOAT_EQ(protonID(particleAll), std::exp(2.22) / numsumexp);
4510 EXPECT_FLOAT_EQ(deuteronID(particleAll), std::exp(3.22) / numsumexp);
4513 auto* particleElectron = particles.appendNew(allTrack,
Const::electron);
4514 auto* particleMuon = particles.appendNew(allTrack,
Const::muon);
4515 auto* particleKaon = particles.appendNew(allTrack,
Const::kaon);
4516 auto* particleProton = particles.appendNew(allTrack,
Const::proton);
4517 auto* particleDeuteron = particles.appendNew(allTrack,
Const::deuteron);
4519 EXPECT_FLOAT_EQ(particleID(particleAll), std::exp(1.4) / numsumexp);
4520 EXPECT_FLOAT_EQ(particleID(particleElectron), std::exp(0.71) / numsumexp);
4521 EXPECT_FLOAT_EQ(particleID(particleMuon), std::exp(3.5) / numsumexp);
4522 EXPECT_FLOAT_EQ(particleID(particleKaon), std::exp(1.9) / numsumexp);
4523 EXPECT_FLOAT_EQ(particleID(particleProton), std::exp(2.22) / numsumexp);
4524 EXPECT_FLOAT_EQ(particleID(particleDeuteron), std::exp(3.22) / numsumexp);
4527 EXPECT_FLOAT_EQ(electronID_noSVD(particleNoSVD), std::exp(0.61) / numsumexp_noSVD);
4528 EXPECT_FLOAT_EQ(muonID_noSVD(particleNoSVD), std::exp(2.92) / numsumexp_noSVD);
4529 EXPECT_FLOAT_EQ(pionID_noSVD(particleNoSVD), std::exp(1.12) / numsumexp_noSVD);
4530 EXPECT_FLOAT_EQ(kaonID_noSVD(particleNoSVD), std::exp(1.52) / numsumexp_noSVD);
4531 EXPECT_FLOAT_EQ(protonID_noSVD(particleNoSVD), std::exp(1.74) / numsumexp_noSVD);
4532 EXPECT_FLOAT_EQ(deuteronID_noSVD(particleNoSVD), std::exp(2.54) / numsumexp_noSVD);
4535 std::vector<double> v_pi_K {211., 321.};
4536 std::vector<double> v_pi_p {211., 2212.};
4537 std::vector<double> v_K_p {321., 2212.};
4538 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_K), std::exp(1.4) / (std::exp(1.4) + std::exp(1.9)));
4539 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_p), std::exp(1.4) / (std::exp(1.4) + std::exp(2.22)));
4540 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_K_p), std::exp(1.9) / (std::exp(1.9) + std::exp(2.22)));
4543 EXPECT_TRUE(std::isnan(electronID(particleNoID)));
4544 EXPECT_TRUE(std::isnan(muonID(particleNoID)));
4545 EXPECT_TRUE(std::isnan(pionID(particleNoID)));
4546 EXPECT_TRUE(std::isnan(kaonID(particleNoID)));
4547 EXPECT_TRUE(std::isnan(protonID(particleNoID)));
4548 EXPECT_TRUE(std::isnan(deuteronID(particleNoID)));
4551 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->function(particleAll)),
4553 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, ALL)")->function(particleAll)),
4555 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(2212, TOP, CDC)")->function(
4556 particleAll)), 0.86);
4559 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(1000010020, ALL)")->function(particleAll)),
4560 std::exp(3.22) / numsumexp);
4561 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(2212, ALL)")->function(particleAll)),
4562 std::exp(2.22) / numsumexp);
4563 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particleAll)),
4564 std::exp(1.4) / numsumexp);
4565 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(321, ALL)")->function(particleAll)),
4566 std::exp(1.9) / numsumexp);
4567 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(13, ALL)")->function(particleAll)),
4568 std::exp(3.5) / numsumexp);
4569 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(11, ALL)")->function(particleAll)),
4570 std::exp(0.71) / numsumexp);
4571 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particledEdx)),
4572 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)));
4573 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particledEdx)),
4574 std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC, SVD)")->function(particleAll)));
4575 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->function(particledEdx)),
4576 std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->function(particleAll)));
4577 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(321, CDC)")->function(particleAll)),
4578 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)));
4581 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->function(
4583 1.0 / (1.0 + std::exp(2.22 - 1.9)));
4584 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->function(
4586 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4587 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, CDC, SVD)")->function(
4589 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4592 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->function(
4594 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP, CDC, SVD)")->function(
4596 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->function(
4598 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->function(
4600 EXPECT_TRUE(std::isnan(std::get<double>
4601 (
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH)")->function(
4603 EXPECT_FALSE(std::isnan(std::get<double>
4604 (
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH, SVD)")->function(
4607 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG()")->function(particledEdx)), 1.00001e+09);
4608 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.5, 0.1, 0.1, 0.1, 0.1, 0.1)")->function(
4611 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.5, 0.1, 0.1, 0.1, 0.1)")->function(
4614 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.5, 0.1, 0.1, 0.1)")->function(
4617 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.5, 0.1, 0.1)")->function(
4620 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.1, 0.5, 0.1)")->function(
4623 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0, 1., 0, 0, 0, 0)")->function(particledEdx)),
4627 TEST_F(PIDVariableTest, MissingLikelihood)
4636 const float pValue = 0.5;
4637 const float bField = 1.5;
4639 TMatrixDSym cov6(6);
4641 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4642 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4643 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4645 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4646 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4648 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4652 Track* savedTrack1 = tracks.appendNew(mytrack);
4653 Track* savedTrack2 = tracks.appendNew(mytrack);
4654 Track* savedTrack3 = tracks.appendNew(mytrack);
4655 Track* savedTrack4 = tracks.appendNew(mytrack);
4665 l2->setLogLikelihood(Const::TOP,
Const::pion, 0.2);
4666 l2->setLogLikelihood(Const::ARICH,
Const::pion, 0.22);
4667 l2->setLogLikelihood(Const::ECL,
Const::pion, 0.24);
4668 l2->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4669 l2->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4672 auto* pion = particles.appendNew(savedTrack2,
Const::pion);
4675 l3->setLogLikelihood(Const::TOP,
Const::kaon, 0.3);
4676 l3->setLogLikelihood(Const::ARICH,
Const::kaon, 0.32);
4679 auto* kaon = particles.appendNew(savedTrack3,
Const::kaon);
4688 auto* proton = particles.appendNew(savedTrack4,
Const::proton);
4695 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(electron)), 0.0);
4696 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(pion)), 0.0);
4697 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(kaon)), 0.0);
4698 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(proton)), 1.0);
4700 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(electron)), 1.0);
4701 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(pion)), 0.0);
4702 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(kaon)), 0.0);
4703 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(proton)), 0.0);
4705 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(electron)), 0.0);
4706 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(pion)), 0.0);
4707 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(kaon)), 1.0);
4708 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(proton)), 0.0);
4711 class FlightInfoTest :
public ::testing::Test {
4714 void SetUp()
override
4721 particles.registerRelationTo(mcParticles);
4749 PxPyPzEVector momentum;
4750 TMatrixFSym error(7);
4757 error(5, 5) = 0.00875;
4759 Particle pi(PxPyPzEVector(1.59607, 1.19705, 0, 2), 211);
4760 momentum += pi.get4Vector();
4761 Particle* newpi = particles.appendNew(pi);
4765 Ks.setVertex(XYZVector(4.0, 5.0, 0.0));
4766 Ks.setMomentumVertexErrorMatrix(error);
4767 momentum += Ks.get4Vector();
4768 Ks.addExtraInfo(
"prodVertX", 1.0);
4769 Ks.addExtraInfo(
"prodVertY", 1.0);
4770 Ks.addExtraInfo(
"prodVertZ", 0.0);
4771 Ks.addExtraInfo(
"prodVertSxx", 0.04);
4772 Ks.addExtraInfo(
"prodVertSxy", 0.0);
4773 Ks.addExtraInfo(
"prodVertSxz", 0.0);
4774 Ks.addExtraInfo(
"prodVertSyx", 0.0);
4775 Ks.addExtraInfo(
"prodVertSyy", 0.00875);
4776 Ks.addExtraInfo(
"prodVertSyz", 0.0);
4777 Ks.addExtraInfo(
"prodVertSzx", 0.0);
4778 Ks.addExtraInfo(
"prodVertSzy", 0.0);
4779 Ks.addExtraInfo(
"prodVertSzz", 0.01);
4780 Particle* newKs = particles.appendNew(Ks);
4785 Dp.appendDaughter(newpi);
4786 Dp.appendDaughter(newKs);
4787 XYZVector motherVtx(1.0, 1.0, 0.0);
4788 Dp.setVertex(motherVtx);
4789 Dp.setMomentumVertexErrorMatrix(error);
4790 Dp.addExtraInfo(
"prodVertX", 0.0);
4791 Dp.addExtraInfo(
"prodVertY", 1.0);
4792 Dp.addExtraInfo(
"prodVertZ", -2.0);
4793 Dp.addExtraInfo(
"prodVertSxx", 0.04);
4794 Dp.addExtraInfo(
"prodVertSxy", 0.0);
4795 Dp.addExtraInfo(
"prodVertSxz", 0.0);
4796 Dp.addExtraInfo(
"prodVertSyx", 0.0);
4797 Dp.addExtraInfo(
"prodVertSyy", 0.01);
4798 Dp.addExtraInfo(
"prodVertSyz", 0.0);
4799 Dp.addExtraInfo(
"prodVertSzx", 0.0);
4800 Dp.addExtraInfo(
"prodVertSzy", 0.0);
4801 Dp.addExtraInfo(
"prodVertSzz", 0.1575);
4802 Particle* newDp = particles.appendNew(Dp);
4808 void TearDown()
override
4813 TEST_F(FlightInfoTest, flightDistance)
4816 const Particle* newKs = particles[1];
4819 ASSERT_NE(var,
nullptr);
4820 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
4822 TEST_F(FlightInfoTest, flightDistanceErr)
4825 const Particle* newKs = particles[1];
4828 ASSERT_NE(var,
nullptr);
4829 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4831 TEST_F(FlightInfoTest, flightTime)
4834 const Particle* newKs = particles[1];
4837 ASSERT_NE(var,
nullptr);
4841 TEST_F(FlightInfoTest, flightTimeErr)
4844 const Particle* newKs = particles[1];
4847 ASSERT_NE(var,
nullptr);
4848 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4851 TEST_F(FlightInfoTest, flightDistanceOfDaughter)
4854 const Particle* newDp = particles[2];
4857 ASSERT_NE(var,
nullptr);
4858 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4861 ASSERT_NE(var,
nullptr);
4862 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4864 TEST_F(FlightInfoTest, flightDistanceOfDaughterErr)
4867 const Particle* newDp = particles[2];
4870 ASSERT_NE(var,
nullptr);
4871 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4874 ASSERT_NE(var,
nullptr);
4875 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4877 TEST_F(FlightInfoTest, flightTimeOfDaughter)
4880 const Particle* newDp = particles[2];
4883 ASSERT_NE(var,
nullptr);
4889 ASSERT_NE(var,
nullptr);
4890 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4892 TEST_F(FlightInfoTest, flightTimeOfDaughterErr)
4895 const Particle* newDp = particles[2];
4898 ASSERT_NE(var,
nullptr);
4899 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4902 ASSERT_NE(var,
nullptr);
4903 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4905 TEST_F(FlightInfoTest, mcFlightDistanceOfDaughter)
4908 const Particle* newDp = particles[2];
4911 ASSERT_NE(var,
nullptr);
4913 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4916 ASSERT_NE(var,
nullptr);
4917 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4919 TEST_F(FlightInfoTest, mcFlightTimeOfDaughter)
4922 const Particle* newDp = particles[2];
4925 ASSERT_NE(var,
nullptr);
4930 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), Ks->getLifetime() / Ks->
getEnergy()*Ks->
getMass());
4933 ASSERT_NE(var,
nullptr);
4934 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4937 TEST_F(FlightInfoTest, vertexDistance)
4940 const Particle* newKS = particles[1];
4943 ASSERT_NE(var,
nullptr);
4944 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 5.0);
4947 TEST_F(FlightInfoTest, vertexDistanceError)
4950 const Particle* newKS = particles[1];
4953 ASSERT_NE(var,
nullptr);
4954 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 0.2);
4957 TEST_F(FlightInfoTest, vertexDistanceSignificance)
4960 const Particle* newKS = particles[1];
4963 ASSERT_NE(var,
nullptr);
4964 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 25);
4967 TEST_F(FlightInfoTest, vertexDistanceOfDaughter)
4970 const Particle* newDp = particles[2];
4973 ASSERT_NE(var,
nullptr);
4974 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4977 ASSERT_NE(var,
nullptr);
4978 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 6.0);
4981 ASSERT_NE(var,
nullptr);
4982 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4985 TEST_F(FlightInfoTest, vertexDistanceOfDaughterError)
4988 const Particle* newDp = particles[2];
4991 ASSERT_NE(var,
nullptr);
4992 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.2);
4995 ASSERT_NE(var,
nullptr);
4996 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.25);
4999 TEST_F(FlightInfoTest, vertexDistanceOfDaughterSignificance)
5002 const Particle* newDp = particles[2];
5005 ASSERT_NE(var,
nullptr);
5006 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 25);
5009 ASSERT_NE(var,
nullptr);
5010 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 24);
5013 class VertexVariablesTest :
public ::testing::Test {
5016 void SetUp()
override
5023 particles.registerRelationTo(mcParticles);
5038 Particle Ks(PxPyPzEVector(1.164, 1.55200, 0, 2), 310);
5052 Particle* newKs = particles.appendNew(Ks);
5057 void TearDown()
override
5064 TEST_F(VertexVariablesTest, mcDecayVertexX)
5067 const Particle* newKs = particles[0];
5070 ASSERT_NE(var,
nullptr);
5071 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 4.0);
5074 TEST_F(VertexVariablesTest, mcDecayVertexY)
5077 const Particle* newKs = particles[0];
5080 ASSERT_NE(var,
nullptr);
5081 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
5084 TEST_F(VertexVariablesTest, mcDecayVertexZ)
5087 const Particle* newKs = particles[0];
5090 ASSERT_NE(var,
nullptr);
5091 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.0);
5095 TEST_F(VertexVariablesTest, mcDecayVertexFromIPDistance)
5098 const Particle* newKs = particles[0];
5101 ASSERT_NE(var,
nullptr);
5102 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(4.0 * 4.0 + 5.0 * 5.0));
5105 TEST_F(VertexVariablesTest, mcDecayVertexRho)
5108 const Particle* newKs = particles[0];
5111 ASSERT_NE(var,
nullptr);
5112 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(4.0 * 4.0 + 5.0 * 5.0));
5115 TEST_F(VertexVariablesTest, mcProductionVertexX)
5118 const Particle* newKs = particles[0];
5121 ASSERT_NE(var,
nullptr);
5122 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
5125 TEST_F(VertexVariablesTest, mcProductionVertexY)
5128 const Particle* newKs = particles[0];
5131 ASSERT_NE(var,
nullptr);
5132 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
5135 TEST_F(VertexVariablesTest, mcProductionVertexZ)
5138 const Particle* newKs = particles[0];
5141 ASSERT_NE(var,
nullptr);
5142 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
5147 TEST_F(VertexVariablesTest, prodVertexX)
5150 const Particle* newKs = particles[0];
5153 ASSERT_NE(var,
nullptr);
5154 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
5156 TEST_F(VertexVariablesTest, prodVertexY)
5159 const Particle* newKs = particles[0];
5162 ASSERT_NE(var,
nullptr);
5163 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
5165 TEST_F(VertexVariablesTest, prodVertexZ)
5168 const Particle* newKs = particles[0];
5171 ASSERT_NE(var,
nullptr);
5172 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
5177 TEST_F(VertexVariablesTest, prodVertexCov)
5180 const Particle* newKs = particles[0];
5184 ASSERT_NE(var,
nullptr);
5185 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.1);
5187 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.2);
5189 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.3);
5191 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.4);
5193 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.5);
5195 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.6);
5197 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.7);
5199 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.8);
5201 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.9);
5203 ASSERT_NE(var,
nullptr);
5204 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.1));
5206 ASSERT_NE(var,
nullptr);
5207 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.5));
5209 ASSERT_NE(var,
nullptr);
5210 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.9));
5215 TEST_F(MetaVariableTest, KSFWVariables)
5226 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5229 EXPECT_B2ERROR(
Manager::Instance().getVariable(
"KSFWVariables(et, mask, FS1)"));
5232 TEST_F(MetaVariableTest, CleoConeCS)
5243 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5247 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5253 TEST_F(MetaVariableTest, TransformedNetworkOutput)
5256 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONSENSE)"));
5259 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, 0, NOTDOUBLE)"));
5260 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, NOTDOUBLE, 1)"));
5266 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle))));
5268 if (not eventExtraInfo.isValid())
5269 eventExtraInfo.create();
5271 EXPECT_TRUE(std::isnan(std::get<double>(var->function(
nullptr))));
Provides a type-safe way to pass members of the chargedStableSet set.
int getPDGCode() const
PDG code.
static DetectorSet set()
Accessor for the set of valid detector IDs.
static const ChargedStable muon
muon particle
static const ParticleSet chargedStableSet
set of charged stable particles
static const ChargedStable pion
charged pion particle
static const ParticleType Klong
K^0_L particle.
static const double speedOfLight
[cm/ns]
static const ChargedStable proton
proton particle
static const ParticleType Kshort
K^0_S particle.
static const ChargedStable kaon
charged kaon particle
static const ParticleType photon
photon particle
static const ChargedStable electron
electron particle
static const ChargedStable deuteron
deuteron particle
EStoreFlags
Flags describing behaviours of objects etc.
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
static DataStore & Instance()
Instance of singleton Store.
void setInitializeActive(bool active)
Setter for m_initializeActive.
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
void setTheta(double theta)
Set Theta of Shower (radian).
void setPhi(double phi)
Set Phi of Shower (radian).
void setClusterId(int clusterid)
Set cluster id.
void setHypothesis(EHypothesisBit hypothesis)
Set hypotheses.
void setEnergy(double energy)
Set Corrected Energy (GeV).
void setR(double r)
Set R (in cm).
Singleton class responsible for loading detector parameters from an XML file.
Class to represent Particle data in graph.
void comesFrom(GraphParticle &mother)
Tells the graph that this particle is a decay product of mother.
Class to build, validate and sort a particle decay chain.
void generateList(const std::string &name="", int options=c_setNothing)
Generates the MCParticle list and stores it in the StoreArray with the given name.
A Class to store the Monte Carlo particle information.
float getEnergy() const
Return particle energy in GeV.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
void setDecayTime(float time)
Set decay time.
void setMass(float mass)
Set particle mass.
void setDecayVertex(const ROOT::Math::XYZVector &vertex)
Set decay vertex.
float getMass() const
Return the particle mass in GeV.
void setProductionVertex(const ROOT::Math::XYZVector &vertex)
Set production vertex position.
ROOT::Math::PxPyPzEVector get4Vector() const
Return 4Vector of particle.
void setPDG(int pdg)
Set PDG code of the particle.
void set4Vector(const ROOT::Math::PxPyPzEVector &p4)
Sets the 4Vector of particle.
void setMomentum(const ROOT::Math::XYZVector &momentum)
Set particle momentum.
void setStatus(unsigned short int status)
Set Status code for the particle.
void setProductionTime(float time)
Set production time.
void setMassFromPDG()
Sets the mass for the particle from the particle's PDG code.
Class to store reconstructed particles.
void appendDaughter(const Particle *daughter, const bool updateType=true, const int daughterProperty=c_Ordinary)
Appends index of daughter to daughters index array.
void setVertex(const ROOT::Math::XYZVector &vertex)
Sets position (decay vertex)
double getEnergy() const
Returns total energy.
double getPDGMass(void) const
Returns uncertainty on the invariant mass (requires valid momentum error matrix)
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
void addExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
@ c_Unflavored
Is its own antiparticle or we don't know whether it is a particle/antiparticle.
@ c_Flavored
Is either particle or antiparticle.
double getP() const
Returns momentum magnitude (same as getMomentumMagnitude but with shorter name)
const Particle * getDaughter(unsigned i) const
Returns a pointer to the i-th daughter particle.
double getMass() const
Returns invariant mass (= nominal for FS particles)
static const ReferenceFrame & GetCurrent()
Get current rest frame.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
void clear() override
Delete all entries in this array.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Type-safe access to single objects in the data store.
Class that bundles various TrackFitResults.
void setTrackFitResultIndex(const Const::ChargedStable &chargedStable, short index)
Set an index (for positive values) or unavailability-code (index = -1) for a specific mass hypothesis...
A template class to apply the reference frame.
Object holding information for V0s.
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
static Manager & Instance()
get singleton instance.
static Gearbox & getInstance()
Return reference to the Gearbox instance.
double sqrt(double a)
sqrt for double
GraphParticle & addParticle()
Add new particle to the graph.
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Abstract base class for different kinds of events.
A variable returning a floating-point value for a given Particle.
FunctionPtr function
Pointer to function.