Exemplo n.º 1
0
	def totEvtEff(self,org,dir=None):
		low1p,low1,low2p,denom,lowNX,denomX=None,None,None,None,None,None
		for step in org.steps:
			for plotName in sorted(step.keys()):
				if 'LowNE1' == plotName : low1=step[plotName]
				if 'NE' == plotName : denom=step[plotName]
				if 'NX' == plotName: denomX=step[plotName]

		efflow1 = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(low1,denom)])

		#fs = [0.01,0.02,0.03,0.06,0.1,0.2,0.3,0.6,1.,2.,3.,6.,10.,20.,30.,60.,100.]
		fs = [0.4,0.6,1.,1.4]
		fs = [round(a,5) for a in fs] 
		N=len(fs)

		sysmap={'1500494':0.10,'1000148':0.10,'350148':0.10,'12048':0.10}
		f=0.89

		for i,sample in enumerate(org.samples):
			digits=re.findall(r'\d+',sample['name'])
			SQ,CHI=digits[0],digits[1]
			name='SQ_'+str(SQ)+"_CHI_"+str(CHI) + ('_priv' if 'priv' in sample['name'] else '')
			sys=0.1

			ctau = self.ctau[self.sig_names.index(name)]

			for j in range(N):
				x,y=r.Double(0),r.Double(0)
				efflow1[i].GetPoint(j,x,y)
				e1 = f*float(y)
				e1Err = f*efflow1[i].GetErrorY(j)
				if e1 > 0. : e1Err = e1*math.sqrt(sys*sys+pow(e1Err/e1,2))
				factor=fs[j]
				#if factor in [0.1,1,10]:
				objects=[ SQ,CHI,factor*ctau,rnd(100*e1,3),rnd(100*e1Err,3)]
				print " & ".join(str(a) for a in objects ) + ' \\\\'
				output=[(e1,e1Err),(e1,e1Err),[e1,e1Err]]
				name = name.replace('_priv','')
				pickle.dump(output,open(supy.whereami()+'/../results/'+dir+'/efficiencies/'+name+'_'+str(factor)+'.pkl','w'))
Exemplo n.º 2
0
	def totEvtEff(self,org,dir=None):
		high1,low1,denom=None,None,None
		for step in org.steps:
			for plotName in sorted(step.keys()):
				if 'HighNE1' == plotName : high1=step[plotName]
				if 'LowNE1' == plotName : low1=step[plotName]
				if 'NE' == plotName : denom=step[plotName]

		efflow1 = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(low1,denom)])
		effhigh1 = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(high1,denom)])

		fs = [0.4,0.6,1.,1.4]#	old factors for the record if not approved
		#fs = [0.1,0.2,0.3,0.6,1.,2.,3.,6.,10.]
		allfs = [0.1*a for a in fs] + fs + [10*a for a in fs]
		allfs = [round(a,5) for a in allfs] 
		N=len(allfs)
		forbidden=[7,8,9,16,17,18]

		sysmap={'1000350':0.075,'1000150':0.075,'400150':0.096,'40050':0.091,'20050':0.10}
		f=0.89

		for i,sample in enumerate(org.samples):
			digits=re.findall(r'\d+',sample['name'])
			H,X=digits[1],digits[4]
			sys=sysmap[H+X]
			name='H_'+str(H)+'_X_'+str(X)
			ctau = self.ctau[self.sig_names.index(name)]

			for j in range(N):
				#if j in forbidden: continue
				x,y=r.Double(0),r.Double(0)
				efflow1[i].GetPoint(j,x,y)
				e1 = f*float(y)
				e1Err = f*efflow1[i].GetErrorY(j)
				if j>N/3:
					effhigh1[i].GetPoint(j,x,y)
					e1p = f*float(y)
					e1pErr = f*effhigh1[i].GetErrorY(j)

				if e1 > 0. : e1Err = e1*math.sqrt(sys*sys+pow(e1Err/e1,2))
				factor=allfs[j]
				#if factor in [0.1,1,10]:
				objects=[ H,X,factor*ctau,rnd(100*e1,3)]
				print " & ".join(str(a) for a in objects ) + ' \\\\'
				output=[(e1,e1Err),(e1,e1Err),[e1,e1Err]]
				pickle.dump(output,open(supy.whereami()+'/../results/'+dir+'/efficiencies/'+name+'_'+str(factor)+'.pkl','w'))
