def theConfig(Nj, mcdir = '', initFile = '', btag = False, toydataFile=""):
    fitterPars = RooWjjFitterParams()
    fitterPars.smoothingOrder = 1
    # fitterPars.MCDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree_PAT/RD_"
    fitterPars.MCDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/OriginalTree_PAT/"
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = False
    ##fitterPars.QCDDirectory = fitterPars.MCDirectory[:-3]
    fitterPars.QCDDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree_PAT/"
        
    fitterPars.initParamsFile = initFile
    fitterPars.constraintParamsFile = initFile
    fitterPars.DataDirectory = fitterPars.MCDirectory 
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = True    
    fitterPars.electronData = 'WenuJets_DataAllSingleElectronTrigger_GoldenJSON_4p7invfb.root'
    fitterPars.includeElectrons = True
    fitterPars.NewPhysicsDirectory = fitterPars.MCDirectory
    fitterPars.toydataFile = toydataFile
    
    fitterPars.minMass = 40.
    fitterPars.maxMass = 150.
    fitterPars.nbins = 32
    fitterPars.intLumi = 5020.
    
    binEdge = fitterPars.minMass
    fitterPars.binEdges.push_back(binEdge)
    print binEdge,' ',
    while (binEdge < fitterPars.maxMass):
        binEdge += round(0.10*binEdge)
        fitterPars.binEdges.push_back(binEdge)
        print binEdge,' ',

