Пример #1
0
    def analysis(self, df):

        djmm = fjtools.DJetMatchMaker()
        djmm.set_ch_pt_eta_phi(self.df_tracks['ParticlePt'].values,
                               self.df_tracks['ParticleEta'].values,
                               self.df_tracks['ParticlePhi'].values)
        djmm.set_Ds_pt_eta_phi_m(df['pt_cand'].values, df['eta_cand'].values,
                                 df['phi_cand'].values, df['inv_mass'].values)
        djmm.set_daughters0_pt_eta_phi(df['pt_prong0'].values,
                                       df['eta_prong0'].values,
                                       df['phi_prong0'].values)
        djmm.set_daughters1_pt_eta_phi(df['pt_prong1'].values,
                                       df['eta_prong1'].values,
                                       df['phi_prong1'].values)

        self.tw.fill_branches(dpsj=djmm.Ds)
        self.tw.fill_tree()

        for id0, d0 in enumerate(djmm.Ds):
            _parts_and_ds = djmm.match(0.005, id0)
            _parts_and_ds.push_back(d0)
            ja = jet_analysis.JetAnalysis(jet_R=0.4,
                                          particle_eta_max=0.9,
                                          jet_pt_min=2.0)
            ja.analyze_event(_parts_and_ds)
            if len(ja.jets) < 1:
                continue
            jets = ja.jets_as_psj_vector()
            djets = djmm.filter_D0_jets(jets)
            if len(djets) > 0:
                j = djets[0]
                dcand = djmm.get_Dcand_in_jet(j)
                sja = jet_analysis.JetAnalysis(jet_R=0.1,
                                               particle_eta_max=0.9,
                                               jet_pt_min=2.0)
                sja.analyze_event(j.constituents())
                lsj = fj.sorted_by_pt(sja.jets_as_psj_vector())
                if len(lsj) < 1:
                    continue
                sj_dcand = djmm.get_Dcand_in_jet(lsj[0])
                is_Dsj = 0
                if len(sj_dcand) > 0:
                    # if sj_dcand[0].m() == dcand[0].m() and sj_dcand[0].perp() == dcand[0].perp():
                    if sj_dcand[0].delta_R(dcand[0]) == 0.0:
                        is_Dsj = 1
                self.twjc.fill_branches(jet=j,
                                        dR=j.delta_R(dcand[0]),
                                        D=dcand[0],
                                        lsj=lsj[0],
                                        Dsj=is_Dsj,
                                        a10=fjext.angularity(j, 1.0, 0.4),
                                        a15=fjext.angularity(j, 0.5, 0.4),
                                        a20=fjext.angularity(j, 0.0, 0.4),
                                        a30=fjext.angularity(j, -1.0, 0.4))
                self.twjc.fill_tree()

            if len(djets) > 1:
                perror("more than one jet per D candidate?")

        return True
Пример #2
0
	def process_event(self, df):
		self.pbar.update(1)
		if 'ev_id_ext' in list(self.event_df):
			_ev_query = "run_number == {} & ev_id == {} & ev_id_ext == {}".format(df['run_number'], df['ev_id'], df['ev_id_ext'])
		else:
			_ev_query = "run_number == {} & ev_id == {}".format(df['run_number'], df['ev_id'])
		_df_d0 = self.d0_df.query(_ev_query)
		_df_d0.reset_index(drop=True)
		_n_d0s = len(_df_d0.index)
		if _n_d0s < 1:
			return
		_ev_query = ""
		_df_tracks = self.track_df.query(_ev_query)
		_df_tracks.reset_index(drop=True)
		_parts = fjext.vectorize_pt_eta_phi(_df_tracks['ParticlePt'].values, _df_tracks['ParticleEta'].values, _df_tracks['ParticlePhi'].values)
		self._user_index_offset = 10000
		# _d0s = fjext.vectorize_pt_eta_phi(_df_d0['pt_cand'].values, _df_d0['eta_cand'].values, _df_d0['phi_cand'].values, self._user_index_offset)
		_d0s = fjext.vectorize_pt_eta_phi_m(_df_d0['pt_cand'].values, _df_d0['eta_cand'].values, _df_d0['phi_cand'].values, _df_d0['inv_mass'].values, self._user_index_offset)
		_d0s_gh = [p * 1.e-6 for p in _d0s]

		_parts_and_ds = _parts
		_tmp = [_parts_and_ds.push_back(p) for p in _d0s_gh]
		# pinfo('n parts = ', len(_parts_and_ds))

		ja = jet_analysis.JetAnalysis(jet_R = 0.6, particle_eta_max=0.9, jet_pt_min=5.0)
		ja.analyze_event(_parts_and_ds)

		_d0_imass_list = _df_d0['inv_mass'].values.tolist()
		self.tw.fill_branches(dpsj = _d0s)
		self.tw.fill_branches(dpsjgh = _d0s_gh)
		self.tw.fill_branches(minv = _d0_imass_list)
		self.tw.fill_branches(jets = ja.jets_as_psj_vector())
		self.tw.fill_tree()

		self.d0_jet_correl(ja.jets, _d0s, _d0_imass_list)
