コード例 #1
0
    def setUp(self):
        self.listdir_org = os.listdir
        self.isdir_org = os.path.isdir
        os.listdir = mock_listdir
        os.path.isdir = mock_isdir

        path = 'dir/201522_SingleMu'
        self.heppy = HeppyResult(path)
        self.heppy._readVersionInfo = mock_readVersionInfo
コード例 #2
0
    def test_init_with_componentNames(self):
        path = 'dir/201522_SingleMu'
        componentNames = ['QCD_HT_100To250', 'QCD_HT_250To500']
        heppy = HeppyResult(path=path, componentNames=componentNames)

        expected = componentNames
        self.assertEqual(expected, heppy.componentNames)
コード例 #3
0
    def test_init_with_excludeList(self):
        path = 'dir/201522_SingleMu'
        excludeList = ('failed', 'QCD_HT_100To250')
        heppy = HeppyResult(path=path, excludeList=excludeList)

        expected = ['QCD_HT_250To500', 'TTJets']
        self.assertEqual(expected, heppy.componentNames)
コード例 #4
0
binning31 = Echo()
binning32 = Echo()
keyComposer3 = GenericKeyComposer(('nJet40', 'nBJet40'),
                                  (binning31, binning32))
nextKeyComposer3 = NextKeyComposer((binning31, binning32))
resultsCombinationMethod3 = CombineIntoList(('njets', 'nbjets'))
deliveryMethod3 = WriteListToFile(outPath3)
collector3 = Collector(resultsCombinationMethod3, deliveryMethod3)

eventBuilder = EventBuilder(analyzerName, fileName, treeName, args.nevents)

progressBar = ProgressBar()
progressMonitor = ProgressMonitor(progressBar)
progressReporter = progressMonitor.createReporter()

heppyResult = HeppyResult(args.heppydir)
for component in heppyResult.components():

    counts1 = Counts()
    counter1 = Counter(keyComposer1, counts1, nextKeyComposer1)
    collector1.addReader(component.name, counter1)

    counts2 = Counts()
    counter2 = Counter(keyComposer2, counts2, nextKeyComposer2)
    collector2.addReader(component.name, counter2)

    counts3 = Counts()
    counter3 = Counter(keyComposer3, counts3, nextKeyComposer3)
    collector3.addReader(component.name, counter3)

    events = eventBuilder.build(component)
コード例 #5
0
ファイル: print_280.py プロジェクト: eshwen/cutflowirl
progressBar = ProgressBar()
progressMonitor = BProgressMonitor(progressBar)
progressMonitor.begin()
communicationChannel = CommunicationChannel(8, progressMonitor)
communicationChannel.begin()
eventLoopRunner = MPEventLoopRunner(communicationChannel)

readers = ReaderComposite()
readers.add(counter1)
readers.add(counter2)
readers.add(counter3)

collectors = CollectorComposite(progressMonitor.createReporter())
collectors.add(collector1)
collectors.add(collector2)
collectors.add(collector3)

eventReader = EventReader(eventBuilder, eventLoopRunner, readers, collectors)

heppyResult = HeppyResult(args.heppydir)

componentReaderComposite = ComponentReaderComposite()
componentReaderComposite.add(eventReader)
componentLoop = ComponentLoop(heppyResult, componentReaderComposite)

componentLoop()
communicationChannel.end()
progressMonitor.end()

##__________________________________________________________________||
コード例 #6
0
 def test_trailing_slash(self):
     heppy = HeppyResult('dir/201522_SingleMu/')
     self.assertEqual('dir/201522_SingleMu', heppy.path)
コード例 #7
0
class TestHeppyResult(unittest.TestCase):
    def setUp(self):
        self.listdir_org = os.listdir
        self.isdir_org = os.path.isdir
        os.listdir = mock_listdir
        os.path.isdir = mock_isdir

        path = 'dir/201522_SingleMu'
        self.heppy = HeppyResult(path)
        self.heppy._readVersionInfo = mock_readVersionInfo

    def tearDown(self):
        os.listdir = self.listdir_org
        os.path.isdir = self.isdir_org

    def test_init(self):
        self.assertEqual('dir/201522_SingleMu', self.heppy.path)

    def test_trailing_slash(self):
        heppy = HeppyResult('dir/201522_SingleMu/')
        self.assertEqual('dir/201522_SingleMu', heppy.path)

    def test_componentNames(self):
        expected = ['QCD_HT_100To250', 'QCD_HT_250To500', 'TTJets']
        self.assertEqual(expected, self.heppy.componentNames)

    def test_components_theSameObject(self):
        comp1 = self.heppy.QCD_HT_100To250
        comp2 = self.heppy.QCD_HT_100To250
        self.assertIs(comp1, comp2)

    def test_AttributeError(self):
        self.assertRaises(AttributeError, self.heppy.__getattr__, 'WrongName')

    def test_components(self):
        expected = [
            self.heppy.QCD_HT_100To250, self.heppy.QCD_HT_250To500,
            self.heppy.TTJets
        ]
        self.assertEqual(expected, self.heppy.components())

    def test_init_with_componentNames(self):
        path = 'dir/201522_SingleMu'
        componentNames = ['QCD_HT_100To250', 'QCD_HT_250To500']
        heppy = HeppyResult(path=path, componentNames=componentNames)

        expected = componentNames
        self.assertEqual(expected, heppy.componentNames)

    def test_init_with_componentNames_wrongName(self):
        path = 'dir/201522_SingleMu'
        componentNames = ['QCD_HT_100To250', 'QCD_HT_250To500', 'WrongName']
        self.assertRaises(ValueError,
                          HeppyResult,
                          path=path,
                          componentNames=componentNames)

    def test_init_with_componentNames_AnotherDir(self):
        path = 'dir/201522_SingleMu'
        componentNames = ['QCD_HT_100To250', 'QCD_HT_250To500', 'AnotherDir']
        self.assertRaises(ValueError,
                          HeppyResult,
                          path=path,
                          componentNames=componentNames)

    def test_init_with_excludeList(self):
        path = 'dir/201522_SingleMu'
        excludeList = ('failed', 'QCD_HT_100To250')
        heppy = HeppyResult(path=path, excludeList=excludeList)

        expected = ['QCD_HT_250To500', 'TTJets']
        self.assertEqual(expected, heppy.componentNames)

    def test_versionInfo(self):
        expected = {
            'tag': 'RA1cmg_v2.3',
            'full':
            'Tag for production: \nRA1cmg_v2.3\n\nExtra information: \n'
        }
        self.assertEqual(expected, self.heppy.versionInfo())

    def test_versionInfo_theSameObject(self):
        info1 = self.heppy.versionInfo()
        info2 = self.heppy.versionInfo()
        self.assertIs(info1, info2)