import argparse import sys,os,glob import math, time pandapath=os.environ.get('PANDAPATH') sys.path.append(pandapath+'/macro/tpc/FOPI/mberger') from functions import * from anaFile import anaFile parser=argparse.ArgumentParser(description='Slice dEdx vs mom histogram, fit proton line with langaus and extract a TCut') parser.add_argument("infile",help='the output file from analyseFOPIReco_pions.py',type=str) parser.add_argument("fitinfo",help='the file with the start parameters for the fit',type=str) parser.add_argument('--slicewidth',help='the width of the momentum bins (%(default)s)',type=float,default=-1) parser.add_argument('--nslices',help='number of slices in momentum (%(default)s)',type=int,default=-1) parser.add_argument('--momRange',help='the range of the momentum to slice (%(default)s)',type=float,nargs=2,default=[0,5]) args=parser.parse_args() if args.slicewidth==-1 and args.nslices==-1: print "please give either slicewidth or nslices!" exit() if args.slicewidth==-1: args.slicewidth=float(args.momRange[1]-args.momRange[0])/float(args.nslices) if args.nslices==-1: args.nslices=int(float(args.momRange[1]-args.momRange[0])/float(args.slicewidth)) #read in fit start parameters fitpar=[] nlines=0 for line in open(args.fitinfo,"r"): if line[0]=='#': continue nlines+=1 words=line.split() pars=[float(word) for word in words] fitpar.append({}) fitpar[-1]["start dedx"] =pars[0] fitpar[-1]["stop dedx"] =pars[1] fitpar[-1]["mean gauss"] =pars[2] fitpar[-1]["sig gauss"] =pars[3] fitpar[-1]["mean landau"]=pars[4] fitpar[-1]["sig landau"] =pars[5] if nlines