Пример #1
0
 def __call__(self, config):
     for id in config['to_tgraph']:
         if isinstance(config['objects'][id]['obj'], collections.Iterable):
             if len(config['objects'][id]['obj']) == 1:
                 config['objects'][id]['obj'] = ROOT.TGraphAsymmErrors(config['objects'][id]['obj'])
             elif len(config['objects'][id]['obj']) == 3:
                 config['objects'][id]['obj'] = get_tgraphasymm_from_histos(*config['objects'][id]['obj'])
             else:
                 raise ValueError('unsupported conversion requested.')
         else:
             config['objects'][id]['obj'] = ROOT.TGraphAsymmErrors(config['objects'][id]['obj'])
Пример #2
0
 def __call__(self, config):
     for id, item in config['objects'].iteritems():
         if 'input' in item:
             # just get object
             if not '=' in item['input']:
                 item['obj'] = get_root_object(item['input'])
             else:
                 kwargs = parse_query(item['input'])
                 item['obj'] = build_root_object(**kwargs)
         elif 'input_tgraph' in item:
             if '&' in item['input_tgraph']:
                 item['obj'] = get_tgraphasymm_from_histos(
                     *[get_root_object(input) for input in item['input_tgraph'].split('&')])
             else:
                 item['obj'] = ROOT.TGraphAsymmErrors(get_root_object(item['input_tgraph']))
         elif 'input_asymmerrgraph' in item:
             item['obj'] = ROOT.TGraphAsymmErrors(get_root_object(item['input']))
Пример #3
0
    def __call__(self, config):
        if config['build_tgraph']:
            for id, input_ids in config['build_tgraph']:
                if len(input_ids) == 1:
                    # Basically only copies th TGraph
                    new_graph = ROOT.TGraphErrors(config['objects'][input_ids[0]]['obj'])
                elif len(input_ids) == 2:
                    # The both inputs define the minimum maximum and the center is set by the mean of both.
                    tmp_tgraph1 = config['objects'][input_ids[0]]['obj']
                    tmp_tgraph2 = config['objects'][input_ids[1]]['obj']
                    if not (tmp_tgraph1.GetN() == tmp_tgraph2.GetN()):
                        raise ValueError('The both objects must have the same number of points.')
                    new_graph = ROOT.TGraphAsymmErrors(tmp_tgraph1)
                    for i in xrange(new_graph.GetN()):
                        tmp_tgraph1x, tmp_tgraph1y = ROOT.Double(0), ROOT.Double(0)
                        tmp_tgraph1.GetPoint(i, tmp_tgraph1x, tmp_tgraph1y)

                        tmp_tgraph2x, tmp_tgraph2y = ROOT.Double(0), ROOT.Double(0)
                        tmp_tgraph2.GetPoint(i, tmp_tgraph2x, tmp_tgraph2y)

                        center = 0.5 * (tmp_tgraph1y + tmp_tgraph2y)

                        new_graph.SetPoint(i, tmp_tgraph1x, 0.5 * (tmp_tgraph1y + tmp_tgraph2y))
                        new_graph.SetPointEYlow(i, abs(tmp_tgraph1y - tmp_tgraph2y) / 2.)
                        new_graph.SetPointEYhigh(i, abs(tmp_tgraph1y - tmp_tgraph2y) / 2.)

                        new_graph.SetPointEXlow(i, tmp_tgraph1.GetErrorX(i))
                        new_graph.SetPointEXhigh(i, tmp_tgraph1.GetErrorX(i))

                    config['objects'].setdefault(id, {})['obj'] = new_graph
                elif len(input_ids) == 3:
                    if isinstance(config['objects'][input_ids[0]]['obj'], ROOT.TGraph):
                        # The both inputs define the minimum maximum and the center is set by the mean of both.
                        tmp_tgraph1 = config['objects'][input_ids[0]]['obj']
                        tmp_tgraph2 = config['objects'][input_ids[1]]['obj']
                        tmp_tgraph3 = config['objects'][input_ids[2]]['obj']
                        if not (tmp_tgraph1.GetN() == tmp_tgraph2.GetN() == tmp_tgraph3.GetN()):
                            raise ValueError('The input objects must have the same number of points.')

                        new_graph = ROOT.TGraphAsymmErrors(tmp_tgraph1)

                        for i in xrange(tmp_tgraph1.GetN()):
                            tmp_tgraph1x, tmp_tgraph1y = ROOT.Double(0), ROOT.Double(0)
                            tmp_tgraph1.GetPoint(i, tmp_tgraph1x, tmp_tgraph1y)

                            tmp_tgraph2x, tmp_tgraph2y = ROOT.Double(0), ROOT.Double(0)
                            tmp_tgraph2.GetPoint(i, tmp_tgraph2x, tmp_tgraph2y)

                            tmp_tgraph3x, tmp_tgraph3y = ROOT.Double(0), ROOT.Double(0)
                            tmp_tgraph3.GetPoint(i, tmp_tgraph3x, tmp_tgraph3y)

                            new_graph.SetPoint(i, tmp_tgraph1x, tmp_tgraph1y)
                            new_graph.SetPointEYlow(i, tmp_tgraph1y - tmp_tgraph2y)
                            new_graph.SetPointEYhigh(i, tmp_tgraph3y - tmp_tgraph1y)

                            new_graph.SetPointEXlow(i, tmp_tgraph1.GetErrorX(i))
                            new_graph.SetPointEXhigh(i, tmp_tgraph1.GetErrorX(i))

                        config['objects'].setdefault(id, {})['obj'] = new_graph
                    elif isinstance(config['objects'][input_ids[0]]['obj'], ROOT.TH1):
                        print 'blub'
                        obj = get_tgraphasymm_from_histos(config['objects'][input_ids[0]]['obj'],
                                                          config['objects'][input_ids[1]]['obj'],
                                                          config['objects'][input_ids[2]]['obj'])
                        config['objects'].setdefault(id, {})['obj'] = obj