Exemplo n.º 3
0
x,w=[],[]
H,X=0,0

for file1,file2 in zip(files1,files2):
	data1,data2=pickle.load(open(dir1+'/'+file1)),pickle.load(open(dir2+'/'+file2))
	strings=file1[:-4].split('_')
	if ((H!=strings[1] or X!=strings[3]) and H!=0):
		avg,err=weightedAvg(x,w)
		print round(avg,5),round(err,5)
		x,w=[],[]	
	H,X,factor = strings[1],strings[3],eval(strings[4])
	if factor != 0.1 and factor!=1 and factor!=10 : continue
	e1,e2 = data1[dict[option][1]],data2[dict[option][1]]
	if e1[0]==e2[0]==0 : continue
	diff = 100* 2*(e1[0]-e2[0])/(e1[0]+e2[0])
	n1=pow(e1[0]/e1[1],2)
	n2=pow(e2[0]/e2[1],2)
	if n1-n2==0: continue
	diffe = diff*1./math.sqrt(abs(n1-n2))
	#diffe=1
	#diffe = 100* 4/pow(e1[0]+e2[0],2)*math.sqrt(pow(e2[0]*e1[1],2)+pow(e1[0]*e2[1],2))
	x.append(diff)
	w.append(diffe)
	e1=tuple([str(rnd(a,2)) for a in e1])
	e2=tuple([str(rnd(a,2)) for a in e2])
	print file1,e1,e2,rnd(diff,2),rnd(diffe,2)

avg,err = weightedAvg(x,w)
print round(avg,5),round(err,5)
Exemplo n.º 4
0
                           eval(file[:-4].split('_')[3]),
                           eval(file[:-4].split('_')[4]))
            )

files2=sorted(os.listdir(dir2),key=lambda file: (eval(file[:-4].split('_')[1]),
                           eval(file[:-4].split('_')[3]),
                           eval(file[:-4].split('_')[4]))
            )
files3=sorted(os.listdir(dir3),key=lambda file: (eval(file[:-4].split('_')[1]),
                           eval(file[:-4].split('_')[3]),
                           eval(file[:-4].split('_')[4]))
            )

x,w=[],[]

for file1,file2,file3 in zip(files1,files2,files3):
	dict1,dict2,dict3=pickle.load(open(dir1+'/'+file1)),pickle.load(open(dir2+'/'+file2)),pickle.load(open(dir3+'/'+file3))
	factor = eval(file1[:-4].split('_')[4])
	if factor != 0.1 and factor!=1 and factor!=10 : continue
	e1,e2,e3 = dict1['eff'],dict2['eff'],dict3['eff']
	if e1[0]==e2[0]==0 : continue
	#x = 0.5*(max(e1[0]+e1[1],e2[0]+e2[1],e3[0]+e3[1])+min(e1[0]-e1[1],e2[0]-e2[1],e3[0]-e3[1]))
	#xe = 0.5*(max(e1[0]+e1[1],e2[0]+e2[1],e3[0]+e3[1])-min(e1[0]-e1[1],e2[0]-e2[1],e3[0]-e3[1]))
	x = 50*(max(e1[0],e2[0],e3[0])+min(e1[0],e2[0],e3[0]))
	xe = 50*(max(e1[0],e2[0],e3[0])-min(e1[0],e2[0],e3[0]))
	diffe=1
	e1=tuple([str(rnd(a,2)) for a in e1])
	e2=tuple([str(rnd(a,2)) for a in e2])
	print file1,e1,e2,rnd(x,2),rnd(xe,2),rnd(100*xe/x,2)