from ROOT import * import sys import argparse import binningtools import ABCDtools parser=argparse.ArgumentParser(description='Plot multiple purity curves.') parser.add_argument('input',metavar='input.txt',type=str,help='Textfile with count in ABCD regions.') parser.add_argument('mcinput',metavar='mcinput.txt',type=str,help='Textfile with MC count in ABCD regions.') parser.add_argument('output',metavar='output.txt',type=str,help='Textfile where to save the output.') args = parser.parse_args() data=ABCDtools.loadABCD(args.input) mcdata=ABCDtools.loadABCD(args.mcinput) output=args.output # Save fout=open(output,'w') for etastr in data: for ptstr in data[etastr]: NA,NB,NC,ND=data[etastr][ptstr] if etastr in mcdata and ptstr in mcdata[etastr]: NAsig,NBsig,NCsig,NDsig=mcdata[etastr][ptstr] text='%s\t%s\t%s\n'%(etastr,ptstr,ABCDtools.calc_mccorr(NA,NB,NC,ND,NAsig,NBsig,NCsig,NDsig)) else: text='%s\t%s\t%s\n'%(etastr,ptstr,ABCDtools.calc(NA,NB,NC,ND)) fout.write(text) fout.close()
import ptetabinningtools import ABCDtools parser=argparse.ArgumentParser(description='Plot multiple purity curves.') parser.add_argument('input',metavar='input.txt:title:color:mcinput.txt',type=str,nargs='+',help='Textfiles with the counts in ABCD regions.') args = parser.parse_args() datas=[] for input in args.input: parts=input.split(':') input=parts[0] title=parts[1] if len(parts)>=2 else input color=parts[2] if len(parts)>=3 else 'kBlack' mcinput=parts[3] if len(parts)>=4 else '' datas.append((ABCDtools.loadABCD(input),title,eval(color),ABCDtools.loadABCD(mcinput))) def fill_graph(g,etadatas,mcetadatas=None): idx=0 for ptstr,data in etadatas.items(): parts=ptstr[2:].split('to') avgpt=0 errptlow=0 errpthigh=0 if parts[0]=='': avgpt=float(parts[1]) elif parts[1]=='': avgpt=float(parts[0])*1.2 errptlow=float(parts[0])*0.2 else: avgpt=(float(parts[0])+float(parts[1]))/2