Пример #3
0
	def process_d0s_1(self, df):
		self.pbar.update(1)
		_n_d0s = len(df)
		if _n_d0s < 1:
			return
		# pinfo(df)
		if 'ev_id_ext' in list(self.event_df):
			_ev_query = "run_number == {} & ev_id == {} & ev_id_ext == {}".format(df['run_number'].values[0], df['ev_id'].values[0], df['ev_id_ext'].values[0])
		else:
			_ev_query = "run_number == {} & ev_id == {}".format(df['run_number'].values[0], df['ev_id'].values[0])
		_df_tracks = self.track_df.query(_ev_query)
		_df_tracks.reset_index(drop=True)

		djmm = fjtools.DJetMatchMaker()
		djmm.set_ch_pt_eta_phi(_df_tracks['ParticlePt'].values, _df_tracks['ParticleEta'].values, _df_tracks['ParticlePhi'].values)
		djmm.set_Ds_pt_eta_phi_m(df['pt_cand'].values, df['eta_cand'].values, df['phi_cand'].values, df['inv_mass'].values)
		if _n_d0s > 1:
			print('-- event break - 2D0 event:')
			print('pt_cand:  ', df['pt_cand'].values)
			print('eta_cand: ', df['eta_cand'].values)
			print('phi_cand: ', df['phi_cand'].values)
			print('inv_mass: ', df['inv_mass'].values)
			print('pt_prong0:  ', df['pt_prong0'].values)
			print('eta_prong0: ', df['eta_prong0'].values)
			print('phi_prong0: ', df['phi_prong0'].values)
			print('pt_prong1:  ', df['pt_prong1'].values)
			print('eta_prong1: ', df['eta_prong1'].values)
			print('phi_prong1: ', df['phi_prong1'].values)
		djmm.set_daughters0_pt_eta_phi(df['pt_prong0'].values, df['eta_prong0'].values, df['phi_prong0'].values)
		djmm.set_daughters1_pt_eta_phi(df['pt_prong1'].values, df['eta_prong1'].values, df['phi_prong1'].values)

		self.tw.fill_branches(dpsj = djmm.Ds)
		self.tw.fill_tree()

		_parts_and_ds = djmm.match(0.005)
		[_parts_and_ds.push_back(p) for p in djmm.Ds]
		ja = jet_analysis.JetAnalysis(jet_R = 0.2, particle_eta_max=0.9, jet_pt_min=2.0)
		ja.analyze_event(_parts_and_ds)
		if len(ja.jets) < 1:
			return True
		# self.d0_jet_correl(ja.jets, djmm.Ds)
		jets = ja.jets_as_psj_vector()
		djets = djmm.filter_D0_jets(jets)

		_tmp = [self.twjc.fill_branches(jet = j, dR = j.delta_R(dcand), D = dcand) for j in djets for dcand in djmm.get_Dcand_in_jet(j)]
		if len(_tmp) > 0:
			self.twjc.fill_tree()

		djpairs = [[j,dcand] for j in djets for dcand in djmm.get_Dcand_in_jet(j)]
		for p in djpairs:
			j = p[0]
			dcand = p[1]
			if j.delta_R(dcand) < 0.01 and dcand.perp() / j.perp() < 0.55:
				self.print_jet(j)

		return True
Пример #4
0
	def process_d0s_0(self, df):
		self.pbar.update(1)
		_n_d0s = len(df)
		if _n_d0s < 1:
			return
		# pinfo(df)
		if 'ev_id_ext' in list(self.event_df):
			# _ev_query = "run_number == {} & ev_id == {} & ev_id_ext == {}".format(df['run_number'], df['ev_id'], df['ev_id_ext'])
			_ev_query = "run_number == {} & ev_id == {} & ev_id_ext == {}".format(df['run_number'].values[0], df['ev_id'].values[0], df['ev_id_ext'].values[0])
		else:
			_ev_query = "run_number == {} & ev_id == {}".format(df['run_number'].values[0], df['ev_id'].values[0])
		_df_tracks = self.track_df.query(_ev_query)
		_df_tracks.reset_index(drop=True)

		djmm = fjtools.DJetMatchMaker()
		djmm.set_ch_pt_eta_phi(_df_tracks['ParticlePt'].values, _df_tracks['ParticleEta'].values, _df_tracks['ParticlePhi'].values)
		# _parts = fjext.vectorize_pt_eta_phi(_df_tracks['ParticlePt'].values, _df_tracks['ParticleEta'].values, _df_tracks['ParticlePhi'].values)
		self._user_index_offset = 10000
		self.D0_index_offset = 10000
		# _d0s = fjext.vectorize_pt_eta_phi([df['pt_cand']], [df['eta_cand']], [df['phi_cand']], self._user_index_offset)
		# _d0s = fjext.vectorize_pt_eta_phi(df['pt_cand'].values, df['eta_cand'].values, df['phi_cand'].values, self._user_index_offset)
		# _d0s = fjext.vectorize_pt_eta_phi_m(df['pt_cand'].values, df['eta_cand'].values, df['phi_cand'].values, df['inv_mass'].values, self._user_index_offset)
		djmm.set_Ds_pt_eta_phi_m(df['pt_cand'].values, df['eta_cand'].values, df['phi_cand'].values, df['inv_mass'].values, self.D0_index_offset)
		_d0s = djmm.Ds;
		_d0s_gh = [p * 1.e-6 for p in _d0s]

		# for di in range(_d0s.size()):
		# 	print(djmm.Ds[di].m(), df['inv_mass'].values[di])

		_d0_imass_list = df['inv_mass'].values.tolist()
		# _d0_imass_list = [df['inv_mass']]
		self.tw.fill_branches(dpsj = _d0s, dpsjgh = _d0s_gh, minv = _d0_imass_list)
		self.tw.fill_tree()

		self.daughter_user_index_offset = self.D0_index_offset * 2
		djmm.set_daughters0_pt_eta_phi(df['pt_prong0'].values, df['eta_prong0'].values, df['phi_prong0'].values, self.daughter_user_index_offset)
		djmm.set_daughters1_pt_eta_phi(df['pt_prong1'].values, df['eta_prong1'].values, df['phi_prong1'].values, self.daughter_user_index_offset * 2)

		pinfo('n D0s', len(_d0s))
		# djmm.match(0.1)
		# djmm.match(0.01)
		# djmm.match(0.005)
		_parts_and_ds = djmm.match(0.005)
		# _parts_and_ds = _parts
		_tmp = [_parts_and_ds.push_back(p) for p in djmm.Ds]
		# # pinfo('n parts = ', len(_parts_and_ds))
		ja = jet_analysis.JetAnalysis(jet_R = 0.2, particle_eta_max=0.9, jet_pt_min=2.0)
		ja.analyze_event(_parts_and_ds)
		if len(ja.jets) < 1:
			return True
		# self.d0_jet_correl_ghosts(ja.jets, _d0s, _d0_imass_list)
		self.d0_jet_correl(ja.jets, djmm.Ds)

		return True
