def __call__(self, cut): newFileList = [] logger.info("Starting nanoAOD postprocessing") for f in self.files: # need a hash to avoid data loss file_hash = str(hash(f)) self.modules = [] JMECorrector = createJMECorrector(isMC=(not self.isData), dataYear=self.year, runPeriod=self.era, jesUncert="Total", jetType="AK4PFchs", metBranchName=self.METCollection, applySmearing=False) self.modules.append(JMECorrector()) # self.modules.append( METSigProducer(self.JER, self.metSigParams, METCollection=self.METCollection, useRecorr=True, calcVariations=(not self.isData), jetThreshold=self.jetThreshold, vetoEtaRegion=self.vetoEtaRegion) ) p = PostProcessor(self.output_directory, [f], cut=cut, modules=self.modules, postfix="%s_%s" % (self.postfix, file_hash)) p.run() newFileList += [ self.output_directory + '/' + f.split('/')[-1].replace( '.root', '%s_%s.root' % (self.postfix, file_hash)) ] logger.info("Done. Replacing input files for further processing.") self.outfiles = newFileList
def run( self , infiles , isample=None ): p=PostProcessor( outputDir='%s/%s/%s/' %( os.getcwd() , self.outfolder , isample ) if isample is not None else '%s/%s/' %( os.getcwd() , self.outfolder ) , inputFiles=infiles , cut= self.presel , branchsel= "%s/scripts/data/slimming-%s-in.txt" %( os.getcwd() , self.year ), modules= self.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 = "%s/scripts/data/slimming-%s-in.txt" %( os.getcwd() , self.year ), maxEntries=None, firstEntry=0, prefetch=False, longTermCache=False ) p.run() pass
def stitcher(fileList, hName=None, theEra="2021", theChannel="NL", theCondition="Nope", theMode="Bloop!", weightMagnitude=1, HTBinWidth=50): # print("Stitcher disabled here, use hist or plot") # print("fileList, hName, theEra, theChannel, theCondition, theMode, weightMagnitude, HTBinWidth:") # print(fileList) # print(hName) # print(theEra) # print(theChannel) # print(theCondition) # print(theMode) # print(weightMagnitude) # print(HTBinWidth) if theMode == "Plot": theNoOut = True else: theNoOut = False if hName == None: hDirName = None else: hDirName = "plots" p=PostProcessor(".", fileList, cut=None, # modules=[Stitcher(maxevt=300000, era=theEra, channel=theChannel, mode=theMode, condition=theCondition, verbose=False)], modules=[Stitcher(verbose=False, mode=theMode, era=theEra, channel=theChannel, condition=theCondition, weightMagnitude=weightMagnitude, fillHists=True, HTBinWidth=HTBinWidth, desiredHTMin=200, desiredHTMax=800)], noOut=theNoOut, # maxEntries=4000, haddFileName=hName, histFileName="HTBin{0}_hist_".format(HTBinWidth)+hName, histDirName=hDirName, postfix="_HTBin{0}".format(HTBinWidth)+hName.replace(".root", "") ) p.run()
def main(): ROOT.PyConfig.IgnoreCommandLineOptions = True ROOT.gROOT.SetBatch(True) postprocessor = PostProcessor( # The output directory is the current working directory. outputDir='.', # Any and all command line arguments are taken to be an input file path. inputFiles=sys.argv[1:], # The skimming selection string. cut=( '(Sum$(Electron_pt > 20 && Electron_mvaSpring16GP_WP90) >= 2' ' || Sum$(Muon_pt > 20) >= 2' ' || Sum$(Electron_pt > 20 && Electron_mvaSpring16GP_WP80) >= 1' ' || Sum$(Muon_pt > 20 && Muon_tightId) >= 1' ' || (Sum$(Muon_pt > 20) == 0 && Sum$(Electron_pt > 20 && Electron_mvaSpring16GP_WP90) == 0 && MET_pt > 80))' '&& Sum$(abs(Jet_eta) < 2.5 && Jet_pt > 20 && Jet_jetId) >= 2' ), # The path to a text file describing which branches to keep and drop. branchsel='keep_and_drop.txt', # Additional postprocessing modules which add additional selections and branches. {% if is_data %} modules=[vhbb()], {% else %} modules=[btagSFProducer('cmva'), jecUncertAll_cppOut(), vhbb()], {% endif %} # Preserve input file provenance information. provenance=True, ) postprocessor.run()
def main(args): isdata = len(args.dataEra) > 0 isfastsim = args.isFastSim isSUSY = args.sampleName.startswith("SMS_") if isdata and isfastsim: print "ERROR: It is impossible to have a dataset that is both data and fastsim" exit(0) mods = [qcdskimmingfile()] #============================================================================# #------------------------- Run PostProcessor ------------------------# #============================================================================# files = [] if len(args.inputfile) > 5 and args.inputfile[0:5] == "file:": #This is just a single test input file files.append(args.inputfile[5:]) else: #this is a file list with open(args.inputfile) as f: files = [line.strip() for line in f] p = PostProcessor(args.outputfile, files, cut=" MET_pt >200", branchsel=None, outputbranchsel="keep_and_drop_skim.txt", modules=mods, provenance=False, maxEvents=args.maxEvents) p.run()
def stitcher(fileList, hName=None, theEra="2021", theChannel="NL", theCondition="Nope", theMode="Bloop!"): if hName == None: hDirName = None else: hDirName = "plots" p = PostProcessor( ".", fileList, cut=None, modules=[ Stitcher(maxevt=300000, era=theEra, channel=theChannel, mode=theMode, condition=theCondition, verbose=False) ], # modules=[TopSystemPt(maxevt=100, wOpt=wOption)], noOut=False, haddFileName=hName, histFileName="hist_" + hName, histDirName=hDirName, ) p.run()
def histogramer(fileList, hName=None, theEra="2021", theChannel="NL", weightMagnitude=1): if hName == None: hDirName = None else: hDirName = "plots" p = PostProcessor( ".", fileList, cut=None, #Need the plotter, yo modules=[ StitchHist(maxevt=-1, era=theEra, channel=theChannel, verbose=False, weightMagnitude=weightMagnitude) ], noOut=True, histFileName=hName, histDirName=hDirName, ) p.run()
def main(args): # isdata = False # isfastsim = False if "False" in args.isData: isdata = False else: isdata = True if "False" in args.isFastSim: isfastsim = False else: isfastsim = True mods = [ qcdskimmingfile(), ] #files=["/eos/uscms/store/user/lpcsusyhad/Stop_production/Summer16_80X_v2_NanAOD_MC/PostProcess_v1/QCD_HT100to200/QCD_HT100to200_0.root"] files = [] lines = open(args.inputfile).readlines() for line in lines: files.append(line.strip()) p = PostProcessor(args.outputfile, files, cut=" MET_pt >200 & nJet >= 2", branchsel=None, outputbranchsel="keep_and_drop_skim.txt", modules=mods, provenance=False) p.run()
def main(args): #where to find our user-generated data PU files datadir = os.path.join(os.environ["CMSSW_BASE"], "src/MyAnalysis/HmmAna/data") #configure the puWeightProducer to extract the MC distribution directly from the current NanoAOD file ("auto") puAutoWeight = lambda: puWeightProducer( "auto", os.path.join(datadir, "pileup", pileup_files_data[args.data_period]), "pu_mc", "pileup", verbose=True) #book all the different things we want to compute in the postprocessor modules = [puAutoWeight()] #friend: if True, create a new tree that contains *only* the output weights, without copying all the inputs. Much faster. p = PostProcessor(args.outdir, args.input_files, friend=True, modules=modules) #actually run the code, creating one output file per each input file p.run()
def _runIt(args): (mysource,myoutpath,mycut,options) = args pp = PostProcessor(myoutpath,[mysource], postfix='', cut = mycut, saveSelectionElist = options.elist, outputbranchsel = options.branchsel_out, compression = options.compression, justcount = options.justcount, jsonInput = options.json) pp.run()
def multiplier(file): pN = PostProcessor( ".", [file], cut=None, modules=[TenKTree()], ) t0 = time.time() pN.run() t1 = time.time() pid = os.getpid() print("Elapsed time {0:7.1f} s by process id: {1}".format((t1 - t0), pid))
def skimmer(arg): """ Args: file: input files of datasets arg: the string attached to the end of the file names Returns: """ redirector = chooseRedirector(arg) pathToFile = redirector + arg.fileName print ("Running on: %s" % pathToFile) datasetFile = Dataset(arg.fileName) inFile = datasetFile.fileName print("inFile: %s" %inFile) print("self.type = %s" %datasetFile.type) if datasetFile.type == "mc": OutDir = "NanoAOD_v5/MC" + datasetFile.year + "/" + datasetFile.primaryName elif datasetFile.type == "data": OutDir = "NanoAOD_V5/Data/" + datasetFile.primaryName else: print("Dataset type is undefined; expected 'mc' or 'data' ; none of these were given") return -1 print("OutDir: %s" % OutDir) thePostFix = "_v" p99 = PostProcessor(".", [pathToFile], cut="nJet > 3 && ( nMuon >0 || nElectron >0 ) ", modules=[PfJetsSkimmer(eventLimit=arg.eventLimit)], postfix=thePostFix, provenance=True, #branchsel="/user/nistylia/CMSSW_9_4_10/src/TopBrussels/RemoteWork/myInFiles/kd_branchsel.txt", #outputbranchsel="/user/nistylia/CMSSW_9_4_10/src/TopBrussels/RemoteWork/myInFiles/kd_branchsel.txt", ) print(p99.inputFiles) t0 = time.time() p99.run() if 'TMPDIR' in os.environ: if os.environ['TMPDIR'] == os.environ['PWD']: print("We are in the temporary directory, so need to copy files in pnfs") cmdString = "gfal-copy -f file://$TMPDIR/{0}{1}.root srm://maite.iihe.ac.be:8443/pnfs/iihe/cms/store/user/$USER/{2}/{0}.root".format(inFile, thePostFix, OutDir) print(cmdString) os.system(cmdString) t1 = time.time() proc = os.getpid() print(">>> Elapsed time {0:7.1f} s by process id: {1}".format((t1 - t0), proc)) else: print("This is a permanent directory so we save in current directory")
def post_processor(out_dir, filelist, channel): ##NanoAOD postprocessor class p = PostProcessor( outputDir=".", inputFiles=filelist, noOut=False, modules=module_list[channel], outputbranchsel= "{}/src/ChargedHiggs/nanoAOD_processing/data/keep_and_drop.txt".format( os.environ["CMSSW_BASE"]), ) p.run()
def process_job(input_files, skim): """Skim files and merge output""" if len(input_files) == 0: return None job_output_eos_dir = get_output_dir(output_eos_dir, input_files[0], skim) job_output_tmp_dir = get_output_dir(output_tmp_dir, input_files[0], skim) fname = filename(input_files) save_file_list(input_files, job_output_eos_dir, fname) job_output_eos_filename = "%s/%s.root" % (job_output_eos_dir, fname) job_output_tmp_filename = "%s/%s.root" % (job_output_tmp_dir, fname) if output_is_already_available(job_output_eos_filename): return job_output_eos_filename # Skim- data cut = "&&".join(skims[skim]['cuts']) processor = PostProcessor( job_output_tmp_dir, input_files, cut=cut, compression="LZMA:4", # need to tune it postfix="_%s" % skim) processor.run() # merge skimed data skimmed_files = [] for f in input_files: skimmed_files.append( os.path.join( job_output_tmp_dir, os.path.basename(f).replace(".root", "_%s.root" % skim))) if len(skimmed_files) > 1: subprocess.call("haddnano.py %s %s" % (job_output_tmp_filename, " ".join(skimmed_files)), shell=True) for f in skimmed_files: os.remove(f) shutil.move(job_output_tmp_filename, job_output_eos_filename) elif len(skimmed_files) == 1: shutil.move(skimmed_files[0], job_output_eos_filename) else: raise Exception("Fatal Error: no skimmped input") if _is_good_file(job_output_eos_filename): return job_output_eos_filename else: return None
def multiplier(fileList, hName=None, NLeps=None, maxevt=1000): if hName == None: hDirName = None else: hDirName = "plots" p = PostProcessor( ".", fileList, modules=[MCTreePlot(maxevt=maxevt, filterNLeps=NLeps)], noOut=True, histFileName=hName, histDirName=hDirName, ) p.run()
def main(args): isdata = len(args.dataEra) > 0 isqcd = args.sampleName.startswith("QCD_") isqcdorig = "ORIG" in args.sampleName process = args.process mods = [] if process == 'jetres': mods.append(JetResSkim(args.era)) elif process == 'smear': mods.append( UpdateEvtWeightSmear(isdata, args.crossSection, args.nEvents, args.sampleName)) mods.append(qcdSmearProducer()) elif process == 'qcdsf': mods.append( QCDObjectsProducer(isQCD=isqcd, isData=isdata, isQCDOrig=isqcdorig)) #files = ["root://cmseos.fnal.gov//store/user/lpcsusyhad/Stop_production/Summer16_94X_v3/PostProcessed_11Apr2019_v2p7/QCD_HT_700to1000_2016/QCD_HT_700to1000_2016_2.root"] files = [] if len(args.inputfile) > 5 and args.inputfile[0:5] == "file:": #This is just a single test input file files.append(args.inputfile[5:]) else: #this is a file list with open(args.inputfile) as f: files = [line.strip() for line in f] if process == 'jetres': p = PostProcessor(args.outputfile, files, cut=None, branchsel=None, outputbranchsel="keep_and_drop_res.txt", typeofprocess="resp", modules=mods, provenance=False) elif process == 'smear': p = PostProcessor(args.outputfile, files, cut="MET_pt > 200", branchsel=None, outputbranchsel="keep_and_drop_QCD.txt", outputbranchselsmear="keep_and_drop_QCD.txt", typeofprocess="smear", modules=mods, provenance=False) elif process == 'qcdsf': p = PostProcessor( args.outputfile, files, cut="Pass_MET & Pass_EventFilter & Pass_HT & Pass_dPhiMETLowDM", branchsel=None, outputbranchsel="keep_and_drop.txt", modules=mods, provenance=False, maxEvents=args.maxEvents) p.run()
def skimmer(fileList, hName=None, theEra="2021", theChannel="NL", theCondition="Nope", theMode="Bloop!", weightMagnitude=1, HTBinWidth=50): p=PostProcessor("stitchingSkims", fileList, cut=None, branchsel="KDStitchSkim.txt", outputbranchsel="KDStitchSkim.txt", # modules=[Stitcher(maxevt=300000, era=theEra, channel=theChannel, mode=theMode, condition=theCondition, verbose=False)], modules=[], noOut=False, # maxEntries=4000, # haddFileName="skimmed"+hName, compression="none", postfix=hName.replace(".root","") ) p.run()
def multiplier(fileList, hName=None): if hName == None: hDirName = None else: hDirName = "plots" p=PostProcessor(".", fileList, cut=None, modules=[modulecache], noOut=True, histFileName=hName, histDirName=hDirName, ) p.run()
def run(input_files, runsAndLumis=None, directory=".", for_crab=True): preselection=None modules = [ NoIsolated("Electron", "miniPFRelIso_all", 0.1, pt_thresh=10), NoIsolated("Muon", "miniPFRelIso_all", 0.2, pt_thresh=10), NoIsolated("Photon", "pfRelIso03_all", 0.1, pt_thresh=10), InvertedVBF(30, 4, 700), ] if for_crab: ext_opts = dict(provenance=True,fwkJobReport=True,jsonInput=runsAndLumis()) else: ext_opts = dict(histFileName="histOut.root",histDirName="plots", haddFileName="combined.root") p=PostProcessor(directory,input_files,cut=preselection,branchsel=None,modules=modules, **ext_opts) p.run()
def multiplier(fileList, hName=None, fName="def.root", NLeps=None, maxevt=10000): hName = None hDirName = None p=PostProcessor(".", fileList, modules=[puWeightProducer("auto",pufile_data2017,"pu_mc","pileup",verbose=True), Trigger(triggers), BaselineSelector(isData=True, era="2017", btagging=['DeepCSV','M'], lepPt=25, MET=50, HT=500, invertZWindow=False, GenTop_LepSelection=None), # MCTreePlot(maxevt=maxevt, filterNLeps=NLeps) ], haddFileName=fName, noOut=False, # histFileName=hName, # histDirName=hDirName, ) p.run()
def multiplier(fileList, hName=None, wOption=0): if hName == None: hDirName = None else: hDirName = "plots" p = PostProcessor( ".", fileList, cut=None, modules=[TopSystemPt(maxevt=-1, wOpt=wOption)], # modules=[TopSystemPt(maxevt=100, wOpt=wOption)], noOut=True, histFileName=hName, histDirName=hDirName, ) p.run()
def fillhists(fileList, hName=None, theEra="2021", theChannel="NL", theCondition="Nope", theMode="Bloop!", weightMagnitude=1, HTBinWidth=50): theMode = "Plot" theNoOut = True if hName == None: raise RuntimeError("No histogram file for plotting!") else: hDirName = "plots" p=PostProcessor(".", fileList, cut=None, modules=[Stitcher(verbose=False, mode=theMode, era=theEra, channel=theChannel, condition=theCondition, weightMagnitude=weightMagnitude, fillHists=True, HTBinWidth=HTBinWidth, desiredHTMin=200, desiredHTMax=800)], noOut=theNoOut, # maxEntries=4000, histFileName="HTBin{0}_hist_".format(HTBinWidth)+hName, histDirName=hDirName, ) p.run()
def main(args): # isdata = False # isfastsim = False if "False" in args.isData: isdata = False else: isdata = True if "False" in args.isFastSim: isfastsim = False else: isfastsim = True mods = [ eleMiniCutID(), Stop0lObjectsProducer(args.era), DeepTopProducer(args.era), Stop0lBaselineProducer(args.era, isData=isdata, isFastSim=isfastsim), UpdateGenWeight(isdata, args.crossSection, args.nEvents) ] if args.era == "2018": mods.append(UpdateJetID(args.era)) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For MC ~~~~~ if not isdata: pufile = "%s/src/PhysicsTools/NanoSUSYTools/data/pileup/%s" % ( os.environ['CMSSW_BASE'], DataDepInputs[args.era]["pileup"]) mods += [ lepSFProducer(args.era), puWeightProducer("auto", pufile, "pu_mc", "pileup", verbose=False) ] files = [] lines = open(args.inputfile).readlines() for line in lines: files.append(line.strip()) p = PostProcessor(args.outputfile, files, cut=None, branchsel=None, outputbranchsel="keep_and_drop.txt", modules=mods, provenance=False) p.run()
def split_sf(fileList, era="2015", muID="LooseID", muISO="LooseRelIso/LooseID", elID="LooseID"): p=PostProcessor(".", fileList, cut=None, #Need the plotter, yo # modules=[lepSplitSFProducer(muon_ID=muID, muon_ISO=muISO, electron_ID=elID, era=era, doMuonHLT=True, doElectronHLT_ZVtx=True)], modules=[lepSplitSFProducer(muon_ID=muID, muon_ISO=muISO, electron_ID=elID, era=era, doMuonHLT=True, doElectronHLT_ZVtx=True, debug=True)], # modules=[lepSplitSFProducer(muon_ID=muID, muon_ISO=muISO, electron_ID=elID, era=era, doMuonHLT=False, doElectronHLT_ZVtx=True, debug=True)], # modules=[lepSplitSFProducer(muon_ID=muID, muon_ISO=muISO, electron_ID=elID, era=era, doMuonHLT=True, doElectronHLT_ZVtx=False, debug=True)], # modules=[lepSplitSFProducer(muon_ID=muID, muon_ISO=muISO, electron_ID=elID, era=era, doMuonHLT=False, doElectronHLT_ZVtx=False, debug=True)], noOut=False, postfix="_"+era+"_"+muID+"_"+muISO.replace("/","@")+"_"+elID, # haddFileName="SFTest_"+muID+"_"+muISO.replace("/","@")+"_"+elID+".root", maxEntries=4, # histFileName=hName, # histDirName=hDirName, ) p.run()
def _process(self): # check for missing information for parameter in ['cut', 'input']: if parameter not in self.job_info: raise Exception("Missing input '%s'" % parameter) input_files = self.job_info['input'] # skim data postfix = "_Skim" processor = PostProcessor(self.tmp_dir, input_files, cut=self.job_info['cut'], compression="LZMA:9", postfix=postfix) sys.stdout.flush() processor.run() sys.stdout.flush() # merge skimed data skimmed_files = [] for f in input_files: skimmed_files.append( os.path.join( self.tmp_dir, os.path.basename(f).replace(".root", "%s.root" % postfix))) if len(skimmed_files) > 1: subprocess.call("haddnano.py %s %s" % (self.job_output_tmp, " ".join(skimmed_files)), shell=True) # clean up for f in skimmed_files: os.remove(f) else: if len(skimmed_files) == 0: raise Exception("There should be more than one skimmed file") subprocess.call("mv -v %s %s" % (skimmed_files[0], self.job_output_tmp), shell=True) sys.stdout.flush()
def multiplier(fileList, hName=None, wOption=1, weightMagnitude=1): # print("wOption is: {}".format(wOption)) # print("input Weight Magnitude is: {}".format(weightMagnitude)) if hName == None: hDirName = None else: hDirName = "plots" p = PostProcessor( ".", fileList, cut=None, modules=[ TopSystemPt(maxevt=1500000, wOpt=wOption, wMag=weightMagnitude) ], noOut=True, histFileName=hName, histDirName=hDirName, ) p.run()
def __call__(self, cut): newFileList = [] logger.info("Starting nanoAOD postprocessing") for f in self.files: # need a hash to avoid data loss file_hash = str(hash(f)) self.modules = [] JMECorrector = createJMECorrector(isMC=(not self.isData), dataYear=self.year, runPeriod=self.era, jesUncert=",".join(self.jesTags), jetType="AK4PFchs", metBranchName=self.METCollection, applySmearing=False) # JMECorrector = createJMECorrector( isMC=(not self.isData), dataYear=self.year, runPeriod=self.era, jesUncert="Total", jetType = "AK4PFchs", metBranchName=self.METCollection, applySmearing=False ) self.modules.append(JMECorrector()) # if not self.isData: # if self.year == 2016: # self.modules.append(ElectronScaleSmear.elecUnc2016MC()) # self.modules.append(PhotonScaleSmear.phoUnc2016MC()) # elif self.year == 2017: # self.modules.append(ElectronScaleSmear.elecUnc2017MC()) # self.modules.append(PhotonScaleSmear.phoUnc2017MC()) # elif self.year == 2018: # self.modules.append(ElectronScaleSmear.elecUnc2018MC()) # self.modules.append(PhotonScaleSmear.phoUnc2018MC()) p = PostProcessor(self.output_directory, [f], cut=cut, modules=self.modules, postfix="%s_%s" % (self.postfix, file_hash)) p.run() newFileList += [ self.output_directory + '/' + f.split('/')[-1].replace( '.root', '%s_%s.root' % (self.postfix, file_hash)) ] logger.info("Done. Replacing input files for further processing.") self.outfiles = newFileList
def multiplier(fileList, connection): old_stdout = sys.stdout try: # with tempfile.NamedTemporaryFile() as fout: # connection.send(['Hello there!', fout.name]) # sys.stdout = fout sys.stdout = open("/tmp/nmangane/" + str(os.getpid()) + ".out", "w") sys.stderr = open("/tmp/nmangane/" + str(os.getpid()) + "_err.out", "w") connection.send({ 'stdout': str(os.getpid()) + ".out", 'stderr': str(os.getpid()) + "_err.out" }) if type(fileList) is str: fileList = [fileList] p = PostProcessor( ".", fileList, modules=[EventCounter()], noOut=True, # branchsel='keepdrop.txt', maxEntries=None, firstEntry=0, prefetch=False, longTermCache=False, ) p.run() connection.send({ 'nEvents': p.modules[0].nEvents, 'nPositiveEvents': p.modules[0].nPositiveEvents, 'nNegativeEvents': p.modules[0].nNegativeEvents, 'nZeroEvents': p.modules[0].nZeroEvents }) # print("nEvents: {0}\t nPositivEvents: {1}\t nNegativeEvents: {2}\t nZeroEvents: {3}".format( # p.modules[0].nEvents, p.modules[0].nPositiveEvents, p.modules[0].nNegativeEvents, p.modules[0].nZeroEvents) # ) # for line in fout: # pass finally: pass
def btag_sf(fileList, hName="default.root", era="2015", algo=None, wp=None): p = PostProcessor( ".", fileList, cut=None, modules=[ btagSFProducer(muon_ID=muID, muon_ISO=muISO, electron_ID=elID, era=era, doMuonHLT=True, doElectronHLT_ZVtx=True, debug=True) ], noOut=False, postfix="_" + era + "_" + algo + "_" + wp, # haddFileName="SFTest_"+muID+"_"+muISO.replace("/","@")+"_"+elID+".root", maxEntries=4, histFileName=era + hName, histDirName=hDirName, ) p.run()
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")
parser.add_option("--justcount", dest="justcount", default=False, action="store_true", help="Just report the number of selected events") parser.add_option("-I", "--import", dest="imports", type="string", default=[], action="append", nargs=2, help="Import modules (python package, comma-separated list of "); parser.add_option("-z", "--compression", dest="compression", type="string", default=("LZMA:9"), help="Compression: none, or (algo):(level) ") (options, args) = parser.parse_args() if options.friend: if options.cut or options.json: raise RuntimeError("Can't apply JSON or cut selection when producing friends") if len(args) < 2 : parser.print_help() sys.exit(1) outdir = args[0]; args = args[1:] modules = [] for mod, names in options.imports: import_module(mod) obj = sys.modules[mod] selnames = names.split(",") for name in dir(obj): if name[0] == "_": continue if name in selnames: print "Loading %s from %s " % (name, mod) modules.append(getattr(obj,name)()) if options.noOut: if len(modules) == 0: raise RuntimeError("Running with --noout and no modules does nothing!") p=PostProcessor(outdir,args,options.cut,options.branchsel,modules,options.compression,options.friend,options.postfix,options.json,options.noOut,options.justcount) p.run()