Пример #1
0
    def get_curve(self, track, quantity, hist_name, stat, bin_by=('pt', )):
        x, y, exl, exh, ey = [], [], [], [], []

        for bin in make_bins(*bin_by):
            if not bin.use_by_bin:
                continue

            lower, upper, abscissa = bin.main_var_range()
            x.append(abscissa)
            exl.append(abscissa - lower)
            exh.append(upper - abscissa)

            h = self.get_histo(bin.name, track, quantity, hist_name)
            value, error = get_histo_stat(h, hist_name, stat)
            y.append(value)
            ey.append(error)

        g = ROOT.TGraphAsymmErrors(
            len(x), *[array('d', z) for z in (x, y, exl, exh, ey, ey)])
        g.SetTitle(';%s;%s' % (self.x_titles.get(bin_by[0], 'FIXME'),
                               self.y_titles.get(
                                   (quantity, hist_name, stat), 'FIXME')))
        g.GetYaxis().SetLabelSize(0.04)
        g.GetXaxis().SetLabelOffset(0.002)
        g.GetYaxis().SetTitleOffset(1.1)
        return g
Пример #2
0
 def draw_histos(self, track, quantity, hist_name, bin_by=('pt',)):
     hs = []
     for bin in make_bins(*bin_by):
         hist = self.get_histo(bin.name, track, quantity, hist_name)
         res = fit_histo(hist, hist_name, draw=True)
         hs.append((bin, hist, res))
     return hs
Пример #3
0
 def draw_histos(self, track, quantity, hist_name, bin_by=('pt', )):
     hs = []
     for bin in make_bins(*bin_by):
         hist = self.get_histo(bin.name, track, quantity, hist_name)
         res = fit_histo(hist, hist_name, draw=True)
         hs.append((bin, hist, res))
     return hs
Пример #4
0
    def get_curve(self, track, quantity, hist_name, stat, bin_by=('pt', )):
        x, y, exl, exh, ey = [], [], [], [], []

        for bin in make_bins(*bin_by):
            if not bin.use_by_bin:
                continue

            lower, upper, abscissa = bin.main_var_range()
            x.append(abscissa)
            exl.append(abscissa - lower)
            exh.append(upper - abscissa)

            h = self.get_histo(bin.name, track, quantity, hist_name)
            if track == 'Global' and quantity == 'qinvpt' and hist_name == 'upperR1lower' and bin.name == 'pT350500':
                hist_name = hist_name + '_test'
            if track == 'TuneP' and quantity == 'qinvpt' and hist_name == 'upperR1lower' and bin.name == 'pT5002000':
                hist_name = hist_name + '_fixed'
            value, error = get_histo_stat(h, hist_name, stat)
            hist_name = hist_name.replace('_test', '')
            hist_name = hist_name.replace('_fixed', '')
            y.append(value)
            ey.append(error)

        g = ROOT.TGraphAsymmErrors(
            len(x), *[array('d', z) for z in (x, y, exl, exh, ey, ey)])
        g.SetTitle(';%s;%s' % (self.x_titles.get(bin_by[0], 'FIXME'),
                               self.y_titles.get(
                                   (quantity, hist_name, stat), 'FIXME')))
        g.GetYaxis().SetLabelSize(0.04)
        g.GetXaxis().SetLabelOffset(0.002)
        g.GetYaxis().SetTitleOffset(1.1)
        return g
Пример #5
0
    def get_curve(self, track, quantity, hist_name, stat, bin_by=('pt',)):
        x, y, exl, exh, ey = [], [], [], [], []

        for bin in make_bins(*bin_by):
            if not bin.use_by_bin:
                continue

            lower, upper, abscissa = bin.main_var_range()
            x.append(abscissa)
            exl.append(abscissa - lower)
            exh.append(upper - abscissa)

            h = self.get_histo(bin.name, track, quantity, hist_name)
            if track == 'Global' and quantity == 'qinvpt' and hist_name == 'upperR1lower' and bin.name == 'pT350500':
                hist_name = hist_name + '_test'            
            if track == 'TuneP' and quantity == 'qinvpt' and hist_name == 'upperR1lower' and bin.name == 'pT5002000':
                hist_name = hist_name + '_fixed'            
            value, error = get_histo_stat(h, hist_name, stat)
            hist_name = hist_name.replace('_test','')
            hist_name = hist_name.replace('_fixed','')
            y.append(value)
            ey.append(error)

        g = ROOT.TGraphAsymmErrors(len(x), *[array('d', z) for z in (x,y,exl,exh,ey,ey)])
        g.SetTitle(';%s;%s' % (self.x_titles.get(bin_by[0], 'FIXME'), self.y_titles.get((quantity, hist_name, stat), 'FIXME')))
        g.GetYaxis().SetLabelSize(0.04)
        g.GetXaxis().SetLabelOffset(0.002)
        g.GetYaxis().SetTitleOffset(1.1)
        return g
