recoMet) > vecSumPt( recoBj1, recoLeps[event.recoNonZ_l1_index], recoMet): event.recoBjNonZlep_index, event.recoBjNonZhad_index = recoBj0[ 'index'], recoBj1['index'] else: event.recoBjNonZlep_index, event.recoBjNonZhad_index = recoBj1[ 'index'], recoBj0['index'] tmp_dir = ROOT.gDirectory #post_fix = '_%i'%args.job if args.nJobs > 1 else '' output_filename = os.path.join(output_directory, sample.name + '.root') _logger.add_fileHandler(output_filename.replace('.root', '.log'), args.logLevel) _logger_rt.add_fileHandler(output_filename.replace('.root', '_rt.log'), args.logLevel) if os.path.exists(output_filename) and args.overwrite == 'none': logger.info("File %s found. Quit.", output_filename) sys.exit(0) output_file = ROOT.TFile(output_filename, 'recreate') output_file.cd() maker = TreeMaker(sequence=[filler], variables=[TreeVariable.fromString(x) for x in variables] + extra_variables, treeName="Events") tmp_dir.cd() counter = 0
jobs = [(i, eventRanges[i]) for i in range(len(eventRanges))] filename, ext = os.path.splitext( os.path.join(tmp_output_directory, sample.name + '.root') ) if len(eventRanges)>1: raise RuntimeError("Using fileBasedSplitting but have more than one event range!") clonedEvents = 0 convertedEvents = 0 outputLumiList = {} for ievtRange, eventRange in enumerate( eventRanges ): logger.info( "Processing range %i/%i from %i to %i which are %i events.", ievtRange, len(eventRanges), eventRange[0], eventRange[1], eventRange[1]-eventRange[0] ) _logger. add_fileHandler( outfilename.replace('.root', '.log'), options.logLevel ) _logger_rt.add_fileHandler( outfilename.replace('.root', '_rt.log'), options.logLevel ) tmp_gdirectory = ROOT.gDirectory outputfile = ROOT.TFile.Open(outfilename, 'recreate') tmp_gdirectory.cd() if options.small: logger.info("Running 'small'. Not more than 10000 events") nMaxEvents = eventRange[1]-eventRange[0] eventRange = ( eventRange[0], eventRange[0] + min( [nMaxEvents, 10000] ) ) # Set the reader to the event range reader.setEventRange( eventRange ) clonedTree = reader.cloneTree( branchKeepStrings, newTreename = "Events", rootfile = outputfile ) nEvents = clonedTree.GetEntries()