def process(self): #Take into account segment for i in xrange(1, len(self.datas)): denivele = float(self.datas[i]["Altitude (m)"]) - float(self.datas[i-1]["Altitude (m)"]) if denivele > 0: self.positive_denivele += denivele else: self.negative_denivele -= denivele self.datas[i]["den"] = denivele d = distance(self.datas[i]["coordo"], self.datas[i - 1]["coordo"]) self.distance_total += d self.datas[i]["distance_total"] = self.distance_total self.datas[i]["distance_previous"] = d dur = duration(self.datas[i]["time"], self.datas[i - 1]["time"]) self.total_time += dur self.datas[i]["duration_total"] = self.total_time self.datas[i]["duration_previous"] = dur self.datas[i]['speed'] = self.datas[i]["duration_previous"] \ and self.datas[i]["distance_previous"] / self.datas[i]["duration_previous"] \ or 0 self.datas[i]['move'] = self.datas[i]['speed'] and True or False if self.datas[i]['speed'] < 0.19: #print "not moving", i self.not_moving_time += dur
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() fout = ROOT.TFile(outfile, "RECREATE") t_out = ROOT.TTree('signal', 'signal') mystruct = ROOT.MyTreeStruct() t_out.Branch('vtx_mrecpipi', mystruct, 'vtx_mrecpipi/D') for jentry in xrange(entries): pbar.update(jentry + 1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb <= 0: continue fill_histograms(t) if select_jpsi_to_invisible(t): h_mrecpipi.Fill(t.vtx_mrecpipi) h_mrecpipi_fit.Fill(t.vtx_mrecpipi) mystruct.vtx_mrecpipi = t.vtx_mrecpipi t_out.Fill() # fout = ROOT.TFile(outfile, "RECREATE") t_out.Write() write_histograms() fout.Close() pbar.finish() dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() for jentry in xrange(entries): pbar.update(jentry+1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb<=0: continue fill_histograms(t) if select_jpsi_to_invisible(t): h_mrecpipi.Fill(t.vtx_mrecpipi) fout = ROOT.TFile(outfile, "RECREATE") write_histograms() fout.Close() pbar.finish() dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) #t = fin.Get('mc') #t = fin.Get('D0bar_kpi') t = fin.Get('D0_kpi') entries = t.GetEntries() fout = ROOT.TFile(outfile, "RECREATE") t_4 = t.CloneTree(0) pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() for jentry in xrange(entries): pbar.update(jentry+1) nb = t.GetEntry(jentry) if nb<=0: continue if abs(t.vtx_mkpi-D0_MASS)<0.2: #if abs(t.vtx_mkpi-D0_MASS)<0.4: t_4.Fill() t_4.Write() fout.Close() pbar.finish() print entries dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('mc') entries = t.GetEntries() fout = ROOT.TFile(outfile, "RECREATE") t_4 = t.CloneTree(0) pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() for jentry in xrange(entries): pbar.update(jentry + 1) nb = t.GetEntry(jentry) if nb <= 0: continue if abs(t.vtx_mkpi - D0_MASS) < 0.2: t_4.Fill() t_4.Write() fout.Close() pbar.finish() print entries dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() count0 = 0 count1 = 0 count2 = 0 count3 = 0 count4 = 0 count5 = 0 count6 = 0 count7 = 0 count8 = 0 count9 = 0 count10 = 0 count11 = 0 count12 = 0 count13 = 0 count14 = 0 count15 = 0 count_EMC_Track = 0 count_all = 0 for jentry in xrange(entries): pbar.update(jentry+1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb<=0: continue #fill_histograms(t) if select_jpsi_to_gammaEta(t): cut_chisq = (t.kmfit_chisq < 60 ) cut_mjpsi_sig = (abs(t.vtx_mrecpipi - JPSI_MASS)<0.015) flag = 0 cut_mgg = 0 cut_mpipieta = 0 if ( t.kmfit_g1g2dang < t.kmfit_g1g3dang and t.kmfit_g1g2dang < t.kmfit_g2g3dang ): flag = 1 cut_mgg = (t.kmfit_m_g1g2 > 0.51 and t.kmfit_m_g1g2 < 0.57) cut_mpipieta = (t.kmfit_m_pipig1g2 > 1.0) if ( t.kmfit_g1g3dang < t.kmfit_g1g2dang and t.kmfit_g1g3dang < t.kmfit_g2g3dang ): flag = 2 cut_mgg = (t.kmfit_m_g1g3 > 0.51 and t.kmfit_m_g1g3 < 0.57) cut_mpipieta = (t.kmfit_m_pipig1g3 > 1.0) if ( t.kmfit_g2g3dang < t.kmfit_g1g2dang and t.kmfit_g2g3dang < t.kmfit_g1g3dang ): flag = 3 cut_mgg = (t.kmfit_m_g2g3 > 0.51 and t.kmfit_m_g2g3 < 0.57) cut_mpipieta = (t.kmfit_m_pipig2g3 > 1.0) if ( cut_chisq and cut_mpipieta ): if ( cut_mjpsi_sig ): if ( flag == 1 ): h_mgg.Fill(t.kmfit_m_g1g2) if ( flag == 2 ): h_mgg.Fill(t.kmfit_m_g1g3) if ( flag == 3 ): h_mgg.Fill(t.kmfit_m_g2g3) if ( cut_mgg ): h_mrecpipi_zc.Fill(t.vtx_mrecpipi) h_mpipi.Fill(t.vtx_mpipi) h_pip_p.Fill(t.trkp_p) h_pim_p.Fill(t.trkm_p) h_pip_costhe.Fill(math.cos(t.trkp_theta)) h_pim_costhe.Fill(math.cos(t.trkm_theta)) h_cospipi.Fill(t.vtx_cospipi) h_cos2pisys.Fill(t.vtx_cos2pisys) ngam = t.ngam for gentry in range(ngam): h_gcostheta.Fill(t.raw_costheta[gentry]) if ( cut_mjpsi_sig and cut_mgg and (t.run>0) ): # Only for data sample ch0 = t.m_trig_channel[0] ch1 = t.m_trig_channel[1] ch2 = t.m_trig_channel[2] ch3 = t.m_trig_channel[3] ch4 = t.m_trig_channel[4] ch5 = t.m_trig_channel[5] ch6 = t.m_trig_channel[6] ch7 = t.m_trig_channel[7] ch8 = t.m_trig_channel[8] ch9 = t.m_trig_channel[9] ch10 = t.m_trig_channel[10] ch11 = t.m_trig_channel[11] ch12 = t.m_trig_channel[12] ch13 = t.m_trig_channel[13] ch14 = t.m_trig_channel[14] ch15 = t.m_trig_channel[15] count0 = count0 + ch0 count1 = count1 + ch1 count2 = count2 + ch2 count3 = count3 + ch3 count4 = count4 + ch4 count5 = count5 + ch5 count6 = count6 + ch6 count7 = count7 + ch7 count8 = count8 + ch8 count9 = count9 + ch9 count10 = count10 + ch10 count11 = count11 + ch11 count12 = count12 + ch12 count13 = count13 + ch13 count14 = count14 + ch14 count15 = count15 + ch15 count_all = count_all + 1 if( ch11 == 1 and ( ch0==1 or ch1==1 or ch2==1 or ch3==1 or ch4==1 or ch5==1 ) ): count_EMC_Track = count_EMC_Track + 1 h_ch_count.Fill(0, count0); h_ch_count.Fill(1, count1); h_ch_count.Fill(2, count2); h_ch_count.Fill(3, count3); h_ch_count.Fill(4, count4); h_ch_count.Fill(5, count5); h_ch_count.Fill(6, count6); h_ch_count.Fill(7, count7); h_ch_count.Fill(8, count8); h_ch_count.Fill(9, count9); h_ch_count.Fill(10, count10); h_ch_count.Fill(11, count11); h_ch_count.Fill(12, count12); h_ch_count.Fill(13, count13); h_ch_count.Fill(14, count14); h_ch_count.Fill(15, count15); h_ch_count.Fill(19, count_EMC_Track); h_ch_count.Fill(21, count_all); fout = ROOT.TFile(outfile, "RECREATE") write_histograms() fout.Close() pbar.finish() # print "count0 = " , count0 # print "count1 = " , count1 # print "count2 = " , count2 # print "count3 = " , count3 # print "count4 = " , count4 # print "count5 = " , count5 # print "count6 = " , count6 # print "count7 = " , count7 # print "count8 = " , count8 # print "count9 = " , count9 # print "count10 = " , count10 # print "count11 = " , count11 # print "count12 = " , count12 # print "count13 = " , count13 # print "count14 = " , count14 # print "count15 = " , count15 # print "count_EMC_Track = " , count_EMC_Track dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): args = sys.argv[1:] if len(args)<2: return usage() infile = args[0] outfile = args[1] if len(args)==2: # default: all pass flag = 0 else: # or , set flag flag = int(args[2]) fin = ROOT.TFile(infile) t_in = fin.Get('tree') entries = t_in.GetEntriesFast() if entries > 0 : pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() # output file & TTree definition fout = ROOT.TFile(outfile, "RECREATE") for jentry in xrange(entries): pbar.update(jentry+1) # get the next tree in the chain and verify ientry = t_in.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t_in.GetEntry(jentry) if nb<=0: continue # raw event number h_evtflw.Fill(0) # Signal( mumuH(->ZZ ) ) sel = 0 if( flag==1 and is_signal(t_in) ): sel = 1 # not Signal if( flag==2 and not( is_signal(t_in) ) ): sel = 1 if( sel==1 or flag==0 ): fill_histograms(t_in) if select_higgs_to_zz(t_in): index = select_zpole_muon(t_in) h_m_dimuon_final.Fill( t_in.dimuon_m[index] ) h_mrec_dimuon_final.Fill( t_in.dimuon_rec_m[index] ) # h_m_lljj.Fill( t_in.lljj_m ) h_y12.Fill( t_in.y12 ) h_y23.Fill( t_in.y23 ) h_y34.Fill( t_in.y34 ) save_pid( t_in ) # Get event flow histogram @ Higgs2zz.cc copy_histo(fin, 'hevtflw', h_evtflw_pre) # Writ histograms & Close file write_histograms() fout.Close() if entries > 0 : pbar.finish() # dur = time()-time_start dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): args = sys.argv[2:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] if len(args) == 3: # default: all pass flag = 0 else: # or , set flag flag = int(args[2]) combine_opt = int(sys.argv[5]) fin = ROOT.TFile(infile) t_in = fin.Get('tree') entries = t_in.GetEntriesFast() if entries > 0: pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() # output file & TTree definition fout = ROOT.TFile(outfile, "RECREATE") t = ROOT.TTree('Higgs Tree', 'Higgs Tree') dimuon_m = array('d', [0]) dimuon_rec_m = array('d', [0]) dijet_m = array('d', [0]) dijet_rec_m = array('d', [0]) vis_ex_dimuon_m = array('d', [0]) vis_all_rec_m = array('d', [0]) vis_all_pt = array('d', [0]) vis_all_m = array('d', [0]) vis_all_p = array('d', [0]) vis_all_rec_m = array('d', [0]) vis_all_cos = array('d', [0]) npfo = array('d', [0]) cos = array('d', [0]) jet_lead_e = array('d', [0]) jet_sub_e = array('d', [0]) angle_mj = array('d', [0]) t.Branch('dimuon_m', dimuon_m, 'dimuon_m/D') t.Branch('dimuon_rec_m', dimuon_rec_m, 'dimuon_rec_m/D') t.Branch('dijet_m', dijet_m, 'dijet_m/D') t.Branch('dijet_rec_m', dijet_rec_m, 'dijet_rec_m/D') t.Branch('vis_ex_dimuon_m', vis_ex_dimuon_m, 'vis_ex_dimuon_m/D') t.Branch('vis_all_rec_m', vis_all_rec_m, 'vis_all_rec_m/D') t.Branch('vis_all_pt', vis_all_pt, 'vis_all_pt/D') t.Branch('vis_all_m', vis_all_m, 'vis_all_m/D') t.Branch('vis_all_p', vis_all_p, 'vis_all_p/D') t.Branch('vis_all_rec_m', vis_all_rec_m, 'vis_all_rec_m/D') t.Branch('npfo', npfo, 'npfo/D') t.Branch('jet_lead_e', jet_lead_e, 'jet_lead_e/D') t.Branch('jet_sub_e', jet_sub_e, 'jet_sub_e/D') t.Branch('angle_mj', angle_mj, 'angle_mj/D') t.Branch('vis_all_cos', vis_all_cos, 'vis_all_cos/D') t.Branch('cos', cos, 'cos/D') if combine_opt == 1: if ZZ_Selection == 1: h_evtflw.GetXaxis().SetBinLabel(1, 'pre-selection') h_evtflw.GetXaxis().SetBinLabel(2, 'is signal') h_evtflw.GetXaxis().SetBinLabel(3, 'M(miss)>M(dijet)') h_evtflw.GetXaxis().SetBinLabel(4, '80GeV<M(dimuon)<100GeV') h_evtflw.GetXaxis().SetBinLabel(5, '120GeV<RecM(dimuon)<142GeV') h_evtflw.GetXaxis().SetBinLabel(6, '20<Npfo<67') h_evtflw.GetXaxis().SetBinLabel(7, 'visible PT>10GeV') h_evtflw.GetXaxis().SetBinLabel(8, 'Mininum angle>17.2') h_evtflw.GetXaxis().SetBinLabel( 9, '80GeV<M(miss)<105GeV, 10GeV<M(dijet)<43GeV') h_evtflw.GetXaxis().SetBinLabel(10, 'JetE>5GeV,JetPt>3GeV') h_evtflw.GetXaxis().SetBinLabel( 11, 'RecM(dijet)<122GeV + 128GeV<RecM(dijet)') h_evtflw.GetXaxis().SetBinLabel( 12, 'vis_all_m<122GeV + 128GeV<vis_all_m') if ZZ_Selection == 2: h_evtflw.GetXaxis().SetBinLabel(1, 'pre-selection') h_evtflw.GetXaxis().SetBinLabel(2, 'is signal') h_evtflw.GetXaxis().SetBinLabel(3, 'M(miss)<M(dijet)') h_evtflw.GetXaxis().SetBinLabel(4, '80GeV<M(dimuon)<100GeV') h_evtflw.GetXaxis().SetBinLabel(5, '120GeV<RecM(dimuon)<142GeV') h_evtflw.GetXaxis().SetBinLabel(6, '30<Npfo<100') h_evtflw.GetXaxis().SetBinLabel(7, '10GeV<visible PT<50GeV') h_evtflw.GetXaxis().SetBinLabel(8, '17.2<Mininum angle<90') h_evtflw.GetXaxis().SetBinLabel(9, 'M(miss),M(dijet)') h_evtflw.GetXaxis().SetBinLabel(10, 'JetE,JetPt,JetAngle') h_evtflw.GetXaxis().SetBinLabel( 11, 'RecM(dijet)<122GeV + 128GeV<RecM(dijet)') h_evtflw.GetXaxis().SetBinLabel( 12, 'vis_all_m<122GeV + 128GeV<vis_all_m') if combine_opt == 2: h_evtflw.GetXaxis().SetBinLabel(1, 'pre-selection') h_evtflw.GetXaxis().SetBinLabel(2, 'is signal') h_evtflw.GetXaxis().SetBinLabel(3, 'Npfo > 9') h_evtflw.GetXaxis().SetBinLabel(4, '115Gev<Vis_Mass<135GeV') h_evtflw.GetXaxis().SetBinLabel(5, '|cos_theta|<0.9') h_evtflw.GetXaxis().SetBinLabel(6, '130GeV<RecM(dimuon)<220GeV') h_evtflw.GetXaxis().SetBinLabel(7, '43GeV<vis_all_p<60GeV') h_evtflw.GetXaxis().SetBinLabel(8, '10GeV<M(dijet)<100GeV') h_evtflw.GetXaxis().SetBinLabel(9, '10GeV<jet_lead_e<95GeV') h_evtflw.GetXaxis().SetBinLabel(10, 'jet_sub_e') h_evtflw.GetXaxis().SetBinLabel(11, 'angle_mj') h_evtflw.GetXaxis().SetBinLabel(12, '13GeV<M(dimuon)<100GeV') h_evtflw.GetXaxis().SetBinLabel(13, 'vis_all_cos') h_evtflw.GetXaxis().SetBinLabel(14, '80GeV<RecM(vis_all)<107GeV') h_evtflw.GetXaxis().SetBinLabel( 15, 'RecM(dimuon)<122GeV + 128GeV<RecM(dimuon)') h_evtflw.GetXaxis().SetBinLabel( 16, 'RecM(dijet)<122GeV + 128GeV<RecM(dijet)') if combine_opt == 3: if ZZ_Selection == 1: h_evtflw.GetXaxis().SetBinLabel(1, 'pre-selection') h_evtflw.GetXaxis().SetBinLabel(2, 'is signal') h_evtflw.GetXaxis().SetBinLabel(3, 'M(missing)>M(dimuon)') h_evtflw.GetXaxis().SetBinLabel(4, '35<Npfo<107') h_evtflw.GetXaxis().SetBinLabel(5, '114Gev<Vis_Mass<154GeV') h_evtflw.GetXaxis().SetBinLabel(6, '-0.94<cos_theta<0.95') h_evtflw.GetXaxis().SetBinLabel(7, '193GeV<RecM(dimuon)<212GeV') h_evtflw.GetXaxis().SetBinLabel(8, '16GeV<vis_all_p<72GeV') h_evtflw.GetXaxis().SetBinLabel(9, '76GeV<M(dijet)<104GeV') h_evtflw.GetXaxis().SetBinLabel(10, '47GeV<jet_lead_e<83GeV') h_evtflw.GetXaxis().SetBinLabel(11, '23GeV<jet_sub_e<55GeV') h_evtflw.GetXaxis().SetBinLabel(12, '20<angle_mj<175') h_evtflw.GetXaxis().SetBinLabel(13, '12GeV<M(dimuon)<43GeV') h_evtflw.GetXaxis().SetBinLabel(14, '-0.84<vis_all_cos<0.86') h_evtflw.GetXaxis().SetBinLabel(15, '69GeV<RecM(vis_all)<111GeV') h_evtflw.GetXaxis().SetBinLabel(16, '10GeV<vis_all_pt<71GeV') h_evtflw.GetXaxis().SetBinLabel( 17, 'RecM(dimuon)<122GeV + 128GeV<RecM(dimuon)') h_evtflw.GetXaxis().SetBinLabel( 18, 'vis_all_m<122GeV + 128GeV<vis_all_m') if ZZ_Selection == 2: h_evtflw.GetXaxis().SetBinLabel(1, 'pre-selection') h_evtflw.GetXaxis().SetBinLabel(2, 'is signal') h_evtflw.GetXaxis().SetBinLabel(3, 'M(missing)<M(dimuon)') h_evtflw.GetXaxis().SetBinLabel(4, '29<Npfo<105') h_evtflw.GetXaxis().SetBinLabel(5, '164Gev<Vis_Mass<222GeV') h_evtflw.GetXaxis().SetBinLabel(6, '-0.94<cos_theta<0.95') h_evtflw.GetXaxis().SetBinLabel(7, '114GeV<RecM(dimuon)<161GeV') h_evtflw.GetXaxis().SetBinLabel(8, '4GeV<vis_all_p<62GeV') h_evtflw.GetXaxis().SetBinLabel(9, '69GeV<M(dijet)<110GeV') h_evtflw.GetXaxis().SetBinLabel(10, '44GeV<jet_lead_e<83GeV') h_evtflw.GetXaxis().SetBinLabel(11, '22GeV<jet_sub_e<58GeV') h_evtflw.GetXaxis().SetBinLabel(12, '95<angle_mj<171') h_evtflw.GetXaxis().SetBinLabel(13, '57GeV<M(dimuon)<95GeV') h_evtflw.GetXaxis().SetBinLabel(14, '-0.84<vis_all_cos<0.86') h_evtflw.GetXaxis().SetBinLabel(15, '15GeV<RecM(vis_all)<61GeV') h_evtflw.GetXaxis().SetBinLabel(16, '8GeV<vis_all_pt<48GeV') h_evtflw.GetXaxis().SetBinLabel( 17, 'RecM(dimuon)<122GeV + 128GeV<RecM(dimuon)') h_evtflw.GetXaxis().SetBinLabel( 18, 'vis_all_m<122GeV + 128GeV<vis_all_m') for jentry in xrange(entries): pbar.update(jentry + 1) # get the next tree in the chain and verify ientry = t_in.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t_in.GetEntry(jentry) if nb <= 0: continue # raw event number h_evtflw.Fill(0) if is_sel(t_in, flag, combine_opt): fill_histograms(t_in, flag, combine_opt) if select_higgs_to_zz(t_in, combine_opt): index = 0 h_m_dimuon_final.Fill(t_in.dimuon_m[index]) h_mrec_dimuon_final.Fill(t_in.dimuon_rec_m[index]) h_m_dijet_final.Fill(t_in.dijet_m[0]) h_mrec_dijet_final.Fill(t_in.dijet_rec_m[0]) h_m_visible_final.Fill(t_in.vis_ex_dimuon_m) h_m_missing_final.Fill(t_in.vis_all_rec_m) h_vis_all_pt_final.Fill(t_in.vis_all_pt) h_vis_all_m_final.Fill(t_in.vis_all_m) h_vis_all_p_final.Fill(t_in.vis_all_p) h_vis_all_rec_m_final.Fill(t_in.vis_all_rec_m) h_vis_all_cos_final.Fill(t_in.vis_all_cos) h_cos_final.Fill(t_in.cos) h_npfo_final.Fill(t_in.n_col_reco) h_jet_lead_e_final.Fill(t_in.jet_lead_e[0]) h_jet_sub_e_final.Fill(t_in.jet_sub_e[0]) h_angle_mj_final.Fill(t_in.lj_angle) h_2D_visible_missing_final.Fill(t_in.vis_ex_dimuon_m, t_in.vis_all_rec_m) h_2D_dijet_missing_final.Fill(t_in.dijet_m[0], t_in.vis_all_rec_m) h_2D_dimuon_missing_final.Fill(t_in.dimuon_m[0], t_in.vis_all_rec_m) # h_m_lljj.Fill( t_in.lljj_m ) h_y12.Fill(t_in.y12) h_y23.Fill(t_in.y23) h_y34.Fill(t_in.y34) h_m_mc_zz_flag.Fill(t_in.mc_zz_flag) save_pid(t_in) dimuon_m[0] = t_in.dimuon_m[index] dimuon_rec_m[0] = t_in.dimuon_rec_m[index] dijet_m[0] = t_in.dijet_m[0] dijet_rec_m[0] = t_in.dijet_rec_m[0] vis_ex_dimuon_m[0] = t_in.vis_ex_dimuon_m vis_all_rec_m[0] = t_in.vis_all_rec_m vis_all_pt[0] = t_in.vis_all_pt vis_all_m[0] = t_in.vis_all_m vis_all_p[0] = t_in.vis_all_p vis_all_rec_m[0] = t_in.vis_all_rec_m vis_all_cos[0] = t_in.vis_all_cos cos[0] = t_in.cos npfo[0] = t_in.n_col_reco jet_lead_e[0] = t_in.jet_lead_e[0] jet_sub_e[0] = t_in.jet_sub_e[0] angle_mj[0] = t_in.lj_angle t.Fill() fout.Write() # Get event flow histogram @ Higgs2zz.cc copy_histo(fin, 'hevtflw', h_evtflw_pre) # Writ histograms & Close file write_histograms() fout.Close() if entries > 0: pbar.finish() dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): args = sys.argv[1:] if len(args) < 5: return usage() infile = args[0] evtflow_file = args[1] outfile = args[2] combine_opt = int(args[3]) flag_zz = int(args[4]) ## Event Flow h_evtflw = ROOT.TH1D('hevtflw_sel', 'eventflow', 12, 0, 12) if (combine_opt == 1): last_bin = 11 if (combine_opt == 2): last_bin = 11 if (combine_opt == 3): last_bin = 11 h_evtflw.GetXaxis().SetBinLabel(last_bin, 'BDT score') fin = ROOT.TFile(infile) t_in = fin.Get('tree') entries = t_in.GetEntriesFast() if entries > 0: pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() # Get event flow histogram @BDT_pre.python evtflow_fin = ROOT.TFile(evtflow_file) copy_histo(evtflow_fin, 'h_evtflw_beforeBDT', h_evtflw, combine_opt) # output file fout = ROOT.TFile(outfile, "RECREATE") t = ROOT.TTree('Higgs Tree', 'Higgs Tree') dimuon_m = array('d', [0]) dijet_m = array('d', [0]) vis_all_rec_m = array('d', [0]) n_col_reco = array('i', [0]) cos = array('d', [0]) vis_all_cos = array('d', [0]) dimuon_dijet_angle = array('d', [0]) dimuon_rec_m = array('d', [0]) dijet_rec_m = array('d', [0]) vis_all_m = array('d', [0]) vis_all_p = array('d', [0]) vis_all_pt = array('d', [0]) jet_lead_e = array('d', [0]) jet_lead_pt = array('d', [0]) jet_sub_e = array('d', [0]) jet_sub_pt = array('d', [0]) BDT_score = array('d', [0]) t.Branch('dimuon_m', dimuon_m, 'dimuon_m/D') t.Branch('dijet_m', dijet_m, 'dijet_m/D') t.Branch('vis_all_rec_m', vis_all_rec_m, 'vis_all_rec_m/D') t.Branch('n_col_reco', n_col_reco, 'n_col_reco/I') t.Branch('cos', cos, 'cos/D') t.Branch('vis_all_cos', vis_all_cos, 'vis_all_cos/D') t.Branch('dimuon_dijet_angle', dimuon_dijet_angle, 'dimuon_dijet_angle/D') t.Branch('dimuon_rec_m', dimuon_rec_m, 'dimuon_rec_m/D') t.Branch('dijet_rec_m', dijet_rec_m, 'dijet_rec_m/D') t.Branch('vis_all_m', vis_all_m, 'vis_all_m/D') t.Branch('vis_all_p', vis_all_p, 'vis_all_p/D') t.Branch('vis_all_pt', vis_all_pt, 'vis_all_pt/D') t.Branch('jet_lead_e', jet_lead_e, 'jet_lead_e/D') t.Branch('jet_lead_pt', jet_lead_pt, 'jet_lead_pt/D') t.Branch('jet_sub_e', jet_sub_e, 'jet_sub_e/D') t.Branch('jet_sub_pt', jet_sub_pt, 'jet_sub_pt/D') t.Branch('BDT_score', BDT_score, 'BDT_score/D') # read trees for jentry in xrange(entries): pbar.update(jentry + 1) # get the next tree in the chain and verify ientry = t_in.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify nb = t_in.GetEntry(jentry) if nb <= 0: continue h_dimuon_rec_m_raw.Fill(t_in.dimuon_rec_m) h_dijet_rec_m_raw.Fill(t_in.dijet_rec_m) h_vis_all_p_raw.Fill(t_in.vis_all_p) h_vis_all_pt_raw.Fill(t_in.vis_all_pt) h_vis_all_m_raw.Fill(t_in.vis_all_m) h_dimuon_m_raw.Fill(t_in.dimuon_m) h_dijet_m_raw.Fill(t_in.dijet_m) h_vis_all_rec_m_raw.Fill(t_in.vis_all_rec_m) h_jet_lead_e_raw.Fill(t_in.jet_lead_e) h_jet_lead_pt_raw.Fill(t_in.jet_lead_pt) h_jet_sub_e_raw.Fill(t_in.jet_sub_e) h_jet_sub_pt_raw.Fill(t_in.jet_sub_pt) h_dimuon_dijet_angle_raw.Fill(t_in.dimuon_dijet_angle) h_n_col_reco_raw.Fill(t_in.n_col_reco) h_cos_raw.Fill(t_in.cos) h_vis_all_cos_raw.Fill(t_in.vis_all_cos) h_BDT_score_raw.Fill(t_in.BDT_score) if (combine_opt == 1): if (flag_zz == 1): Cut_BDT_score = (t_in.BDT_score > 0.14) if (flag_zz == 2): Cut_BDT_score = (t_in.BDT_score > 0.01) if (combine_opt == 2): if (flag_zz == 1): Cut_BDT_score = (t_in.BDT_score > -0.01) if (flag_zz == 2): Cut_BDT_score = (t_in.BDT_score > -0.01) if (combine_opt == 3): if (flag_zz == 1): Cut_BDT_score = (t_in.BDT_score > -0.04) if (flag_zz == 2): Cut_BDT_score = (t_in.BDT_score > -0.01) if (Cut_BDT_score): h_dimuon_rec_m_final.Fill(t_in.dimuon_rec_m) h_dijet_rec_m_final.Fill(t_in.dijet_rec_m) h_vis_all_p_final.Fill(t_in.vis_all_p) h_vis_all_pt_final.Fill(t_in.vis_all_pt) h_vis_all_m_final.Fill(t_in.vis_all_m) h_dimuon_m_final.Fill(t_in.dimuon_m) h_dijet_m_final.Fill(t_in.dijet_m) h_vis_all_rec_m_final.Fill(t_in.vis_all_rec_m) h_jet_lead_e_final.Fill(t_in.jet_lead_e) h_jet_lead_pt_final.Fill(t_in.jet_lead_pt) h_jet_sub_e_final.Fill(t_in.jet_sub_e) h_jet_sub_pt_final.Fill(t_in.jet_sub_pt) h_dimuon_dijet_angle_final.Fill(t_in.dimuon_dijet_angle) h_n_col_reco_final.Fill(t_in.n_col_reco) h_cos_final.Fill(t_in.cos) h_vis_all_cos_final.Fill(t_in.vis_all_cos) h_BDT_score_final.Fill(t_in.BDT_score) dimuon_m[0] = t_in.dimuon_m dijet_m[0] = t_in.dijet_m vis_all_rec_m[0] = t_in.vis_all_rec_m n_col_reco[0] = t_in.n_col_reco cos[0] = t_in.cos vis_all_cos[0] = t_in.vis_all_cos dimuon_dijet_angle[0] = t_in.dimuon_dijet_angle dimuon_rec_m[0] = t_in.dimuon_rec_m dijet_rec_m[0] = t_in.dijet_rec_m vis_all_m[0] = t_in.vis_all_m vis_all_p[0] = t_in.vis_all_p vis_all_pt[0] = t_in.vis_all_pt jet_lead_e[0] = t_in.jet_lead_e jet_lead_pt[0] = t_in.jet_lead_pt jet_sub_e[0] = t_in.jet_sub_e jet_sub_pt[0] = t_in.jet_sub_pt BDT_score[0] = t_in.BDT_score t.Fill() # Fill event flow if (combine_opt == 1): h_evtflw.Fill(10) if (combine_opt == 2): h_evtflw.Fill(10) if (combine_opt == 3): h_evtflw.Fill(10) fout.Write() h_evtflw.Write() h_dimuon_rec_m_raw.Write() h_dijet_rec_m_raw.Write() h_vis_all_p_raw.Write() h_vis_all_pt_raw.Write() h_vis_all_m_raw.Write() h_dimuon_m_raw.Write() h_dijet_m_raw.Write() h_vis_all_rec_m_raw.Write() h_jet_lead_e_raw.Write() h_jet_lead_pt_raw.Write() h_jet_sub_e_raw.Write() h_jet_sub_pt_raw.Write() h_dimuon_dijet_angle_raw.Write() h_n_col_reco_raw.Write() h_cos_raw.Write() h_vis_all_cos_raw.Write() h_BDT_score_raw.Write() h_dimuon_rec_m_final.Write() h_dijet_rec_m_final.Write() h_vis_all_p_final.Write() h_vis_all_pt_final.Write() h_vis_all_m_final.Write() h_dimuon_m_final.Write() h_dijet_m_final.Write() h_vis_all_rec_m_final.Write() h_jet_lead_e_final.Write() h_jet_lead_pt_final.Write() h_jet_sub_e_final.Write() h_jet_sub_pt_final.Write() h_dimuon_dijet_angle_final.Write() h_n_col_reco_final.Write() h_cos_final.Write() h_vis_all_cos_final.Write() h_BDT_score_final.Write() # Writ histograms & Close file fout.Close() if entries > 0: pbar.finish() dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] print "outfile : ",outfile check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() fout = ROOT.TFile(outfile, "RECREATE") t_out = ROOT.TTree('signal', 'signal') t_out.Branch('run', n_run, 'run/I') t_out.Branch('event', n_event, 'event/I') t_out.Branch('indexmc', n_indexmc, 'indexmc/I') t_out.Branch('pdgid', n_pdgid, 'pdgid[100]/I') t_out.Branch('motheridx', n_motheridx, 'motheridx[100]/I') # mystruct = ROOT.MyTreeStruct() t_out.Branch('vtx_mrecpipi',vtx_mrecpipi) for jentry in xrange(entries): pbar.update(jentry+1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb<=0: continue # if t.run > 25600: # continue # if (t.run > 26200 or t.run < 25600 ): # continue # if (t.run > 26600 or t.run < 26200 ): # continue # if (t.run > 26900 or t.run < 26600 ): # continue # if t.run < 26900: # continue # if t.run < 10000: if t.run > 10000: continue #print type(vtx_mrecpipi) #print dir(ROOT.vector.__doc__) # if NonPiPiJpsi: # Non-PiPiJpsi # if not ( check_pipiJpsi(t) ): # fill_histograms_all_combination(t) # else: # Normal # fill_histograms_all_combination(t) fill_histograms_all_combination(t, t_out) select_jpsi_to_inclusive(t) # h_mrecpipi.Fill(t.vtx_mrecpipi) # h_mrecpipi_fit.Fill(t.vtx_mrecpipi) # mystruct.vtx_mrecpipi = t.vtx_mrecpipi # t_out.Fill() t_out.Fill() t_out.Write() write_histograms() fout.Close() pbar.finish() dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): args = sys.argv[1:] if len(args) < 5: return usage() infile = args[0] outfile = args[1] combine_opt = int(args[2]) flag_zz = int(args[3]) flag = int(args[4]) fin = ROOT.TFile(infile) t_in = fin.Get('tree') entries = t_in.GetEntriesFast() if entries > 0: pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() # event flow plot definition h_evtflw.GetXaxis().SetBinLabel(1,'Raw') h_evtflw.GetXaxis().SetBinLabel(2,'Pre-selection') h_evtflw.GetXaxis().SetBinLabel(3,'Is signal') if (combine_opt==1): if (flag_zz==1): h_evtflw.GetXaxis().SetBinLabel(4,'M_miss > M_dijet') h_evtflw.GetXaxis().SetBinLabel(5,'20<npfo<90') h_evtflw.GetXaxis().SetBinLabel(6,'80<M_dimuon<100') h_evtflw.GetXaxis().SetBinLabel(7,'110<M_dimuon_rec<140') h_evtflw.GetXaxis().SetBinLabel(8,'|Vis_all_cos|<0.95') h_evtflw.GetXaxis().SetBinLabel(9,'2D Mass Cut 1') h_evtflw.GetXaxis().SetBinLabel(10,'2D Mass Cut 2') if (flag_zz==2): h_evtflw.GetXaxis().SetBinLabel(4,'M_miss < M_dijet') h_evtflw.GetXaxis().SetBinLabel(5,'30<npfo<100') h_evtflw.GetXaxis().SetBinLabel(6,'80<M_dimuon<100') h_evtflw.GetXaxis().SetBinLabel(7,'110<M_dimuon_rec<140') h_evtflw.GetXaxis().SetBinLabel(8,'|Vis_all_cos|<0.95') h_evtflw.GetXaxis().SetBinLabel(9,'2D Mass Cut 1') h_evtflw.GetXaxis().SetBinLabel(10,'2D Mass Cut 2') if (combine_opt==2): if (flag_zz==1): h_evtflw.GetXaxis().SetBinLabel(4,'M_dimuon > M_dijet') h_evtflw.GetXaxis().SetBinLabel(5,'20<npfo<60') h_evtflw.GetXaxis().SetBinLabel(6,'75<M_missing<110') h_evtflw.GetXaxis().SetBinLabel(7,'110<M_visible<140') h_evtflw.GetXaxis().SetBinLabel(8,'|Vis_all_cos|<0.95') h_evtflw.GetXaxis().SetBinLabel(9,'2D Mass Cut 1') h_evtflw.GetXaxis().SetBinLabel(10,'2D Mass Cut 2') if (flag_zz==1): h_evtflw.GetXaxis().SetBinLabel(4,'M_dimuon < M_dijet') h_evtflw.GetXaxis().SetBinLabel(5,'30<npfo<100') h_evtflw.GetXaxis().SetBinLabel(6,'75<M_missing<110') h_evtflw.GetXaxis().SetBinLabel(7,'110<M_visible<140') h_evtflw.GetXaxis().SetBinLabel(8,'|Vis_all_cos|<0.95') h_evtflw.GetXaxis().SetBinLabel(9,'2D Mass Cut 1') h_evtflw.GetXaxis().SetBinLabel(10,'2D Mass Cut 2') if (combine_opt==3): if (flag_zz==1): h_evtflw.GetXaxis().SetBinLabel(4,'M_missing > M_dimuon') h_evtflw.GetXaxis().SetBinLabel(5,'40<npfo<95') h_evtflw.GetXaxis().SetBinLabel(6,'75<M_dijet<105') h_evtflw.GetXaxis().SetBinLabel(7,'110<M_dijet_rec<140') h_evtflw.GetXaxis().SetBinLabel(8,'|Vis_all_cos|<0.95') h_evtflw.GetXaxis().SetBinLabel(9,'2D Mass Cut 1') h_evtflw.GetXaxis().SetBinLabel(10,'2D Mass Cut 2') if (flag_zz==2): h_evtflw.GetXaxis().SetBinLabel(4,'M_missing < M_dimuon') h_evtflw.GetXaxis().SetBinLabel(5,'40<npfo<95') h_evtflw.GetXaxis().SetBinLabel(6,'75<M_dijet<105') h_evtflw.GetXaxis().SetBinLabel(7,'110<M_dijet_rec<140') h_evtflw.GetXaxis().SetBinLabel(8,'|Vis_all_cos|<0.95') h_evtflw.GetXaxis().SetBinLabel(9,'2D Mass Cut 1') h_evtflw.GetXaxis().SetBinLabel(10,'2D Mass Cut 2') # event flow copying h_evtflw_in = fin.Get("hevtflw") c1 = h_evtflw_in.GetBinContent(1) h_evtflw.SetBinContent(1, c1) # output file fout = ROOT.TFile(outfile, "RECREATE") t = ROOT.TTree('tree', 'tree') dimuon_m = array( 'd', [0] ) dijet_m = array( 'd', [0] ) vis_all_rec_m = array( 'd', [0] ) n_col_reco = array( 'i', [0] ) cos = array( 'd', [0] ) vis_all_cos = array( 'd', [0] ) dimuon_dijet_angle = array( 'd', [0] ) dimuon_rec_m = array( 'd', [0] ) dijet_rec_m = array( 'd', [0] ) vis_all_m = array( 'd', [0] ) vis_all_p = array( 'd', [0] ) vis_all_pt = array( 'd', [0] ) jet_lead_e = array( 'd', [0] ) jet_lead_pt = array( 'd', [0] ) jet_sub_e = array( 'd', [0] ) jet_sub_pt = array( 'd', [0] ) dalitz_mzz = array( 'd', [0] ) dalitz_mzz_star = array( 'd', [0] ) t.Branch( 'dimuon_m', dimuon_m, 'dimuon_m/D') t.Branch( 'dijet_m', dijet_m, 'dijet_m/D') t.Branch( 'vis_all_rec_m', vis_all_rec_m, 'vis_all_rec_m/D') t.Branch( 'n_col_reco', n_col_reco, 'n_col_reco/I') t.Branch( 'cos', cos, 'cos/D') t.Branch( 'vis_all_cos', vis_all_cos, 'vis_all_cos/D') t.Branch( 'dimuon_dijet_angle', dimuon_dijet_angle, 'dimuon_dijet_angle/D') t.Branch( 'dimuon_rec_m', dimuon_rec_m, 'dimuon_rec_m/D') t.Branch( 'dijet_rec_m', dijet_rec_m, 'dijet_rec_m/D') t.Branch( 'vis_all_m', vis_all_m, 'vis_all_m/D') t.Branch( 'vis_all_p', vis_all_p, 'vis_all_p/D') t.Branch( 'vis_all_pt', vis_all_pt, 'vis_all_pt/D') t.Branch( 'jet_lead_e', jet_lead_e, 'jet_lead_e/D') t.Branch( 'jet_lead_pt', jet_lead_pt, 'jet_lead_pt/D') t.Branch( 'jet_sub_e', jet_sub_e, 'jet_sub_e/D') t.Branch( 'jet_sub_pt', jet_sub_pt, 'jet_sub_pt/D') # read trees for jentry in xrange(entries): pbar.update(jentry+1) #get the next tree in the chain and verify ientry = t_in.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify nb = t_in.GetEntry(jentry) if nb<=0: continue # Raw event number (after pre-selection) h_evtflw.Fill(1) # use truth information of not sel = 0 if( flag==0 and is_signal(t_in, combine_opt) ): sel = 1 # not Signal if( flag==1 and not(is_signal(t_in, combine_opt)) ): sel = 1 if( flag==2 ): sel = 1 # Cut begins if (sel): if (combine_opt==1): if (flag_zz==1): Cut_Missing_dijet = ( t_in.vis_all_rec_m > t_in.dijet_m[0] ) Cut_Npfo = ( 20 < t_in.n_col_reco and t_in.n_col_reco < 90 ) Cut_Dimuon_Mass = ( 80 < t_in.dimuon_m[0] and t_in.dimuon_m[0] < 100 ) Cut_Dimuon_Rec_Mass = ( 110 < t_in.dimuon_rec_m[0] and t_in.dimuon_rec_m[0] < 140 ) Cut_Vis_Cos = ( -0.95 < t_in.vis_all_cos and t_in.vis_all_cos < 0.95 ) if (flag_zz==2): Cut_Missing_dijet = ( t_in.vis_all_rec_m < t_in.dijet_m[0] ) Cut_Npfo = ( 30 < t_in.n_col_reco and t_in.n_col_reco < 100 ) Cut_Dimuon_Mass = ( 80 < t_in.dimuon_m[0] and t_in.dimuon_m[0] < 100 ) Cut_Dimuon_Rec_Mass = ( 110 < t_in.dimuon_rec_m[0] and t_in.dimuon_rec_m[0] < 140 ) Cut_Vis_Cos = ( -0.95 < t_in.vis_all_cos and t_in.vis_all_cos < 0.95 ) Cut_2D_1 = ( (t_in.dimuon_rec_m[0] > t_in.dijet_rec_m[0] and t_in.dimuon_rec_m[0] < (-t_in.dijet_rec_m[0]+250)) or (t_in.dimuon_rec_m[0] < t_in.dijet_rec_m[0] and t_in.dimuon_rec_m[0] > (-t_in.dijet_rec_m[0]+250)) ) Cut_2D_2 = ( (t_in.dimuon_rec_m[0] > t_in.vis_all_m and t_in.dimuon_rec_m[0] < (-t_in.vis_all_m+250)) or (t_in.dimuon_rec_m[0] < t_in.vis_all_m and t_in.dimuon_rec_m[0] > (-t_in.vis_all_m+250)) ) BDT_pre_cut = 0 BDT_pre_cut = Cut_Missing_dijet * Cut_Npfo * Cut_Dimuon_Mass * Cut_Dimuon_Rec_Mass * Cut_Vis_Cos * Cut_2D_1 * Cut_2D_2 # event flow and filling h_evtflw.Fill(2) if (Cut_Missing_dijet): h_evtflw.Fill(3) if (Cut_Missing_dijet and Cut_Npfo): h_evtflw.Fill(4) if (Cut_Missing_dijet and Cut_Npfo and Cut_Dimuon_Mass): h_evtflw.Fill(5) if (Cut_Missing_dijet and Cut_Npfo and Cut_Dimuon_Mass and Cut_Dimuon_Rec_Mass): h_evtflw.Fill(6) if (Cut_Missing_dijet and Cut_Npfo and Cut_Dimuon_Mass and Cut_Dimuon_Rec_Mass and Cut_Vis_Cos): h_evtflw.Fill(7) if (Cut_Missing_dijet and Cut_Npfo and Cut_Dimuon_Mass and Cut_Dimuon_Rec_Mass and Cut_Vis_Cos and Cut_2D_1): h_evtflw.Fill(8) if (Cut_Missing_dijet and Cut_Npfo and Cut_Dimuon_Mass and Cut_Dimuon_Rec_Mass and Cut_Vis_Cos and Cut_2D_1 and Cut_2D_2): h_evtflw.Fill(9) if (combine_opt==2): if (flag_zz==1): Cut_Dimuon_dijet = ( t_in.dimuon_m[0] > t_in.dijet_m[0] ) Cut_Npfo = ( 20 < t_in.n_col_reco and t_in.n_col_reco < 60 ) Cut_Missing_Mass = ( 75 < t_in.vis_all_rec_m and t_in.vis_all_rec_m < 110 ) Cut_Visible_Mass = ( 110 < t_in.vis_all_m and t_in.vis_all_m < 140 ) Cut_Vis_Cos = ( -0.95 < t_in.vis_all_cos and t_in.vis_all_cos < 0.95 ) if (flag_zz==2): Cut_Dimuon_dijet = ( t_in.dimuon_m[0] < t_in.dijet_m[0] ) Cut_Npfo = ( 30 < t_in.n_col_reco and t_in.n_col_reco < 100 ) Cut_Missing_Mass = ( 75 < t_in.vis_all_rec_m and t_in.vis_all_rec_m < 110 ) Cut_Visible_Mass = ( 110 < t_in.vis_all_m and t_in.vis_all_m < 140 ) Cut_Vis_Cos = ( -0.95 < t_in.vis_all_cos and t_in.vis_all_cos < 0.95 ) Cut_2D_1 = ( (t_in.vis_all_m > t_in.dimuon_rec_m[0] and t_in.vis_all_m < (-t_in.dimuon_rec_m[0]+250)) or (t_in.vis_all_m < t_in.dimuon_rec_m[0] and t_in.vis_all_m > (-t_in.dimuon_rec_m[0]+250)) ) Cut_2D_2 = ( (t_in.vis_all_m > t_in.dijet_rec_m[0] and t_in.vis_all_m < (-t_in.dijet_rec_m[0]+250)) or (t_in.vis_all_m < t_in.dijet_rec_m[0] and t_in.vis_all_m > (-t_in.dijet_rec_m[0]+250)) ) BDT_pre_cut = 0 BDT_pre_cut = Cut_Dimuon_dijet * Cut_Npfo * Cut_Missing_Mass * Cut_Visible_Mass * Cut_Vis_Cos * Cut_2D_1 * Cut_2D_2 # event flow and filling h_evtflw.Fill(2) if (Cut_Dimuon_dijet): h_evtflw.Fill(3) if (Cut_Dimuon_dijet and Cut_Npfo): h_evtflw.Fill(4) if (Cut_Dimuon_dijet and Cut_Npfo and Cut_Missing_Mass): h_evtflw.Fill(5) if (Cut_Dimuon_dijet and Cut_Npfo and Cut_Missing_Mass and Cut_Visible_Mass): h_evtflw.Fill(6) if (Cut_Dimuon_dijet and Cut_Npfo and Cut_Missing_Mass and Cut_Visible_Mass and Cut_Vis_Cos): h_evtflw.Fill(7) if (Cut_Dimuon_dijet and Cut_Npfo and Cut_Missing_Mass and Cut_Visible_Mass and Cut_Vis_Cos and Cut_2D_1): h_evtflw.Fill(8) if (Cut_Dimuon_dijet and Cut_Npfo and Cut_Missing_Mass and Cut_Visible_Mass and Cut_Vis_Cos and Cut_2D_1 and Cut_2D_2): h_evtflw.Fill(9) if (combine_opt==3): if (flag_zz==1): Cut_Missing_dimuon = ( t_in.vis_all_rec_m > t_in.dimuon_m[0] ) Cut_Npfo = ( 40 < t_in.n_col_reco and t_in.n_col_reco < 95 ) Cut_Dijet_Mass = ( 75 < t_in.dijet_m[0] and t_in.dijet_m[0] < 105 ) Cut_Dijet_Rec_Mass = ( 110 < t_in.dijet_rec_m[0] and t_in.dijet_rec_m[0] < 140 ) Cut_Vis_Cos = ( -0.95 < t_in.vis_all_cos and t_in.vis_all_cos < 0.95 ) if (flag_zz==2): Cut_Missing_dimuon = ( t_in.vis_all_rec_m < t_in.dimuon_m[0] ) Cut_Npfo = ( 40 < t_in.n_col_reco and t_in.n_col_reco < 95 ) Cut_Dijet_Mass = ( 75 < t_in.dijet_m[0] and t_in.dijet_m[0] < 105 ) Cut_Dijet_Rec_Mass = ( 110 < t_in.dijet_rec_m[0] and t_in.dijet_rec_m[0] < 140 ) Cut_Vis_Cos = ( -0.95 < t_in.vis_all_cos and t_in.vis_all_cos < 0.95 ) Cut_2D_1 = ( (t_in.dijet_rec_m[0] > t_in.dimuon_rec_m[0] and t_in.dijet_rec_m[0] < (-t_in.dimuon_rec_m[0]+250)) or (t_in.dijet_rec_m[0] < t_in.dimuon_rec_m[0] and t_in.dijet_rec_m[0] > (-t_in.dimuon_rec_m[0]+250)) ) Cut_2D_2 = ( (t_in.dijet_rec_m[0] > t_in.vis_all_m and t_in.dijet_rec_m[0] < (-t_in.vis_all_m+250)) or (t_in.dijet_rec_m[0] < t_in.vis_all_m and t_in.dijet_rec_m[0] > (-t_in.vis_all_m+250)) ) BDT_pre_cut = 0 BDT_pre_cut = Cut_Missing_dimuon * Cut_Npfo * Cut_Dijet_Mass * Cut_Dijet_Rec_Mass * Cut_Vis_Cos * Cut_2D_1 * Cut_2D_2 # event flow and filling h_evtflw.Fill(2) if (Cut_Missing_dimuon): h_evtflw.Fill(3) if (Cut_Missing_dimuon and Cut_Npfo): h_evtflw.Fill(4) if (Cut_Missing_dimuon and Cut_Npfo and Cut_Dijet_Mass): h_evtflw.Fill(5) if (Cut_Missing_dimuon and Cut_Npfo and Cut_Dijet_Mass and Cut_Dijet_Rec_Mass): h_evtflw.Fill(6) if (Cut_Missing_dimuon and Cut_Npfo and Cut_Dijet_Mass and Cut_Dijet_Rec_Mass and Cut_Vis_Cos): h_evtflw.Fill(7) if (Cut_Missing_dimuon and Cut_Npfo and Cut_Dijet_Mass and Cut_Dijet_Rec_Mass and Cut_Vis_Cos and Cut_2D_1): h_evtflw.Fill(8) if (Cut_Missing_dimuon and Cut_Npfo and Cut_Dijet_Mass and Cut_Dijet_Rec_Mass and Cut_Vis_Cos and Cut_2D_1 and Cut_2D_2): h_evtflw.Fill(9) # Several cuts before BDT if (BDT_pre_cut): dimuon_m[0] = t_in.dimuon_m[0] dijet_m[0] = t_in.dijet_m[0] vis_all_rec_m[0] = t_in.vis_all_rec_m n_col_reco[0] = t_in.n_col_reco cos[0] = t_in.cos vis_all_cos[0] = t_in.vis_all_cos dimuon_dijet_angle[0] = t_in.lj_angle dimuon_rec_m[0] = t_in.dimuon_rec_m[0] dijet_rec_m[0] = t_in.dijet_rec_m[0] vis_all_m[0] = t_in.vis_all_m vis_all_p[0] = t_in.vis_all_p vis_all_pt[0] = t_in.vis_all_pt jet_lead_e[0] = t_in.jet_lead_e[0] jet_sub_e[0] = t_in.jet_sub_e[0] if (t_in.jet_e[0] > t_in.jet_e[1]): jet_lead_pt[0] = t_in.jet_pt[0] jet_sub_pt[0] = t_in.jet_pt[1] else: jet_lead_pt[0] = t_in.jet_pt[1] jet_sub_pt[0] = t_in.jet_pt[0] t.Fill() fout.Write() h_evtflw.Write() fout.Close() if entries > 0 : pbar.finish() dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() for jentry in xrange(entries): pbar.update(jentry + 1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb <= 0: continue fill_histograms(t) if select_jpsi_to_ll(t): cut_mu_eop_p = (abs(t.trklp_eraw / t.trklp_p) < 0.26) cut_mu_eop_m = (abs(t.trklm_eraw / t.trklm_p) < 0.26) cut_el_eop_p = (abs(t.trklp_eraw / t.trklp_p) > 0.80) cut_el_eop_m = (abs(t.trklm_eraw / t.trklm_p) > 0.80) cut_el_eop_pm = (math.sqrt( math.pow((t.trklp_eraw / t.trklp_p) - 1, 2) + math.pow((t.trklm_eraw / t.trklm_p) - 1, 2)) < 0.4) eop1 = abs(t.trklp_eraw / t.trklp_p) eop2 = abs(t.trklm_eraw / t.trklm_p) h_EOP.Fill(eop1, eop2) cut_invMass_el = (t.vtx_melel > 2.7 and t.vtx_melel < 3.2) cut_invMass_mu = (t.vtx_mmumu > 3.0 and t.vtx_mmumu < 3.2) if (t.jpsi2elel_flag == 1 and (cut_el_eop_p or cut_el_eop_m or cut_el_eop_pm) and cut_invMass_el): h_mrecpipi_el.Fill(t.vtx_mrecpipi) h_mrecpipi_el_fit.Fill(t.vtx_mrecpipi) h_melel.Fill(t.vtx_melel) h_elp_p.Fill(t.vtx_elp_p) h_elm_p.Fill(t.vtx_elm_p) h_elp_costhe.Fill(t.vtx_elp_costheta) h_elm_costhe.Fill(t.vtx_elm_costheta) h_coselel.Fill(t.vtx_coselel) if (t.jpsi2mumu_flag == 1 and (cut_mu_eop_p and cut_mu_eop_m) and cut_invMass_mu): h_mrecpipi_mu.Fill(t.vtx_mrecpipi) h_mmumu.Fill(t.vtx_mmumu) h_mup_p.Fill(t.vtx_mup_p) h_mum_p.Fill(t.vtx_mum_p) h_mup_costhe.Fill(t.vtx_mup_costheta) h_mum_costhe.Fill(t.vtx_mum_costheta) h_cosmumu.Fill(t.vtx_cosmumu) fout = ROOT.TFile(outfile, "RECREATE") write_histograms() fout.Close() pbar.finish() dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() fout = ROOT.TFile(outfile, "RECREATE") t_out = ROOT.TTree('signal', 'signal') t_out.Branch('run', n_run, 'run/I') t_out.Branch('event', n_event, 'event/I') t_out.Branch('indexmc', n_indexmc, 'indexmc/I') t_out.Branch('pdgid', n_pdgid, 'pdgid[100]/I') t_out.Branch('motheridx', n_motheridx, 'motheridx[100]/I') mystruct = ROOT.MyTreeStruct() t_out.Branch('vtx_mrecpipi', mystruct, 'vtx_mrecpipi/D') pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() # mystruct = ROOT.MyTreeStruct() for jentry in xrange(entries): pbar.update(jentry+1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb<=0: continue fill_histograms(t, t_out) if select_jpsi_to_invisible(t): h_mrecpipi.Fill(t.vtx_mrecpipi) h_mrecpipi_fit.Fill(t.vtx_mrecpipi) mystruct.vtx_mrecpipi = t.vtx_mrecpipi t_out.Fill() # fout = ROOT.TFile(outfile, "RECREATE") t_out.Write() write_histograms() fout.Close() pbar.finish() dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() # fout = ROOT.TFile(outfile, "RECREATE") # t_out = ROOT.TTree('signal', 'signal') # mystruct = ROOT.MyTreeStruct() ## mystruct2 = ROOT.MyTreeStruct2() # t_out.Branch('vtx_mrecpipi', mystruct, 'vtx_mrecpipi/D') # t_out.Branch('indexmc', mystruct2, 'indexmc/D') # t_out.Branch('pdgid', mystruct, 'm_pdgid[100]/I') # t_out.Branch('trkidx', mystruct, 'm_trkidx[100]/I') # t_out.Branch('motherpid', mystruct, 'm_motherpid[100]/I') # t_out.Branch('motheridx', mystruct, 'm_motheridx[100]/I') for jentry in xrange(entries): pbar.update(jentry + 1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb <= 0: continue if NonPiPiJpsi: # Non-PiPiJpsi if not (check_pipiJpsi(t)): fill_histograms_all_combination(t) else: # Normal fill_histograms_all_combination(t) fout = ROOT.TFile(outfile, "RECREATE") # t_out.Write() write_histograms() fout.Close() pbar.finish() dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() for jentry in xrange(entries): pbar.update(jentry+1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb<=0: continue fill_histograms(t) if select_jpsi_to_ll(t): cut_mu_eop_p = (abs(t.trklp_eraw/t.trklp_p) < 0.26) cut_mu_eop_m = (abs(t.trklm_eraw/t.trklm_p) < 0.26) cut_el_eop_p = (abs(t.trklp_eraw/t.trklp_p) > 0.80) cut_el_eop_m = (abs(t.trklm_eraw/t.trklm_p) > 0.80) cut_el_eop_pm = (math.sqrt( math.pow((t.trklp_eraw/t.trklp_p)-1 , 2) +math.pow((t.trklm_eraw/t.trklm_p)-1 , 2) ) < 0.4) eop1 = abs(t.trklp_eraw/t.trklp_p) eop2 = abs(t.trklm_eraw/t.trklm_p) h_EOP.Fill(eop1, eop2) cut_invMass_el = (t.vtx_melel > 2.7 and t.vtx_melel < 3.2) cut_invMass_mu = (t.vtx_mmumu > 3.0 and t.vtx_mmumu < 3.2) if (t.jpsi2elel_flag == 1 and (cut_el_eop_p or cut_el_eop_m or cut_el_eop_pm) and cut_invMass_el): h_mrecpipi_el.Fill(t.vtx_mrecpipi) h_mrecpipi_el_fit.Fill(t.vtx_mrecpipi) h_melel.Fill(t.vtx_melel) h_elp_p.Fill(t.vtx_elp_p) h_elm_p.Fill(t.vtx_elm_p) h_elp_costhe.Fill(t.vtx_elp_costheta) h_elm_costhe.Fill(t.vtx_elm_costheta) h_coselel.Fill(t.vtx_coselel) if (t.jpsi2mumu_flag == 1 and (cut_mu_eop_p and cut_mu_eop_m) and cut_invMass_mu): h_mrecpipi_mu.Fill(t.vtx_mrecpipi) h_mmumu.Fill(t.vtx_mmumu) h_mup_p.Fill(t.vtx_mup_p) h_mum_p.Fill(t.vtx_mum_p) h_mup_costhe.Fill(t.vtx_mup_costheta) h_mum_costhe.Fill(t.vtx_mum_costheta) h_cosmumu.Fill(t.vtx_cosmumu) fout = ROOT.TFile(outfile, "RECREATE") write_histograms() fout.Close() pbar.finish() dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() count0 = 0 count1 = 0 count2 = 0 count3 = 0 count4 = 0 count5 = 0 count6 = 0 count7 = 0 count8 = 0 count9 = 0 count10 = 0 count11 = 0 count12 = 0 count13 = 0 count14 = 0 count15 = 0 count_EMC_Track = 0 count_all = 0 for jentry in xrange(entries): pbar.update(jentry + 1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb <= 0: continue #fill_histograms(t) if select_jpsi_to_gammaEta(t): cut_chisq = (t.kmfit_chisq < 60) cut_mjpsi_sig = (abs(t.vtx_mrecpipi - JPSI_MASS) < 0.015) flag = 0 cut_mgg = 0 cut_mpipieta = 0 if (t.kmfit_g1g2dang < t.kmfit_g1g3dang and t.kmfit_g1g2dang < t.kmfit_g2g3dang): flag = 1 cut_mgg = (t.kmfit_m_g1g2 > 0.51 and t.kmfit_m_g1g2 < 0.57) cut_mpipieta = (t.kmfit_m_pipig1g2 > 1.0) if (t.kmfit_g1g3dang < t.kmfit_g1g2dang and t.kmfit_g1g3dang < t.kmfit_g2g3dang): flag = 2 cut_mgg = (t.kmfit_m_g1g3 > 0.51 and t.kmfit_m_g1g3 < 0.57) cut_mpipieta = (t.kmfit_m_pipig1g3 > 1.0) if (t.kmfit_g2g3dang < t.kmfit_g1g2dang and t.kmfit_g2g3dang < t.kmfit_g1g3dang): flag = 3 cut_mgg = (t.kmfit_m_g2g3 > 0.51 and t.kmfit_m_g2g3 < 0.57) cut_mpipieta = (t.kmfit_m_pipig2g3 > 1.0) if (cut_chisq and cut_mpipieta): if (cut_mjpsi_sig): if (flag == 1): h_mgg.Fill(t.kmfit_m_g1g2) if (flag == 2): h_mgg.Fill(t.kmfit_m_g1g3) if (flag == 3): h_mgg.Fill(t.kmfit_m_g2g3) if (cut_mgg): h_mrecpipi_zc.Fill(t.vtx_mrecpipi) h_mpipi.Fill(t.vtx_mpipi) h_pip_p.Fill(t.trkp_p) h_pim_p.Fill(t.trkm_p) h_pip_costhe.Fill(math.cos(t.trkp_theta)) h_pim_costhe.Fill(math.cos(t.trkm_theta)) h_cospipi.Fill(t.vtx_cospipi) h_cos2pisys.Fill(t.vtx_cos2pisys) ngam = t.ngam for gentry in range(ngam): h_gcostheta.Fill(t.raw_costheta[gentry]) if (cut_mjpsi_sig and cut_mgg and (t.run > 0)): # Only for data sample ch0 = t.m_trig_channel[0] ch1 = t.m_trig_channel[1] ch2 = t.m_trig_channel[2] ch3 = t.m_trig_channel[3] ch4 = t.m_trig_channel[4] ch5 = t.m_trig_channel[5] ch6 = t.m_trig_channel[6] ch7 = t.m_trig_channel[7] ch8 = t.m_trig_channel[8] ch9 = t.m_trig_channel[9] ch10 = t.m_trig_channel[10] ch11 = t.m_trig_channel[11] ch12 = t.m_trig_channel[12] ch13 = t.m_trig_channel[13] ch14 = t.m_trig_channel[14] ch15 = t.m_trig_channel[15] count0 = count0 + ch0 count1 = count1 + ch1 count2 = count2 + ch2 count3 = count3 + ch3 count4 = count4 + ch4 count5 = count5 + ch5 count6 = count6 + ch6 count7 = count7 + ch7 count8 = count8 + ch8 count9 = count9 + ch9 count10 = count10 + ch10 count11 = count11 + ch11 count12 = count12 + ch12 count13 = count13 + ch13 count14 = count14 + ch14 count15 = count15 + ch15 count_all = count_all + 1 if (ch11 == 1 and (ch0 == 1 or ch1 == 1 or ch2 == 1 or ch3 == 1 or ch4 == 1 or ch5 == 1)): count_EMC_Track = count_EMC_Track + 1 h_ch_count.Fill(0, count0) h_ch_count.Fill(1, count1) h_ch_count.Fill(2, count2) h_ch_count.Fill(3, count3) h_ch_count.Fill(4, count4) h_ch_count.Fill(5, count5) h_ch_count.Fill(6, count6) h_ch_count.Fill(7, count7) h_ch_count.Fill(8, count8) h_ch_count.Fill(9, count9) h_ch_count.Fill(10, count10) h_ch_count.Fill(11, count11) h_ch_count.Fill(12, count12) h_ch_count.Fill(13, count13) h_ch_count.Fill(14, count14) h_ch_count.Fill(15, count15) h_ch_count.Fill(19, count_EMC_Track) h_ch_count.Fill(21, count_all) fout = ROOT.TFile(outfile, "RECREATE") write_histograms() fout.Close() pbar.finish() # print "count0 = " , count0 # print "count1 = " , count1 # print "count2 = " , count2 # print "count3 = " , count3 # print "count4 = " , count4 # print "count5 = " , count5 # print "count6 = " , count6 # print "count7 = " , count7 # print "count8 = " , count8 # print "count9 = " , count9 # print "count10 = " , count10 # print "count11 = " , count11 # print "count12 = " , count12 # print "count13 = " , count13 # print "count14 = " , count14 # print "count15 = " , count15 # print "count_EMC_Track = " , count_EMC_Track dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
if (t.run < 0): # judge whether this run is MonteCarlo n_run[0] = t.run n_event[0] = t.event n_indexmc[0] = t.m_indexmc for ii in range(t.m_indexmc): n_pdgid[ii] = t.m_pdgid[ii] n_motheridx[ii] = t.m_motheridx[ii] # t_out.Fill() gam1_E.clear() gam2_E.clear() #t_out.Write() h_evtflw.Write() h_mrec_gam1_d.Write() h_mrec_gam1_n.Write() h_mrec_gamgam_d.Write() h_mrec_gamgam_n.Write() h_Mgamgam_d.Write() h_Mgamgam_n.Write() h_gam1_costhe.Write() h_gam1_E_d.Write() h_gam1_E_n.Write() h_gam2_E.Write() h_gam2_costhe.Write() h_ngam.Write() fout.Close() pbar.finish() dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] print "outfile : ",outfile check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() fout = ROOT.TFile(outfile, "RECREATE") t_out = ROOT.TTree('signal', 'signal') # mystruct = ROOT.MyTreeStruct() t_out.Branch('vtx_mrecpipi', vtx_mrecpipi) n_run = array('i',[0]) n_event = array('i',[0]) n_indexmc = array('i',[0]) t_out.Branch('run', n_run, 'run/I') t_out.Branch('event', n_event, 'event/I') t_out.Branch('indexmc', n_indexmc, 'indexmc/I') n_pdgid = array('i',100*[-99]) n_motheridx = array('i',100*[-99]) t_out.Branch('pdgid', n_pdgid, 'pdgid[100]/I') t_out.Branch('motheridx', n_motheridx, 'motheridx[100]/I') # fout = ROOT.TFile(outfile, "RECREATE") # t_out = ROOT.TTree('signal', 'signal') # mystruct = ROOT.MyTreeStruct() # # mystruct2 = ROOT.MyTreeStruct2() # t_out.Branch('vtx_mrecpipi', mystruct, 'vtx_mrecpipi/D') # t_out.Branch('indexmc', mystruct2, 'indexmc/D') # t_out.Branch('pdgid', mystruct, 'm_pdgid[100]/I') # t_out.Branch('trkidx', mystruct, 'm_trkidx[100]/I') # t_out.Branch('motherpid', mystruct, 'm_motherpid[100]/I') # t_out.Branch('motheridx', mystruct, 'm_motheridx[100]/I') for jentry in xrange(entries): pbar.update(jentry+1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb<=0: continue #print type(vtx_mrecpipi) #print dir(ROOT.vector.__doc__) # if NonPiPiJpsi: # Non-PiPiJpsi # if not ( check_pipiJpsi(t) ): # fill_histograms_all_combination(t) # else: # Normal # fill_histograms_all_combination(t) if (t.run<0): n_run[0] = t.run n_event[0] = t.event n_indexmc[0] = t.indexmc for ii in range(t.indexmc): n_pdgid[ii] = t.m_pdgid[ii] n_motheridx[ii] = t.m_motheridx[ii] # t_out.Fill() # vtx_cospipi.clear() fill_histograms_all_combination(t) t_out.Fill() t_out.Write() write_histograms() fout.Close() pbar.finish() dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() fout = ROOT.TFile(outfile, "RECREATE") t_out = ROOT.TTree('signal', 'signal') t_out.Branch('run', n_run, 'run/I') t_out.Branch('event', n_event, 'event/I') t_out.Branch('indexmc', n_indexmc, 'indexmc/I') t_out.Branch('pdgid', n_pdgid, 'pdgid[100]/I') t_out.Branch('motheridx', n_motheridx, 'motheridx[100]/I') t_out.Branch('prob_pip', prob_pip, 'prob_pip/D') t_out.Branch('prob_kp', prob_kp, 'prob_kp/D') t_out.Branch('prob_pim', prob_pim, 'prob_pim/D') t_out.Branch('prob_km', prob_km, 'prob_km/D') t_out_2 = ROOT.TTree('pid', 'pid') t_out_2.Branch('prob_pip_no', prob_pip_no, 'prob_pip_no/D') t_out_2.Branch('prob_kp_no', prob_kp_no, 'prob_kp_no/D') t_out_2.Branch('prob_pim_no', prob_pim_no, 'prob_pim_no/D') t_out_2.Branch('prob_km_no', prob_km_no, 'prob_km_no/D') mystruct = ROOT.MyTreeStruct() t_out.Branch('vtx_mrecpipi', mystruct, 'vtx_mrecpipi/D') pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() # mystruct = ROOT.MyTreeStruct() for jentry in xrange(entries): pbar.update(jentry + 1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb <= 0: continue # if t.run > 25600: # continue # if (t.run > 26200 or t.run < 25600 ): # continue # if (t.run > 26600 or t.run < 26200 ): # continue # if (t.run > 26900 or t.run < 26600 ): # continue # if t.run < 26900: # continue # if t.run < 10000: if t.run > 10000: continue fill_histograms(t, t_out, t_out_2) if select_jpsi_to_invisible(t): h_mrecpipi.Fill(t.vtx_mrecpipi) h_mrecpipi_fit.Fill(t.vtx_mrecpipi) mystruct.vtx_mrecpipi = t.vtx_mrecpipi t_out.Fill() # fout = ROOT.TFile(outfile, "RECREATE") t_out.Write() t_out_2.Write() write_histograms() fout.Close() pbar.finish() dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] # print sys.argv[0] # exit (0) if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') t.SetBranchAddress("raw_gpx", raw_gpx) t.SetBranchAddress("raw_gpy", raw_gpy) t.SetBranchAddress("raw_gpz", raw_gpz) t.SetBranchAddress("raw_ge", raw_ge) t.SetBranchAddress("raw_costheta", raw_costheta) t.SetBranchAddress("raw_costheta", raw_costheta) # t.SetBranchAddress("pdgid", m_pdgid, "pdgid[100]/I") # t.SetBranchAddress("motheridx", m_motheridx, "motheridx[100]/I") entries = t.GetEntriesFast() # fout = ROOT.TFile(outfile, "RECREATE") fout = ROOT.TFile(outfile, "RECREATE") t_out = ROOT.TTree('tree', 'tree') mystruct = ROOT.MyTreeStruct() # t_out.Branch('vtx_mrecgam1', mystruct, 'vtx_mrecgam1/D') t_out.Branch('mrec_gam1_raw', mystruct, 'mrec_gam1_raw/D') t_out.Branch("raw_gpx", raw_gpx) t_out.Branch("raw_gpy", raw_gpy) t_out.Branch("raw_gpz", raw_gpz) t_out.Branch("raw_ge", raw_ge) t_out.Branch("raw_costheta", raw_costheta) n_run = array('i', [0]) n_event = array('i', [0]) n_indexmc = array('i', [0]) t_out.Branch("run", n_run, "run/I") t_out.Branch("event", n_event, "event/I") t_out.Branch("indexmc", n_indexmc, "indexmc/I") n_pdgid = array('i', 100 * [-99]) n_motheridx = array('i', 100 * [-99]) t_out.Branch("pdgid", n_pdgid, "pdgid[100]/I") t_out.Branch("motheridx", n_motheridx, "motheridx[100]/I") pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() for jentry in xrange(entries): pbar.update(jentry + 1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break if select_chic0_to_inclusive(t): # h_mrecgam1.Fill(t.vtx_mrecgam1) # mystruct.vtx_mrecgam1 = t.vtx_mrecgam1 t_out.Fill() fill_histograms(t) nb = t.GetEntry(jentry) if nb <= 0: continue n_run[0] = t.run n_event[0] = t.event n_indexmc[0] = t.m_indexmc for ii in range(t.m_indexmc): n_pdgid[ii] = t.m_pdgid[ii] n_motheridx[ii] = t.m_motheridx[ii] t_out.Write() write_histograms() fout.Close() pbar.finish() dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') entries = t.GetEntriesFast() pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() for jentry in xrange(entries): pbar.update(jentry+1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 10000: break nb = t.GetEntry(jentry) if nb<=0: continue fill_histograms(t) if select_jpsi_to_pnpi(t): ngam = t.ngam num_n_related_gamma = 0 for gentry in range(ngam): if( t.gn_dang[gentry] < 30 ): num_n_related_gamma += 1 if( t.pnpi_flag == 1 ): h_nbar_mass.Fill(t.vtx_neutron_m) h_nbar_ngam_dangcut.Fill(num_n_related_gamma) h_nbar_pmom.Fill(t.vtx_proton_p) h_nbar_pimom.Fill(t.vtx_pion_p) for gentry in range(ngam): if( t.gn_dang[gentry] < 30 ): h_nbar_nhit.Fill(t.raw_nhit[gentry]) h_nbar_secmom.Fill(t.raw_secmom[gentry]) h_nbar_cstat.Fill(t.raw_cstat[gentry]) if( t.raw_cstat[gentry]%2 == 0 ): h_nbar_nhit_c0.Fill(t.raw_nhit[gentry]) h_nbar_secmom_c0.Fill(t.raw_secmom[gentry]) if( t.raw_cstat[gentry]%2 == 1 ): h_nbar_nhit_c1.Fill(t.raw_nhit[gentry]) h_nbar_secmom_c1.Fill(t.raw_secmom[gentry]) if( t.pnpi_flag == 2 ): h_n_mass.Fill(t.vtx_neutron_m) h_n_ngam_dangcut.Fill(num_n_related_gamma) h_n_pmom.Fill(t.vtx_proton_p) h_n_pimom.Fill(t.vtx_pion_p) for gentry in range(ngam): if( t.gn_dang[gentry] < 30 ): h_n_nhit.Fill(t.raw_nhit[gentry]) h_n_secmom.Fill(t.raw_secmom[gentry]) h_n_cstat.Fill(t.raw_cstat[gentry]) if( t.raw_cstat[gentry]%2 == 0 ): h_n_nhit_c0.Fill(t.raw_nhit[gentry]) h_n_secmom_c0.Fill(t.raw_secmom[gentry]) if( t.raw_cstat[gentry]%2 == 1 ): h_n_nhit_c1.Fill(t.raw_nhit[gentry]) h_n_secmom_c1.Fill(t.raw_secmom[gentry]) fout = ROOT.TFile(outfile, "RECREATE") write_histograms() fout.Close() pbar.finish() dur = duration(time()-time_start) sys.stdout.write(' \nDone in %s. \n' % dur)
def main(): if TEST: sys.stdout.write('Run in TEST mode! \n') args = sys.argv[1:] if len(args) < 2: return usage() infile = args[0] outfile = args[1] check_outfile_path(outfile) fin = ROOT.TFile(infile) t = fin.Get('tree') t.SetBranchAddress("raw_gpx", raw_gpx) t.SetBranchAddress("raw_gpy", raw_gpy) t.SetBranchAddress("raw_gpz", raw_gpz) t.SetBranchAddress("raw_ge", raw_ge) # t.SetBranchAddress("trkm_px", trkm_px, "trkm_px/D") # t.SetBranchAddress("trkm_py", trkm_py, "trkm_py/D") # t.SetBranchAddress("trkm_pz", trkm_pz, "trkm_pz/D") # t.SetBranchAddress("trkm_e" , trkm_e , "trkm_e/D" ) # t.SetBranchAddress("trkp_px", trkp_px, "trkp_px/D") # t.SetBranchAddress("trkp_py", trkp_py, "trkp_py/D") # t.SetBranchAddress("trkp_pz", trkp_pz, "trkp_pz/D") # t.SetBranchAddress("trkp_e" , trkp_e , "trkp_e/D" ) entries = t.GetEntriesFast() fout = ROOT.TFile(outfile, "RECREATE") t_out = ROOT.TTree('tree', 'tree') pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=entries).start() time_start = time() for jentry in xrange(entries): pbar.update(jentry + 1) # get the next tree in the chain and verify ientry = t.LoadTree(jentry) if ientry < 0: break # copy next entry into memory and verify if TEST and ientry > 500: break nb = t.GetEntry(jentry) if nb <= 0: continue fill_histograms(t) if select_jpsi_to_gammaEta(t): t_out.Fill() if (fill_trig): ch0 = t.m_trig_channel[0] ch1 = t.m_trig_channel[1] ch2 = t.m_trig_channel[2] ch3 = t.m_trig_channel[3] ch4 = t.m_trig_channel[4] ch5 = t.m_trig_channel[5] ch6 = t.m_trig_channel[6] ch7 = t.m_trig_channel[7] ch8 = t.m_trig_channel[8] ch9 = t.m_trig_channel[9] ch10 = t.m_trig_channel[10] ch11 = t.m_trig_channel[11] ch12 = t.m_trig_channel[12] ch13 = t.m_trig_channel[13] ch14 = t.m_trig_channel[14] ch15 = t.m_trig_channel[15] global count0 global count1 global count2 global count3 global count4 global count5 global count6 global count7 global count8 global count9 global count10 global count11 global count12 global count13 global count14 global count15 global count_EMC_Track global count_all count0 = count0 + ch0 count1 = count1 + ch1 count2 = count2 + ch2 count3 = count3 + ch3 count4 = count4 + ch4 count5 = count5 + ch5 count6 = count6 + ch6 count7 = count7 + ch7 count8 = count8 + ch8 count9 = count9 + ch9 count10 = count10 + ch10 count11 = count11 + ch11 count12 = count12 + ch12 count13 = count13 + ch13 count14 = count14 + ch14 count15 = count15 + ch15 count_all = count_all + 1 if (ch11 == 1 and (ch0 == 1 or ch1 == 1 or ch2 == 1 or ch3 == 1 or ch4 == 1 or ch5 == 1)): count_EMC_Track = count_EMC_Track + 1 h_ch_count.Fill(0, count0) h_ch_count.Fill(1, count1) h_ch_count.Fill(2, count2) h_ch_count.Fill(3, count3) h_ch_count.Fill(4, count4) h_ch_count.Fill(5, count5) h_ch_count.Fill(6, count6) h_ch_count.Fill(7, count7) h_ch_count.Fill(8, count8) h_ch_count.Fill(9, count9) h_ch_count.Fill(10, count10) h_ch_count.Fill(11, count11) h_ch_count.Fill(12, count12) h_ch_count.Fill(13, count13) h_ch_count.Fill(14, count14) h_ch_count.Fill(15, count15) h_ch_count.Fill(19, count_EMC_Track) h_ch_count.Fill(21, count_all) t_out.Write() write_histograms() fout.Close() pbar.finish() dur = duration(time() - time_start) sys.stdout.write(' \nDone in %s. \n' % dur)