14import modularAnalysis
as ma
15from variables
import variables
16from vertex
import kFit
21 """The unit test case for the AllParticleCombiner"""
24 """Run the test fit"""
26 testFile = tempfile.NamedTemporaryFile()
31 basf2.set_random_seed(
"1234")
32 main = basf2.create_path()
34 'analysis/tests/mdst.root', py_case=self)
37 inputFileNames=[inputfile],
38 logLevel=basf2.LogLevel.ERROR)
40 ma.fillParticleList(
'pi+:fromPV',
'dr < 2 and abs(dz) < 5', path=main)
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)
47 ma.combineAllParticles([
'pi+:fromPV'],
'vpho:PVFit', path=main)
49 kFit(
'vpho:PVFit', conf_level=-1, fit_type=
'vertex', constraint=
'iptube', path=main)
51 variables.addAlias(
'PVX',
'x')
52 variables.addAlias(
'PVY',
'y')
53 variables.addAlias(
'PVZ',
'z')
54 variables.addAlias(
'nGoodTracksFromPV',
'nParticlesInList(pi+:fromPV)')
58 particleList=
'vpho:PVFit',
59 fileName=testFile.name,
68 ma.summaryOfLists([
'vpho:PVFit'], path=main)
72 ntuplefile = TFile(testFile.name)
73 ntuple = ntuplefile.Get(
'ntuple')
75 self.assertFalse(ntuple.GetEntries() == 0,
"Ntuple is empty.")
77 converged = ntuple.GetEntries(
"chiProb > 0")
79 self.assertFalse(converged == 0,
"No fit converged.")
81 print(
"Test passed, cleaning up.")
84if __name__ ==
'__main__':
def testCombination(self)
def require_file(filename, data_type="", py_case=None)
def clean_working_directory()
def configure_logging_for_tests(user_replacements=None)