Belle II Software light-2406-ragdoll
TestParticleLoader Class Reference
Inheritance diagram for TestParticleLoader:
Collaboration diagram for TestParticleLoader:

Public Member Functions

def testNumberOfParticles (self)
 

Detailed Description

Test case of ParticleLoader

Definition at line 19 of file test_particleLoader.py.

Member Function Documentation

◆ testNumberOfParticles()

def testNumberOfParticles (   self)
Compare the number of mdst objects and particles.

Definition at line 22 of file test_particleLoader.py.

22 def testNumberOfParticles(self):
23 """Compare the number of mdst objects and particles."""
24 from ROOT import TFile
25
26 testFile = tempfile.NamedTemporaryFile()
27
28 main = basf2.create_path()
29
30 ma.inputMdstList(filelist=[b2test_utils.require_file('analysis/1000_B_Jpsi_ks_pipi.root', 'validation')], path=main)
31
32 ma.fillParticleList('pi+:all', '', path=main)
33 ma.fillParticleList('gamma:all', '', path=main)
34 ma.fillParticleList('K_L0:all', '', path=main)
35 ma.fillParticleList('K_S0:V0 -> pi+ pi-', '', path=main)
36 ma.fillParticleList('Lambda0:V0 -> p+ pi-', '', path=main)
37 ma.fillConvertedPhotonsList('gamma:V0 -> e+ e-', '', path=main)
38
39 ma.cutAndCopyList('K_L0:ecl', 'K_L0:all', 'isFromECL', path=main)
40 ma.cutAndCopyList('K_L0:klm', 'K_L0:all', 'isFromKLM', path=main)
41
42 ma.variablesToNtuple('',
43 ['nTrackFitResults(pi+)',
44 'nParticlesInList(pi+:all)',
45 'nNeutralECLClusters(1)',
46 'nParticlesInList(gamma:all)',
47 'nNeutralECLClusters(2)',
48 'nParticlesInList(K_L0:ecl)',
49 'nKLMClusters',
50 'nParticlesInList(K_L0:klm)',
51 'nValidV0s',
52 'nParticlesInList(K_S0:V0)',
53 'nParticlesInList(Lambda0:V0)',
54 'nParticlesInList(gamma:V0)'],
55 filename=testFile.name,
56 treename='tree',
57 path=main)
58
59 basf2.process(main)
60
61 ntuplefile = TFile(testFile.name)
62 ntuple = ntuplefile.Get('tree')
63 totalEvents = ntuple.GetEntries()
64 self.assertFalse(totalEvents == 0, "Ntuple is empty.")
65
66 missedTracks = ntuple.GetEntries("nTrackFitResults__bopi__pl__bc > nParticlesInList__bopi__pl__clall__bc")
67 missedECLClustersNPhotons = ntuple.GetEntries("nNeutralECLClusters__bo1__bc > nParticlesInList__bogamma__clall__bc")
68 missedECLClustersNeutralHad = ntuple.GetEntries("nNeutralECLClusters__bo2__bc > nParticlesInList__boK_L0__clecl__bc")
69 missedKLMClusters = ntuple.GetEntries("nKLMClusters > nParticlesInList__boK_L0__clklm__bc")
70 missedV0s = ntuple.GetEntries("nValidV0s > nParticlesInList__boK_S0__clV0__bc + nParticlesInList__boLambda0__clV0__bc + " +
71 "nParticlesInList__bogamma__clV0__bc")
72
73 self.assertTrue(missedTracks == 0, "Tracks are missed to be loaded as charged particles")
74 self.assertTrue(missedECLClustersNPhotons == 0, "ECLClusters (nPhotons) are missed to be loaded as gammas")
75 self.assertTrue(missedECLClustersNeutralHad == 0, "ECLClusters (neutralHadron) are missed to be loaded as K_L0s")
76 self.assertTrue(missedKLMClusters == 0, "KLMClusters are missed to be loaded as K_L0s")
77 self.assertTrue(missedV0s == 0, "V0s are missed to be loaded as K_S0, Lambda0, and converted-gamma")
78
79 duplicatedTracks = ntuple.GetEntries("nTrackFitResults__bopi__pl__bc < nParticlesInList__bopi__pl__clall__bc")
80 duplicatedECLClustersNPhotons = ntuple.GetEntries("nNeutralECLClusters__bo1__bc < nParticlesInList__bogamma__clall__bc")
81 duplicatedECLClustersNeutralHad = ntuple.GetEntries("nNeutralECLClusters__bo2__bc < nParticlesInList__boK_L0__clecl__bc")
82 duplicatedKLMClusters = ntuple.GetEntries("nKLMClusters < nParticlesInList__boK_L0__clklm__bc")
83 duplicatedV0s = ntuple.GetEntries(
84 "nValidV0s < nParticlesInList__boK_S0__clV0__bc + nParticlesInList__boLambda0__clV0__bc + " +
85 "nParticlesInList__bogamma__clV0__bc")
86
87 self.assertTrue(duplicatedTracks == 0, "Tracks are loaded as charged particles more than once")
88 self.assertTrue(duplicatedECLClustersNPhotons == 0, "ECLClusters (nPhotons) are loaded as gammas more than once")
89 self.assertTrue(duplicatedECLClustersNeutralHad == 0, "ECLClusters (neutralHadron) are loaded as K_L0s more than once")
90 self.assertTrue(duplicatedKLMClusters == 0, "KLMClusters are loaded as K_L0s more than once")
91 self.assertTrue(duplicatedV0s == 0, "V0s are loaded as K_S0, Lambda0, and converted-gamma more than once")
92
93 print("Test passed, cleaning up.")
94
95
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54

The documentation for this class was generated from the following file: