Belle II Software  release-08-01-10
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 20 of file allparticlecombiner.py.

Member Function Documentation

◆ testCombination()

def testCombination (   self)
Run the test fit

Definition at line 23 of file allparticlecombiner.py.

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

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