2 \namespace xboa::examples::Example_3
4 Example code to read a file, make some cuts and then plot
6 \include xboa/examples/Example_3.py
27 print '========= XBOA example 3 ========='
30 print "This example shows how to make cuts"
31 print "Loading file... "
32 bunch_list = Bunch.new_list_from_read_builtin(
'icool_for009', sys.prefix+
'/share/xboa/data/for009.dat')
36 bunch_list[0].root_histogram(
'px',
'MeV/c')
40 bunch_list[0].cut({
'px':30.}, operator.ge)
42 bunch_list[0].cut({
'px':-30.}, operator.le)
44 bunch_list[0].root_histogram(
'px',
'MeV/c')
48 bunch_list[0].clear_weights()
51 bunch_list[0].cut({
'amplitude x y':30.}, operator.ge, global_cut=
True)
52 n_stations = len(bunch_list)
57 bunch_list[0].root_histogram(
'amplitude x y',
'mm')
60 bunch_list[n_stations/3].root_histogram(
'amplitude x y',
'mm')
61 bunch_list[2*n_stations/3].root_histogram(
'amplitude x y',
'mm')
62 bunch_list[-1].root_histogram(
'amplitude x y',
'mm')
65 for bunch
in bunch_list:
69 Bunch.root_graph(bunch_list,
'mean', [
'z'],
'bunch_weight',
'')
74 bunch_list[0].transmission_cut(bunch_list[-1], global_cut=
True)
76 Bunch.root_graph(bunch_list,
'mean', [
'z'],
'bunch_weight',
'')
79 print 'Press <return> key to finish'
81 Bunch.clear_global_weights()