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);
992 TEST_F(MetaVariableTest, extraInfo)
994 Particle p({ 0.1, -0.4, 0.8, 1.0 }, 11);
995 p.addExtraInfo(
"pi", 3.14);
998 ASSERT_NE(var,
nullptr);
999 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.14);
1002 EXPECT_TRUE(std::isnan(std::get<double>(var->function(
nullptr))));
1005 TEST_F(MetaVariableTest, eventExtraInfo)
1008 if (not eventExtraInfo.isValid())
1009 eventExtraInfo.create();
1010 eventExtraInfo->addExtraInfo(
"pi", 3.14);
1012 ASSERT_NE(var,
nullptr);
1013 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1016 TEST_F(MetaVariableTest, eventCached)
1019 ASSERT_NE(var,
nullptr);
1020 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1022 EXPECT_TRUE(eventExtraInfo.isValid());
1023 EXPECT_TRUE(eventExtraInfo->hasExtraInfo(
"__constant__bo3__pt14__bc"));
1024 EXPECT_FLOAT_EQ(eventExtraInfo->getExtraInfo(
"__constant__bo3__pt14__bc"), 3.14);
1025 eventExtraInfo->addExtraInfo(
"__eventExtraInfo__bopi__bc", 3.14);
1027 ASSERT_NE(var,
nullptr);
1028 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1031 TEST_F(MetaVariableTest, particleCached)
1033 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1035 ASSERT_NE(var,
nullptr);
1036 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
1037 EXPECT_TRUE(p.hasExtraInfo(
"__px"));
1038 EXPECT_FLOAT_EQ(p.getExtraInfo(
"__px"), 0.1);
1039 p.addExtraInfo(
"__py", -0.5);
1041 ASSERT_NE(var,
nullptr);
1042 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.5);
1045 TEST_F(MetaVariableTest, basicMathTest)
1047 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1050 ASSERT_NE(var,
nullptr);
1051 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.4);
1054 ASSERT_NE(var,
nullptr);
1055 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.8);
1058 ASSERT_NE(var,
nullptr);
1059 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 2.0);
1062 ASSERT_NE(var,
nullptr);
1063 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1067 ASSERT_NE(var,
nullptr);
1068 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1072 ASSERT_NE(var,
nullptr);
1073 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1077 ASSERT_NE(var,
nullptr);
1078 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.5707963267948966);
1082 ASSERT_NE(var,
nullptr);
1083 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1087 ASSERT_NE(var,
nullptr);
1088 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.5707963267948966);
1092 TEST_F(MetaVariableTest, formula)
1099 Particle p({ 0.1, -0.4, 0.8, 2.0 }, -411);
1102 ASSERT_NE(var,
nullptr);
1103 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.3);
1106 ASSERT_NE(var,
nullptr);
1107 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1110 ASSERT_NE(var,
nullptr);
1111 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.04);
1114 ASSERT_NE(var,
nullptr);
1115 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -4.0);
1118 ASSERT_NE(var,
nullptr);
1119 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.01);
1122 ASSERT_NE(var,
nullptr);
1123 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1126 ASSERT_NE(var,
nullptr);
1127 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1130 ASSERT_NE(var,
nullptr);
1131 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.41231057);
1132 double pt = std::get<double>(var->function(&p));
1135 ASSERT_NE(var,
nullptr);
1136 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), pt);
1139 ASSERT_NE(var,
nullptr);
1140 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1143 ASSERT_NE(var,
nullptr);
1144 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1147 ASSERT_NE(var,
nullptr);
1148 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1151 ASSERT_NE(var,
nullptr);
1152 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 411.0);
1155 ASSERT_NE(var,
nullptr);
1156 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -168921.0);
1159 ASSERT_NE(var,
nullptr);
1160 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 8.33);
1163 ASSERT_NE(var,
nullptr);
1164 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -8.33);
1167 ASSERT_NE(var,
nullptr);
1168 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 411);
1171 TEST_F(MetaVariableTest, passesCut)
1173 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1174 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 411);
1177 ASSERT_NE(var,
nullptr);
1178 EXPECT_TRUE(std::get<bool>(var->function(&p)));
1179 EXPECT_FALSE(std::get<bool>(var->function(&p2)));
1184 TEST_F(MetaVariableTest, unmask)
1189 particles.registerInDataStore();
1191 particles.registerRelationTo(mcParticles);
1205 graphParticleGrandMother.
setPDG(-521);
1207 graphParticleAunt.
setPDG(-14);
1209 graphParticleDaughter2.
setPDG(14);
1211 graphParticleMother.
comesFrom(graphParticleGrandMother);
1212 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1213 graphParticleDaughter1.
comesFrom(graphParticleMother);
1214 graphParticleDaughter2.
comesFrom(graphParticleMother);
1219 auto* mcGrandMother = mcParticles[0];
1222 auto* mcMother = mcParticles[1];
1225 auto* mcAunt = mcParticles[2];
1228 auto* mcDaughter1 = mcParticles[3];
1231 auto* mcDaughter2 = mcParticles[4];
1234 auto* pGrandMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1235 pGrandMother->addRelationTo(mcGrandMother);
1237 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1238 pMother->addRelationTo(mcMother);
1241 pMother->writeExtraInfo(
"mcErrors", 8);
1242 pGrandMother->writeExtraInfo(
"mcErrors", 8 | 16);
1245 ASSERT_NE(var1,
nullptr);
1246 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pMother)), 0);
1247 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pGrandMother)), 16);
1248 ASSERT_NE(var2,
nullptr);
1249 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pMother)), 0);
1250 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pGrandMother)), 0);
1253 pMother->writeExtraInfo(
"mcErrors", 8 | 128);
1254 pGrandMother->writeExtraInfo(
"mcErrors", 8 | 16 | 512);
1255 ASSERT_NE(var1,
nullptr);
1256 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pMother)), 128);
1257 EXPECT_FLOAT_EQ(std::get<double>(var1->function(pGrandMother)), 16 | 512);
1258 ASSERT_NE(var2,
nullptr);
1259 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pMother)), 128);
1260 EXPECT_FLOAT_EQ(std::get<double>(var2->
function(pGrandMother)), 512);
1269 TEST_F(MetaVariableTest, conditionalVariableSelector)
1271 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1274 ASSERT_NE(var,
nullptr);
1275 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
1278 ASSERT_NE(var,
nullptr);
1279 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.4);
1283 TEST_F(MetaVariableTest, nCleanedTracks)
1289 tracks.registerInDataStore();
1292 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1293 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 11);
1295 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.1, 0.0, 0.0),
1296 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1297 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.15, 0.0, 0.0),
1298 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1299 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.4, 0.0, 0.0),
1300 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1301 track_fit_results.
appendNew(ROOT::Math::XYZVector(0.1, 0.1, 0.1), ROOT::Math::XYZVector(0.6, 0.0, 0.0),
1302 TMatrixDSym(6), 1,
Const::pion, 0.01, 1.5, 0, 0, 0);
1304 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 0);
1305 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 1);
1306 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 2);
1307 tracks.appendNew()->setTrackFitResultIndex(
Const::pion, 3);
1310 EXPECT_FLOAT_EQ(std::get<int>(var1->function(
nullptr)), 1);
1313 EXPECT_FLOAT_EQ(std::get<int>(var2->
function(
nullptr)), 2);
1316 EXPECT_FLOAT_EQ(std::get<int>(var3->
function(
nullptr)), 4);
1321 TEST_F(MetaVariableTest, NumberOfMCParticlesInEvent)
1323 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
1324 Particle p2({ 0.1, -0.4, 0.8, 4.0 }, 11);
1327 auto* mcParticle = mcParticles.
appendNew();
1330 mcParticle = mcParticles.appendNew();
1333 mcParticle = mcParticles.appendNew();
1336 mcParticle = mcParticles.appendNew();
1341 ASSERT_NE(var,
nullptr);
1342 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 2);
1346 TEST_F(MetaVariableTest, daughterInvM)
1348 PxPyPzEVector momentum;
1349 const int nDaughters = 6;
1351 std::vector<int> daughterIndices;
1352 for (
int i = 0; i < nDaughters; i++) {
1353 Particle d(PxPyPzEVector(2, 2, 2, 4.0), (i % 2) ? 213 : -213);
1354 momentum += d.get4Vector();
1355 Particle* newDaughters = particles.appendNew(d);
1361 ASSERT_NE(var,
nullptr);
1362 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1365 ASSERT_NE(var,
nullptr);
1366 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 4.0);
1369 ASSERT_NE(var,
nullptr);
1370 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 6.0);
1373 TEST_F(MetaVariableTest, daughter)
1375 PxPyPzEVector momentum;
1376 const int nDaughters = 6;
1378 std::vector<int> daughterIndices;
1379 for (
int i = 0; i < nDaughters; i++) {
1380 Particle d(PxPyPzEVector(i * 1.0, 1, 1, 1), (i % 2) ? 211 : -211);
1381 momentum += d.get4Vector();
1382 Particle* newDaughters = particles.appendNew(d);
1388 ASSERT_NE(var,
nullptr);
1389 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1392 ASSERT_NE(var,
nullptr);
1393 EXPECT_NEAR(std::get<double>(var->function(p)), 0.0, 1e-6);
1396 ASSERT_NE(var,
nullptr);
1397 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 1.0);
1400 ASSERT_NE(var,
nullptr);
1401 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 2.0);
1404 TEST_F(MetaVariableTest, mcDaughter)
1409 particles.registerInDataStore();
1411 particles.registerRelationTo(mcParticles);
1425 graphParticleGrandMother.
setPDG(-521);
1427 graphParticleAunt.
setPDG(-14);
1429 graphParticleDaughter2.
setPDG(14);
1431 graphParticleMother.
comesFrom(graphParticleGrandMother);
1432 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1433 graphParticleDaughter1.
comesFrom(graphParticleMother);
1434 graphParticleDaughter2.
comesFrom(graphParticleMother);
1438 auto* mcGrandMother = mcParticles[0];
1441 auto* mcMother = mcParticles[1];
1444 auto* mcAunt = mcParticles[2];
1447 auto* mcDaughter1 = mcParticles[3];
1450 auto* mcDaughter2 = mcParticles[4];
1453 auto* pGrandMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1454 pGrandMother->addRelationTo(mcGrandMother);
1456 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1457 pMother->addRelationTo(mcMother);
1460 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1463 auto* p_noDaughter = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1464 p_noDaughter->addRelationTo(mcDaughter1);
1467 ASSERT_NE(var,
nullptr);
1468 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 13);
1469 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), 11);
1470 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1471 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noDaughter))));
1473 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), -14);
1474 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), 14);
1477 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1478 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1481 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 11);
1482 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1484 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 14);
1486 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1488 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1491 TEST_F(MetaVariableTest, mcMother)
1496 particles.registerInDataStore();
1498 particles.registerRelationTo(mcParticles);
1512 graphParticleGrandMother.
setPDG(-521);
1514 graphParticleAunt.
setPDG(-14);
1516 graphParticleDaughter2.
setPDG(14);
1518 graphParticleMother.
comesFrom(graphParticleGrandMother);
1519 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1520 graphParticleDaughter1.
comesFrom(graphParticleMother);
1521 graphParticleDaughter2.
comesFrom(graphParticleMother);
1526 auto* mcGrandMother = mcParticles[0];
1529 auto* mcMother = mcParticles[1];
1532 auto* mcAunt = mcParticles[2];
1535 auto* mcDaughter1 = mcParticles[3];
1538 auto* mcDaughter2 = mcParticles[4];
1541 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1542 p1->addRelationTo(mcDaughter1);
1544 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 14);
1545 p2->addRelationTo(mcDaughter2);
1547 auto* pMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 13);
1548 pMother->addRelationTo(mcMother);
1551 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1554 auto* p_noMother = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), -521);
1555 p_noMother->addRelationTo(mcGrandMother);
1558 ASSERT_NE(var,
nullptr);
1559 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 13);
1560 EXPECT_FLOAT_EQ(std::get<double>(var->function(p2)), 13);
1561 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), -521);
1562 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1563 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMother))));
1567 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1570 TEST_F(MetaVariableTest, genParticle)
1575 particles.registerInDataStore();
1577 particles.registerRelationTo(mcParticles);
1591 graphParticleGrandMother.
setPDG(300553);
1592 graphParticleMother.
setPDG(-521);
1593 graphParticleAunt.
setPDG(521);
1595 graphParticleDaughter2.
setPDG(-12);
1597 graphParticleGrandMother.
setMomentum(0.0, 0.0, 0.4);
1600 graphParticleMother.
comesFrom(graphParticleGrandMother);
1601 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1602 graphParticleDaughter1.
comesFrom(graphParticleMother);
1603 graphParticleDaughter2.
comesFrom(graphParticleMother);
1608 auto* mcGrandMother = mcParticles[0];
1611 auto* mcMother = mcParticles[1];
1614 auto* mcAunt = mcParticles[2];
1617 auto* mcDaughter1 = mcParticles[3];
1620 auto* mcDaughter2 = mcParticles[4];
1623 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1624 p1->addRelationTo(mcDaughter1);
1627 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 211);
1630 ASSERT_NE(var,
nullptr);
1631 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 300553);
1632 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 300553);
1635 ASSERT_NE(var,
nullptr);
1636 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 0.4);
1637 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 0.4);
1640 ASSERT_NE(var,
nullptr);
1641 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1642 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1645 ASSERT_NE(var,
nullptr);
1646 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 1.1);
1647 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 1.1);
1650 ASSERT_NE(var,
nullptr);
1651 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1652 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1655 ASSERT_NE(var,
nullptr);
1656 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -12);
1657 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -12);
1660 ASSERT_NE(var,
nullptr);
1661 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p1))));
1662 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p_noMC))));
1665 TEST_F(MetaVariableTest, genUpsilon4S)
1670 particles.registerInDataStore();
1672 particles.registerRelationTo(mcParticles);
1686 graphParticleGrandMother.
setPDG(300553);
1687 graphParticleMother.
setPDG(-521);
1688 graphParticleAunt.
setPDG(521);
1690 graphParticleDaughter2.
setPDG(-12);
1692 graphParticleGrandMother.
setMomentum(0.0, 0.0, 0.4);
1695 graphParticleMother.
comesFrom(graphParticleGrandMother);
1696 graphParticleAunt.
comesFrom(graphParticleGrandMother);
1697 graphParticleDaughter1.
comesFrom(graphParticleMother);
1698 graphParticleDaughter2.
comesFrom(graphParticleMother);
1703 auto* mcGrandMother = mcParticles[0];
1706 auto* mcMother = mcParticles[1];
1709 auto* mcAunt = mcParticles[2];
1712 auto* mcDaughter1 = mcParticles[3];
1715 auto* mcDaughter2 = mcParticles[4];
1718 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1719 p1->addRelationTo(mcDaughter1);
1722 auto* p_noMC = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 211);
1725 ASSERT_NE(var,
nullptr);
1726 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 300553);
1727 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 300553);
1730 ASSERT_NE(var,
nullptr);
1731 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 0.4);
1732 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 0.4);
1735 ASSERT_NE(var,
nullptr);
1736 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1737 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), -521);
1740 ASSERT_NE(var,
nullptr);
1741 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), 1.1);
1742 EXPECT_FLOAT_EQ(std::get<double>(var->function(p_noMC)), 1.1);
1745 mcParticles.
clear();
1760 auto* mcP1 = mcParticles[0];
1763 auto* mcP2 = mcParticles[1];
1766 auto* someParticle = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1767 someParticle->addRelationTo(mcP1);
1770 ASSERT_NE(var,
nullptr);
1771 EXPECT_TRUE(std::isnan(std::get<double>(var->function(someParticle))));
1774 TEST_F(MetaVariableTest, daughterProductOf)
1776 PxPyPzEVector momentum;
1777 const int nDaughters = 4;
1779 std::vector<int> daughterIndices;
1780 for (
int i = 0; i < nDaughters; i++) {
1781 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1782 momentum += d.get4Vector();
1783 Particle* newDaughters = particles.appendNew(d);
1789 ASSERT_NE(var,
nullptr);
1790 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 120.0);
1793 TEST_F(MetaVariableTest, daughterSumOf)
1795 PxPyPzEVector momentum;
1796 const int nDaughters = 4;
1798 std::vector<int> daughterIndices;
1799 for (
int i = 0; i < nDaughters; i++) {
1800 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1801 momentum += d.get4Vector();
1802 Particle* newDaughters = particles.appendNew(d);
1808 ASSERT_NE(var,
nullptr);
1809 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 14.0);
1812 TEST_F(MetaVariableTest, daughterLowest)
1814 PxPyPzEVector momentum;
1815 const int nDaughters = 4;
1817 std::vector<int> daughterIndices;
1818 for (
int i = 0; i < nDaughters; i++) {
1819 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 2.0), (i % 2) ? 213 : -213);
1820 momentum += d.get4Vector();
1821 Particle* newDaughters = particles.appendNew(d);
1827 ASSERT_NE(var,
nullptr);
1828 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 2.0);
1831 TEST_F(MetaVariableTest, daughterHighest)
1833 PxPyPzEVector momentum;
1834 const int nDaughters = 4;
1836 std::vector<int> daughterIndices;
1837 for (
int i = 0; i < nDaughters; i++) {
1838 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? 213 : -213);
1839 momentum += d.get4Vector();
1840 Particle* newDaughters = particles.appendNew(d);
1846 ASSERT_NE(var,
nullptr);
1847 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 4.0);
1850 TEST_F(MetaVariableTest, daughterDiffOf)
1852 PxPyPzEVector momentum;
1853 const int nDaughters = 4;
1855 std::vector<int> daughterIndices;
1856 for (
int i = 0; i < nDaughters; i++) {
1857 Particle d(PxPyPzEVector(-1, 1.0 - 2 * (i % 2), 1, i * 1.0 + 2.0), (i % 2) ? -11 : 211);
1858 momentum += d.get4Vector();
1859 Particle* newDaughters = particles.appendNew(d);
1865 ASSERT_NE(var,
nullptr);
1866 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1869 ASSERT_NE(var,
nullptr);
1870 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1873 ASSERT_NE(var,
nullptr);
1874 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1877 ASSERT_NE(var,
nullptr);
1878 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1881 ASSERT_NE(var,
nullptr);
1882 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1885 ASSERT_NE(var,
nullptr);
1886 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1889 ASSERT_NE(var,
nullptr);
1890 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5707964);
1893 ASSERT_NE(var,
nullptr);
1894 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5004894);
1897 ASSERT_NE(var,
nullptr);
1898 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1902 TEST_F(MetaVariableTest, mcDaughterDiffOf)
1905 PxPyPzEVector momentum;
1906 const int nDaughters = 4;
1909 particles.registerRelationTo(mcParticles);
1910 std::vector<int> daughterIndices;
1913 for (
int i = 0; i < nDaughters; i++) {
1914 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
1915 momentum += d.get4Vector();
1916 Particle* newDaughters = particles.appendNew(d);
1918 auto* mcParticle = mcParticles.
appendNew();
1926 ASSERT_NE(var,
nullptr);
1927 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1930 ASSERT_NE(var,
nullptr);
1931 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1934 ASSERT_NE(var,
nullptr);
1935 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1938 ASSERT_NE(var,
nullptr);
1939 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1942 ASSERT_NE(var,
nullptr);
1943 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1946 ASSERT_NE(var,
nullptr);
1947 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1950 ASSERT_NE(var,
nullptr);
1951 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1956 TEST_F(MetaVariableTest, daughterClusterAngleInBetween)
1960 std::vector<int> daughterIndices, daughterIndices_noclst;
1966 particles.registerRelationTo(eclclusters);
1970 const float px_CM = 2.;
1971 const float py_CM = 1.;
1972 const float pz_CM = 3.;
1974 E_CM =
sqrt(pow(px_CM, 2) + pow(py_CM, 2) + pow(pz_CM, 2));
1975 PxPyPzEVector momentum, momentum_noclst;
1976 PxPyPzEVector dau0_4vec_CM(px_CM, py_CM, pz_CM, E_CM), dau1_4vec_CM(-px_CM, -py_CM, -pz_CM, E_CM);
1977 PxPyPzEVector dau0_4vec_Lab, dau1_4vec_Lab;
1983 Particle dau0_noclst(dau0_4vec_Lab, 22);
1984 momentum += dau0_noclst.get4Vector();
1985 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
1986 daughterIndices_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
1987 Particle dau1_noclst(dau1_4vec_Lab, 22);
1988 momentum += dau1_noclst.get4Vector();
1989 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
1990 daughterIndices_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
1998 ASSERT_NE(var,
nullptr);
1999 EXPECT_TRUE(std::isnan(std::get<double>(var->function(par_noclst))));
2004 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2006 eclst0->
setTheta(dau0_4vec_Lab.Theta());
2007 eclst0->
setPhi(dau0_4vec_Lab.Phi());
2008 eclst0->
setR(148.4);
2011 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2013 eclst1->
setTheta(dau1_4vec_Lab.Theta());
2014 eclst1->
setPhi(dau1_4vec_Lab.Phi());
2015 eclst1->
setR(148.5);
2017 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2019 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2025 EXPECT_FLOAT_EQ(std::get<double>(var->function(par)), 2.8613892);
2026 EXPECT_FLOAT_EQ(std::get<double>(varCMS->
function(par)), M_PI);
2029 TEST_F(MetaVariableTest, grandDaughterDiffOfs)
2033 std::vector<int> daughterIndices0_noclst, daughterIndices1_noclst, daughterIndices2_noclst;
2034 std::vector<int> daughterIndices0, daughterIndices1, daughterIndices2;
2040 particles.registerRelationTo(eclclusters);
2044 const float px_0 = 2.;
2045 const float py_0 = 1.;
2046 const float pz_0 = 3.;
2047 const float px_1 = 1.5;
2048 const float py_1 = 1.5;
2049 const float pz_1 = 2.5;
2051 E_0 =
sqrt(pow(px_0, 2) + pow(py_0, 2) + pow(pz_0, 2));
2052 E_1 =
sqrt(pow(px_1, 2) + pow(py_1, 2) + pow(pz_1, 2));
2053 PxPyPzEVector momentum_0, momentum_1, momentum;
2054 PxPyPzEVector dau0_4vec(px_0, py_0, pz_0, E_0), dau1_4vec(px_1, py_1, pz_1, E_1);
2067 Particle dau0_noclst(dau0_4vec, 22);
2068 momentum_0 = dau0_4vec;
2069 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
2070 daughterIndices0_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
2072 Particle dau1_noclst(dau1_4vec, 22);
2073 momentum_1 = dau1_4vec;
2074 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
2075 daughterIndices1_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
2078 momentum = momentum_0 + momentum_1;
2079 daughterIndices2_noclst.push_back(par0_noclst->
getArrayIndex());
2080 daughterIndices2_noclst.push_back(par1_noclst->
getArrayIndex());
2099 ASSERT_NE(var_ClusterPhi,
nullptr);
2100 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi->
function(parGranny_noclst))));
2101 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterTheta->
function(parGranny_noclst))));
2102 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE->
function(parGranny_noclst))));
2103 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny_noclst)), 0.32175055);
2104 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny_noclst)), 0.06311664);
2105 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny_noclst)), -0.46293807);
2106 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi_wrongIndexes->
function(parGranny_noclst))));
2107 EXPECT_TRUE(std::isnan(std::get<double>(var_Phi_wrongIndexes->
function(parGranny_noclst))));
2108 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE_wrongIndexes->
function(parGranny_noclst))));
2109 EXPECT_TRUE(std::isnan(std::get<double>(var_E_wrongIndexes->
function(parGranny_noclst))));
2114 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2116 eclst0->
setTheta(dau0_4vec.Theta());
2117 eclst0->
setPhi(dau0_4vec.Phi());
2118 eclst0->
setR(148.4);
2121 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2123 eclst1->
setTheta(dau1_4vec.Theta());
2124 eclst1->
setPhi(dau1_4vec.Phi());
2125 eclst1->
setR(148.5);
2127 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2131 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2141 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterPhi->
function(parGranny)), 0.32175055);
2142 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny)), 0.32175055);
2143 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterTheta->
function(parGranny)), 0.06311664);
2144 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny)), 0.06311664);
2145 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterE->
function(parGranny)), -0.46293831);
2146 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny)), -0.46293831);
2149 TEST_F(MetaVariableTest, daughterNormDiffOf)
2151 PxPyPzEVector momentum;
2152 const int nDaughters = 4;
2154 std::vector<int> daughterIndices;
2155 for (
int i = 0; i < nDaughters; i++) {
2156 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2157 momentum += d.get4Vector();
2158 Particle* newDaughters = particles.appendNew(d);
2164 ASSERT_NE(var,
nullptr);
2165 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222 / 200.);
2168 ASSERT_NE(var,
nullptr);
2169 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222 / 200.);
2172 ASSERT_NE(var,
nullptr);
2173 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200 / 222.);
2176 ASSERT_NE(var,
nullptr);
2177 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -0 / 22.);
2180 ASSERT_NE(var,
nullptr);
2181 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 22.);
2184 ASSERT_NE(var,
nullptr);
2185 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 422.);
2189 TEST_F(MetaVariableTest, daughterMotherDiffOf)
2191 PxPyPzEVector momentum;
2192 const int nDaughters = 4;
2194 std::vector<int> daughterIndices;
2195 for (
int i = 0; i < nDaughters; i++) {
2196 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2197 momentum += d.get4Vector();
2198 Particle* newDaughters = particles.appendNew(d);
2204 ASSERT_NE(var,
nullptr);
2205 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422);
2208 ASSERT_NE(var,
nullptr);
2209 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400);
2212 ASSERT_NE(var,
nullptr);
2213 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200);
2217 TEST_F(MetaVariableTest, daughterMotherNormDiffOf)
2219 PxPyPzEVector momentum;
2220 const int nDaughters = 4;
2222 std::vector<int> daughterIndices;
2223 for (
int i = 0; i < nDaughters; i++) {
2224 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2225 momentum += d.get4Vector();
2226 Particle* newDaughters = particles.appendNew(d);
2232 ASSERT_NE(var,
nullptr);
2233 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422 / 400.);
2236 ASSERT_NE(var,
nullptr);
2237 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400 / 422.);
2240 ASSERT_NE(var,
nullptr);
2241 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200 / 622.);
2245 TEST_F(MetaVariableTest, constant)
2249 ASSERT_NE(var,
nullptr);
2250 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 1.0);
2253 ASSERT_NE(var,
nullptr);
2254 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 0.0);
2258 TEST_F(MetaVariableTest, abs)
2260 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
2261 Particle p2({ -0.1, -0.4, 0.8, 4.0 }, -11);
2264 ASSERT_NE(var,
nullptr);
2265 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
2266 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 0.1);
2270 TEST_F(MetaVariableTest, sin)
2272 Particle p({ 3.14159265359 / 2.0, -0.4, 0.8, 1.0}, 11);
2273 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2276 ASSERT_NE(var,
nullptr);
2277 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
2278 EXPECT_NEAR(std::get<double>(var->function(&p2)), 0.0, 1e-6);
2282 TEST_F(MetaVariableTest, cos)
2284 Particle p({ 3.14159265359 / 2.0, -0.4, 0.8, 1.0}, 11);
2285 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2288 ASSERT_NE(var,
nullptr);
2289 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.0, 1e-6);
2290 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 1.0);
2294 TEST_F(MetaVariableTest, NBDeltaIfMissingDeathTest)
2301 TEST_F(MetaVariableTest, matchedMC)
2306 particles.registerRelationTo(mcParticles);
2309 auto* mcParticle = mcParticles.
appendNew();
2312 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2313 p1->addRelationTo(mcParticle);
2318 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2319 p2->addRelationTo(mcParticle);
2324 auto* p3 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2325 p3->addRelationTo(mcParticle);
2328 auto* p4 = particles.appendNew(mcParticle);
2331 ASSERT_NE(var,
nullptr);
2332 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -1);
2333 EXPECT_FLOAT_EQ(std::get<double>(var->function(p2)), 1);
2334 EXPECT_FLOAT_EQ(std::get<double>(var->function(p3)), 0);
2335 EXPECT_FLOAT_EQ(std::get<double>(var->function(p4)), 0);
2338 TEST_F(MetaVariableTest, countInList)
2345 outputList.registerInDataStore(flags);
2347 outputList.create();
2348 outputList->initialize(22,
"pList1");
2363 ASSERT_NE(var,
nullptr);
2364 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 2);
2367 ASSERT_NE(var,
nullptr);
2368 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2371 ASSERT_NE(var,
nullptr);
2372 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 0);
2375 ASSERT_NE(var,
nullptr);
2376 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2379 TEST_F(MetaVariableTest, isInList)
2388 gammalist.registerInDataStore(flags);
2391 gammalist->initialize(22,
"testGammaList");
2396 auto* inthelist = particles.appendNew(goingin);
2397 auto* notinthelist = particles.appendNew(notgoingin);
2407 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(notinthelist)));
2408 EXPECT_TRUE(std::get<bool>(vsensible->
function(inthelist)));
2409 EXPECT_FALSE(std::get<bool>(vsensible->
function(notinthelist)));
2413 TEST_F(MetaVariableTest, cutIsInList)
2419 const std::string listname {
"wil/d(-+)'':l*"};
2423 particlelist.registerInDataStore(flags);
2425 particlelist.create();
2426 particlelist->initialize(22, listname);
2430 auto* inthelist = particles.appendNew(goingin);
2431 auto* notinthelist = particles.appendNew(notgoingin);
2440 EXPECT_B2FATAL(std::get<bool>(nonexistlist->
function(inthelist)));
2441 EXPECT_FALSE(std::get<bool>(existlist->
function(notinthelist)));
2442 EXPECT_TRUE(std::get<bool>(existlist->
function(inthelist)));
2445 TEST_F(MetaVariableTest, sourceObjectIsInList)
2457 particles.registerInDataStore();
2459 gammalist.registerInDataStore(flags);
2466 gammalist->initialize(22,
"testGammaList");
2471 cl0->setEnergy(1.0);
2472 cl0->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2473 cl0->addHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2474 cl0->setClusterId(0);
2476 cl1->setEnergy(1.0);
2477 cl1->setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2478 cl1->setClusterId(1);
2486 auto* myphoton_ = particles.appendNew(myphoton);
2487 gammalist->addParticle(myphoton_);
2489 auto* iscopied = particles.appendNew(iscopiedin);
2490 auto* notcopied = particles.appendNew(notcopiedin);
2497 EXPECT_B2FATAL(std::get<int>(vnonsense->
function(iscopied)));
2498 EXPECT_EQ(std::get<int>(vsensible->
function(iscopied)), 1);
2499 EXPECT_EQ(std::get<int>(vsensible->
function(notcopied)), 0);
2504 auto* composite_ = particles.appendNew(undefined);
2505 auto* undefined_ = particles.appendNew(composite);
2506 EXPECT_EQ(std::get<int>(vsensible->
function(composite_)), -1);
2507 EXPECT_EQ(std::get<int>(vsensible->
function(undefined_)), -1);
2510 TEST_F(MetaVariableTest, mcParticleIsInMCList)
2523 particles.registerInDataStore();
2524 particles.registerRelationTo(mcparticles);
2526 list.registerInDataStore(flags);
2527 anotherlist.registerInDataStore(flags);
2533 list->initialize(22,
"testList");
2535 anotherlist.create();
2536 anotherlist->initialize(22,
"supplimentaryList");
2539 auto* mcphoton = mcparticles.
appendNew();
2543 auto* mcelectron = mcparticles.
appendNew();
2547 auto* mcanotherelectron = mcparticles.
appendNew();
2551 auto* mcyetanotherelectron = mcparticles.
appendNew();
2556 auto* photon = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2557 photon->addRelationTo(mcphoton);
2558 list->addParticle(photon);
2560 auto* electron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2561 electron->addRelationTo(mcelectron);
2562 list->addParticle(electron);
2564 auto* other = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2565 other->addRelationTo(mcanotherelectron);
2567 auto* yetanotherelectron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2568 yetanotherelectron->addRelationTo(mcyetanotherelectron);
2569 anotherlist->addParticle(yetanotherelectron);
2577 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(photon)));
2578 EXPECT_TRUE(std::get<bool>(vsensible->
function(photon)));
2579 EXPECT_TRUE(std::get<bool>(vsensible->
function(electron)));
2580 EXPECT_FALSE(std::get<bool>(vsensible->
function(other)));
2581 EXPECT_FALSE(std::get<bool>(vsensible->
function(yetanotherelectron)));
2586 auto* composite_ = particles.appendNew(undefined);
2587 auto* undefined_ = particles.appendNew(composite);
2588 EXPECT_FALSE(std::get<bool>(vsensible->
function(composite_)));
2589 EXPECT_FALSE(std::get<bool>(vsensible->
function(undefined_)));
2592 TEST_F(MetaVariableTest, mostB2BAndClosestParticles)
2602 gearbox.setBackends({std::string(
"file:")});
2604 gearbox.open(
"geometry/Belle2.xml",
false);
2614 gammalist.registerInDataStore(flags);
2615 emptylist.registerInDataStore(flags);
2618 gammalist->initialize(22,
"testGammaList");
2620 emptylist->initialize(22,
"testEmptyList");
2623 std::vector<Particle> gammavector = {
2630 for (
const auto& g : gammavector)
2631 particles.appendNew(g);
2634 for (
size_t i = 0; i < gammavector.size(); i++)
2638 const auto* electron = particles.appendNew(
2648 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2651 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2654 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 0.68014491);
2657 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 0.67901474);
2665 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2668 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2671 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 3.4);
2674 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 3.2732551);
2677 EXPECT_FLOAT_EQ(std::get<double>(closestCMSLabE->function(electron)), 3.4);
2685 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2688 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2691 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 2.2869499);
2694 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 2.8312778);
2702 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2705 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2708 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 1.7);
2711 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 1.5848758);
2714 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMSLabE->function(electron)), 1.7);
2718 TEST_F(MetaVariableTest, totalEnergyOfParticlesInList)
2727 gammalist.registerInDataStore(flags);
2730 gammalist->initialize(22,
"testGammaList");
2733 std::vector<Particle> gammavector = {
2742 for (
const auto& g : gammavector)
2743 particles.appendNew(g);
2746 for (
size_t i = 0; i < gammavector.size(); i++)
2751 "totalEnergyOfParticlesInList(NONEXISTANTLIST)");
2753 "totalEnergyOfParticlesInList(testGammaList)");
2756 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2757 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 4.3);
2759 TEST_F(MetaVariableTest, totalPxOfParticlesInList)
2768 gammalist.registerInDataStore(flags);
2771 gammalist->initialize(22,
"testGammaList");
2774 std::vector<Particle> gammavector = {
2783 for (
const auto& g : gammavector)
2784 particles.appendNew(g);
2787 for (
size_t i = 0; i < gammavector.size(); i++)
2792 "totalPxOfParticlesInList(NONEXISTANTLIST)");
2794 "totalPxOfParticlesInList(testGammaList)");
2797 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2798 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 2.2);
2800 TEST_F(MetaVariableTest, totalPyOfParticlesInList)
2809 gammalist.registerInDataStore(flags);
2812 gammalist->initialize(22,
"testGammaList");
2815 std::vector<Particle> gammavector = {
2824 for (
const auto& g : gammavector)
2825 particles.appendNew(g);
2828 for (
size_t i = 0; i < gammavector.size(); i++)
2833 "totalPyOfParticlesInList(NONEXISTANTLIST)");
2835 "totalPyOfParticlesInList(testGammaList)");
2838 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2839 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 1.5);
2841 TEST_F(MetaVariableTest, totalPzOfParticlesInList)
2850 gammalist.registerInDataStore(flags);
2853 gammalist->initialize(22,
"testGammaList");
2856 std::vector<Particle> gammavector = {
2865 for (
const auto& g : gammavector)
2866 particles.appendNew(g);
2869 for (
size_t i = 0; i < gammavector.size(); i++)
2874 "totalPzOfParticlesInList(NONEXISTANTLIST)");
2876 "totalPzOfParticlesInList(testGammaList)");
2879 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2880 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 3.1);
2882 TEST_F(MetaVariableTest, maxPtInList)
2891 gammalist.registerInDataStore(flags);
2894 gammalist->initialize(22,
"testGammaList");
2897 std::vector<Particle> gammavector = {
2906 for (
const auto& g : gammavector)
2907 particles.appendNew(g);
2910 for (
size_t i = 0; i < gammavector.size(); i++)
2915 "maxPtInList(NONEXISTANTLIST)");
2917 "maxPtInList(testGammaList)");
2920 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2921 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)),
sqrt(0.5 * 0.5 + 0.4 * 0.4));
2925 TEST_F(MetaVariableTest, numberOfNonOverlappingParticles)
2932 outputList.registerInDataStore(flags);
2934 outputList.create();
2935 outputList->initialize(22,
"pList1");
2945 ASSERT_NE(var,
nullptr);
2946 EXPECT_EQ(std::get<int>(var->function(p1)), 1);
2947 EXPECT_EQ(std::get<int>(var->function(p2)), 1);
2948 EXPECT_EQ(std::get<int>(var->function(p3)), 2);
2952 TEST_F(MetaVariableTest, veto)
2957 const Particle* p = particles.appendNew(
Particle({0.8, 0.8, 1.131370849898476039041351, 1.6}, 22,
2962 outputList.registerInDataStore(flags);
2964 outputList.create();
2965 outputList->initialize(22,
"pList1");
2967 particles.appendNew(
Particle({0.5, 0.4953406774856531014212777, 0.5609256753154148484773173, 0.9}, 22,
2982 outputList2.registerInDataStore(flags);
2984 outputList2.create();
2985 outputList2->initialize(22,
"pList2");
3000 ASSERT_NE(var,
nullptr);
3001 EXPECT_TRUE(std::get<bool>(var->function(p)));
3004 ASSERT_NE(var,
nullptr);
3005 EXPECT_FALSE(std::get<bool>(var->function(p)));
3009 TEST_F(MetaVariableTest, averageValueInList)
3018 gammalist.registerInDataStore(flags);
3021 gammalist->initialize(22,
"testGammaList");
3024 std::vector<Particle> gammavector = {
3033 for (
const auto& g : gammavector)
3034 particles.appendNew(g);
3037 for (
size_t i = 0; i < gammavector.size(); i++)
3042 "averageValueInList(testGammaList, px)");
3044 "averageValueInList(testGammaList, py)");
3046 "averageValueInList(testGammaList, pz)");
3048 "averageValueInList(testGammaList, E)");
3050 EXPECT_FLOAT_EQ(std::get<double>(vmeanpx->
function(
nullptr)), 0.44);
3051 EXPECT_FLOAT_EQ(std::get<double>(vmeanpy->
function(
nullptr)), 0.3);
3052 EXPECT_FLOAT_EQ(std::get<double>(vmeanpz->
function(
nullptr)), 0.6);
3053 EXPECT_FLOAT_EQ(std::get<double>(vmeanE->
function(
nullptr)), 0.86);
3056 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"averageValueInList(testGammaList)"));
3059 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"averageValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3063 "averageValueInList(NONEXISTANTLIST, px)");
3065 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3068 TEST_F(MetaVariableTest, medianValueInList)
3077 oddgammalist.registerInDataStore(flags);
3079 oddgammalist.create();
3080 oddgammalist->initialize(22,
"oddGammaList");
3083 evengammalist.registerInDataStore(flags);
3085 evengammalist.create();
3086 evengammalist->initialize(22,
"evenGammaList");
3089 std::vector<Particle> gammavector = {
3098 for (
const auto& g : gammavector)
3099 particles.appendNew(g);
3103 for (
size_t i = 1; i < gammavector.size(); i++) {
3110 "medianValueInList(oddGammaList, px)");
3112 "medianValueInList(oddGammaList, py)");
3114 "medianValueInList(oddGammaList, pz)");
3116 "medianValueInList(oddGammaList, E)");
3118 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpx->
function(
nullptr)), 0.5);
3119 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpy->
function(
nullptr)), 0.3);
3120 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpz->
function(
nullptr)), 0.7);
3121 EXPECT_FLOAT_EQ(std::get<double>(voddmedianE->
function(
nullptr)), 0.9);
3125 "medianValueInList(evenGammaList, px)");
3127 "medianValueInList(evenGammaList, py)");
3129 "medianValueInList(evenGammaList, pz)");
3131 "medianValueInList(evenGammaList, E)");
3133 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpx->
function(
nullptr)), 0.45);
3134 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpy->
function(
nullptr)), 0.25);
3135 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpz->
function(
nullptr)), 0.7);
3136 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianE->
function(
nullptr)), 0.9);
3139 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"medianValueInList(oddGammaList)"));
3142 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"medianValueInList(oddGammaList, NONEXISTANTVARIABLE)"));
3146 "medianValueInList(NONEXISTANTLIST, px)");
3148 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3151 TEST_F(MetaVariableTest, productValueInList)
3160 gammalist.registerInDataStore(flags);
3163 gammalist->initialize(22,
"testGammaList");
3166 std::vector<Particle> gammavector = {
3175 for (
const auto& g : gammavector)
3176 particles.appendNew(g);
3179 for (
size_t i = 0; i < gammavector.size(); i++)
3184 "productValueInList(testGammaList, px)");
3186 "productValueInList(testGammaList, py)");
3188 "productValueInList(testGammaList, pz)");
3190 "productValueInList(testGammaList, E)");
3192 EXPECT_FLOAT_EQ(std::get<double>(vproductpx->
function(
nullptr)), 0.015);
3193 EXPECT_FLOAT_EQ(std::get<double>(vproductpy->
function(
nullptr)), 0.00192);
3194 EXPECT_FLOAT_EQ(std::get<double>(vproductpz->
function(
nullptr)), 0.06272);
3195 EXPECT_FLOAT_EQ(std::get<double>(vproductE->
function(
nullptr)), 0.42768);
3198 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"productValueInList(testGammaList)"));
3201 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"productValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3205 "productValueInList(NONEXISTANTLIST, px)");
3207 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3210 TEST_F(MetaVariableTest, sumValueInList)
3219 gammalist.registerInDataStore(flags);
3222 gammalist->initialize(22,
"testGammaList");
3225 std::vector<Particle> gammavector = {
3234 for (
const auto& g : gammavector)
3235 particles.appendNew(g);
3238 for (
size_t i = 0; i < gammavector.size(); i++)
3243 "sumValueInList(testGammaList, px)");
3245 "sumValueInList(testGammaList, py)");
3247 "sumValueInList(testGammaList, pz)");
3249 "sumValueInList(testGammaList, E)");
3251 EXPECT_FLOAT_EQ(std::get<double>(vsumpx->
function(
nullptr)), 2.2);
3252 EXPECT_FLOAT_EQ(std::get<double>(vsumpy->
function(
nullptr)), 1.5);
3253 EXPECT_FLOAT_EQ(std::get<double>(vsumpz->
function(
nullptr)), 3.0);
3254 EXPECT_FLOAT_EQ(std::get<double>(vsumE->
function(
nullptr)), 4.3);
3257 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"sumValueInList(testGammaList)"));
3260 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"sumValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3264 "sumValueInList(NONEXISTANTLIST, px)");
3266 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3269 TEST_F(MetaVariableTest, pValueCombination)
3271 PxPyPzEVector momentum;
3273 std::vector<int> daughterIndices;
3276 momentum += KS.get4Vector();
3277 Particle* newDaughters = particles.appendNew(KS);
3280 Jpsi.setPValue(0.9);
3281 momentum += Jpsi.get4Vector();
3282 newDaughters = particles.appendNew(Jpsi);
3288 ASSERT_NE(singlePvalue,
nullptr);
3289 EXPECT_FLOAT_EQ(std::get<double>(singlePvalue->
function(B)), 0.5);
3292 ASSERT_NE(twoPvalues,
nullptr);
3293 EXPECT_FLOAT_EQ(std::get<double>(twoPvalues->
function(B)), 0.05 * (1 - log(0.05)));
3297 ASSERT_NE(threePvalues,
nullptr);
3298 EXPECT_FLOAT_EQ(std::get<double>(threePvalues->
function(B)), 0.045 * (1 - log(0.045) + 0.5 * log(0.045) * log(0.045)));
3304 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"pValueCombination(chiProb, NONEXISTANTVARIABLE)"));
3308 TEST_F(MetaVariableTest, daughterCombinationOneGeneration)
3310 const int nDaughters = 5;
3311 PxPyPzEVector momentum(0, 0, 0, 0);
3313 std::vector<int> daughterIndices;
3314 std::vector<PxPyPzEVector> daughterMomenta;
3316 for (
int i = 0; i < nDaughters; i++) {
3317 PxPyPzEVector mom(1, i * 0.5, 1, i * 1.0 + 2.0);
3318 Particle d(mom, (i % 2) ? 111 : 113);
3319 Particle* newDaughters = particles.appendNew(d);
3321 daughterMomenta.push_back(mom);
3322 momentum = momentum + mom;
3328 double M_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[2]).mag();
3329 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3332 M_test = (daughterMomenta[0] + daughterMomenta[4]).mag();
3333 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3338 double p_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[4]).P();
3339 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), p_test);
3343 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"daughterCombination(aVeryNonExistingVariableSillyName, 1, 0, 4)"));
3346 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3347 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3351 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3352 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3356 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3357 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3362 TEST_F(MetaVariableTest, daughterCombinationTwoGenerations)
3368 PxPyPzEVector momentum_1(0, 0, 0, 0);
3369 std::vector<PxPyPzEVector> daughterMomenta_1;
3370 std::vector<int> daughterIndices_1;
3372 for (
int i = 0; i < 3; i++) {
3373 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3374 Particle d(mom, (i % 2) ? 111 : 113);
3375 Particle* newDaughters = particles.appendNew(d);
3377 daughterMomenta_1.push_back(mom);
3378 momentum_1 = momentum_1 + mom;
3386 PxPyPzEVector momentum_2(0, 0, 0, 0);
3387 std::vector<PxPyPzEVector> daughterMomenta_2;
3388 std::vector<int> daughterIndices_2;
3390 for (
int i = 0; i < 2; i++) {
3391 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3392 Particle d(mom, (i % 2) ? 111 : 113);
3393 Particle* newDaughters = particles.appendNew(d);
3395 daughterMomenta_2.push_back(mom);
3396 momentum_2 = momentum_2 + mom;
3410 double M_test = (momentum_1 + momentum_2).mag();
3411 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3415 M_test = (momentum_1).mag();
3416 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3420 M_test = (daughterMomenta_1[0] + daughterMomenta_1[1] + daughterMomenta_2[0]).mag();
3421 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3426 TEST_F(MetaVariableTest, useAlternativeDaughterHypothesis)
3428 const int nDaughters = 5;
3432 PxPyPzEVector momentum(0, 0, 0, 0);
3433 std::vector<int> daughterIndices;
3434 for (
int i = 0; i < nDaughters; i++) {
3435 double px = i * 0.1;
3436 double py = i * 0.3;
3437 double pz = -i * 0.1 - 0.2;
3439 PxPyPzEVector mom(px, py, pz, 1);
3443 d.updateMass(pdgCode);
3444 mom = d.get4Vector();
3446 Particle* daughters = particles.appendNew(d);
3448 momentum = momentum + mom;
3454 PxPyPzEVector momentumAlt(0, 0, 0, 0);
3455 std::vector<int> daughterIndicesAlt;
3456 for (
int i = 0; i < nDaughters; i++) {
3457 double px = i * 0.1;
3458 double py = i * 0.3;
3459 double pz = -i * 0.1 - 0.2;
3461 PxPyPzEVector mom(px, py, pz, 1);
3469 d.updateMass(pdgCode);
3470 mom = d.get4Vector();
3472 Particle* daughters = particles.appendNew(d);
3474 momentumAlt = momentumAlt + mom;
3480 std::cout <<
"mass test" << std::endl;
3483 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3486 std::cout <<
"charge test" << std::endl;
3488 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3491 std::cout <<
"momentum test" << std::endl;
3494 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3495 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(p)));
3496 EXPECT_FLOAT_EQ(std::get<double>(var->function(pAlt)), std::get<double>(varAlt->
function(pAlt)));
3502 TEST_F(MetaVariableTest, daughterAngle)
3508 PxPyPzEVector momentum_1(0, 0, 0, 0);
3509 std::vector<PxPyPzEVector> daughterMomenta_1;
3510 std::vector<int> daughterIndices_1;
3512 for (
int i = 0; i < 3; i++) {
3513 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3514 Particle d(mom, (i % 2) ? -11 : 211);
3515 Particle* newDaughters = particles.appendNew(d);
3517 daughterMomenta_1.push_back(mom);
3518 momentum_1 = momentum_1 + mom;
3526 PxPyPzEVector momentum_2(0, 0, 0, 0);
3527 std::vector<PxPyPzEVector> daughterMomenta_2;
3528 std::vector<int> daughterIndices_2;
3530 for (
int i = 0; i < 2; i++) {
3531 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3532 Particle d(mom, (i % 2) ? -11 : 211);
3533 Particle* newDaughters = particles.appendNew(d);
3535 daughterMomenta_2.push_back(mom);
3536 momentum_2 = momentum_2 + mom;
3549 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3551 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3555 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3556 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3559 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3560 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3563 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3564 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3568 TEST_F(MetaVariableTest, mcDaughterVariables)
3574 particles.registerRelationTo(mcParticles);
3578 PxPyPzEVector momentum_1(0, 0, 0, 0);
3579 std::vector<PxPyPzEVector> daughterMomenta_1;
3580 std::vector<int> daughterIndices_1;
3582 for (
int i = 0; i < 3; i++) {
3583 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3584 Particle d(mom, (i % 2) ? -11 : 211);
3585 Particle* newDaughters = particles.appendNew(d);
3587 daughterMomenta_1.push_back(mom);
3588 momentum_1 = momentum_1 + mom;
3590 auto* mcParticle = mcParticles.
appendNew();
3593 mcParticle->set4Vector(mom);
3598 auto* mcCompositeDau_1 = mcParticles.
appendNew();
3599 mcCompositeDau_1->setPDG(411);
3601 mcCompositeDau_1->set4Vector(momentum_1);
3606 PxPyPzEVector momentum_2(0, 0, 0, 0);
3607 std::vector<PxPyPzEVector> daughterMomenta_2;
3608 std::vector<int> daughterIndices_2;
3610 for (
int i = 0; i < 2; i++) {
3611 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3612 Particle d(mom, (i % 2) ? -11 : 211);
3613 Particle* newDaughters = particles.appendNew(d);
3615 daughterMomenta_2.push_back(mom);
3616 momentum_2 = momentum_2 + mom;
3618 auto* mcParticle = mcParticles.
appendNew();
3621 mcParticle->set4Vector(mom);
3626 auto* mcCompositeDau_2 = mcParticles.
appendNew();
3627 mcCompositeDau_2->setPDG(411);
3629 mcCompositeDau_2->set4Vector(momentum_2);
3639 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3640 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3643 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3644 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3647 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3648 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3651 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3652 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3656 ASSERT_NE(var,
nullptr);
3657 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
3660 ASSERT_NE(var,
nullptr);
3661 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3665 ASSERT_NE(var,
nullptr);
3666 v_test = momentum_2.Phi() - momentum_1.Phi();
3667 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3671 TEST_F(MetaVariableTest, varForFirstMCAncestorOfType)
3676 particles.registerInDataStore();
3678 particles.registerRelationTo(mcParticles);
3680 DList.registerInDataStore();
3682 DList->initialize(421,
"D0:vartest");
3684 PxPyPzEVector momentum;
3685 PxPyPzEVector momentum_0;
3686 PxPyPzEVector momentum_1;
3687 std::vector<int> D_daughterIndices;
3688 std::vector<int> D_grandDaughterIndices_0;
3689 std::vector<int> D_grandDaughterIndices_1;
3707 mcg_d_0.
set4Vector(PxPyPzEVector(6, 6, 6, 6));
3709 mcg_d_1.
set4Vector(PxPyPzEVector(5, 5, 5, 5));
3711 mcg_gd_0_0.
set4Vector(PxPyPzEVector(4, 4, 4, 4));
3713 mcg_gd_0_1.
set4Vector(PxPyPzEVector(3, 3, 3, 3));
3715 mcg_gd_1_0.
set4Vector(PxPyPzEVector(2, 1, 2, 2));
3717 mcg_gd_1_1.
set4Vector(PxPyPzEVector(1, 1, 1, 1));
3719 mcg_not_child.
set4Vector(PxPyPzEVector(10, 10, 10, 10));
3731 auto* mc_not_child = mcParticles[0];
3732 auto* mc_m = mcParticles[1];
3733 auto* mc_d_0 = mcParticles[2];
3734 auto* mc_d_1 = mcParticles[3];
3735 auto* mc_gd_0_0 = mcParticles[4];
3736 auto* mc_gd_0_1 = mcParticles[5];
3737 auto* mc_gd_1_0 = mcParticles[6];
3738 auto* mc_gd_1_1 = mcParticles[7];
3752 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
3753 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
3754 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
3755 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
3757 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3758 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3759 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3760 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3774 DList->addParticle(D_m);
3777 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
3780 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
3794 ASSERT_NE(var_d,
nullptr);
3795 EXPECT_TRUE(std::get<double>(var_d->
function(D_gd_0_0)) >= 0);
3796 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_0_1)));
3797 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_1_0)), std::get<double>(var_d->
function(D_gd_1_1)));
3798 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_1_0)));
3799 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_1)), std::get<double>(var_d->
function(D_gd_1_1)));
3800 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child))));
3801 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child_2))));
3806 ASSERT_NE(var_310,
nullptr);
3807 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_0_1)));
3808 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_1_0)), std::get<double>(var_310->
function(D_gd_1_1)));
3809 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_1_0)));
3810 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_1)), std::get<double>(var_310->
function(D_gd_1_1)));
3811 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child))));
3812 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child_2))));
3813 EXPECT_FLOAT_EQ(
int(std::get<double>(
Manager::Instance().getVariable(
"varForFirstMCAncestorOfType(310, E)")->function(D_gd_0_0))),
3817 TEST_F(MetaVariableTest, isDescendantOfList)
3821 DList.registerInDataStore();
3823 DList->initialize(421,
"D0:vartest");
3825 BList.registerInDataStore();
3827 BList->initialize(521,
"B:vartest");
3830 PxPyPzEVector momentum;
3831 PxPyPzEVector momentum_0;
3832 PxPyPzEVector momentum_1;
3834 std::vector<int> D_daughterIndices;
3835 std::vector<int> D_grandDaughterIndices_0;
3836 std::vector<int> D_grandDaughterIndices_1;
3837 std::vector<int> B_daughterIndices;
3838 std::vector<int> B_grandDaughterIndices;
3839 std::vector<int> B_grandGrandDaughterIndices;
3848 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3849 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3850 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3851 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3865 DList->addParticle(D_m);
3874 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_0->
getArrayIndex());
3875 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_1->
getArrayIndex());
3879 B_grandDaughterIndices.push_back(B_gd_0_0->
getArrayIndex());
3880 B_grandDaughterIndices.push_back(B_gd_0_1->
getArrayIndex());
3888 BList->addParticle(B_m);
3895 ASSERT_NE(var_0,
nullptr);
3896 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_0)));
3897 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_1)));
3898 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_0)));
3899 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_1)));
3900 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_0)));
3901 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_1)));
3902 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_0)));
3903 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_1)));
3904 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_0)));
3905 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_1)));
3906 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_0)));
3907 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_1)));
3908 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
3911 ASSERT_NE(var_0a,
nullptr);
3912 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_0)));
3913 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_1)));
3914 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_0)));
3915 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_1)));
3916 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_0)));
3917 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_1)));
3918 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_0)));
3919 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_1)));
3920 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_0)));
3921 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_1)));
3922 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_0)));
3923 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_1)));
3924 EXPECT_FALSE(std::get<bool>(var_0a->
function(not_child)));
3927 ASSERT_NE(var_0b,
nullptr);
3928 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_0)));
3929 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_1)));
3930 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_0)));
3931 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_1)));
3932 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_0)));
3933 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_1)));
3934 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_0)));
3935 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_1)));
3936 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_0)));
3937 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_1)));
3938 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_0)));
3939 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_1)));
3940 EXPECT_FALSE(std::get<bool>(var_0b->
function(not_child)));
3943 ASSERT_NE(var_1,
nullptr);
3944 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
3945 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
3946 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
3947 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
3948 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_0)));
3949 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_1)));
3950 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_0)));
3951 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_1)));
3952 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_0)));
3953 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_1)));
3954 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_0)));
3955 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_1)));
3956 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
3959 ASSERT_NE(var_2,
nullptr);
3960 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_0)));
3961 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_1)));
3962 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_0)));
3963 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_1)));
3964 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
3965 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
3966 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_0)));
3967 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_1)));
3968 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_0)));
3969 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_1)));
3970 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_0)));
3971 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_1)));
3972 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
3975 ASSERT_NE(var_3,
nullptr);
3976 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_0)));
3977 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_1)));
3978 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_0)));
3979 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_1)));
3980 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_0)));
3981 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_1)));
3982 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_0)));
3983 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_1)));
3984 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_0)));
3985 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_1)));
3986 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_0)));
3987 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_1)));
3988 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
3991 ASSERT_NE(var_4,
nullptr);
3992 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_0)));
3993 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_1)));
3994 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_0)));
3995 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_1)));
3996 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_0)));
3997 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_1)));
3998 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_0)));
3999 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_1)));
4000 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_0)));
4001 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_1)));
4002 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_0)));
4003 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_1)));
4004 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
4007 ASSERT_NE(var_5,
nullptr);
4008 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
4009 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
4010 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
4011 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
4012 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_0)));
4013 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_1)));
4014 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_0)));
4015 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_1)));
4016 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_0)));
4017 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_1)));
4018 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_0)));
4019 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_1)));
4020 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
4023 ASSERT_NE(var_6,
nullptr);
4024 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_0)));
4025 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_1)));
4026 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_0)));
4027 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_1)));
4028 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_0)));
4029 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_1)));
4030 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_0)));
4031 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_1)));
4032 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_0)));
4033 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_1)));
4034 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_0)));
4035 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_1)));
4036 EXPECT_FALSE(std::get<bool>(var_6->
function(not_child)));
4039 ASSERT_NE(var_7,
nullptr);
4040 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_0)));
4041 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_1)));
4042 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_0)));
4043 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_1)));
4044 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_0)));
4045 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_1)));
4046 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_0)));
4047 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_1)));
4048 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_0)));
4049 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_1)));
4050 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_0)));
4051 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_1)));
4052 EXPECT_FALSE(std::get<bool>(var_7->
function(not_child)));
4056 TEST_F(MetaVariableTest, isMCDescendantOfList)
4061 particles.registerInDataStore();
4063 particles.registerRelationTo(mcParticles);
4065 BList.registerInDataStore();
4067 BList->initialize(521,
"B:vartest");
4069 DList.registerInDataStore();
4071 DList->initialize(421,
"D0:vartest");
4073 PxPyPzEVector momentum;
4074 PxPyPzEVector momentum_0;
4075 PxPyPzEVector momentum_1;
4076 std::vector<int> daughterIndices;
4077 std::vector<int> grandDaughterIndices;
4078 std::vector<int> grandGrandDaughterIndices;
4079 std::vector<int> D_daughterIndices;
4080 std::vector<int> D_grandDaughterIndices_0;
4081 std::vector<int> D_grandDaughterIndices_1;
4115 auto* mc_m = mcParticles[0];
4116 auto* mc_d_0 = mcParticles[1];
4117 auto* mc_d_1 = mcParticles[2];
4118 auto* mc_gd_0_0 = mcParticles[3];
4119 auto* mc_gd_0_1 = mcParticles[4];
4120 auto* mc_ggd_0_0_0 = mcParticles[5];
4121 auto* mc_ggd_0_0_1 = mcParticles[6];
4122 auto* mc_not_child = mcParticles[7];
4135 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4136 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4137 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4138 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4140 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
4141 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
4142 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
4143 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
4157 DList->addParticle(D_m);
4160 const Particle* d_1 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4161 const Particle* gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4162 const Particle* ggd_0_0_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4163 const Particle* ggd_0_0_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4165 grandGrandDaughterIndices.push_back(ggd_0_0_0->
getArrayIndex());
4166 grandGrandDaughterIndices.push_back(ggd_0_0_1->
getArrayIndex());
4179 BList->addParticle(m);
4182 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
4185 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
4193 m->addRelationTo(mc_m);
4197 ASSERT_NE(var_0,
nullptr);
4198 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_0)));
4199 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_1)));
4200 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_0)));
4201 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_1)));
4202 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_0)));
4203 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_1)));
4204 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_0)));
4205 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_1)));
4206 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_0)));
4207 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_1)));
4208 EXPECT_TRUE(std::get<bool>(var_0->
function(d_0)));
4209 EXPECT_TRUE(std::get<bool>(var_0->
function(d_1)));
4210 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
4211 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child_2)));
4214 ASSERT_NE(var_1,
nullptr);
4215 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
4216 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
4217 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
4218 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
4219 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_0)));
4220 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_1)));
4221 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_0)));
4222 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_1)));
4223 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_0)));
4224 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_1)));
4225 EXPECT_TRUE(std::get<bool>(var_1->
function(d_0)));
4226 EXPECT_TRUE(std::get<bool>(var_1->
function(d_1)));
4227 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
4228 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child_2)));
4231 ASSERT_NE(var_2,
nullptr);
4232 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_0)));
4233 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_1)));
4234 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_0)));
4235 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_1)));
4236 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
4237 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
4238 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_0)));
4239 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_1)));
4240 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_0)));
4241 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_1)));
4242 EXPECT_TRUE(std::get<bool>(var_2->
function(d_0)));
4243 EXPECT_TRUE(std::get<bool>(var_2->
function(d_1)));
4244 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
4245 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child_2)));
4248 ASSERT_NE(var_3,
nullptr);
4249 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_0)));
4250 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_1)));
4251 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_0)));
4252 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_1)));
4253 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_0)));
4254 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_1)));
4255 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_0)));
4256 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_1)));
4257 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_0)));
4258 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_1)));
4259 EXPECT_TRUE(std::get<bool>(var_3->
function(d_0)));
4260 EXPECT_TRUE(std::get<bool>(var_3->
function(d_1)));
4261 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
4262 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child_2)));
4265 ASSERT_NE(var_4,
nullptr);
4266 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_0)));
4267 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_1)));
4268 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_0)));
4269 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_1)));
4270 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_0)));
4271 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_1)));
4272 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_0)));
4273 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_1)));
4274 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_0)));
4275 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_1)));
4276 EXPECT_FALSE(std::get<bool>(var_4->
function(d_0)));
4277 EXPECT_FALSE(std::get<bool>(var_4->
function(d_1)));
4278 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
4279 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child_2)));
4283 ASSERT_NE(var_5,
nullptr);
4284 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
4285 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
4286 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
4287 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
4288 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_0)));
4289 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_1)));
4290 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_0)));
4291 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_1)));
4292 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_0)));
4293 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_1)));
4294 EXPECT_FALSE(std::get<bool>(var_5->
function(d_0)));
4295 EXPECT_FALSE(std::get<bool>(var_5->
function(d_1)));
4296 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
4297 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child_2)));
4304 class PIDVariableTest :
public ::testing::Test {
4307 void SetUp()
override
4320 particles.registerInDataStore();
4321 tracks.registerInDataStore();
4322 particles.registerRelationTo(likelihood);
4323 tracks.registerRelationTo(likelihood);
4328 void TearDown()
override
4334 TEST_F(PIDVariableTest, LogLikelihood)
4343 const float pValue = 0.5;
4344 const float bField = 1.5;
4346 TMatrixDSym cov6(6);
4348 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4349 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4350 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4352 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4353 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4355 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4359 Track* allTrack = tracks.appendNew(mytrack);
4360 Track* noSVDTrack = tracks.appendNew(mytrack);
4361 Track* noPIDTrack = tracks.appendNew(mytrack);
4362 Track* dEdxTrack = tracks.appendNew(mytrack);
4375 lAll->setLogLikelihood(Const::TOP,
Const::muon, 0.5);
4376 lAll->setLogLikelihood(Const::ARICH,
Const::muon, 0.52);
4377 lAll->setLogLikelihood(Const::ECL,
Const::muon, 0.54);
4378 lAll->setLogLikelihood(Const::CDC,
Const::muon, 0.56);
4379 lAll->setLogLikelihood(Const::SVD,
Const::muon, 0.58);
4380 lAll->setLogLikelihood(Const::KLM,
Const::muon, 0.8);
4382 lAll->setLogLikelihood(Const::TOP,
Const::pion, 0.2);
4383 lAll->setLogLikelihood(Const::ARICH,
Const::pion, 0.22);
4384 lAll->setLogLikelihood(Const::ECL,
Const::pion, 0.24);
4385 lAll->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4386 lAll->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4387 lAll->setLogLikelihood(Const::KLM,
Const::pion, 0.2);
4389 lAll->setLogLikelihood(Const::TOP,
Const::kaon, 0.3);
4390 lAll->setLogLikelihood(Const::ARICH,
Const::kaon, 0.32);
4391 lAll->setLogLikelihood(Const::ECL,
Const::kaon, 0.34);
4392 lAll->setLogLikelihood(Const::CDC,
Const::kaon, 0.36);
4393 lAll->setLogLikelihood(Const::SVD,
Const::kaon, 0.38);
4394 lAll->setLogLikelihood(Const::KLM,
Const::kaon, 0.2);
4411 auto* lAllNoSVD = likelihood.
appendNew();
4415 if (det != Const::SVD) {
4416 lAllNoSVD->setLogLikelihood(det, hypo, lAll->getLogL(hypo, det));
4426 ldEdx->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4427 ldEdx->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4429 ldEdx->setLogLikelihood(Const::CDC,
Const::kaon, 0.36);
4430 ldEdx->setLogLikelihood(Const::SVD,
Const::kaon, 0.38);
4435 ldEdx->setLogLikelihood(Const::CDC,
Const::muon, 0.56);
4436 ldEdx->setLogLikelihood(Const::SVD,
Const::muon, 0.58);
4454 auto* particleAll = particles.appendNew(allTrack,
Const::pion);
4455 auto* particleNoSVD = particles.appendNew(noSVDTrack,
Const::pion);
4456 auto* particledEdx = particles.appendNew(dEdxTrack,
Const::pion);
4457 auto* particleNoID = particles.appendNew(noPIDTrack,
Const::pion);
4459 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);
4460 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);
4463 EXPECT_FLOAT_EQ(electronID(particleAll), std::exp(0.71) / numsumexp);
4464 EXPECT_FLOAT_EQ(muonID(particleAll), std::exp(3.5) / numsumexp);
4465 EXPECT_FLOAT_EQ(pionID(particleAll), std::exp(1.4) / numsumexp);
4466 EXPECT_FLOAT_EQ(kaonID(particleAll), std::exp(1.9) / numsumexp);
4467 EXPECT_FLOAT_EQ(protonID(particleAll), std::exp(2.22) / numsumexp);
4468 EXPECT_FLOAT_EQ(deuteronID(particleAll), std::exp(3.22) / numsumexp);
4471 auto* particleElectron = particles.appendNew(allTrack,
Const::electron);
4472 auto* particleMuon = particles.appendNew(allTrack,
Const::muon);
4473 auto* particleKaon = particles.appendNew(allTrack,
Const::kaon);
4474 auto* particleProton = particles.appendNew(allTrack,
Const::proton);
4475 auto* particleDeuteron = particles.appendNew(allTrack,
Const::deuteron);
4477 EXPECT_FLOAT_EQ(particleID(particleAll), std::exp(1.4) / numsumexp);
4478 EXPECT_FLOAT_EQ(particleID(particleElectron), std::exp(0.71) / numsumexp);
4479 EXPECT_FLOAT_EQ(particleID(particleMuon), std::exp(3.5) / numsumexp);
4480 EXPECT_FLOAT_EQ(particleID(particleKaon), std::exp(1.9) / numsumexp);
4481 EXPECT_FLOAT_EQ(particleID(particleProton), std::exp(2.22) / numsumexp);
4482 EXPECT_FLOAT_EQ(particleID(particleDeuteron), std::exp(3.22) / numsumexp);
4485 EXPECT_FLOAT_EQ(electronID_noSVD(particleNoSVD), std::exp(0.61) / numsumexp_noSVD);
4486 EXPECT_FLOAT_EQ(muonID_noSVD(particleNoSVD), std::exp(2.92) / numsumexp_noSVD);
4487 EXPECT_FLOAT_EQ(pionID_noSVD(particleNoSVD), std::exp(1.12) / numsumexp_noSVD);
4488 EXPECT_FLOAT_EQ(kaonID_noSVD(particleNoSVD), std::exp(1.52) / numsumexp_noSVD);
4489 EXPECT_FLOAT_EQ(protonID_noSVD(particleNoSVD), std::exp(1.74) / numsumexp_noSVD);
4490 EXPECT_FLOAT_EQ(deuteronID_noSVD(particleNoSVD), std::exp(2.54) / numsumexp_noSVD);
4493 std::vector<double> v_pi_K {211., 321.};
4494 std::vector<double> v_pi_p {211., 2212.};
4495 std::vector<double> v_K_p {321., 2212.};
4496 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_K), std::exp(1.4) / (std::exp(1.4) + std::exp(1.9)));
4497 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_p), std::exp(1.4) / (std::exp(1.4) + std::exp(2.22)));
4498 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_K_p), std::exp(1.9) / (std::exp(1.9) + std::exp(2.22)));
4501 EXPECT_TRUE(std::isnan(electronID(particleNoID)));
4502 EXPECT_TRUE(std::isnan(muonID(particleNoID)));
4503 EXPECT_TRUE(std::isnan(pionID(particleNoID)));
4504 EXPECT_TRUE(std::isnan(kaonID(particleNoID)));
4505 EXPECT_TRUE(std::isnan(protonID(particleNoID)));
4506 EXPECT_TRUE(std::isnan(deuteronID(particleNoID)));
4509 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->function(particleAll)),
4511 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, ALL)")->function(particleAll)),
4513 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(2212, TOP, CDC)")->function(
4514 particleAll)), 0.86);
4517 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(1000010020, ALL)")->function(particleAll)),
4518 std::exp(3.22) / numsumexp);
4519 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(2212, ALL)")->function(particleAll)),
4520 std::exp(2.22) / numsumexp);
4521 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particleAll)),
4522 std::exp(1.4) / numsumexp);
4523 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(321, ALL)")->function(particleAll)),
4524 std::exp(1.9) / numsumexp);
4525 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(13, ALL)")->function(particleAll)),
4526 std::exp(3.5) / numsumexp);
4527 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(11, ALL)")->function(particleAll)),
4528 std::exp(0.71) / numsumexp);
4529 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particledEdx)),
4530 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)));
4531 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->function(particledEdx)),
4532 std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC, SVD)")->function(particleAll)));
4533 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->function(particledEdx)),
4534 std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->function(particleAll)));
4535 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidProbabilityExpert(321, CDC)")->function(particleAll)),
4536 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)));
4539 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->function(
4541 1.0 / (1.0 + std::exp(2.22 - 1.9)));
4542 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->function(
4544 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4545 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, CDC, SVD)")->function(
4547 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4550 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->function(
4552 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP, CDC, SVD)")->function(
4554 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->function(
4556 EXPECT_TRUE(std::isnan(std::get<double>(
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->function(
4558 EXPECT_TRUE(std::isnan(std::get<double>
4559 (
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH)")->function(
4561 EXPECT_FALSE(std::isnan(std::get<double>
4562 (
Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH, SVD)")->function(
4565 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG()")->function(particledEdx)), 1.00001e+09);
4566 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.5, 0.1, 0.1, 0.1, 0.1, 0.1)")->function(
4569 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.5, 0.1, 0.1, 0.1, 0.1)")->function(
4572 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.5, 0.1, 0.1, 0.1)")->function(
4575 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.5, 0.1, 0.1)")->function(
4578 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.1, 0.5, 0.1)")->function(
4581 EXPECT_FLOAT_EQ(std::get<double>(
Manager::Instance().getVariable(
"pidMostLikelyPDG(0, 1., 0, 0, 0, 0)")->function(particledEdx)),
4585 TEST_F(PIDVariableTest, MissingLikelihood)
4594 const float pValue = 0.5;
4595 const float bField = 1.5;
4597 TMatrixDSym cov6(6);
4599 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4600 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4601 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4603 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4604 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4606 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4610 Track* savedTrack1 = tracks.appendNew(mytrack);
4611 Track* savedTrack2 = tracks.appendNew(mytrack);
4612 Track* savedTrack3 = tracks.appendNew(mytrack);
4613 Track* savedTrack4 = tracks.appendNew(mytrack);
4623 l2->setLogLikelihood(Const::TOP,
Const::pion, 0.2);
4624 l2->setLogLikelihood(Const::ARICH,
Const::pion, 0.22);
4625 l2->setLogLikelihood(Const::ECL,
Const::pion, 0.24);
4626 l2->setLogLikelihood(Const::CDC,
Const::pion, 0.26);
4627 l2->setLogLikelihood(Const::SVD,
Const::pion, 0.28);
4630 auto* pion = particles.appendNew(savedTrack2,
Const::pion);
4633 l3->setLogLikelihood(Const::TOP,
Const::kaon, 0.3);
4634 l3->setLogLikelihood(Const::ARICH,
Const::kaon, 0.32);
4637 auto* kaon = particles.appendNew(savedTrack3,
Const::kaon);
4646 auto* proton = particles.appendNew(savedTrack4,
Const::proton);
4653 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(electron)), 0.0);
4654 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(pion)), 0.0);
4655 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(kaon)), 0.0);
4656 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(proton)), 1.0);
4658 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(electron)), 1.0);
4659 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(pion)), 0.0);
4660 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(kaon)), 0.0);
4661 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(proton)), 0.0);
4663 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(electron)), 0.0);
4664 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(pion)), 0.0);
4665 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(kaon)), 1.0);
4666 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(proton)), 0.0);
4669 class FlightInfoTest :
public ::testing::Test {
4672 void SetUp()
override
4679 particles.registerRelationTo(mcParticles);
4707 PxPyPzEVector momentum;
4708 TMatrixFSym error(7);
4715 error(5, 5) = 0.00875;
4717 Particle pi(PxPyPzEVector(1.59607, 1.19705, 0, 2), 211);
4718 momentum += pi.get4Vector();
4719 Particle* newpi = particles.appendNew(pi);
4723 Ks.setVertex(XYZVector(4.0, 5.0, 0.0));
4724 Ks.setMomentumVertexErrorMatrix(error);
4725 momentum += Ks.get4Vector();
4726 Ks.addExtraInfo(
"prodVertX", 1.0);
4727 Ks.addExtraInfo(
"prodVertY", 1.0);
4728 Ks.addExtraInfo(
"prodVertZ", 0.0);
4729 Ks.addExtraInfo(
"prodVertSxx", 0.04);
4730 Ks.addExtraInfo(
"prodVertSxy", 0.0);
4731 Ks.addExtraInfo(
"prodVertSxz", 0.0);
4732 Ks.addExtraInfo(
"prodVertSyx", 0.0);
4733 Ks.addExtraInfo(
"prodVertSyy", 0.00875);
4734 Ks.addExtraInfo(
"prodVertSyz", 0.0);
4735 Ks.addExtraInfo(
"prodVertSzx", 0.0);
4736 Ks.addExtraInfo(
"prodVertSzy", 0.0);
4737 Ks.addExtraInfo(
"prodVertSzz", 0.01);
4738 Particle* newKs = particles.appendNew(Ks);
4743 Dp.appendDaughter(newpi);
4744 Dp.appendDaughter(newKs);
4745 XYZVector motherVtx(1.0, 1.0, 0.0);
4746 Dp.setVertex(motherVtx);
4747 Dp.setMomentumVertexErrorMatrix(error);
4748 Dp.addExtraInfo(
"prodVertX", 0.0);
4749 Dp.addExtraInfo(
"prodVertY", 1.0);
4750 Dp.addExtraInfo(
"prodVertZ", -2.0);
4751 Dp.addExtraInfo(
"prodVertSxx", 0.04);
4752 Dp.addExtraInfo(
"prodVertSxy", 0.0);
4753 Dp.addExtraInfo(
"prodVertSxz", 0.0);
4754 Dp.addExtraInfo(
"prodVertSyx", 0.0);
4755 Dp.addExtraInfo(
"prodVertSyy", 0.01);
4756 Dp.addExtraInfo(
"prodVertSyz", 0.0);
4757 Dp.addExtraInfo(
"prodVertSzx", 0.0);
4758 Dp.addExtraInfo(
"prodVertSzy", 0.0);
4759 Dp.addExtraInfo(
"prodVertSzz", 0.1575);
4760 Particle* newDp = particles.appendNew(Dp);
4766 void TearDown()
override
4771 TEST_F(FlightInfoTest, flightDistance)
4774 const Particle* newKs = particles[1];
4777 ASSERT_NE(var,
nullptr);
4778 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
4780 TEST_F(FlightInfoTest, flightDistanceErr)
4783 const Particle* newKs = particles[1];
4786 ASSERT_NE(var,
nullptr);
4787 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4789 TEST_F(FlightInfoTest, flightTime)
4792 const Particle* newKs = particles[1];
4795 ASSERT_NE(var,
nullptr);
4799 TEST_F(FlightInfoTest, flightTimeErr)
4802 const Particle* newKs = particles[1];
4805 ASSERT_NE(var,
nullptr);
4806 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4809 TEST_F(FlightInfoTest, flightDistanceOfDaughter)
4812 const Particle* newDp = particles[2];
4815 ASSERT_NE(var,
nullptr);
4816 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4819 ASSERT_NE(var,
nullptr);
4820 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4822 TEST_F(FlightInfoTest, flightDistanceOfDaughterErr)
4825 const Particle* newDp = particles[2];
4828 ASSERT_NE(var,
nullptr);
4829 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4832 ASSERT_NE(var,
nullptr);
4833 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4835 TEST_F(FlightInfoTest, flightTimeOfDaughter)
4838 const Particle* newDp = particles[2];
4841 ASSERT_NE(var,
nullptr);
4847 ASSERT_NE(var,
nullptr);
4848 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4850 TEST_F(FlightInfoTest, flightTimeOfDaughterErr)
4853 const Particle* newDp = particles[2];
4856 ASSERT_NE(var,
nullptr);
4857 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4860 ASSERT_NE(var,
nullptr);
4861 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4863 TEST_F(FlightInfoTest, mcFlightDistanceOfDaughter)
4866 const Particle* newDp = particles[2];
4869 ASSERT_NE(var,
nullptr);
4871 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4874 ASSERT_NE(var,
nullptr);
4875 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4877 TEST_F(FlightInfoTest, mcFlightTimeOfDaughter)
4880 const Particle* newDp = particles[2];
4883 ASSERT_NE(var,
nullptr);
4888 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), Ks->getLifetime() / Ks->
getEnergy()*Ks->
getMass());
4891 ASSERT_NE(var,
nullptr);
4892 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4895 TEST_F(FlightInfoTest, vertexDistance)
4898 const Particle* newKS = particles[1];
4901 ASSERT_NE(var,
nullptr);
4902 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 5.0);
4905 TEST_F(FlightInfoTest, vertexDistanceError)
4908 const Particle* newKS = particles[1];
4911 ASSERT_NE(var,
nullptr);
4912 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 0.2);
4915 TEST_F(FlightInfoTest, vertexDistanceSignificance)
4918 const Particle* newKS = particles[1];
4921 ASSERT_NE(var,
nullptr);
4922 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 25);
4925 TEST_F(FlightInfoTest, vertexDistanceOfDaughter)
4928 const Particle* newDp = particles[2];
4931 ASSERT_NE(var,
nullptr);
4932 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4935 ASSERT_NE(var,
nullptr);
4936 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 6.0);
4939 ASSERT_NE(var,
nullptr);
4940 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4943 TEST_F(FlightInfoTest, vertexDistanceOfDaughterError)
4946 const Particle* newDp = particles[2];
4949 ASSERT_NE(var,
nullptr);
4950 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.2);
4953 ASSERT_NE(var,
nullptr);
4954 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.25);
4957 TEST_F(FlightInfoTest, vertexDistanceOfDaughterSignificance)
4960 const Particle* newDp = particles[2];
4963 ASSERT_NE(var,
nullptr);
4964 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 25);
4967 ASSERT_NE(var,
nullptr);
4968 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 24);
4971 class VertexVariablesTest :
public ::testing::Test {
4974 void SetUp()
override
4981 particles.registerRelationTo(mcParticles);
4996 Particle Ks(PxPyPzEVector(1.164, 1.55200, 0, 2), 310);
5010 Particle* newKs = particles.appendNew(Ks);
5015 void TearDown()
override
5022 TEST_F(VertexVariablesTest, mcDecayVertexX)
5025 const Particle* newKs = particles[0];
5028 ASSERT_NE(var,
nullptr);
5029 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 4.0);
5032 TEST_F(VertexVariablesTest, mcDecayVertexY)
5035 const Particle* newKs = particles[0];
5038 ASSERT_NE(var,
nullptr);
5039 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
5042 TEST_F(VertexVariablesTest, mcDecayVertexZ)
5045 const Particle* newKs = particles[0];
5048 ASSERT_NE(var,
nullptr);
5049 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.0);
5053 TEST_F(VertexVariablesTest, mcDecayVertexFromIPDistance)
5056 const Particle* newKs = particles[0];
5059 ASSERT_NE(var,
nullptr);
5060 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(4.0 * 4.0 + 5.0 * 5.0));
5063 TEST_F(VertexVariablesTest, mcDecayVertexRho)
5066 const Particle* newKs = particles[0];
5069 ASSERT_NE(var,
nullptr);
5070 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(4.0 * 4.0 + 5.0 * 5.0));
5073 TEST_F(VertexVariablesTest, mcProductionVertexX)
5076 const Particle* newKs = particles[0];
5079 ASSERT_NE(var,
nullptr);
5080 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
5083 TEST_F(VertexVariablesTest, mcProductionVertexY)
5086 const Particle* newKs = particles[0];
5089 ASSERT_NE(var,
nullptr);
5090 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
5093 TEST_F(VertexVariablesTest, mcProductionVertexZ)
5096 const Particle* newKs = particles[0];
5099 ASSERT_NE(var,
nullptr);
5100 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
5105 TEST_F(VertexVariablesTest, prodVertexX)
5108 const Particle* newKs = particles[0];
5111 ASSERT_NE(var,
nullptr);
5112 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
5114 TEST_F(VertexVariablesTest, prodVertexY)
5117 const Particle* newKs = particles[0];
5120 ASSERT_NE(var,
nullptr);
5121 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
5123 TEST_F(VertexVariablesTest, prodVertexZ)
5126 const Particle* newKs = particles[0];
5129 ASSERT_NE(var,
nullptr);
5130 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
5135 TEST_F(VertexVariablesTest, prodVertexCov)
5138 const Particle* newKs = particles[0];
5142 ASSERT_NE(var,
nullptr);
5143 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.1);
5145 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.2);
5147 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.3);
5149 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.4);
5151 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.5);
5153 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.6);
5155 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.7);
5157 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.8);
5159 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.9);
5161 ASSERT_NE(var,
nullptr);
5162 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.1));
5164 ASSERT_NE(var,
nullptr);
5165 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.5));
5167 ASSERT_NE(var,
nullptr);
5168 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.9));
5173 TEST_F(MetaVariableTest, KSFWVariables)
5184 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5187 EXPECT_B2ERROR(
Manager::Instance().getVariable(
"KSFWVariables(et, mask, FS1)"));
5190 TEST_F(MetaVariableTest, CleoConeCS)
5201 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5205 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5211 TEST_F(MetaVariableTest, TransformedNetworkOutput)
5214 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONSENSE)"));
5217 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, 0, NOTDOUBLE)"));
5218 EXPECT_B2FATAL(
Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, NOTDOUBLE, 1)"));
5224 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle))));
5226 if (not eventExtraInfo.isValid())
5227 eventExtraInfo.create();
5229 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.