Пример #5
0
    def analysis_gen(self, df):

        m_gen_array = np.full((self.df_gen_tracks['ParticlePt'].values.size),
                              0.1396)

        djmm_gen = fjtools.DJetMatchMaker()
        djmm_gen.set_ch_pt_eta_phi_m(self.df_gen_tracks['ParticlePt'].values,
                                     self.df_gen_tracks['ParticleEta'].values,
                                     self.df_gen_tracks['ParticlePhi'].values,
                                     m_gen_array)
        djmm_gen.set_Ds_pt_eta_phi(df['pt_cand'].values, df['eta_cand'].values,
                                   df['phi_cand'].values)

        for id0, d0 in enumerate(djmm_gen.Ds):
            _parts_and_ds = djmm_gen.ch
            _parts_and_ds.push_back(d0)
            ja_gen = jet_analysis.JetAnalysis(
                jet_R=0.4,
                jet_RecombinationScheme=fj.E_scheme,
                particle_eta_max=0.9,
                jet_pt_min=5.0)
            ja_gen.analyze_event(_parts_and_ds)
            if len(ja_gen.jets) < 1:
                continue

            jets = ja_gen.jets_as_psj_vector()
            djets = djmm_gen.filter_D0_jets(jets)

            if len(djets) > 0:
                j = djets[0]
                dcand = djmm_gen.get_Dcand_in_jet(j)
                D_cand_type = df['cand_type'].values
                self.twjc_gen.fill_branches(jet=j,
                                            dR=j.delta_R(dcand[0]),
                                            D=dcand[0],
                                            Dmeson_cand_type=float(
                                                D_cand_type[id0]))
                self.twjc_gen.fill_tree()

            if len(djets) > 1:
                perror("more than one jet per D candidate?")

        return True
Пример #6
0
	def process_d0s(self, df):
		self.pbar.update(1)
		_n_d0s = len(df)
		if _n_d0s < 1:
			return
		# pinfo(df)
		if 'ev_id_ext' in list(self.event_df):
			_ev_query = "run_number == {} & ev_id == {} & ev_id_ext == {}".format(df['run_number'].values[0], df['ev_id'].values[0], df['ev_id_ext'].values[0])
		else:
			_ev_query = "run_number == {} & ev_id == {}".format(df['run_number'].values[0], df['ev_id'].values[0])
		_df_tracks = self.track_df.query(_ev_query)
		_df_tracks.reset_index(drop=True)

		djmm = fjtools.DJetMatchMaker()
		djmm.set_ch_pt_eta_phi(_df_tracks['ParticlePt'].values, _df_tracks['ParticleEta'].values, _df_tracks['ParticlePhi'].values)
		djmm.set_Ds_pt_eta_phi_m(df['pt_cand'].values, df['eta_cand'].values, df['phi_cand'].values, df['inv_mass'].values)
		djmm.set_daughters0_pt_eta_phi(df['pt_prong0'].values, df['eta_prong0'].values, df['phi_prong0'].values)
		djmm.set_daughters1_pt_eta_phi(df['pt_prong1'].values, df['eta_prong1'].values, df['phi_prong1'].values)

		# if _n_d0s > 1:
		# 	print('-- event break - 2D0 event:')
		# 	print('pt_cand:  ', df['pt_cand'].values)
		# 	print('eta_cand: ', df['eta_cand'].values)
		# 	print('phi_cand: ', df['phi_cand'].values)
		# 	print('inv_mass: ', df['inv_mass'].values)
		# 	print('pt_prong0:  ', df['pt_prong0'].values)
		# 	print('eta_prong0: ', df['eta_prong0'].values)
		# 	print('phi_prong0: ', df['phi_prong0'].values)
		# 	print('pt_prong1:  ', df['pt_prong1'].values)
		# 	print('eta_prong1: ', df['eta_prong1'].values)
		# 	print('phi_prong1: ', df['phi_prong1'].values)

		self.tw.fill_branches(dpsj = djmm.Ds)
		self.tw.fill_tree()

		for id0, d0 in enumerate(djmm.Ds):
			_parts_and_ds = djmm.match(0.005, id0)
			_parts_and_ds.push_back(d0)
			ja = jet_analysis.JetAnalysis(jet_R = 0.4, particle_eta_max=0.9, jet_pt_min=2.0)
			ja.analyze_event(_parts_and_ds)
			if len(ja.jets) < 1:
				continue
			jets = ja.jets_as_psj_vector()
			djets = djmm.filter_D0_jets(jets)
			if len(djets) > 0:
				j = djets[0]
				dcand = djmm.get_Dcand_in_jet(j)

				sja = jet_analysis.JetAnalysis(jet_R = 0.1, particle_eta_max=0.9, jet_pt_min=2.0)
				sja.analyze_event(j.constituents())
				lsj = fj.sorted_by_pt(sja.jets_as_psj_vector())
				sj_dcand = djmm.get_Dcand_in_jet(lsj[0])
				is_Dsj = 0
				if len(sj_dcand) > 0:
					# if sj_dcand[0].m() == dcand[0].m() and sj_dcand[0].perp() == dcand[0].perp():
					if sj_dcand[0].delta_R(dcand[0]) == 0.0:
						is_Dsj = 1
				self.twjc.fill_branches(jet = j, dR = j.delta_R(dcand[0]), D = dcand[0], lsj = lsj[0], Dsj = is_Dsj
										, a10 = fjext.angularity(j,  1.0, 0.4)
										, a15 = fjext.angularity(j,  0.5, 0.4)
										, a20 = fjext.angularity(j,  0.0, 0.4)
										, a30 = fjext.angularity(j, -1.0, 0.4))
				self.twjc.fill_tree()
			if len(djets) > 1:
				perror("more than one jet per D candidate?")

		return True
