Пример #1
0
def configureSequence(args):
    # analysis and mithep defined in config
    
    if args.flatConfig:
        # copy the config to a temporary python directory to allow import
        bambutmp = os.environ['CMSSW_BASE'] + '/python/bambutmp'
        try:
            os.mkdir(bambutmp)
            open(bambutmp + '/__init__.py', 'w').close()
        except:
            pass
    
        shutil.copy(args.config, bambutmp)
        cfg = importlib.import_module('bambutmp.' + os.path.basename(args.config).replace('.py', ''))
        shutil.rmtree(bambutmp)

        try:
            analysis = cfg.analysis
        except AttributeError:
            print 'Analysis object not defined in ' + args.config
            sys.exit(1)

        try:
            mithep = cfg.mithep
        except AttributeError:
            import ROOT
            ROOT.gSystem.Load('libMitAnaTreeMod.so')
            mithep = ROOT.mithep

        if args.goodlumiFile is not None:
            # RunLumiSelectionMod assumed to be the first module
            try:
                jsonDir = os.environ['MIT_JSON_DIR']
                for sm in analysis.GetSuperMods():
                    if sm.Class() != mithep.RunLumiSelectionMod.Class():
                        continue

                    sm.AddJSONFile(jsonDir + '/' + goodlumiFile)

            except:
                print 'Lumi list configuration failed.'
                sys.exit(1)

    else:
        from MitAna.TreeMod.bambu import analysis, mithep

        if args.realData or args.goodlumiFile is not None:
            analysis.isRealData = True

        execfile(args.config)

        # if good run / lumi list is given, prepend the filter module
        if args.goodlumiFile is not None:
            from MitAna.PhysicsMod.runlumisel import goodLumiFilter
            filterMod = goodLumiFilter(args.goodlumiFile)
            analysis._sequence = filterMod * analysis._sequence
    
        analysis.buildSequence()

    return mithep, analysis
Пример #2
0
            catalog = mithep.Catalog(os.environ['MIT_CATALOG'])
        except KeyError:
            print 'Dataset catalog requires environment MIT_CATALOG to be set.'
            sys.exit(1)

        dataset = catalog.FindDataset(args.book, args.dataset, args.fileset, 1)
        analysis.AddDataset(dataset)
        analysis.SetUseCacher(1)
        
    elif args.inputFile:
        analysis.AddFile(args.inputFile)

    # if good run / lumi list is given, prepend the filter module
    if args.goodlumiFiles:
        from MitAna.PhysicsMod.runlumisel import goodLumiFilter
        filterMod = goodLumiFilter(args.goodlumiFiles)
        analysis._sequence = filterMod * analysis._sequence
    
    if args.outputFile:
        analysis.SetOutputName(args.outputFile)
    
    if args.nentries >= 0:
        analysis.SetProcessNEvents(args.nentries)
    
    if args.useCacher:
        analysis.SetUseCacher(1)
    
    if args.hierarchy:
        analysis.SetKeepHierarchy(True)

    for mod in analysis._sequence.build()[0]:
Пример #3
0
        for expr in args.custom:
            key, eq, value = expr.partition('=')
            if not value:
                continue

            try:
                value = eval(value)
            except:
                pass

            print 'Adding a custom variable', key, '=', ('"%s"' % value if type(value) is str else value)
            analysis.custom[key] = value

    # load macro
    execfile(args.config)

    # if good run / lumi list is given, prepend the filter module
    if args.goodlumiFile:
        from MitAna.PhysicsMod.runlumisel import goodLumiFilter
        filterMod = goodLumiFilter(args.goodlumiFile)
        analysis._sequence = filterMod * analysis._sequence

    # build the module sequence
    analysis.buildSequence()

    print '\n+++++ ANALYSIS FLOW +++++\n'
    analysis.PrintModuleTree()
    print '\n+++++++++++++++++++++++++\n'

    analysis.Run(False)