コード例 #1
0
def ns2ps(inputfilename,outputfilename):

	ftin = TFile(NTUPLE_PATH+inputfilename+'.root')
	ttin = ftin.Get('DecayTree')
	ftout = TFile(NTUPLE_PATH+outputfilename+'.root','RECREATE')
	print "Copying the original tree ..."
	ttout = ttin.CopyTree("")
	print "Tree copied."

	gROOT.ProcessLine(\
		"struct MyStruct{\
		Float_t afloat;\
		};")
	from ROOT import MyStruct

	t = MyStruct()
	newBrancht = ttout.Branch('B_s0_t', AddressOf(t,'afloat'), 'B_s0_t/F')
	terr = MyStruct()
	newBranchterr = ttout.Branch('B_s0_terr', AddressOf(terr,'afloat'), 'B_s0_terr/F')

	print "Processing events ..."
	for i in ttout:
		t.afloat = eval('i.'+tau_name)*1000.
		terr.afloat = eval('i.'+tauerr_name)*1000.
		newBrancht.Fill()
		newBranchterr.Fill()
	print "All events processed."

	ttout.Write()
	ftout.Close()
コード例 #2
0
def AddCosines(inputfilename,inputfileextradir,inputfileextradirname,outputfilename):

	fcosin = TFile(NTUPLE_PATH + inputfilename + '.root')
	if inputfileextradir: tcosin = fcosin.Get(inputfileextradirname).Get('DecayTree')
	else: tcosin = fcosin.Get('DecayTree')
	fcosout = TFile(NTUPLE_PATH + outputfilename + '.root','RECREATE')
	print "Copying the original tree ..."
	tcosout = tcosin.CopyTree("")
	print "Tree copied."

	gROOT.ProcessLine(\
		"struct MyStruct{\
		Double_t adouble;\
		};")
	from ROOT import MyStruct
	cos1 = MyStruct()
	newBranchcos1 = tcosout.Branch('B_s0_Cos1', AddressOf(cos1,'adouble'), 'B_s0_Cos1/D')
	cos2 = MyStruct()
	newBranchcos2 = tcosout.Branch('B_s0_Cos2', AddressOf(cos2,'adouble'), 'B_s0_Cos2/D')
	kp = TLorentzVector()
	pim = TLorentzVector()
	km = TLorentzVector()
	pip = TLorentzVector()

	print "Processing events ..."
	for i in tcosout:
		kp.SetXYZM(eval('i.'+KpPx_name),eval('i.'+KpPy_name),eval('i.'+KpPz_name),493.667)
		pim.SetXYZM(eval('i.'+PimPx_name),eval('i.'+PimPy_name),eval('i.'+PimPz_name),139.570)
		km.SetXYZM(eval('i.'+KmPx_name),eval('i.'+KmPy_name),eval('i.'+KmPz_name),493.667)
		pip.SetXYZM(eval('i.'+PipPx_name),eval('i.'+PipPy_name),eval('i.'+PipPz_name),139.570)
		angles = get_Angles(kp,pim,km,pip)
		cos1.afloat = angles[0]
		cos2.afloat = angles[1]
		newBranchcos1.Fill()
		newBranchcos2.Fill()
	print "All events processed."

	tcosout.Write()
	fcosout.Close()
コード例 #3
0
ファイル: create_toy_sample.py プロジェクト: ferdani/bsksks
                                'signal/F')
br_weight_bkg = tout_bkg.Branch('weight', AddressOf(weight, 'afloat'),
                                'weight/F')
br_mass_bkg = tout_bkg.Branch('Dplus_MM_toy', AddressOf(mass, 'afloat'),
                              'Dplus_MM_toy/F')

bkg_pdf = TF1("bkg_pdf", "1.-4.3835e-04*x", 1840, 1900)

sig_weight = 1.3516e+06 / 26651.
bkg_weight = 2.7154e+05 / 111230.

print 'Processing data ...'
print '- Signal -'
for ev in tin_signal:
    if ev.Dplus_BKGCAT == 0 and ev.Dplus_MM >= 1840. and ev.Dplus_MM < 1900.:
        evtype.afloat = 1.
        weight.afloat = sig_weight
        mass.afloat = ev.Dplus_MM
        tout_signal.Fill()
print '- Background -'
for ev in tin_bkg:
    if (
        (ev.Dplus_MM >= 1830 and ev.Dplus_MM < 1840) or
        (ev.Dplus_MM >= 1900 and ev.Dplus_MM < 1910)
    ) and ev.pi1_ProbNNpik >= 0.14 and ev.pi2_ProbNNpik >= 0.14 and ev.K_ProbNNkpi >= 0.12:
        evtype.afloat = 0.
        weight.afloat = bkg_weight
        mass.afloat = bkg_pdf.GetRandom()
        tout_bkg.Fill()
print 'Data processed.'
コード例 #4
0
ファイル: Dani_BDT_evaluator.py プロジェクト: ferdani/bsksks
print "Processing events ..."
for ev in tout:

    var_Bs_PT[0] = ev.Bs_PT
    var_Kst_PT[0] = ev.Kst_PT
    var_Kstb_PT[0] = ev.Kstb_PT
    var_max_Kp_Km_PT[0] = max(ev.Kp_PT, ev.Km_PT)
    var_min_Kp_Km_PT[0] = min(ev.Kp_PT, ev.Km_PT)
    var_max_pip_pim_PT[0] = max(ev.pip_PT, ev.pim_PT)
    var_min_pip_pim_PT[0] = min(ev.pip_PT, ev.pim_PT)
    var_Bs_DIRA_OWNPV[0] = ev.Bs_DIRA_OWNPV
    var_Bs_ENDVERTEX_CHI2[0] = ev.Bs_ENDVERTEX_CHI2
    var_Bs_LOKI_ETA[0] = ev.Bs_LOKI_ETA
    var_Kst_LOKI_ETA[0] = ev.Kst_LOKI_ETA
    var_Kstb_LOKI_ETA[0] = ev.Kstb_LOKI_ETA
    var_max_Kp_Km_ETA[0] = max(ev.Kp_LOKI_ETA, ev.Km_LOKI_ETA)
    var_min_Kp_Km_ETA[0] = min(ev.Kp_LOKI_ETA, ev.Km_LOKI_ETA)
    var_max_pip_pim_ETA[0] = max(ev.pip_LOKI_ETA, ev.pim_LOKI_ETA)
    var_min_pip_pim_ETA[0] = min(ev.pip_LOKI_ETA, ev.pim_LOKI_ETA)

    bdt_output.afloat = reader.EvaluateMVA("BDT")
    #   bdtg_output.afloat = reader.EvaluateMVA("BDTG")
    br_bdt.Fill()
#   br_bdtg.Fill()

print "Events processed."

tout.Write()
fout.Close()