Пример #6
0
 def draw_histos(self, track, quantity, hist_name, bin_by=('pt', )):
     hs = []
     for bin in make_bins(*bin_by):
         hist = self.get_histo(bin.name, track, quantity, hist_name)
         if track == 'Global' and quantity == 'qinvpt' and hist_name == 'upperR1lower' and bin.name == 'pT350500':
             hist_name = hist_name + '_test'
         if track == 'TuneP' and quantity == 'qinvpt' and hist_name == 'upperR1lower' and bin.name == 'pT5002000':
             hist_name = hist_name + '_fixed'
         res = fit_histo(hist, hist_name, draw=True)
         hist_name = hist_name.replace('_test', '')
         hist_name = hist_name.replace('_fixed', '')
         hs.append((bin, hist, res))
     return hs
Пример #7
0
 def draw_histos(self, track, quantity, hist_name, bin_by=('pt',)):
     hs = []
     for bin in make_bins(*bin_by):
         hist = self.get_histo(bin.name, track, quantity, hist_name)
         if track == 'Global' and quantity == 'qinvpt' and hist_name == 'upperR1lower' and bin.name == 'pT350500':
             hist_name = hist_name + '_test'            
         if track == 'TuneP' and quantity == 'qinvpt' and hist_name == 'upperR1lower' and bin.name == 'pT5002000':
             hist_name = hist_name + '_fixed'            
         res = fit_histo(hist, hist_name, draw=True)
         hist_name = hist_name.replace('_test','')
         hist_name = hist_name.replace('_fixed','')
         hs.append((bin, hist, res))
     return hs
Пример #8
0
    def get_curve(self, track, quantity, hist_name, stat, bin_by=('pt',)):
        x, y, exl, exh, ey = [], [], [], [], []

        for bin in make_bins(*bin_by):
            if not bin.use_by_bin:
                continue

            lower, upper, abscissa = bin.main_var_range()
            x.append(abscissa)
            exl.append(abscissa - lower)
            exh.append(upper - abscissa)

            h = self.get_histo(bin.name, track, quantity, hist_name)
            value, error = get_histo_stat(h, hist_name, stat)
            y.append(value)
            ey.append(error)

        g = ROOT.TGraphAsymmErrors(len(x), *[array('d', z) for z in (x,y,exl,exh,ey,ey)])
        g.SetTitle(';%s;%s' % (self.x_titles.get(bin_by[0], 'FIXME'), self.y_titles.get((quantity, hist_name, stat), 'FIXME')))
        g.GetYaxis().SetLabelSize(0.04)
        g.GetXaxis().SetLabelOffset(0.002)
        g.GetYaxis().SetTitleOffset(1.1)
        return g
Пример #9
0
rhoit(curves)

leg = ROOT.TLegend(0.200, 0.766, 0.638, 0.900)
leg.AddEntry(curves[0], 'estimate', 'LE')
leg.AddEntry(curves[1], 'MC truth', 'LE')
leg.AddEntry(curves[2], 'estimate corrected by #rho', 'LE')
leg.SetBorderSize(0)
leg.SetFillColor(ROOT.kWhite)
leg.Draw()

ps.save('tkonly_qinvpt_rms')

hist_names = [
    ('upperPlower', ROOT.kRed),
    ('upperPmctruth', ROOT.kBlue),
    ('lowerPmctruth', ROOT.kGreen),
]

curves = overlay_curves(which, quantity, hist_names, 'rms', 0, 2)
desqrt2(curves)
rhoit(curves)
ps.save('tkonly_qinvpt_rms_P')

print 'qinvpt upperXlowerXmctruth'
from bins import make_bins
for bin in make_bins('pt'):
    if not bin.use_by_bin: continue
    h = drawer.file.Get('histos/%s/TkOnly/qinvpt/upperXlowerXmctruth' %
                        bin.name)
    print '%20s %6.4f' % (bin.name, h.GetCorrelationFactor())
Пример #10
0
    use_unpropagated_values=cms.bool(True),
    pp_reco_mode=cms.bool(False),
    force_run_list=cms.vuint32(run_list),
    force_lumi_list=cms.vuint32(lumi_list),
    force_event_list=cms.vuint32(ev_list),
    require_tt25=cms.bool(options.require_tt25),
    require_not_tt25=cms.bool(options.require_not_tt25),
    min_bfield=cms.double(3.7),
    copy_selected_events=cms.bool(options.copy_selected_events),
    make_scatterplots=cms.bool(options.make_scatterplots),
)

if options.bin_by_run:
    if not run_list:
        raise ValueError('bin_by_run specified but run_list is empty')
    bins = make_bins('run', run_list)
elif options.bin_by_phi:
    bins = make_bins('phi', [x / 100. for x in range(-320, 321, 32)])
else:
    bins = make_bins('pt')

print 'configuring config:'

