bunch_list[0] .root_histogram('p', 'MeV/c') bunch_list[-1].root_histogram('p', 'MeV/c') #energy-time scatter plot at start bunch_list[0].root_scatter_graph('t', 'energy', 'ns', 'MeV/c') #histogram at start; note that in the first instance it *looks* like a scatter plot #but it is not; hence I draw the same histogram twice, once as a pseudo-scatter #and once as a contour plot bunch_list[0].root_histogram('t', 'ns', 'energy', 'MeV/c') (canvas, hist) = bunch_list[0] .root_histogram('t', 'ns', 'energy', 'MeV/c') hist.Draw('CONT') canvas.Update() #evolution of RMS emittance in x along the beamline Bunch.root_graph(bunch_list, 'mean', ['z'], 'emittance', ['x'], 'm', 'mm') Bunch.root_graph(bunch_list, 'mean', ['z'], 'emittance', ['x','y'], 'm', 'mm') except ImportError: print("PyROOT not detected - skipping PyROOT graphics") #now try to make plots with matplotlib if matplotlib exists try: print('Trying to make some plots using matplotlib plotting package') config.has_matplot() #check for matplot library #momentum distribution at start and end bunch_list[0] .matplot_histogram('p', 'MeV/c') bunch_list[-1].matplot_histogram('p', 'MeV/c') #energy-time scatter plot at start bunch_list[0].matplot_scatter_graph('t', 'energy', 'ns', 'MeV/c')
#plot transverse amplitude #note that the plot doesn't quite stop at 30 mm; this is because the #amplitudes have been recalculated with the new distribution and have #moved slightly bunch_list[0].root_histogram('amplitude x y','mm') #plot transverse amplitude at a few points in the linac; look to see how much the amplitude blurs bunch_list[n_stations/3].root_histogram('amplitude x y','mm') bunch_list[2*n_stations/3].root_histogram('amplitude x y','mm') bunch_list[-1].root_histogram('amplitude x y','mm') #clear weights for bunch in bunch_list: bunch.clear_weights() #plot transmission Bunch.root_graph(bunch_list, 'mean', ['z'], 'bunch_weight', '') #cut on transmission in middle plane #looks through all particles in bunch_list[0]; if it can't find the event_number in #bunch_list[-1], set weight to 0 bunch_list[0].transmission_cut(bunch_list[-1], global_cut=True) #plot transmission Bunch.root_graph(bunch_list, 'mean', ['z'], 'bunch_weight', '') #now wait for user to review plots before ending print('Press <return> key to finish') input() Bunch.clear_global_weights()