class TestAnalysis_ee_Z_bb_fccsw(unittest.TestCase):

        def setUp(self):
            random.seed(0xdeadbeef)
            self.outdir = tempfile.mkdtemp()
            import logging
            logging.disable(logging.CRITICAL)

        def tearDown(self):
            shutil.rmtree(self.outdir)
            logging.disable(logging.NOTSET)

        def test_beff_cms_fccsw(self):
            '''check that the analysis runs with papas inputs from cmssw
            '''
            from heppy.papas.detectors.CMS import cms
            fname = '/'.join([os.environ['HEPPY'],
                              'test/data/ee_Z_bbbar_with_papas_rec.root'])
            config.components[0].files = [fname]
            for s in config.sequence:
                if hasattr( s,'detector'):
                    s.detector = cms
            self.looper = Looper( self.outdir, config,
                                  nEvents=100,
                                  nPrint=0 )
            self.looper.loop()
Example #2
0
class TestAnalysis_ee_Z(unittest.TestCase):

    def setUp(self):
        random.seed(0xdeadbeef)
        self.outdir = tempfile.mkdtemp()
        fname = '/'.join([os.environ['HEPPY'],
                          'test/data/ee_Z_ddbar.root'])
        config.components[0].files = [fname]
        self.looper = Looper( self.outdir, config,
                              nEvents=100,
                              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.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'])
        mean, sigma = plot(rootfile)
        self.assertAlmostEqual(mean, 90.13, 1)
        self.assertAlmostEqual(sigma, 10.54, 1)
Example #3
0
 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)
Example #4
0
 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))
Example #5
0
 def test_skip(self):
     first = 10 
     loop = Looper( self.outdir, config,
                    nEvents=None,
                    firstEvent=first,
                    nPrint=0 )
     loop.loop()
     loop.write()
     # input file has 200 entries
     # we skip 10 entries, so we process 190.
     self.assertEqual(loop.nEvProcessed, self.nevents-first)
 def test_1(self):
     '''
     '''
     fname = '/'.join([os.environ['HEPPY'],
                       'test/data/ee_ZZ_4mu.root'])
     config.components[0].files = [fname]
     looper = Looper( self.outdir, config,
                      nEvents=50,
                      nPrint=0 )
     looper.loop()
     looper.write()
Example #7
0
 def test_all_events_processed(self):
     loop = Looper( self.outdir, config,
                    nEvents=None,
                    nPrint=0 )
     loop.loop()
     loop.write()
     logfile = open('/'.join([self.outdir, 'log.txt']))
     nev_processed = None
     for line in logfile:
         if line.startswith('number of events processed:'):
             nev_processed = int(line.split(':')[1])
     logfile.close()
     self.assertEqual(nev_processed, self.nevents)
     # checking the looper itself.
     self.assertEqual(loop.nEvProcessed, self.nevents)
Example #8
0
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
Example #9
0
    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)
Example #10
0
    class TestAnalysis_ee_Z(unittest.TestCase):

        def setUp(self):
            random.seed(0xdeadbeef)
            self.outdir = tempfile.mkdtemp()
            import logging
            #Alice: I turned this off otherwise no pdebug output. Ask Colin why it is on and if this is OK
            #logging.disable(logging.CRITICAL)

        def tearDown(self):
            shutil.rmtree(self.outdir)
            logging.disable(logging.NOTSET)

        
        # NB If this test fails and If you expected the physics results to change 
        # then it means that the cpp version of papas will need to be updated.
        # Please
        # (1) take the physics_clic.txt file that is produced by this test and rename it to update
        # the required_clic_physics_dd.txt file in heppy/test/data
        # (2) notify alice to change papas cpp
        def test_z_clic(self):
            '''Check Z mass in ee->Z->ddbar (CLIC).
            Will fail if physics algorithms are modified,
            so should probably be removed from test suite,
            or better: be made optional. 
            '''
            random.seed(0xdeadbeef)
            from heppy.papas.detectors.CLIC import clic
            fname = '/'.join([os.environ['HEPPY'],
                                      'test/data/ee_Z_ddbar.root'])
            config.components[0].files = [fname]
            for s in config.sequence:
                if hasattr( s,'detector'):
                    s.detector = clic
                if hasattr(s, 'debug_filename'):
                    s.debug_filename = 'physics_clic.txt'
            self.looper = Looper( self.outdir, config,
                                  nEvents=10,
                                  nPrint=0 )            
            self.looper.loop()
            self.looper.write()
            self.assertEqual(0,os.system("source $HEPPY/test/data/pdebug_python_check.sh  physics_clic.txt $HEPPY/test/data/required_clic_physics_dd.txt"))
Example #11
0
 def setUp(self):
     random.seed(0xdeadbeef)
     self.outdir = tempfile.mkdtemp()
     fname = '/'.join([os.environ['HEPPY'],
                       'test/data/ee_Z_ddbar.root'])
     config.components[0].files = [fname]
     self.looper = Looper( self.outdir, config,
                           nEvents=100,
                           nPrint=0,
                           timeReport=True)
     import logging
     logging.disable(logging.CRITICAL)
