Skip to content
Snippets Groups Projects
Commit b0d29102 authored by Stefan Reck's avatar Stefan Reck
Browse files

Adjustments to mupage mc info extr.

parent 290c615f
Branches
Tags
No related merge requests found
...@@ -65,58 +65,74 @@ def get_mupage_mc(blob): ...@@ -65,58 +65,74 @@ def get_mupage_mc(blob):
track = dict() track = dict()
track["event_id"] = blob['EventInfo'].event_id[0] track["event_id"] = blob['EventInfo'].event_id[0]
track["run_id"] = blob["EventInfo"].run_id track["run_id"] = blob["EventInfo"].run_id[0]
# run_id = blob['Header'].start_run.run_id.astype('float32') # run_id = blob['Header'].start_run.run_id.astype('float32')
# take 0: assumed that this is the same for all muons in a bundle # take 0: assumed that this is the same for all muons in a bundle
track["particle_type"] = blob['McTracks'][0].type track["particle_type"] = blob['McTracks'][0].type
# always 1 actually # always 1 actually
track["is_cc"] = blob['McTracks'][0].is_cc # track["is_cc"] = blob['McTracks'][0].is_cc
# always 0 actually # always 0 actually
track["bjorkeny"] = blob['McTracks'][0].bjorkeny # track["bjorkeny"] = blob['McTracks'][0].bjorkeny
# same for all muons in a bundle #TODO not? # same for all muons in a bundle #TODO not?
track["time_interaction"] = blob['McTracks'][0].time track["time_interaction"] = blob['McTracks'][0].time
# takes position of time_residual_vertex in 'neutrino' case # takes position of time_residual_vertex in 'neutrino' case
track["n_muons"] = blob['McTracks'].shape[0] n_muons = blob['McTracks'].shape[0]
track["n_muons"] = n_muons
# sum up the energy of all muons # sum up the energy of all muons
energy = blob['McTracks'].energy energy = blob['McTracks'].energy
track["energy"] = np.sum(energy) track["energy"] = np.sum(energy)
# energy in the highest energy muons of the bundle
sorted_energy = np.sort(energy) # Origin of each mchit (as int) in the active line
track["energy_highest_frac"] = sorted_energy[-1]/np.sum(energy) in_active_du = blob["McHits"]["du"] == active_du
if len(energy) > 1: origin = blob["McHits"]["origin"][in_active_du]
sec_highest_energy = sorted_energy[-2]/np.sum(energy)
else:
sec_highest_energy = 0.
track["energy_sec_highest_frac"] = sec_highest_energy
# coefficient of variation of energy
track["energy_cvar"] = np.std(energy)/np.mean(energy)
# get how many mchits were produced per muon in the bundle # get how many mchits were produced per muon in the bundle
origin = blob["McHits"]["origin"][blob["McHits"]["du"] == active_du]
origin_dict = dict(zip(*np.unique(origin, return_counts=True))) origin_dict = dict(zip(*np.unique(origin, return_counts=True)))
origin_list = [] origin_list = []
for i in range(1, track["n_muons"]+1): for i in range(1, n_muons+1):
origin_list.append(origin_dict.get(i, 0)) origin_list.append(origin_dict.get(i, 0))
origin_list = np.array(origin_list) origin_list = np.array(origin_list)
track["n_mc_hits"] = np.sum(origin_list)
desc_order = np.argsort(-origin_list)
# fraction of mchits in the highest mchit muons of the bundle # Sort by energy, highest first
sorted_origin = np.sort(origin_list) sorted_energy = energy[desc_order]
track["mchit_highest_frac"] = sorted_origin[-1] / np.sum(origin_list) sorted_mc_hits = origin_list[desc_order]
if len(sorted_origin) > 1:
sec_highest_mchit_frac = sorted_origin[-2] / np.sum(origin_list) # Store number of mchits of the 10 highest mchits muons (-1 if it has less)
else: for i in range(10):
sec_highest_mchit_frac = 0. field_name = "n_mc_hits_"+str(i)
track["mchit_sec_highest_frac"] = sec_highest_mchit_frac
if i < len(sorted_mc_hits):
field_data = sorted_mc_hits[i]
else:
field_data = -1
track[field_name] = field_data
# Store energy of the 10 highest mchits muons (-1 if it has less)
for i in range(10):
field_name = "energy_"+str(i)
if i < len(sorted_energy):
field_data = sorted_energy[i]
else:
field_data = -1
track[field_name] = field_data
# only muons with at least one mchit in active line # only muons with at least one mchit in active line
track["n_muons_visible"] = len(origin_list[origin_list > 0]) track["n_muons_visible"] = len(origin_list[origin_list > 0])
# only muons with at least 5 mchits in active line # only muons with at least 5 mchits in active line
track["n_muons_thresh"] = len(origin_list[origin_list > 4]) track["n_muons_5_mchits"] = len(origin_list[origin_list > 4])
# only muons with at least 10 mchits in active line
# coefficient of variation of the origin of mc hits in the bundle track["n_muons_10_mchits"] = len(origin_list[origin_list > 9])
track["mchit_cvar"] = np.std(origin_list)/np.mean(origin_list)
# all muons in a bundle are parallel, so just take dir of first muon # all muons in a bundle are parallel, so just take dir of first muon
track["dir_x"] = blob['McTracks'][0].dir_x track["dir_x"] = blob['McTracks'][0].dir_x
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment