Example #1
0
def main():
    ## option parser
    usage = 'usage: %prog [options]'
    parser = optparse.OptionParser(usage)

    hwwtools.addOptions(parser)
    hwwtools.loadOptDefaults(parser)

    addOptions(parser)
    (opt, args) = parseOptions(parser)

    inputdir = opt.inputdir
    outputdir = opt.outputdir
    mass = opt.mass    

    # get MWLPlot.C
    shapepath = os.path.abspath(os.path.dirname(os.path.normpath(__file__))+'/..')
    print 'Shape main directory is',shapepath
    ROOT.gInterpreter.ExecuteMacro(shapepath+'/macros/LatinoStyle2.C')
    hwwtools.loadAndCompile(shapepath+'/macros/MWLPlot.C')

    filenames = getFiles(inputdir)
    # loop over all files
    for file in filenames:
        path = inputdir+'/'+file
        if not any([ (str(m) in file) for m in mass ]): continue
#         if str(mass) not in file and mass > 0:
#             continue

        print 'Making',path
        if not opt.variations:
            makeNominalPlots(path, outputdir, opt)
        else:
            makeShapeUpDown(path,outputdir, opt)

    print 'Used options'
    print ', '.join([ '{0} = {1}'.format(a,b) for a,b in opt.__dict__.iteritems()])
Example #2
0
def runTheShape():
    usage = 'usage: %prog -t tag -p prefix channel'
    parser = optparse.OptionParser(usage)
    parser.add_option('--tag',
                      '-t',
                      dest='tag',
                      help='tag to identify the plots',
                      default=None)
    parser.add_option('--prefix',
                      '-p',
                      dest='prefix',
                      help='prefix',
                      default='.')
    hwwtools.addOptions(parser)
    hwwtools.loadOptDefaults(parser)
    (opt, args) = parser.parse_args()

    tag = opt.tag.replace(' ', '_')

    if not args:
        raise ValueError('Desired channels missing: check the usage')

    if args[0] in hwwlimits.dcnames:
        plots = hwwlimits.dcnames[args[0]]
    else:
        plots = args[:]

    if opt.prefix:
        os.chdir(opt.prefix)

    name = opt.prefix if opt.prefix[-1] != '/' else opt.prefix[:-1]

    macropath = os.path.join(os.path.dirname(mypath), 'macros')

    import ROOT
    hwwtools.loadAndCompile(macropath + '/tdrstyle.C')
    hwwtools.loadAndCompile(macropath + '/PlotLimit.C')

    data = '8'
    if int(opt.lumi) < 10: data = '7'
    pars = {
        'tag': tag,
        'option': '',
        'mypath': mypath,
        'name': name,
        'lumi': opt.lumi,
        'data': data
    }
    print pars
    os.system('mkdir -p plots')
    for plot in plots:
        print plot
        pars['option'] = plot
        command = plot_tmpl.format(tag=tag,
                                   option=plot,
                                   mypath=macropath,
                                   name=name,
                                   lumi=opt.lumi)

        print command
        p = os.system(command)

        ROOT.gROOT.SetBatch(True)
        ROOT.setTDRStyle()
        if int(opt.lumi) < 22:
            ROOT.PlotLimit("limits/{option}_shape.summary".format(**pars),
                           "plots/{tag}_{name}_{option}".format(**pars),
                           ("{lumi} fb^{{-1}} ({data} TeV)".format(**pars)),
                           110, 600, 1, 1,
                           "H #rightarrow WW #rightarrow 2l2#nu", True, 0,
                           'pdf')
            ROOT.PlotLimit("limits/{option}_shape.summary".format(**pars),
                           "plots/{tag}_{name}_{option}".format(**pars),
                           ("{lumi} fb^{{-1}} ({data} TeV)".format(**pars)),
                           110, 600, 1, 1,
                           "H #rightarrow WW #rightarrow 2l2#nu", True, 0,
                           'png')
        else:
            ROOT.PlotLimit("limits/{option}_shape.summary".format(**pars),
                           "plots/{tag}_{name}_{option}".format(**pars),
                           "default", 110, 600, 1, 1,
                           "H #rightarrow WW #rightarrow 2l2#nu", True, 0,
                           'pdf')
            ROOT.PlotLimit("limits/{option}_shape.summary".format(**pars),
                           "plots/{tag}_{name}_{option}".format(**pars),
                           "default", 110, 600, 1, 1,
                           "H #rightarrow WW #rightarrow 2l2#nu", True, 0,
                           'png')
Example #3
0
    ('DYmm', { 'color':ROOT.kGreen+3,   'label':'DY+jets'   , }),
    ('Vg',   { 'color':ROOT.kMagenta+1, 'label':'V+#gamma'  , }),
    ('VgS',  { 'color':ROOT.kMagenta+2, 'label':'V+#gamma*' , }),
    ('WJet', { 'color':ROOT.kGray+1,    'label':'W+jets'    , }),
    ('Top',  { 'color':ROOT.kYellow,    'label':'top'       , }),
    ('ttbar',{ 'color':ROOT.kYellow-4,  'label':'t#bar{t}'  , }),
    ('tW',   { 'color':ROOT.kOrange-2,  'label':'tW'        , }),
    ('WW',   { 'color':ROOT.kAzure-9,   'label':'WW'        , }),
    ('ggWW', { 'color':ROOT.kAzure-7,   'label':'WW'        , }),
])


if not ROOT.gROOT.GetListOfClasses().FindObject('PlotVHqqHggH'):
    shape_path = os.path.join(os.getenv('CMSSW_BASE'),'src/HWWAnalysis/ShapeAnalysis')

    hwwtools.loadAndCompile(shape_path+'/macros/PlotVHqqHggH.C')

class NullStdOutSentry:
    def __init__(self):

        ignlvl = ROOT.gErrorIgnoreLevel
        ROOT.gErrorIgnoreLevel = ROOT.kSysError
        self.rdbuf = ROOT.std.cout.rdbuf()
        ROOT.std.cout.rdbuf(0x0)
        ROOT.gErrorIgnoreLevel = ignlvl

    
    def __del__(self):
        ROOT.std.cout.rdbuf(self.rdbuf)

class HWWPlot(ROOT.PlotVHqqHggH):
Example #4
0
    }),
    ('WW', {
        'color': ROOT.kAzure - 9,
        'label': 'WW',
    }),
    ('ggWW', {
        'color': ROOT.kAzure - 7,
        'label': 'WW',
    }),
])

if not ROOT.gROOT.GetListOfClasses().FindObject('PlotVHqqHggH'):
    shape_path = os.path.join(os.getenv('CMSSW_BASE'),
                              'src/HWWAnalysis/ShapeAnalysis')

    hwwtools.loadAndCompile(shape_path + '/macros/PlotVHqqHggH.C')


class NullStdOutSentry:
    def __init__(self):

        ignlvl = ROOT.gErrorIgnoreLevel
        ROOT.gErrorIgnoreLevel = ROOT.kSysError
        self.rdbuf = ROOT.std.cout.rdbuf()
        ROOT.std.cout.rdbuf(0x0)
        ROOT.gErrorIgnoreLevel = ignlvl

    def __del__(self):
        ROOT.std.cout.rdbuf(self.rdbuf)