z = cfg.parameters_().items() + [
    ('bins, number of', len(bins)),
    ('bins', bins),
    ('run_types', options.run_types),
    ('require_rpc_good', options.require_rpc_good),
    ('output_file', options.output_fn),
]
z.sort(key=lambda x: x[0])
Пример #11
0
    use_unpropagated_values = cms.bool(True),
    pp_reco_mode            = cms.bool(False),
    force_run_list          = cms.vuint32(run_list),
    force_lumi_list         = cms.vuint32(lumi_list),
    force_event_list        = cms.vuint32(ev_list),
    require_tt25            = cms.bool(options.require_tt25),
    require_not_tt25        = cms.bool(options.require_not_tt25),
    min_bfield              = cms.double(3.7),
    copy_selected_events    = cms.bool(options.copy_selected_events),
    make_scatterplots       = cms.bool(options.make_scatterplots),
    )

if options.bin_by_run:
    if not run_list:
        raise ValueError('bin_by_run specified but run_list is empty')
    bins = make_bins('run', run_list)
elif options.bin_by_phi:
    bins = make_bins('phi', [x/100. for x in range(-320, 321, 32)])
else:
    bins = make_bins('pt')

print 'configuring config:'

z = cfg.parameters_().items() + [
    ('bins, number of', len(bins)),
    ('bins', bins),
    ('run_types', options.run_types),
    ('require_rpc_good', options.require_rpc_good),
    ('output_file', options.output_fn),
    ]
z.sort(key=lambda x: x[0])
Пример #12
0
    check_shared_hits=cms.bool(options.check_shared_hits),
    use_unpropagated_values=cms.bool(True),
    pp_reco_mode=cms.bool(False),
    force_run_list=cms.vuint32(run_list),
    force_event_list=cms.vuint32(),
    require_tt25=cms.bool(options.require_tt25),
    require_not_tt25=cms.bool(options.require_not_tt25),
    min_bfield=cms.double(3.7),
    copy_selected_events=cms.bool(options.copy_selected_events),
    make_scatterplots=cms.bool(options.make_scatterplots),
)

if options.bin_by_run:
    if not run_list:
        raise ValueError("bin_by_run specified but run_list is empty")
    bins = make_bins("run", run_list)
elif options.bin_by_phi:
    bins = make_bins("phi", [x / 100.0 for x in range(-320, 321, 32)])
else:
    bins = make_bins("pt")

print "configuring config:"

z = cfg.parameters_().items() + [
    ("bins, number of", len(bins)),
    ("bins", bins),
    ("run_types", options.run_types),
    ("require_rpc_good", options.require_rpc_good),
    ("output_file", options.output_fn),
]
z.sort(key=lambda x: x[0])
Пример #13
0
rhoit(curves)

leg = ROOT.TLegend(0.200, 0.766, 0.638, 0.900)
leg.AddEntry(curves[0], 'estimate', 'LE')
leg.AddEntry(curves[1], 'MC truth', 'LE')
leg.AddEntry(curves[2], 'estimate corrected by #rho', 'LE')
leg.SetBorderSize(0)
leg.SetFillColor(ROOT.kWhite)
leg.Draw()

ps.save('tkonly_qinvpt_rms')


hist_names = [
    ('upperPlower',   ROOT.kRed),
    ('upperPmctruth', ROOT.kBlue),
    ('lowerPmctruth', ROOT.kGreen),
    ]

curves = overlay_curves(which, quantity, hist_names, 'rms', 0, 2)
desqrt2(curves)
rhoit(curves)
ps.save('tkonly_qinvpt_rms_P')

print 'qinvpt upperXlowerXmctruth'
from bins import make_bins
for bin in make_bins('pt'):
    if not bin.use_by_bin: continue
    h = drawer.file.Get('histos/%s/TkOnly/qinvpt/upperXlowerXmctruth' % bin.name)
    print '%20s %6.4f' % (bin.name, h.GetCorrelationFactor())
Пример #14
0
    if path != 'histos/pT5002000/TkOnly/qinvpt/upperR1lower':
        continue
    print i, path
    name = path.replace('/', '_').replace('histos_', '')
    try:
        draw(name, path, name, 'arb. units', save=True)
        path, base = path.rsplit('/', 1)
        mkdir(cmp_file, path).WriteTObject(ps.c, base)
    except HistogramNotFoundException:
        print '  skipping!'

cmp_file.Close()


from bins import make_bins
bins = make_bins(options.binned_by)
from MuonAnalysis.Cosmics.ResolutionNtupleHelper import track_nicks
quantities = 'chi2dof pixelhits striphits pixellayers striplayers muonhits charge pt invpt qpt qinvpt theta phi dxy dz'.split()
histograms = 'upper lower upperDlower upperR0lower upperR1lower upperPlower'.split()

#quantities = 'qpt qinvpt theta phi dxy dz'.split()
#bins = [bins[-1]]
#histograms = ['upperR1lower']
#track_nicks = ['TkOnly']

for bin in bins:
    bin = bin.name
    for track in track_nicks:
        for quantity in quantities:
            for histogram in histograms:
                name = '%(bin)s_%(track)s_%(quantity)s_%(histogram)s' % locals()