示例#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 * 

#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")

示例#3
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")
if args.file:

    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("-")
示例#5
0
  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
  from PhysicsTools.NanoAODTools.postprocessing.analysis.mt2.metaDataProducer import metaDataProducer
  from PhysicsTools.NanoAODTools.postprocessing.analysis.mt2.smsAnalyzer import smsAnalyzer
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")       
#!/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")

示例#8
0
#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 PhysicsTools.NanoAODTools.postprocessing.modules.common.puWeightProducer import puAutoWeight_2018
from PhysicsTools.NanoAODTools.postprocessing.modules.common.puWeightProducer import puWeightProducer

'''
from nanoAOD_filesPaths.BcToJpsiMuNu_new_nanoAOD_filesPath import BcToJpsiMuNu_files
from nanoAOD_filesPaths.BcToJpsiTauNu_nanoAOD_filesPath import BcToJpsiTauNu_files
from nanoAOD_filesPaths.OniaX_nanoAOD_filesPath import OniaX_files
from nanoAOD_filesPaths.data_nanoAOD_filesPath import data_files
'''
#p=PostProcessor(".",['root://t3dcachedb03.psi.ch:1094//pnfs/psi.ch/cms/trivcat/store/user/friti/crab_job_2020Jul28/BcToJPsiMuNu_TuneCP5_13TeV-bcvegpy2-pythia8-evtgen/crab_BcToJpsiMuNu_new/200728_084005/0000/RJPsi_mc_2020Jul28_1.root'],"",modules=[puAutoWeight_2018()],provenance=True,fwkJobReport=True,maxEntries=10000)
'''
datasets = [BcToJpsiMuNu_files, BcToJpsiTauNu_files, OniaX_files, data_files]

for dataset,name in zip(datasets,['BcMu','BcTau','Onia','data']):
    files_path = dataset
    p=PostProcessor(name,files_path,"",modules=[puAutoWeight_2018()],provenance=True,fwkJobReport=True,haddFileName=name+'_pu.root')

    p.run()

print "DONE"
'''
p=PostProcessor('.',inputFiles(),"",modules=[puAutoWeight_2018()],provenance=True,haddFileName='tree.root', fwkJobReport=True)
#p=PostProcessor('.',['root://cms-xrd-global.cern.ch//store/user/friti/crab_job_2020Jul28/BcToJPsiMuNu_TuneCP5_13TeV-bcvegpy2-pythia8-evtgen/crab_BcToJpsiMuNu_new/200728_084005/0000/RJPsi_mc_2020Jul28_1.root'],"",modules=[puAutoWeight_2018()],provenance=True,haddFileName='tree.root',maxEntries=100)

p.run()
示例#9
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"
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")
示例#11
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")

示例#12
0
                    dest="inputfile",
                    type=str,
                    default=None,
                    help="path to input file")
parser.add_argument('--year', dest='year', action='store', type=int)
parser.add_argument('--maxEntries', '-N', type=int, default=None)
parser.add_argument('--crab', action='store_true')
parser.add_argument('--output', type=str, default='weights.root')

args = parser.parse_args()
print(args)

the_inputfiles = None
keep = None
if args.crab:
    the_inputfiles = inputFiles()
    keep = './keep.txt'
else:
    the_inputfiles = [args.inputfile]
    keep = 'processors/keep.txt'

print('Inputfiles: ', the_inputfiles)

