def testFailValidityTreeInput(self):
     i = ti.Input(input_file='doesnotexist.root',
               tree='test',
               branch='x',
               selection='1',
               weight_branch='1')
     self.assertFalse(i.isValid())
 def testReadHist(self):
     i = ti.Input(input_file='test.root',
               hist='test_hist',
               )
     h = i.read()
     h_test = create_test_hist()
     self.assertEqual(h.nbins(), h_test.nbins())
 def testValidityTreeInput(self):
     i = ti.Input(input_file='test.root',
               tree='test',
               branch='x',
               selection='1',
               weight_branch='1')
     self.assertTrue(i.isValid())
 def testReadTree(self):
     i = ti.Input(input_file='test.root',
               tree='test',
               branch='x',
               selection='1',
               weight_branch='1',
               n_bins=10,
               x_min=0,
               x_max=10,
               )
     h = i.read()
     self.assertEqual(h.nbins(), 10)
 def read_sample(self, sample):
     if self.samples[sample].has_key('input'):
         i = self.samples[sample]['input']
         if isinstance(i, dict):
             i = ti.Input(**self.samples[sample]['input'])
         self.histograms[sample] = i.read()
         return
     input_file = self.samples[sample]['input_file']
     if self.samples[sample].has_key('hist'):
         hist = self.samples[sample]['hist']
         self.histograms[sample] = tools.ROOT_utils.get_histogram_from_file(
             hist, input_file)
Beispiel #6
0
 def __init__(self, caption):
     self.surface = pygame.display.get_surface()
     self.surface_rect = self.surface.get_rect()
     self.state_dict = {}
     self.state_name = None
     self.level_dict = {}
     self.level_name = None
     self.caption = caption
     self.show_fps = False
     self.done = False
     self.input = input.Input()
     self.fps = 60
     self.clock = pygame.time.Clock()
     self.fps_font = pygame.font.SysFont('comicsansms', 20)
     self.fps_pos = (880, 50)
 def fromDict(d):
     m = None
     if d['class'] == 'tools.measurement.Measurement':
         m = Measurement(d['name'])
     if d['class'] == 'tools.measurement.Systematic':
         m = Systematic(d['name'], d['type'],
                        affected_samples=d['affected_samples'], scale=d['scale'])
     m.setVariable(d['variable'])
     m.setCentreOfMassEnergy(int(d['centre_of_mass_energy']))
     m.setChannel(d['channel'])
     m.setMETType(d['met_type'])
     for sample, i in d['samples'].items():
         if i.has_key('input'):
             inp = ti.Input(**i['input'])
             m.addSample(sample, read=True, input=inp)
         else:
             m.addSample(sample, i['file'], i['hist'], read=True)
     for shape, obj in d['shapes'].items():
         m.addShapeForSample(shape, Measurement.fromDict(obj), read=True)
     for norm, obj in d['norms'].items():
         m.addNormForSample(
             norm, Measurement.fromDict(obj), read=True)
     return m
 def testToDict1(self):
     i = ti.Input(input_file='test.root',
               hist='test_hist',
               )
     d = i.toDict()
     self.assertEqual(d, {'input_file': 'test.root', 'hist': 'test_hist'})
 def testFailValidityHistInput(self):
     i = ti.Input(input_file='test.root',
               hist='doesnotexist',
               )
     self.assertFalse(i.isValid())
 def testValidityHistInput(self):
     i = ti.Input(input_file='test.root',
               hist='test_hist',
               )
     self.assertTrue(i.isValid())