##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = fitterPars.maxMass
    fitterPars.maxMass = fitterPars.binEdges[fitterPars.binEdges.size()-1]

    print "mass range:",fitterPars.minMass,'-',fitterPars.maxMass
    
    fitterPars.truncRange = False
    fitterPars.blind = False
    fitterPars.minTrunc = 65.

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 94.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = fitterPars.minMass
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = fitterPars.maxMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break


    fitterPars.minWmass = fitterPars.minTrunc
    fitterPars.maxWmass = fitterPars.maxTrunc
    
    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:',fitterPars.minFit,'-',fitterPars.maxFit
    
    fitterPars.njets = Nj
    fitterPars.constrainDiboson = False
    fitterPars.constrainDibosonShape = False
    fitterPars.constrainWpJShape = False
    fitterPars.constrainWpJ = True

    
    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back("EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back("EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    
    fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsSingleElectron.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/FullyEfficient_Jet2NoJet1.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    fitterPars.eleWMtEffFiles.push_back("EffTableDir/WMt50TriggerEfficiency.txt")
    fitterPars.lumiPerEpochElectron.push_back(fitterPars.intLumi)

    fitterPars.useExternalMorphingPars = False

##     jetCut = '(jetPFCor_Pt[%i] < 2) ' % (Nj)
##     for j in range(0, Nj):
##         jetCut += '&& (JetPFCor_Pt[%i] > 30) ' % (j)
##    jetCut = '(ggdevt == %i)' % (Nj)
##     if (Nj < 2):
##         jetCut = '((ggdevt == 2) || (ggdevt == 3))'

    btagCut = 1.74

    fitterPars.cuts = '(sqrt(JetPFCor_Pt[0]**2+JetPFCor_Pt[1]**2+2*JetPFCor_Pt[0]*JetPFCor_Pt[1]*cos(JetPFCor_Phi[0]-JetPFCor_Phi[1]))>20.) ' + \
                      '&& (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.5) ' + \
                      '&& (abs(JetPFCor_dphiMET[0])>0.4) '
    fitterPars.cuts += '&& (JetPFCor_Pt[2]<30) '
    #fitterPars.cuts += '&& (fit_status==0) '

    if btag:
        fitterPars.useWbbPDF = False
        fitterPars.cuts += '&& ( (JetPFCor_bDiscriminator[0]>%.2f) || (JetPFCor_bDiscriminator[1]>%.2f) ) ' % (btagCut,btagCut)
        fitterPars.cuts += '&& (JetPFCor_Pt[1]>35) '
    else:
        fitterPars.useWbbPDF = False
        fitterPars.cuts += '&& (JetPFCor_bDiscriminator[0]<%.2f) && (JetPFCor_bDiscriminator[1]<%.2f) ' % (btagCut,btagCut)
        fitterPars.cuts += '&& (JetPFCor_Pt[1]>35.) '

    return fitterPars
def theConfig(Nj, mcdir = '', initFile = '', toydataFile = ''):
    fitterPars = RooWjjFitterParams()

    fitterPars.MCDirectory = '/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree/RD_'
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = True
    fitterPars.QCDDirectory = '/uscms_data/d2/kalanand/WjjTrees/NewReducedQCDTrees/'
    fitterPars.initParamsFile = initFile

    fitterPars.DataDirectory = fitterPars.MCDirectory
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = False
##    fitterPars.electronData = 'WenuJets_DataAll_GoldenJSON_4p7invfb.root'
##     fitterPars.electronData = 'SingleEleAndEleTwoPFJetTrigger.root'
    fitterPars.electronData = 'EleTwoCaloJetTrigger.root'
    fitterPars.includeElectrons = True

    fitterPars.NewPhysicsDirectory = '/uscms_data/d2/kalanand/WjjTrees/ReducedTree/NewKfitRDTree/RD_'

    fitterPars.fitToyDataset = False
    fitterPars.ToyDatasetDirectory = '/uscms_data/d1/ilyao/KinematicFitterS11/ErrorScans/1KMCSets/'
    fitterPars.toydataFile = toydataFile

    fitterPars.minMass = 30.
    fitterPars.maxMass = 400.
    fitterPars.nbins = 34
    fitterPars.intLumi = 3819.994

    fitterPars.binEdges.push_back(fitterPars.minMass)

    binEdge = fitterPars.minMass
    print binEdge,' ',
    while (binEdge <= fitterPars.maxMass):
        binEdge += round(0.15*binEdge)
        fitterPars.binEdges.push_back(binEdge)
        print binEdge,' ',

    fitterPars.binEdges[fitterPars.binEdges.size()-1] = fitterPars.maxMass
##     fitterPars.maxMass = fitterPars.binEdges[fitterPars.binEdges.size()-1]
    
    print "mass range:",fitterPars.minMass,'-',fitterPars.maxMass
    
    fitterPars.truncRange = True
    fitterPars.blind = True
    fitterPars.minTrunc = 130.

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 170.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = 60.
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = 400.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break

    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:',fitterPars.minFit,'-',fitterPars.maxFit

    fitterPars.njets = Nj
    fitterPars.constrainDiboson = True

    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back("EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back("EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

#### Add the information for Electron each epoch ####
#### Epoch Luminosities are 215.274+664.732=880.006, 927.947, 323.164, 412.359, 246.527, 1909.9970 (Sum Lumi = 4700).
##     ## Epochs 1+7
##     fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
##     fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
##     fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
##     fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
##     fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
##     fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
##     fitterPars.lumiPerEpochElectron.push_back(880.006)
    ## Epoch 2
    fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_PromptReco-v4-PFEE-EleJets.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_PromptReco-v4-PFEE-EleJets.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(927.947)
    ## Epoch 3
    fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_05Aug2011ReReco-v1-2E33.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_05Aug2011ReReco-v1-2E33.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(323.164)
    ## Epoch 4
    fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_PromptReco-v6-2E33.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_PromptReco-v6-2E33.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(412.359)
    ## Epoch 5
    fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_PromptReco-v6-3E33.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_PromptReco-v6-3E33.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(246.527)
    ## Epoch 6
    fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_post-epsCaloLWA.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_post-epsCaloLWA.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(1909.9970)



    fitterPars.useExternalMorphingPars = False
       
    fitterPars.cuts = '(W_mt > 50.) ' + \
                      '&& (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.2) ' + \
                      '&& (sqrt(JetPFCor_Pt[0]**2+JetPFCor_Pt[1]**2+2*JetPFCor_Pt[0]*JetPFCor_Pt[1]*cos(JetPFCor_Phi[0]-JetPFCor_Phi[1]))>45.) ' + \
                      '&& (JetPFCor_Pt[1]/Mass2j_PFCor>0.3) ' + \
                      '&& (JetPFCor_Pt[1]/Mass2j_PFCor<0.7) ' + \
                      '&& (JetPFCor_Pt[0] > 40) '

    return fitterPars
예제 #3
0
def theConfig(Nj, mcdir='', initFile='', toydataFile=''):
    fitterPars = RooWjjFitterParams()

    fitterPars.MCDirectory = '/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree/RD_'
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = True
    fitterPars.QCDDirectory = '/uscms_data/d2/kalanand/WjjTrees/NewReducedQCDTrees/'
    fitterPars.initParamsFile = initFile

    fitterPars.DataDirectory = fitterPars.MCDirectory
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = False
    ##    fitterPars.electronData = 'WenuJets_DataAll_GoldenJSON_4p7invfb.root'
    ##     fitterPars.electronData = 'SingleEleAndEleTwoPFJetTrigger.root'
    fitterPars.electronData = 'EleTwoCaloJetTrigger.root'
    fitterPars.includeElectrons = True

    fitterPars.NewPhysicsDirectory = '/uscms_data/d2/kalanand/WjjTrees/ReducedTree/NewKfitRDTree/RD_'

    fitterPars.fitToyDataset = False
    fitterPars.ToyDatasetDirectory = '/uscms_data/d1/ilyao/KinematicFitterS11/ErrorScans/1KMCSets/'
    fitterPars.toydataFile = toydataFile

    fitterPars.minMass = 30.
    fitterPars.maxMass = 400.
    fitterPars.nbins = 34
    fitterPars.intLumi = 3819.994

    fitterPars.binEdges.push_back(fitterPars.minMass)

    binEdge = fitterPars.minMass
    print binEdge, ' ',
    while (binEdge <= fitterPars.maxMass):
        binEdge += round(0.15 * binEdge)
        fitterPars.binEdges.push_back(binEdge)
        print binEdge, ' ',

    fitterPars.binEdges[fitterPars.binEdges.size() - 1] = fitterPars.maxMass
    ##     fitterPars.maxMass = fitterPars.binEdges[fitterPars.binEdges.size()-1]

    print "mass range:", fitterPars.minMass, '-', fitterPars.maxMass

    fitterPars.truncRange = True
    fitterPars.blind = True
    fitterPars.minTrunc = 130.

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 170.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = 60.
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = 400.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break

    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:', fitterPars.minFit, '-', fitterPars.maxFit

    fitterPars.njets = Nj
    fitterPars.constrainDiboson = True

    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back(
        "EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back(
        "EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    #### Add the information for Electron each epoch ####
    #### Epoch Luminosities are 215.274+664.732=880.006, 927.947, 323.164, 412.359, 246.527, 1909.9970 (Sum Lumi = 4700).
    ##     ## Epochs 1+7
    ##     fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    ##     fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    ##     fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    ##     fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    ##     fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    ##     fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    ##     fitterPars.lumiPerEpochElectron.push_back(880.006)
    ## Epoch 2
    fitterPars.eleIdEffFiles.push_back(
        "EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back(
        "EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back(
        "EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_PromptReco-v4-PFEE-EleJets.txt"
    )
    fitterPars.eleJ25NoJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_PromptReco-v4-PFEE-EleJets.txt"
    )
    fitterPars.eleMHTEffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(927.947)
    ## Epoch 3
    fitterPars.eleIdEffFiles.push_back(
        "EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back(
        "EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back(
        "EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_05Aug2011ReReco-v1-2E33.txt"
    )
    fitterPars.eleJ25NoJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_05Aug2011ReReco-v1-2E33.txt"
    )
    fitterPars.eleMHTEffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(323.164)
    ## Epoch 4
    fitterPars.eleIdEffFiles.push_back(
        "EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back(
        "EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back(
        "EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_PromptReco-v6-2E33.txt"
    )
    fitterPars.eleJ25NoJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_PromptReco-v6-2E33.txt"
    )
    fitterPars.eleMHTEffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(412.359)
    ## Epoch 5
    fitterPars.eleIdEffFiles.push_back(
        "EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back(
        "EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back(
        "EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_PromptReco-v6-3E33.txt"
    )
    fitterPars.eleJ25NoJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_PromptReco-v6-3E33.txt"
    )
    fitterPars.eleMHTEffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(246.527)
    ## Epoch 6
    fitterPars.eleIdEffFiles.push_back(
        "EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back(
        "EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back(
        "EffTableDir/eleEffsWP80ToHLTEle27_May10ReReco.txt")
    fitterPars.eleJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_post-epsCaloLWA.txt"
    )
    fitterPars.eleJ25NoJ30EffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_post-epsCaloLWA.txt"
    )
    fitterPars.eleMHTEffFiles.push_back(
        "EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    fitterPars.lumiPerEpochElectron.push_back(1909.9970)

    fitterPars.useExternalMorphingPars = False

    fitterPars.cuts = '(W_mt > 50.) ' + \
                      '&& (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.2) ' + \
                      '&& (sqrt(JetPFCor_Pt[0]**2+JetPFCor_Pt[1]**2+2*JetPFCor_Pt[0]*JetPFCor_Pt[1]*cos(JetPFCor_Phi[0]-JetPFCor_Phi[1]))>45.) ' + \
                      '&& (JetPFCor_Pt[1]/Mass2j_PFCor>0.3) ' + \
                      '&& (JetPFCor_Pt[1]/Mass2j_PFCor<0.7) ' + \
                      '&& (JetPFCor_Pt[0] > 40) '

    return fitterPars
def theConfig(Nj, mcdir='', initFile='', mH=400):
    optPars = getOptimalPars(mH, optimalPars2)
    minMlvjj = optPars[1]
    maxMlvjj = optPars[2]
    fitterPars = RooWjjFitterParams()
    fitterPars.smoothingOrder = 1
    fitterPars.MCDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree/RD_"
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = False
    fitterPars.QCDDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree/"
    fitterPars.initParamsFile = initFile
    # fitterPars.constraintParamsFile = "HWWConstraints2Jets.txt";
    fitterPars.DataDirectory = fitterPars.MCDirectory
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = True
    fitterPars.electronData = 'WenuJets_DataAllSingleElectronTrigger_GoldenJSON_4p7invfb.root'
    fitterPars.includeElectrons = False

    fitterPars.NewPhysicsDirectory = '/uscms_data/d2/kalanand/WjjTrees/ReducedTree/NewKfitRDTree/RD_'
    fitterPars.minMass = 40.
    fitterPars.maxMass = 200.
    fitterPars.nbins = 30
    fitterPars.intLumi = 4700.

    fitterPars.binEdges.push_back(fitterPars.minMass)
    #fitterPars.binEdges.push_back(40.)
    fitterPars.binEdges.push_back(45.)
    fitterPars.binEdges.push_back(50.)
    fitterPars.binEdges.push_back(55.)
    fitterPars.binEdges.push_back(60.)
    fitterPars.binEdges.push_back(65.)
    fitterPars.binEdges.push_back(70.)
    fitterPars.binEdges.push_back(75.)
    fitterPars.binEdges.push_back(80.)
    fitterPars.binEdges.push_back(85.)
    fitterPars.binEdges.push_back(95.)
    fitterPars.binEdges.push_back(105.)
    fitterPars.binEdges.push_back(115.)
    fitterPars.binEdges.push_back(125.)
    fitterPars.binEdges.push_back(135.)
    fitterPars.binEdges.push_back(145.)
    fitterPars.binEdges.push_back(160.)
    fitterPars.binEdges.push_back(175.)
    fitterPars.binEdges.push_back(200.)

    ##     binEdge = fitterPars.minMass
    ##     print binEdge,' ',
    ##     while (binEdge <= fitterPars.maxMass):
    ##         binEdge += round(0.14*binEdge)
    ##         fitterPars.binEdges.push_back(binEdge)
    ##         print binEdge,' ',

    ##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = fitterPars.maxMass

    print "mass range:", fitterPars.minMass, '-', fitterPars.maxMass

    fitterPars.truncRange = True
    fitterPars.blind = False
    fitterPars.minTrunc = 65.

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 94.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = fitterPars.minMass
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = fitterPars.maxMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break

    fitterPars.minWmass = fitterPars.minTrunc
    fitterPars.maxWmass = fitterPars.maxTrunc

    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:', fitterPars.minFit, '-', fitterPars.maxFit

    fitterPars.njets = Nj
    fitterPars.constrainDiboson = True

    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back(
        "EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back(
        "EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    fitterPars.eleIdEffFiles.push_back(
        "EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back(
        "EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back(
        "EffTableDir/eleEffsSingleElectron.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back(
        "EffTableDir/FullyEfficient_Jet2NoJet1.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    fitterPars.eleWMtEffFiles.push_back(
        "EffTableDir/WMt50TriggerEfficiency.txt")
    fitterPars.lumiPerEpochElectron.push_back(fitterPars.intLumi)

    fitterPars.constrainDiboson = True
    fitterPars.useExternalMorphingPars = False

    jetCut = '(ggdevt == %i)' % (Nj)
    if (Nj < 2):
        jetCut = '((ggdevt == 2) || (ggdevt == 3))'

    fitterPars.cuts = '(fit_status==0) ' + \
                      '&& %s ' % (jetCut) + \
                      '&& (fit_mlvjj > %0.1f) && (fit_mlvjj < %0.1f) ' % \
                      (minMlvjj, maxMlvjj)

    return fitterPars
def theConfig(Nj, mcdir = '', initFile = '', mH = 400):
    optPars = getOptimalPars(mH, optimalPars2)
    minMlvjj = optPars[1]
    maxMlvjj = optPars[2]
    fitterPars = RooWjjFitterParams()
    fitterPars.smoothingOrder = 1
    fitterPars.MCDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree/RD_"
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = False
    fitterPars.QCDDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree/"
    fitterPars.initParamsFile = initFile
    # fitterPars.constraintParamsFile = "HWWConstraints2Jets.txt";
    fitterPars.DataDirectory = fitterPars.MCDirectory 
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = True    
    fitterPars.electronData = 'WenuJets_DataAllSingleElectronTrigger_GoldenJSON_4p7invfb.root'
    fitterPars.includeElectrons = False
   
    fitterPars.NewPhysicsDirectory = '/uscms_data/d2/kalanand/WjjTrees/ReducedTree/NewKfitRDTree/RD_'
    fitterPars.minMass = 40.
    fitterPars.maxMass = 200.
    fitterPars.nbins = 30
    fitterPars.intLumi = 4700.

    
    fitterPars.binEdges.push_back(fitterPars.minMass)
    #fitterPars.binEdges.push_back(40.)
    fitterPars.binEdges.push_back(45.)
    fitterPars.binEdges.push_back(50.)
    fitterPars.binEdges.push_back(55.)
    fitterPars.binEdges.push_back(60.)
    fitterPars.binEdges.push_back(65.)
    fitterPars.binEdges.push_back(70.)
    fitterPars.binEdges.push_back(75.)
    fitterPars.binEdges.push_back(80.)
    fitterPars.binEdges.push_back(85.)
    fitterPars.binEdges.push_back(95.)
    fitterPars.binEdges.push_back(105.)
    fitterPars.binEdges.push_back(115.)
    fitterPars.binEdges.push_back(125.)
    fitterPars.binEdges.push_back(135.)
    fitterPars.binEdges.push_back(145.)
    fitterPars.binEdges.push_back(160.)
    fitterPars.binEdges.push_back(175.)
    fitterPars.binEdges.push_back(200.)

##     binEdge = fitterPars.minMass
##     print binEdge,' ',
##     while (binEdge <= fitterPars.maxMass):
##         binEdge += round(0.14*binEdge)
##         fitterPars.binEdges.push_back(binEdge)
##         print binEdge,' ',

##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = fitterPars.maxMass

    print "mass range:",fitterPars.minMass,'-',fitterPars.maxMass
    
    fitterPars.truncRange = True
    fitterPars.blind = False
    fitterPars.minTrunc = 65.

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 94.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = fitterPars.minMass
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = fitterPars.maxMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break


    fitterPars.minWmass = fitterPars.minTrunc
    fitterPars.maxWmass = fitterPars.maxTrunc
    
    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:',fitterPars.minFit,'-',fitterPars.maxFit
    
    fitterPars.njets = Nj
    fitterPars.constrainDiboson = True

    
    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back("EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back("EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    
    fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsSingleElectron.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/FullyEfficient_Jet2NoJet1.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    fitterPars.eleWMtEffFiles.push_back("EffTableDir/WMt50TriggerEfficiency.txt")
    fitterPars.lumiPerEpochElectron.push_back(fitterPars.intLumi)

    fitterPars.constrainDiboson = True
    fitterPars.useExternalMorphingPars = False

    jetCut = '(ggdevt == %i)' % (Nj)
    if (Nj < 2):
        jetCut = '((ggdevt == 2) || (ggdevt == 3))'

    fitterPars.cuts = '(fit_status==0) ' + \
                      '&& %s ' % (jetCut) + \
                      '&& (fit_mlvjj > %0.1f) && (fit_mlvjj < %0.1f) ' % \
                      (minMlvjj, maxMlvjj)
    if mH == 180:
        fitterPars.cuts += '&& (abs(ang_hs) <= 0.64) ' + \
                           '&& (JetPFCor_QGLikelihood[0] >= 0.26) ' + \
                           '&& (JetPFCor_QGLikelihood[1] >= 0.23) ' + \
                           '&& (ang_hb < 0.72) ' + \
                           '&& (abs(ang_ha)<0.84) ' + \
                           '&& (ptlvjj >=4.) && (ptlvjj <= 52.) ' +\
                           '&& (abs(ylvjj) <= 1.55) '
    if mH == 250:
        fitterPars.cuts += '&& (abs(ang_hs) <= 0.42) ' + \
                           '&& (JetPFCor_QGLikelihood[0] >= 0.25) ' + \
                           '&& (JetPFCor_QGLikelihood[1] >= 0.28) ' + \
                           '&& (ang_hb < 0.46) ' + \
                           '&& (abs(ang_ha)<0.64) ' + \
                           '&& (ptlvjj >=8.) && (ptlvjj <= 118.) ' +\
                           '&& (abs(ylvjj) <= 1.7) '
    if mH == 400:
        fitterPars.cuts += '&& (abs(ang_hs) <= 0.40) ' + \
                           '&& (JetPFCor_QGLikelihood[0] >= 0.21) ' + \
                           '&& (JetPFCor_QGLikelihood[1] >= 0.27) ' + \
                           '&& (ang_hb < 0.52) ' + \
                           '&& (abs(ang_ha)<0.92) ' + \
                           '&& (ptlvjj <= 148.) ' +\
                           '&& (abs(ylvjj) <= 1.95) '

    return fitterPars
def theConfig(Nj, mcdir="", initFile=""):
    fitterPars = RooWjjFitterParams()
    fitterPars.smoothingOrder = 1
    # fitterPars.MCDirectory = "root://cmseos.fnal.gov:1094//eos/uscms/store/user/lnujj/HCP2012METfix/ReducedTrees/RD_"
    fitterPars.MCDirectory = "/uscms_data/d1/andersj/Wjj/2012/data/ReducedTrees/RD_"

    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if len(mcdir) > 0:
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = False
    fitterPars.QCDDirectory = fitterPars.MCDirectory[:-3]
    # fitterPars.QCDDirectory = 'root://cmseos:1094//eos/uscms/store/user/lnujj/2012_RDTrees_PAT/'
    fitterPars.initParamsFile = initFile
    # fitterPars.constraintParamsFile = "HWWConstraints2Jets.txt";
    fitterPars.DataDirectory = fitterPars.MCDirectory
    # fitterPars.DataDirectory = "/uscms_data/d1/andersj/Wjj/2012/data/ICHEP2012/ReducedTrees/RD_"
    # fitterPars.muonData = 'SingleMu_0p56fb_Golden.root'
    # fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_5p1invfb.root'
    fitterPars.muonData = "WmunuJets_DataAll_GoldenJSON_12p0invfb.root"
    fitterPars.includeMuons = True
    # fitterPars.electronData = 'WenuJets_DataSingleElectron_GoldenJSON_2012_xxpxinvfb.root'
    # fitterPars.electronData = 'WenuJets_DataAllSingleElectronTrigger_GoldenJSON_5p1invfb.root'
    fitterPars.electronData = "WenuJets_DataAllSingleElectronTrigger_GoldenJSON_11p9invfb.root"
    fitterPars.includeElectrons = True

    fitterPars.NewPhysicsDirectory = fitterPars.MCDirectory
    fitterPars.minMass = 45.0
    # fitterPars.minMass = 50.
    fitterPars.maxMass = 200.0
    fitterPars.nbins = 17
    fitterPars.intLumi = 12000
    # fitterPars.intLumi = 3500.
    # fitterPars.intLumi = 539.385+21.297
    # fitterPars.intLumi = 297.848+21.297+48.465

    fitterPars.binEdges.push_back(fitterPars.minMass)
    # fitterPars.binEdges.push_back(40.)
    # fitterPars.binEdges.push_back(45.)
    fitterPars.binEdges.push_back(50.0)
    fitterPars.binEdges.push_back(55.0)
    fitterPars.binEdges.push_back(60.0)
    fitterPars.binEdges.push_back(65.0)
    fitterPars.binEdges.push_back(70.0)
    fitterPars.binEdges.push_back(75.0)
    fitterPars.binEdges.push_back(80.0)
    fitterPars.binEdges.push_back(85.0)
    fitterPars.binEdges.push_back(95.0)
    fitterPars.binEdges.push_back(105.0)
    fitterPars.binEdges.push_back(115.0)
    fitterPars.binEdges.push_back(125.0)
    fitterPars.binEdges.push_back(135.0)
    fitterPars.binEdges.push_back(145.0)
    fitterPars.binEdges.push_back(160.0)
    fitterPars.binEdges.push_back(175.0)
    fitterPars.binEdges.push_back(200.0)

    ##     binEdge = fitterPars.minMass
    ##     print binEdge,' ',
    ##     while (binEdge <= fitterPars.maxMass):
    ##         binEdge += round(0.14*binEdge)
    ##         fitterPars.binEdges.push_back(binEdge)
    ##         print binEdge,' ',

    ##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = fitterPars.maxMass

    print "mass range:", fitterPars.minMass, "-", fitterPars.maxMass

    fitterPars.truncRange = True
    fitterPars.blind = False
    fitterPars.minTrunc = 65.0

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 94.0
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = fitterPars.minMass
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = fitterPars.maxMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break

    fitterPars.minWmass = fitterPars.minTrunc
    fitterPars.maxWmass = fitterPars.maxTrunc

    print "truncate:", fitterPars.truncRange, ":", fitterPars.minTrunc, "-", fitterPars.maxTrunc
    print "fit range:", fitterPars.minFit, "-", fitterPars.maxFit

    fitterPars.njets = Nj
    fitterPars.constrainDiboson = True
    fitterPars.externalConstraints = False

    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back("EffTable2012/scaleFactor-Run2012ABC-RecoToIso.txt")
    fitterPars.muHLTEffFiles.push_back("EffTable2012/efficiency-Run2012ABC-IsoToIsoMuHLT.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    fitterPars.eleIdEffFiles.push_back("EffTable2012/scaleFactor-Run2012ABC-GsfElectronToId.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTable2012/scaleFactor-Run2012ABC-SCToElectron.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTable2012/efficiency-Run2012ABC-WP80ToHLTEle.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/FullyEfficient_Jet2NoJet1.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    fitterPars.eleWMtEffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.lumiPerEpochElectron.push_back(fitterPars.intLumi)

    fitterPars.constrainDiboson = True
    fitterPars.useExternalMorphingPars = False

    jetCut = "(ggdevt == %i)" % (Nj)
    if Nj < 2:
        jetCut = "((ggdevt == 2) || (ggdevt == 3))"

    fitterPars.cuts = "(fit_status==0) " + "&& %s " % (jetCut) + "&& (W_mt > 30) "

    return fitterPars
def theConfig(Nj, mcdir = '', initFile = '', toydataFile = '', implementTTbarScaleMatchingSystOption = 0, e_minT = -1.0, e_maxT = -1.0):
    fitterPars = RooWjjFitterParams()

    fitterPars.smoothingOrder = 0
    fitterPars.MCDirectory = '/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree_AOD/RD_'
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = True
    fitterPars.QCDDirectory = fitterPars.MCDirectory[:-3]
    fitterPars.initParamsFile = initFile

    fitterPars.DataDirectory = fitterPars.MCDirectory
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = True
    fitterPars.electronData = 'WenuJets_DataAllSingleElectronTrigger_GoldenJSON_4p7invfb.root'
##     fitterPars.electronData = 'WenuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeElectrons = True

##     fitterPars.NewPhysicsDirectory = '/uscms_data/d2/kalanand/WjjTrees/ReducedTree/NewKfitRDTree/RD_'
    fitterPars.NewPhysicsDirectory = fitterPars.MCDirectory
    fitterPars.fitToyDataset = False
    fitterPars.ToyDatasetDirectory = '/uscms_data/d1/ilyao/KinematicFitterS11/ErrorScans/1KMCSets/'
    fitterPars.toydataFile = toydataFile
    fitterPars.implementTTbarScaleMatchingSystOption = implementTTbarScaleMatchingSystOption

    fitterPars.minMass = 30.
    fitterPars.maxMass = 400.
    fitterPars.nbins = 34
    fitterPars.intLumi = 5020.

    fitterPars.binEdges.push_back(fitterPars.minMass)

    binEdge = fitterPars.minMass
    print binEdge,' ',

## ### Scan between Min=120-140 (Max=160-180)
##     while (binEdge < 120.0):
##         binEdge += round(0.15*binEdge)
##         fitterPars.binEdges.push_back(binEdge)
##         print binEdge,' ',

##     binEdge=120;
##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = binEdge;
##     print 'replaced with ',binEdge,' '

##     while (binEdge < 140.0):
##         binEdge += 2.0
##         fitterPars.binEdges.push_back(binEdge)
##         print binEdge,' ',

##     binEdge=140;
##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = binEdge;
##     print 'replaced with ', binEdge,' ',

##     binEdge=160;
##     fitterPars.binEdges.push_back(binEdge)
##     print binEdge,' ',
    
##     while (binEdge < 182.0):
##         binEdge += 2.0
##         fitterPars.binEdges.push_back(binEdge)
##         print binEdge,' ',

##     binEdge=182;
##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = binEdge;
##     print 'replaced with ',binEdge,' ',
    
    while (binEdge <= fitterPars.maxMass):
        binEdge += round(0.15*binEdge)
        fitterPars.binEdges.push_back(binEdge)
        print binEdge,' ',




    fitterPars.binEdges[fitterPars.binEdges.size()-1] = fitterPars.maxMass
##     fitterPars.maxMass = fitterPars.binEdges[fitterPars.binEdges.size()-1]
    
    print "mass range:",fitterPars.minMass,'-',fitterPars.maxMass
    
    fitterPars.truncRange = True
    fitterPars.blind = False
    fitterPars.minTrunc = 130.
    if e_minT>0:
        fitterPars.minTrunc = e_minT

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 170.
    if e_maxT>0:
        fitterPars.maxTrunc = e_maxT
    
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = 60.
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = 400.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break

    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:',fitterPars.minFit,'-',fitterPars.maxFit

    fitterPars.njets = Nj
    fitterPars.constrainDiboson = True

    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back("EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back("EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    
    fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsSingleElectron.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/FullyEfficient_Jet2NoJet1.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    fitterPars.eleWMtEffFiles.push_back("EffTableDir/WMt50TriggerEfficiency.txt")
    fitterPars.lumiPerEpochElectron.push_back(fitterPars.intLumi)

##     fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
##     fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
##     fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_Ele.txt")
##     fitterPars.eleJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_post-epsCaloLWA.txt")
##     fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_post-epsCaloLWA.txt")
##     fitterPars.eleMHTEffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
##     fitterPars.lumiPerEpochElectron.push_back(3700)

    fitterPars.useExternalMorphingPars = False

    jetCut = '(evtNJ == %i)' % (Nj)
    if (Nj < 2):
        jetCut = '((evtNJ == 2) || (evtNJ == 3))'
       
    fitterPars.cuts = '(W_mt > 50.) ' + \
                      '&& %s ' % (jetCut) + \
                      '&& (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.2) ' + \
                      '&& (sqrt(JetPFCor_Pt[0]**2+JetPFCor_Pt[1]**2+2*JetPFCor_Pt[0]*JetPFCor_Pt[1]*cos(JetPFCor_Phi[0]-JetPFCor_Phi[1]))>45.) ' + \
                      '&& (JetPFCor_Pt[1]/Mass2j_PFCor>0.3) ' + \
                      '&& (JetPFCor_Pt[1]/Mass2j_PFCor<0.7) ' + \
                      '&& (JetPFCor_Pt[0] > 40) '

    return fitterPars
예제 #8
0
def theConfig(Nj, mcdir='', initFile='', btag=False, toydataFile=""):
    fitterPars = RooWjjFitterParams()
    fitterPars.smoothingOrder = 1
    # fitterPars.MCDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree_PAT/RD_"
    fitterPars.MCDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/OriginalTree_PAT/"
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = False
    ##fitterPars.QCDDirectory = fitterPars.MCDirectory[:-3]
    fitterPars.QCDDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree_PAT/"

    fitterPars.initParamsFile = initFile
    fitterPars.constraintParamsFile = initFile
    fitterPars.DataDirectory = fitterPars.MCDirectory
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = True
    fitterPars.electronData = 'WenuJets_DataAllSingleElectronTrigger_GoldenJSON_4p7invfb.root'
    fitterPars.includeElectrons = True
    fitterPars.NewPhysicsDirectory = fitterPars.MCDirectory
    fitterPars.toydataFile = toydataFile

    fitterPars.minMass = 40.
    fitterPars.maxMass = 150.
    fitterPars.nbins = 32
    fitterPars.intLumi = 5020.

    binEdge = fitterPars.minMass
    fitterPars.binEdges.push_back(binEdge)
    print binEdge, ' ',
    while (binEdge < fitterPars.maxMass):
        binEdge += round(0.10 * binEdge)
        fitterPars.binEdges.push_back(binEdge)
        print binEdge, ' ',

##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = fitterPars.maxMass
    fitterPars.maxMass = fitterPars.binEdges[fitterPars.binEdges.size() - 1]

    print "mass range:", fitterPars.minMass, '-', fitterPars.maxMass

    fitterPars.truncRange = False
    fitterPars.blind = False
    fitterPars.minTrunc = 65.

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 94.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = fitterPars.minMass
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = fitterPars.maxMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break

    fitterPars.minWmass = fitterPars.minTrunc
    fitterPars.maxWmass = fitterPars.maxTrunc

    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:', fitterPars.minFit, '-', fitterPars.maxFit

    fitterPars.njets = Nj
    fitterPars.constrainDiboson = False
    fitterPars.constrainDibosonShape = False
    fitterPars.constrainWpJShape = False
    fitterPars.constrainWpJ = True

    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back(
        "EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back(
        "EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    fitterPars.eleIdEffFiles.push_back(
        "EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back(
        "EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back(
        "EffTableDir/eleEffsSingleElectron.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back(
        "EffTableDir/FullyEfficient_Jet2NoJet1.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    fitterPars.eleWMtEffFiles.push_back(
        "EffTableDir/WMt50TriggerEfficiency.txt")
    fitterPars.lumiPerEpochElectron.push_back(fitterPars.intLumi)

    fitterPars.useExternalMorphingPars = False

    ##     jetCut = '(jetPFCor_Pt[%i] < 2) ' % (Nj)
    ##     for j in range(0, Nj):
    ##         jetCut += '&& (JetPFCor_Pt[%i] > 30) ' % (j)
    ##    jetCut = '(ggdevt == %i)' % (Nj)
    ##     if (Nj < 2):
    ##         jetCut = '((ggdevt == 2) || (ggdevt == 3))'

    btagCut = 1.74

    fitterPars.cuts = '(sqrt(JetPFCor_Pt[0]**2+JetPFCor_Pt[1]**2+2*JetPFCor_Pt[0]*JetPFCor_Pt[1]*cos(JetPFCor_Phi[0]-JetPFCor_Phi[1]))>20.) ' + \
                      '&& (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.5) ' + \
                      '&& (abs(JetPFCor_dphiMET[0])>0.4) '
    fitterPars.cuts += '&& (JetPFCor_Pt[2]<30) '
    #fitterPars.cuts += '&& (fit_status==0) '

    if btag:
        fitterPars.useWbbPDF = False
        fitterPars.cuts += '&& ( (JetPFCor_bDiscriminator[0]>%.2f) || (JetPFCor_bDiscriminator[1]>%.2f) ) ' % (
            btagCut, btagCut)
        fitterPars.cuts += '&& (JetPFCor_Pt[1]>35) '
    else:
        fitterPars.useWbbPDF = False
        fitterPars.cuts += '&& (JetPFCor_bDiscriminator[0]<%.2f) && (JetPFCor_bDiscriminator[1]<%.2f) ' % (
            btagCut, btagCut)
        fitterPars.cuts += '&& (JetPFCor_Pt[1]>35.) '

    return fitterPars
def theConfig(Nj,
              mcdir='',
              initFile='',
              toydataFile='',
              implementTTbarScaleMatchingSystOption=0,
              e_minT=-1.0,
              e_maxT=-1.0):
    fitterPars = RooWjjFitterParams()

    fitterPars.smoothingOrder = 0
    fitterPars.MCDirectory = '/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree_AOD/RD_'
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = True
    fitterPars.QCDDirectory = fitterPars.MCDirectory[:-3]
    fitterPars.initParamsFile = initFile

    fitterPars.DataDirectory = fitterPars.MCDirectory
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = True
    fitterPars.electronData = 'WenuJets_DataAllSingleElectronTrigger_GoldenJSON_4p7invfb.root'
    ##     fitterPars.electronData = 'WenuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeElectrons = True

    ##     fitterPars.NewPhysicsDirectory = '/uscms_data/d2/kalanand/WjjTrees/ReducedTree/NewKfitRDTree/RD_'
    fitterPars.NewPhysicsDirectory = fitterPars.MCDirectory
    fitterPars.fitToyDataset = False
    fitterPars.ToyDatasetDirectory = '/uscms_data/d1/ilyao/KinematicFitterS11/ErrorScans/1KMCSets/'
    fitterPars.toydataFile = toydataFile
    fitterPars.implementTTbarScaleMatchingSystOption = implementTTbarScaleMatchingSystOption

    fitterPars.minMass = 30.
    fitterPars.maxMass = 400.
    fitterPars.nbins = 34
    fitterPars.intLumi = 5020.

    fitterPars.binEdges.push_back(fitterPars.minMass)

    binEdge = fitterPars.minMass
    print binEdge, ' ',

    ## ### Scan between Min=120-140 (Max=160-180)
    ##     while (binEdge < 120.0):
    ##         binEdge += round(0.15*binEdge)
    ##         fitterPars.binEdges.push_back(binEdge)
    ##         print binEdge,' ',

    ##     binEdge=120;
    ##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = binEdge;
    ##     print 'replaced with ',binEdge,' '

    ##     while (binEdge < 140.0):
    ##         binEdge += 2.0
    ##         fitterPars.binEdges.push_back(binEdge)
    ##         print binEdge,' ',

    ##     binEdge=140;
    ##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = binEdge;
    ##     print 'replaced with ', binEdge,' ',

    ##     binEdge=160;
    ##     fitterPars.binEdges.push_back(binEdge)
    ##     print binEdge,' ',

    ##     while (binEdge < 182.0):
    ##         binEdge += 2.0
    ##         fitterPars.binEdges.push_back(binEdge)
    ##         print binEdge,' ',

    ##     binEdge=182;
    ##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = binEdge;
    ##     print 'replaced with ',binEdge,' ',

    while (binEdge <= fitterPars.maxMass):
        binEdge += round(0.15 * binEdge)
        fitterPars.binEdges.push_back(binEdge)
        print binEdge, ' ',

    fitterPars.binEdges[fitterPars.binEdges.size() - 1] = fitterPars.maxMass
    ##     fitterPars.maxMass = fitterPars.binEdges[fitterPars.binEdges.size()-1]

    print "mass range:", fitterPars.minMass, '-', fitterPars.maxMass

    fitterPars.truncRange = True
    fitterPars.blind = False
    fitterPars.minTrunc = 130.
    if e_minT > 0:
        fitterPars.minTrunc = e_minT

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 170.
    if e_maxT > 0:
        fitterPars.maxTrunc = e_maxT

    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = 60.
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = 400.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break

    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:', fitterPars.minFit, '-', fitterPars.maxFit

    fitterPars.njets = Nj
    fitterPars.constrainDiboson = True

    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back(
        "EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back(
        "EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    fitterPars.eleIdEffFiles.push_back(
        "EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back(
        "EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back(
        "EffTableDir/eleEffsSingleElectron.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back(
        "EffTableDir/FullyEfficient_Jet2NoJet1.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    fitterPars.eleWMtEffFiles.push_back(
        "EffTableDir/WMt50TriggerEfficiency.txt")
    fitterPars.lumiPerEpochElectron.push_back(fitterPars.intLumi)

    ##     fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    ##     fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    ##     fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_Ele.txt")
    ##     fitterPars.eleJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet30_FracLumi_post-epsCaloLWA.txt")
    ##     fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_Jet25Not30_FracLumi_post-epsCaloLWA.txt")
    ##     fitterPars.eleMHTEffFiles.push_back("EffTableDir/eleEffsHLTEle2jPfMht_data_LWA_PfMht.txt")
    ##     fitterPars.lumiPerEpochElectron.push_back(3700)

    fitterPars.useExternalMorphingPars = False

    jetCut = '(evtNJ == %i)' % (Nj)
    if (Nj < 2):
        jetCut = '((evtNJ == 2) || (evtNJ == 3))'

    fitterPars.cuts = '(W_mt > 50.) ' + \
                      '&& %s ' % (jetCut) + \
                      '&& (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.2) ' + \
                      '&& (sqrt(JetPFCor_Pt[0]**2+JetPFCor_Pt[1]**2+2*JetPFCor_Pt[0]*JetPFCor_Pt[1]*cos(JetPFCor_Phi[0]-JetPFCor_Phi[1]))>45.) ' + \
                      '&& (JetPFCor_Pt[1]/Mass2j_PFCor>0.3) ' + \
                      '&& (JetPFCor_Pt[1]/Mass2j_PFCor<0.7) ' + \
                      '&& (JetPFCor_Pt[0] > 40) '

    return fitterPars
def theConfig(Nj, mcdir = '', initFile = ''):
    fitterPars = RooWjjFitterParams()
    fitterPars.smoothingOrder = 1
    fitterPars.MCDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree_VBF/RD_"
##     fitterPars.WpJDirectory = str(fitterPars.MCDirectory).replace("PAT", "AOD")
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = False
    fitterPars.QCDDirectory = fitterPars.MCDirectory[:-3]
    fitterPars.initParamsFile = initFile
    fitterPars.constraintParamsFile = initFile;
    fitterPars.DataDirectory = fitterPars.MCDirectory
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = True    
    fitterPars.electronData = 'WenuJets_DataAllSingleElectronTrigger_GoldenJSON_4p7invfb.root'
    fitterPars.includeElectrons = True
    fitterPars.overwriteDibosonPDFWithVBFWW = True
    
    fitterPars.NewPhysicsDirectory = fitterPars.MCDirectory
    fitterPars.minMass = 40.
    fitterPars.maxMass = 200.
    fitterPars.nbins = 30
    fitterPars.intLumi = 5020.
    
    fitterPars.binEdges.push_back(fitterPars.minMass)
    #fitterPars.binEdges.push_back(40.)
    fitterPars.binEdges.push_back(45.)
    fitterPars.binEdges.push_back(50.)
    fitterPars.binEdges.push_back(55.)
    fitterPars.binEdges.push_back(60.)
    fitterPars.binEdges.push_back(65.)
    fitterPars.binEdges.push_back(70.)
    fitterPars.binEdges.push_back(75.)
    fitterPars.binEdges.push_back(80.)
    fitterPars.binEdges.push_back(85.)
    fitterPars.binEdges.push_back(95.)
    fitterPars.binEdges.push_back(105.)
    fitterPars.binEdges.push_back(115.)
    fitterPars.binEdges.push_back(125.)
    fitterPars.binEdges.push_back(135.)
    fitterPars.binEdges.push_back(145.)
    fitterPars.binEdges.push_back(160.)
    fitterPars.binEdges.push_back(175.)
    fitterPars.binEdges.push_back(200.)

##     binEdge = fitterPars.minMass
##     print binEdge,' ',
##     while (binEdge <= fitterPars.maxMass):
##         binEdge += round(0.14*binEdge)
##         fitterPars.binEdges.push_back(binEdge)
##         print binEdge,' ',

##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = fitterPars.maxMass

    print "mass range:",fitterPars.minMass,'-',fitterPars.maxMass
    
    fitterPars.truncRange = True
    fitterPars.blind = False
    fitterPars.minTrunc = 65.

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 94.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = fitterPars.minMass
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = fitterPars.maxMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break


    fitterPars.minWmass = fitterPars.minTrunc
    fitterPars.maxWmass = fitterPars.maxTrunc
    
    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:',fitterPars.minFit,'-',fitterPars.maxFit
    
    fitterPars.njets = Nj
    fitterPars.constrainDiboson = True

    
    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back("EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back("EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    
    fitterPars.eleIdEffFiles.push_back("EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back("EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back("EffTableDir/eleEffsSingleElectron.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back("EffTableDir/FullyEfficient_Jet2NoJet1.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    fitterPars.eleWMtEffFiles.push_back("EffTableDir/WMt50TriggerEfficiency.txt")
    fitterPars.lumiPerEpochElectron.push_back(fitterPars.intLumi)

    fitterPars.constrainDiboson = True
    fitterPars.useExternalMorphingPars = False

    fitterPars.var = "vbf_wjj_m"

    fitterPars.cuts = '(vbf_event==1) ' + \
        '&& (JetPFCor_bDiscriminator[vbf_waj_id] < 1.74) ' + \
        '&& (JetPFCor_bDiscriminator[vbf_wbj_id] < 1.74) ' + \
        '&& (vbf_lvjj_m > %0.1f) && (vbf_lvjj_m < %0.1f) ' % \
        (minMlvjj, maxMlvjj)

    return fitterPars
def theConfig(Nj, mcdir='', initFile=''):
    fitterPars = RooWjjFitterParams()
    fitterPars.smoothingOrder = 1
    fitterPars.MCDirectory = "/uscms_data/d2/kalanand/WjjTrees/Full2011DataFall11MC/ReducedTree_VBF/RD_"
    ##     fitterPars.WpJDirectory = str(fitterPars.MCDirectory).replace("PAT", "AOD")
    fitterPars.WpJDirectory = fitterPars.MCDirectory
    if (len(mcdir) > 0):
        fitterPars.WpJDirectory = mcdir
        fitterPars.toyWpJ = False
    fitterPars.QCDDirectory = fitterPars.MCDirectory[:-3]
    fitterPars.initParamsFile = initFile
    fitterPars.constraintParamsFile = initFile
    fitterPars.DataDirectory = fitterPars.MCDirectory
    fitterPars.muonData = 'WmunuJets_DataAll_GoldenJSON_4p7invfb.root'
    fitterPars.includeMuons = True
    fitterPars.electronData = 'WenuJets_DataAllSingleElectronTrigger_GoldenJSON_4p7invfb.root'
    fitterPars.includeElectrons = True
    fitterPars.overwriteDibosonPDFWithVBFWW = True

    fitterPars.NewPhysicsDirectory = fitterPars.MCDirectory
    fitterPars.minMass = 40.
    fitterPars.maxMass = 200.
    fitterPars.nbins = 30
    fitterPars.intLumi = 5020.

    fitterPars.binEdges.push_back(fitterPars.minMass)
    #fitterPars.binEdges.push_back(40.)
    fitterPars.binEdges.push_back(45.)
    fitterPars.binEdges.push_back(50.)
    fitterPars.binEdges.push_back(55.)
    fitterPars.binEdges.push_back(60.)
    fitterPars.binEdges.push_back(65.)
    fitterPars.binEdges.push_back(70.)
    fitterPars.binEdges.push_back(75.)
    fitterPars.binEdges.push_back(80.)
    fitterPars.binEdges.push_back(85.)
    fitterPars.binEdges.push_back(95.)
    fitterPars.binEdges.push_back(105.)
    fitterPars.binEdges.push_back(115.)
    fitterPars.binEdges.push_back(125.)
    fitterPars.binEdges.push_back(135.)
    fitterPars.binEdges.push_back(145.)
    fitterPars.binEdges.push_back(160.)
    fitterPars.binEdges.push_back(175.)
    fitterPars.binEdges.push_back(200.)

    ##     binEdge = fitterPars.minMass
    ##     print binEdge,' ',
    ##     while (binEdge <= fitterPars.maxMass):
    ##         binEdge += round(0.14*binEdge)
    ##         fitterPars.binEdges.push_back(binEdge)
    ##         print binEdge,' ',

    ##     fitterPars.binEdges[fitterPars.binEdges.size()-1] = fitterPars.maxMass

    print "mass range:", fitterPars.minMass, '-', fitterPars.maxMass

    fitterPars.truncRange = True
    fitterPars.blind = False
    fitterPars.minTrunc = 65.

    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minTrunc:
            fitterPars.minTrunc = binMin
            break
        binMin = binEdge

    fitterPars.maxTrunc = 94.
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxTrunc:
            fitterPars.maxTrunc = binEdge
            break

    fitterPars.minFit = fitterPars.minMass
    binMin = fitterPars.minMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.minFit:
            fitterPars.minFit = binMin
            break
        binMin = binEdge

    fitterPars.maxFit = fitterPars.maxMass
    for binEdge in fitterPars.binEdges:
        if binEdge > fitterPars.maxFit:
            fitterPars.maxFit = binEdge
            break

    fitterPars.minWmass = fitterPars.minTrunc
    fitterPars.maxWmass = fitterPars.maxTrunc

    print 'truncate:',fitterPars.truncRange,':', fitterPars.minTrunc,'-',\
          fitterPars.maxTrunc
    print 'fit range:', fitterPars.minFit, '-', fitterPars.maxFit

    fitterPars.njets = Nj
    fitterPars.constrainDiboson = True

    fitterPars.doEffCorrections = True
    fitterPars.muIdEffFiles.push_back(
        "EffTableDir/muonEffsRecoToIso_ScaleFactors.txt")
    fitterPars.muHLTEffFiles.push_back(
        "EffTableDir/muonEffsIsoToHLT_data_LP_LWA.txt")
    fitterPars.lumiPerEpochMuon.push_back(fitterPars.intLumi)

    fitterPars.eleIdEffFiles.push_back(
        "EffTableDir/eleEffsRecoToWP80_ScaleFactors.txt")
    fitterPars.eleRecoEffFiles.push_back(
        "EffTableDir/eleEffsSCToReco_ScaleFactors.txt")
    fitterPars.eleHLTEffFiles.push_back(
        "EffTableDir/eleEffsSingleElectron.txt")
    fitterPars.eleJ30EffFiles.push_back("EffTableDir/FullyEfficient.txt")
    fitterPars.eleJ25NoJ30EffFiles.push_back(
        "EffTableDir/FullyEfficient_Jet2NoJet1.txt")
    fitterPars.eleMHTEffFiles.push_back("EffTableDir/FullyEfficient_MHT.txt")
    fitterPars.eleWMtEffFiles.push_back(
        "EffTableDir/WMt50TriggerEfficiency.txt")
    fitterPars.lumiPerEpochElectron.push_back(fitterPars.intLumi)

    fitterPars.constrainDiboson = True
    fitterPars.useExternalMorphingPars = False

    fitterPars.var = "vbf_wjj_m"

    fitterPars.cuts = '(vbf_event==1) ' + \
        '&& (JetPFCor_bDiscriminator[vbf_waj_id] < 1.74) ' + \
        '&& (JetPFCor_bDiscriminator[vbf_wbj_id] < 1.74) ' + \
        '&& (vbf_lvjj_m > %0.1f) && (vbf_lvjj_m < %0.1f) ' % \
        (minMlvjj, maxMlvjj)

    return fitterPars