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>
52 using namespace Belle2::Variable;
53 using namespace ROOT::Math;
58 TEST(KinematicVariableTest, Variable)
63 Gearbox& gearbox = Gearbox::getInstance();
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));
182 const auto& frame = ReferenceFrame::GetCurrent();
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));
200 const auto& frame = ReferenceFrame::GetCurrent();
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));
257 DataStore::Instance().setInitializeActive(
true);
259 particles.registerInDataStore();
260 DataStore::Instance().setInitializeActive(
false);
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)
284 Gearbox& gearbox = Gearbox::getInstance();
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)
346 DataStore::Instance().setInitializeActive(
true);
355 DataStore::Instance().setInitializeActive(
false);
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);
375 myResults.
appendNew(position, momentum, cov6, charge, Const::electron, pValue, bField, CDCValue, 16777215, 0);
382 const Manager::Var* vIsFromECL = Manager::Instance().getVariable(
"isFromECL");
383 const Manager::Var* vIsFromKLM = Manager::Instance().getVariable(
"isFromKLM");
384 const Manager::Var* vIsFromTrack = Manager::Instance().getVariable(
"isFromTrack");
385 const Manager::Var* vIsFromV0 = Manager::Instance().getVariable(
"isFromV0");
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,
403 Const::electron, pValue, bField, CDCValue, 16777215, 0);
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,
411 Particle::c_Unflavored, Particle::c_V0, 0);
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)));
421 const Manager::Var* vNDaughters = Manager::Instance().getVariable(
"nDaughters");
422 EXPECT_EQ(std::get<int>(vNDaughters->
function(v0particle)), 2);
425 class MCTruthVariablesTest :
public ::testing::Test {
430 DataStore::Instance().reset();
431 DataStore::Instance().setInitializeActive(
true);
443 tracks.registerInDataStore();
445 particles.registerInDataStore();
449 tracks.registerRelationTo(mcparticles);
450 particles.registerRelationTo(mcparticles);
454 tracks.registerRelationTo(clusters);
457 DataStore::Instance().setInitializeActive(
false);
470 true_photon->
setPDG(Const::photon.getPDGCode());
472 true_electron->
setPDG(Const::electron.getPDGCode());
474 true_pion->
setPDG(-Const::pion.getPDGCode());
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());
493 electron_tr->setTrackFitResultIndex(Const::electron, 0);
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());
501 pion_tr->setTrackFitResultIndex(Const::pion, 0);
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));
516 const auto* electron = particles.appendNew(
Particle(electron_tr, Const::electron));
517 const auto* pion = particles.appendNew(
Particle(pion_tr, Const::pion));
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()
529 DataStore::Instance().reset();
533 TEST_F(MCTruthVariablesTest, mcCosThetaBetweenParticleAndNominalB)
535 DataStore::Instance().reset();
536 DataStore::Instance().setInitializeActive(
true);
539 particles.registerInDataStore();
541 particles.registerRelationTo(mcParticles);
542 DataStore::Instance().setInitializeActive(
false);
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);
562 graphParticleDaughter2.
setPDG(-Const::pion.getPDGCode());
563 graphParticleGranddaughter1.
setPDG(-Const::kaon.getPDGCode());
564 graphParticleGranddaughter2.
setPDG(-Const::electron.getPDGCode());
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);
609 const auto* mcCosBY = Manager::Instance().getVariable(
"mcCosThetaBetweenParticleAndNominalB");
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];
621 const auto* weight = Manager::Instance().getVariable(
"clusterMCMatchWeight");
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];
636 const auto* pdgcode = Manager::Instance().getVariable(
"clusterBestMCPDG");
637 EXPECT_EQ(std::get<double>(pdgcode->function(photon)), Const::photon.getPDGCode());
638 EXPECT_EQ(std::get<double>(pdgcode->function(electron)), Const::electron.getPDGCode());
639 EXPECT_EQ(std::get<double>(pdgcode->function(pion)), Const::electron.getPDGCode());
640 EXPECT_EQ(std::get<double>(pdgcode->function(misid_photon)), Const::electron.getPDGCode());
642 const auto* weight = Manager::Instance().getVariable(
"clusterBestMCMatchWeight");
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
655 DataStore::Instance().setInitializeActive(
true);
658 DataStore::Instance().setInitializeActive(
false);
663 void TearDown()
override
665 DataStore::Instance().reset();
669 TEST_F(EventVariableTest, ExperimentRunEventDateAndTime)
671 const Manager::Var* exp = Manager::Instance().getVariable(
"expNum");
672 const Manager::Var* run = Manager::Instance().getVariable(
"runNum");
673 const Manager::Var* evt = Manager::Instance().getVariable(
"evtNum");
674 const Manager::Var* date = Manager::Instance().getVariable(
"date");
675 const Manager::Var* year = Manager::Instance().getVariable(
"year");
676 const Manager::Var* time = Manager::Instance().getVariable(
"eventTimeSeconds");
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)));
683 DataStore::Instance().setInitializeActive(
true);
686 DataStore::Instance().setInitializeActive(
false);
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)
707 const Manager::Var* var = Manager::Instance().getVariable(
"nMCParticles");
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)
720 DataStore::Instance().setInitializeActive(
true);
723 particles.registerRelationTo(mcParticles);
724 DataStore::Instance().setInitializeActive(
false);
726 auto* mcParticle = mcParticles.
appendNew();
727 mcParticle->
setPDG(Const::electron.getPDGCode());
728 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
729 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
730 p1->addRelationTo(mcParticle);
733 mcParticle->
setPDG(-Const::electron.getPDGCode());
734 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
735 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
736 p2->addRelationTo(mcParticle);
738 const Manager::Var* var = Manager::Instance().getVariable(
"isContinuumEvent");
739 ASSERT_NE(var,
nullptr);
740 EXPECT_TRUE(std::get<bool>(var->function(p1)));
741 EXPECT_TRUE(std::get<bool>(var->function(p2)));
742 const Manager::Var* varN = Manager::Instance().getVariable(
"isNotContinuumEvent");
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)
750 DataStore::Instance().setInitializeActive(
true);
754 DataStore::Instance().setInitializeActive(
false);
756 auto* mcParticle = mcParticles2.
appendNew();
757 mcParticle->
setPDG(Const::photon.getPDGCode());
758 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
759 auto* p3 = particles2.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
760 p3->addRelationTo(mcParticle);
763 mcParticle->
setPDG(300553);
764 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
765 auto* p4 = particles2.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 300553);
766 p4->addRelationTo(mcParticle);
768 const Manager::Var* var2 = Manager::Instance().getVariable(
"isContinuumEvent");
769 ASSERT_NE(var2,
nullptr);
770 EXPECT_FALSE(std::get<bool>(var2->
function(p3)));
771 EXPECT_FALSE(std::get<bool>(var2->
function(p4)));
772 const Manager::Var* var2N = Manager::Instance().getVariable(
"isNotContinuumEvent");
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)
780 DataStore::Instance().setInitializeActive(
true);
784 DataStore::Instance().setInitializeActive(
false);
786 auto* mcParticle = mcParticles3.
appendNew();
787 mcParticle->
setPDG(Const::photon.getPDGCode());
788 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
789 auto* p5 = particles3.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
790 p5->addRelationTo(mcParticle);
793 mcParticle->
setPDG(300553);
794 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
795 auto* p6 = particles3.
appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 15);
796 p6->addRelationTo(mcParticle);
798 const Manager::Var* var3 = Manager::Instance().getVariable(
"isContinuumEvent");
799 ASSERT_NE(var3,
nullptr);
800 EXPECT_FALSE(std::get<bool>(var3->
function(p5)));
801 EXPECT_FALSE(std::get<bool>(var3->
function(p6)));
802 const Manager::Var* var3N = Manager::Instance().getVariable(
"isNotContinuumEvent");
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
814 DataStore::Instance().setInitializeActive(
true);
819 DataStore::Instance().setInitializeActive(
false);
823 void TearDown()
override
825 DataStore::Instance().reset();
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);
841 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
843 const Manager::Var* var = Manager::Instance().getVariable(
"countDaughters(charge > 0)");
844 ASSERT_NE(var,
nullptr);
845 EXPECT_EQ(std::get<int>(var->function(p)), 3);
847 var = Manager::Instance().getVariable(
"countDaughters(abs(charge) > 0)");
848 ASSERT_NE(var,
nullptr);
849 EXPECT_EQ(std::get<int>(var->function(p)), 6);
853 TEST_F(MetaVariableTest, useRestFrame)
855 Gearbox& gearbox = Gearbox::getInstance();
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));
863 const Manager::Var* var = Manager::Instance().getVariable(
"p");
864 ASSERT_NE(var,
nullptr);
865 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
867 var = Manager::Instance().getVariable(
"E");
868 ASSERT_NE(var,
nullptr);
869 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
871 var = Manager::Instance().getVariable(
"distance");
872 ASSERT_NE(var,
nullptr);
873 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
875 var = Manager::Instance().getVariable(
"useRestFrame(p)");
876 ASSERT_NE(var,
nullptr);
877 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.0, 1e-9);
879 var = Manager::Instance().getVariable(
"useRestFrame(E)");
880 ASSERT_NE(var,
nullptr);
881 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.4358899);
883 var = Manager::Instance().getVariable(
"useRestFrame(distance)");
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));
893 const Manager::Var* var = Manager::Instance().getVariable(
"p");
894 ASSERT_NE(var,
nullptr);
895 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
897 var = Manager::Instance().getVariable(
"E");
898 ASSERT_NE(var,
nullptr);
899 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
901 var = Manager::Instance().getVariable(
"distance");
902 ASSERT_NE(var,
nullptr);
903 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
905 var = Manager::Instance().getVariable(
"useLabFrame(p)");
906 ASSERT_NE(var,
nullptr);
907 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
909 var = Manager::Instance().getVariable(
"useLabFrame(E)");
910 ASSERT_NE(var,
nullptr);
911 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
913 var = Manager::Instance().getVariable(
"useLabFrame(distance)");
914 ASSERT_NE(var,
nullptr);
915 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
918 TEST_F(MetaVariableTest, useCMSFrame)
920 Gearbox& gearbox = Gearbox::getInstance();
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));
928 const Manager::Var* var = Manager::Instance().getVariable(
"p");
929 ASSERT_NE(var,
nullptr);
930 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.9);
932 var = Manager::Instance().getVariable(
"E");
933 ASSERT_NE(var,
nullptr);
934 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
936 var = Manager::Instance().getVariable(
"distance");
937 ASSERT_NE(var,
nullptr);
938 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.0);
940 var = Manager::Instance().getVariable(
"useCMSFrame(p)");
941 ASSERT_NE(var,
nullptr);
942 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.68174650327489894064);
944 var = Manager::Instance().getVariable(
"useCMSFrame(E)");
945 ASSERT_NE(var,
nullptr);
946 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.80918372124478121776);
948 var = Manager::Instance().getVariable(
"useCMSFrame(distance)");
949 ASSERT_NE(var,
nullptr);
950 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 3.1853695);
953 TEST_F(MetaVariableTest, useTagSideRecoilRestFrame)
955 DataStore::Instance().setInitializeActive(
true);
957 particles.registerInDataStore();
958 DataStore::Instance().setInitializeActive(
false);
961 PxPyPzEVector vec1 = {0.0, +0.332174566, 0.0, T.
getCMSEnergy() / 2.};
962 PxPyPzEVector vec2 = {0.0, -0.332174566, 0.0, T.
getCMSEnergy() / 2.};
970 const Manager::Var* var = Manager::Instance().getVariable(
"useTagSideRecoilRestFrame(daughter(1, p), 0)");
971 ASSERT_NE(var,
nullptr);
972 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
974 var = Manager::Instance().getVariable(
"useTagSideRecoilRestFrame(daughter(1, px), 0)");
975 ASSERT_NE(var,
nullptr);
976 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
978 var = Manager::Instance().getVariable(
"useTagSideRecoilRestFrame(daughter(1, py), 0)");
979 ASSERT_NE(var,
nullptr);
980 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
982 var = Manager::Instance().getVariable(
"useTagSideRecoilRestFrame(daughter(1, pz), 0)");
983 ASSERT_NE(var,
nullptr);
984 EXPECT_NEAR(std::get<double>(var->function(p0)), 0., 1e-6);
986 var = Manager::Instance().getVariable(
"useTagSideRecoilRestFrame(daughter(1, E), 0)");
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);
997 const Manager::Var* var = Manager::Instance().getVariable(
"extraInfo(pi)");
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);
1011 const Manager::Var* var = Manager::Instance().getVariable(
"eventExtraInfo(pi)");
1012 ASSERT_NE(var,
nullptr);
1013 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 3.14);
1016 TEST_F(MetaVariableTest, eventCached)
1018 const Manager::Var* var = Manager::Instance().getVariable(
"eventCached(constant(3.14))");
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);
1026 var = Manager::Instance().getVariable(
"eventCached(eventExtraInfo(pi))");
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);
1034 const Manager::Var* var = Manager::Instance().getVariable(
"particleCached(px)");
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);
1040 var = Manager::Instance().getVariable(
"particleCached(py)");
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);
1049 const Manager::Var* var = Manager::Instance().getVariable(
"abs(py)");
1050 ASSERT_NE(var,
nullptr);
1051 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.4);
1053 var = Manager::Instance().getVariable(
"min(E, pz)");
1054 ASSERT_NE(var,
nullptr);
1055 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.8);
1057 var = Manager::Instance().getVariable(
"max(E, pz)");
1058 ASSERT_NE(var,
nullptr);
1059 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 2.0);
1061 var = Manager::Instance().getVariable(
"log10(px)");
1062 ASSERT_NE(var,
nullptr);
1063 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1066 var = Manager::Instance().getVariable(
"sin(0.5235987755983)");
1067 ASSERT_NE(var,
nullptr);
1068 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1071 var = Manager::Instance().getVariable(
"sin(1.5707963267948966)");
1072 ASSERT_NE(var,
nullptr);
1073 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1076 var = Manager::Instance().getVariable(
"asin(1.0)");
1077 ASSERT_NE(var,
nullptr);
1078 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.5707963267948966);
1081 var = Manager::Instance().getVariable(
"cos(1.0471975511965976)");
1082 ASSERT_NE(var,
nullptr);
1083 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1086 var = Manager::Instance().getVariable(
"acos(0)");
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);
1101 const Manager::Var* var = Manager::Instance().getVariable(
"formula(px + py)");
1102 ASSERT_NE(var,
nullptr);
1103 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.3);
1105 var = Manager::Instance().getVariable(
"formula(px - py)");
1106 ASSERT_NE(var,
nullptr);
1107 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.5);
1109 var = Manager::Instance().getVariable(
"formula(px * py)");
1110 ASSERT_NE(var,
nullptr);
1111 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.04);
1113 var = Manager::Instance().getVariable(
"formula(py / px)");
1114 ASSERT_NE(var,
nullptr);
1115 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -4.0);
1117 var = Manager::Instance().getVariable(
"formula(px ^ E)");
1118 ASSERT_NE(var,
nullptr);
1119 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.01);
1121 var = Manager::Instance().getVariable(
"formula(px * py + pz)");
1122 ASSERT_NE(var,
nullptr);
1123 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1125 var = Manager::Instance().getVariable(
"formula(pz + px * py)");
1126 ASSERT_NE(var,
nullptr);
1127 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.76, 1e-6);
1129 var = Manager::Instance().getVariable(
"formula(pt)");
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));
1134 var = Manager::Instance().getVariable(
"formula((px**2 + py**2)**(1/2))");
1135 ASSERT_NE(var,
nullptr);
1136 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), pt);
1138 var = Manager::Instance().getVariable(
"formula(charge)");
1139 ASSERT_NE(var,
nullptr);
1140 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -1.0);
1142 var = Manager::Instance().getVariable(
"formula(charge**2)");
1143 ASSERT_NE(var,
nullptr);
1144 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1146 var = Manager::Instance().getVariable(
"formula(charge^2)");
1147 ASSERT_NE(var,
nullptr);
1148 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
1150 var = Manager::Instance().getVariable(
"formula(PDG * charge)");
1151 ASSERT_NE(var,
nullptr);
1152 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 411.0);
1154 var = Manager::Instance().getVariable(
"formula(PDG**2 * charge)");
1155 ASSERT_NE(var,
nullptr);
1156 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -168921.0);
1158 var = Manager::Instance().getVariable(
"formula(10.58 - (px + py + pz - E)**2)");
1159 ASSERT_NE(var,
nullptr);
1160 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 8.33);
1162 var = Manager::Instance().getVariable(
"formula(-10.58 + (px + py + pz - E)**2)");
1163 ASSERT_NE(var,
nullptr);
1164 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -8.33);
1166 var = Manager::Instance().getVariable(
"formula(-1.0 * PDG)");
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);
1176 const Manager::Var* var = Manager::Instance().getVariable(
"passesCut(E < 3)");
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)
1186 DataStore::Instance().setInitializeActive(
true);
1189 particles.registerInDataStore();
1191 particles.registerRelationTo(mcParticles);
1192 DataStore::Instance().setInitializeActive(
false);
1205 graphParticleGrandMother.
setPDG(-521);
1206 graphParticleMother.
setPDG(Const::muon.getPDGCode());
1207 graphParticleAunt.
setPDG(-14);
1208 graphParticleDaughter1.
setPDG(Const::electron.getPDGCode());
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];
1220 mcGrandMother->setStatus(MCParticle::c_PrimaryParticle);
1222 auto* mcMother = mcParticles[1];
1223 mcMother->setStatus(MCParticle::c_PrimaryParticle);
1225 auto* mcAunt = mcParticles[2];
1226 mcAunt->setStatus(MCParticle::c_PrimaryParticle);
1228 auto* mcDaughter1 = mcParticles[3];
1229 mcDaughter1->setStatus(MCParticle::c_PrimaryParticle);
1231 auto* mcDaughter2 = mcParticles[4];
1232 mcDaughter2->setStatus(MCParticle::c_PrimaryParticle);
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);
1243 const Manager::Var* var1 = Manager::Instance().getVariable(
"unmask(mcErrors, 8)");
1244 const Manager::Var* var2 = Manager::Instance().getVariable(
"unmask(mcErrors, 8, 16, 32, 64)");
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);
1263 EXPECT_B2FATAL(Manager::Instance().getVariable(
"unmask(mcErrors)"));
1266 EXPECT_B2FATAL(Manager::Instance().getVariable(
"unmask(mcErrors, NOTINT)"));
1269 TEST_F(MetaVariableTest, conditionalVariableSelector)
1271 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 411);
1273 const Manager::Var* var = Manager::Instance().getVariable(
"conditionalVariableSelector(E>1, px, py)");
1274 ASSERT_NE(var,
nullptr);
1275 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
1277 var = Manager::Instance().getVariable(
"conditionalVariableSelector(E<1, px, py)");
1278 ASSERT_NE(var,
nullptr);
1279 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), -0.4);
1283 TEST_F(MetaVariableTest, nCleanedTracks)
1285 DataStore::Instance().setInitializeActive(
true);
1289 tracks.registerInDataStore();
1290 DataStore::Instance().setInitializeActive(
false);
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);
1309 const Manager::Var* var1 = Manager::Instance().getVariable(
"nCleanedTracks(p > 0.5)");
1310 EXPECT_FLOAT_EQ(std::get<int>(var1->function(
nullptr)), 1);
1312 const Manager::Var* var2 = Manager::Instance().getVariable(
"nCleanedTracks(p > 0.2)");
1313 EXPECT_FLOAT_EQ(std::get<int>(var2->
function(
nullptr)), 2);
1315 const Manager::Var* var3 = Manager::Instance().getVariable(
"nCleanedTracks()");
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();
1328 mcParticle->
setPDG(Const::electron.getPDGCode());
1329 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
1330 mcParticle = mcParticles.appendNew();
1331 mcParticle->setPDG(Const::photon.getPDGCode());
1332 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
1333 mcParticle = mcParticles.appendNew();
1334 mcParticle->setPDG(-Const::electron.getPDGCode());
1335 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
1336 mcParticle = mcParticles.appendNew();
1337 mcParticle->setPDG(Const::electron.getPDGCode());
1340 const Manager::Var* var = Manager::Instance().getVariable(
"NumberOfMCParticlesInEvent(11)");
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);
1358 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
1360 const Manager::Var* var = Manager::Instance().getVariable(
"daughterInvM(6,5)");
1361 ASSERT_NE(var,
nullptr);
1362 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1364 var = Manager::Instance().getVariable(
"daughterInvM(0, 1)");
1365 ASSERT_NE(var,
nullptr);
1366 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 4.0);
1368 var = Manager::Instance().getVariable(
"daughterInvM(0, 1, 2)");
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);
1385 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
1387 const Manager::Var* var = Manager::Instance().getVariable(
"daughter(6, px)");
1388 ASSERT_NE(var,
nullptr);
1389 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
1391 var = Manager::Instance().getVariable(
"daughter(0, px)");
1392 ASSERT_NE(var,
nullptr);
1393 EXPECT_NEAR(std::get<double>(var->function(p)), 0.0, 1e-6);
1395 var = Manager::Instance().getVariable(
"daughter(1, px)");
1396 ASSERT_NE(var,
nullptr);
1397 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 1.0);
1399 var = Manager::Instance().getVariable(
"daughter(2, px)");
1400 ASSERT_NE(var,
nullptr);
1401 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 2.0);
1404 TEST_F(MetaVariableTest, mcDaughter)
1406 DataStore::Instance().setInitializeActive(
true);
1409 particles.registerInDataStore();
1411 particles.registerRelationTo(mcParticles);
1412 DataStore::Instance().setInitializeActive(
false);
1425 graphParticleGrandMother.
setPDG(-521);
1426 graphParticleMother.
setPDG(Const::muon.getPDGCode());
1427 graphParticleAunt.
setPDG(-14);
1428 graphParticleDaughter1.
setPDG(Const::electron.getPDGCode());
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];
1439 mcGrandMother->setStatus(MCParticle::c_PrimaryParticle);
1441 auto* mcMother = mcParticles[1];
1442 mcMother->setStatus(MCParticle::c_PrimaryParticle);
1444 auto* mcAunt = mcParticles[2];
1445 mcAunt->setStatus(MCParticle::c_PrimaryParticle);
1447 auto* mcDaughter1 = mcParticles[3];
1448 mcDaughter1->setStatus(MCParticle::c_PrimaryParticle);
1450 auto* mcDaughter2 = mcParticles[4];
1451 mcDaughter2->setStatus(MCParticle::c_PrimaryParticle);
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);
1466 const Manager::Var* var = Manager::Instance().getVariable(
"mcDaughter(0, PDG)");
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))));
1472 var = Manager::Instance().getVariable(
"mcDaughter(1, PDG)");
1473 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), -14);
1474 EXPECT_FLOAT_EQ(std::get<double>(var->function(pMother)), 14);
1476 var = Manager::Instance().getVariable(
"mcDaughter(2, PDG)");
1477 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1478 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1480 var = Manager::Instance().getVariable(
"mcDaughter(0, mcDaughter(0, PDG))");
1481 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 11);
1482 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pMother))));
1483 var = Manager::Instance().getVariable(
"mcDaughter(0, mcDaughter(1, PDG))");
1484 EXPECT_FLOAT_EQ(std::get<double>(var->function(pGrandMother)), 14);
1485 var = Manager::Instance().getVariable(
"mcDaughter(0, mcDaughter(2, PDG))");
1486 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1487 var = Manager::Instance().getVariable(
"mcDaughter(1, mcDaughter(0, PDG))");
1488 EXPECT_TRUE(std::isnan(std::get<double>(var->function(pGrandMother))));
1491 TEST_F(MetaVariableTest, mcMother)
1493 DataStore::Instance().setInitializeActive(
true);
1496 particles.registerInDataStore();
1498 particles.registerRelationTo(mcParticles);
1499 DataStore::Instance().setInitializeActive(
false);
1512 graphParticleGrandMother.
setPDG(-521);
1513 graphParticleMother.
setPDG(Const::muon.getPDGCode());
1514 graphParticleAunt.
setPDG(-14);
1515 graphParticleDaughter1.
setPDG(Const::electron.getPDGCode());
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];
1527 mcGrandMother->setStatus(MCParticle::c_PrimaryParticle);
1529 auto* mcMother = mcParticles[1];
1530 mcMother->setStatus(MCParticle::c_PrimaryParticle);
1532 auto* mcAunt = mcParticles[2];
1533 mcAunt->setStatus(MCParticle::c_PrimaryParticle);
1535 auto* mcDaughter1 = mcParticles[3];
1536 mcDaughter1->setStatus(MCParticle::c_PrimaryParticle);
1538 auto* mcDaughter2 = mcParticles[4];
1539 mcDaughter2->setStatus(MCParticle::c_PrimaryParticle);
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);
1557 const Manager::Var* var = Manager::Instance().getVariable(
"mcMother(PDG)");
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))));
1566 var = Manager::Instance().getVariable(
"mcMother(mcMother(PDG))");
1567 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -521);
1570 TEST_F(MetaVariableTest, genParticle)
1572 DataStore::Instance().setInitializeActive(
true);
1575 particles.registerInDataStore();
1577 particles.registerRelationTo(mcParticles);
1578 DataStore::Instance().setInitializeActive(
false);
1591 graphParticleGrandMother.
setPDG(300553);
1592 graphParticleMother.
setPDG(-521);
1593 graphParticleAunt.
setPDG(521);
1594 graphParticleDaughter1.
setPDG(Const::electron.getPDGCode());
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];
1609 mcGrandMother->setStatus(MCParticle::c_PrimaryParticle);
1611 auto* mcMother = mcParticles[1];
1612 mcMother->setStatus(MCParticle::c_PrimaryParticle);
1614 auto* mcAunt = mcParticles[2];
1615 mcAunt->setStatus(MCParticle::c_PrimaryParticle);
1617 auto* mcDaughter1 = mcParticles[3];
1618 mcDaughter1->setStatus(MCParticle::c_PrimaryParticle);
1620 auto* mcDaughter2 = mcParticles[4];
1621 mcDaughter2->setStatus(MCParticle::c_PrimaryParticle);
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);
1629 const Manager::Var* var = Manager::Instance().getVariable(
"genParticle(0, PDG)");
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);
1634 var = Manager::Instance().getVariable(
"genParticle(0, matchedMC(pz))");
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);
1639 var = Manager::Instance().getVariable(
"genParticle(0, mcDaughter(0, PDG))");
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);
1644 var = Manager::Instance().getVariable(
"genParticle(0, mcDaughter(0, matchedMC(px)))");
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);
1649 var = Manager::Instance().getVariable(
"genParticle(1, PDG)");
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);
1654 var = Manager::Instance().getVariable(
"genParticle(4, PDG)");
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);
1659 var = Manager::Instance().getVariable(
"genParticle(5, PDG)");
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)
1667 DataStore::Instance().setInitializeActive(
true);
1670 particles.registerInDataStore();
1672 particles.registerRelationTo(mcParticles);
1673 DataStore::Instance().setInitializeActive(
false);
1686 graphParticleGrandMother.
setPDG(300553);
1687 graphParticleMother.
setPDG(-521);
1688 graphParticleAunt.
setPDG(521);
1689 graphParticleDaughter1.
setPDG(Const::electron.getPDGCode());
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];
1704 mcGrandMother->setStatus(MCParticle::c_PrimaryParticle);
1706 auto* mcMother = mcParticles[1];
1707 mcMother->setStatus(MCParticle::c_PrimaryParticle);
1709 auto* mcAunt = mcParticles[2];
1710 mcAunt->setStatus(MCParticle::c_PrimaryParticle);
1712 auto* mcDaughter1 = mcParticles[3];
1713 mcDaughter1->setStatus(MCParticle::c_PrimaryParticle);
1715 auto* mcDaughter2 = mcParticles[4];
1716 mcDaughter2->setStatus(MCParticle::c_PrimaryParticle);
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);
1724 const Manager::Var* var = Manager::Instance().getVariable(
"genUpsilon4S(PDG)");
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);
1729 var = Manager::Instance().getVariable(
"genUpsilon4S(matchedMC(pz))");
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);
1734 var = Manager::Instance().getVariable(
"genUpsilon4S(mcDaughter(0, PDG))");
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);
1739 var = Manager::Instance().getVariable(
"genUpsilon4S(mcDaughter(0, matchedMC(px)))");
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();
1752 graphParticle1.
setPDG(Const::electron.getPDGCode());
1753 graphParticle2.
setPDG(-Const::electron.getPDGCode());
1760 auto* mcP1 = mcParticles[0];
1761 mcP1->setStatus(MCParticle::c_PrimaryParticle);
1763 auto* mcP2 = mcParticles[1];
1764 mcP2->setStatus(MCParticle::c_PrimaryParticle);
1766 auto* someParticle = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
1767 someParticle->addRelationTo(mcP1);
1769 var = Manager::Instance().getVariable(
"genUpsilon4S(PDG)");
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);
1786 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
1788 const Manager::Var* var = Manager::Instance().getVariable(
"daughterProductOf(E)");
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);
1805 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
1807 const Manager::Var* var = Manager::Instance().getVariable(
"daughterSumOf(E)");
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);
1824 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
1826 const Manager::Var* var = Manager::Instance().getVariable(
"daughterLowest(E)");
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);
1843 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
1845 const Manager::Var* var = Manager::Instance().getVariable(
"daughterHighest(E)");
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);
1862 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
1864 const Manager::Var* var = Manager::Instance().getVariable(
"daughterDiffOf(0, 1, PDG)");
1865 ASSERT_NE(var,
nullptr);
1866 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1868 var = Manager::Instance().getVariable(
"daughterDiffOf(1, 0, PDG)");
1869 ASSERT_NE(var,
nullptr);
1870 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1872 var = Manager::Instance().getVariable(
"daughterDiffOf(0, 1, abs(PDG))");
1873 ASSERT_NE(var,
nullptr);
1874 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1876 var = Manager::Instance().getVariable(
"daughterDiffOf(1, 1, PDG)");
1877 ASSERT_NE(var,
nullptr);
1878 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1880 var = Manager::Instance().getVariable(
"daughterDiffOf(1, 3, abs(PDG))");
1881 ASSERT_NE(var,
nullptr);
1882 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1884 var = Manager::Instance().getVariable(
"daughterDiffOf(0, 2, PDG)");
1885 ASSERT_NE(var,
nullptr);
1886 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1888 var = Manager::Instance().getVariable(
"daughterDiffOf(1, 0, phi)");
1889 ASSERT_NE(var,
nullptr);
1890 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5707964);
1892 var = Manager::Instance().getVariable(
"daughterDiffOf(1, 0, useCMSFrame(phi))");
1893 ASSERT_NE(var,
nullptr);
1894 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -1.5004894);
1896 EXPECT_B2FATAL(Manager::Instance().getVariable(
"daughterDiffOf(0, NOTINT, PDG)"));
1900 TEST_F(MetaVariableTest, mcDaughterDiffOf)
1902 DataStore::Instance().setInitializeActive(
true);
1903 PxPyPzEVector momentum;
1904 const int nDaughters = 4;
1907 particles.registerRelationTo(mcParticles);
1908 std::vector<int> daughterIndices;
1909 DataStore::Instance().setInitializeActive(
false);
1911 for (
int i = 0; i < nDaughters; i++) {
1912 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
1913 momentum += d.get4Vector();
1914 Particle* newDaughters = particles.appendNew(d);
1916 auto* mcParticle = mcParticles.
appendNew();
1917 mcParticle->
setPDG((i % 2) ? -Const::electron.getPDGCode() : Const::pion.getPDGCode());
1918 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
1921 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
1923 const Manager::Var* var = Manager::Instance().getVariable(
"mcDaughterDiffOf(0, 1, PDG)");
1924 ASSERT_NE(var,
nullptr);
1925 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222);
1927 var = Manager::Instance().getVariable(
"mcDaughterDiffOf(1, 0, PDG)");
1928 ASSERT_NE(var,
nullptr);
1929 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222);
1931 var = Manager::Instance().getVariable(
"mcDaughterDiffOf(0, 1, abs(PDG))");
1932 ASSERT_NE(var,
nullptr);
1933 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200);
1935 var = Manager::Instance().getVariable(
"mcDaughterDiffOf(1, 1, PDG)");
1936 ASSERT_NE(var,
nullptr);
1937 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1939 var = Manager::Instance().getVariable(
"mcDaughterDiffOf(1, 3, abs(PDG))");
1940 ASSERT_NE(var,
nullptr);
1941 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1943 var = Manager::Instance().getVariable(
"mcDaughterDiffOf(0, 2, PDG)");
1944 ASSERT_NE(var,
nullptr);
1945 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
1947 EXPECT_B2FATAL(Manager::Instance().getVariable(
"mcDaughterDiffOf(0, NOTINT, PDG)"));
1952 TEST_F(MetaVariableTest, daughterClusterAngleInBetween)
1956 std::vector<int> daughterIndices, daughterIndices_noclst;
1959 DataStore::Instance().setInitializeActive(
true);
1962 particles.registerRelationTo(eclclusters);
1963 DataStore::Instance().setInitializeActive(
false);
1966 const float px_CM = 2.;
1967 const float py_CM = 1.;
1968 const float pz_CM = 3.;
1970 E_CM =
sqrt(pow(px_CM, 2) + pow(py_CM, 2) + pow(pz_CM, 2));
1971 PxPyPzEVector momentum, momentum_noclst;
1972 PxPyPzEVector dau0_4vec_CM(px_CM, py_CM, pz_CM, E_CM), dau1_4vec_CM(-px_CM, -py_CM, -pz_CM, E_CM);
1973 PxPyPzEVector dau0_4vec_Lab, dau1_4vec_Lab;
1974 dau0_4vec_Lab = PCmsLabTransform::cmsToLab(
1976 dau1_4vec_Lab = PCmsLabTransform::cmsToLab(dau1_4vec_CM);
1979 Particle dau0_noclst(dau0_4vec_Lab, 22);
1980 momentum += dau0_noclst.get4Vector();
1981 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
1982 daughterIndices_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
1983 Particle dau1_noclst(dau1_4vec_Lab, 22);
1984 momentum += dau1_noclst.get4Vector();
1985 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
1986 daughterIndices_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
1987 const Particle* par_noclst = particles.appendNew(momentum, 111, Particle::c_Unflavored, daughterIndices_noclst);
1990 const Manager::Var* var = Manager::Instance().getVariable(
"daughterClusterAngleInBetween(0, 1)");
1991 const Manager::Var* varCMS = Manager::Instance().getVariable(
"useCMSFrame(daughterClusterAngleInBetween(0, 1))");
1994 ASSERT_NE(var,
nullptr);
1995 EXPECT_TRUE(std::isnan(std::get<double>(var->function(par_noclst))));
2000 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2002 eclst0->
setTheta(dau0_4vec_Lab.Theta());
2003 eclst0->
setPhi(dau0_4vec_Lab.Phi());
2004 eclst0->
setR(148.4);
2007 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2009 eclst1->
setTheta(dau1_4vec_Lab.Theta());
2010 eclst1->
setPhi(dau1_4vec_Lab.Phi());
2011 eclst1->
setR(148.5);
2013 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2015 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2018 const Particle* par = particles.appendNew(momentum, 111, Particle::c_Unflavored, daughterIndices);
2021 EXPECT_FLOAT_EQ(std::get<double>(var->function(par)), 2.8613892);
2022 EXPECT_FLOAT_EQ(std::get<double>(varCMS->
function(par)), M_PI);
2025 TEST_F(MetaVariableTest, grandDaughterDiffOfs)
2029 std::vector<int> daughterIndices0_noclst, daughterIndices1_noclst, daughterIndices2_noclst;
2030 std::vector<int> daughterIndices0, daughterIndices1, daughterIndices2;
2033 DataStore::Instance().setInitializeActive(
true);
2036 particles.registerRelationTo(eclclusters);
2037 DataStore::Instance().setInitializeActive(
false);
2040 const float px_0 = 2.;
2041 const float py_0 = 1.;
2042 const float pz_0 = 3.;
2043 const float px_1 = 1.5;
2044 const float py_1 = 1.5;
2045 const float pz_1 = 2.5;
2047 E_0 =
sqrt(pow(px_0, 2) + pow(py_0, 2) + pow(pz_0, 2));
2048 E_1 =
sqrt(pow(px_1, 2) + pow(py_1, 2) + pow(pz_1, 2));
2049 PxPyPzEVector momentum_0, momentum_1, momentum;
2050 PxPyPzEVector dau0_4vec(px_0, py_0, pz_0, E_0), dau1_4vec(px_1, py_1, pz_1, E_1);
2063 Particle dau0_noclst(dau0_4vec, 22);
2064 momentum_0 = dau0_4vec;
2065 Particle* newDaughter0_noclst = particles.appendNew(dau0_noclst);
2066 daughterIndices0_noclst.push_back(newDaughter0_noclst->
getArrayIndex());
2067 const Particle* par0_noclst = particles.appendNew(momentum_0, 111, Particle::c_Unflavored, daughterIndices0_noclst);
2068 Particle dau1_noclst(dau1_4vec, 22);
2069 momentum_1 = dau1_4vec;
2070 Particle* newDaughter1_noclst = particles.appendNew(dau1_noclst);
2071 daughterIndices1_noclst.push_back(newDaughter1_noclst->
getArrayIndex());
2072 const Particle* par1_noclst = particles.appendNew(momentum_1, 111, Particle::c_Unflavored, daughterIndices1_noclst);
2074 momentum = momentum_0 + momentum_1;
2075 daughterIndices2_noclst.push_back(par0_noclst->
getArrayIndex());
2076 daughterIndices2_noclst.push_back(par1_noclst->
getArrayIndex());
2077 const Particle* parGranny_noclst = particles.appendNew(momentum, 111, Particle::c_Unflavored, daughterIndices2_noclst);
2080 const Manager::Var* var_Theta = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,0,0,theta)");
2081 const Manager::Var* var_ClusterTheta = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,0,0,clusterTheta)");
2082 const Manager::Var* var_E = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,0,0,E)");
2083 const Manager::Var* var_ClusterE = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,0,0,clusterE)");
2084 const Manager::Var* var_E_wrongIndexes = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,2,3,E)");
2085 const Manager::Var* var_ClusterE_wrongIndexes = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,2,3,clusterE)");
2087 const Manager::Var* var_ClusterPhi = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,0,0,clusterPhi)");
2088 const Manager::Var* var_Phi = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,0,0,phi)");
2089 const Manager::Var* var_ClusterPhi_wrongIndexes = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,2,3,clusterPhi)");
2090 const Manager::Var* var_Phi_wrongIndexes = Manager::Instance().getVariable(
"grandDaughterDiffOf(0,1,2,3,phi)");
2095 ASSERT_NE(var_ClusterPhi,
nullptr);
2096 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi->
function(parGranny_noclst))));
2097 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterTheta->
function(parGranny_noclst))));
2098 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE->
function(parGranny_noclst))));
2099 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny_noclst)), 0.32175055);
2100 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny_noclst)), 0.06311664);
2101 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny_noclst)), -0.46293807);
2102 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterPhi_wrongIndexes->
function(parGranny_noclst))));
2103 EXPECT_TRUE(std::isnan(std::get<double>(var_Phi_wrongIndexes->
function(parGranny_noclst))));
2104 EXPECT_TRUE(std::isnan(std::get<double>(var_ClusterE_wrongIndexes->
function(parGranny_noclst))));
2105 EXPECT_TRUE(std::isnan(std::get<double>(var_E_wrongIndexes->
function(parGranny_noclst))));
2110 eclst0->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2112 eclst0->
setTheta(dau0_4vec.Theta());
2113 eclst0->
setPhi(dau0_4vec.Phi());
2114 eclst0->
setR(148.4);
2117 eclst1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2119 eclst1->
setTheta(dau1_4vec.Theta());
2120 eclst1->
setPhi(dau1_4vec.Phi());
2121 eclst1->
setR(148.5);
2123 const Particle* newDaughter0 = particles.appendNew(
Particle(eclclusters[0]));
2125 const Particle* par0 = particles.appendNew(momentum_0, 111, Particle::c_Unflavored, daughterIndices0);
2127 const Particle* newDaughter1 = particles.appendNew(
Particle(eclclusters[1]));
2129 const Particle* par1 = particles.appendNew(momentum_1, 111, Particle::c_Unflavored, daughterIndices1);
2133 const Particle* parGranny = particles.appendNew(momentum, 111, Particle::c_Unflavored, daughterIndices2);
2137 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterPhi->
function(parGranny)), 0.32175055);
2138 EXPECT_FLOAT_EQ(std::get<double>(var_Phi->
function(parGranny)), 0.32175055);
2139 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterTheta->
function(parGranny)), 0.06311664);
2140 EXPECT_FLOAT_EQ(std::get<double>(var_Theta->
function(parGranny)), 0.06311664);
2141 EXPECT_FLOAT_EQ(std::get<double>(var_ClusterE->
function(parGranny)), -0.46293831);
2142 EXPECT_FLOAT_EQ(std::get<double>(var_E->
function(parGranny)), -0.46293831);
2145 TEST_F(MetaVariableTest, daughterNormDiffOf)
2147 PxPyPzEVector momentum;
2148 const int nDaughters = 4;
2150 std::vector<int> daughterIndices;
2151 for (
int i = 0; i < nDaughters; i++) {
2152 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2153 momentum += d.get4Vector();
2154 Particle* newDaughters = particles.appendNew(d);
2157 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
2159 const Manager::Var* var = Manager::Instance().getVariable(
"daughterNormDiffOf(0, 1, PDG)");
2160 ASSERT_NE(var,
nullptr);
2161 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -222 / 200.);
2163 var = Manager::Instance().getVariable(
"daughterNormDiffOf(1, 0, PDG)");
2164 ASSERT_NE(var,
nullptr);
2165 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 222 / 200.);
2167 var = Manager::Instance().getVariable(
"daughterNormDiffOf(0, 1, abs(PDG))");
2168 ASSERT_NE(var,
nullptr);
2169 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -200 / 222.);
2171 var = Manager::Instance().getVariable(
"daughterNormDiffOf(1, 1, PDG)");
2172 ASSERT_NE(var,
nullptr);
2173 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), -0 / 22.);
2175 var = Manager::Instance().getVariable(
"daughterNormDiffOf(1, 3, abs(PDG))");
2176 ASSERT_NE(var,
nullptr);
2177 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 22.);
2179 var = Manager::Instance().getVariable(
"daughterNormDiffOf(0, 2, PDG)");
2180 ASSERT_NE(var,
nullptr);
2181 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0 / 422.);
2185 TEST_F(MetaVariableTest, daughterMotherDiffOf)
2187 PxPyPzEVector momentum;
2188 const int nDaughters = 4;
2190 std::vector<int> daughterIndices;
2191 for (
int i = 0; i < nDaughters; i++) {
2192 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2193 momentum += d.get4Vector();
2194 Particle* newDaughters = particles.appendNew(d);
2197 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
2199 const Manager::Var* var = Manager::Instance().getVariable(
"daughterMotherDiffOf(1, PDG)");
2200 ASSERT_NE(var,
nullptr);
2201 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422);
2203 var = Manager::Instance().getVariable(
"daughterMotherDiffOf(1, abs(PDG))");
2204 ASSERT_NE(var,
nullptr);
2205 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400);
2207 var = Manager::Instance().getVariable(
"daughterMotherDiffOf(0, PDG)");
2208 ASSERT_NE(var,
nullptr);
2209 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200);
2213 TEST_F(MetaVariableTest, daughterMotherNormDiffOf)
2215 PxPyPzEVector momentum;
2216 const int nDaughters = 4;
2218 std::vector<int> daughterIndices;
2219 for (
int i = 0; i < nDaughters; i++) {
2220 Particle d(PxPyPzEVector(1, 1, 1, i * 1.0 + 1.0), (i % 2) ? -11 : 211);
2221 momentum += d.get4Vector();
2222 Particle* newDaughters = particles.appendNew(d);
2225 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices);
2227 const Manager::Var* var = Manager::Instance().getVariable(
"daughterMotherNormDiffOf(1, PDG)");
2228 ASSERT_NE(var,
nullptr);
2229 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 422 / 400.);
2231 var = Manager::Instance().getVariable(
"daughterMotherNormDiffOf(1, abs(PDG))");
2232 ASSERT_NE(var,
nullptr);
2233 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 400 / 422.);
2235 var = Manager::Instance().getVariable(
"daughterMotherNormDiffOf(0, PDG)");
2236 ASSERT_NE(var,
nullptr);
2237 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 200 / 622.);
2241 TEST_F(MetaVariableTest, constant)
2244 const Manager::Var* var = Manager::Instance().getVariable(
"constant(1)");
2245 ASSERT_NE(var,
nullptr);
2246 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 1.0);
2248 var = Manager::Instance().getVariable(
"constant(0)");
2249 ASSERT_NE(var,
nullptr);
2250 EXPECT_FLOAT_EQ(std::get<double>(var->function(
nullptr)), 0.0);
2254 TEST_F(MetaVariableTest, abs)
2256 Particle p({ 0.1, -0.4, 0.8, 2.0 }, 11);
2257 Particle p2({ -0.1, -0.4, 0.8, 4.0 }, -11);
2259 const Manager::Var* var = Manager::Instance().getVariable(
"abs(px)");
2260 ASSERT_NE(var,
nullptr);
2261 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 0.1);
2262 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 0.1);
2266 TEST_F(MetaVariableTest, sin)
2268 Particle p({ 3.14159265359 / 2.0, -0.4, 0.8, 1.0}, 11);
2269 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2271 const Manager::Var* var = Manager::Instance().getVariable(
"sin(px)");
2272 ASSERT_NE(var,
nullptr);
2273 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p)), 1.0);
2274 EXPECT_NEAR(std::get<double>(var->function(&p2)), 0.0, 1e-6);
2278 TEST_F(MetaVariableTest, cos)
2280 Particle p({ 3.14159265359 / 2.0, -0.4, 0.8, 1.0}, 11);
2281 Particle p2({ 0.0, -0.4, 0.8, 1.0 }, -11);
2283 const Manager::Var* var = Manager::Instance().getVariable(
"cos(px)");
2284 ASSERT_NE(var,
nullptr);
2285 EXPECT_NEAR(std::get<double>(var->function(&p)), 0.0, 1e-6);
2286 EXPECT_FLOAT_EQ(std::get<double>(var->function(&p2)), 1.0);
2290 TEST_F(MetaVariableTest, NBDeltaIfMissingDeathTest)
2293 EXPECT_B2FATAL(Manager::Instance().getVariable(
"NBDeltaIfMissing(TOP, 11)"));
2294 EXPECT_B2FATAL(Manager::Instance().getVariable(
"NBDeltaIfMissing(ARICH, 11)"));
2297 TEST_F(MetaVariableTest, matchedMC)
2299 DataStore::Instance().setInitializeActive(
true);
2302 particles.registerRelationTo(mcParticles);
2303 DataStore::Instance().setInitializeActive(
false);
2305 auto* mcParticle = mcParticles.
appendNew();
2306 mcParticle->
setPDG(Const::electron.getPDGCode());
2307 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
2308 auto* p1 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2309 p1->addRelationTo(mcParticle);
2312 mcParticle->
setPDG(-Const::electron.getPDGCode());
2313 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
2314 auto* p2 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2315 p2->addRelationTo(mcParticle);
2318 mcParticle->
setPDG(Const::photon.getPDGCode());
2319 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
2320 auto* p3 = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 11);
2321 p3->addRelationTo(mcParticle);
2324 auto* p4 = particles.appendNew(mcParticle);
2326 const Manager::Var* var = Manager::Instance().getVariable(
"matchedMC(charge)");
2327 ASSERT_NE(var,
nullptr);
2328 EXPECT_FLOAT_EQ(std::get<double>(var->function(p1)), -1);
2329 EXPECT_FLOAT_EQ(std::get<double>(var->function(p2)), 1);
2330 EXPECT_FLOAT_EQ(std::get<double>(var->function(p3)), 0);
2331 EXPECT_FLOAT_EQ(std::get<double>(var->function(p4)), 0);
2334 TEST_F(MetaVariableTest, countInList)
2340 DataStore::Instance().setInitializeActive(
true);
2341 outputList.registerInDataStore(flags);
2342 DataStore::Instance().setInitializeActive(
false);
2343 outputList.create();
2344 outputList->initialize(22,
"pList1");
2346 particles.appendNew(
Particle({0.5, 0.4, 0.5, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 2));
2347 particles.appendNew(
Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3));
2348 particles.appendNew(
Particle({0.4, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4));
2349 particles.appendNew(
Particle({0.5, 0.4, 0.8, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 5));
2350 particles.appendNew(
Particle({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 6));
2352 outputList->addParticle(0, 22, Particle::c_Unflavored);
2353 outputList->addParticle(1, 22, Particle::c_Unflavored);
2354 outputList->addParticle(2, 22, Particle::c_Unflavored);
2355 outputList->addParticle(3, 22, Particle::c_Unflavored);
2356 outputList->addParticle(4, 22, Particle::c_Unflavored);
2358 const Manager::Var* var = Manager::Instance().getVariable(
"countInList(pList1, E < 0.85)");
2359 ASSERT_NE(var,
nullptr);
2360 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 2);
2362 var = Manager::Instance().getVariable(
"countInList(pList1)");
2363 ASSERT_NE(var,
nullptr);
2364 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2366 var = Manager::Instance().getVariable(
"countInList(pList1, E > 5)");
2367 ASSERT_NE(var,
nullptr);
2368 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 0);
2370 var = Manager::Instance().getVariable(
"countInList(pList1, E < 5)");
2371 ASSERT_NE(var,
nullptr);
2372 EXPECT_EQ(std::get<int>(var->function(
nullptr)), 5);
2375 TEST_F(MetaVariableTest, isInList)
2383 DataStore::Instance().setInitializeActive(
true);
2384 gammalist.registerInDataStore(flags);
2385 DataStore::Instance().setInitializeActive(
false);
2387 gammalist->initialize(22,
"testGammaList");
2390 Particle goingin({0.5, 0.4, 0.5, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 0);
2391 Particle notgoingin({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1);
2392 auto* inthelist = particles.appendNew(goingin);
2393 auto* notinthelist = particles.appendNew(notgoingin);
2396 gammalist->addParticle(0, 22, Particle::c_Unflavored);
2399 const Manager::Var* vnonsense = Manager::Instance().getVariable(
"isInList(NONEXISTANTLIST)");
2400 const Manager::Var* vsensible = Manager::Instance().getVariable(
"isInList(testGammaList)");
2403 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(notinthelist)));
2404 EXPECT_TRUE(std::get<bool>(vsensible->
function(inthelist)));
2405 EXPECT_FALSE(std::get<bool>(vsensible->
function(notinthelist)));
2409 TEST_F(MetaVariableTest, cutIsInList)
2415 const std::string listname {
"wil/d(-+)'':l*"};
2418 DataStore::Instance().setInitializeActive(
true);
2419 particlelist.registerInDataStore(flags);
2420 DataStore::Instance().setInitializeActive(
false);
2421 particlelist.create();
2422 particlelist->initialize(22, listname);
2424 Particle goingin({0.5, 0.4, 0.5, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 0);
2425 Particle notgoingin({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1);
2426 auto* inthelist = particles.appendNew(goingin);
2427 auto* notinthelist = particles.appendNew(notgoingin);
2430 particlelist->addParticle(0, 22, Particle::c_Unflavored);
2433 const Manager::Var* nonexistlist = Manager::Instance().getVariable(
"passesCut(isInList(NONEXISTANTLIST))");
2434 const Manager::Var* existlist = Manager::Instance().getVariable(
"passesCut(isInList(" + listname +
"))");
2436 EXPECT_B2FATAL(std::get<bool>(nonexistlist->
function(inthelist)));
2437 EXPECT_FALSE(std::get<bool>(existlist->
function(notinthelist)));
2438 EXPECT_TRUE(std::get<bool>(existlist->
function(inthelist)));
2441 TEST_F(MetaVariableTest, sourceObjectIsInList)
2444 DataStore::Instance().reset();
2445 DataStore::Instance().setInitializeActive(
true);
2453 particles.registerInDataStore();
2455 gammalist.registerInDataStore(flags);
2458 DataStore::Instance().setInitializeActive(
false);
2462 gammalist->initialize(22,
"testGammaList");
2467 cl0->setEnergy(1.0);
2468 cl0->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
2469 cl0->addHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2470 cl0->setClusterId(0);
2472 cl1->setEnergy(1.0);
2473 cl1->setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
2474 cl1->setClusterId(1);
2477 Particle myphoton(cl0, Const::photon);
2478 Particle iscopiedin(cl0, Const::Klong);
2479 Particle notcopiedin(cl1, Const::Klong);
2482 auto* myphoton_ = particles.appendNew(myphoton);
2483 gammalist->addParticle(myphoton_);
2485 auto* iscopied = particles.appendNew(iscopiedin);
2486 auto* notcopied = particles.appendNew(notcopiedin);
2489 const Manager::Var* vnonsense = Manager::Instance().getVariable(
"sourceObjectIsInList(NONEXISTANTLIST)");
2490 const Manager::Var* vsensible = Manager::Instance().getVariable(
"sourceObjectIsInList(testGammaList)");
2493 EXPECT_B2FATAL(std::get<int>(vnonsense->
function(iscopied)));
2494 EXPECT_EQ(std::get<int>(vsensible->
function(iscopied)), 1);
2495 EXPECT_EQ(std::get<int>(vsensible->
function(notcopied)), 0);
2498 Particle composite({0.5, 0.4, 0.5, 0.8}, 512, Particle::c_Unflavored, Particle::c_Composite, 0);
2499 Particle undefined({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1);
2500 auto* composite_ = particles.appendNew(undefined);
2501 auto* undefined_ = particles.appendNew(composite);
2502 EXPECT_EQ(std::get<int>(vsensible->
function(composite_)), -1);
2503 EXPECT_EQ(std::get<int>(vsensible->
function(undefined_)), -1);
2506 TEST_F(MetaVariableTest, mcParticleIsInMCList)
2509 DataStore::Instance().reset();
2510 DataStore::Instance().setInitializeActive(
true);
2519 particles.registerInDataStore();
2520 particles.registerRelationTo(mcparticles);
2522 list.registerInDataStore(flags);
2523 anotherlist.registerInDataStore(flags);
2525 DataStore::Instance().setInitializeActive(
false);
2529 list->initialize(22,
"testList");
2531 anotherlist.create();
2532 anotherlist->initialize(22,
"supplimentaryList");
2535 auto* mcphoton = mcparticles.
appendNew();
2536 mcphoton->
setPDG(Const::photon.getPDGCode());
2537 mcphoton->setStatus(MCParticle::c_PrimaryParticle);
2539 auto* mcelectron = mcparticles.
appendNew();
2540 mcelectron->
setPDG(Const::electron.getPDGCode());
2541 mcelectron->setStatus(MCParticle::c_PrimaryParticle);
2543 auto* mcanotherelectron = mcparticles.
appendNew();
2544 mcanotherelectron->
setPDG(Const::photon.getPDGCode());
2545 mcanotherelectron->setStatus(MCParticle::c_PrimaryParticle);
2547 auto* mcyetanotherelectron = mcparticles.
appendNew();
2548 mcyetanotherelectron->
setPDG(Const::photon.getPDGCode());
2549 mcyetanotherelectron->setStatus(MCParticle::c_PrimaryParticle);
2552 auto* photon = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2553 photon->addRelationTo(mcphoton);
2554 list->addParticle(photon);
2556 auto* electron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2557 electron->addRelationTo(mcelectron);
2558 list->addParticle(electron);
2560 auto* other = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2561 other->addRelationTo(mcanotherelectron);
2563 auto* yetanotherelectron = particles.appendNew(PxPyPzEVector({ 0.0, -0.4, 0.8, 1.0}), 22);
2564 yetanotherelectron->addRelationTo(mcyetanotherelectron);
2565 anotherlist->addParticle(yetanotherelectron);
2569 const Manager::Var* vnonsense = Manager::Instance().getVariable(
"mcParticleIsInMCList(NONEXISTANTLIST)");
2570 const Manager::Var* vsensible = Manager::Instance().getVariable(
"mcParticleIsInMCList(testList)");
2573 EXPECT_B2FATAL(std::get<bool>(vnonsense->
function(photon)));
2574 EXPECT_TRUE(std::get<bool>(vsensible->
function(photon)));
2575 EXPECT_TRUE(std::get<bool>(vsensible->
function(electron)));
2576 EXPECT_FALSE(std::get<bool>(vsensible->
function(other)));
2577 EXPECT_FALSE(std::get<bool>(vsensible->
function(yetanotherelectron)));
2580 Particle composite({0.5, 0.4, 0.5, 0.8}, 512, Particle::c_Unflavored, Particle::c_Composite, 0);
2581 Particle undefined({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1);
2582 auto* composite_ = particles.appendNew(undefined);
2583 auto* undefined_ = particles.appendNew(composite);
2584 EXPECT_FALSE(std::get<bool>(vsensible->
function(composite_)));
2585 EXPECT_FALSE(std::get<bool>(vsensible->
function(undefined_)));
2588 TEST_F(MetaVariableTest, mostB2BAndClosestParticles)
2597 Gearbox& gearbox = Gearbox::getInstance();
2598 gearbox.setBackends({std::string(
"file:")});
2600 gearbox.open(
"geometry/Belle2.xml",
false);
2609 DataStore::Instance().setInitializeActive(
true);
2610 gammalist.registerInDataStore(flags);
2611 emptylist.registerInDataStore(flags);
2612 DataStore::Instance().setInitializeActive(
false);
2614 gammalist->initialize(22,
"testGammaList");
2616 emptylist->initialize(22,
"testEmptyList");
2619 std::vector<Particle> gammavector = {
2621 22, Particle::c_Unflavored, Particle::c_Undefined, 0),
2623 22, Particle::c_Unflavored, Particle::c_Undefined, 1),
2626 for (
const auto& g : gammavector)
2627 particles.appendNew(g);
2630 for (
size_t i = 0; i < gammavector.size(); i++)
2631 gammalist->addParticle(i, 22, Particle::c_Unflavored);
2634 const auto* electron = particles.appendNew(
2636 11, Particle::c_Unflavored, Particle::c_Undefined, 2)
2640 EXPECT_B2FATAL(Manager::Instance().getVariable(
"angleToClosestInList"));
2641 EXPECT_B2FATAL(Manager::Instance().getVariable(
"angleToClosestInList(A, B)"));
2643 const auto* nonexistent = Manager::Instance().getVariable(
"angleToClosestInList(NONEXISTANTLIST)");
2644 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2646 const auto* empty = Manager::Instance().getVariable(
"angleToClosestInList(testEmptyList)");
2647 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2649 const auto* closest = Manager::Instance().getVariable(
"angleToClosestInList(testGammaList)");
2650 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 0.68014491);
2652 const auto* closestCMS = Manager::Instance().getVariable(
"useCMSFrame(angleToClosestInList(testGammaList))");
2653 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 0.67901474);
2657 EXPECT_B2FATAL(Manager::Instance().getVariable(
"closestInList"));
2658 EXPECT_B2FATAL(Manager::Instance().getVariable(
"closestInList(A, B, C)"));
2660 const auto* nonexistent = Manager::Instance().getVariable(
"closestInList(NONEXISTANTLIST, E)");
2661 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2663 const auto* empty = Manager::Instance().getVariable(
"closestInList(testEmptyList, E)");
2664 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2666 const auto* closest = Manager::Instance().getVariable(
"closestInList(testGammaList, E)");
2667 EXPECT_FLOAT_EQ(std::get<double>(closest->function(electron)), 3.4);
2669 const auto* closestCMS = Manager::Instance().getVariable(
"useCMSFrame(closestInList(testGammaList, E))");
2670 EXPECT_FLOAT_EQ(std::get<double>(closestCMS->function(electron)), 3.2732551);
2672 const auto* closestCMSLabE = Manager::Instance().getVariable(
"useCMSFrame(closestInList(testGammaList, useLabFrame(E)))");
2673 EXPECT_FLOAT_EQ(std::get<double>(closestCMSLabE->function(electron)), 3.4);
2677 EXPECT_B2FATAL(Manager::Instance().getVariable(
"angleToMostB2BInList"));
2678 EXPECT_B2FATAL(Manager::Instance().getVariable(
"angleToMostB2BInList(A, B)"));
2680 const auto* nonexistent = Manager::Instance().getVariable(
"angleToMostB2BInList(NONEXISTANTLIST)");
2681 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2683 const auto* empty = Manager::Instance().getVariable(
"angleToMostB2BInList(testEmptyList)");
2684 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2686 const auto* mostB2B = Manager::Instance().getVariable(
"angleToMostB2BInList(testGammaList)");
2687 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 2.2869499);
2689 const auto* mostB2BCMS = Manager::Instance().getVariable(
"useCMSFrame(angleToMostB2BInList(testGammaList))");
2690 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 2.8312778);
2694 EXPECT_B2FATAL(Manager::Instance().getVariable(
"mostB2BInList"));
2695 EXPECT_B2FATAL(Manager::Instance().getVariable(
"mostB2BInList(A, B, C)"));
2697 const auto* nonexistent = Manager::Instance().getVariable(
"mostB2BInList(NONEXISTANTLIST, E)");
2698 EXPECT_B2FATAL(std::get<double>(nonexistent->function(electron)));
2700 const auto* empty = Manager::Instance().getVariable(
"mostB2BInList(testEmptyList, E)");
2701 EXPECT_TRUE(std::isnan(std::get<double>(empty->function(electron))));
2703 const auto* mostB2B = Manager::Instance().getVariable(
"mostB2BInList(testGammaList, E)");
2704 EXPECT_FLOAT_EQ(std::get<double>(mostB2B->function(electron)), 1.7);
2706 const auto* mostB2BCMS = Manager::Instance().getVariable(
"useCMSFrame(mostB2BInList(testGammaList, E))");
2707 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMS->function(electron)), 1.5848758);
2709 const auto* mostB2BCMSLabE = Manager::Instance().getVariable(
"useCMSFrame(mostB2BInList(testGammaList, useLabFrame(E)))");
2710 EXPECT_FLOAT_EQ(std::get<double>(mostB2BCMSLabE->function(electron)), 1.7);
2714 TEST_F(MetaVariableTest, totalEnergyOfParticlesInList)
2722 DataStore::Instance().setInitializeActive(
true);
2723 gammalist.registerInDataStore(flags);
2724 DataStore::Instance().setInitializeActive(
false);
2726 gammalist->initialize(22,
"testGammaList");
2729 std::vector<Particle> gammavector = {
2730 Particle({0.5, 0.4, 0.4, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 0),
2731 Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1),
2732 Particle({0.4, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 2),
2733 Particle({0.5, 0.4, 0.8, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3),
2734 Particle({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4)
2738 for (
const auto& g : gammavector)
2739 particles.appendNew(g);
2742 for (
size_t i = 0; i < gammavector.size(); i++)
2743 gammalist->addParticle(i, 22, Particle::c_Unflavored);
2746 const Manager::Var* vnonsense = Manager::Instance().getVariable(
2747 "totalEnergyOfParticlesInList(NONEXISTANTLIST)");
2748 const Manager::Var* vsensible = Manager::Instance().getVariable(
2749 "totalEnergyOfParticlesInList(testGammaList)");
2752 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2753 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 4.3);
2755 TEST_F(MetaVariableTest, totalPxOfParticlesInList)
2763 DataStore::Instance().setInitializeActive(
true);
2764 gammalist.registerInDataStore(flags);
2765 DataStore::Instance().setInitializeActive(
false);
2767 gammalist->initialize(22,
"testGammaList");
2770 std::vector<Particle> gammavector = {
2771 Particle({0.5, 0.4, 0.5, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 0),
2772 Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1),
2773 Particle({0.4, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 2),
2774 Particle({0.5, 0.4, 0.8, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3),
2775 Particle({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4)
2779 for (
const auto& g : gammavector)
2780 particles.appendNew(g);
2783 for (
size_t i = 0; i < gammavector.size(); i++)
2784 gammalist->addParticle(i, 22, Particle::c_Unflavored);
2787 const Manager::Var* vnonsense = Manager::Instance().getVariable(
2788 "totalPxOfParticlesInList(NONEXISTANTLIST)");
2789 const Manager::Var* vsensible = Manager::Instance().getVariable(
2790 "totalPxOfParticlesInList(testGammaList)");
2793 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2794 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 2.2);
2796 TEST_F(MetaVariableTest, totalPyOfParticlesInList)
2804 DataStore::Instance().setInitializeActive(
true);
2805 gammalist.registerInDataStore(flags);
2806 DataStore::Instance().setInitializeActive(
false);
2808 gammalist->initialize(22,
"testGammaList");
2811 std::vector<Particle> gammavector = {
2812 Particle({0.5, 0.4, 0.5, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 0),
2813 Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1),
2814 Particle({0.4, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 2),
2815 Particle({0.5, 0.4, 0.8, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3),
2816 Particle({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4)
2820 for (
const auto& g : gammavector)
2821 particles.appendNew(g);
2824 for (
size_t i = 0; i < gammavector.size(); i++)
2825 gammalist->addParticle(i, 22, Particle::c_Unflavored);
2828 const Manager::Var* vnonsense = Manager::Instance().getVariable(
2829 "totalPyOfParticlesInList(NONEXISTANTLIST)");
2830 const Manager::Var* vsensible = Manager::Instance().getVariable(
2831 "totalPyOfParticlesInList(testGammaList)");
2834 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2835 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 1.5);
2837 TEST_F(MetaVariableTest, totalPzOfParticlesInList)
2845 DataStore::Instance().setInitializeActive(
true);
2846 gammalist.registerInDataStore(flags);
2847 DataStore::Instance().setInitializeActive(
false);
2849 gammalist->initialize(22,
"testGammaList");
2852 std::vector<Particle> gammavector = {
2853 Particle({0.5, 0.4, 0.5, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 0),
2854 Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1),
2855 Particle({0.4, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 2),
2856 Particle({0.5, 0.4, 0.8, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3),
2857 Particle({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4)
2861 for (
const auto& g : gammavector)
2862 particles.appendNew(g);
2865 for (
size_t i = 0; i < gammavector.size(); i++)
2866 gammalist->addParticle(i, 22, Particle::c_Unflavored);
2869 const Manager::Var* vnonsense = Manager::Instance().getVariable(
2870 "totalPzOfParticlesInList(NONEXISTANTLIST)");
2871 const Manager::Var* vsensible = Manager::Instance().getVariable(
2872 "totalPzOfParticlesInList(testGammaList)");
2875 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2876 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)), 3.1);
2878 TEST_F(MetaVariableTest, maxPtInList)
2886 DataStore::Instance().setInitializeActive(
true);
2887 gammalist.registerInDataStore(flags);
2888 DataStore::Instance().setInitializeActive(
false);
2890 gammalist->initialize(22,
"testGammaList");
2893 std::vector<Particle> gammavector = {
2894 Particle({0.5, 0.4, 0.5, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 0),
2895 Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1),
2896 Particle({0.4, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 2),
2897 Particle({0.5, 0.4, 0.8, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3),
2898 Particle({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4)
2902 for (
const auto& g : gammavector)
2903 particles.appendNew(g);
2906 for (
size_t i = 0; i < gammavector.size(); i++)
2907 gammalist->addParticle(i, 22, Particle::c_Unflavored);
2910 const Manager::Var* vnonsense = Manager::Instance().getVariable(
2911 "maxPtInList(NONEXISTANTLIST)");
2912 const Manager::Var* vsensible = Manager::Instance().getVariable(
2913 "maxPtInList(testGammaList)");
2916 EXPECT_B2FATAL(std::get<double>(vnonsense->
function(
nullptr)));
2917 EXPECT_FLOAT_EQ(std::get<double>(vsensible->
function(
nullptr)),
sqrt(0.5 * 0.5 + 0.4 * 0.4));
2921 TEST_F(MetaVariableTest, numberOfNonOverlappingParticles)
2927 DataStore::Instance().setInitializeActive(
true);
2928 outputList.registerInDataStore(flags);
2929 DataStore::Instance().setInitializeActive(
false);
2930 outputList.create();
2931 outputList->initialize(22,
"pList1");
2933 auto* p1 = particles.appendNew(
Particle({0.5, 0.4, 0.5, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 2));
2934 auto* p2 = particles.appendNew(
Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3));
2935 auto* p3 = particles.appendNew(
Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4));
2937 outputList->addParticle(0, 22, Particle::c_Unflavored);
2938 outputList->addParticle(1, 22, Particle::c_Unflavored);
2940 const Manager::Var* var = Manager::Instance().getVariable(
"numberOfNonOverlappingParticles(pList1)");
2941 ASSERT_NE(var,
nullptr);
2942 EXPECT_EQ(std::get<int>(var->function(p1)), 1);
2943 EXPECT_EQ(std::get<int>(var->function(p2)), 1);
2944 EXPECT_EQ(std::get<int>(var->function(p3)), 2);
2948 TEST_F(MetaVariableTest, veto)
2953 const Particle* p = particles.appendNew(
Particle({0.8, 0.8, 1.131370849898476039041351, 1.6}, 22,
2954 Particle::c_Unflavored, Particle::c_Undefined, 1));
2957 DataStore::Instance().setInitializeActive(
true);
2958 outputList.registerInDataStore(flags);
2959 DataStore::Instance().setInitializeActive(
false);
2960 outputList.create();
2961 outputList->initialize(22,
"pList1");
2963 particles.appendNew(
Particle({0.5, 0.4953406774856531014212777, 0.5609256753154148484773173, 0.9}, 22,
2964 Particle::c_Unflavored, Particle::c_Undefined, 2));
2965 particles.appendNew(
Particle({0.5, 0.2, 0.72111, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3));
2966 particles.appendNew(
Particle({0.4, 0.2, 0.78102, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4));
2967 particles.appendNew(
Particle({0.5, 0.4, 0.89443, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 5));
2968 particles.appendNew(
Particle({0.3, 0.3, 0.42426, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 6));
2970 outputList->addParticle(1, 22, Particle::c_Unflavored);
2971 outputList->addParticle(2, 22, Particle::c_Unflavored);
2972 outputList->addParticle(3, 22, Particle::c_Unflavored);
2973 outputList->addParticle(4, 22, Particle::c_Unflavored);
2974 outputList->addParticle(5, 22, Particle::c_Unflavored);
2977 DataStore::Instance().setInitializeActive(
true);
2978 outputList2.registerInDataStore(flags);
2979 DataStore::Instance().setInitializeActive(
false);
2980 outputList2.create();
2981 outputList2->initialize(22,
"pList2");
2983 particles.appendNew(
Particle({0.5, -0.4, 0.63246, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 7));
2984 particles.appendNew(
Particle({0.5, 0.2, 0.72111, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 8));
2985 particles.appendNew(
Particle({0.4, 0.2, 0.78102, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 9));
2986 particles.appendNew(
Particle({0.5, 0.4, 0.89443, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 10));
2987 particles.appendNew(
Particle({0.3, 0.3, 0.42426, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 11));
2989 outputList2->addParticle(6, 22, Particle::c_Unflavored);
2990 outputList2->addParticle(7, 22, Particle::c_Unflavored);
2991 outputList2->addParticle(8, 22, Particle::c_Unflavored);
2992 outputList2->addParticle(9, 22, Particle::c_Unflavored);
2993 outputList2->addParticle(10, 22, Particle::c_Unflavored);
2995 const Manager::Var* var = Manager::Instance().getVariable(
"veto(pList1, 0.130 < M < 0.140, 22)");
2996 ASSERT_NE(var,
nullptr);
2997 EXPECT_TRUE(std::get<bool>(var->function(p)));
2999 var = Manager::Instance().getVariable(
"veto(pList2, 0.130 < M < 0.140, 22)");
3000 ASSERT_NE(var,
nullptr);
3001 EXPECT_FALSE(std::get<bool>(var->function(p)));
3005 TEST_F(MetaVariableTest, averageValueInList)
3013 DataStore::Instance().setInitializeActive(
true);
3014 gammalist.registerInDataStore(flags);
3015 DataStore::Instance().setInitializeActive(
false);
3017 gammalist->initialize(22,
"testGammaList");
3020 std::vector<Particle> gammavector = {
3021 Particle({0.5, 0.4, 0.4, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 0),
3022 Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1),
3023 Particle({0.4, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 2),
3024 Particle({0.5, 0.4, 0.8, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3),
3025 Particle({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4)
3029 for (
const auto& g : gammavector)
3030 particles.appendNew(g);
3033 for (
size_t i = 0; i < gammavector.size(); i++)
3034 gammalist->addParticle(i, 22, Particle::c_Unflavored);
3037 const Manager::Var* vmeanpx = Manager::Instance().getVariable(
3038 "averageValueInList(testGammaList, px)");
3039 const Manager::Var* vmeanpy = Manager::Instance().getVariable(
3040 "averageValueInList(testGammaList, py)");
3041 const Manager::Var* vmeanpz = Manager::Instance().getVariable(
3042 "averageValueInList(testGammaList, pz)");
3043 const Manager::Var* vmeanE = Manager::Instance().getVariable(
3044 "averageValueInList(testGammaList, E)");
3046 EXPECT_FLOAT_EQ(std::get<double>(vmeanpx->
function(
nullptr)), 0.44);
3047 EXPECT_FLOAT_EQ(std::get<double>(vmeanpy->
function(
nullptr)), 0.3);
3048 EXPECT_FLOAT_EQ(std::get<double>(vmeanpz->
function(
nullptr)), 0.6);
3049 EXPECT_FLOAT_EQ(std::get<double>(vmeanE->
function(
nullptr)), 0.86);
3052 EXPECT_B2FATAL(Manager::Instance().getVariable(
"averageValueInList(testGammaList)"));
3055 EXPECT_B2FATAL(Manager::Instance().getVariable(
"averageValueInList(testGammaList, NONEXISTANTVARIABLE)"));
3058 const Manager::Var* vnolist = Manager::Instance().getVariable(
3059 "averageValueInList(NONEXISTANTLIST, px)");
3061 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3064 TEST_F(MetaVariableTest, medianValueInList)
3072 DataStore::Instance().setInitializeActive(
true);
3073 oddgammalist.registerInDataStore(flags);
3074 DataStore::Instance().setInitializeActive(
false);
3075 oddgammalist.create();
3076 oddgammalist->initialize(22,
"oddGammaList");
3078 DataStore::Instance().setInitializeActive(
true);
3079 evengammalist.registerInDataStore(flags);
3080 DataStore::Instance().setInitializeActive(
false);
3081 evengammalist.create();
3082 evengammalist->initialize(22,
"evenGammaList");
3085 std::vector<Particle> gammavector = {
3086 Particle({0.5, 0.4, 0.4, 0.8}, 22, Particle::c_Unflavored, Particle::c_Undefined, 0),
3087 Particle({0.5, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 1),
3088 Particle({0.4, 0.2, 0.7, 0.9}, 22, Particle::c_Unflavored, Particle::c_Undefined, 2),
3089 Particle({0.5, 0.4, 0.8, 1.1}, 22, Particle::c_Unflavored, Particle::c_Undefined, 3),
3090 Particle({0.3, 0.3, 0.4, 0.6}, 22, Particle::c_Unflavored, Particle::c_Undefined, 4)
3094 for (
const auto& g : gammavector)
3095 particles.appendNew(g);
3098 oddgammalist->addParticle(0, 22, Particle::c_Unflavored);
3099 for (
size_t i = 1; i < gammavector.size(); i++) {
3100 oddgammalist->addParticle(i, 22, Particle::c_Unflavored);
3101 evengammalist->addParticle(i, 22, Particle::c_Unflavored);
3105 const Manager::Var* voddmedianpx = Manager::Instance().getVariable(
3106 "medianValueInList(oddGammaList, px)");
3107 const Manager::Var* voddmedianpy = Manager::Instance().getVariable(
3108 "medianValueInList(oddGammaList, py)");
3109 const Manager::Var* voddmedianpz = Manager::Instance().getVariable(
3110 "medianValueInList(oddGammaList, pz)");
3111 const Manager::Var* voddmedianE = Manager::Instance().getVariable(
3112 "medianValueInList(oddGammaList, E)");
3114 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpx->
function(
nullptr)), 0.5);
3115 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpy->
function(
nullptr)), 0.3);
3116 EXPECT_FLOAT_EQ(std::get<double>(voddmedianpz->
function(
nullptr)), 0.7);
3117 EXPECT_FLOAT_EQ(std::get<double>(voddmedianE->
function(
nullptr)), 0.9);
3120 const Manager::Var* vevenmedianpx = Manager::Instance().getVariable(
3121 "medianValueInList(evenGammaList, px)");
3122 const Manager::Var* vevenmedianpy = Manager::Instance().getVariable(
3123 "medianValueInList(evenGammaList, py)");
3124 const Manager::Var* vevenmedianpz = Manager::Instance().getVariable(
3125 "medianValueInList(evenGammaList, pz)");
3126 const Manager::Var* vevenmedianE = Manager::Instance().getVariable(
3127 "medianValueInList(evenGammaList, E)");
3129 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpx->
function(
nullptr)), 0.45);
3130 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpy->
function(
nullptr)), 0.25);
3131 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianpz->
function(
nullptr)), 0.7);
3132 EXPECT_FLOAT_EQ(std::get<double>(vevenmedianE->
function(
nullptr)), 0.9);
3135 EXPECT_B2FATAL(Manager::Instance().getVariable(
"medianValueInList(oddGammaList)"));
3138 EXPECT_B2FATAL(Manager::Instance().getVariable(
"medianValueInList(oddGammaList, NONEXISTANTVARIABLE)"));
3141 const Manager::Var* vnolist = Manager::Instance().getVariable(
3142 "medianValueInList(NONEXISTANTLIST, px)");
3144 EXPECT_B2FATAL(std::get<double>(vnolist->
function(
nullptr)));
3147 TEST_F(MetaVariableTest, pValueCombination)
3149 PxPyPzEVector momentum;
3151 std::vector<int> daughterIndices;
3152 Particle KS(PxPyPzEVector(1.164, 1.55200, 0, 2), 310, Particle::c_Unflavored, Particle::c_Composite, 0);
3154 momentum += KS.get4Vector();
3155 Particle* newDaughters = particles.appendNew(KS);
3157 Particle Jpsi(PxPyPzEVector(-1, 1, 1, 3.548), 443, Particle::c_Unflavored, Particle::c_Composite, 1);
3158 Jpsi.setPValue(0.9);
3159 momentum += Jpsi.get4Vector();
3160 newDaughters = particles.appendNew(Jpsi);
3162 Particle* B = particles.appendNew(momentum, 521, Particle::c_Flavored, daughterIndices);
3165 const Manager::Var* singlePvalue = Manager::Instance().getVariable(
"pValueCombination(chiProb)");
3166 ASSERT_NE(singlePvalue,
nullptr);
3167 EXPECT_FLOAT_EQ(std::get<double>(singlePvalue->
function(B)), 0.5);
3169 const Manager::Var* twoPvalues = Manager::Instance().getVariable(
"pValueCombination(chiProb, daughter(0, chiProb))");
3170 ASSERT_NE(twoPvalues,
nullptr);
3171 EXPECT_FLOAT_EQ(std::get<double>(twoPvalues->
function(B)), 0.05 * (1 - log(0.05)));
3174 Manager::Instance().getVariable(
"pValueCombination(chiProb, daughter(0, chiProb), daughter(1, chiProb))");
3175 ASSERT_NE(threePvalues,
nullptr);
3176 EXPECT_FLOAT_EQ(std::get<double>(threePvalues->
function(B)), 0.045 * (1 - log(0.045) + 0.5 * log(0.045) * log(0.045)));
3179 EXPECT_B2FATAL(Manager::Instance().getVariable(
"pValueCombination()"));
3182 EXPECT_B2FATAL(Manager::Instance().getVariable(
"pValueCombination(chiProb, NONEXISTANTVARIABLE)"));
3186 TEST_F(MetaVariableTest, daughterCombinationOneGeneration)
3188 const int nDaughters = 5;
3189 PxPyPzEVector momentum(0, 0, 0, 0);
3191 std::vector<int> daughterIndices;
3192 std::vector<PxPyPzEVector> daughterMomenta;
3194 for (
int i = 0; i < nDaughters; i++) {
3195 PxPyPzEVector mom(1, i * 0.5, 1, i * 1.0 + 2.0);
3196 Particle d(mom, (i % 2) ? 111 : 113);
3197 Particle* newDaughters = particles.appendNew(d);
3199 daughterMomenta.push_back(mom);
3200 momentum = momentum + mom;
3202 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Flavored, daughterIndices);
3205 const Manager::Var* var = Manager::Instance().getVariable(
"daughterCombination(M, 0,1,2)");
3206 double M_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[2]).mag();
3207 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3209 var = Manager::Instance().getVariable(
"daughterCombination(M, 0,4)");
3210 M_test = (daughterMomenta[0] + daughterMomenta[4]).mag();
3211 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3215 var = Manager::Instance().getVariable(
"daughterCombination(p, 1, 0, 4)");
3216 double p_test = (daughterMomenta[0] + daughterMomenta[1] + daughterMomenta[4]).P();
3217 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), p_test);
3221 EXPECT_B2FATAL(Manager::Instance().getVariable(
"daughterCombination(aVeryNonExistingVariableSillyName, 1, 0, 4)"));
3223 var = Manager::Instance().getVariable(
"daughterCombination(M, 1, 0, 100)");
3224 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3225 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3228 var = Manager::Instance().getVariable(
"daughterCombination(M, 1, -1)");
3229 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3230 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3233 var = Manager::Instance().getVariable(
"daughterCombination(M, 1, 0:1:0:0:1)");
3234 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3235 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3240 TEST_F(MetaVariableTest, daughterCombinationTwoGenerations)
3246 PxPyPzEVector momentum_1(0, 0, 0, 0);
3247 std::vector<PxPyPzEVector> daughterMomenta_1;
3248 std::vector<int> daughterIndices_1;
3250 for (
int i = 0; i < 3; i++) {
3251 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3252 Particle d(mom, (i % 2) ? 111 : 113);
3253 Particle* newDaughters = particles.appendNew(d);
3255 daughterMomenta_1.push_back(mom);
3256 momentum_1 = momentum_1 + mom;
3259 const Particle* compositeDau_1 = particles.appendNew(momentum_1, 411, Particle::c_Flavored, daughterIndices_1);
3264 PxPyPzEVector momentum_2(0, 0, 0, 0);
3265 std::vector<PxPyPzEVector> daughterMomenta_2;
3266 std::vector<int> daughterIndices_2;
3268 for (
int i = 0; i < 2; i++) {
3269 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3270 Particle d(mom, (i % 2) ? 111 : 113);
3271 Particle* newDaughters = particles.appendNew(d);
3273 daughterMomenta_2.push_back(mom);
3274 momentum_2 = momentum_2 + mom;
3277 const Particle* compositeDau_2 = particles.appendNew(momentum_2, 411, Particle::c_Flavored, daughterIndices_2);
3282 const Particle* p = particles.appendNew(momentum_2 + momentum_1, 111, Particle::c_Unflavored, daughterIndices);
3286 const Manager::Var* var = Manager::Instance().getVariable(
"daughterCombination(M, 0,1)");
3288 double M_test = (momentum_1 + momentum_2).mag();
3289 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3292 var = Manager::Instance().getVariable(
"daughterCombination(M, 0:0, 0:1, 0:2)");
3293 M_test = (momentum_1).mag();
3294 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3297 var = Manager::Instance().getVariable(
"daughterCombination(M, 0:0, 0:1, 1:0)");
3298 M_test = (daughterMomenta_1[0] + daughterMomenta_1[1] + daughterMomenta_2[0]).mag();
3299 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), M_test);
3304 TEST_F(MetaVariableTest, useAlternativeDaughterHypothesis)
3306 const int nDaughters = 5;
3310 PxPyPzEVector momentum(0, 0, 0, 0);
3311 std::vector<int> daughterIndices;
3312 for (
int i = 0; i < nDaughters; i++) {
3313 double px = i * 0.1;
3314 double py = i * 0.3;
3315 double pz = -i * 0.1 - 0.2;
3317 PxPyPzEVector mom(px, py, pz, 1);
3319 int pdgCode = Const::pion.getPDGCode();
3321 d.updateMass(pdgCode);
3322 mom = d.get4Vector();
3324 Particle* daughters = particles.appendNew(d);
3326 momentum = momentum + mom;
3328 const Particle* p = particles.appendNew(momentum, 411, Particle::c_Flavored, daughterIndices);
3332 PxPyPzEVector momentumAlt(0, 0, 0, 0);
3333 std::vector<int> daughterIndicesAlt;
3334 for (
int i = 0; i < nDaughters; i++) {
3335 double px = i * 0.1;
3336 double py = i * 0.3;
3337 double pz = -i * 0.1 - 0.2;
3339 PxPyPzEVector mom(px, py, pz, 1);
3341 int pdgCode = Const::pion.getPDGCode();
3343 pdgCode = Const::proton.getPDGCode();
3345 pdgCode = Const::kaon.getPDGCode();
3347 d.updateMass(pdgCode);
3348 mom = d.get4Vector();
3350 Particle* daughters = particles.appendNew(d);
3352 momentumAlt = momentumAlt + mom;
3354 const Particle* pAlt = particles.appendNew(momentumAlt, 411, Particle::c_Flavored, daughterIndicesAlt);
3358 std::cout <<
"mass test" << std::endl;
3359 const Manager::Var* var = Manager::Instance().getVariable(
"useAlternativeDaughterHypothesis(M, 0:p+,1:K+)");
3360 const Manager::Var* varAlt = Manager::Instance().getVariable(
"M");
3361 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3364 std::cout <<
"charge test" << std::endl;
3365 var = Manager::Instance().getVariable(
"useAlternativeDaughterHypothesis(M, 0:p+,1:K-)");
3366 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3369 std::cout <<
"momentum test" << std::endl;
3370 var = Manager::Instance().getVariable(
"useAlternativeDaughterHypothesis(p, 0:p+,1:K-)");
3371 varAlt = Manager::Instance().getVariable(
"p");
3372 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(pAlt)));
3373 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), std::get<double>(varAlt->
function(p)));
3374 EXPECT_FLOAT_EQ(std::get<double>(var->function(pAlt)), std::get<double>(varAlt->
function(pAlt)));
3380 TEST_F(MetaVariableTest, daughterAngle)
3386 PxPyPzEVector momentum_1(0, 0, 0, 0);
3387 std::vector<PxPyPzEVector> daughterMomenta_1;
3388 std::vector<int> daughterIndices_1;
3390 for (
int i = 0; i < 3; i++) {
3391 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3392 Particle d(mom, (i % 2) ? -11 : 211);
3393 Particle* newDaughters = particles.appendNew(d);
3395 daughterMomenta_1.push_back(mom);
3396 momentum_1 = momentum_1 + mom;
3399 const Particle* compositeDau_1 = particles.appendNew(momentum_1, 411, Particle::c_Flavored, daughterIndices_1);
3404 PxPyPzEVector momentum_2(0, 0, 0, 0);
3405 std::vector<PxPyPzEVector> daughterMomenta_2;
3406 std::vector<int> daughterIndices_2;
3408 for (
int i = 0; i < 2; i++) {
3409 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3410 Particle d(mom, (i % 2) ? -11 : 211);
3411 Particle* newDaughters = particles.appendNew(d);
3413 daughterMomenta_2.push_back(mom);
3414 momentum_2 = momentum_2 + mom;
3417 const Particle* compositeDau_2 = particles.appendNew(momentum_2, 411, Particle::c_Flavored, daughterIndices_2);
3422 const Particle* p = particles.appendNew(momentum_2 + momentum_1, 111, Particle::c_Unflavored, daughterIndices);
3426 const Manager::Var* var = Manager::Instance().getVariable(
"daughterAngle(0, 1)");
3427 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3429 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3432 var = Manager::Instance().getVariable(
"daughterAngle(0:0, 1:0)");
3433 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3434 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3436 var = Manager::Instance().getVariable(
"daughterAngle( 1, -1)");
3437 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3438 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3440 var = Manager::Instance().getVariable(
"daughterAngle(1, 0:1:0:0:1)");
3441 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3442 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3446 TEST_F(MetaVariableTest, mcDaughterVariables)
3449 DataStore::Instance().setInitializeActive(
true);
3452 particles.registerRelationTo(mcParticles);
3453 DataStore::Instance().setInitializeActive(
true);
3456 PxPyPzEVector momentum_1(0, 0, 0, 0);
3457 std::vector<PxPyPzEVector> daughterMomenta_1;
3458 std::vector<int> daughterIndices_1;
3460 for (
int i = 0; i < 3; i++) {
3461 PxPyPzEVector mom(i * 0.2, 1, 1, i * 1.0 + 2.0);
3462 Particle d(mom, (i % 2) ? -11 : 211);
3463 Particle* newDaughters = particles.appendNew(d);
3465 daughterMomenta_1.push_back(mom);
3466 momentum_1 = momentum_1 + mom;
3468 auto* mcParticle = mcParticles.
appendNew();
3469 mcParticle->
setPDG((i % 2) ? -Const::electron.getPDGCode() : Const::pion.getPDGCode());
3470 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
3471 mcParticle->set4Vector(mom);
3475 const Particle* compositeDau_1 = particles.appendNew(momentum_1, 411, Particle::c_Flavored, daughterIndices_1);
3476 auto* mcCompositeDau_1 = mcParticles.
appendNew();
3477 mcCompositeDau_1->
setPDG(411);
3478 mcCompositeDau_1->setStatus(MCParticle::c_PrimaryParticle);
3479 mcCompositeDau_1->set4Vector(momentum_1);
3484 PxPyPzEVector momentum_2(0, 0, 0, 0);
3485 std::vector<PxPyPzEVector> daughterMomenta_2;
3486 std::vector<int> daughterIndices_2;
3488 for (
int i = 0; i < 2; i++) {
3489 PxPyPzEVector mom(1, 1, i * 0.3, i * 1.0 + 2.0);
3490 Particle d(mom, (i % 2) ? -11 : 211);
3491 Particle* newDaughters = particles.appendNew(d);
3493 daughterMomenta_2.push_back(mom);
3494 momentum_2 = momentum_2 + mom;
3496 auto* mcParticle = mcParticles.
appendNew();
3497 mcParticle->
setPDG((i % 2) ? -Const::electron.getPDGCode() : Const::pion.getPDGCode());
3498 mcParticle->setStatus(MCParticle::c_PrimaryParticle);
3499 mcParticle->set4Vector(mom);
3503 const Particle* compositeDau_2 = particles.appendNew(momentum_2, 411, Particle::c_Flavored, daughterIndices_2);
3504 auto* mcCompositeDau_2 = mcParticles.
appendNew();
3505 mcCompositeDau_2->
setPDG(411);
3506 mcCompositeDau_2->setStatus(MCParticle::c_PrimaryParticle);
3507 mcCompositeDau_2->set4Vector(momentum_2);
3512 const Particle* p = particles.appendNew(momentum_2 + momentum_1, 111, Particle::c_Unflavored, daughterIndices);
3516 const Manager::Var* var = Manager::Instance().getVariable(
"mcDaughterAngle(0, 1)");
3517 double v_test = acos(momentum_1.Vect().Unit().Dot(momentum_2.Vect().Unit()));
3518 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3520 var = Manager::Instance().getVariable(
"mcDaughterAngle(0:0, 1:0)");
3521 v_test = acos(daughterMomenta_1[0].Vect().
Unit().Dot(daughterMomenta_2[0].Vect().
Unit()));
3522 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3524 var = Manager::Instance().getVariable(
"mcDaughterAngle( 1, -1)");
3525 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3526 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3528 var = Manager::Instance().getVariable(
"mcDaughterAngle(1, 0:1:0:0:1)");
3529 EXPECT_B2WARNING(std::get<double>(var->function(p)));
3530 EXPECT_TRUE(std::isnan(std::get<double>(var->function(p))));
3533 var = Manager::Instance().getVariable(
"mcDaughterDiffOf(0, 1, PDG)");
3534 ASSERT_NE(var,
nullptr);
3535 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), 0);
3537 EXPECT_B2FATAL(Manager::Instance().getVariable(
"mcDaughterDiffOf(0, NOTINT, PDG)"));
3540 var = Manager::Instance().getVariable(
"mcDaughterDiffOf(0, 1, phi)");
3541 ASSERT_NE(var,
nullptr);
3542 v_test = momentum_2.Phi() - momentum_1.Phi();
3543 EXPECT_FLOAT_EQ(std::get<double>(var->function(p)), v_test);
3547 TEST_F(MetaVariableTest, varForFirstMCAncestorOfType)
3549 DataStore::Instance().setInitializeActive(
true);
3552 particles.registerInDataStore();
3554 particles.registerRelationTo(mcParticles);
3556 DList.registerInDataStore();
3558 DList->initialize(421,
"D0:vartest");
3559 DataStore::Instance().setInitializeActive(
false);
3560 PxPyPzEVector momentum;
3561 PxPyPzEVector momentum_0;
3562 PxPyPzEVector momentum_1;
3563 std::vector<int> D_daughterIndices;
3564 std::vector<int> D_grandDaughterIndices_0;
3565 std::vector<int> D_grandDaughterIndices_1;
3582 mcg_d_0.
setPDG(-Const::Kshort.getPDGCode());
3583 mcg_d_0.
set4Vector(PxPyPzEVector(6, 6, 6, 6));
3584 mcg_d_1.
setPDG(Const::Kshort.getPDGCode());
3585 mcg_d_1.
set4Vector(PxPyPzEVector(5, 5, 5, 5));
3586 mcg_gd_0_0.
setPDG(Const::pion.getPDGCode());
3587 mcg_gd_0_0.
set4Vector(PxPyPzEVector(4, 4, 4, 4));
3588 mcg_gd_0_1.
setPDG(-Const::pion.getPDGCode());
3589 mcg_gd_0_1.
set4Vector(PxPyPzEVector(3, 3, 3, 3));
3590 mcg_gd_1_0.
setPDG(Const::pion.getPDGCode());
3591 mcg_gd_1_0.
set4Vector(PxPyPzEVector(2, 1, 2, 2));
3592 mcg_gd_1_1.
setPDG(-Const::pion.getPDGCode());
3593 mcg_gd_1_1.
set4Vector(PxPyPzEVector(1, 1, 1, 1));
3594 mcg_not_child.
setPDG(Const::pion.getPDGCode());
3595 mcg_not_child.
set4Vector(PxPyPzEVector(10, 10, 10, 10));
3607 auto* mc_not_child = mcParticles[0];
3608 auto* mc_m = mcParticles[1];
3609 auto* mc_d_0 = mcParticles[2];
3610 auto* mc_d_1 = mcParticles[3];
3611 auto* mc_gd_0_0 = mcParticles[4];
3612 auto* mc_gd_0_1 = mcParticles[5];
3613 auto* mc_gd_1_0 = mcParticles[6];
3614 auto* mc_gd_1_1 = mcParticles[7];
3617 mc_m->setStatus(MCParticle::c_PrimaryParticle);
3618 mc_d_0->setStatus(MCParticle::c_PrimaryParticle);
3619 mc_d_1->setStatus(MCParticle::c_PrimaryParticle);
3620 mc_gd_0_0->setStatus(MCParticle::c_PrimaryParticle);
3621 mc_gd_0_1->setStatus(MCParticle::c_PrimaryParticle);
3622 mc_gd_1_0->setStatus(MCParticle::c_PrimaryParticle);
3623 mc_gd_1_1->setStatus(MCParticle::c_PrimaryParticle);
3624 mc_not_child->setStatus(MCParticle::c_PrimaryParticle);
3628 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
3629 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
3630 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
3631 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
3633 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3634 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3635 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3636 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3641 const Particle* D_d_0 = particles.appendNew(momentum_0, 310, Particle::c_Unflavored, D_grandDaughterIndices_0);
3642 const Particle* D_d_1 = particles.appendNew(momentum_1, 310, Particle::c_Unflavored, D_grandDaughterIndices_1);
3649 const Particle* D_m = particles.appendNew(momentum, 421, Particle::c_Unflavored, D_daughterIndices);
3650 DList->addParticle(D_m);
3653 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
3656 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
3669 const Manager::Var* var_d = Manager::Instance().getVariable(
"varForFirstMCAncestorOfType(D0, mdstIndex)");
3670 ASSERT_NE(var_d,
nullptr);
3671 EXPECT_TRUE(std::get<double>(var_d->
function(D_gd_0_0)) >= 0);
3672 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_0_1)));
3673 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_1_0)), std::get<double>(var_d->
function(D_gd_1_1)));
3674 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_0)), std::get<double>(var_d->
function(D_gd_1_0)));
3675 EXPECT_FLOAT_EQ(std::get<double>(var_d->
function(D_gd_0_1)), std::get<double>(var_d->
function(D_gd_1_1)));
3676 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child))));
3677 EXPECT_TRUE(std::isnan(std::get<double>(var_d->
function(not_child_2))));
3681 const Manager::Var* var_310 = Manager::Instance().getVariable(
"varForFirstMCAncestorOfType(310, mdstIndex)");
3682 ASSERT_NE(var_310,
nullptr);
3683 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_0_1)));
3684 EXPECT_FLOAT_EQ(std::get<double>(var_310->
function(D_gd_1_0)), std::get<double>(var_310->
function(D_gd_1_1)));
3685 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_0)), std::get<double>(var_310->
function(D_gd_1_0)));
3686 EXPECT_NE(std::get<double>(var_310->
function(D_gd_0_1)), std::get<double>(var_310->
function(D_gd_1_1)));
3687 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child))));
3688 EXPECT_TRUE(std::isnan(std::get<double>(var_310->
function(not_child_2))));
3689 EXPECT_FLOAT_EQ(
int(std::get<double>(Manager::Instance().getVariable(
"varForFirstMCAncestorOfType(310, E)")->
function(D_gd_0_0))),
3693 TEST_F(MetaVariableTest, isDescendantOfList)
3695 DataStore::Instance().setInitializeActive(
true);
3697 DList.registerInDataStore();
3699 DList->initialize(421,
"D0:vartest");
3701 BList.registerInDataStore();
3703 BList->initialize(521,
"B:vartest");
3704 DataStore::Instance().setInitializeActive(
false);
3706 PxPyPzEVector momentum;
3707 PxPyPzEVector momentum_0;
3708 PxPyPzEVector momentum_1;
3710 std::vector<int> D_daughterIndices;
3711 std::vector<int> D_grandDaughterIndices_0;
3712 std::vector<int> D_grandDaughterIndices_1;
3713 std::vector<int> B_daughterIndices;
3714 std::vector<int> B_grandDaughterIndices;
3715 std::vector<int> B_grandGrandDaughterIndices;
3719 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211, Particle::c_Flavored, Particle::c_Track, 0);
3720 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211, Particle::c_Flavored, Particle::c_Track, 1);
3721 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211, Particle::c_Flavored, Particle::c_Track, 2);
3722 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211, Particle::c_Flavored, Particle::c_Track, 3);
3724 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
3725 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
3726 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
3727 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
3732 const Particle* D_d_0 = particles.appendNew(momentum_0, 310, Particle::c_Unflavored, D_grandDaughterIndices_0);
3733 const Particle* D_d_1 = particles.appendNew(momentum_1, 310, Particle::c_Unflavored, D_grandDaughterIndices_1);
3740 const Particle* D_m = particles.appendNew(momentum, 421, Particle::c_Unflavored, D_daughterIndices);
3741 DList->addParticle(D_m);
3745 const Particle* B_d_1 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211, Particle::c_Flavored, Particle::c_Track, 4);
3746 const Particle* B_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211, Particle::c_Flavored, Particle::c_Track, 5);
3747 const Particle* B_ggd_0_0_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211, Particle::c_Flavored, Particle::c_Track, 6);
3748 const Particle* B_ggd_0_0_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211, Particle::c_Flavored, Particle::c_Track, 7);
3750 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_0->
getArrayIndex());
3751 B_grandGrandDaughterIndices.push_back(B_ggd_0_0_1->
getArrayIndex());
3753 const Particle* B_gd_0_0 = particles.appendNew(momentum_0, 310, Particle::c_Unflavored, B_grandGrandDaughterIndices);
3755 B_grandDaughterIndices.push_back(B_gd_0_0->
getArrayIndex());
3756 B_grandDaughterIndices.push_back(B_gd_0_1->
getArrayIndex());
3758 const Particle* B_d_0 = particles.appendNew(momentum_1, -411, Particle::c_Unflavored, B_grandDaughterIndices);
3763 const Particle* B_m = particles.appendNew(momentum, 521, Particle::c_Unflavored, B_daughterIndices);
3764 BList->addParticle(B_m);
3767 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211, Particle::c_Flavored, Particle::c_Track, 8);
3770 const Manager::Var* var_0 = Manager::Instance().getVariable(
"isDescendantOfList(D0:vartest)");
3771 ASSERT_NE(var_0,
nullptr);
3772 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_0)));
3773 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_0_1)));
3774 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_0)));
3775 EXPECT_TRUE(std::get<bool>(var_0->
function(D_gd_1_1)));
3776 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_0)));
3777 EXPECT_TRUE(std::get<bool>(var_0->
function(D_d_1)));
3778 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_0)));
3779 EXPECT_FALSE(std::get<bool>(var_0->
function(B_ggd_0_0_1)));
3780 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_0)));
3781 EXPECT_FALSE(std::get<bool>(var_0->
function(B_gd_0_1)));
3782 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_0)));
3783 EXPECT_FALSE(std::get<bool>(var_0->
function(B_d_1)));
3784 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
3786 const Manager::Var* var_0a = Manager::Instance().getVariable(
"isDaughterOfList(D0:vartest)");
3787 ASSERT_NE(var_0a,
nullptr);
3788 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_0)));
3789 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_0_1)));
3790 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_0)));
3791 EXPECT_FALSE(std::get<bool>(var_0a->
function(D_gd_1_1)));
3792 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_0)));
3793 EXPECT_TRUE(std::get<bool>(var_0a->
function(D_d_1)));
3794 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_0)));
3795 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_ggd_0_0_1)));
3796 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_0)));
3797 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_gd_0_1)));
3798 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_0)));
3799 EXPECT_FALSE(std::get<bool>(var_0a->
function(B_d_1)));
3800 EXPECT_FALSE(std::get<bool>(var_0a->
function(not_child)));
3802 const Manager::Var* var_0b = Manager::Instance().getVariable(
"isGrandDaughterOfList(D0:vartest)");
3803 ASSERT_NE(var_0b,
nullptr);
3804 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_0)));
3805 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_0_1)));
3806 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_0)));
3807 EXPECT_TRUE(std::get<bool>(var_0b->
function(D_gd_1_1)));
3808 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_0)));
3809 EXPECT_FALSE(std::get<bool>(var_0b->
function(D_d_1)));
3810 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_0)));
3811 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_ggd_0_0_1)));
3812 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_0)));
3813 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_gd_0_1)));
3814 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_0)));
3815 EXPECT_FALSE(std::get<bool>(var_0b->
function(B_d_1)));
3816 EXPECT_FALSE(std::get<bool>(var_0b->
function(not_child)));
3818 const Manager::Var* var_1 = Manager::Instance().getVariable(
"isDescendantOfList(D0:vartest, 1)");
3819 ASSERT_NE(var_1,
nullptr);
3820 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
3821 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
3822 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
3823 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
3824 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_0)));
3825 EXPECT_TRUE(std::get<bool>(var_1->
function(D_d_1)));
3826 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_0)));
3827 EXPECT_FALSE(std::get<bool>(var_1->
function(B_ggd_0_0_1)));
3828 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_0)));
3829 EXPECT_FALSE(std::get<bool>(var_1->
function(B_gd_0_1)));
3830 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_0)));
3831 EXPECT_FALSE(std::get<bool>(var_1->
function(B_d_1)));
3832 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
3834 const Manager::Var* var_2 = Manager::Instance().getVariable(
"isDescendantOfList(D0:vartest, 2)");
3835 ASSERT_NE(var_2,
nullptr);
3836 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_0)));
3837 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_0_1)));
3838 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_0)));
3839 EXPECT_TRUE(std::get<bool>(var_2->
function(D_gd_1_1)));
3840 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
3841 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
3842 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_0)));
3843 EXPECT_FALSE(std::get<bool>(var_2->
function(B_ggd_0_0_1)));
3844 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_0)));
3845 EXPECT_FALSE(std::get<bool>(var_2->
function(B_gd_0_1)));
3846 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_0)));
3847 EXPECT_FALSE(std::get<bool>(var_2->
function(B_d_1)));
3848 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
3850 const Manager::Var* var_3 = Manager::Instance().getVariable(
"isDescendantOfList(D0:vartest, B:vartest)");
3851 ASSERT_NE(var_3,
nullptr);
3852 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_0)));
3853 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_0_1)));
3854 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_0)));
3855 EXPECT_TRUE(std::get<bool>(var_3->
function(D_gd_1_1)));
3856 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_0)));
3857 EXPECT_TRUE(std::get<bool>(var_3->
function(D_d_1)));
3858 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_0)));
3859 EXPECT_TRUE(std::get<bool>(var_3->
function(B_ggd_0_0_1)));
3860 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_0)));
3861 EXPECT_TRUE(std::get<bool>(var_3->
function(B_gd_0_1)));
3862 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_0)));
3863 EXPECT_TRUE(std::get<bool>(var_3->
function(B_d_1)));
3864 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
3866 const Manager::Var* var_4 = Manager::Instance().getVariable(
"isDescendantOfList(D0:vartest, B:vartest, -1)");
3867 ASSERT_NE(var_4,
nullptr);
3868 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_0)));
3869 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_0_1)));
3870 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_0)));
3871 EXPECT_TRUE(std::get<bool>(var_4->
function(D_gd_1_1)));
3872 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_0)));
3873 EXPECT_TRUE(std::get<bool>(var_4->
function(D_d_1)));
3874 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_0)));
3875 EXPECT_TRUE(std::get<bool>(var_4->
function(B_ggd_0_0_1)));
3876 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_0)));
3877 EXPECT_TRUE(std::get<bool>(var_4->
function(B_gd_0_1)));
3878 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_0)));
3879 EXPECT_TRUE(std::get<bool>(var_4->
function(B_d_1)));
3880 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
3882 const Manager::Var* var_5 = Manager::Instance().getVariable(
"isDescendantOfList(D0:vartest, B:vartest, 1)");
3883 ASSERT_NE(var_5,
nullptr);
3884 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
3885 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
3886 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
3887 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
3888 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_0)));
3889 EXPECT_TRUE(std::get<bool>(var_5->
function(D_d_1)));
3890 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_0)));
3891 EXPECT_FALSE(std::get<bool>(var_5->
function(B_ggd_0_0_1)));
3892 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_0)));
3893 EXPECT_FALSE(std::get<bool>(var_5->
function(B_gd_0_1)));
3894 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_0)));
3895 EXPECT_TRUE(std::get<bool>(var_5->
function(B_d_1)));
3896 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
3898 const Manager::Var* var_6 = Manager::Instance().getVariable(
"isDescendantOfList(D0:vartest, B:vartest, 2)");
3899 ASSERT_NE(var_6,
nullptr);
3900 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_0)));
3901 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_0_1)));
3902 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_0)));
3903 EXPECT_TRUE(std::get<bool>(var_6->
function(D_gd_1_1)));
3904 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_0)));
3905 EXPECT_FALSE(std::get<bool>(var_6->
function(D_d_1)));
3906 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_0)));
3907 EXPECT_FALSE(std::get<bool>(var_6->
function(B_ggd_0_0_1)));
3908 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_0)));
3909 EXPECT_TRUE(std::get<bool>(var_6->
function(B_gd_0_1)));
3910 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_0)));
3911 EXPECT_FALSE(std::get<bool>(var_6->
function(B_d_1)));
3912 EXPECT_FALSE(std::get<bool>(var_6->
function(not_child)));
3914 const Manager::Var* var_7 = Manager::Instance().getVariable(
"isDescendantOfList(D0:vartest, B:vartest, 3)");
3915 ASSERT_NE(var_7,
nullptr);
3916 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_0)));
3917 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_0_1)));
3918 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_0)));
3919 EXPECT_FALSE(std::get<bool>(var_7->
function(D_gd_1_1)));
3920 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_0)));
3921 EXPECT_FALSE(std::get<bool>(var_7->
function(D_d_1)));
3922 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_0)));
3923 EXPECT_TRUE(std::get<bool>(var_7->
function(B_ggd_0_0_1)));
3924 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_0)));
3925 EXPECT_FALSE(std::get<bool>(var_7->
function(B_gd_0_1)));
3926 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_0)));
3927 EXPECT_FALSE(std::get<bool>(var_7->
function(B_d_1)));
3928 EXPECT_FALSE(std::get<bool>(var_7->
function(not_child)));
3932 TEST_F(MetaVariableTest, isMCDescendantOfList)
3934 DataStore::Instance().setInitializeActive(
true);
3937 particles.registerInDataStore();
3939 particles.registerRelationTo(mcParticles);
3941 BList.registerInDataStore();
3943 BList->initialize(521,
"B:vartest");
3945 DList.registerInDataStore();
3947 DList->initialize(421,
"D0:vartest");
3948 DataStore::Instance().setInitializeActive(
false);
3949 PxPyPzEVector momentum;
3950 PxPyPzEVector momentum_0;
3951 PxPyPzEVector momentum_1;
3952 std::vector<int> daughterIndices;
3953 std::vector<int> grandDaughterIndices;
3954 std::vector<int> grandGrandDaughterIndices;
3955 std::vector<int> D_daughterIndices;
3956 std::vector<int> D_grandDaughterIndices_0;
3957 std::vector<int> D_grandDaughterIndices_1;
3974 mcg_d_1.
setPDG(Const::pion.getPDGCode());
3975 mcg_gd_0_0.
setPDG(Const::Kshort.getPDGCode());
3976 mcg_gd_0_1.
setPDG(-Const::pion.getPDGCode());
3977 mcg_ggd_0_0_0.
setPDG(Const::pion.getPDGCode());
3978 mcg_ggd_0_0_1.
setPDG(-Const::pion.getPDGCode());
3979 mcg_not_child.
setPDG(Const::pion.getPDGCode());
3991 auto* mc_m = mcParticles[0];
3992 auto* mc_d_0 = mcParticles[1];
3993 auto* mc_d_1 = mcParticles[2];
3994 auto* mc_gd_0_0 = mcParticles[3];
3995 auto* mc_gd_0_1 = mcParticles[4];
3996 auto* mc_ggd_0_0_0 = mcParticles[5];
3997 auto* mc_ggd_0_0_1 = mcParticles[6];
3998 auto* mc_not_child = mcParticles[7];
4000 mc_m->setStatus(MCParticle::c_PrimaryParticle);
4001 mc_d_0->setStatus(MCParticle::c_PrimaryParticle);
4002 mc_d_1->setStatus(MCParticle::c_PrimaryParticle);
4003 mc_gd_0_0->setStatus(MCParticle::c_PrimaryParticle);
4004 mc_gd_0_1->setStatus(MCParticle::c_PrimaryParticle);
4005 mc_ggd_0_0_0->setStatus(MCParticle::c_PrimaryParticle);
4006 mc_ggd_0_0_1->setStatus(MCParticle::c_PrimaryParticle);
4007 mc_not_child->setStatus(MCParticle::c_PrimaryParticle);
4011 const Particle* D_gd_0_0 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4012 const Particle* D_gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4013 const Particle* D_gd_1_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4014 const Particle* D_gd_1_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4016 D_grandDaughterIndices_0.push_back(D_gd_0_0->
getArrayIndex());
4017 D_grandDaughterIndices_0.push_back(D_gd_0_1->
getArrayIndex());
4018 D_grandDaughterIndices_1.push_back(D_gd_1_0->
getArrayIndex());
4019 D_grandDaughterIndices_1.push_back(D_gd_1_1->
getArrayIndex());
4024 const Particle* D_d_0 = particles.appendNew(momentum_0, 310, Particle::c_Unflavored, D_grandDaughterIndices_0);
4025 const Particle* D_d_1 = particles.appendNew(momentum_1, 310, Particle::c_Unflavored, D_grandDaughterIndices_1);
4032 const Particle* D_m = particles.appendNew(momentum, 421, Particle::c_Unflavored, D_daughterIndices);
4033 DList->addParticle(D_m);
4036 const Particle* d_1 = particles.appendNew(PxPyPzEVector(0.0, 1, 1, 1), 211);
4037 const Particle* gd_0_1 = particles.appendNew(PxPyPzEVector(1.0, 1, 1, 1), -211);
4038 const Particle* ggd_0_0_0 = particles.appendNew(PxPyPzEVector(2.0, 1, 1, 1), 211);
4039 const Particle* ggd_0_0_1 = particles.appendNew(PxPyPzEVector(3.0, 1, 1, 1), -211);
4041 grandGrandDaughterIndices.push_back(ggd_0_0_0->
getArrayIndex());
4042 grandGrandDaughterIndices.push_back(ggd_0_0_1->
getArrayIndex());
4044 const Particle* gd_0_0 = particles.appendNew(momentum_0, 310, Particle::c_Unflavored, grandGrandDaughterIndices);
4049 const Particle* d_0 = particles.appendNew(momentum_1, -411, Particle::c_Unflavored, grandDaughterIndices);
4054 const Particle* m = particles.appendNew(momentum, 521, Particle::c_Unflavored, daughterIndices);
4055 BList->addParticle(m);
4058 const Particle* not_child = particles.appendNew(PxPyPzEVector(5.0, 1, 1, 1), 211);
4061 const Particle* not_child_2 = particles.appendNew(PxPyPzEVector(6.0, 1, 1, 1), 211);
4069 m->addRelationTo(mc_m);
4072 const Manager::Var* var_0 = Manager::Instance().getVariable(
"isMCDescendantOfList(B:vartest)");
4073 ASSERT_NE(var_0,
nullptr);
4074 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_0)));
4075 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_0_1)));
4076 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_0)));
4077 EXPECT_FALSE(std::get<bool>(var_0->
function(D_gd_1_1)));
4078 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_0)));
4079 EXPECT_FALSE(std::get<bool>(var_0->
function(D_d_1)));
4080 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_0)));
4081 EXPECT_TRUE(std::get<bool>(var_0->
function(ggd_0_0_1)));
4082 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_0)));
4083 EXPECT_TRUE(std::get<bool>(var_0->
function(gd_0_1)));
4084 EXPECT_TRUE(std::get<bool>(var_0->
function(d_0)));
4085 EXPECT_TRUE(std::get<bool>(var_0->
function(d_1)));
4086 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child)));
4087 EXPECT_FALSE(std::get<bool>(var_0->
function(not_child_2)));
4089 const Manager::Var* var_1 = Manager::Instance().getVariable(
"isMCDescendantOfList(B:vartest, D0:vartest)");
4090 ASSERT_NE(var_1,
nullptr);
4091 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_0)));
4092 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_0_1)));
4093 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_0)));
4094 EXPECT_FALSE(std::get<bool>(var_1->
function(D_gd_1_1)));
4095 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_0)));
4096 EXPECT_FALSE(std::get<bool>(var_1->
function(D_d_1)));
4097 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_0)));
4098 EXPECT_TRUE(std::get<bool>(var_1->
function(ggd_0_0_1)));
4099 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_0)));
4100 EXPECT_TRUE(std::get<bool>(var_1->
function(gd_0_1)));
4101 EXPECT_TRUE(std::get<bool>(var_1->
function(d_0)));
4102 EXPECT_TRUE(std::get<bool>(var_1->
function(d_1)));
4103 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child)));
4104 EXPECT_FALSE(std::get<bool>(var_1->
function(not_child_2)));
4106 const Manager::Var* var_2 = Manager::Instance().getVariable(
"isMCDescendantOfList(B:vartest, -1)");
4107 ASSERT_NE(var_2,
nullptr);
4108 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_0)));
4109 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_0_1)));
4110 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_0)));
4111 EXPECT_FALSE(std::get<bool>(var_2->
function(D_gd_1_1)));
4112 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_0)));
4113 EXPECT_FALSE(std::get<bool>(var_2->
function(D_d_1)));
4114 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_0)));
4115 EXPECT_TRUE(std::get<bool>(var_2->
function(ggd_0_0_1)));
4116 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_0)));
4117 EXPECT_TRUE(std::get<bool>(var_2->
function(gd_0_1)));
4118 EXPECT_TRUE(std::get<bool>(var_2->
function(d_0)));
4119 EXPECT_TRUE(std::get<bool>(var_2->
function(d_1)));
4120 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child)));
4121 EXPECT_FALSE(std::get<bool>(var_2->
function(not_child_2)));
4123 const Manager::Var* var_3 = Manager::Instance().getVariable(
"isMCDescendantOfList(B:vartest, 1)");
4124 ASSERT_NE(var_3,
nullptr);
4125 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_0)));
4126 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_0_1)));
4127 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_0)));
4128 EXPECT_FALSE(std::get<bool>(var_3->
function(D_gd_1_1)));
4129 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_0)));
4130 EXPECT_FALSE(std::get<bool>(var_3->
function(D_d_1)));
4131 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_0)));
4132 EXPECT_FALSE(std::get<bool>(var_3->
function(ggd_0_0_1)));
4133 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_0)));
4134 EXPECT_FALSE(std::get<bool>(var_3->
function(gd_0_1)));
4135 EXPECT_TRUE(std::get<bool>(var_3->
function(d_0)));
4136 EXPECT_TRUE(std::get<bool>(var_3->
function(d_1)));
4137 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child)));
4138 EXPECT_FALSE(std::get<bool>(var_3->
function(not_child_2)));
4140 const Manager::Var* var_4 = Manager::Instance().getVariable(
"isMCDescendantOfList(B:vartest, 2)");
4141 ASSERT_NE(var_4,
nullptr);
4142 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_0)));
4143 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_0_1)));
4144 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_0)));
4145 EXPECT_FALSE(std::get<bool>(var_4->
function(D_gd_1_1)));
4146 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_0)));
4147 EXPECT_FALSE(std::get<bool>(var_4->
function(D_d_1)));
4148 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_0)));
4149 EXPECT_FALSE(std::get<bool>(var_4->
function(ggd_0_0_1)));
4150 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_0)));
4151 EXPECT_TRUE(std::get<bool>(var_4->
function(gd_0_1)));
4152 EXPECT_FALSE(std::get<bool>(var_4->
function(d_0)));
4153 EXPECT_FALSE(std::get<bool>(var_4->
function(d_1)));
4154 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child)));
4155 EXPECT_FALSE(std::get<bool>(var_4->
function(not_child_2)));
4158 const Manager::Var* var_5 = Manager::Instance().getVariable(
"isMCDescendantOfList(B:vartest, 3)");
4159 ASSERT_NE(var_5,
nullptr);
4160 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_0)));
4161 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_0_1)));
4162 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_0)));
4163 EXPECT_FALSE(std::get<bool>(var_5->
function(D_gd_1_1)));
4164 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_0)));
4165 EXPECT_FALSE(std::get<bool>(var_5->
function(D_d_1)));
4166 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_0)));
4167 EXPECT_TRUE(std::get<bool>(var_5->
function(ggd_0_0_1)));
4168 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_0)));
4169 EXPECT_FALSE(std::get<bool>(var_5->
function(gd_0_1)));
4170 EXPECT_FALSE(std::get<bool>(var_5->
function(d_0)));
4171 EXPECT_FALSE(std::get<bool>(var_5->
function(d_1)));
4172 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child)));
4173 EXPECT_FALSE(std::get<bool>(var_5->
function(not_child_2)));
4180 class PIDVariableTest :
public ::testing::Test {
4183 void SetUp()
override
4185 DataStore::Instance().setInitializeActive(
true);
4196 particles.registerInDataStore();
4197 tracks.registerInDataStore();
4198 particles.registerRelationTo(likelihood);
4199 tracks.registerRelationTo(likelihood);
4200 DataStore::Instance().setInitializeActive(
false);
4204 void TearDown()
override
4206 DataStore::Instance().reset();
4210 TEST_F(PIDVariableTest, LogLikelihood)
4219 const float pValue = 0.5;
4220 const float bField = 1.5;
4222 TMatrixDSym cov6(6);
4224 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4225 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4226 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4228 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4229 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4231 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4232 tfrs.
appendNew(position, momentum, cov6, charge, Const::electron, pValue, bField, CDCValue, 16777215, 0);
4235 Track* allTrack = tracks.appendNew(mytrack);
4236 Track* noSVDTrack = tracks.appendNew(mytrack);
4237 Track* noPIDTrack = tracks.appendNew(mytrack);
4238 Track* dEdxTrack = tracks.appendNew(mytrack);
4244 lAll->setLogLikelihood(Const::TOP, Const::electron, 0.18);
4245 lAll->setLogLikelihood(Const::ARICH, Const::electron, 0.16);
4246 lAll->setLogLikelihood(Const::ECL, Const::electron, 0.14);
4247 lAll->setLogLikelihood(Const::CDC, Const::electron, 0.12);
4248 lAll->setLogLikelihood(Const::SVD, Const::electron, 0.1);
4249 lAll->setLogLikelihood(Const::KLM, Const::electron, 0.01);
4251 lAll->setLogLikelihood(Const::TOP, Const::muon, 0.5);
4252 lAll->setLogLikelihood(Const::ARICH, Const::muon, 0.52);
4253 lAll->setLogLikelihood(Const::ECL, Const::muon, 0.54);
4254 lAll->setLogLikelihood(Const::CDC, Const::muon, 0.56);
4255 lAll->setLogLikelihood(Const::SVD, Const::muon, 0.58);
4256 lAll->setLogLikelihood(Const::KLM, Const::muon, 0.8);
4258 lAll->setLogLikelihood(Const::TOP, Const::pion, 0.2);
4259 lAll->setLogLikelihood(Const::ARICH, Const::pion, 0.22);
4260 lAll->setLogLikelihood(Const::ECL, Const::pion, 0.24);
4261 lAll->setLogLikelihood(Const::CDC, Const::pion, 0.26);
4262 lAll->setLogLikelihood(Const::SVD, Const::pion, 0.28);
4263 lAll->setLogLikelihood(Const::KLM, Const::pion, 0.2);
4265 lAll->setLogLikelihood(Const::TOP, Const::kaon, 0.3);
4266 lAll->setLogLikelihood(Const::ARICH, Const::kaon, 0.32);
4267 lAll->setLogLikelihood(Const::ECL, Const::kaon, 0.34);
4268 lAll->setLogLikelihood(Const::CDC, Const::kaon, 0.36);
4269 lAll->setLogLikelihood(Const::SVD, Const::kaon, 0.38);
4270 lAll->setLogLikelihood(Const::KLM, Const::kaon, 0.2);
4272 lAll->setLogLikelihood(Const::TOP, Const::proton, 0.4);
4273 lAll->setLogLikelihood(Const::ARICH, Const::proton, 0.42);
4274 lAll->setLogLikelihood(Const::ECL, Const::proton, 0.44);
4275 lAll->setLogLikelihood(Const::CDC, Const::proton, 0.46);
4276 lAll->setLogLikelihood(Const::SVD, Const::proton, 0.48);
4277 lAll->setLogLikelihood(Const::KLM, Const::proton, 0.02);
4279 lAll->setLogLikelihood(Const::TOP, Const::deuteron, 0.6);
4280 lAll->setLogLikelihood(Const::ARICH, Const::deuteron, 0.62);
4281 lAll->setLogLikelihood(Const::ECL, Const::deuteron, 0.64);
4282 lAll->setLogLikelihood(Const::CDC, Const::deuteron, 0.66);
4283 lAll->setLogLikelihood(Const::SVD, Const::deuteron, 0.68);
4284 lAll->setLogLikelihood(Const::KLM, Const::deuteron, 0.02);
4287 auto* lAllNoSVD = likelihood.
appendNew();
4289 for (
const auto& det : Const::PIDDetectorSet::set()) {
4290 for (
const auto& hypo : Const::chargedStableSet) {
4291 if (det != Const::SVD) {
4292 lAllNoSVD->setLogLikelihood(det, hypo, lAll->getLogL(hypo, det));
4299 ldEdx->setLogLikelihood(Const::CDC, Const::electron, 0.12);
4300 ldEdx->setLogLikelihood(Const::SVD, Const::electron, 0.1);
4302 ldEdx->setLogLikelihood(Const::CDC, Const::pion, 0.26);
4303 ldEdx->setLogLikelihood(Const::SVD, Const::pion, 0.28);
4305 ldEdx->setLogLikelihood(Const::CDC, Const::kaon, 0.36);
4306 ldEdx->setLogLikelihood(Const::SVD, Const::kaon, 0.38);
4308 ldEdx->setLogLikelihood(Const::CDC, Const::proton, 0.46);
4309 ldEdx->setLogLikelihood(Const::SVD, Const::proton, 0.48);
4311 ldEdx->setLogLikelihood(Const::CDC, Const::muon, 0.56);
4312 ldEdx->setLogLikelihood(Const::SVD, Const::muon, 0.58);
4314 ldEdx->setLogLikelihood(Const::CDC, Const::deuteron, 0.66);
4315 ldEdx->setLogLikelihood(Const::SVD, Const::deuteron, 0.68);
4330 auto* particleAll = particles.appendNew(allTrack, Const::pion);
4331 auto* particleNoSVD = particles.appendNew(noSVDTrack, Const::pion);
4332 auto* particledEdx = particles.appendNew(dEdxTrack, Const::pion);
4333 auto* particleNoID = particles.appendNew(noPIDTrack, Const::pion);
4335 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);
4336 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);
4339 EXPECT_FLOAT_EQ(electronID(particleAll), std::exp(0.71) / numsumexp);
4340 EXPECT_FLOAT_EQ(muonID(particleAll), std::exp(3.5) / numsumexp);
4341 EXPECT_FLOAT_EQ(pionID(particleAll), std::exp(1.4) / numsumexp);
4342 EXPECT_FLOAT_EQ(kaonID(particleAll), std::exp(1.9) / numsumexp);
4343 EXPECT_FLOAT_EQ(protonID(particleAll), std::exp(2.22) / numsumexp);
4344 EXPECT_FLOAT_EQ(deuteronID(particleAll), std::exp(3.22) / numsumexp);
4347 auto* particleElectron = particles.appendNew(allTrack, Const::electron);
4348 auto* particleMuon = particles.appendNew(allTrack, Const::muon);
4349 auto* particleKaon = particles.appendNew(allTrack, Const::kaon);
4350 auto* particleProton = particles.appendNew(allTrack, Const::proton);
4351 auto* particleDeuteron = particles.appendNew(allTrack, Const::deuteron);
4353 EXPECT_FLOAT_EQ(particleID(particleAll), std::exp(1.4) / numsumexp);
4354 EXPECT_FLOAT_EQ(particleID(particleElectron), std::exp(0.71) / numsumexp);
4355 EXPECT_FLOAT_EQ(particleID(particleMuon), std::exp(3.5) / numsumexp);
4356 EXPECT_FLOAT_EQ(particleID(particleKaon), std::exp(1.9) / numsumexp);
4357 EXPECT_FLOAT_EQ(particleID(particleProton), std::exp(2.22) / numsumexp);
4358 EXPECT_FLOAT_EQ(particleID(particleDeuteron), std::exp(3.22) / numsumexp);
4361 EXPECT_FLOAT_EQ(electronID_noSVD(particleNoSVD), std::exp(0.61) / numsumexp_noSVD);
4362 EXPECT_FLOAT_EQ(muonID_noSVD(particleNoSVD), std::exp(2.92) / numsumexp_noSVD);
4363 EXPECT_FLOAT_EQ(pionID_noSVD(particleNoSVD), std::exp(1.12) / numsumexp_noSVD);
4364 EXPECT_FLOAT_EQ(kaonID_noSVD(particleNoSVD), std::exp(1.52) / numsumexp_noSVD);
4365 EXPECT_FLOAT_EQ(protonID_noSVD(particleNoSVD), std::exp(1.74) / numsumexp_noSVD);
4366 EXPECT_FLOAT_EQ(deuteronID_noSVD(particleNoSVD), std::exp(2.54) / numsumexp_noSVD);
4369 std::vector<double> v_pi_K {211., 321.};
4370 std::vector<double> v_pi_p {211., 2212.};
4371 std::vector<double> v_K_p {321., 2212.};
4372 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_K), std::exp(1.4) / (std::exp(1.4) + std::exp(1.9)));
4373 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_pi_p), std::exp(1.4) / (std::exp(1.4) + std::exp(2.22)));
4374 EXPECT_FLOAT_EQ(binaryPID(particleAll, v_K_p), std::exp(1.9) / (std::exp(1.9) + std::exp(2.22)));
4377 EXPECT_TRUE(std::isnan(electronID(particleNoID)));
4378 EXPECT_TRUE(std::isnan(muonID(particleNoID)));
4379 EXPECT_TRUE(std::isnan(pionID(particleNoID)));
4380 EXPECT_TRUE(std::isnan(kaonID(particleNoID)));
4381 EXPECT_TRUE(std::isnan(protonID(particleNoID)));
4382 EXPECT_TRUE(std::isnan(deuteronID(particleNoID)));
4385 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->
function(particleAll)),
4387 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, ALL)")->
function(particleAll)),
4389 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(2212, TOP, CDC)")->
function(
4390 particleAll)), 0.86);
4393 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(1000010020, ALL)")->
function(particleAll)),
4394 std::exp(3.22) / numsumexp);
4395 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(2212, ALL)")->
function(particleAll)),
4396 std::exp(2.22) / numsumexp);
4397 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->
function(particleAll)),
4398 std::exp(1.4) / numsumexp);
4399 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(321, ALL)")->
function(particleAll)),
4400 std::exp(1.9) / numsumexp);
4401 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(13, ALL)")->
function(particleAll)),
4402 std::exp(3.5) / numsumexp);
4403 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(11, ALL)")->
function(particleAll)),
4404 std::exp(0.71) / numsumexp);
4405 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->
function(particledEdx)),
4406 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)));
4407 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(211, ALL)")->
function(particledEdx)),
4408 std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC, SVD)")->
function(particleAll)));
4409 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->
function(particledEdx)),
4410 std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(211, CDC)")->
function(particleAll)));
4411 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidProbabilityExpert(321, CDC)")->
function(particleAll)),
4412 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)));
4415 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->
function(
4417 1.0 / (1.0 + std::exp(2.22 - 1.9)));
4418 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ALL)")->
function(
4420 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4421 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, CDC, SVD)")->
function(
4423 1.0 / (1.0 + std::exp(0.94 - 0.74)));
4426 EXPECT_TRUE(std::isnan(std::get<double>(Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->
function(
4428 EXPECT_TRUE(std::isnan(std::get<double>(Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP, CDC, SVD)")->
function(
4430 EXPECT_TRUE(std::isnan(std::get<double>(Manager::Instance().getVariable(
"pidLogLikelihoodValueExpert(11, TOP)")->
function(
4432 EXPECT_TRUE(std::isnan(std::get<double>(Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, KLM)")->
function(
4434 EXPECT_TRUE(std::isnan(std::get<double>
4435 (Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH)")->
function(
4437 EXPECT_FALSE(std::isnan(std::get<double>
4438 (Manager::Instance().getVariable(
"pidPairProbabilityExpert(321, 2212, ECL, TOP, ARICH, SVD)")->
function(
4441 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidMostLikelyPDG()")->
function(particledEdx)), 1.00001e+09);
4442 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidMostLikelyPDG(0.5, 0.1, 0.1, 0.1, 0.1, 0.1)")->
function(
4444 Const::electron.getPDGCode());
4445 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.5, 0.1, 0.1, 0.1, 0.1)")->
function(
4447 Const::muon.getPDGCode());
4448 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.5, 0.1, 0.1, 0.1)")->
function(
4450 Const::pion.getPDGCode());
4451 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.5, 0.1, 0.1)")->
function(
4453 Const::kaon.getPDGCode());
4454 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidMostLikelyPDG(0.1, 0.1, 0.1, 0.1, 0.5, 0.1)")->
function(
4456 Const::proton.getPDGCode());
4457 EXPECT_FLOAT_EQ(std::get<double>(Manager::Instance().getVariable(
"pidMostLikelyPDG(0, 1., 0, 0, 0, 0)")->
function(particledEdx)),
4458 Const::muon.getPDGCode());
4461 TEST_F(PIDVariableTest, MissingLikelihood)
4470 const float pValue = 0.5;
4471 const float bField = 1.5;
4473 TMatrixDSym cov6(6);
4475 ROOT::Math::Cartesian2D d(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4476 ROOT::Math::Cartesian2D pt(generator.Uniform(-1, 1), generator.Uniform(-1, 1));
4477 d.SetXY(d.X(), -(d.X()*pt.X()) / pt.Y());
4479 ROOT::Math::XYZVector position(d.X(), d.Y(), generator.Uniform(-1, 1));
4480 ROOT::Math::XYZVector momentum(pt.X(), pt.Y(), generator.Uniform(-1, 1));
4482 auto CDCValue =
static_cast<unsigned long long int>(0x300000000000000);
4483 tfrs.
appendNew(position, momentum, cov6, charge, Const::electron, pValue, bField, CDCValue, 16777215, 0);
4486 Track* savedTrack1 = tracks.appendNew(mytrack);
4487 Track* savedTrack2 = tracks.appendNew(mytrack);
4488 Track* savedTrack3 = tracks.appendNew(mytrack);
4489 Track* savedTrack4 = tracks.appendNew(mytrack);
4492 l1->setLogLikelihood(Const::TOP, Const::electron, 0.18);
4493 l1->setLogLikelihood(Const::ECL, Const::electron, 0.14);
4496 auto* electron = particles.appendNew(savedTrack1, Const::electron);
4499 l2->setLogLikelihood(Const::TOP, Const::pion, 0.2);
4500 l2->setLogLikelihood(Const::ARICH, Const::pion, 0.22);
4501 l2->setLogLikelihood(Const::ECL, Const::pion, 0.24);
4502 l2->setLogLikelihood(Const::CDC, Const::pion, 0.26);
4503 l2->setLogLikelihood(Const::SVD, Const::pion, 0.28);
4506 auto* pion = particles.appendNew(savedTrack2, Const::pion);
4509 l3->setLogLikelihood(Const::TOP, Const::kaon, 0.3);
4510 l3->setLogLikelihood(Const::ARICH, Const::kaon, 0.32);
4513 auto* kaon = particles.appendNew(savedTrack3, Const::kaon);
4516 l4->setLogLikelihood(Const::ARICH, Const::proton, 0.42);
4517 l4->setLogLikelihood(Const::ECL, Const::proton, 0.44);
4518 l4->setLogLikelihood(Const::CDC, Const::proton, 0.46);
4519 l4->setLogLikelihood(Const::SVD, Const::proton, 0.48);
4522 auto* proton = particles.appendNew(savedTrack4, Const::proton);
4524 const Manager::Var* varMissECL = Manager::Instance().getVariable(
"pidMissingProbabilityExpert(ECL)");
4525 const Manager::Var* varMissTOP = Manager::Instance().getVariable(
"pidMissingProbabilityExpert(TOP)");
4526 const Manager::Var* varMissARICH = Manager::Instance().getVariable(
"pidMissingProbabilityExpert(ARICH)");
4529 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(electron)), 0.0);
4530 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(pion)), 0.0);
4531 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(kaon)), 0.0);
4532 EXPECT_FLOAT_EQ(std::get<double>(varMissTOP->
function(proton)), 1.0);
4534 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(electron)), 1.0);
4535 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(pion)), 0.0);
4536 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(kaon)), 0.0);
4537 EXPECT_FLOAT_EQ(std::get<double>(varMissARICH->
function(proton)), 0.0);
4539 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(electron)), 0.0);
4540 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(pion)), 0.0);
4541 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(kaon)), 1.0);
4542 EXPECT_FLOAT_EQ(std::get<double>(varMissECL->
function(proton)), 0.0);
4545 class FlightInfoTest :
public ::testing::Test {
4548 void SetUp()
override
4550 DataStore::Instance().setInitializeActive(
true);
4555 particles.registerRelationTo(mcParticles);
4557 DataStore::Instance().setInitializeActive(
false);
4562 mcKs.
setPDG(Const::Kshort.getPDGCode());
4570 mcKs.
setStatus(MCParticle::c_PrimaryParticle);
4579 mcDp.
setStatus(MCParticle::c_PrimaryParticle);
4583 PxPyPzEVector momentum;
4584 TMatrixFSym error(7);
4591 error(5, 5) = 0.00875;
4593 Particle pi(PxPyPzEVector(1.59607, 1.19705, 0, 2), 211);
4594 momentum += pi.get4Vector();
4595 Particle* newpi = particles.appendNew(pi);
4598 Particle Ks(PxPyPzEVector(1.164, 1.55200, 0, 2), 310, Particle::c_Unflavored, Particle::c_Composite, 0);
4599 Ks.setVertex(XYZVector(4.0, 5.0, 0.0));
4600 Ks.setMomentumVertexErrorMatrix(error);
4601 momentum += Ks.get4Vector();
4602 Ks.addExtraInfo(
"prodVertX", 1.0);
4603 Ks.addExtraInfo(
"prodVertY", 1.0);
4604 Ks.addExtraInfo(
"prodVertZ", 0.0);
4605 Ks.addExtraInfo(
"prodVertSxx", 0.04);
4606 Ks.addExtraInfo(
"prodVertSxy", 0.0);
4607 Ks.addExtraInfo(
"prodVertSxz", 0.0);
4608 Ks.addExtraInfo(
"prodVertSyx", 0.0);
4609 Ks.addExtraInfo(
"prodVertSyy", 0.00875);
4610 Ks.addExtraInfo(
"prodVertSyz", 0.0);
4611 Ks.addExtraInfo(
"prodVertSzx", 0.0);
4612 Ks.addExtraInfo(
"prodVertSzy", 0.0);
4613 Ks.addExtraInfo(
"prodVertSzz", 0.01);
4614 Particle* newKs = particles.appendNew(Ks);
4618 Particle Dp(momentum, 411, Particle::c_Flavored, Particle::c_Composite, 0);
4619 Dp.appendDaughter(newpi);
4620 Dp.appendDaughter(newKs);
4621 XYZVector motherVtx(1.0, 1.0, 0.0);
4622 Dp.setVertex(motherVtx);
4623 Dp.setMomentumVertexErrorMatrix(error);
4624 Dp.addExtraInfo(
"prodVertX", 0.0);
4625 Dp.addExtraInfo(
"prodVertY", 1.0);
4626 Dp.addExtraInfo(
"prodVertZ", -2.0);
4627 Dp.addExtraInfo(
"prodVertSxx", 0.04);
4628 Dp.addExtraInfo(
"prodVertSxy", 0.0);
4629 Dp.addExtraInfo(
"prodVertSxz", 0.0);
4630 Dp.addExtraInfo(
"prodVertSyx", 0.0);
4631 Dp.addExtraInfo(
"prodVertSyy", 0.01);
4632 Dp.addExtraInfo(
"prodVertSyz", 0.0);
4633 Dp.addExtraInfo(
"prodVertSzx", 0.0);
4634 Dp.addExtraInfo(
"prodVertSzy", 0.0);
4635 Dp.addExtraInfo(
"prodVertSzz", 0.1575);
4636 Particle* newDp = particles.appendNew(Dp);
4642 void TearDown()
override
4644 DataStore::Instance().reset();
4647 TEST_F(FlightInfoTest, flightDistance)
4650 const Particle* newKs = particles[1];
4652 const Manager::Var* var = Manager::Instance().getVariable(
"flightDistance");
4653 ASSERT_NE(var,
nullptr);
4654 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
4656 TEST_F(FlightInfoTest, flightDistanceErr)
4659 const Particle* newKs = particles[1];
4661 const Manager::Var* var = Manager::Instance().getVariable(
"flightDistanceErr");
4662 ASSERT_NE(var,
nullptr);
4663 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4665 TEST_F(FlightInfoTest, flightTime)
4668 const Particle* newKs = particles[1];
4670 const Manager::Var* var = Manager::Instance().getVariable(
"flightTime");
4671 ASSERT_NE(var,
nullptr);
4672 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0 / Const::speedOfLight * newKs->
getPDGMass() / newKs->
getP());
4675 TEST_F(FlightInfoTest, flightTimeErr)
4678 const Particle* newKs = particles[1];
4680 const Manager::Var* var = Manager::Instance().getVariable(
"flightTimeErr");
4681 ASSERT_NE(var,
nullptr);
4682 EXPECT_GT(std::get<double>(var->function(newKs)), 0.0);
4685 TEST_F(FlightInfoTest, flightDistanceOfDaughter)
4688 const Particle* newDp = particles[2];
4690 const Manager::Var* var = Manager::Instance().getVariable(
"flightDistanceOfDaughter(1)");
4691 ASSERT_NE(var,
nullptr);
4692 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4694 var = Manager::Instance().getVariable(
"flightDistanceOfDaughter(3)");
4695 ASSERT_NE(var,
nullptr);
4696 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4698 TEST_F(FlightInfoTest, flightDistanceOfDaughterErr)
4701 const Particle* newDp = particles[2];
4703 const Manager::Var* var = Manager::Instance().getVariable(
"flightDistanceOfDaughterErr(1)");
4704 ASSERT_NE(var,
nullptr);
4705 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4707 var = Manager::Instance().getVariable(
"flightDistanceOfDaughterErr(3)");
4708 ASSERT_NE(var,
nullptr);
4709 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4711 TEST_F(FlightInfoTest, flightTimeOfDaughter)
4714 const Particle* newDp = particles[2];
4716 const Manager::Var* var = Manager::Instance().getVariable(
"flightTimeOfDaughter(1)");
4717 ASSERT_NE(var,
nullptr);
4720 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0 / Const::speedOfLight * Ks->
getPDGMass() / Ks->
getP());
4722 var = Manager::Instance().getVariable(
"flightTimeOfDaughter(3)");
4723 ASSERT_NE(var,
nullptr);
4724 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4726 TEST_F(FlightInfoTest, flightTimeOfDaughterErr)
4729 const Particle* newDp = particles[2];
4731 const Manager::Var* var = Manager::Instance().getVariable(
"flightTimeOfDaughterErr(1)");
4732 ASSERT_NE(var,
nullptr);
4733 EXPECT_GT(std::get<double>(var->function(newDp)), 0.0);
4735 var = Manager::Instance().getVariable(
"flightTimeOfDaughterErr(3)");
4736 ASSERT_NE(var,
nullptr);
4737 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4739 TEST_F(FlightInfoTest, mcFlightDistanceOfDaughter)
4742 const Particle* newDp = particles[2];
4744 const Manager::Var* var = Manager::Instance().getVariable(
"mcFlightDistanceOfDaughter(1)");
4745 ASSERT_NE(var,
nullptr);
4747 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4749 var = Manager::Instance().getVariable(
"mcFlightDistanceOfDaughter(3)");
4750 ASSERT_NE(var,
nullptr);
4751 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4753 TEST_F(FlightInfoTest, mcFlightTimeOfDaughter)
4756 const Particle* newDp = particles[2];
4758 const Manager::Var* var = Manager::Instance().getVariable(
"mcFlightTimeOfDaughter(1)");
4759 ASSERT_NE(var,
nullptr);
4764 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), Ks->getLifetime() / Ks->
getEnergy()*Ks->
getMass());
4766 var = Manager::Instance().getVariable(
"mcFlightTimeOfDaughter(3)");
4767 ASSERT_NE(var,
nullptr);
4768 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4771 TEST_F(FlightInfoTest, vertexDistance)
4774 const Particle* newKS = particles[1];
4776 const Manager::Var* var = Manager::Instance().getVariable(
"vertexDistance");
4777 ASSERT_NE(var,
nullptr);
4778 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 5.0);
4781 TEST_F(FlightInfoTest, vertexDistanceError)
4784 const Particle* newKS = particles[1];
4786 const Manager::Var* var = Manager::Instance().getVariable(
"vertexDistanceErr");
4787 ASSERT_NE(var,
nullptr);
4788 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 0.2);
4791 TEST_F(FlightInfoTest, vertexDistanceSignificance)
4794 const Particle* newKS = particles[1];
4796 const Manager::Var* var = Manager::Instance().getVariable(
"vertexDistanceSignificance");
4797 ASSERT_NE(var,
nullptr);
4798 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKS)), 25);
4801 TEST_F(FlightInfoTest, vertexDistanceOfDaughter)
4804 const Particle* newDp = particles[2];
4806 const Manager::Var* var = Manager::Instance().getVariable(
"vertexDistanceOfDaughter(1, 0)");
4807 ASSERT_NE(var,
nullptr);
4808 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 5.0);
4810 var = Manager::Instance().getVariable(
"vertexDistanceOfDaughter(1)");
4811 ASSERT_NE(var,
nullptr);
4812 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 6.0);
4814 var = Manager::Instance().getVariable(
"vertexDistanceOfDaughter(2)");
4815 ASSERT_NE(var,
nullptr);
4816 EXPECT_TRUE(std::isnan(std::get<double>(var->function(newDp))));
4819 TEST_F(FlightInfoTest, vertexDistanceOfDaughterError)
4822 const Particle* newDp = particles[2];
4824 const Manager::Var* var = Manager::Instance().getVariable(
"vertexDistanceOfDaughterErr(1, 0)");
4825 ASSERT_NE(var,
nullptr);
4826 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.2);
4828 var = Manager::Instance().getVariable(
"vertexDistanceOfDaughterErr(1)");
4829 ASSERT_NE(var,
nullptr);
4830 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 0.25);
4833 TEST_F(FlightInfoTest, vertexDistanceOfDaughterSignificance)
4836 const Particle* newDp = particles[2];
4838 const Manager::Var* var = Manager::Instance().getVariable(
"vertexDistanceOfDaughterSignificance(1, 0)");
4839 ASSERT_NE(var,
nullptr);
4840 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 25);
4842 var = Manager::Instance().getVariable(
"vertexDistanceOfDaughterSignificance(1)");
4843 ASSERT_NE(var,
nullptr);
4844 EXPECT_FLOAT_EQ(std::get<double>(var->function(newDp)), 24);
4847 class VertexVariablesTest :
public ::testing::Test {
4850 void SetUp()
override
4852 DataStore::Instance().setInitializeActive(
true);
4857 particles.registerRelationTo(mcParticles);
4859 DataStore::Instance().setInitializeActive(
false);
4864 mcKs.
setPDG(Const::Kshort.getPDGCode());
4869 mcKs.
setStatus(MCParticle::c_PrimaryParticle);
4872 Particle Ks(PxPyPzEVector(1.164, 1.55200, 0, 2), 310);
4886 Particle* newKs = particles.appendNew(Ks);
4891 void TearDown()
override
4893 DataStore::Instance().reset();
4898 TEST_F(VertexVariablesTest, mcDecayVertexX)
4901 const Particle* newKs = particles[0];
4903 const Manager::Var* var = Manager::Instance().getVariable(
"mcDecayVertexX");
4904 ASSERT_NE(var,
nullptr);
4905 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 4.0);
4908 TEST_F(VertexVariablesTest, mcDecayVertexY)
4911 const Particle* newKs = particles[0];
4913 const Manager::Var* var = Manager::Instance().getVariable(
"mcDecayVertexY");
4914 ASSERT_NE(var,
nullptr);
4915 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 5.0);
4918 TEST_F(VertexVariablesTest, mcDecayVertexZ)
4921 const Particle* newKs = particles[0];
4923 const Manager::Var* var = Manager::Instance().getVariable(
"mcDecayVertexZ");
4924 ASSERT_NE(var,
nullptr);
4925 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.0);
4929 TEST_F(VertexVariablesTest, mcDecayVertexFromIPDistance)
4932 const Particle* newKs = particles[0];
4934 const Manager::Var* var = Manager::Instance().getVariable(
"mcDecayVertexFromIPDistance");
4935 ASSERT_NE(var,
nullptr);
4936 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(4.0 * 4.0 + 5.0 * 5.0));
4939 TEST_F(VertexVariablesTest, mcDecayVertexRho)
4942 const Particle* newKs = particles[0];
4944 const Manager::Var* var = Manager::Instance().getVariable(
"mcDecayVertexRho");
4945 ASSERT_NE(var,
nullptr);
4946 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(4.0 * 4.0 + 5.0 * 5.0));
4949 TEST_F(VertexVariablesTest, mcProductionVertexX)
4952 const Particle* newKs = particles[0];
4954 const Manager::Var* var = Manager::Instance().getVariable(
"mcProductionVertexX");
4955 ASSERT_NE(var,
nullptr);
4956 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
4959 TEST_F(VertexVariablesTest, mcProductionVertexY)
4962 const Particle* newKs = particles[0];
4964 const Manager::Var* var = Manager::Instance().getVariable(
"mcProductionVertexY");
4965 ASSERT_NE(var,
nullptr);
4966 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
4969 TEST_F(VertexVariablesTest, mcProductionVertexZ)
4972 const Particle* newKs = particles[0];
4974 const Manager::Var* var = Manager::Instance().getVariable(
"mcProductionVertexZ");
4975 ASSERT_NE(var,
nullptr);
4976 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
4981 TEST_F(VertexVariablesTest, prodVertexX)
4984 const Particle* newKs = particles[0];
4986 const Manager::Var* var = Manager::Instance().getVariable(
"prodVertexX");
4987 ASSERT_NE(var,
nullptr);
4988 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 1.0);
4990 TEST_F(VertexVariablesTest, prodVertexY)
4993 const Particle* newKs = particles[0];
4995 const Manager::Var* var = Manager::Instance().getVariable(
"prodVertexY");
4996 ASSERT_NE(var,
nullptr);
4997 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 2.0);
4999 TEST_F(VertexVariablesTest, prodVertexZ)
5002 const Particle* newKs = particles[0];
5004 const Manager::Var* var = Manager::Instance().getVariable(
"prodVertexZ");
5005 ASSERT_NE(var,
nullptr);
5006 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 3.0);
5011 TEST_F(VertexVariablesTest, prodVertexCov)
5014 const Particle* newKs = particles[0];
5017 const Manager::Var* var = Manager::Instance().getVariable(
"prodVertexCov(0,0)");
5018 ASSERT_NE(var,
nullptr);
5019 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.1);
5020 var = Manager::Instance().getVariable(
"prodVertexCov(0,1)");
5021 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.2);
5022 var = Manager::Instance().getVariable(
"prodVertexCov(0,2)");
5023 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.3);
5024 var = Manager::Instance().getVariable(
"prodVertexCov(1,0)");
5025 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.4);
5026 var = Manager::Instance().getVariable(
"prodVertexCov(1,1)");
5027 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.5);
5028 var = Manager::Instance().getVariable(
"prodVertexCov(1,2)");
5029 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.6);
5030 var = Manager::Instance().getVariable(
"prodVertexCov(2,0)");
5031 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.7);
5032 var = Manager::Instance().getVariable(
"prodVertexCov(2,1)");
5033 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.8);
5034 var = Manager::Instance().getVariable(
"prodVertexCov(2,2)");
5035 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)), 0.9);
5036 var = Manager::Instance().getVariable(
"prodVertexXErr");
5037 ASSERT_NE(var,
nullptr);
5038 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.1));
5039 var = Manager::Instance().getVariable(
"prodVertexYErr");
5040 ASSERT_NE(var,
nullptr);
5041 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.5));
5042 var = Manager::Instance().getVariable(
"prodVertexZErr");
5043 ASSERT_NE(var,
nullptr);
5044 EXPECT_FLOAT_EQ(std::get<double>(var->function(newKs)),
sqrt(0.9));
5049 TEST_F(MetaVariableTest, KSFWVariables)
5054 EXPECT_B2FATAL(Manager::Instance().getVariable(
"KSFWVariables(NONSENSE)"));
5059 const Manager::Var* var = Manager::Instance().getVariable(
"KSFWVariables(mm2)");
5060 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5063 EXPECT_B2ERROR(Manager::Instance().getVariable(
"KSFWVariables(et, mask, FS1)"));
5066 TEST_F(MetaVariableTest, CleoConeCS)
5071 EXPECT_B2FATAL(Manager::Instance().getVariable(
"CleoConeCS(NONSENSE)"));
5076 const Manager::Var* var = Manager::Instance().getVariable(
"CleoConeCS(0)");
5077 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5080 var = Manager::Instance().getVariable(
"CleoConeCS(0, NOTROE)");
5081 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle_with_no_cs))));
5084 EXPECT_B2ERROR(Manager::Instance().getVariable(
"CleoConeCS(0, mask, ROE)"));
5087 TEST_F(MetaVariableTest, TransformedNetworkOutput)
5090 EXPECT_B2FATAL(Manager::Instance().getVariable(
"transformedNetworkOutput(NONSENSE)"));
5093 EXPECT_B2FATAL(Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, 0, NOTDOUBLE)"));
5094 EXPECT_B2FATAL(Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, NOTDOUBLE, 1)"));
5099 const Manager::Var* var = Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, 0, 1)");
5100 EXPECT_TRUE(std::isnan(std::get<double>(var->function(particle))));
5102 if (not eventExtraInfo.isValid())
5103 eventExtraInfo.create();
5104 var = Manager::Instance().getVariable(
"transformedNetworkOutput(NONEXISTENT, 0, 1)");
5105 EXPECT_TRUE(std::isnan(std::get<double>(var->function(
nullptr))));
Provides a type-safe way to pass members of the chargedStableSet set.
EStoreFlags
Flags describing behaviours of objects etc.
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.
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.
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)
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.
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
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.