Exemplo n.º 1
0
 def __init__(self,
              box,
              tag="Razor2016_MoriondRereco",
              weights=None,
              isData=True,
              configFile="config/run2_2016.config",
              full=False):
     self.sideband = None
     self.weights = weights
     self.isData = isData
     if full:
         self.fitRegion = 'Full'
     else:
         self.fitRegion = 'LowMR,LowRsq'
     self.analysis = Analysis(box, tag=tag)
     self.filename = self.getFilename()
     self.dirname = os.path.dirname(self.filename)
     self.toysFile = self.getToysFilename(noStat=False, doFreq=False)
     self.sysFile = self.getToysFilename(noStat=True, doFreq=False)
     self.freqToysFile = self.getToysFilename(noStat=False, doFreq=True)
     self.freqSysFile = self.getToysFilename(noStat=True, doFreq=True)
     if not os.path.isdir(self.dirname):
         os.makedirs(self.dirname)
     self.config = Config.Config(configFile)
     self.x = array('d', self.config.getBinning(box)[0])  # MR binning
     self.y = array('d', self.config.getBinning(box)[1])  # Rsq binning
     self.z = array('d', self.config.getBinning(box)[2])  # nBtag binning
     self.workspace = rt.RooWorkspace("w" + box)
     initializeWorkspace(self.workspace, self.config, box)
     setStyle()
Exemplo n.º 2
0
 def __init__(self, box, tag="Razor2016_MoriondRereco", 
         weights=None, isData=True, configFile="config/run2_2016.config",
         full=False):
     self.sideband = None
     self.weights = weights
     self.isData = isData
     if full:
         self.fitRegion = 'Full'
     else:
         self.fitRegion = 'LowMR,LowRsq'
     self.analysis = Analysis(box, tag=tag)
     self.filename = self.getFilename()
     self.dirname = os.path.dirname(self.filename)
     self.toysFile = self.getToysFilename(noStat=False, doFreq=False)
     self.sysFile = self.getToysFilename(noStat=True, doFreq=False)
     self.freqToysFile = self.getToysFilename(noStat=False, doFreq=True)
     self.freqSysFile = self.getToysFilename(noStat=True, doFreq=True)
     if not os.path.isdir(self.dirname):
         os.makedirs(self.dirname)
     self.config = Config.Config(configFile)
     self.x = array('d', self.config.getBinning(box)[0]) # MR binning
     self.y = array('d', self.config.getBinning(box)[1]) # Rsq binning
     self.z = array('d', self.config.getBinning(box)[2]) # nBtag binning
     self.workspace = rt.RooWorkspace("w"+box)
     initializeWorkspace(self.workspace, self.config, box)
     setStyle()
                      dest="box",
                      default="MultiJet",
                      type="string",
                      help="box name")

    (options, args) = parser.parse_args()

    cfg = Config.Config(options.config)

    box = options.box

    ids = 0

    w = rt.RooWorkspace("w" + box)

    initializeWorkspace(w, cfg, box)

    ds = []
    for f in args:
        if f.lower().endswith('.root'):
            rootFile = rt.TFile(f)
            workspace = rootFile.Get('w' + box)
            ds.append(workspace.data('RMRTree').Clone('RMRTree_%i' % ids))
            ids += 1

    wdata = ds[0].Clone('RMRTree')
    for ids in range(1, len(ds)):
        wdata.append(ds[ids])

    uwdata = convertDataset2UnweightedToy(wdata, cfg, box, w, uwName='uw')
    #if a list of physics processes is given, the uncertainty will be applied to each process in the list, assumed uncorrelated from process to process.
    #if an empty list is given, the uncertainty will be applied (correlated) to all processes, including signal.
    shapes = {
            #"norm" : ['dyjetstoll', 'qcd', 'ttjets', 'zjetstonunu', 'multiboson', 'singletop', 'wjetstolnu', 'ttv']
            }

    #specify which systematics should be treated as uncorrelated bin-by-bin
    uncorrShapes = [
            #"norm"
            ] 

    print 'Input files are %s' % ', '.join(args)
    
    #create workspace
    w = rt.RooWorkspace("w"+box)
    variables = initializeWorkspace(w,cfg,box)    
    
    #list of histograms
    ds = []
        
    btagMin =  w.var('nBtag').getMin()
    btagMax =  w.var('nBtag').getMax()

    if removeQCD:
        # first get sum of weights for each background per b-tag bin ( sumW[label] )
        sumW = {}
        sumWQCD = 0.
        for f in args:
            if f.lower().endswith('.root'):
                rootFile = rt.TFile(f)
                tree = rootFile.Get('RazorInclusive')
    parser.add_option('-d','--dir',dest="outDir",default="./",type="string",
                  help="Output directory to store datasets")
    parser.add_option('-b','--box',dest="box", default="MultiJet",type="string",
                  help="box name")

    (options,args) = parser.parse_args()
    
    cfg = Config.Config(options.config)

    box =  options.box

    ids = 0
    
    w = rt.RooWorkspace("w"+box)

    initializeWorkspace(w,cfg,box)
    
    ds = []
    for f in args:
        if f.lower().endswith('.root'):
            rootFile = rt.TFile(f)
            workspace = rootFile.Get('w'+box)
            ds.append(workspace.data('RMRTree').Clone('RMRTree_%i'%ids))
            ids+=1

    
    wdata = ds[0].Clone('RMRTree')
    for ids in range(1,len(ds)):
        wdata.append(ds[ids])
    
    uwdata = convertDataset2UnweightedToy(wdata, cfg, box, w, uwName = 'uw')
