Belle II Software  light-2303-iriomote
TestParticleExtractorFromROE Class Reference
Inheritance diagram for TestParticleExtractorFromROE:
Collaboration diagram for TestParticleExtractorFromROE:

Public Member Functions

def test_roepath (self)
 
def test_mainpath (self)
 

Detailed Description

The unit test for ParticleExtractorFromROE module 

Definition at line 20 of file test_particleExtractorFromROE.py.

Member Function Documentation

◆ test_mainpath()

def test_mainpath (   self)
 Test the extractParticlesFromROE function in main path 

Definition at line 85 of file test_particleExtractorFromROE.py.

85  def test_mainpath(self):
86  """ Test the extractParticlesFromROE function in main path """
87 
88  testFile = tempfile.NamedTemporaryFile()
89 
90  main = basf2.create_path()
91 
92  inputfile = b2test_utils.require_file('analysis/tests/100_noBKG_B0ToPiPiPi0.root', py_case=self)
93  ma.inputMdst(inputfile, path=main)
94 
95  ma.fillParticleList('pi+:sig', 'pionID > 0.5', path=main)
96 
97  ma.fillParticleList('gamma:all', '', path=main)
98  ma.reconstructDecay('pi0:sig -> gamma:all gamma:all', '0.125 < InvM < 0.145', path=main)
99 
100  ma.reconstructDecay('B0:sig -> pi-:sig pi+:sig pi0:sig', '', path=main)
101 
102  ma.matchMCTruth('B0:sig', path=main)
103  ma.applyCuts('B0:sig', 'isSignal==1', path=main) # there must be only 1 candidate
104 
105  ma.buildRestOfEvent('B0:sig', fillWithMostLikely=True, path=main)
106 
107  plists = ['%s:in_roe' % ptype for ptype in ['pi+', 'gamma', 'K_L0', 'K+', 'p+', 'e+', 'mu+']]
108  ma.extractParticlesFromROE(plists, maskName='all', path=main, signalSideParticleList='B0:sig')
109 
110  charged_inROE = ['nParticlesInList(%s:in_roe)' % ptype for ptype in ['pi+', 'K+', 'p+', 'e+', 'mu+']]
111  neutral_inROE = ['nParticlesInList(%s:in_roe)' % ptype for ptype in ['gamma', 'K_L0']]
112 
113  default = ['nParticlesInList(pi+:all)', 'nParticlesInList(gamma:all)', 'nParticlesInList(K_L0:roe_default)']
114  mostLikely = ['nParticlesInList(%s:mostlikely_roe)' % ptype for ptype in ['K+', 'p+', 'e+', 'mu+']]
115 
116  ma.variablesToNtuple('B0:sig', charged_inROE + neutral_inROE + default + mostLikely,
117  filename=testFile.name,
118  path=main)
119 
120  basf2.process(main)
121 
122  ntuplefile = TFile(testFile.name)
123  ntuple = ntuplefile.Get('variables')
124 
125  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
126 
127  nEntries = ntuple.GetEntries()
128 
129  # Number of pi+:all = Number of charged-FSPs in ROE + 2-pions in signal side
130  cut = Belle2.MakeROOTCompatible.makeROOTCompatible('nParticlesInList(pi+:all)') + ' == ' \
131  '(' + '+'.join([Belle2.MakeROOTCompatible.makeROOTCompatible(charged) for charged in charged_inROE]) + ' + 2)'
132  nPass_chargedCheck = ntuple.GetEntries(cut)
133  self.assertFalse(nPass_chargedCheck < nEntries, "Charged particles are not correctly extracted")
134 
135  # Number of mostLikely = Number of charged in ROE
136  cut = Belle2.MakeROOTCompatible.makeROOTCompatible('nParticlesInList(e+:mostlikely_roe)') + ' == ' \
137  + Belle2.MakeROOTCompatible.makeROOTCompatible('nParticlesInList(e+:in_roe)')
138  nPass_electronCheck = ntuple.GetEntries(cut)
139  self.assertFalse(nPass_electronCheck < nEntries, "MostLikely option seems broken")
140 
141 
static std::string makeROOTCompatible(std::string str)
Remove special characters that ROOT dislikes in branch names, e.g.
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54

◆ test_roepath()

def test_roepath (   self)
 Test the extractParticlesFromROE function in roe_path 

Definition at line 23 of file test_particleExtractorFromROE.py.


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