Пример #7
0
    def analysis(self, df):
        #print(df)

        m_array = np.full((self.df_tracks['ParticlePt'].values.size), 0.1396)

        djmm = fjtools.DJetMatchMaker()
        djmm.set_ch_pt_eta_phi_m(self.df_tracks['ParticlePt'].values,
                                 self.df_tracks['ParticleEta'].values,
                                 self.df_tracks['ParticlePhi'].values, m_array)
        djmm.set_Ds_pt_eta_phi_m(df['pt_cand'].values, df['eta_cand'].values,
                                 df['phi_cand'].values, df['inv_mass'].values)
        djmm.set_daughters0_pt_eta_phi(df['pt_prong0'].values,
                                       df['eta_prong0'].values,
                                       df['phi_prong0'].values)
        djmm.set_daughters1_pt_eta_phi(df['pt_prong1'].values,
                                       df['eta_prong1'].values,
                                       df['phi_prong1'].values)

        #run for each D candidate to build jet
        for id0, d0 in enumerate(djmm.Ds):

            #daughter tracks matching
            _parts_and_ds = djmm.match(0.005, id0)
            #replacing daughter tracks with matched D0 candidate
            #including D0
            _parts_and_ds.push_back(d0)

            #jet reconstruction with D0 and charged particle
            jetR = 0.4
            ja = jet_analysis.JetAnalysis(jet_R=jetR,
                                          jet_RecombinationScheme=fj.E_scheme,
                                          particle_eta_max=0.9,
                                          jet_pt_min=5.0)
            ja.analyze_event(_parts_and_ds)
            if len(ja.jets) < 1:
                continue
            jets = ja.jets_as_psj_vector()

            #filtering D0 jets
            djets = djmm.filter_D0_jets(jets)

            if len(djets) > 0:
                j = djets[0]
                dcand = djmm.get_Dcand_in_jet(j)

                #number of constitutents > 1
                #if len(j.constituents())<=1:
                #	continue

                #jets with the winner take all axis################################
                jet_def_wta = fj.JetDefinition(fj.cambridge_algorithm,
                                               2 * jetR)
                jet_def_wta.set_recombination_scheme(fj.WTA_pt_scheme)
                #print('WTA jet definition is:', jet_def_wta)
                reclusterer_wta = fjcontrib.Recluster(jet_def_wta)
                jet_wta = reclusterer_wta.result(j)
                ################################

                D_cosp = df['cos_p'].values
                D_cosTStar = df['cos_t_star'].values
                D_NormalisedDecayLength = df['norm_dl_xy'].values
                D_ImpactParameterProduct = df['imp_par_prod'].values
                D_cand_type = df['cand_type'].values

                self.twjc.fill_branches(
                    jet=j,
                    jetWta=jet_wta,
                    dR=j.delta_R(dcand[0]),
                    dRWTA=jet_wta.delta_R(dcand[0]),
                    D=dcand[0],
                    cos_p=float(D_cosp[id0]),
                    D_cos_t_star=float(D_cosTStar[id0]),
                    D_norm_dlxy=float(D_NormalisedDecayLength[id0]),
                    D_imp_par_prod=float(D_ImpactParameterProduct[id0]),
                    Dmeson_cand_type=float(D_cand_type[id0]))
                self.twjc.fill_tree()

            if len(djets) > 1:
                perror("more than one jet per D candidate?")

        return True