def testDirectoryWithSpace(self):
     '''
         Reported and fixed:
         https://github.com/rootpy/rootpy/issues/663
     '''
     with File.open('test.root') as f:
         self.assertTrue(f.__contains__('TTbar_plus_X_analysis/EPlusJets/Ref selection'))
Exemple #2
0
 def setUp(self):
     with File.open('test.root', 'recreate') as f:
         f.mkdir('TTbar_plus_X_analysis/EPlusJets/Ref selection',
                 recurse=True)
         f.cd('TTbar_plus_X_analysis/EPlusJets/Ref selection')
         tree = Tree("test")
         tree.create_branches({
             'x': 'F',
             'y': 'F',
             'z': 'F',
             'i': 'I',
             'EventWeight': "F"
         })
         for i in xrange(10000):
             tree.x = gauss(.5, 1.)
             tree.y = gauss(.3, 2.)
             tree.z = gauss(13., 42.)
             tree.i = i
             tree.EventWeight = 1.
             tree.fill()
         f.write()
         h = create_test_hist()
         h.write()
         tree.write()
         f.write()
         f.Close()
 def testDirectoryWithSpace(self):
     """
         Reported and fixed:
         https://github.com/rootpy/rootpy/issues/663
     """
     with File.open("test.root") as f:
         self.assertTrue(f.__contains__("TTbar_plus_X_analysis/EPlusJets/Ref selection"))
 def test_tree_branches(self):
     with File.open(self.output_file) as f:
         self.assertTrue(f.__contains__('events'))
         tree = f.get('events')
         branches = ['run_number', 'event_number',
                     'electrons.pt', 'electrons.hoE']
         for branch in branches:
             error_msg = "Branch '{}' does not exist".format(branch)
             self.assertTrue(tree.has_branch(branch), error_msg)
Exemple #5
0
 def testDirectoryWithSpace(self):
     '''
         Reported and fixed:
         https://github.com/rootpy/rootpy/issues/663
     '''
     with File.open('test.root') as f:
         self.assertTrue(
             f.__contains__(
                 'TTbar_plus_X_analysis/EPlusJets/Ref selection'))
Exemple #6
0
 def test_tree_content(self):
     with File.open(self.output_file) as f:
         tree = f.get('events')
         for i, event in enumerate(tree):
             if i == 0:
                 self.assertEqual(event.run_number, self.event1.getRun())
                 self.assertEqual(event.event_number, self.event1.id())
             if i == 1:
                 self.assertEqual(event.run_number, self.event2.getRun())
                 self.assertEqual(event.event_number, self.event2.id())
Exemple #7
0
 def test_tree_branches(self):
     with File.open(self.output_file) as f:
         self.assertTrue(f.__contains__('events'))
         tree = f.get('events')
         branches = [
             'run_number', 'event_number', 'electrons.pt', 'electrons.hoE'
         ]
         for branch in branches:
             error_msg = "Branch '{}' does not exist".format(branch)
             self.assertTrue(tree.has_branch(branch), error_msg)
 def test_tree_content(self):
     with File.open(self.output_file) as f:
         tree = f.get('events')
         for i, event in enumerate(tree):
             if i == 0:
                 self.assertEqual(event.run_number, self.event1.getRun())
                 self.assertEqual(event.event_number, self.event1.id())
             if i == 1:
                 self.assertEqual(event.run_number, self.event2.getRun())
                 self.assertEqual(event.event_number, self.event2.id())
 def setUp(self):
     with File.open ('test.root', 'recreate') as f:
         f.mkdir('TTbar_plus_X_analysis/EPlusJets/Ref selection', recurse=True)
         f.cd('TTbar_plus_X_analysis/EPlusJets/Ref selection')
         tree = Tree("test")
         tree.create_branches(
             {'x': 'F',
              'y': 'F',
              'z': 'F',
              'i': 'I',
              'EventWeight': "F"})
         for i in xrange(10000):
             tree.x = gauss(.5, 1.)
             tree.y = gauss(.3, 2.)
             tree.z = gauss(13., 42.)
             tree.i = i
             tree.EventWeight = 1.
             tree.fill()
         f.write()
         h = create_test_hist()
         h.write()
         tree.write()
         f.write()
         f.Close()