Skip to content
Snippets Groups Projects
Commit 8b7502a7 authored by Tooba Ali's avatar Tooba Ali
Browse files

use ReconstructedChargedParticles instead of ReconstructedParticles and...

use ReconstructedChargedParticles instead of ReconstructedParticles and include DETECTOR_CONFIG in plot titles of benchmarks/dis/analysis/truth_reconstruction.py
parent 957c8e0a
No related branches found
No related tags found
1 merge request!193Truth reconstruction
......@@ -16,31 +16,32 @@ args = parser.parse_args()
kwargs = vars(args)
rec_file = args.rec_file
config = args.config
config = args.config.split('_epic')[0].strip()
Nevents = int(args.nevents)
r_path = args.results_path + '/truth_reconstruction/' #Path for output figures and file.
Dconfig = 'epic' + config.split('_epic')[1].strip() #detector configuration
for array in ur.iterate(rec_file + ':events',['MCParticles/MCParticles.generatorStatus',
'MCParticles/MCParticles.PDG',
'MCParticles/MCParticles.momentum.x',
'MCParticles/MCParticles.momentum.y',
'MCParticles/MCParticles.momentum.z',
'ReconstructedParticles/ReconstructedParticles.PDG',
'ReconstructedParticles/ReconstructedParticles.momentum.x',
'ReconstructedParticles/ReconstructedParticles.momentum.y',
'ReconstructedParticles/ReconstructedParticles.momentum.z',
'ReconstructedParticlesAssoc/ReconstructedParticlesAssoc.simID',
'ReconstructedParticlesAssoc/ReconstructedParticlesAssoc.recID',],step_size=Nevents):
'ReconstructedChargedParticles/ReconstructedChargedParticles.PDG',
'ReconstructedChargedParticles/ReconstructedChargedParticles.momentum.x',
'ReconstructedChargedParticles/ReconstructedChargedParticles.momentum.y',
'ReconstructedChargedParticles/ReconstructedChargedParticles.momentum.z',
'ReconstructedChargedParticlesAssociations/ReconstructedChargedParticlesAssociations.simID',
'ReconstructedChargedParticlesAssociations/ReconstructedChargedParticlesAssociations.recID'],step_size=Nevents):
PDG_mc = array['MCParticles/MCParticles.PDG'] #Monte Carlo (MC) particle numbering scheme.
px_mc = array['MCParticles/MCParticles.momentum.x']
py_mc = array['MCParticles/MCParticles.momentum.y']
pz_mc = array['MCParticles/MCParticles.momentum.z']
PDG_rc = array['ReconstructedParticles/ReconstructedParticles.PDG']
px_rc = array['ReconstructedParticles/ReconstructedParticles.momentum.x']
py_rc = array['ReconstructedParticles/ReconstructedParticles.momentum.y']
pz_rc = array['ReconstructedParticles/ReconstructedParticles.momentum.z']
simID = array['ReconstructedParticlesAssoc/ReconstructedParticlesAssoc.simID']
recID = array['ReconstructedParticlesAssoc/ReconstructedParticlesAssoc.recID']
PDG_rc = array['ReconstructedChargedParticles/ReconstructedChargedParticles.PDG']
px_rc = array['ReconstructedChargedParticles/ReconstructedChargedParticles.momentum.x']
py_rc = array['ReconstructedChargedParticles/ReconstructedChargedParticles.momentum.y']
pz_rc = array['ReconstructedChargedParticles/ReconstructedChargedParticles.momentum.z']
simID = array['ReconstructedChargedParticlesAssociations/ReconstructedChargedParticlesAssociations.simID']
recID = array['ReconstructedChargedParticlesAssociations/ReconstructedChargedParticlesAssociations.recID']
#SimID and recID contain the indices of the MCParticles and ReconstructedParticles entry for that event.
### MCParticles Variables
......@@ -172,7 +173,7 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (mom
x_range = list(ax1.get_xlim())
fig.set_figwidth(20)
fig.set_figheight(10)
ax1.set_title('%s %s %s %s events'%(title_list[i],title,config,Nevents))
ax1.set_title('%s %s %s %s events\n DETECTOR_CONFIG: %s'%(title_list[i],title,config,Nevents,Dconfig))
plt.savefig(os.path.join(r_path, '%s_%s_%s.png' % (title_list[i],title,config)))
plt.close()
......@@ -215,7 +216,7 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (mom
ax6.set_title('Photons')
fig.set_figwidth(20)
fig.set_figheight(10)
ax1.set_title('%s Difference Vs Momentum %s %s events'%(title_list[i],config,Nevents))
ax1.set_title('%s Difference Vs Momentum %s %s events\n DETECTOR_CONFIG: %s'%(title_list[i],config,Nevents,Dconfig))
plt.savefig(os.path.join(r_path, '%s_difference_vs_momentum_%s.png' % (title_list[i],config)))
###################################################################################################
......@@ -264,7 +265,7 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (mom
axs[1].set_xlabel('%s_mc'%(title_list[i]))
axs[1].set_ylabel('%s_rc'%(title_list[i]))
axs[1].set_title('%s Correlation'%(title_list[i]))
fig.suptitle('%s %s events'%(config,Nevents))
fig.suptitle('%s %s events\n DETECTOR_CONFIG: %s'%(config,Nevents,Dconfig))
plt.savefig(os.path.join(r_path, '%s_correlation_%s.png' % (title_list[i],config)))
###################################################################################################
......@@ -314,7 +315,7 @@ if particle in particle_dict.keys():
particle_name = particle_dict[particle][1]
particle_plots(boolean_particle)
plt.suptitle('%s in %s %s events'%(particle_name,config,Nevents))
plt.suptitle('%s in %s %s events\n DETECTOR_CONFIG: %s'%(particle_name,config,Nevents,Dconfig))
plt.savefig(os.path.join(r_path, '%s_%s.png' % (particle_name,config)))
else:
for i in [[boolean_photon,'Photons'],[boolean_electron,'Electrons'],[boolean_pion,'Pions']]:
......@@ -322,7 +323,7 @@ else:
particle_name = i[1]
particle_plots(boolean_particle)
plt.suptitle('%s in %s %s events'%(particle_name,config,Nevents))
plt.suptitle('%s in %s %s events\n DETECTOR_CONFIG: %s'%(particle_name,config,Nevents,Dconfig))
plt.savefig(os.path.join(r_path, '%s_%s.png' % (particle_name,config)))
......
......@@ -8,7 +8,7 @@
int analyze(std::string file)
{
// open dataframe
ROOT::RDataFrame df("events", file, {"GeneratedParticles", "ReconstructedParticles"});
ROOT::RDataFrame df("events", file, {"GeneratedParticles", "ReconstructedChargedParticles"});
// count total events
auto count = df.Count();
......@@ -21,7 +21,7 @@ int analyze(std::string file)
auto d = df
.Define("n_tracks_gen", n_tracks, {"GeneratedParticles"})
.Define("n_tracks_rec", n_tracks, {"ReconstructedParticles"})
.Define("n_tracks_rec", n_tracks, {"ReconstructedChargedParticles"})
;
auto stats_n_tracks_gen = d.Stats("n_tracks_gen");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment