def runLoop( comp, outDir, config, options): fullName = '/'.join( [outDir, comp.name ] ) # import pdb; pdb.set_trace() config.components = [comp] loop = Looper( fullName, config, options.nevents, 0, nPrint = options.nprint, timeReport = options.timeReport, quiet = options.quiet) # print loop if options.iEvent is None: loop.loop() loop.write() # print loop else: # loop.InitOutput() iEvent = int(options.iEvent) loop.process( iEvent ) return loop
def runLoop( comp, outDir, config, options): fullName = '/'.join( [outDir, comp.name ] ) config.components = [comp] memcheck = 2 if getattr(options,'memCheck',False) else -1 loop = Looper( fullName, config, options.nevents, 0, nPrint = options.nprint, timeReport = options.timeReport, quiet = options.quiet, memCheckFromEvent = memcheck, stopFlag = _globalGracefulStopFlag) # print loop if options.iEvent is None: loop.loop() loop.write() # print loop else: # loop.InitOutput() iEvent = int(options.iEvent) loop.process( iEvent ) return loop
print " - components:", config.components if len(selectedComponents) > 1: print "More than one selected component:" from PhysicsTools.HeppyCore.framework.config import printComps printComps(selectedComponents) else: print "Selected component:" print selectedComponents[0] print "files: ", selectedComponents[0].files # set component to run config.components = selectedComponents # run!!! from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Output', config, nPrint=nprint, nEvents=nevents) looper.loop() looper.write() #os.system("ls -lR") # for debugging # print in crab log file the content of the job log files, so one can see it from 'crab getlog' print "-" * 25 print "printing output txt and log files" os.system('for i in Output/*.txt; do echo $i; cat $i; echo "---------"; done') os.system('for i in Output/*.log; do echo $i; cat $i; echo "---------"; done') # assign the right name os.system("rm Output/cmsswPreProcessing.root") if _filestounpack != "": filestounpack = _filestounpack.split(',') for mytree in filestounpack:
crabFiles[i] = pfn else: print "Data is not local, using AAA/xrootd" crabFiles[i] = "root://cms-xrd-global.cern.ch/" + crabFiles[i] import imp handle = open("heppy_config.py", 'r') cfo = imp.load_source("heppy_config", "heppy_config.py", handle) config = cfo.config handle.close() #replace files with crab ones config.components[0].files = crabFiles from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Output', config, nPrint=1) looper.loop() looper.write() #print PSet.process.output.fileName os.system("ls -lR") os.rename("Output/tree.root", "tree.root") os.system("ls -lR") import ROOT f = ROOT.TFile.Open('tree.root') entries = f.Get('tree').GetEntries() fwkreport = '''<FrameworkJobReport> <ReadBranches> </ReadBranches>
#### FULL ZZhToLL #selectedComponents = [sampleZZhToLLM1000] #selectedComponents = [sampleZZhToLLM2000] #selectedComponents = [sampleZZhToLLM3000] #selectedComponents = [sampleZZhToLLM4000] ###LOCAL COMPONENTS #selectedComponents = [sampleDM_MonoVbb,sampleDM_MonoH] config = cfg.Config( components=selectedComponents, sequence=sequence, services=[output_service], #preprocessor = preprocessor, events_class=Events) ############################## ### LOOPER ### ############################## # and the following runs the process directly if running as with python filename.py if __name__ == '__main__': from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper( 'MonoX', config, nPrint=0, nEvents=1000, ) looper.loop() looper.write()
#Run across these inputs components=[samp], #Using this sequence sequence=sequence, #save output to these services services=[output_service], #This defines how events are loaded events_class=Events) #Configure the number of events to run from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop_{0}'.format(samp.name), config, nPrint=0, firstEvent=0, nEvents=10000000) #execute the code looper.loop() tf = looper.setup.services["outputfile"].file tf.cd() ts = ROOT.TNamed("config", conf_to_str(Conf)) ts.Write("", ROOT.TObject.kOverwrite) #write the output looper.write()
if s.skip.value() == False: inputSamples.append(inputSample) #finalization of the configuration object. from PhysicsTools.HeppyCore.framework.chain import Chain as Events config = cfg.Config( #Run across these inputs components = inputSamples, #Using this sequence sequence = sequence, #save output to these services services = [output_service], #This defines how events are loaded events_class = Events ) from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop', config, nPrint = 0, firstEvent=firstEvent, nEvents = nEvents ) looper.loop() looper.write()
puFileDataMinus="puDataMinus.root", splitFactor=5) sample.isMC = True # the following is declared in case this cfg is used in input to the heppy.py script selectedComponents = [sample] from PhysicsTools.HeppyCore.framework.eventsfwlite import Events config = cfg.Config(components=selectedComponents, sequence=sequence, services=[output_service], events_class=Events) class TestFilter(logging.Filter): def filter(self, record): print record # and the following runs the process directly if __name__ == '__main__': from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop', config, nPrint=1, nEvents=1000) import time import cProfile p = cProfile.Profile(time.clock) p.runcall(looper.loop) p.print_stats() looper.write()
#save output to these services services=[output_service], #This defines how events are loaded events_class=Events) #Configure the number of events to run from PhysicsTools.HeppyCore.framework.looper import Looper nEvents = 1000 kwargs = {} if conf.general.get("eventWhitelist", None) is None: kwargs["nEvents"] = nEvents kwargs["firstEvent"] = conf.general.get("firstEvent", 0) looper = Looper('Loop_' + samp.name, config, nPrint=0, **kwargs) import cProfile, time p = cProfile.Profile(time.clock) p.runcall(looper.loop) p.print_stats() #execute the code #looper.loop() tf = looper.setup.services["outputfile"].file tf.cd() ts = ROOT.TNamed("config", conf_to_str(Conf)) ts.Write("", ROOT.TObject.kOverwrite) #write the output
from vhbb_combined import * from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop', config, nPrint=0, nEvents=1) of = open("tree.py", "w") of.write(looper.analyzers[-1].getPythonWrapper()) of.close()
handle.close() print "timeto_setLumis ", (time.time() - t0) #replace files with crab ones config.components[0].files = crabFiles_pfn if not "--nostep1" in args: print "heppy_config", config from PhysicsTools.HeppyCore.framework.looper import Looper if hasattr(PSet.process.source, "skipEvents") and PSet.process.source.skipEvents.value() >= 0: nfirst = int(PSet.process.source.skipEvents.value()) nmax = int(PSet.process.maxEvents.input.value()) looper = Looper('Output', config, nPrint=0, nEvents=nmax, firstEvent=nfirst) else: looper = Looper('Output', config, nPrint=0) looper.loop() looper.write() print "timeto_doVHbb ", (time.time() - t0) ### ### tthbb13 code ### if not "--nostep2" in args: print "Running tth code" import cPickle as pickle import TTH.MEAnalysis.TFClasses as TFClasses
def process(iev=None): if iev is None: iev = loop.iEvent loop.process(iev) if display: display.draw() def next(): loop.process(loop.iEvent+1) if display: display.draw() iev = None if len(sys.argv)==2: iev = int(sys.argv[1]) loop = Looper( 'looper', config, nEvents=500, nPrint=5, timeReport=True) pfsim = loop.analyzers[1] display = getattr(pfsim, 'display', None) simulator = pfsim.simulator detector = simulator.detector if iev is not None: process(iev) else: loop.loop() loop.write()
n_gen=1.0, xs=1.0) inputSample.isMC = s.isMC.value() if s.skip.value() == False: inputSamples.append(inputSample) #finalization of the configuration object. from PhysicsTools.HeppyCore.framework.chain import Chain as Events config = cfg.Config( #Run across these inputs components=inputSamples, #Using this sequence sequence=sequence, #save output to these services services=[output_service], #This defines how events are loaded events_class=Events) from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop', config, nPrint=0, firstEvent=firstEvent, nEvents=nEvents) looper.loop() looper.write()
#! /usr/bin/env python from vhbb_combined import * from PhysicsTools.Heppy.utils.cmsswPreprocessor import CmsswPreprocessor import glob, sys if __name__ == "__main__": fi = sys.argv[1] outfn = sys.argv[2] selectedComponents = [ cfg.MCComponent(files=[fi], name=fi.split("/")[-1].split(".")[0]) ] config.components = selectedComponents from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop_{0}'.format(outfn), config, nPrint=0) looper.loop() looper.write()
testfiles = miniAodFiles() sample = cfg.Component( #specify the file you want to run on # files = ["/scratch/arizzi/Hbb/CMSSW_7_2_2_patch2/src/VHbbAnalysis/Heppy/test/ZLL-8A345C56-6665-E411-9C25-1CC1DE04DF20.root"], files=testfiles, name="SingleSample", isMC=False, isEmbed=False) from PhysicsTools.Heppy.utils.cmsswPreprocessor import CmsswPreprocessor preprocessor = CmsswPreprocessor("makeAK5Jets.py") # the following is declared in case this cfg is used in input to the heppy.py script from PhysicsTools.HeppyCore.framework.eventsfwlite import Events selectedComponents = [sample] config = cfg.Config( components=selectedComponents, sequence=sequence, services=[output_service], preprocessor= preprocessor, #this would run cmsRun makeAK5Jets.py before running Heppy events_class=Events) # and the following runs the process directly if running as with python filename.py if __name__ == '__main__': from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop', config, nPrint=5, nEvents=300) looper.loop() looper.write()
from vhbb import * from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop', config) of = open("tree.py", "w") of.write(looper.analyzers[-1].getPythonWrapper()) of.close()
# processName='HLT', # outprefix='HLT' ) sequence = [VertexAna, LepAna, TauAna, PhoAna, JetAna, TrigAna, treeProducer] from PhysicsTools.Heppy.utils.miniAodFiles import miniAodFiles sample = cfg.Component( # files = "/scratch/arizzi/heppy/CMSSW_7_2_0_pre8/src/PhysicsTools/Heppy/test/E21AD523-E548-E411-8DF6-00261894388F.root", files=miniAodFiles(), name="ATEST", isMC=False, isEmbed=False) # the following is declared in case this cfg is used in input to the heppy.py script selectedComponents = [sample] from PhysicsTools.HeppyCore.framework.eventsfwlite import Events config = cfg.Config(components=selectedComponents, sequence=sequence, services=[], events_class=Events) # and the following runs the process directly if __name__ == '__main__': from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop', config, nPrint=5) looper.loop() looper.write()
puFileDataPlus="puDataPlus.root", puFileDataMinus="puDataMinus.root", splitFactor = 5 ) sample.isMC=True # the following is declared in case this cfg is used in input to the heppy.py script selectedComponents = [sample] from PhysicsTools.HeppyCore.framework.eventsfwlite import Events config = cfg.Config( components = selectedComponents, sequence = sequence, services = [output_service], events_class = Events) class TestFilter(logging.Filter): def filter(self, record): print record # and the following runs the process directly if __name__ == '__main__': from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper( 'Loop', config, nPrint = 1, nEvents = 1000) import time import cProfile p = cProfile.Profile(time.clock) p.runcall(looper.loop) p.print_stats() looper.write()
from PhysicsTools.Heppy.analyzers.objects.JetAnalyzer import JetAnalyzer JetAna = JetAnalyzer.defaultConfig sequence = [VertexAna, LepAna, TauAna, PhoAna, JetAna, treeProducer] from PhysicsTools.Heppy.utils.miniAodFiles import miniAodFiles sample = cfg.Component( # files = "/scratch/arizzi/heppy/CMSSW_7_2_0_pre8/src/PhysicsTools/Heppy/test/E21AD523-E548-E411-8DF6-00261894388F.root", files=miniAodFiles(), name="ATEST", isMC=False, isEmbed=False) # the following is declared in case this cfg is used in input to the heppy.py script selectedComponents = [sample] from PhysicsTools.HeppyCore.framework.eventsfwlite import Events config = cfg.Config(components=selectedComponents, sequence=sequence, events_class=Events) # and the following runs the process directly if __name__ == '__main__': from PhysicsTools.HeppyCore.framework.looper import Looper looper = Looper('Loop', sample, sequence, Events, nPrint=5) looper.loop() looper.write()
logging.basicConfig(level=logging.INFO) import random random.seed(0xdeadbeef) def process(iev=None): if iev is None: iev = loop.iEvent loop.process(iev) if display: display.draw() def next(): loop.process(loop.iEvent + 1) if display: display.draw() iev = None if len(sys.argv) == 2: iev = int(sys.argv[1]) loop = Looper('looper', config, nEvents=500, nPrint=5, timeReport=True) pfsim = loop.analyzers[1] display = getattr(pfsim, 'display', None) simulator = pfsim.simulator detector = simulator.detector if iev is not None: process(iev) else: loop.loop() loop.write()
import sys, os sys.path.append(os.environ.get("CMSSW_BASE") + "/src/VHbbAnalysis/Heppy/test") from vhbb_combined import * components = [ cfg.MCComponent( files = [ "root://xrootd-cms.infn.it///store/mc/RunIISpring15DR74/ttHTobb_M125_13TeV_powheg_pythia8/MINIAODSIM/Asympt25ns_MCRUN2_74_V9-v1/00000/141B9915-1F08-E511-B9FF-001E675A6AB3.root" ], name = "tth_hbb", isMC = True ), cfg.MCComponent( files = [ "root://xrootd-cms.infn.it///store/mc/RunIISpring15DR74/TT_TuneCUETP8M1_13TeV-powheg-pythia8/MINIAODSIM/Asympt25ns_MCRUN2_74_V9-v2/00000/0AB045B5-BB0C-E511-81FD-0025905A60B8.root" ], name = "ttjets", isMC = True ) ] if __name__ == '__main__': from PhysicsTools.HeppyCore.framework.looper import Looper for comp in components: print "processing",comp config.components = [comp] looper = Looper( 'Loop_validation_tth_sl_dl_' + comp.name, config, nPrint = 0, nEvents = 10) looper.loop() looper.write()