Пример #1
0
def main():
    '''
    Main entry point of execution.
    '''
    ## Mitigate numerical noise paying lower performance.
    if debuglevel == 0:
        ROOT.RooAbsReal.defaultIntegratorConfig().setEpsAbs(1e-9)
        ROOT.RooAbsReal.defaultIntegratorConfig().setEpsRel(1e-9)

    ## Assemble the job name
    name = '_'.join([em, src, cat])

    f = ModeAndEffSigmaFitter(name, debuglevel)
    f.run()

    ## Store RooFit objects in a rootfile
    w = ROOT.RooWorkspace('w')
    for item in [f.data, f.data_half_odd, f.data_half_even, f.model]:
        w.Import(item)
    w.Import(f.fit_data, f.name + '_fit_data')
    w.Import(f.train_data, f.name + '_train_data')
    w.Import(f.fit_result, f.name + '_fit_result')

    w.writeToFile(output_filename)

    ## Store canvases in a rootfile
    outfile = ROOT.TFile.Open(output_filename, 'UPDATE')
    outfile.mkdir('Canvases').cd()
    for c in canvases.canvases:
        if c:
            c.Write(c.GetName())

    ## Make the plots
    canvases.make_plots('eps png C'.split())
Пример #2
0
def main():
    '''
    Main entry point of execution.
    '''
    ## Mitigate numerical noise paying lower performance.
    if debuglevel == 0:
        ROOT.RooAbsReal.defaultIntegratorConfig().setEpsAbs(1e-9)
        ROOT.RooAbsReal.defaultIntegratorConfig().setEpsRel(1e-9)

    ## Assemble the job name
    name = '_'.join([em, src, cat])

    f = ModeAndEffSigmaFitter(name, debuglevel)
    f.run()


    ## Store RooFit objects in a rootfile
    w = ROOT.RooWorkspace('w')
    for item in [f.data, f.data_half_odd, f.data_half_even, f.model]:
        w.Import(item)
    w.Import(f.fit_data, f.name + '_fit_data')
    w.Import(f.train_data, f.name + '_train_data')
    w.Import(f.fit_result, f.name + '_fit_result')

    w.writeToFile(output_filename)
            
    ## Store canvases in a rootfile
    outfile = ROOT.TFile.Open(output_filename, 'UPDATE')
    outfile.mkdir('Canvases').cd()
    for c in canvases.canvases:
        if c:
            c.Write(c.GetName())

    ## Make the plots
    canvases.make_plots('eps png C'.split())
Пример #3
0
def build_animation():
    '''
    Creates an animated gif out of the canvases.
    '''
    canvases.make_plots(['gif'])
    mc_files, data_files = [], []

    ## Create lists of files with the animation snapshots
    for c in canvases.canvases:
        if 'MC' in c.GetName():
            mc_files.append(c.GetName() + '.gif')
        else:
            data_files.append(c.GetName() + '.gif')

    ## Repeat the first snapshot 3xtimes and the 2nd 2xtimes.
    for files in [mc_files, data_files]:
        files = 3 * files[:1] +  2 * files[1:2] + mc_files[2:]
    
    options = ' --delay=100 --loop'
    command = 'gifsicle %s \\\n    %s > %s_Animation_MC.gif' % (
        options, '\\\n    '.join(mc_files), base_name
        )
    print command
    commands.getoutput(command)
        
    command = 'gifsicle %s \\\n    %s > %s_Animation_Data.gif' % (
        options, '\\\n    '.join(data_files), base_name
        )
    print command
    commands.getoutput(command)
Пример #4
0
def make_pdf_plots():
    '''
    Creates pdf files out of the canvases.
    '''
    canvases.make_plots(['eps'])
    ## Create lists of files with the animation snapshots
    for c in canvases.canvases:
        command = "ps2pdf -dEPSCrop %s.eps" % c.GetName()
        print command
        commands.getoutput(command)
Пример #5
0
def save_and_cleanup(outdir='plots'):
    ## Save plots
    if not os.path.exists(outdir):
        print "Creating folder `%s'" % outdir
        os.mkdir(outdir)
    else:
        ## TODO: remove outdir
        pass
    canvases.make_plots(['png', 'root'], outdir)
    canvases.make_pdf_from_eps(outdir)
    ## Store corrections
    for extractor in extractors:
        raw = extractor.raw.name.split('-')[0]
        target = extractor.target.name.split('-')[0]
        out_file_name = '_'.join([raw, 'to', target, 'qqcorrections.root'])
        extractor.write_corrector_to_file(outdir + '/' + out_file_name)
    ## Cleanup
    trees.close_files()
Пример #6
0
def save_and_cleanup(outdir = 'plots'):
    ## Save plots
    if not os.path.exists(outdir):
        print "Creating folder `%s'" % outdir
        os.mkdir(outdir)
    else:
        ## TODO: remove outdir
        pass
    canvases.make_plots(['png', 'root'], outdir)
    canvases.make_pdf_from_eps(outdir)
    ## Store corrections
    for extractor in extractors:
        raw    = extractor.raw   .name.split('-')[0]
        target = extractor.target.name.split('-')[0]
        out_file_name = '_'.join([raw, 'to', target, 'qqcorrections.root'])
        extractor.write_corrector_to_file(outdir + '/' + out_file_name)
    ## Cleanup
    trees.close_files()
