예제 #1
0
파일: tests.py 프로젝트: ndawe/goodruns
def test_ROOT():

    try:
        import ROOT
    except ImportError:
        raise SkipTest

    filename = os.path.join(DIRNAME, 'test.root')
    root_file = ROOT.TFile.Open(filename, 'recreate')
    root_file.Close()

    grl = GRL(GRLA)
    grl.save(filename + ':/lumi')
    grl2 = GRL(filename + ':/lumi')
    assert_equal(grl, grl2)

    root_file = ROOT.TFile.Open(filename, 'recreate')
    root_file.mkdir('dir')
    root_file.Close()

    grl = GRL(GRLA)
    grl.save(filename + ':/dir/lumi')
    grl2 = GRL(filename + ':/dir/lumi')
    assert_equal(grl, grl2)

    root_file = ROOT.TFile.Open(filename)
    tobj = root_file.Get('dir/lumi')
    assert_true(isinstance(tobj, ROOT.TObjString))
    root_file.Close()
    os.unlink(filename)
예제 #2
0
파일: tests.py 프로젝트: ndawe/goodruns
def test_ROOT():

    try:
        import ROOT
    except ImportError:
        raise SkipTest

    filename = os.path.join(DIRNAME, 'test.root')
    root_file = ROOT.TFile.Open(filename, 'recreate')
    root_file.Close()

    grl = GRL(GRLA)
    grl.save(filename + ':/lumi')
    grl2 = GRL(filename + ':/lumi')
    assert_equal(grl, grl2)

    root_file = ROOT.TFile.Open(filename, 'recreate')
    root_file.mkdir('dir')
    root_file.Close()

    grl = GRL(GRLA)
    grl.save(filename + ':/dir/lumi')
    grl2 = GRL(filename + ':/dir/lumi')
    assert_equal(grl, grl2)

    root_file = ROOT.TFile.Open(filename)
    tobj = root_file.Get('dir/lumi')
    assert_true(isinstance(tobj, ROOT.TObjString))
    root_file.Close()
    os.unlink(filename)
예제 #3
0
파일: hhgrl.py 프로젝트: ndawe/hhntup
    def work(self):

        # merge GRL XML strings
        grl = GRL()
        for fname in self.files:
            with root_open(fname) as f:
                for key in f.Lumi.keys():
                    grl |= GRL(str(key.ReadObj().GetString()), from_string=True)
        grl.save('grl.xml')
예제 #4
0
파일: hhgrl.py 프로젝트: aashaqshah/hhntup
    def work(self):

        # merge GRL XML strings
        grl = GRL()
        for fname in self.files:
            with root_open(fname) as f:
                for key in f.Lumi.keys():
                    grl |= GRL(str(key.ReadObj().GetString()),
                               from_string=True)
        grl.save('grl.xml')
예제 #5
0
파일: tests.py 프로젝트: ndawe/goodruns
def test_read_yaml():

    try:
        import yaml
    except ImportError:
        raise SkipTest

    grl = GRL(GRLA)
    grl.save('test.yml')
    grl2 = GRL('test.yml')
    assert_equal(grl, grl2)
    os.unlink('test.yml')
예제 #6
0
    def merge(inputs, output, metadata):

        # merge output trees
        root_output = output + '.root'
        subprocess.call(['hadd', root_output] + inputs)

        if metadata.datatype == datasets.DATA:
            # merge GRLs
            grl = GRL()
            for input in inputs:
                grl |= GRL('%s:/lumi' % input)
            grl.save('%s:/lumi' % root_output)
예제 #7
0
파일: tests.py 프로젝트: ndawe/goodruns
def test_read_yaml():

    try:
        import yaml
    except ImportError:
        raise SkipTest

    grl = GRL(GRLA)
    grl.save('test.yml')
    grl2 = GRL('test.yml')
    assert_equal(grl, grl2)
    os.unlink('test.yml')
예제 #8
0
파일: tests.py 프로젝트: ndawe/goodruns
def save_test():

    grl = GRL(GRLA)
    grl.save('testA.xml')
    os.unlink('testA.xml')
    assert_raises(ValueError, grl.save, 'testB.badext')
예제 #9
0
파일: tests.py 프로젝트: ndawe/goodruns
def save_test():

    grl = GRL(GRLA)
    grl.save('testA.xml')
    os.unlink('testA.xml')
    assert_raises(ValueError, grl.save, 'testB.badext')