Exemplo n.º 6
0
    unrollBins = None
    if options.mergeBins:
        btagBins = cfg.getBinning(box)[2][:-1]
        unrollBins = [(xbinsSignal[box][str(int(btags))+'B'], colsSignal[box][str(int(btags))+'B']) for btags in btagBins]

    if options.noSignalSys:
        shapes = []
    else:
        shapes = ['tightmuoneff','tighteleeff','vetomuoneff','vetoeleeff','jes','muontrig','eletrig','btag','tightmuonfastsim','tightelefastsim','vetomuonfastsim','vetoelefastsim','btagfastsim','facscale','renscale','facrenscale','ees','mes','pileup','isr','mcstat%s'%box.lower()]
        #shapes.append('pdf%s'%box.lower()) #this is for the flat 10% PDF uncertainty (uncorrelated across bins)
        #shapes.extend(['n'+str(n)+'pdf' for n in range(options.numPdfWeights)])

    for curBox in boxList:
        #create workspace
        w = rt.RooWorkspace("w"+curBox)
        variables = initializeWorkspace(w,cfg,curBox)    
        btagMin =  w.var('nBtag').getMin()
        btagMax =  w.var('nBtag').getMax()
        z = array('d', cfg.getBinning(curBox)[2]) # nBtag binning
        
        #list of histograms
        ds = []
        #dictionary of histograms (same content - useful for uncorrelate function)
        dsDict = {}
            
        #make MC histograms
        model = ''
        if f.lower().endswith('.root'):
            rootFile = rt.TFile.Open(f) #open file
            tree = rootFile.Get('RazorInclusive') #get tree
Exemplo n.º 7
0
    else:
        shapes = [
            'tightmuoneff', 'tighteleeff', 'vetomuoneff', 'vetoeleeff', 'jes',
            'muontrig', 'eletrig', 'btag', 'tightmuonfastsim',
            'tightelefastsim', 'vetomuonfastsim', 'vetoelefastsim',
            'btagfastsim', 'facscale', 'renscale', 'facrenscale', 'ees', 'mes',
            'pileup', 'isr',
            'mcstat%s' % box.lower()
        ]
        #shapes.append('pdf%s'%box.lower()) #this is for the flat 10% PDF uncertainty (uncorrelated across bins)
        #shapes.extend(['n'+str(n)+'pdf' for n in range(options.numPdfWeights)])

    for curBox in boxList:
        #create workspace
        w = rt.RooWorkspace("w" + curBox)
        variables = initializeWorkspace(w, cfg, curBox)
        btagMin = w.var('nBtag').getMin()
        btagMax = w.var('nBtag').getMax()
        z = array('d', cfg.getBinning(curBox)[2])  # nBtag binning

        #list of histograms
        ds = []
        #dictionary of histograms (same content - useful for uncorrelate function)
        dsDict = {}

        #make MC histograms
        model = ''
        if f.lower().endswith('.root'):
            rootFile = rt.TFile.Open(f)  #open file
            tree = rootFile.Get('RazorInclusive')  #get tree