from math import sqrt import ROOT import Styles import argparse from prettifyFunctions import * import ratios # To use user defined help message, sys.arv has to be sent to python and not # to TApplication. ROOT.PyConfig.IgnoreCommandLineOptions = True Styles.tdrStyle() ROOT.gROOT.SetBatch() ROOT.gSystem.Load("libTreeObjects.so") def rebin2D(oldHist, xList, yList): """Rebins a TH2F. oldHist: input TH2F xList: list which mark the bin edges of the new xaxis yList: list which mark the bin edges of the new yaxis """ import ROOT import array newHist = ROOT.TH2F( oldHist.GetName()+randomName(), "%s;%s;%s"%(oldHist.GetTitle(),oldHist.GetXaxis().GetTitle(),oldHist.GetYaxis().GetTitle()), \ len(xList)-1, array.array('d', xList), \ len(yList)-1, array.array('d', yList) ) newHist.Sumw2() for i in range(oldHist.GetNbinsX() + 2): for j in range(oldHist.GetNbinsY() + 2):
print "%.2f standard deviations between theory and measurement"%Compare_val(xs,err_xs_stat,err_xs_sys, theo[1][i], theo[2][i]) if (__name__ == "__main__"): from argparse import ArgumentParser parser = ArgumentParser() parser.add_argument("-m", "--mcfile", dest="mcfile", default="mc_all_new.root/MCTree", help="MC file path") parser.add_argument("-d", "--datafile", dest="datafile", default="d0_new.root/MessTree", help="Data file path") parser.add_argument("-c", "--cut", dest="cut", default="met > 30 && el_et > 30", help="Cuts applied to all structures" ) parser.add_argument("--save", action="store_true", default=False, help="Plots are not drawn, but saved as pdf") parser.add_argument("-p", "--plots", dest="plots", default= "mwt") parser.add_argument("-q", "--quiet", action="store_true", default = False) opts = parser.parse_args() import Styles # official cms style style = Styles.tdrStyle() mcTree = readTree( opts.mcfile ) dataTree = readTree( opts.datafile ) # set cut for el_et !!!!!!!!!!!!!!!! overwrites all!!!!!!!!!!!!! if opts.plots == "el_et": opts.cut = opts.cut + ' && mwt/el_et>1.9' m, e_m,e_m_sys = getMass( dataTree, mcTree, opts.cut, opts.save, opts.plots, opts.quiet ) sin2_wein,err_sin2_wein_stat,err_sin2_wein_sys = getWeinberg( m, e_m ,e_m_sys) gamma,err_gamma_stat,err_gamma_sys = getWidth(m, e_m, e_m_sys ) print "Mass: %.2f \pm %.2f/ (stat.) \pm %.2f (sys.) GeV"%(m, e_m,e_m_sys) print if not opts.quiet: xs,err_xs_stat,err_xs_sys = getXs(dataTree,mcTree,opts.plots,opts.cut)
#! /usr/bin/env python2 # -*- coding: utf-8 -*- import ROOT import argparse import ConfigParser import os.path import Styles Styles.tdrStyle() axisConf = ConfigParser.SafeConfigParser() axisConf.read("axis.cfg") integratedLuminosity = 19.3 #fb def readTree( filename, treename = "susyTree" ): """ filename: name of file containing the tree treename: name of the tree returns: TTree Object """ if not os.path.isfile(filename): print( "File %s does not exist"%filename) tree = ROOT.TChain( treename ) tree.AddFile( filename ) return tree def createHistoFromTree2D(tree, variable, weight="", nBin=50): """ tree: tree to create histo from variable: variable to plot (must be a branch of the tree)