def runLoop( comp, outDir, config, options): if options.input is not None: comp.files = [options.input] fullName = '/'.join( [outDir, comp.name ] ) # import pdb; pdb.set_trace() 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
class TestAnalysis_ee_ZH(unittest.TestCase): def setUp(self): random.seed(0xDEADBEEF) self.outdir = tempfile.mkdtemp() fname = "/".join([os.environ["HEPPY"], "test/data/ee_ZH_Zmumu_Hbb.root"]) config.components[0].files = [fname] self.looper = Looper(self.outdir, config, nEvents=50, nPrint=0, timeReport=True) import logging logging.disable(logging.CRITICAL) def tearDown(self): shutil.rmtree(self.outdir) logging.disable(logging.NOTSET) def test_analysis(self): """Check for an almost perfect match with reference. Will fail if physics algorithms are modified, so should probably be removed from test suite, or better: be made optional. """ self.looper.loop() self.looper.write() rootfile = "/".join([self.outdir, "heppy.analyzers.examples.zh.ZHTreeProducer.ZHTreeProducer_1/tree.root"]) mean, sigma = plot(rootfile) self.assertAlmostEqual(mean, 120.7, 1) self.assertAlmostEqual(sigma, 20.3, 1) def test_analysis_sorting(self): self.looper.process(0) self.assertTrue(test_sorted(self.looper.event.rec_particles))
def test_process_event(self): loop = Looper( self.outdir, config, nEvents=None, nPrint=0 ) loop.process(10) self.assertEqual(loop.event.input.var1, 10) loop.process(10)
def test_analysis_sorting(self): fname = '/'.join([os.environ['HEPPY'], 'test/data/ee_ZH_Zmumu_Hbb.root']) config.components[0].files = [fname] looper = Looper( self.outdir, config, nEvents=50, nPrint=0 ) looper.process(0) self.assertTrue(test_sorted(looper.event.rec_particles))
def runLoop( comp, outDir, config, options): fullName = '/'.join( [outDir, comp.name ] ) # import pdb; pdb.set_trace() loop = Looper( fullName, comp, config.sequence, config.events_class, options.nevents, 0, nPrint = options.nprint) 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 ] ) # import pdb; pdb.set_trace() config.components = [comp] loop = Looper( fullName, config, options.nevents, 0, nPrint = options.nprint, timeReport = True, 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
# sel_iso_leptons, # match_jet_leptons, # sel_jets_nolepton, # m3, # gen_tree ] ) # comp.files.append('example_2.root') # comp.splitFactor = 2 # splitting the component in 2 chunks config = cfg.Config( components = selectedComponents, sequence = sequence, services = [], events_class = Events ) if __name__ == '__main__': import sys from heppy.framework.looper import Looper def next(): loop.process(loop.iEvent+1) loop = Looper( 'looper', config, nEvents=100, nPrint=0, timeReport=True) loop.process(6) print loop.event
jets_trk02_1000, jets_trk04_1000, jets_trk08_1000, electrons_500, muons_500, tree, ] ) config = cfg.Config( components = selectedComponents, sequence = sequence, services = [], events_class = Events ) if __name__ == '__main__': import sys from heppy.framework.looper import Looper def next(): loop.process(loop.iEvent+1) loop = Looper( 'looper', config, nEvents=100, nPrint=0, timeReport=True) loop.process(6) print loop.event
def test_process_event(self): loop = Looper(self.outdir, config, nEvents=None, nPrint=0) loop.process(10) self.assertEqual(loop.event.input.var1, 10) loop.process(10)