Пример #7
0
def main():
    '''
    Main entry point of execution.
    '''
    hist = get_gaussian_histogram()
    make_canvases(hist)
    make_more_canvases(hist)

    ## Make output graphics in different formats using ROOT for the conversions
    canvases.make_plots('png C root eps'.split())

    ## Store canvases as pdf by creating eps and then using ps2pdf to convert
    ## them.
    canvases.make_pdf_from_eps()

    ## The module holds references to the created canvases.
    ## Note that they did not get killed even though we do not
    ## explicitly keep references to them.  They still show up on the screen.
    ## You can access them like this:
    print 'List of canvases:'
    pprint.pprint(canvases.canvases)
Пример #8
0
def main():
    '''
    Main entry point of execution.
    '''
    hist = get_gaussian_histogram()
    make_canvases(hist)
    make_more_canvases(hist)

    ## Make output graphics in different formats using ROOT for the conversions
    canvases.make_plots('png C root eps'.split())

    ## Store canvases as pdf by creating eps and then using ps2pdf to convert
    ## them.
    canvases.make_pdf_from_eps()

    ## The module holds references to the created canvases.
    ## Note that they did not get killed even though we do not
    ## explicitly keep references to them.  They still show up on the screen.
    ## You can access them like this:
    print 'List of canvases:'
    pprint.pprint(canvases.canvases)
Пример #9
0
        for icalcat in range(8):
            cat = 'calcat%d' % icalcat
            print '+++ ', em, src, cat
            fitter = ModeAndEffSigmaFitter(name = '_'.join([em, src, cat]),
                                           debuglevel = debuglevel)        
            fitter.run()
            fitters.append(fitter)

## Store RooFit objects in a rootfile
w = ROOT.RooWorkspace('w')
for f in fitters:
    for item in [f.data, f.data_half_odd, f.data_half_even, f.model]:
        w.Import(item)
    w.Import(f.fit_data, f.name + '_fit_data')
    w.Import(f.train_data, f.name + '_train_data')
    w.Import(f.fit_result, f.name + '_fit_result')

w.writeToFile(output_filename)
        
## Store canvases in a rootfile
outfile = ROOT.TFile.Open(output_filename, 'UPDATE')
outfile.mkdir('Canvases').cd()
for c in canvases.canvases:
    if c:
        c.Write(c.GetName())

canvases.make_plots('eps png C'.split())

if __name__ == '__main__':
        import user
Пример #10
0
        for icalcat in range(8):
            cat = 'calcat%d' % icalcat
            print '+++ ', em, src, cat
            fitter = ModeAndEffSigmaFitter(name='_'.join([em, src, cat]),
                                           debuglevel=debuglevel)
            fitter.run()
            fitters.append(fitter)

## Store RooFit objects in a rootfile
w = ROOT.RooWorkspace('w')
for f in fitters:
    for item in [f.data, f.data_half_odd, f.data_half_even, f.model]:
        w.Import(item)
    w.Import(f.fit_data, f.name + '_fit_data')
    w.Import(f.train_data, f.name + '_train_data')
    w.Import(f.fit_result, f.name + '_fit_result')

w.writeToFile(output_filename)

## Store canvases in a rootfile
outfile = ROOT.TFile.Open(output_filename, 'UPDATE')
outfile.mkdir('Canvases').cd()
for c in canvases.canvases:
    if c:
        c.Write(c.GetName())

canvases.make_plots('eps png C'.split())

if __name__ == '__main__':
    import user
Пример #11
0
    if ytitle:
        graph.GetYaxis().SetTitle(ytitle)
    if yrange:
        graph.GetYaxis().SetRangeUser(*yrange)
    if color:
        paint(graph, color)
    return graph


## End of customize(graph)


##______________________________________________________________________________
def paint(graph, color):
    '''
    For the given graph, sets the color of the line and marker to the given one.
    '''
    graph.SetLineColor(color)
    graph.SetMarkerColor(color)
    return graph


## End of customize(graph)

##______________________________________________________________________________
if __name__ == '__main__':
    main()
    #pprint.pprint(graphs)
    canvases.make_plots(['png'])
    canvases.make_pdf_from_eps()
Пример #12
0
    '''
    if name:
        graph.SetName(name)
    if ytitle:
        graph.GetYaxis().SetTitle(ytitle)
    if yrange:
        graph.GetYaxis().SetRangeUser(*yrange)
    if color:
        paint(graph, color)
    return graph
## End of customize(graph)


##______________________________________________________________________________
def paint(graph, color):
    '''
    For the given graph, sets the color of the line and marker to the given one.
    '''
    graph.SetLineColor(color)
    graph.SetMarkerColor(color)
    return graph
## End of customize(graph)


##______________________________________________________________________________
if __name__ == '__main__':
    main()
    #pprint.pprint(graphs)
    canvases.make_plots(['png'])
    canvases.make_pdf_from_eps()
Пример #13
0
 def save_plots(self):
     canvases.make_plots(['root'])
     canvases.make_pdf_from_eps()
Пример #14
0
 def save_plots(self):
     canvases.make_plots(['root'])
     canvases.make_pdf_from_eps()