triggers = {
    2016: [
        '(HLT_IsoMu24 == 1)',
        '(HLT_IsoTkMu24 == 1)',
        '(HLT_Ele27_WPTight_Gsf == 1)',
        '(HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL_DZ == 1)',
        '(HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL == 1)',
        #'(HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ == 1)',
示例#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.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")
示例#14
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()
示例#15
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"
示例#16
0
    
    if not sampOpt['isData']:
        # add pile-up weight before any skim
        mod = [puAutoWeight] + mod
        
        ## add jet met uncertainties
        from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetUncertainties import jetmetUncertainties2017All, jetmetUncertainties2017
        jmeUncert = jetmetUncertainties2017()
        jmeUncert.metBranchName = 'METFixEE2017'
        mod.extend([jmeUncert]) # jetmetUncertainties2017All()
    
        ## 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 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(".",inputFiles() if 'IS_CRAB' in os.environ else [],cut,inputSlim,mod,provenance=True,fwkJobReport=True,jsonInput=jsonInput, outputbranchsel=outputSlim)




示例#17
0
if selector == 'bff':
    from PhysicsTools.NanoAODTools.postprocessing.bff.bffPreselModule import bffPreselProducer as preselectorProducer
if selector == 'bff_eff':
    from PhysicsTools.NanoAODTools.postprocessing.bff.bffBtagEff import bffBtagEffProducer as preselectorProducer
if selector == 'minseok':
    from PhysicsTools.NanoAODTools.postprocessing.bff.bffPreselModule_minseok import bffPreselProducer as preselectorProducer

#prepare file if glob
if not crab:
    print("using input file", infile)
    import glob
    infile = glob.glob(infile)
else:
    from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles
    print("get input file (crab)")
    infile = inputFiles()
print("infile", infile)
#2017 EE fix
conditions_dict = {
    '2016': {
        'metBranchName': 'MET',
        'heepBranchName': 'cutBased_HEEP',
        'applyHEMfix': False
    },
    '2017': {
        'metBranchName': 'METFixEE2017',
        'heepBranchName': 'cutBased_HEEP',
        'applyHEMfix': False
    },
    '2018': {
        'metBranchName': 'MET',
示例#18
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")

示例#19
0
#!/usr/bin/env python
import os, sys
import ROOT
ROOT.PyConfig.IgnoreCommandLineOptions = True

from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import PostProcessor
from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetUncertainties import *
from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetRecalib import *
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles, runsAndLumis

from Analysis.TTbarAllHad.TTbarResAnaHadronic import *

import random
random.seed(12345)

inff = inputFiles()
print 'Input files are :'

print inff

p1 = PostProcessor(
    ".",
    inff,
    'nFatJet >= 2 && FatJet_pt[0] > 400. && FatJet_pt[1] > 400.',
    '', [ttbarreshad_preddistwriter_data()],
    provenance=True,
    histFileName='ttbarreshad.root',
    histDirName='ttbarres',
    noOut=True)  #, haddFileName = 'ttbarreshad_nanoskim.root')
p1.run()
示例#20
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":
示例#21
0
#Run
#All options
#PostProcessor(outputDir,inputFiles,cut=None,branchsel=None,modules=[],compression="LZMA:9",friend=False,postfix=None,jsonInput=None,noOut=False,justcount=False,provenance=False,haddFileName=None,fwkJobReport=False,histFileName=None,histDirName=None,outputbranchsel=None)
if dataType == 'data':
    if process == 'local':
        p = PostProcessor(
            outputDir=".",
            noOut=True,
            modules=[module2run()],
            inputFiles=infiles
        )  #,jsonInput=jsonfile) #No need jsonInput locally (it takes sometime to prefilter evt)
    if process == 'crab':
        p = PostProcessor(outputDir=".",
                          noOut=True,
                          modules=[module2run()],
                          inputFiles=inputFiles(),
                          jsonInput=jsonfile,
                          fwkJobReport=True)
elif dataType == 'mc':
    if process == 'local':
        p = PostProcessor(outputDir=".",
                          noOut=True,
                          modules=[module2run()],
                          inputFiles=infiles)
    if process == 'crab':
        p = PostProcessor(outputDir=".",
                          noOut=True,
                          modules=[module2run()],
                          inputFiles=inputFiles(),
                          fwkJobReport=True)
else:
示例#22
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")
        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"]])
示例#24
0
job_report=JobReport()
bin_path="%s/src/BSM3GAna/BSM3GAna/data/Analyzer/"%(os.environ['CMSSW_BASE'])

output_file="tree.root"
output_log="output_log.log"

if os.path.exists(output_log):
    os.remove(output_log)
if os.path.exists(output_file):
    os.remove(output_file)


    
cwd=os.getcwd()
os.chdir(bin_path)
command="./Analyzer -in "+" ".join(inputFiles())+" -out "+output_file+" -C PartDet"
# command="./Analyzer -in "+inputFiles+" -out output.root -C PartDet -t"
print "Command: "+command
# subprocess.call(command, shell=True, stderr=subprocess.STDOUT,)
try:
    logfile=open(output_log,"w")
    subprocess.call(command, shell=True, stderr=subprocess.STDOUT, stdout=logfile)
    logfile.close()

    if os.path.exists(output_log):
        shutil.copy(output_log,cwd)
    else:
        print "no log file"
    if os.path.exists(output_file):
        shutil.move(output_file,cwd)
    else:
示例#25
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")
示例#26
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"
from FourTopNAOD.Kai.modules.LeptonSkimmer import *
from FourTopNAOD.Kai.modules.JetMETSkimmer import *
isData = True
isUltraLegacy = False
era = "2017"
subera = "E"
thePreselection = None
crossSection = None
equivLumi = 41.53
nEventsPositive = None
nEventsNegative = None
sumWeights = None
TriggerChannel = "MuMu"
JESUnc = "Merged" # options: "All", "Merged", "Total"

theFiles = inputFiles()
GoldenJSON = {"2016": {"non-UL": "Cert_271036-284044_13TeV_ReReco_07Aug2017_Collisions16_JSON.txt",
                       "UL": "Cert_271036-284044_13TeV_Legacy2016_Collisions16_JSON.txt"
                   },
              "2017": {"non-UL": "Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON_v1.txt",
                       "UL": "Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt"
                   },
              "2018": {"non-UL": "Cert_314472-325175_13TeV_17SeptEarlyReReco2018ABC_PromptEraD_Collisions18_JSON.txt",
                       "UL": "Cert_314472-325175_13TeV_Legacy2018_Collisions18_JSON.txt"
                   }
          }

if isData:
    theLumis = os.path.join(os.environ["CMSSW_BASE"], "python/FourTopNAOD/Kai/jsons", GoldenJSON.get(era).get("UL" if isUltraLegacy else "non-UL"))
    print("Loading Golden Json: {}".format(theLumis))
    if not os.path.isfile(theLumis):
#!/usr/bin/env python
import os
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import * 
import VBFHToInv.NanoAODTools.postprocessing.VBFHToInvModules as vbf

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

modules = [
    vbf.TriggerSelectionConstructor(),
    vbf.MetFilters2016Data(),
    vbf.JetCleaningConstructor(), # currently, this includes MET cleaning, dijet variables and jetMETMinDPhi
    vbf.jecUncert_2016{block}_data(), # (block) is a kwarg replacement field, replaced in crab_cfg_creator with a proper value
    ]

p = PostProcessor('.', inputFiles(), modules=modules, provenance=True, fwkJobReport=True, jsonInput='Cert_271036-284044_13TeV_23Sep2016ReReco_Collisions16_JSON.txt')
p.run()

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

示例#29
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_ReReco_07Aug2017_Collisions16_JSON.txt" 
#jsonFile = "Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON_v1.txt"
jsonFile = "Cert_314472-325175_13TeV_Legacy2018_Collisions18_JSON.txt"

#p=PostProcessor(".",inputFiles(),cut=None,branchsel=None,modules=[analyze2016MC_Skim()],provenance=True,fwkJobReport=True,jsonInput=runsAndLumis(),noOut=False,outputbranchsel="keep_and_dropSR_out.txt")
p=PostProcessor(".",inputFiles(),cut=None,branchsel=None,modules=[jetmetCorrector2018DataC(),analyze2018Data_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")
示例#30
0
from PhysicsTools.NanoAODTools.postprocessing.framework.datamodel import Collection
from PhysicsTools.NanoAODTools.postprocessing.framework.eventloop import Module

#this takes care of converting the input files from CRAB
from PhysicsTools.NanoAODTools.postprocessing.framework.crabhelper import inputFiles, runsAndLumis
#from Analysis.QJetMass.skimmers.ZPlusJet_SkimNANO import *
from PhysicsTools.NanoAODJMARTools.postprocessing.modules.skimmers.JetPlusStuff_SkimNANO import *

### Get the name of the input file and decide if it is 80XMC , 94X MC , data 2016 or 2017
is80XMC = False
is94XMC = False
is2016Data = False
is2017Data = False
print "Analyzing filename for keywords....."
nameis = str(inputFiles()[0].split('/')[8])
print nameis
if ('SingleMuon' in nameis) or ('SingleElectron' in nameis):
    nameis = str(inputFiles()[0].split('/')[8])
    if 'Run2016' in nameis: is2016Data = True
    if 'Run2017' in nameis: is2017Data = True
else:
    #if len(inputFiles()[0].split('/')[7]) > 100 : nameis = str(inputFiles()[0].split('/')[7][:-10])
    if '16MiniAOD' in str(inputFiles()[0].split('/')[8]): is80XMC = True
    if '17MiniAOD' in str(inputFiles()[0].split('/')[8]): is94XMC = True

print "NAMEISSSSS"
print nameis

problemS = False
if len(nameis) < 5: problemS = True