示例#1
0
def LoadCfgToRun(inputFile=None):

    #this takes care of converting the input files from CRAB
    if not inputFile:
        from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles, runsAndLumis

    sampoptjson = open('options_sample.json', 'r')
    sampOpt = json.loads(sampoptjson.read())
    sampoptjson.close()

    skimRecoLeps = SkimRecoLeps(sampOpt['isData'] == True, nMinLeps=2)
    mod = [
        puAutoWeight, goodLepProducer, skimRecoLeps, isoTrackAnalysis,
        edgeFriends
    ]
    if sampOpt['isData']:
        mod.remove(puAutoWeight)
    else:
        from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetUncertainties import jetmetUncertainties2017All, jetmetUncertainties2017
        jmeUncert = jetmetUncertainties2017()
        jmeUncert.metBranchName = 'METFixEE2017'
        mod.extend([jmeUncert])  # jetmetUncertainties2017All()

    if 'triggers' in sampOpt:
        if not 'vetotriggers' in sampOpt:
            raise RuntimeError(
                '[%s]: You have specified trigger requierments, but not veto triggers. Please include them (can be an empty list)'
            )
        triggerBitFilter = TriggerBitFilter(
            triggers=sampOpt['triggers'], vetotriggers=sampOpt['vetotriggers'])
        mod = [triggerBitFilter] + mod

    jsonInput = sampOpt['json'] if 'json' in sampOpt else runsAndLumis()
    POSTPROCESSOR = PostProcessor(".",
                                  inputFile if inputFile else inputFiles(),
                                  cut,
                                  inputSlim,
                                  mod,
                                  provenance=True,
                                  fwkJobReport=True,
                                  jsonInput=jsonInput,
                                  outputbranchsel=outputSlim)

    return POSTPROCESSOR
示例#2
0
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import PostProcessor

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis
from PhysicsTools.NanoAODTools.postprocessing.analysis.nanoAOD_vvVBS.wvAnalysisModule import wvAnalysisModule

from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetHelperRun2 import *

testfile = "root://cms-xrd-global.cern.ch//store/mc/RunIIFall17NanoAODv7/WJetsToLNu_TuneCP5_13TeV-amcatnloFXFX-pythia8/NANOAODSIM/PU2017_12Apr2018_Nano02Apr2020_102X_mc2017_realistic_v8-v1/270000/0E62152C-8DC8-B940-B84F-21F4296AD5CC.root"

