'existing' : vhww_masses, 'label' : 'WW', 'name' : lambda mass : 'VH%iWW' % mass }, } for rule, rule_info in rules.iteritems(): for mass in sorted(rule_info['target_masses']): low, high = find_best_interp_points( mass, rule_info['existing']) log.info("Interpolating m=%i %s histogram between %i and %i", mass, rule_info['label'], low, high) for folder in folders: log.debug("Doing shape folder %s", folder) # Switch to the folder name = rule_info['name'] low_hist = f.get(os.path.join(folder, name(low))) high_hist = f.get(os.path.join(folder, name(high))) f.cd(folder) new_hist = morph( name(mass), "VH%s m=%i" % (rule_info['label'], mass), mass, low_hist, low, high_hist, high) log.debug( "mean/norm low:%0.2f/%0.2f high:%0.2f/%0.2f new:%0.2f/%0.2f", low_hist.GetMean(), low_hist.Integral(), high_hist.GetMean(), high_hist.Integral(), new_hist.GetMean(), new_hist.Integral()) new_hist.Write()
''' Stupid tests of the th1fmorph tool ''' from FinalStateAnalysis.StatTools.morph import morph from rootpy.io import open, DoesNotExist file = open('$fsa/VHiggs/test/plotting/wh_shapes.root') hist1 = file.get('mmt_mumu_final_140_MuTauMass/VH140') hist2 = file.get('mmt_mumu_final_120_MuTauMass/VH120') hist130true = file.get('mmt_mumu_final_130_MuTauMass/VH130') print '140', hist1.Integral(), hist1.GetMean() print '130 true', hist130true.Integral(), hist130true.GetMean() print '120', hist2.Integral(), hist2.GetMean() # Try to morph to 130 m130 = morph('130', '130', 130, hist1, 140, hist2, 120) print m130.Integral(), m130.GetMean()