Belle II Software  release-05-01-25
TestAllParticleCombiner Class Reference
Inheritance diagram for TestAllParticleCombiner:
Collaboration diagram for TestAllParticleCombiner:

Public Member Functions

def testCombination (self)
 

Detailed Description

The unit test case for the AllParticleCombiner

Definition at line 15 of file allparticlecombiner.py.

Member Function Documentation

◆ testCombination()

def testCombination (   self)
Run the test fit

Definition at line 18 of file allparticlecombiner.py.

18  def testCombination(self):
19  """Run the test fit"""
20 
21  testFile = tempfile.NamedTemporaryFile()
22  # make logging more reproducible by replacing some strings.
23  # Also make sure the testfile name is replaced if necessary
24  b2test_utils.configure_logging_for_tests({testFile.name: "${testfile}"})
25 
26  basf2.set_random_seed("1234")
27  main = basf2.create_path()
28  inputfile = b2test_utils.require_file(
29  'analysis/tests/mdst.root', py_case=self)
30  main.add_module(
31  'RootInput',
32  inputFileNames=[inputfile],
33  logLevel=basf2.LogLevel.ERROR)
34 
35  ma.fillParticleList('pi+:fromPV', 'dr < 2 and abs(dz) < 5', path=main)
36 
37  ma.variablesToExtraInfo('pi+:fromPV', {'medianValueInList(pi+:fromPV, dz)': 'medianDZ'}, path=main)
38  variables.addAlias('medianDzFromPV', 'extraInfo(medianDZ)')
39  variables.addAlias('dzFromMedianDz', 'formula(dz - medianDzFromPV)')
40  ma.applyCuts('pi+:fromPV', 'abs(dzFromMedianDz) < 0.05', path=main)
41 
42  ma.combineAllParticles(['pi+:fromPV'], 'vpho:PVFit', path=main)
43 
44  kFit('vpho:PVFit', conf_level=-1, fit_type='vertex', constraint='iptube', path=main)
45 
46  variables.addAlias('PVX', 'x')
47  variables.addAlias('PVY', 'y')
48  variables.addAlias('PVZ', 'z')
49  variables.addAlias('nGoodTracksFromPV', 'nParticlesInList(pi+:fromPV)')
50 
51  main.add_module(
52  'VariablesToNtuple',
53  particleList='vpho:PVFit',
54  fileName=testFile.name,
55  variables=[
56  'PVX',
57  'PVY',
58  'PVZ',
59  'chiProb',
60  'nGoodTracksFromPV',
61  'distance'])
62 
63  ma.summaryOfLists(['vpho:PVFit'], path=main)
64 
65  basf2.process(main)
66 
67  ntuplefile = TFile(testFile.name)
68  ntuple = ntuplefile.Get('ntuple')
69 
70  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
71 
72  converged = ntuple.GetEntries("chiProb > 0")
73 
74  self.assertFalse(converged == 0, "No fit converged.")
75 
76  print("Test passed, cleaning up.")
77 
78 

The documentation for this class was generated from the following file:
b2test_utils.configure_logging_for_tests
def configure_logging_for_tests(user_replacements=None)
Definition: __init__.py:99
basf2.process
def process(path, max_event=0)
Definition: __init__.py:25
b2test_utils.require_file
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:47