def main(args): comname = "SingleB2KstarMuMu" gROOT.SetBatch(kTRUE) datatype = args[0] label = args[1] test = get_options(args, "test") batch = get_options(args, "batch") if batch: cmd = create_batch_cmd() bashname = "sel_%s.sh" % comname bashpath = os.path.join(atr.afbpath, "src", "sh", label) afb = atr.get_afb_from_label(label) bashfile = create_bashfile_cmd(cmd, bashpath, bashname, afb, test=test) logpath = os.path.join(atr.afbpath, "log", "sel", datatype, label) logfile = set_logfile(logpath, comname, test=test) jobname = "selb2kmm" bsub_jobs(logfile, jobname, bashfile, test) return ntp_label = get_label_by_version(label, "x") infile = atr.ntp.rootfile(datatype, ntp_label) outfile = atr.sel.rootfile(datatype, label, comname, create=True, test=test) ccname = "SingleB2KstarMuMuSelector.cc+" if "-fcompile" in args: ccname += "+" ccpath = os.path.join(os.environ["HOME"], "bak/src/cms/afb/cc") ccfile = os.path.join(ccpath, ccname) t = root_chain(infile, "B0Cand/B0KstMuMuNTuple") if test: nentries = 10000 else: nentries = t.GetEntries() option = "outfile=%s" % outfile if datatype == "data": option += "checkTrigger1" if "-d" in args: option += "debug" nentries = 2 firstentry = 0 if "-firstentry" in args: firstentry = int(args[args.index("-firstentry") + 1]) time_start = time() t.Process(ccfile, option, nentries, firstentry) dur = duration(time() - time_start) sys.stdout.write(" \nDone in %s. \n" % dur) if test: estimate = duration(t.GetEntries() / float(nentries) * (time() - time_start)) sys.stdout.write("Estimate for the total %s : %s\n" % (t.GetEntries(), estimate)) sys.stdout.flush()
def proc_ntuple(args, label, cut): datatype = args[0] test = option_exists(args, '-t') batch = option_exists(args, '-b') inname = atr.ntp.rootname(datatype, label, batch) comname = 'SingleBuToKstarMuMu' outname = comname if batch : outname = comname+'_${LSB_JOBINDEX}' inpath = atr.ntp.rootpath(datatype, label) infile = os.path.join(inpath, inname+'.root') outpath = os.path.join(atr.datpath, 'sel', datatype, label) outfile = set_file(outpath, cut, outname, '.root', test=test) sel_datatype = datatype if datatype == 'mc' and 'BuToKstarJPsi' in label: sel_datatype = 'BuToKstarJPsi' if datatype == 'mc' and 'BuToKstarMuMu' in label: sel_datatype = 'BuToKstarMuMu' procdir = atr.sel.procdir(label) cmd = './sel %s %s %s %s' %(sel_datatype, cut, infile, outfile) if option_exists(args, '-n') : nentries = get_option(args, '-n') cmd = '%s -n %s' %(cmd, nentries) else: if test: cmd = '%s -n 1000' % cmd if option_exists(args, '-j'): nworkers = get_option(args, '-j') cmd = '%s -j %s' %(cmd, nworkers) time_start = time() if batch: afb = atr.get_afb_from_label(label) pre = 'setafb %s\n\ncd %s' % (afb, procdir) bashfile = set_file(atr.bashpath, label, comname, '.sh', test=test) update_bashfile_cmd(bashfile, cmd, pre=pre, test=test) logfile = set_file(atr.logpath, label, comname, '.log', test=test) #jobname = 'selbu' njobs = atr.ntp.num_rootfiles[label] jobname = 'selb[1-%s]' %njobs if option_exists(args, '-J'): jobname = get_option(args, '-J') bsub_jobs(logfile, jobname, bashfile, test=option_exists(args, '-btest'), queue='1nh') return output = proc_cmd(cmd, procdir=procdir, test=option_exists(args, '-ctest')) if output is not None: sys.stdout.write(output) if option_exists(args, '-ctest'): return dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur) sys.stdout.flush()