p=PostProcessor(".",inputFiles(),"","keep_and_drop_MC.txt",modules=[wvAnalysisModule()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
#p=PostProcessor(".",[testfile],"","keep_and_drop_MC.txt",modules=[wvAnalysisModule()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())

p.run()

print "DONE"
示例#3
0
Log        = {cd}/log_condor_{dm}{rp}_chunk{ch}.log
Output     = {cd}/log_condor_{dm}{rp}_chunk{ch}.out
Error      = {cd}/log_condor_{dm}{rp}_chunk{ch}.error\n'''.format(
            cd=args.condorDir, ch=il, dm=dm, rp=runperiod))
        tmp_condor.write('queue 1\n\n')
    tmp_condor.close()

    print 'condor submission file made:', tmp_condor_filename
    if args.executeCondor:
        print("Executing condor submission file")
        xcmd = "condor_submit " + tmp_condor_filename
        os.system(xcmd)

else:
    p = PostProcessor(outputDir=outDir,
                      inputFiles=(input_files if crab == 0 else inputFiles()),
                      cut=treecut,
                      modules=modules,
                      provenance=True,
                      outputbranchsel=kd_file,
                      maxEntries=maxEvents if maxEvents > 0 else None,
                      fwkJobReport=(False if crab == 0 else True),
                      jsonInput=(None if crab == 0 else runsAndLumis()),
                      compression=args.compression,
                      saveHistoGenWeights=(True if isMC else False),
                      allowNoPostfix=args.noPostfixSkim)
    p.run()

print "DONE"
#os.system("ls -lR")
示例#4
0
mhtVHbb = lambda : mhtProducer( lambda j : j.pt > 30,
                            lambda mu : mu.pt > 5 and mu.pfRelIso04_all < 0.4,
                            lambda el : el.pt > 5 and el.pfRelIso03_all < 0.4 )

#p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jetmetUncertainties(),vhbb()],provenance=True)
##p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jecUncertAll_cppOut(),jetmetUncertainties(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jecUncertAll_cppOut(),jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p.run()

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

if isMC:
    if era == "2016":
        p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[puWeight(),jetmetUncertainties2016All(),jetmetUncertainties2016AK8PuppiAllNoGroom(),muonScaleRes2016(),mhtVHbb(),btagSFProducer("2016","cmva"),vhbb2016()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
    elif era == "2017":
        p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",[puAutoWeight(),jetmetUncertainties2017All(),jetmetUncertainties2017AK8PuppiAll(),muonScaleRes2017(),mhtVHbb(),btagSFProducer("2017","deepcsv"),vhbb2017()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
else:
    if era == "2016":
        p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[muonScaleRes2016(),mhtVHbb(),vhbb2016_data()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
    elif era == "2017":
        if dataRun == "B":
            p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[jetRecalib2017B(),muonScaleRes2017(),mhtVHbb(),vhbb2017_data()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
        if dataRun == "C":
            p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[jetRecalib2017C(),muonScaleRes2017(),mhtVHbb(),vhbb2017_data()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
        if dataRun == "D":
            p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[jetRecalib2017D(),muonScaleRes2017(),mhtVHbb(),vhbb2017_data()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
        if dataRun == "E":
            p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[jetRecalib2017E(),muonScaleRes2017(),mhtVHbb(),vhbb2017_data()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
        if dataRun == "F":
示例#5
0
#!/usr/bin/env python
import os, sys
import ROOT
ROOT.PyConfig.IgnoreCommandLineOptions = True
from importlib import import_module
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import PostProcessor

from wgModule import *
from wgFiducialModule import *
from wgFilterModule import *
from countHistogramsFiducialModule import *

from PhysicsTools.NanoAODTools.postprocessing.modules.common.countHistogramsModule import *
from PhysicsTools.NanoAODTools.postprocessing.modules.common.PrefireCorr import *
from PhysicsTools.NanoAODTools.postprocessing.modules.common.puWeightProducer import *

from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

#p=PostProcessor(".",inputFiles(),None,"wg_keep_and_drop.txt",[countHistogramsModule(),wgModule(),wgFilterModule()],provenance=True,justcount=False,fwkJobReport=True,jsonInput=runsAndLumis(),noOut=False,outputbranchsel = "wg_output_branch_selection.txt")

p=PostProcessor(".",inputFiles(),None,"wg_keep_and_drop.txt",[countHistogramsModule(),wgModule(),wgFilterModule(),puWeight_2016(),PrefCorr()],provenance=True,justcount=False,fwkJobReport=True,jsonInput=runsAndLumis(),noOut=False,outputbranchsel = "wg_output_branch_selection.txt")

#p=PostProcessor(".",inputFiles(),None,"wg_keep_and_drop.txt",[countHistogramsModule(),wgFiducialModule(),countHistogramsFiducialModule(),wgModule(),wgFilterModule(),puWeight_2016(),PrefCorr()],provenance=True,justcount=False,fwkJobReport=True,jsonInput=runsAndLumis(),noOut=False,outputbranchsel = "wg_output_branch_selection.txt")

p.run()

print "DONE"



    infilelist = []
    jsoninput = None
    fwkjobreport = False

    if args.mode == 'condor':
        import DAS_filesearch as search
        infilelist.append(search.getValidSite(args.file)+args.file) 
    else:
        infilelist = [args.file]

else:

    from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis
    infilelist = inputFiles()
    jsoninput = runsAndLumis()
    fwkjobreport = True

if args.isdata and args.year=='2018' and args.period=='D' and ('MuonEG' in infilelist):
    print 'special treatment for MuonEG_Run2018D'
    import FWCore.PythonUtilities.LumiList as LumiList
    import FWCore.ParameterSet.Config as cms

    lumisToProcess = cms.untracked.VLuminosityBlockRange( LumiList.LumiList(filename="./Cert_314472-325175_13TeV_Legacy2018_Collisions18_JSON.txt").getCMSSWString().split(',') )
    # print lumisToProcess

    runsAndLumis_special = {}
    for l in lumisToProcess:
        if "-" in l:
            start, stop = l.split("-")
            rstart, lstart = start.split(":")
示例#7
0
    puFileData = None
    puFileMC = None

  if options.doLocal:
    print 'Running in local'
    from unitTestFiles import f
    sampleName = 'test' # please do not change
    files = ['root://cms-xrd-global.cern.ch/' + f[options.year][options.what] ]
    #files = ['/work/mratti/nanoaod_workarea/nano_making/CMSSW_10_2_9/src/test_for_mini_comparison_2016/SUS-RunIISummer16NanoAODv4-00181.root']
  else:
    print 'Running on the grid'
    dofwkJobReport = True
    haddFileName = 'mt2.root'
    import PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper as CH # inputFiles,runsAndLumis
    if not options.doMC and not options.doSkipJSON:
      jsonInput = CH.runsAndLumis()
    #this takes care of converting the input files from CRAB
    files = CH.inputFiles() # it is aweful that the input files are obtained in a such a confused way, but crab doesn't seem to support anything better than that!
    sampleName = getSampleName(files=files, isMC=options.doMC) # This is really poor, but CMS hasn't thought of any sample handler, which is a bit of a shame
    print 'Sample name figured from files', sampleName

  ## Modules to be run
  from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import PostProcessor
  #from PhysicsTools.NanoAODTools.postprocessing.examples.mhtjuProducerCpp import mhtjuProducerCpp
  from PhysicsTools.NanoAODTools.postprocessing.modules.common.lepSFProducer import lepSFProducer
  from PhysicsTools.NanoAODTools.postprocessing.modules.btv.btagSFProducer import btagSFProducer
  from PhysicsTools.NanoAODTools.postprocessing.modules.common.puWeightProducer import puWeightProducer
  from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetUncertainties import *
  from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetRecalib import jetRecalib
  #from PhysicsTools.NanoAODTools.postprocessing.modules.jme.JetReCalibrator import JetReCalibrator
  from PhysicsTools.NanoAODTools.postprocessing.analysis.mt2.mt2VarsProducer import mt2VarsProducer
        jmeUncert = jetmetUncertaintiesFast2016()
        jmeUncert.metBranchName = 'MET'
        mod.extend([jmeUncert])

        ## add xsec branch
        addFlags = AddFlags([(('xsec', 'F'), lambda ev: sampOpt['xsec'])])
        mod.extend([addFlags])

    if 'triggers' in sampOpt:
        if not 'vetotriggers' in sampOpt:
            raise RuntimeError(
                '[%s]: You have specified trigger requirements, but not veto triggers. Please include them (can be an empty list)'
            )
        triggerBitFilter = TriggerBitFilter(
            triggers=sampOpt['triggers'], vetotriggers=sampOpt['vetotriggers'])
        mod = [triggerBitFilter] + mod

    jsonInput = sampOpt['json'] if 'json' in sampOpt else runsAndLumis()
    POSTPROCESSOR = PostProcessor(
        ".",
        inputFiles() if 'IS_CRAB' in os.environ else [],
        cut,
        inputSlim,
        mod,
        provenance=True,
        fwkJobReport=True,
        jsonInput=jsonInput,
        outputbranchsel=outputSlim,
        SMSMasses=[sampOpt["LSPID"], sampOpt["NLSPID1"]],
        doISR=[sampOpt["NLSPID1"], sampOpt["NLSPID2"]])
示例#9
0
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import * 

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

from PhysicsTools.NanoAODTools.postprocessing.corrections.getBTagHist import *


p=PostProcessor(".",inputFiles(),cut=None,branchsel=None,modules=[getBTagHist2018_DeepCSV()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis(),noOut=False,outputbranchsel="keep_and_dropBTag_out.txt",histFileName="hist.root",histDirName="ttbar")
p.run()

print "DONE"
os.system("ls -lR")
示例#10
0
#!/usr/bin/env python
import os, sys
import ROOT
ROOT.PyConfig.IgnoreCommandLineOptions = True
from importlib import import_module
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import PostProcessor

from  ewkzgjjModule import *

from  countHistogramsModule import *

from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

p=PostProcessor(".",inputFiles(),None,"ewkzgjj_keep_and_drop.txt",[countHistogramsModule(),ewkzgjjModule()],provenance=True,justcount=False,fwkJobReport=True,jsonInput=runsAndLumis(),noOut=False,outputbranchsel = "ewkzgjj_output_branch_selection.txt")

#p=PostProcessor(".",["root://cms-xrd-global.cern.ch//store/data/Run2017B/DoubleEG/NANOAOD/Nano14Dec2018-v1/10000/FC0F0BE5-5D07-9C4A-B1FB-EDE0BCE0B842.root"],None,"ewkzgjj_keep_and_drop.txt",[countHistogramsModule(),ewkzgjjModule()],provenance=True,justcount=False,noOut=False,outputbranchsel = "ewkzgjj_output_branch_selection.txt")

#p=PostProcessor(".",["root://cms-xrd-global.cern.ch//store/mc/RunIIFall17NanoAODv4/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/NANOAODSIM/PU2017_12Apr2018_Nano14Dec2018_102X_mc2017_realistic_v6-v3/40000/48BB36BB-5DAF-A645-B86C-0A0E6A2A75FE.root"],"event == 10000794","ewkzgjj_keep_and_drop.txt",[countHistogramsModule(),ewkzgjjModule()],provenance=True,justcount=False,noOut=False,outputbranchsel = "ewkzgjj_output_branch_selection.txt")

#p=PostProcessor(".",["root://cms-xrd-global.cern.ch//store/mc/RunIIFall17NanoAODv4/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/NANOAODSIM/PU2017_12Apr2018_Nano14Dec2018_102X_mc2017_realistic_v6-v3/260000/05CC0B0B-8D53-1941-9804-072BC83F2439.root"],"event == 49051079","ewkzgjj_keep_and_drop.txt",[countHistogramsModule(),ewkzgjjModule()],provenance=True,justcount=False,noOut=False,outputbranchsel = "ewkzgjj_output_branch_selection.txt")

p.run()
示例#11
0
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import PostProcessor

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis
from PhysicsTools.NanoAODTools.postprocessing.analysis.nanoAOD_vvVBS.wvAnalysisModule import wvAnalysisModule

from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetHelperRun2 import *

jetmetCorrector = createJMECorrector(isMC=True, dataYear=2018, jesUncert="All", redojec=True, jetType = "AK4PFchs")
fatJetCorrector = createJMECorrector(isMC=True, dataYear=2018, jesUncert="All", redojec=True, jetType = "AK8PFPuppi")


p=PostProcessor(".",inputFiles(),"","keep_and_drop.txt",modules=[jetmetCorrector(),fatJetCorrector(),wvAnalysisModule()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())

p.run()

print "DONE"
示例#12
0
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import * 

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

from  PhysicsTools.NanoAODTools.postprocessing.examples.mhtProducer import *
p=PostProcessor(".",inputFiles(),"Jet_pt>200",modules=[mht()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
p.run()

print "DONE"
os.system("ls -lR")

示例#13
0
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import * 

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

from PhysicsTools.NanoAODTools.postprocessing.analysis.ModuleCommon import *

p=PostProcessor(".",inputFiles(),cut=None,branchsel="keep_and_dropCount_out.txt",modules=[countEvents()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis(),noOut=False,outputbranchsel="keep_and_dropCount_out.txt")
p.run()

print "DONE"
os.system("ls -lR")
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import * 
from VBFHToInv.NanoAODTools.postprocessing.VBFHToInvModules import *

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

p=PostProcessor(".",inputFiles(),"",modules=[JetCleaningConstructor(),MetCleaningConstructor()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
p.run()

print "DONE"
os.system("ls -lR")

示例#15
0
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import * 

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

#from  PhysicsTools.NanoAODTools.postprocessing.examples.exampleModule import *
from  tthAnalysis.NanoAODTools.postprocessing.tthModules import *
p=PostProcessor(".",inputFiles(),"",modules=[@MODULES],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
p.run()
print "DONE"
os.system("ls -lR")

import os, sys
#import ROOT
#ROOT.PyConfig.IgnoreCommandLineOptions = True
from importlib import import_module
#from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import *
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import PostProcessor
from PhysicsTools.NanoAODTools.postprocessing.framework.datamodel import Collection
from PhysicsTools.NanoAODTools.postprocessing.framework.eventloop import Module
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis
#from PhysicsTools.NanoAODTools.postprocessing.examples.skimmer import jetskimmer                        #local
from PhysicsTools.NanoAODTools.postprocessing.examples.skimmer import *                                  #crab
#from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetUncertainties import *
#from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetHelperRun2 import *

name= 'JetCharge_skimmer'


#p=PostProcessor(".",files,"Jet_pt>400","keep_and_drop.txt", modules=[jmeCorrections2018C_DATA_AK4CHS(), jetskimmer()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
#p=PostProcessor(".",files,"Jet_pt>30", modules=[jmeCorrections2018_MC_AK4CHS(), MCeventselectionTest()],)
#p=PostProcessor(".",inputFiles(),"Jet_pt>30","keep_and_drop.txt", modules=[jmeCorrections2018A_DATA_AK4CHS(), jetskimmer()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())

## DATA ##
p=PostProcessor(".",inputFiles(),"Jet_pt>0","keep_and_drop.txt", modules=[jetskimmer()],provenance=True,fwkJobReport=True,histFileName= name +'-histOut_DATA.root',histDirName="JetCharge_2017",haddFileName = name +'-trees.root',jsonInput=runsAndLumis(),outputbranchsel='output_tree.txt')

## MC ##
#p=PostProcessor(".",inputFiles(),"Jet_pt>0","keep_and_drop.txt", modules=[jetskimmer()],provenance=True,fwkJobReport=True,histFileName= name +'-histOut_MC.root',histDirName="JetCharge_2017",haddFileName = name +'-trees.root',jsonInput=runsAndLumis(),outputbranchsel='output_tree.txt')

p.run()
print "Done"
#os.system("ls -lR")       
selectionALL='''Sum$(Electron_pt > 20 && Electron_mvaSpring16GP_WP90) >= 2  ||
 Sum$(Electron_pt > 20 && Electron_mvaSpring16GP_WP80) >= 1   ||
 Sum$(Jet_pt > 40 && Jet_jetId) >= 4   || 
Sum$(Jet_pt *(abs(Jet_eta)<2.5 && Jet_pt > 20 && Jet_jetId)) > 160  || 
MET_pt > 100  || Sum$(Muon_pt > 20 && Muon_tightId) >= 1
'''
mhtVHbb = lambda : mhtProducer( lambda j : j.pt > 30,
                            lambda mu : mu.pt > 5 and mu.pfRelIso04_all < 0.4,
                            lambda el : el.pt > 5 and el.pfRelIso03_all < 0.4 )

#p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jetmetUncertainties(),vhbb()],provenance=True)
##p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jecUncertAll_cppOut(),jetmetUncertainties(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jecUncertAll_cppOut(),jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p.run()

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[puWeight(),jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True,fwkJobReport=True)
#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[puWeight(),jetmetUncertaintiesAll(),mhtVHbb(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[puWeight(),jetmetUncertaintiesAll(),mhtVHbb(),btagSFProducer("cmva"),vhbb()],provenance=True,jsonInput=runsAndLumis())
p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[mhtVHbb(),vhbb2017_data()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[jetmetUncertaintiesAll(),mht(),btagSFProducer("cmva"),vhbb()],provenance=True,fwkJobReport=True)
#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
p.run()

print "DONE"
os.system("ls -lR")
示例#18
0
doTnP = 'TnP' in sys.argv[-1]
doJECunc = 'JEC' in sys.argv[-1]
doMuonScale = 'muScale' in sys.argv[-1]
doJECunc = True
doMuonScale = True
doElecScale = True
if '18' in sys.argv[-1]: year = 18
elif '16' in sys.argv[-1]: year = 16
elif '5' in sys.argv[-1]: year = 5
else: year = 17
era = '' if not 'era' in sys.argv[-1] else sys.argv[-1][
    sys.argv[-1].find('era') + 3:sys.argv[-1].find('era') + 4]
if era != '': print '>Found era: ', era

### Json file
jsonfile = runsAndLumis()
#if isData:
#  if     year == 18: jsonfile = 'Cert_314472-322057_13TeV_PromptReco_Collisions18_JSON.txt'
#  elif   year == 17: jsonfile = 'Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt'
#  elif   year == 16: jsonfile = 'Cert_271036-284044_13TeV_23Sep2016ReReco_Collisions16_JSON.txt'

mod = []
jecfile = ''
if not isData:
    if year == 16:
        mod.append(puWeight_2016())
        mod.append(PrefCorr2016())
    elif year == 17:
        mod.append(puWeight_2017())  # puAutoWeight_2017
        mod.append(PrefCorr2017())
    elif year == 18:
示例#19
0
#!/usr/bin/env python
import os, sys
import ROOT
ROOT.PyConfig.IgnoreCommandLineOptions = True
from importlib import import_module
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import PostProcessor

from  wgFakeLeptonModule import *

from PhysicsTools.NanoAODTools.postprocessing.modules.common.countHistogramsModule import *
from PhysicsTools.NanoAODTools.postprocessing.modules.common.PrefireCorr import *
from PhysicsTools.NanoAODTools.postprocessing.modules.common.puWeightProducer import *

from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

p=PostProcessor(".",inputFiles(),None,"wg_fake_lepton_keep_and_drop.txt",[countHistogramsModule(),wgFakeLeptonModule()],provenance=True,justcount=False,noOut=False,fwkJobReport=True, jsonInput=runsAndLumis(), outputbranchsel = "wg_fake_lepton_output_branch_selection.txt")

#p=PostProcessor(".",inputFiles(),None,"wg_fake_lepton_keep_and_drop.txt",[countHistogramsModule(),wgFakeLeptonModule(),puWeight_2017(),PrefCorr()],provenance=True,justcount=False,noOut=False,fwkJobReport=True, jsonInput=runsAndLumis(), outputbranchsel = "wg_fake_lepton_output_branch_selection.txt")

p.run()

print "DONE"
示例#20
0
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import * 

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

from PhysicsTools.NanoAODTools.postprocessing.analysis.ModuleCommon import *
#from PhysicsTools.NanoAODTools.postprocessing.corrections.getBTagHist import *

#jsonFile = "Cert_271036-284044_13TeV_23Sep2016ReReco_Collisions16_JSON.txt" 
#jsonFile = "Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON_v1.txt"
#jsonFile = "Cert_314472-325175_13TeV_17SeptEarlyReReco2018ABC_PromptEraD_Collisions18_JSON.txt"

p=PostProcessor(".",inputFiles(),cut=None,branchsel=None,modules=[jetmetCorrectorUL2018MC(),analyzeUL2018MC_Skim()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis(),noOut=False,outputbranchsel="keep_and_dropSR_out.txt")
#p=PostProcessor(".",inputFiles(),cut=None,branchsel=None,modules=[jetmetCorrector2016DataH(),analyze2016Data_Skim()],provenance=True,fwkJobReport=True,jsonInput=jsonFile,noOut=False,outputbranchsel="keep_and_dropSR_out.txt")
#p=PostProcessor(".",inputFiles(),cut=None,branchsel=None,modules=[getBTagHist2018_DeepCSV()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis(),noOut=False,outputbranchsel="keep_and_dropBTag_out.txt",histFileName="hist.root",histDirName="ttbar")
p.run()

print "DONE"
os.system("ls -lR")
示例#21
0
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import * 

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles,runsAndLumis

#Module
from PhysicsTools.NanoAODTools.analysis.Producer import producer
from PhysicsTools.NanoAODTools.postprocessing.modules.common.puWeightProducer import puWeight

preselection="( (Muon_pt[0]>5 && Muon_mediumId[0]>0) || (Electron_pt[0]>15 && Electron_cutBased[0]>0) ) || ( (Muon_pt[0]>5 && Muon_mediumId[0]>0) && (Electron_pt[0]>15 && Electron_cutBased[0]>0) )"
bIn="keep_and_drop_Input.txt"
bOut="keep_and_drop_Output.txt"
Nevent=-1

p=PostProcessor( "." , inputFiles() , cut=preselection , branchsel=bIn , modules=[ puWeight(), producer() ] , maxevent=Nevent , provenance=False , fwkJobReport=True , jsonInput=runsAndLumis() , outputbranchsel=bOut )
p.run()

print "DONE"
os.system("ls -lR")

示例#22
0
mhtVHbb = lambda: mhtProducer(lambda j: j.pt > 30, lambda mu: mu.pt > 5 and mu.
                              pfRelIso04_all < 0.4, lambda el: el.pt > 5 and el
                              .pfRelIso03_all < 0.4)

#p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jetmetUncertainties(),vhbb()],provenance=True)
##p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jecUncertAll_cppOut(),jetmetUncertainties(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p=PostProcessor(".",files,selection.replace('\n',' '),"keep_and_drop.txt",[jecUncertAll_cppOut(),jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p.run()

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles, runsAndLumis

#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[puWeight(),jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True,fwkJobReport=True)
#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[puWeight(),jetmetUncertaintiesAll(),mhtVHbb(),btagSFProducer("cmva"),vhbb()],provenance=True)
#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[puWeight(),jetmetUncertaintiesAll(),mhtVHbb(),btagSFProducer("cmva"),vhbb()],provenance=True,jsonInput=runsAndLumis())
p = PostProcessor(".",
                  inputFiles(),
                  selection.replace('\n', ' '),
                  "keep_and_drop.txt",
                  modules=[mhtVHbb(), vhbb_data()],
                  provenance=True,
                  fwkJobReport=True,
                  jsonInput=runsAndLumis())
#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[jetmetUncertaintiesAll(),mht(),btagSFProducer("cmva"),vhbb()],provenance=True,fwkJobReport=True)
#p=PostProcessor(".",inputFiles(),selection.replace('\n',' '),"keep_and_drop.txt",modules=[jetmetUncertaintiesAll(),btagSFProducer("cmva"),vhbb()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis())
p.run()

print "DONE"
os.system("ls -lR")
示例#23
0
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles, runsAndLumis
from PhysicsTools.NanoAODTools.postprocessing.framework.jobreport import JobReport
from Sphaleron_Ana.NanoAODReader.NanoReader import *

nFiles = 0
outFilesList = []
jobReport = JobReport()
for f in inputFiles():
    nFiles += 1
    outStr = "out" + str(nFiles)
    outFilesList.append(outStr)
    nEvents = NanoReader(inputFileName=f,
                         outputFileName=outStr,
                         nJobs=1,
                         jobNum=1,
                         json=runsAndLumis())
    print("events are %i \n" % nEvents)
    jobReport.addInputFile(f, nEvents)

#hadd outputs
hadd_cmnd = "./haddnano.py tree.root "
for f in outFilesList:
    hadd_cmnd += f + " "

print("executing : %s" % hadd_cmnd)
os.system(hadd_cmnd)
print("ls")
os.system("ls")

jobReport.addOutputFile("tree.root")
jobReport.save()