9 #include <analysis/DecayDescriptor/DecayDescriptor.h>
10 #include <analysis/dataobjects/Particle.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <framework/utilities/TestHelpers.h>
14 #include <framework/gearbox/Const.h>
16 #include <gtest/gtest.h>
23 TEST(DecayDescriptorTest, TrivialUse)
27 bool initok = dd.
init(
"K+");
28 EXPECT_EQ(initok,
true);
37 TEST(DecayDescriptorTest, NormalBehaviour)
40 bool initok = dd.
init(
"B0:cand -> K+:loose pi-:loose");
42 EXPECT_EQ(initok,
true);
70 TEST(DecayDescriptorTest, Granddaughters)
73 bool initok = dd.
init(
74 "B0:cand -> [D0:dau1 -> K+:grandau pi-:grandau] [pi0:dau2 -> gamma:grandau [gamma:converted -> e+:gtgrandau e-:gtgrandau]]"
76 EXPECT_EQ(initok,
true);
112 TEST(DecayDescriptorTest, ArrowsDecaysGrammar)
116 bool initok = dd1.
init(
"B0:candidates =direct=> K+:loose pi-:loose gamma:clean");
117 EXPECT_EQ(initok,
true);
123 initok = dd2.
init(
"B0:candidates =norad=> K+:loose pi-:loose gamma:clean");
124 EXPECT_EQ(initok,
true);
130 initok = dd3.
init(
"B0:candidates =exact=> K+:loose pi-:loose gamma:clean");
131 EXPECT_EQ(initok,
true);
137 TEST(DecayDescriptorTest, KeywordDecaysGrammar)
141 bool initok = dd1.
init(
"B0:candidates -> K+:loose gamma:clean ...");
142 EXPECT_EQ(initok,
true);
152 initok = dd2.
init(
"B0:candidates -> K+:loose pi-:loose ?nu");
153 EXPECT_EQ(initok,
true);
163 initok = dd3.
init(
"B0:candidates -> K+:loose pi-:loose !nu");
164 EXPECT_EQ(initok,
true);
174 initok = dd4.
init(
"B0:candidates -> K+:loose pi-:loose ?gamma");
175 EXPECT_EQ(initok,
true);
185 initok = dd5.
init(
"B0:candidates -> K+:loose pi-:loose !gamma");
186 EXPECT_EQ(initok,
true);
196 initok = dd6.
init(
"B0:candidates -> e-:loose ... ?nu ?gamma");
197 EXPECT_EQ(initok,
true);
207 initok = dd7.
init(
"B0:candidates -> K+:loose pi-:loose ?addbrems");
208 EXPECT_EQ(initok,
true);
218 TEST(DecayDescriptorTest, UnspecifiedParticleGrammar)
222 bool initok = dd1.
init(
"@Xsd:candidates -> K+:loose pi-:loose");
223 EXPECT_EQ(initok,
true);
231 initok = dd2.
init(
"^@Xsd:candidates -> K+:loose pi-:loose");
232 EXPECT_EQ(initok,
true);
238 initok = dd3.
init(
"@^Xsd:candidates -> K+:loose pi-:loose");
239 EXPECT_EQ(initok,
true);
247 initok = dd4.
init(
"B0:Xsdee -> @Xsd e+:loose e-:loose");
248 EXPECT_EQ(initok,
true);
260 initok = dd5.
init(
"B0:Xsdee -> ^@Xsd e+:loose e-:loose");
261 EXPECT_EQ(initok,
true);
267 initok = dd6.
init(
"B0:Xsdee -> @^Xsd e+:loose e-:loose");
268 EXPECT_EQ(initok,
true);
275 TEST(DecayDescriptorTest, GrammarWithNestedDecay)
279 bool initok = dd1.
init(
"B0:candidates =direct=> [D-:pi =norad=> pi-:loose ... ?gamma] e+:loose ?nu ?addbrems");
280 EXPECT_EQ(initok,
true);
301 TEST(DecayDescriptorTest, SelectionParticles)
304 bool initok = dd1.
init(
"B0:B2Dzpipi -> [D0 -> ^K+:loose pi-:loose] pi+:loose pi-:loose");
305 EXPECT_EQ(initok,
true);
307 ASSERT_EQ(names.size(), 1);
308 EXPECT_EQ(names[0],
"B0_D0_K");
312 initok = dd1.
init(
"B0:B2Dzpipi -> [D0 -> K+:loose ^pi-:loose] pi+:loose pi-:loose");
313 EXPECT_EQ(initok,
true);
315 ASSERT_EQ(names.size(), 2);
316 EXPECT_EQ(names[0],
"B0_D0_K");
317 EXPECT_EQ(names[1],
"B0_D0_pi");
321 initok = dd2.
init(
"vpho:complex -> [D0 -> ^K+:loose pi-:loose] ^e+:loose ^e-:loose ^gamma:loose");
322 EXPECT_EQ(initok,
true);
324 ASSERT_EQ(names.size(), 4);
325 EXPECT_EQ(names[0],
"vpho_D0_K");
326 EXPECT_EQ(names[1],
"vpho_e0");
327 EXPECT_EQ(names[2],
"vpho_e1");
328 EXPECT_EQ(names[3],
"vpho_gamma");
331 TEST(DecayDescriptorTest, MisIDandDecayInFlightGrammar)
335 bool initok = dd1.
init(
"B0:sig -> (misID)K+:loose pi-:loose");
336 EXPECT_EQ(initok,
true);
351 initok = dd2.
init(
"B0:sig -> K+:loose (misID)pi-:loose");
352 EXPECT_EQ(initok,
true);
363 initok = dd3.
init(
"B0:sig -> (misID)K+:loose (misID)pi-:loose");
364 EXPECT_EQ(initok,
true);
376 initok = dd4.
init(
"B0:sig -> (decay)K+:loose pi-:loose");
377 EXPECT_EQ(initok,
true);
388 initok = dd5.
init(
"B0:sig -> K+:loose (decay)pi-:loose");
389 EXPECT_EQ(initok,
true);
400 initok = dd6.
init(
"B0:sig -> (decay)K+:loose (decay)pi-:loose");
401 EXPECT_EQ(initok,
true);
413 initok = dd7.
init(
"B0:sig -> (misID)(decay)K+:loose (decay)(misID)pi-:loose");
414 EXPECT_EQ(initok,
true);
429 initok = dd8.
init(
"B0:sig -> ^(misID)K+:loose (decay)@pi-:loose");
430 EXPECT_EQ(initok,
true);
445 initok = dd9.
init(
"B0:sig -> ^@(misID)(decay)K+:loose (decay)@^(misID)pi-:loose");
446 EXPECT_EQ(initok,
true);
462 TEST(DecayDescriptorTest, BadLabelTest)
466 bool initok = dd1.
init(
"B0:lab[el -> K+:loose pi-:loose");
467 EXPECT_EQ(initok,
false);
472 initok = dd2.
init(
"B0:lab^el -> K+:loose pi-:loose");
473 EXPECT_EQ(initok,
false);
478 initok = dd3.
init(
"B0:lab]el -> K+:loose pi-:loose");
479 EXPECT_EQ(initok,
false);
484 initok = dd4.
init(
"B0:lab>el -> K+:loose pi-:loose");
485 EXPECT_EQ(initok,
false);
490 initok = dd5.
init(
"B0:lab:el -> K+:loose pi-:loose");
491 EXPECT_EQ(initok,
false);
496 TEST(DecayDescriptorTest, UnicodeTest)
501 const std::string weird =
"β¨Οβ°=πΌπ°";
503 bool initok = dd1.
init(
"B0:" + weird +
" -> K+:π©π pi-:π―ππ¦");
504 ASSERT_EQ(initok,
true);
514 TEST(DecayDescriptorTest, BadGrammarTest)
517 bool initok = dd1.
init(
"B0:label ---> K+:loose pi-:loose");
518 EXPECT_EQ(initok,
false);
521 initok = dd2.
init(
"B0:label > K+:loose pi-:loose");
522 EXPECT_EQ(initok,
false);
525 initok = dd3.
init(
"B0:label -> K+::loose pi-:loose");
526 EXPECT_EQ(initok,
false);
529 initok = dd4.
init(
"B0:label K+:loose pi-:loose");
530 EXPECT_EQ(initok,
false);
533 initok = dd5.
init(
"B0:label <- K+:loose pi-:loose");
534 EXPECT_EQ(initok,
false);
537 initok = dd6.
init(
"B0:label => K+:loose pi-:loose");
538 EXPECT_EQ(initok,
false);
541 initok = dd7.
init(
"B0:label --> K+:loose pi-:loose");
542 EXPECT_EQ(initok,
false);
545 initok = dd8.
init(
"B0:label ==> K+:loose pi-:loose");
546 EXPECT_EQ(initok,
false);
549 TEST(DecayDescriptorTest, B2ParticleInterface)
554 particles.registerInDataStore();
558 TLorentzVector zeroes(0, 0, 0, 0);
564 D0->appendDaughter(0);
565 D0->appendDaughter(1);
573 bool initok = dd.
init(
"B0:B2Dzpipi -> [D0 -> K+:loose ^pi-:loose] ^pi+:loose pi-:loose");
574 ASSERT_EQ(initok,
true);
577 EXPECT_EQ(selectionparticles.size(), 2);
578 EXPECT_EQ(selectionparticles[0], pim1);
579 EXPECT_EQ(selectionparticles[1], pip);
593 TEST(DecayDescriptorTest, HierarchyDefinitionTest)
596 bool initok = dd.
init(
"B+ -> [ D+ -> ^K+ pi0 ] ^pi0");
597 EXPECT_EQ(initok,
true);
601 std::vector<std::vector<std::pair<int, std::string>>> expected_hierarchies;
602 std::vector<std::pair<int, std::string>> K_path;
603 std::vector<std::pair<int, std::string>> pi0_path;
605 K_path.emplace_back(0, std::string(
"B"));
606 K_path.emplace_back(0, std::string(
"D"));
607 K_path.emplace_back(0, std::string(
"K"));
609 pi0_path.emplace_back(0, std::string(
"B"));
610 pi0_path.emplace_back(1, std::string(
"pi0"));
612 EXPECT_NE(expected_hierarchies, selected_hierarchies);
613 expected_hierarchies.push_back(K_path);
614 expected_hierarchies.push_back(pi0_path);
615 EXPECT_EQ(expected_hierarchies, selected_hierarchies);
int getPDGCode() const
PDG code.
static const ParticleType pi0
neutral pion particle
static const ChargedStable pion
charged pion particle
static const ChargedStable kaon
charged kaon particle
static const ParticleType photon
photon particle
static const ChargedStable electron
electron particle
static DataStore & Instance()
Instance of singleton Store.
void setInitializeActive(bool active)
Setter for m_initializeActive.
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
int getPDGCode() const
Return PDG code.
bool isUnspecified() const
Is the particle unspecified?
std::string getFullName() const
returns the full name of the particle full_name = name:label
bool isSelected() const
Is the particle selected in the decay string?
bool isIgnoreDecayInFlight() const
Check if decayInFlight shall be ignored.
std::string getName() const
evt.pdl name of the particle.
std::string getLabel() const
The label of this particle, "default" returned, when no label set.
bool isIgnoreMisID() const
Check if misID shall be ignored.
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
bool isIgnoreBrems() const
Check if added Brems gammas shall be ignored.
bool isIgnoreRadiatedPhotons() const
Check if additional radiated photons shall be ignored.
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
const DecayDescriptorParticle * getMother() const
return mother.
bool isIgnoreNeutrino() const
Check if missing neutrinos shall be ignored.
int getNDaughters() const
return number of direct daughters.
bool isIgnoreMassive() const
Check if missing massive final state particles shall be ignored.
const DecayDescriptor * getDaughter(int i) const
return i-th daughter (0 based index).
std::vector< std::vector< std::pair< int, std::string > > > getHierarchyOfSelected()
Function to get hierarchy of selected particles and their names (for python use)
bool isIgnoreGamma() const
Check if missing gammas shall be ignored.
std::vector< std::string > getSelectionNames()
Return list of human readable names of selected particles.
std::vector< const Particle * > getSelectionParticles(const Particle *particle)
Get a vector of pointers with selected daughters in the decay tree.
bool isIgnoreIntermediate() const
Check if intermediate resonances/particles shall be ignored.
Class to store reconstructed particles.
void appendDaughter(const Particle *daughter, const bool updateType=true)
Appends index of daughter to daughters index array.
Accessor to arrays stored in the data store.
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.