def analysis(self):
     print "Loading data"
     bunch_list = Bunch.new_list_from_read_builtin('maus_root_virtual_hit', 'maus_output.100.root')
     bunch_list = [bunch for bunch in bunch_list if bunch.bunch_weight() > 10 and bunch[0]['z'] < 3472.001]
     print len(bunch_list)
     delaunay = DelaunayWrapper(bunch_list[0], ['x', 'px', 'y', 'py', 't', 'energy'])
     areas_0 = delaunay.get_areas(bunch_list[0])
     areas_1 = delaunay.get_areas(bunch_list[1])
     self.plot_areas(areas_0, areas_1)
예제 #2
0
 def analysis(self):
     print "Loading data"
     bunch_list = Bunch.new_list_from_read_builtin('maus_root_virtual_hit',
                                                   'maus_output.100.root')
     bunch_list = [
         bunch for bunch in bunch_list
         if bunch.bunch_weight() > 10 and bunch[0]['z'] < 3472.001
     ]
     print len(bunch_list)
     delaunay = DelaunayWrapper(bunch_list[0],
                                ['x', 'px', 'y', 'py', 't', 'energy'])
     areas_0 = delaunay.get_areas(bunch_list[0])
     areas_1 = delaunay.get_areas(bunch_list[1])
     self.plot_areas(areas_0, areas_1)
예제 #3
0
import sys

#script starts here
target_beta = 800. * Common.units['mm']
target_alpha = 0.0

print('========= XBOA example 4 =========')

print()
"""
Now we start manipulating the data. The idea here is to take particles from
one system, apply a match condition so that they can be used in another system.
Aim is to mimic an ideal transfer line.
"""
print("Loading file... ")
bunch_list = Bunch.new_list_from_read_builtin(
    'icool_for003', sys.prefix + '/share/xboa/data/for003_test.dat')
print("Loaded")

#I only use the last bunch for this
bunch = bunch_list[-1]

#let's look at the particles with 150 MeV < energy < 400 MeV
bunch.cut({'energy': 400}, operator.ge)
bunch.cut({'energy': 150}, operator.le)
#remove the outside of the beam - particles with amplitude > 90 mm (emittance > 22.5)
bunch.cut({'amplitude x y': 90}, operator.ge)
bunch.root_scatter_graph('t', 'energy', 'ns', 'MeV', include_weightless=False)
#first we transform the bunch so that all particles sit in a single RF bucket
bunch.period_transformation(bunch[0]['t'], 0.20125 * Common.units['GHz'])
bunch.root_scatter_graph('t', 'energy', 'ns', 'MeV', include_weightless=False)
예제 #4
0
import xboa.common as common
import xboa.common.config as config
import sys

#some input data
filename = sys.prefix+'/share/xboa/data/for009.dat'
filetype = "icool_for009" #some other options are "g4mice_virtual_hit", "icool_for003", "g4mice_special_hit"

print('========= XBOA example 2 =========')

#try to load an input file
#this will load the for009 file, and make a list of "bunches", one for each region
#a list is a python version of an array
print("This example shows how to make plots\nYou will need to have access to either ROOT library or the matplotlib library to make plots")
print("First loading the data... ")
bunch_list = Bunch.new_list_from_read_builtin(filetype, filename)
print("Loaded")

#make some plots
#first try to make plots with ROOT if PyROOT exists
try:
  print('Trying to make some plots using PyROOT plotting package')
  config.has_root() #check for PyRoot library
  #momentum distribution at start and end
  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