Example #12
0
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))
Example #13
0
class TestAnalysis_ee_Z_bb(unittest.TestCase):

    def setUp(self):
        random.seed(0xdeadbeef)
        self.outdir = tempfile.mkdtemp()
        import logging
        logging.disable(logging.CRITICAL)

    def tearDown(self):
        shutil.rmtree(self.outdir)
        logging.disable(logging.NOTSET)

    def test_beff_cms(self):
        '''Check b matching probability and b tag efficiency in CMS 
        '''
        from heppy.papas.detectors.CMS import cms
        fname = '/'.join([os.environ['HEPPY'],
                          'test/data/ee_Z_bbbar.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr( s,'detector'):
                s.detector = cms
        self.looper = Looper( self.outdir, config,
                              nEvents=500,
                              nPrint=0 )
        self.looper.loop()
        self.looper.write()
        rootfile = '/'.join([self.outdir,
                            'heppy.analyzers.JetTreeProducer.JetTreeProducer_1/jet_tree.root '])
        plotter = Plotter(rootfile)
        self.assertAlmostEqual(plotter.bfrac(), 0.867, places=2)
        self.assertAlmostEqual(plotter.beff(), 0.71, places=2)

    def test_fake_cms(self):
        '''Check fake rate in CMS
        '''
        from heppy.papas.detectors.CMS import cms
        fname = '/'.join([os.environ['HEPPY'],
                          'test/data/ee_Z_ddbar.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr( s,'detector'):
                s.detector = cms
        self.looper = Looper( self.outdir, config,
                              nEvents=100,
                              nPrint=0 )
        self.looper.loop()
        self.looper.write()
        rootfile = '/'.join([self.outdir,
                             'heppy.analyzers.JetTreeProducer.JetTreeProducer_1/jet_tree.root '])
Example #14
0
 def test_analysis_ee_ZH_mumubb(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. 
     '''
     from heppy.papas.detectors.CMS import cms
     for s in config.sequence:
         if hasattr( s,'detector'):
             s.detector = cms
         if hasattr(s, 'debug_filename'):
             s.debug_filename = 'physics_cms.txt'
     # import pdb; pdb.set_trace()
     fname = '/'.join([os.environ['HEPPY'],
                               'test/data/ee_ZH_Zmumu_Hbb.root'])
     config.components[0].files = [fname]
     looper = Looper( self.outdir, config,
                                   nEvents=10,
                                   nPrint=0 )
     looper.loop()
     looper.write()
     self.assertEqual(0,os.system("source $HEPPY/test/data/pdebug_python_check.sh  physics_cms.txt $HEPPY/test/data/required_cms_physics.txt"))
 def test_beff_cms_fccsw(self):
     '''check that the analysis runs with papas inputs from cmssw
     '''
     from heppy.papas.detectors.CMS import cms
     fname = '/'.join([os.environ['HEPPY'],
                       'test/data/ee_Z_bbbar_with_papas_rec.root'])
     config.components[0].files = [fname]
     for s in config.sequence:
         if hasattr( s,'detector'):
             s.detector = cms
     self.looper = Looper( self.outdir, config,
                           nEvents=100,
                           nPrint=0 )
     self.looper.loop()
Example #16
0
 def test_z_2_clic(self):
     '''Check Z mass in ee->Z->ddbar (CLIC).
     Will fail if physics algorithms are modified,
     so should probably be removed from test suite,
     or better: be made optional. 
     '''
     from heppy.papas.detectors.CLIC import clic
     fname = '/'.join(
         [os.environ['HEPPY'], 'test/data/ee_Z_ddbar.root'])
     config.components[0].files = [fname]
     for s in config.sequence:
         if hasattr(s, 'detector'):
             s.detector = clic
     self.looper = Looper(self.outdir, config, nEvents=100, nPrint=0)
     self.looper.loop()
     self.looper.write()
     rootfile = '/'.join([
         self.outdir,
         'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'
     ])
     mean, sigma = plot_ee_mass(rootfile)
     self.assertAlmostEqual(mean, 87.45, 1)
     self.assertAlmostEqual(sigma, 3.75, 1)
Example #17
0
class TestAnalysis(unittest.TestCase):

    def setUp(self):
        random.seed(0xdeadbeef)
        self.outdir = tempfile.mkdtemp()
        # logging.disable(logging.CRITICAL)

    def tearDown(self):
        shutil.rmtree(self.outdir)
        # logging.disable(logging.NOTSET)

    def test_1(self):
        '''Check that the ZH->nunubb analysis runs
        '''
        config.components = config.components[:1]
        config.components[0].files = config.components[0].files[:1]
        nevts = 100 
        self.looper = Looper( self.outdir,
                              config,
                              nEvents=nevts,
                              nPrint=0)
        self.looper.loop()
        self.looper.write()
class TestAnalysis_ee_Z_bb_fccsw(unittest.TestCase):
    def setUp(self):
        random.seed(0xdeadbeef)
        self.outdir = tempfile.mkdtemp()
        import logging
        logging.disable(logging.CRITICAL)

    def tearDown(self):
        shutil.rmtree(self.outdir)
        logging.disable(logging.NOTSET)

    def test_beff_cms_fccsw(self):
        '''check that the analysis runs with papas inputs from cmssw
        '''
        from heppy.papas.detectors.CMS import cms
        fname = '/'.join(
            [os.environ['HEPPY'], 'test/data/ee_Z_bbbar_with_papas_rec.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr(s, 'detector'):
                s.detector = cms
        self.looper = Looper(self.outdir, config, nEvents=100, nPrint=0)
        self.looper.loop()
Example #19
0
class TestAnalysis_ee_Z_bb(unittest.TestCase):
    def setUp(self):
        random.seed(0xdeadbeef)
        self.outdir = tempfile.mkdtemp()
        import logging
        logging.disable(logging.CRITICAL)

    def tearDown(self):
        shutil.rmtree(self.outdir)
        logging.disable(logging.NOTSET)

    def test_beff_cms(self):
        '''Check b matching probability and b tag efficiency in CMS 
        '''
        from heppy.papas.detectors.CMS import cms
        fname = '/'.join([os.environ['HEPPY'], 'test/data/ee_Z_bbbar.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr(s, 'detector'):
                s.detector = cms
        self.looper = Looper(self.outdir, config, nEvents=500, nPrint=0)
        self.looper.loop()
        self.looper.write()
        rootfile = '/'.join([
            self.outdir,
            'heppy.analyzers.JetTreeProducer.JetTreeProducer_1/jet_tree.root '
        ])
        plotter = Plotter(rootfile)
        self.assertAlmostEqual(plotter.bfrac(), 0.867, places=2)
        self.assertAlmostEqual(plotter.beff(), 0.71, places=2)

    def test_fake_cms(self):
        '''Check fake rate in CMS
        '''
        from heppy.papas.detectors.CMS import cms
        fname = '/'.join([os.environ['HEPPY'], 'test/data/ee_Z_ddbar.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr(s, 'detector'):
                s.detector = cms
        self.looper = Looper(self.outdir, config, nEvents=100, nPrint=0)
        self.looper.loop()
        self.looper.write()
        rootfile = '/'.join([
            self.outdir,
            'heppy.analyzers.JetTreeProducer.JetTreeProducer_1/jet_tree.root '
        ])
 def test_ZZ_nunubb(self):
     '''Check that the ZH nunubb analysis runs
     '''
     from analysis_ee_ZH_nunubb_cfg import config
     fname = 'samples/test/ee_ZZ_nunu.root'
     config.components[0].files = [fname]
     looper = Looper(self.outdir, config, nEvents=100, nPrint=0)
     looper.loop()
     looper.write()
Example #21
0
 def test_process_event(self):
     loop = Looper(self.outdir,
                   config,
                   nEvents=None,
                   nPrint=0,
                   timeReport=True)
     loop.process(10)
     self.assertEqual(loop.event.input.var1, 10)
     loop.process(10)
Example #22
0
 def test_z_clic(self):
     '''Check Z mass in ee->Z->ddbar (CLIC).
     Will fail if physics algorithms are modified,
     so should probably be removed from test suite,
     or better: be made optional. 
     '''
     random.seed(0xdeadbeef)
     from heppy.papas.detectors.CLIC import clic
     fname = '/'.join(
         [os.environ['HEPPY'], 'test/data/ee_Z_ddbar.root'])
     config.components[0].files = [fname]
     for s in config.sequence:
         if hasattr(s, 'detector'):
             s.detector = clic
         if hasattr(s, 'debug_filename'):
             s.debug_filename = 'physics_clic.txt'
     self.looper = Looper(self.outdir, config, nEvents=10, nPrint=0)
     self.looper.loop()
     self.looper.write()
     self.assertEqual(
         0,
         os.system(
             "source $HEPPY/test/data/pdebug_python_check.sh  physics_clic.txt $HEPPY/test/data/required_clic_physics_dd.txt"
         ))
Example #23
0
    class TestAnalysis_ee_Z(unittest.TestCase):
        def setUp(self):
            random.seed(0xdeadbeef)
            self.outdir = tempfile.mkdtemp()
            import logging
            #Alice: I turned this off otherwise no pdebug output. Ask Colin why it is on and if this is OK
            #logging.disable(logging.CRITICAL)

        def tearDown(self):
            shutil.rmtree(self.outdir)
            logging.disable(logging.NOTSET)

        def test_z_clic(self):
            '''Check Z mass in ee->Z->ddbar (CLIC).
            Will fail if physics algorithms are modified,
            so should probably be removed from test suite,
            or better: be made optional. 
            '''
            random.seed(0xdeadbeef)
            from heppy.papas.detectors.CLIC import clic
            fname = '/'.join(
                [os.environ['HEPPY'], 'test/data/ee_Z_ddbar.root'])
            config.components[0].files = [fname]
            for s in config.sequence:
                if hasattr(s, 'detector'):
                    s.detector = clic
                if hasattr(s, 'debug_filename'):
                    s.debug_filename = 'physics_clic.txt'
            self.looper = Looper(self.outdir, config, nEvents=10, nPrint=0)
            self.looper.loop()
            self.looper.write()
            self.assertEqual(
                0,
                os.system(
                    "source $HEPPY/test/data/pdebug_python_check.sh  physics_clic.txt $HEPPY/test/data/required_clic_physics_dd.txt"
                ))
Example #24
0
 def test_z_mumu_cms(self):
     '''Test Z->mumu with CMS
     '''
     from heppy.papas.detectors.CMS import cms
     fname = '/'.join([os.environ['HEPPY'],
                               'test/data/ee_Z_mumu.root'])
     config.components[0].files = [fname]
     for s in config.sequence:
         if hasattr( s,'detector'):
             s.detector = cms
     self.looper = Looper( self.outdir, config,
                           nEvents=10,
                           nPrint=0 )
     self.looper.loop()
     self.looper.write()
Example #25
0
 def test_analysis_ee_ZH_mumubb(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. 
     '''
     from heppy.papas.detectors.CMS import cms
     for s in config.sequence:
         if hasattr( s,'detector'):
             s.detector = cms
     # import pdb; pdb.set_trace()
     fname = '/'.join([os.environ['HEPPY'],
                               'test/data/ee_ZH_Zmumu_Hbb.root'])
     config.components[0].files = [fname]
     looper = Looper( self.outdir, config,
                                   nEvents=100,
                                   nPrint=0 )
     looper.loop()
     looper.write()
     rootfile = '/'.join([self.outdir,
                         'heppy.analyzers.examples.zh.ZHTreeProducer.ZHTreeProducer_1/tree.root'])
     mean, sigma = plot(rootfile)
     self.assertAlmostEqual(mean, 110.87, 1)
     self.assertAlmostEqual(sigma, 18.6, 1)
Example #26
0
 def test_fake_cms(self):
     '''Check fake rate in CMS
     '''
     from heppy.papas.detectors.CMS import cms
     fname = '/'.join([os.environ['HEPPY'],
                       'test/data/ee_Z_ddbar.root'])
     config.components[0].files = [fname]
     for s in config.sequence:
         if hasattr( s,'detector'):
             s.detector = cms
     self.looper = Looper( self.outdir, config,
                           nEvents=100,
                           nPrint=0 )
     self.looper.loop()
     self.looper.write()
     rootfile = '/'.join([self.outdir,
                          'heppy.analyzers.JetTreeProducer.JetTreeProducer_1/jet_tree.root '])
Example #27
0
 def test_skip(self):
     first = 10
     loop = Looper(self.outdir,
                   config,
                   nEvents=None,
                   firstEvent=first,
                   nPrint=0)
     loop.loop()
     loop.write()
     # input file has 200 entries
     # we skip 10 entries, so we process 190.
     self.assertEqual(loop.nEvProcessed, self.nevents - first)
Example #28
0
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
Example #29
0
 def test_all_events_processed(self):
     loop = Looper(self.outdir, config, nEvents=None, nPrint=0)
     loop.loop()
     loop.write()
     logfile = open('/'.join([self.outdir, 'log.txt']))
     nev_processed = None
     for line in logfile:
         if line.startswith('number of events processed:'):
             nev_processed = int(line.split(':')[1])
     logfile.close()
     self.assertEqual(nev_processed, self.nevents)
     # checking the looper itself.
     self.assertEqual(loop.nEvProcessed, self.nevents)
Example #30
0
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
Example #31
0
 def test_beff_cms(self):
     '''Check b matching probability and b tag efficiency in CMS 
     '''
     from heppy.papas.detectors.CMS import cms
     fname = '/'.join([os.environ['HEPPY'],
                       'test/data/ee_Z_bbbar.root'])
     config.components[0].files = [fname]
     for s in config.sequence:
         if hasattr( s,'detector'):
             s.detector = cms
     self.looper = Looper( self.outdir, config,
                           nEvents=500,
                           nPrint=0 )
     self.looper.loop()
     self.looper.write()
     rootfile = '/'.join([self.outdir,
                         'heppy.analyzers.JetTreeProducer.JetTreeProducer_1/jet_tree.root '])
     plotter = Plotter(rootfile)
     self.assertAlmostEqual(plotter.bfrac(), 0.867, places=2)
     self.assertAlmostEqual(plotter.beff(), 0.71, places=2)
Example #32
0
 def test_z_clic(self):
     '''Check Z mass in ee->Z->ddbar (CLIC).
     Will fail if physics algorithms are modified,
     so should probably be removed from test suite,
     or better: be made optional. 
     '''
     random.seed(0xdeadbeef)
     from heppy.papas.detectors.CLIC import clic
     fname = '/'.join([os.environ['HEPPY'],
                               'test/data/ee_Z_ddbar.root'])
     config.components[0].files = [fname]
     for s in config.sequence:
         if hasattr( s,'detector'):
             s.detector = clic
         if hasattr(s, 'debug_filename'):
             s.debug_filename = 'physics_clic.txt'
     self.looper = Looper( self.outdir, config,
                           nEvents=10,
                           nPrint=0 )            
     self.looper.loop()
     self.looper.write()
     self.assertEqual(0,os.system("source $HEPPY/test/data/pdebug_python_check.sh  physics_clic.txt $HEPPY/test/data/required_clic_physics_dd.txt"))
Example #33
0
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
Example #34
0
 def test_z_2_clic(self):
     '''Check Z mass in ee->Z->ddbar (CLIC).
     Will fail if physics algorithms are modified,
     so should probably be removed from test suite,
     or better: be made optional. 
     '''
     from heppy.papas.detectors.CLIC import clic
     fname = '/'.join([os.environ['HEPPY'],
                               'test/data/ee_Z_ddbar.root'])
     config.components[0].files = [fname]
     for s in config.sequence:
         if hasattr( s,'detector'):
             s.detector = clic
     self.looper = Looper( self.outdir, config,
                           nEvents=100,
                           nPrint=0 )            
     self.looper.loop()
     self.looper.write()
     rootfile = '/'.join([self.outdir,
                         'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'])
     mean, sigma = plot_ee_mass(rootfile)
     self.assertAlmostEqual(mean, 90.15, 1)
     self.assertAlmostEqual(sigma, 3.3, 1)
Example #35
0
 def test_analysis_ee_ZH_mumubb(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. 
     '''
     from heppy.papas.detectors.CMS import cms
     config.sequence[2].detector = cms
     # import pdb; pdb.set_trace()
     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.loop()
     looper.write()
     rootfile = '/'.join([
         self.outdir,
         'heppy.analyzers.examples.zh.ZHTreeProducer.ZHTreeProducer_1/tree.root'
     ])
     mean, sigma = plot(rootfile)
     self.assertAlmostEqual(mean, 113.3, 1)
     self.assertAlmostEqual(sigma, 21.2, 1)
Example #36
0
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_analysis_ee_ZH_mumubb(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. 
     '''
     from heppy.papas.detectors.CMS import cms
     for s in config.sequence:
         if hasattr(s, 'detector'):
             s.detector = cms
         if hasattr(s, 'debug_filename'):
             s.debug_filename = 'physics_cms.txt'
     # import pdb; pdb.set_trace()
     fname = '/'.join(
         [os.environ['HEPPY'], 'test/data/ee_ZH_Zmumu_Hbb.root'])
     config.components[0].files = [fname]
     looper = Looper(self.outdir, config, nEvents=10, nPrint=0)
     looper.loop()
     looper.write()
     self.assertEqual(
         0,
         os.system(
             "source $HEPPY/test/data/pdebug_python_check.sh  physics_cms.txt $HEPPY/test/data/required_cms_physics.txt"
         ))
Example #38
0
    class TestAnalysis_ee_Z(unittest.TestCase):
        def setUp(self):
            random.seed(0xdeadbeef)
            self.outdir = tempfile.mkdtemp()
            import logging
            logging.disable(logging.CRITICAL)

        def tearDown(self):
            shutil.rmtree(self.outdir)
            logging.disable(logging.NOTSET)

        def test_z_1_cms(self):
            '''Check Z mass in ee->Z->ddbar (CMS).
            Will fail if physics algorithms are modified,
            so should probably be removed from test suite,
            or better: be made optional. 
            '''
            from heppy.papas.detectors.CMS import cms
            fname = '/'.join(
                [os.environ['HEPPY'], 'test/data/ee_Z_ddbar.root'])
            config.components[0].files = [fname]
            for s in config.sequence:
                if hasattr(s, 'detector'):
                    s.detector = cms
            self.looper = Looper(self.outdir, config, nEvents=100, nPrint=0)
            self.looper.loop()
            self.looper.write()
            rootfile = '/'.join([
                self.outdir,
                'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'
            ])
            mean, sigma = plot_ee_mass(rootfile)
            self.assertAlmostEqual(mean, 77.26, 1)
            self.assertAlmostEqual(sigma, 8.27, 1)

        def test_z_2_clic(self):
            '''Check Z mass in ee->Z->ddbar (CLIC).
            Will fail if physics algorithms are modified,
            so should probably be removed from test suite,
            or better: be made optional. 
            '''
            from heppy.papas.detectors.CLIC import clic
            fname = '/'.join(
                [os.environ['HEPPY'], 'test/data/ee_Z_ddbar.root'])
            config.components[0].files = [fname]
            for s in config.sequence:
                if hasattr(s, 'detector'):
                    s.detector = clic
            self.looper = Looper(self.outdir, config, nEvents=100, nPrint=0)
            self.looper.loop()
            self.looper.write()
            rootfile = '/'.join([
                self.outdir,
                'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'
            ])
            mean, sigma = plot_ee_mass(rootfile)
            self.assertAlmostEqual(mean, 86.48, 1)
            self.assertAlmostEqual(sigma, 6.21, 1)

        def test_z_mumu_clic(self):
            '''Check Z mass in ee->Z->mumu (CLIC).
            Will fail if physics algorithms are modified,
            so should probably be removed from test suite,
            or better: be made optional. 
            '''
            from heppy.papas.detectors.CLIC import clic
            fname = '/'.join([os.environ['HEPPY'], 'test/data/ee_Z_mumu.root'])
            config.components[0].files = [fname]
            for s in config.sequence:
                if hasattr(s, 'detector'):
                    s.detector = clic
            self.looper = Looper(self.outdir, config, nEvents=500, nPrint=0)
            self.looper.loop()
            self.looper.write()
            rootfile = '/'.join([
                self.outdir,
                'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'
            ])
            mean, sigma = plot_ee_mass(rootfile, nbins=400, xmin=70, xmax=110)
            self.assertAlmostEqual(mean, 90.84, 1)
            self.assertAlmostEqual(sigma, 1.32, 1)

        def test_z_ee_clic(self):
            '''Check Z mass in ee->Z->ee (CLIC).
            Will fail if physics algorithms are modified,
            so should probably be removed from test suite,
            or better: be made optional. 
            '''
            from heppy.papas.detectors.CLIC import clic
            fname = '/'.join([os.environ['HEPPY'], 'test/data/ee_Z_ee.root'])
            config.components[0].files = [fname]
            for s in config.sequence:
                if hasattr(s, 'detector'):
                    s.detector = clic
            self.looper = Looper(self.outdir, config, nEvents=500, nPrint=0)
            self.looper.loop()
            self.looper.write()
            rootfile = '/'.join([
                self.outdir,
                'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'
            ])
            mean, sigma = plot_ee_mass(rootfile, nbins=400, xmin=70, xmax=110)
            self.assertAlmostEqual(mean, 90.77, 1)
            self.assertAlmostEqual(sigma, 2.00, 1)
Example #39
0
class TestAnalysis_ee_Z(unittest.TestCase):

    def setUp(self):
        random.seed(0xdeadbeef)
        self.outdir = tempfile.mkdtemp()
        import logging
        logging.disable(logging.CRITICAL)

    def tearDown(self):
        shutil.rmtree(self.outdir)
        logging.disable(logging.NOTSET)

    def test_z_1_cms(self):
        '''Check Z mass in ee->Z->ddbar (CMS).
        Will fail if physics algorithms are modified,
        so should probably be removed from test suite,
        or better: be made optional. 
        '''
        from heppy.papas.detectors.CMS import cms
        fname = '/'.join([os.environ['HEPPY'],
                                  'test/data/ee_Z_ddbar.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr( s,'detector'):
                s.detector = cms
        self.looper = Looper( self.outdir, config,
                              nEvents=100,
                              nPrint=0 )
        self.looper.loop()
        self.looper.write()
        rootfile = '/'.join([self.outdir,
                            'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'])
        mean, sigma = plot_ee_mass(rootfile)
        self.assertAlmostEqual(mean, 83.58, 1)
        self.assertAlmostEqual(sigma, 7.06, 1)

    def test_z_ee_cms(self):
        '''Test Z->ee with CMS
        '''
        from heppy.papas.detectors.CMS import cms
        fname = '/'.join([os.environ['HEPPY'],
                                  'test/data/ee_Z_ee.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr( s,'detector'):
                s.detector = cms
        self.looper = Looper( self.outdir, config,
                              nEvents=10,
                              nPrint=0 )
        self.looper.loop()
        self.looper.write()

    def test_z_mumu_cms(self):
        '''Test Z->mumu with CMS
        '''
        from heppy.papas.detectors.CMS import cms
        fname = '/'.join([os.environ['HEPPY'],
                                  'test/data/ee_Z_mumu.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr( s,'detector'):
                s.detector = cms
        self.looper = Looper( self.outdir, config,
                              nEvents=10,
                              nPrint=0 )
        self.looper.loop()
        self.looper.write()


    def test_z_2_clic(self):
        '''Check Z mass in ee->Z->ddbar (CLIC).
        Will fail if physics algorithms are modified,
        so should probably be removed from test suite,
        or better: be made optional. 
        '''
        from heppy.papas.detectors.CLIC import clic
        fname = '/'.join([os.environ['HEPPY'],
                                  'test/data/ee_Z_ddbar.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr( s,'detector'):
                s.detector = clic
        self.looper = Looper( self.outdir, config,
                              nEvents=100,
                              nPrint=0 )            
        self.looper.loop()
        self.looper.write()
        rootfile = '/'.join([self.outdir,
                            'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'])
        mean, sigma = plot_ee_mass(rootfile)
        self.assertAlmostEqual(mean, 90.15, 1)
        self.assertAlmostEqual(sigma, 3.3, 1)

    def test_z_mumu_clic(self):
        '''Check Z mass in ee->Z->mumu (CLIC).
        Will fail if physics algorithms are modified,
        so should probably be removed from test suite,
        or better: be made optional. 
        '''
        from heppy.papas.detectors.CLIC import clic
        fname = '/'.join([os.environ['HEPPY'],
                                  'test/data/ee_Z_mumu.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr( s,'detector'):
                s.detector = clic
        self.looper = Looper( self.outdir, config,
                              nEvents=500,
                              nPrint=0 )            
        self.looper.loop()
        self.looper.write()
        rootfile = '/'.join([self.outdir,
                            'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'])
        mean, sigma = plot_ee_mass(rootfile, nbins=400, xmin=70, xmax=110)
        self.assertAlmostEqual(mean, 90.80, 1)
        self.assertAlmostEqual(sigma, 2.7, 1)

    def test_z_ee_clic(self):
        '''Check Z mass in ee->Z->ee (CLIC).
        Will fail if physics algorithms are modified,
        so should probably be removed from test suite,
        or better: be made optional. 
        '''
        from heppy.papas.detectors.CLIC import clic
        fname = '/'.join([os.environ['HEPPY'],
                                  'test/data/ee_Z_ee.root'])
        config.components[0].files = [fname]
        for s in config.sequence:
            if hasattr( s,'detector'):
                s.detector = clic
        self.looper = Looper( self.outdir, config,
                              nEvents=500,
                              nPrint=0 )            
        self.looper.loop()
        self.looper.write()
        rootfile = '/'.join([self.outdir,
                            'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'])
        mean, sigma = plot_ee_mass(rootfile, nbins=400, xmin=70, xmax=110)
        self.assertAlmostEqual(mean, 90.67, 1)
        self.assertAlmostEqual(sigma, 5.05, 1)
Example #40
0
    class TestAnalysis_ee_Z(unittest.TestCase):
        def setUp(self):
            random.seed(0xdeadbeef)
            self.outdir = tempfile.mkdtemp()
            import logging
            logging.disable(logging.CRITICAL)

        def tearDown(self):
            shutil.rmtree(self.outdir)
            logging.disable(logging.NOTSET)

        def test_z_cms(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. 
            '''
            from heppy.papas.detectors.CMS import cms
            fname = '/'.join(
                [os.environ['HEPPY'], 'test/data/ee_Z_ddbar.root'])
            config.components[0].files = [fname]
            config.sequence[2].detector = cms
            self.looper = Looper(self.outdir, config, nEvents=100, nPrint=0)
            self.looper.loop()
            self.looper.write()
            rootfile = '/'.join([
                self.outdir,
                'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'
            ])
            mean, sigma = plot(rootfile)
            self.assertAlmostEqual(mean, 94.6, 1)
            self.assertAlmostEqual(sigma, 15.1, 1)

        def test_z_clic(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. 
            '''
            from heppy.papas.detectors.CLIC import clic
            fname = '/'.join(
                [os.environ['HEPPY'], 'test/data/ee_Z_ddbar.root'])
            config.components[0].files = [fname]
            config.sequence[2].detector = clic
            self.looper = Looper(self.outdir, config, nEvents=100, nPrint=0)
            self.looper.loop()
            self.looper.write()
            rootfile = '/'.join([
                self.outdir,
                'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'
            ])
            mean, sigma = plot(rootfile)
            self.assertAlmostEqual(mean, 83.24, 1)
            self.assertAlmostEqual(sigma, 7.37, 1)

        def test_z_mumu_clic(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. 
            '''
            from heppy.papas.detectors.CLIC import clic
            fname = '/'.join([os.environ['HEPPY'], 'test/data/ee_Z_mumu.root'])
            config.components[0].files = [fname]
            config.sequence[2].detector = clic
            self.looper = Looper(self.outdir, config, nEvents=500, nPrint=0)
            self.looper.loop()
            self.looper.write()
            rootfile = '/'.join([
                self.outdir,
                'heppy.analyzers.GlobalEventTreeProducer.GlobalEventTreeProducer_1/tree.root'
            ])
            mean, sigma = plot(rootfile, nbins=400)
            self.assertAlmostEqual(mean, 90.84, 1)
            self.assertAlmostEqual(sigma, 1.32, 1)
Example #41
0
 def test_gun(self):
     '''test that the particle gun runs
     '''
     self.looper = Looper(self.outdir, config, nEvents=100, nPrint=0)
     self.looper.loop()
     self.looper.write()
Example #42
0
 heppy_loop.py OutDir/ analysis_ee_ZH_cfg.py -f -N 100 
 '''
 if len(sys.argv)==2:
     papas.display = True
     try:
         iev = int(sys.argv[1])
     except ValueError:
         print usage
         sys.exit(1)
 elif len(sys.argv)>2: 
     print usage
     sys.exit(1)
         
     
 loop = Looper( 'looper', config,
                nEvents=10,
                nPrint=5,
                timeReport=True)
 
 simulation = None
 for ana in loop.analyzers: 
     if hasattr(ana, 'display'):
         simulation = ana
 display = getattr(simulation, 'display', None)
 simulator = getattr(simulation, 'simulator', None)
 if simulator: 
     detector = simulator.detector
 if iev is not None:
     process(iev)
 else:
     loop.loop()
     loop.write()
Example #43
0
    # 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
Example #44
0
 def test_userstop(self):
     config_with_stopper = copy.copy(config)
     config_with_stopper.sequence.insert(1, stopper)
     loop = Looper(self.outdir, config_with_stopper, nEvents=None, nPrint=0)
     self.assertRaises(UserStop, loop.process, 10)
Example #45
0
        parser.error('incorrect number of arguments')
        
    cfgfilename = args[0]    
    config = load_config(cfgfilename)
    
    nevents = sys.maxint
    if options.nevents is not None and options.event is not None:
        raise ValueError('provide either the -i or the -n option, but not both')
    elif options.nevents is None and options.event is None:
        options.event = 0
    elif options.nevents is not None:
        nevents = options.nevents
    
    if options.event is not None:
        ievent = options.event
        display_config.do_display = True           
    else:
        display_config.do_display = False       
        

    loop = Looper( 'looper', config,
                   nEvents=nevents,
                   nPrint=sys.maxint,
                   timeReport=False)

    if options.event is not None: 
        process(ievent)
    else:
        loop.loop()
        loop.write()
Example #46
0
 def test_process_event(self):
     '''Test that indeed, calling loop.process(iev) raises
     TypeError if the events backend does not support indexing. 
     '''
     loop = Looper(self.outdir, config, nEvents=None, nPrint=0)
     self.assertRaises(TypeError, loop.process, 10)
Example #47
0
from heppy.framework.looper import Looper

if __name__ == '__main__':

    import pickle
    import sys
    import os
    import imp
    if len(sys.argv) == 2:
        cfgFileName = sys.argv[1]
        pckfile = open(cfgFileName, 'r')
        config = pickle.load(pckfile)
        comp = config.components[0]
        events_class = config.events_class
    elif len(sys.argv) == 3:
        cfgFileName = sys.argv[1]
        file = open(cfgFileName, 'r')
        cfg = imp.load_source('cfg', cfgFileName, file)
        compFileName = sys.argv[2]
        pckfile = open(compFileName, 'r')
        comp = pickle.load(pckfile)
        cfg.config.components = [comp]
        events_class = cfg.config.events_class
    else:
        print 'usage: looper.py <configuration_file.py> [component.pickle]'
        sys.exit(1)
    looper = Looper('Loop', cfg.config, nPrint=5)
    looper.loop()
    looper.write()
Example #48
0
    gen_tree,
    selected_muons,
    selected_electrons,
    selected_leptons,
    zeds,
    selection,
    higgses,
    reco_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)
    loop.process(6)
    print loop.event
Example #49
0
    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=nevents_per_job,
                  nPrint=0,
                  timeReport=True)
    # pfsim = loop.analyzers[1]
    # display = getattr(pfsim, 'display', None)
    display = None
    # simulator = pfsim.simulator
    # detector = simulator.detector
    if iev is not None:
        process(iev)
    else:
        loop.loop()
        loop.write()
Example #50
0
    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:
        papas.display = True
        iev = int(sys.argv[1])

    loop = Looper('looper', config, nEvents=100, nPrint=0, timeReport=True)
    simulation = loop.analyzers[2]
    display = getattr(simulation, 'display', None)
    simulator = simulation.simulator
    detector = simulator.detector
    if iev is not None:
        process(iev)
    else:
        loop.loop()
        loop.write()
Example #51
0
 def test_all_events_processed(self):
     loop = Looper( self.outdir, config,
                    nEvents=None,
                    nPrint=0 )
     loop.loop()
Example #52
0
    selected_photons,
    jets_20,
    match_jet_electrons,
    jets_noelectron,
    match_muon_jets,
    jets_nomuon,
    match_photon_jets,
    jets_nophoton,
    selected_bs,
    selected_lights,
    #photon_higgses,
    #b_higgses,
    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
Example #53
0
from heppy.framework.looper import Looper

if __name__ == '__main__':
    
    import pickle
    import sys
    import os
    import imp
    if len(sys.argv) == 2 :
        cfgFileName = sys.argv[1]
        pckfile = open( cfgFileName, 'r' )
        config = pickle.load( pckfile )
        comp = config.components[0]
        events_class = config.events_class
    elif len(sys.argv) == 3 :
        cfgFileName = sys.argv[1]
        file = open( cfgFileName, 'r' )
        cfg = imp.load_source( 'cfg', cfgFileName, file)
        compFileName = sys.argv[2]
        pckfile = open( compFileName, 'r' )
        comp = pickle.load( pckfile )
        cfg.config.components=[comp]
        events_class = cfg.config.events_class
    else:
        print 'usage: looper.py <configuration_file.py> [component.pickle]'
        sys.exit(1)
    looper = Looper( 'Loop', cfg.config,nPrint = 5)
    looper.loop()
    looper.write()