Index of /~dlr/g-2/gm2/mytest/efield_pitch/files

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[TXT]60hRadialDistribution.txt2019-03-15 10:44 804  
[   ]IBMS_layout.dat2022-10-23 11:05 280  
[   ]KICKER_E821.dat2013-12-17 09:03 1.0M 
[   ]KICKER_E989.dat2013-12-17 09:03 1.0M 
[   ]KICKER_E989_NoRolledEdges.dat2019-04-08 09:26 829K 
[   ]QUAD1_Long.dat2014-04-21 15:50 1.5M 
[   ]QUAD1_Short.dat2014-04-21 15:50 1.5M 
[DIR]TrackerData/2020-05-28 13:51 -  
[   ]VerticalPositionRun15922.dat2019-04-28 08:28 3.1K 
[DIR]backleg/2022-10-29 11:35 -  
[   ]beta_alpha_eta_etap.dat2022-10-19 10:31 11K 
[   ]beta_eta.dat2022-10-19 10:31 5.5K 
[   ]bmad.2015-10-13 21:34 13K 
[   ]bmad_all_configs.2018-03-19 10:45 14K 
[   ]bmad_all_configs_fringe_inf_grid.2019-04-08 09:26 11K 
[   ]bmad_all_configs_fringe_inf_grid_fh_muon_cquad_4k.2018-03-22 13:19 12K 
[   ]bmad_all_configs_fringe_inf_grid_fh_muon_cquad_ks.2019-02-21 16:29 12K 
[   ]bmad_em_field_calc_or_custom.2018-02-28 13:01 11K 
[   ]bmad_ering.2015-12-02 10:49 550  
[   ]bmad_es_multipoles.2015-12-22 15:16 15K 
[   ]bmad_es_ring.2016-09-27 20:45 15K 
[   ]bmad_esquad_grid.2019-05-16 09:12 12K 
[   ]bmad_esquad_grid_10cmupstreamIBMS1.2022-11-11 09:30 12K 
[   ]bmad_esquad_single_plates_grid.2019-02-21 16:28 14K 
[   ]bmad_generalize_lattice.2017-03-30 11:11 15K 
[   ]bmad_grid_fringe_inf.bmad2023-11-17 19:57 4.1K 
[   ]bmad_grid_fringe_inf_10cmupstreamIBMS1.bmad2022-10-22 11:35 4.0K 
[   ]bmad_grid_fringe_inf_custom.bmad2019-04-08 09:26 3.6K 
[   ]bmad_ideal_ring.2017-03-10 13:29 534  
[   ]bmad_m5_injection.2017-07-24 11:52 11K 
[   ]bmad_m5_to_ring.2016-05-11 12:20 15K 
[   ]bmad_m5_to_ring..digested2842022-09-26 10:41 274K 
[   ]bmad_pure_ring.2017-11-01 20:53 11K 
[   ]bmad_quad15kV_harps.2017-06-15 20:46 10K 
[   ]bmad_quad_grids_short_kickers.2017-05-02 15:07 13K 
[   ]bmad_quad_grids_short_kickers_quad_offset.2017-01-01 12:04 13K 
[   ]bmad_quads_grids_or_multipoles_kickers.2017-01-01 12:04 12K 
[   ]bmad_ring.2017-06-16 12:37 11K 
[   ]bmad_short_inf.2017-01-01 12:04 7.6K 
[   ]bmad_short_inf_ap_collimator.2015-10-13 21:34 12K 
[   ]bmad_short_kickers.2015-10-16 07:22 13K 
[   ]bmad_short_kickers_trackers.2015-10-13 21:34 15K 
[   ]calorimeter_lattice.2019-04-08 09:26 3.4K 
[   ]cons_ff.in2016-05-11 14:04 2.0K 
[   ]ering_input.dat2015-12-02 10:49 182  
[DIR]fiber_energy_loss/2019-04-08 09:26 -  
[   ]fiber_monitor_lattice.2019-07-05 02:33 1.0K 
[DIR]fiberharpData_run3/2020-07-06 11:10 -  
[DIR]fields/2018-02-14 12:58 -  
[   ]fort.332022-10-19 10:31 7.4K 
[   ]g-2_FFT_04032015.lat2022-09-26 10:39 5.8K 
[   ]g-2_FODO_04032015.lat2019-04-08 09:26 3.7K 
[   ]g-2_horzbend_04032015.lat2018-03-19 10:45 2.3K 
[   ]geometry.dat2022-10-19 10:31 8.8K 
[   ]gnu_input.dat2014-02-13 10:31 476  
[   ]ibms_lattice.2024-07-30 18:07 1.0K 
[   ]input.dat2019-05-16 12:16 21K 
[   ]input.dat.tmp2013-11-19 13:40 1.2K 
[   ]input.dat_save2013-11-01 08:36 1.2K 
[   ]integral_fit_parameters.dat2019-04-27 06:48 3.9K 
[DIR]kickermaps/2019-06-19 14:18 -  
[   ]lattice.py2019-05-11 08:49 13K 
[DIR]muons/2025-02-02 11:59 -  
[   ]muons_off_target.dat2017-07-19 10:13 1.1M 
[   ]parameters_g-2_03112015.lat2019-04-08 09:26 4.1K 
[   ]pulse_127cm.dat2019-04-08 09:26 480  
[DIR]pulse_shapes/2019-06-18 16:39 -  
[DIR]quad_curvilinear/2025-02-11 10:46 -  
[DIR]quad_curvilinear_single_plate/2025-07-13 19:07 -  
[   ]quad_input.dat2019-04-18 16:39 1.3K 
[   ]quad_multipoles.dat2015-05-08 14:49 444  
[   ]quad_plate_misalign.bmad2019-04-16 20:31 2.6K 
[DIR]quads/2025-02-11 10:46 -  
[   ]spin_pitch_fit_parameters.dat2019-04-27 11:34 1.2K 
[   ]spin_pitch_fit_parameters.dat_save2019-04-27 06:48 1.2K 
[   ]tao.ps2017-07-24 12:01 57K 
[DIR]test/2019-05-13 20:39 -  
[   ]total_muons.dat_0.00242017-05-25 17:03 1.2K 
[   ]total_muons.dat_start2017-05-26 18:43 1.1K 
[DIR]tracker/2019-11-18 18:33 -  
[   ]transfer_matrix_file.dat2014-02-13 10:31 5.5K 
[   ]walls_free.bmad2019-04-08 09:26 4.3K 
[   ]walls_free_less_afree.bmad2024-07-30 16:39 4.3K 
[   ]walls_free_qm.bmad2020-06-09 08:05 4.5K 
[   ]walls_quads2-4.bmad2019-04-08 09:26 4.0K 

<<<<<<< .mine
March 3, 2021 - adjust plots for beam dynamics paper. The plots are created in /nfs/gm2/data1/dlr10/g-2/mytest/spin_test/spin_test_single_plate_ref2/ using mytest/spin_test/spin_test_pub.pdf and spin_test_conv_efield_pub.gnu

=======
September 3
                    To create plots of twiss parameters propagating into ring /home/dlr/development9_linux/g-2/mytest/mismatch
                    
August 27-September 2
                    New plots for BD paper. polarization plot use david@Davids-Mac-mini:~/development/bmad_dist/g-2/mytest/spin_track/plot_spin.gnu
                    quad_field.pdf - g-2/plotting_scripts/quad_field.gnu in subdirectory /spin_track/20200811_160221/   mini 
                    Efield/pitch theory mini/g-2/documentation/PitchSystematic1.tex, called by header.tex
                    bd systematics - documentation/aps_bdsys/Rubin-aps-July2020/ ap1_pitch.tex
August 8 - 18
                    gm22/mytest/efield_pitch_surveyed 
                    gm22/mytest/efield_pitch_survey_sym_volt 81 configs, +-0.01,0 V -surveyed alignment  - in progress 8/18
                    gm22/mytest/efield_pitch_survey_sym_errors 81 configs, +- (sum+diff/2 errors) 
                    gm22/mytest/efield_pitch_survey_sym_v2 81 configs, +- (sum and diff errors not correlated)

                    gm22/mytest/energy_vs_time_vs_turn
                              config_011-config_018 - pulse shapes 1-8 


August 3, 22020
                          2-43M                                                                                            amplitude agree. Width small, out of phase?
                          2-44M                                                                                            nominal collimators, 0 injection angle
>>>>>>> .r53682
July 1, 2020        run	CBOptp		CBOavg		width		ap			comments
                          2-39       -4>13		5			17			+40.-38            kick 244 offset collimators, 15.8 > +1mm, 19.2 > 0,27.2 > -2mm, 30.4> 2.5mm, 38.1 > -.5mm
			  2-38       -7.5>10           1.25			16.5			+38,-40             kick 292
              		  2-40       -12>13            1   			19 			45, -45		 poor statistics, 50mm collimator, kick 244G
			  2-36	-4,11                3 			18			-32, 32	         no energy loss, poor statistics,collimators only at 16 and 20
			  2-35	-2>14		6    			17			+40,-32            kick 233
			  2-34	-2>14		6			16			+35,-32		 kick 233, 10ns bin width
			  2-33	-4>14		5			16-17		+40,-35		 kick 244
			  2-41	-8>12		2			18.5			+40,-40		 kick 244, offset collimators -5mm and 50mm aperture
			  2-40       -11,14	        1.5			19.5		         +42,-40      	 

June 26, 2020     For fiber harp try removing 3/5 collimators. Actually, displace all colimators radially in 2.5mm.  Keep it simple Start with run_2-37/20200617_142252 with 1ns bunch.
                           run_2-40 20200626_090735, Now try increasing collimator diameter 20200626_200804 
June 23, 2020     vertical width - config_br_18kV_play_y  gets radial centroid but width too small -   220.e-4   190.e-4     205.e-4 
                                                  - config_br_18kV_play_z/20200611_135121  gets radial width but centroid too big   200.e-4   170.e-4     185.e-4
						  - Try kick halfway in between. Also set initial vertial beta to 5 from 10 (based on vertical mismatch)
						    config_br_18kV_play_z/20200623_094947  20200623_094954  20200623_095013  20200623_095017  210.e-4   180.e-4     195.e-4, beta_v inf = 5
                                                               Complete analysis and plot this last. Good match to radial width. Average radial too high.
							       For more statistic - submit batch

                                                    config_br_18kV_play_y/ use 220.e-4   190.e-4     205.e-4 play/20200623_195122  20200623_195131  20200623_195136  20200623_195140

                                                  fiber harps  - the closed orbit distortion peaks at -2.5 mm at 9m and +2.5mm at 30mm. The collimators are at the end of Q2 short, Q2 long, Q3 long Q4 short and Q4 long, that is
			                          15.8m, 19.2m, 27.2 m, 30.4m 38.1m
						  A shortcut to including the closed orbit distortion is to displace the collimators.
						  15.8 > +1mm, 19.2 > 0,27.2 > -2mm, 30.4> 2.5mm, 38.1 > -.5mm
						  Set up in run_2-39. In retrospect not sure how this helps. The radial out aperture is smaller. But the radially in is no bigger.
June 22, 2020    STuff to do
                             1. Beta mismatch ~/development9_linux/g-2/mytest/mismatch - the vertical mismatch is pretty extreme. Try setting beta_y smaller at inflector exit. That might reduce eventual vertical distribution?
			     2. Why does centroid and width oscillate at revolution frequency? I would expect that number of muons would oscillate (FR signal) but not the average position.
			     3. How to include nonuniform field?
June 17, 2020    Set bunch length to 1ns. That way all particles get the same kick. run_2-37.
                                20200617_142252  - bunch length = 1ns., kicker =244 G
				20200617_193249  - bunch length = 1ns., kicker=292 G - the 'Beam_moments_by_element.dat' agrees with centroid data.
				    Next repeat with realistic bunch length and more data
June 16, 2020    Harp comparison. Plotting centroid +sign*width. Is the sum greater than the aperture? Copy run_2-27/20200604_124602 to run_2-36 for convenience. This run had energy loss off. To see how it fills apertures.

June 12, 2020    run_2-34 plot (centroid sign)* width + centroid. Sim is 5-10mm less than measurement. Plotting width from FiberHarp.dat from run_2-21 looks very different from width from Beam_moments_by_element.
                          Maybe the 149 ns bin is too big? What if we get Beam_moments_by_element for each element (rather than full turn). Try that in run_2-34. set save_element_by_element_info = T
                          Also run_2-35/ input from run_2-34 with 2.5ns bin.
June 11, 2020    Try that last excercise again. Repeat run_2-22 angle, kicker,distr. Note that scraping is different.
June 10, 2020     run_2-33. Increased angle. Still not making CBO. Are the collimators right? Something is not right. A difference from run_2-22 is the distribution. From the file in run_2-33 and new from run_2-22. Try run_2-33 with random dist.
                           Another difference is that muon decay is turned on in run_2-22.
			   Go back to run_2-30 and rerun with random distribution. As in run_2-22 set pzsigma=0.026.
			   
June 9, 2020       Modify lattice with 24 (rather than 12) markers for time dependence of width. Run test job /config_b4_18kV_play_y/ to make sure it is working before submitting a load. 20200609_105109. Close but wants bigger kick.
                            Requires some minor modification of compute_time_dep_moments_calo.f90. Create new versions of ploting scripts.
			    Fiber harp/ run_2-30. Increase angle of run_2-29 to -3mrad and submit 25 jobs - CBO too big. Try angle = -2.5mrad run_2-31. Centroid too small. Try -2.75mrad run_2-32

                            vertical width - config_br_18kV_play_y/ 20200610_102811 - with 10G increase in kicker. Looks OK. start 4 more jobs same input.dat  20200610_204531  20200610_204536  20200610_204544  20200610_204627
                           
Jun 8, 2020         Modify <analyze_fibers_harp.f90> so that if there is only one file to read, the output <FiberHarp.dat> gets written to that directory (as well as main directory). That way it gets saved. Create local plotting
                           script plot_harp.gnu to plot from FiberHarp.dat  for those directories to help figure out what's what with all the runs in run_2-27. Decide to run for more statistics with inputs from
			   run_2-27/20200605_203649/input.dat > run_2-29   submit 25 runs
                           /run_2-27/20200605_144834/input.dat > run_2-28  submit 25 runs

                           More statistics for phase-correlation study.

June 7, 2020       Increase angle more. 20200607_072208. Try same angle but no offset. 20200607_133758. CBO got smaller !!! Next try bigger collimators 20200607_134347 also no help. Try random distribution rather than Diktus.
June 6, 2020       More kicker. <x> high. Got to 254G. 20200605_203649. Now need more CBO. Increase angle, reduce offset,  -0.001   0.0  0.0 -0.0025 0 0 20200606_203036. CBO shifts down. 
June 5, 2020       latest/run_2-27/20200604_202126/ 0.01<width <0.019, -0.002<CBO <0.013.
                           Increase angle and kick to get more CBO and smaller average. Also add the remaining collimators
			   Relabel collimators as per 4330-v2 in /nfs/gm2/data2/dlr10/g-2/mytest/harp/run_2-27/bmad_esquad_br_8_grid.
			   Set inflector field t0 0.97 as in run_2-22. And try again. '20200605_144834 very close. Width a bit low. average x a bit high. Increase kick. Increase kick from 233.6 to 244G  20200605_203649
June 4, 2020       Fiber harp /nfs/gm2/data2/dlr10/g-2/mytest/harp/run_2-27/   Start with input.dat from play/ Turn on fiber harp, and harp scattering. > 20200603_190201 - reasonable.
                           Next use injection angle and kicker from run_2-22/input.dat 20200604_103242. - strange. CBO is smaller and average is too high? width looks good. Using Diktus distr.
			   Maybe statistics. Try again with 100k vs 25k. run_2-27/ 20200604_124602. No energy loss. Turns out ift was off. Try again with energy loss
June 2, 2020       Use Dyktis distribution with input from 20200531_135810  -> play/'20200602_072207'  
                           Modify tracking_master, create_phase_space, read_dmuons, muon_interface, to specify the number of muons to read from a file and the first muon to read
			   With that feature play/'20200602_105603  20200602_105616  20200602_105631    20200602_110047'  each run reads next 100k muons (or as many as are left)
June 1, 2020       Maybe its about the radial field. Try using BrFourier2016.dat  and input from 20200531_135810 > play/    20200601_100826  20200601_100924   no help. Vertical is worse. Try opposite sign Br
                           Change sign  of radial field in subroutine generalize_cyl_exp /play/'20200601_152222  20200601_15222' 
May 31, 2020     Redo that last as kicker inadvertenly set to zero. play/'20200531_090213'         kicker_params%kicker_field =        210.e-4   180.e-4     195.e-4  ! Renee + 10 - centroid matches but vertical width too big,
                           horizontal too small. Try more inj angle. (y) play/'20200531_135810 very close-vertical width a bit high. 
			   Try more inj angle.   -0.001   0.0  0.0  -0.002 0 0, kick = renee + 10  play/'20200531_175429'. CBO too big. Vertical width too big.
May 30, 2020     increase kicker to bring down CBO play '20200530_093959' looks good but cbo still too big. Increase kicker a bit more play/'20200530_195038' - kicker at 0.
May 29, 2020     The problem seems to be only in the radial width 10-30 us. Vertical width looks OK. Try running g2tracking with 149.2ns bin again. Somethng funny about that last attempt. play/'20200529_111751'
May  28, 2020    play/ ' 20200527_183248'  (y)  inflector_end_target = -0.00185   0.0  0.0  -0.00125 0 0, vertical width OK but CBO too big, radial width too small.
     	 	       	   Reduce angle, keep offset.  (z) inflector_end_target = -0.00185   0.0  0.0  -0.00025 0 0 play/'20200528_071649' vertical width too big.
			   Maybe horizontal CBO and width are at wrong relative phase. Add a plot. Find that relative phase width and amplitude in good agreement with measurement. 
May 27, 2020     Forward momentum/correlation distributions with unequal kickers in /nfs/gm2/data2/dlr10/g-2/mytest/energy_vs_time_vs_turn/config_008
                          and config_009 to tyler.
			  /play/'20200527_110918'  - with differential kicker voltages from Renee. But otherwise same as. Use config_br_18kV_play_x input.dat with differential kicks.
			  Find that reducing the kick makes the vetical width smaller, (too small) Also CBO is to big. Try reduing injection angle.
                          Init (r) (-1mrad) play/20200527_143053. CBO too big. Vertical width too big. radial width too small.		  
May 25, 2020     Turns out that compute_moments_s_time_calo was doig the right thing. The problem was in compile_all_time_dep combining 10ns bins into 149.2 ns bins.
                           This is fixed so that re running compile_all_time_dep will work. Use option'N'.
			   Try again with tracking starting after inflector. This time with restored compute_moments_vs_time_calo play/'20200525_104150' Radial width is a few mm bigger than tracker.
May 22, 2020     20200521_170741 with 149.2 ns bins. Width and amplitude in Time_Dep_Moments_at_END.dat now look identical to Beam_moments_by_element.dat. Is the problem in the way the
                           bins are combined? Meanwhile, no calo data was written. Must be a bug.
May 21, 2020     Create <compute_moments_by_time_sum_calo.f90>. Modification of <compute_moments_by_time_calo.f90> so that both sums and averages are written to files with '_at_' and '_sum_'
                           so that can try to understand what's happening.
                           Two things to try
                               - Increase bin width in input.dat to 149.2 ns -  play/'20200521_170741' with latest modification of <compute_moments_by_time_sum_calo> that writes both average and sum 
			       - decrease momentum width of the initial districtuon so there is no debunching
May 20, 2020       /play '  20200520_073918' injection through inflector, with version of compute_time_dep_moments that sums
                            version of compute_time_dep_moments_calo that collects sums. Modify compile_all_time_dep so that it can translate sums as well as ave. Test of this
                            feature on 20200519_19620 suggests that this fixes the problem with width!
                            /g-2/mytest/energy_vs_time_vs_turn/config_008/ kicker 1 - 20, kicker 3 +20 			    
May 19, 2020       /play/20200519_190620 edit compute_time_dep_moments_calo.f90 so that sums are saved rather than sigma. Start tracking after inflector.
May 18, 2020       /g-2/mytest/energy_vs_time_vs_turn/config_008/ kicker 1 + 20, kicker 3 -20 
May 13, 2020       Time to find out what varying individual kickers does. Decrease kicker 1 increase kicker 3. play/'20200513_201758  20200513_201815  20200513_201817  20200513_201821'
May 12, 2020       play/'20200512_071716  20200512_071722  20200512_071726  20200512_07173' decrease kicker slightly(200.0 to 198.) decrease horizontal angle slightly (-1.25 to -1mrad)
                             config_br_18kV_play_x  - inflector_end_target = -0.00085   0.0  0.0  -0.00125 to get vertical width. - But CBO amplitude is too big.
May 11, 2020       Change initial horizontal angle. -1mm,-1.5mrad (m) Vertical angle back to 0 play/' 20200511_083129  20200511_083252  20200511_083300  20200511_083306'
                             CBO average a bit low. Amplitude a bit high. Vertical lines up
                             pretty well both centroid and width. Radial width amplitude agrees at 60 us . A bit low at earlier time. But minimum of width is a few mm below minimum of measured width.
			     Try a bit smaller angle. A bit lower kicker. play/'20200511_130616  20200511_130624  20200511_130641  20200511_130647' CBO way too big and vertical width too small.
			     Try increasing kicker play/'20200511_185443  20200511_185450  20200511_185527  20200511_185534' vertical width very close, CBO too big
May 10, 2020       20200510_073020 - single partle, on momentum, -1mrad vert
                             20200510_083506 single particle. No scattering. 
			     20200510_110615 single particle. No scattering. 50ppm radial. increases vertical ptp. which we know reduces vertical width
			     20200510_124030  single particle. No scatter. Br=0.  py_init=1mrad > 1.6mrad at inflector. gives 3 times ppt as 100ppm bradial.
			     20200510_124845  20200510_124857  20200510_124904  20200510_124912 - py_init=1mrad. scatter in inflector is on. Not much effect on width
			     That means an incoming vertical angle should do the same.
May 9, 2020         Maybe somehow a vertical offset or angle from inflector is equivalent in some way to radial field? Try an offset at inflector. enter at 2mm,0mrad, exit inflector with -1.2mrad vert,
                             play/'20200509_150416  20200509_150422  20200509_150430  20200509_150435' MISTAKE. There is no -1.2mrad. Vertical angle is zero
May 8, 2020         Run '20200501_181949  20200501_181955'  with more statistics.
                             Appears a bit closer to measured vertical width? But this time turn off muon decay. play/ '20200508_082514  20200508_082521  20200508_082532  20200508_082539' vertical width too big
			     Try radial field. Radial field does reduce width.  Try 50 ppm.  play/'20200508_213314  20200508_213323  20200508_213332  20200508_213339' vertical width closer but still too big. Horizontal
			     ptp is very close. Why does increasing radial field also increase mean radial? 
May 7, 2020         Getting th scraping right seems to have helped. Start looking at vertical rather than horizontal. Rus from 20200501 both short on statistics.
                             play '20200507_164938  20200507_164947  20200507_164954  20200507_165004'. same as '20200501_122036  20200501_123056'.
May 4, 2020         /g-2/programs/compile_all_time_dep.f90 - edit to loop through all locations and write plot_width_cboamp_10-30us.dat that is loaded by config_ref/plot_width_cboamp_10-30us.gnu and labels plot and output file
			    /g-2/mytest/energy_vs_time_vs_turn/config_007/ 25ns early  started 12:22 
May 3, 2020         /g-2/mytest/energy_vs_time_vs_turn/config_006/all_Energy_vs_time_0.dat 25 ns later  (started 8:56 am)
			    /g-2/mytest/energy_vs_time_vs_turn/config_007/ 25ns early

May 1, 2020         Edit track1_preprocess so that scraping differentially exponentially dissapears with tau= 7.e-6  -  focus_scrape_scale = init_quad_focus * exp(- (quad_time-quad_ramp_start_time)/tau). There
                             is no longer a stop time. The differential asymptotically approaches zero. Decay time fixed to 7 us for time being. (ma) play/'20200501_122036  20200501_123056'  no difference. But extra scattering.
			     Set extra scattering back to zero and try again. (mb) play/'20200501_181949  20200501_181955' no difference
 
April 30, 2020      Still confused. Maybe I should get the scraping time dependence in the right way.
April 26, 2020      Set 18.3-15.1 (vs 13.1) and 50mm collimator  a26 /play/'20200426_070054  20200426_070108  20200426_070132  20200426_070138' Did the width get smaller?
April 25, 2020      Comparison with tracker data suggests that scrape voltage change is less than in simulation. Especially vertical. Try reducing change. 
April 19, 2020      Maybe its the colimator at 180 deg that scrapes the waist.  Try opening that collimator (a19a) play/'20200419_132656  20200419_132714  20200419_132728  20200419_132736' nothing.
                            Increase both collimators to 50mm (a19b) play/' 20200419_172726  20200419_172730  20200419_172737  20200419_172812'  width withing 0.5mm. ptp cbo close but CBO simulation decays more quickly than data. Does
			    that mean there is too much mom
April 18, 2020      Try positive angle (w) (a18) play '20200418_140306  20200418_140309  20200418_140317  20200418_140319'  No help
April 17, 2020      Turning scraping off increases width. Turning off just horizontal width has almost no effect on horizontal width. Does that make sense? Not sure about that but it does seem to be implemented properly
                             Try radial B-field - set to 100 ppm in lattice file and quad_input.dat  Back to (r). bad resistors. horiozntla scraping on
			     (a17a) /play/'20200417_090600  20200417_092713  20200417_092725  20200417_092736  20200417_092740'
			     Shifted up 8mm. Width is 0.5mm narrower. CBO ptp -5:17.
			     Try something a bit smaller. 20ppm (17b) play/'20200417_114137  20200417_114208  20200417_114237  20200417_114254'
April 15, 2020      Increase scattering in inflector ends /play/ set extra scatter factor to 5, turn on scraping and bad resistors and
                            (a15a) play/'20200415_101206  20200415_101211  20200415_101218  20200415_101226' No effect on width.

                             extra_inf_scatter_factor  =0. Track1_custom now has a scale factor that allows multiplication of the end of the inflector scatter. Normally extra_inf_scatter_factor=0.
 
                             Modify track1_preprocess so that horizontal scraping can be turned off independently. logical horizontal_scrape if false turns off horiozntal voltage change (r)
			     (a15b) play/'20200415_164037  20200415_164042  20200415_164047  20200415_164051' width is 8:17, radial centroid is 1-3mm too great. Maybe a bit less inj angle?
                             Try combination of (p) and no horizontal scrape (a15c) play/'20200415_192902  20200415_192905  20200415_192909  20200415_192912' cbo ptp -5:21, width 8.5:17
April 14, 2020      (a14) play/  turn off scraping '20200414_210912  20200414_210920  20200414_210941  20200414_210948'  radial width does increase to nearly match tracker. Centroid amplitude is now smaller ~2-3 mm.  Also tracker
                            vertical mean shows scraping change in vertical orbit is smaller than in simulation but still there.
April 13, 2020	    Compare config_br_18kV_play_t_nodecay/ and config_br_18kV_play_t_nodecay/. The feature that vertical width decreased with time was evidently statistical as no longer happens.
                            Meanwhile tracker data is in g-2/files/TrackerData/ .C files are modified to .dat so that they are gnuplot readable.  Names of files are /g-2/files/TrackerData/plot_form.gnu to be
			    loaded when plotting. Tracker width 10:19 mm. Centroid measurements > sim and average is > sim  ? larger inj angle? Vetical - width 13.25 vs 12.75 measurement.
			    Vertical mean at S12 more or less agrees with simulation. So simulated vertical width is too big. Simulated horizontal width is too small.
			         
April 11, 2020      config_br_18kV_play_t_nodecay/ complete, make plots. Wdith vs time almost no change to 300 us. No decay
                            config_gr_18kV_play_t_nodecay
         
April 8, 2020        show results from config_br_18kV_play_t/ in phase-acceptance meeting. The big discrepancy is that the width shrinks too fast. More statistics
                            create config_br_18kV_play_t_nodecay/ all the same as config_br_18kV_play_t but with decay turned off. submit jobs
                            Fix /config_ref/plot_vert_one_dir - label horizontal (not vertical) centroid

                            plot /config_br_18kV_play_v - kicker is 210 G. Widths are different. But vertical width nevertheless too small.

April 7, 2020       submit (v) config_gr_18kV_play_v
			    /g-2/mytest/energy_vs_time_vs_turn/config_005/ all_Energy_vs_time__0.dat 50ns early

April 6, 2020       (u) /play/'20200405_141805  20200405_141815  20200405_141843  20200405_141913' - e_x too small.
                           try kick 210. (v) play/'20200406_075059  20200406_075109  20200406_075116  20200406_075123' <x> 10:150 = 5.87 - try config_gr_18kV_play_v

                            /g-2/mytest/energy_vs_time_vs_turn/config_004/all_Energy_vs_time_0.dat 50 ns later
			    /g-2/mytest/energy_vs_time_vs_turn/config_005/ 50ns early
April 5, 2020       /nfs/gm2/data2/dlr10/g-2/mytest/energy_vs_time_vs_turn/config_004 correlated distribution kicker time    +50ns
                            back to efield_pitch_bad_resistors/play. Two things to try. Bigger kick to get r_e closer. And more scattering to increase width. Start with kick. Increase from 204 to 224. Label (t)
			    /play/'20200405_141805  20200405_141815  20200405_141843  20200405_141913'
April 4, 2020       plot results from config_gr_18kV_play_t/  and create a presentation g-2/documentation/bad_resistors/WidthvsTimePosition_20200404
April 3, 2020      config_br_18kV_play_t/
                          $pb/compile_all_time_dep 'QUADM1' 149.2e-9 'all' for each location and END
			  gnup500 -e 'title="bad resistors"' ../config_ref/plot_vert_one_dir.gnu
			           Features - Plot width vs time at 12 locations. Lost muons - more low energy muons are lost. <x_e>=6.83 is a bit high (closest to End Game)
				   Plot fraction of muons lost. Plot width and CBO 10-30us  /config_ref/plot_width_cboamp_10-30us.gnu
				   There are 67,167 muons that decay after 35us. 207 muons lost after 35us, 55 muons lost after 35us with p>p_magic, 152 lost after 35us with p< p_magic
				    Fix up compile_Time_Dep so that it writes a file of lost muons with just those lost after 35us - hist_lost_muons.pdf
				    Copy input.dat from config_br_18kV_play_t to config_gr_18kV_play_t. Turn off bad resistors and start 50 jobs
April 2, 2020      Since (t) was pretty close, use input.dat from 20200401_152555 and submit 50 jobs into directory /config_br_18kV_play_t/

April 1, 2020      Discover that inflector scattering was turned off because tracking_method=custom was commented out in bmad_grid_fringe_inf.bmad. Fixed
                          (s) Rerun (r) with scattering in inflector entrance and exit.  play/'20200401_064716  20200401_064727  20200401_064735  20200401_064738'  Not much different from (r)
			  Next look at collimators. Sudeshna says the 2 collimators were between Q3short and Q3long (near calo 16) and at about 270 halfway from Q3long to Q4short. Comment out
			  custom tracking in all other collimators in bmad_es_br_8_grid.
			  (t) Rerun (s)  play/'20200401_152530  20200401_152541  20200401_152550  20200401_152555' 10-30us width ptp 7:17- 8:18, 100us 12:18, CBO ptp -5:20 at 10us to -2:14 at 100us


March 27-30, 2020  That last experiment to reduce scraping to increase width did just the opposite. With the reduced scraping the centroid amplitude increased and the width decreased.
                           (a)Try increasing scraping? Increase scraping 50% play/'20200327_073357 20200327_073446 20200327_073505 20200327_073523'
                           (b)Reduce scraping  voltage change in half. submit 4 jobs play/20200326_194142 20200326_194223  20200326_194233 20200326_194239  
                                Again, amplitude is bigger, width is smaller.
                           (c) Go back to nominal voltage and shift ramp start time to 7.5 us (D. Tarazona's recommendation) 0., -2mrad
			           play/'20200327_115759  20200327_115809 20200327_115821 20200327_115834'
			           Does not help - OSC amplitude a bit too big. ptp=-10-20 and width ptp = 7-16.5
		           (d)  Try reducing injection angle a bit to -1mm -1.5mrad  play/'20200327_164118  20200327_164131 20200327_164143 20200327_164157'. Now the CBO amplitude is too small (16mm)
			     but the width did increase a bit ptp = 8-17.5.
			   (e)  Try -2mm -1.75 play/'20200328_020457  20200328_020508  20200328_020515  20200328_020524'  CBO ptp -3:16, width ptp 7:17
   			   (f)  Try -2mm -2.25 play/'20200328_102519  20200328_102531  20200328_102540  20200328_102552' width  ptp 7:16.5 CBO ptp  -4:16,
      			   (g)  Try -1mm -2.25 play/'20200328_160624  20200328_160633  20200328_160649  20200328_160701', width  ptp 7:17   CBO pt -3:16
                           (h)  Try  -2mm -3mrad play/'20200329_074521  20200329_074529  20200329_074539  20200329_074545' width ptp 7:17, CBO ptp -3:16
                           (j)  Try  -2mm -3mrad again.  This time restore scrape start time to 15us play/'20200329_133837  20200329_133842  20200329_133851  20200329_133856' no change
			   (k)  Restore inflector to 0.97 (harp optimum), Then to run 2-21. 0.,-2mrad, start scrape at 7.5us play/'20200329_184146  20200329_184232  20200329_184240  20200329_184250' CBO ptp -6:20,
			   width ptp 6:15
			   (l) Very interesting. Now try -1mm, -2mrad play/'20200330_071616  20200330_071629  20200330_071642  20200330_071653' CBO ptp -7:21  width ptp 6-16
                           (m) Try -1mm, -1.5mrad play/'20200330_111715  20200330_111721  20200330_111727  20200330_111732' at QUADM10, CBO ptp -5:22, width ptp 6:15 almost no difference
			   (p) 0.,0. inflector = 0.98 play/'20200330_171315  20200330_171321  20200330_171326  20200330_171329' at QUADM10 (near tracker 18) CBO ptp -3:18 width ptp 6:17
   			   (r) 0.,-0.001 inflector = 0.98 play/'20200331_154344  20200331_154354  20200331_154402  20200331_154407'     at QUADM10 (near tracker 18) CBO ptp -5:19 width ptp 6:17

March 26, 2020   generalize <compile_all_time_dep.f90> so that the bin width can be changed. There are two inputs from the command line, location - QUADM1, and desired width 149.2e-9
                            With 149.2 ns bin, can compare CBO amplitude and width and equilibrium radius to measurements. Both amplitude and width are a bit too small. Increase emittance and injection angle.
			    and run test job in play/20200326_102040
			    Further generalize compile_all_time_dep.f90 so that a specific subset of directories can be input at the command line.
			    Find that play/20200326_102040 now has the proper CBO amplitude but the width is not affected. Maybe I am scraping too aggressively.

March 25, 2020   /energy_vs_time_vs_turn/ config_002 and config_003 all_Energy_vs_time_0.dat forward to Josh and Tyler.
                            Need to write some code to automate the compilation.
			    Rewrite <energy_vs_time.f90> to search through all of the subdirectories, look for phase_space files  END028_phase_space.dat, and compile a local Energy_vs_time_0.dat file. Then cat
			    together in <all_energy_vs_time_0.dat>

March 24, 2020 - /efield/pitch_bad_resistors/config_br_18kv/  same as config_ref/20200323_114801 - submit jobs

/efield/pitch_bad_resistors/config_gr_18kv/  same as config_ref/20200323_183557 - submit jobs

                             energy_vs_time_vs_turn. Try again. bad g2.sh script. config_003, use cat.dat to combine


March 23, 2020 - in /config_ref there is a bug when writing End of tracking phse space. Sometimes. ? I started a db version to see if I get a hint.  20200323_085907
                            Add more markers (12) to lattice and modify compute_moments_vs_time_calo.f90. Modify lattice in config_ref 20200323_114801

                             20200323_114801 - intesting. 12 markers. plot_vert_one_dir.pdf   No muons lost after 30us. More statistics?
			     Should do the same without bad resistors. 20200323_183557 
__________________________________________________________________________________________________________________________
March 22, 2020 - lost muons, vertical width, gm22/efield_pitch_bad_resistors/config_ref/, plot_lost_muons.pdf, plot_vertical_width.pdf (run compile_all_time_dep).
                            Will generalize 'compile_all_time_dep' so that 'Time_Dep_Moments_at_QUADM#' are compiled
			    Removing what seems to be about efield and pitch calc from this version <compile_all_time_dep.f90> but for safety cp compile_all_time_dep.f90 to compile_all_time_dep.f90_save
			    Works fine like this ./compile_all_time_dep <location>  where <location> is QUADM1, QUADM2,..., QUADM8, or END. Writes to EndTime_location.dat

                            harp/run_2-22-dp - more statistic and still width does notmatch measurement ?

                             gm22/mytest/energy_vs_time_vs_turn/config_003 - kicker time + 100ns

                           

March 21, 2020 - gm22/mytest/energy_vs_time_vs_turn/config_002 - compiled into all_Energy_vs_time_0.dat and ready to go  kick is 100ns early
                            gm22/mytest/efield_pitch_bad_resistors/config_ref - submit many jobs to generate lost muon statistics. (lost muons are compiled with compile_Time_Dep

March 21, 2020 - gm22/mytest/energy_vs_time_vs_turn/config_002 - compiled into all_Energy_vs_time_0.dat and ready to go  kick is 100ns early
                            gm22/mytest/efield_pitch_bad_resistors/config_ref - submit many jobs to generate lost muon statistics. (lost muons are compiled with compile_Time_Dep
                            gm22/mytest/harp/run_2-22-dp  jobs on lnx6186 to increase statistics
			    
March 20, 2020 - gm22/mytest/energy_vs_time_vs_turn/config_001 - complete, nominal
                                                                                        /config_002 -  kicker time - 100ns

                             gm22/mytest/efield_pitch_bad_resistors/config_ref  -  for a look at lost muons and vertical distribution with bad resistors.
			     Having fixed <number_turns> problem, do a trial run to make sure data is written at all of the calo markers 7:38. Fixed 9:00
			     Trail run with nmuons = 10000

                             
                              Another bug with writing data for calo markers. There was no final call to write in tracking_master. This must have gotten lost when I was confused about versions.
			      Checks out 9:38. When other grid jobs are complete will launch.
__________________________________________________________________________________
March 19, 2020 - A version of compile_Time_Dep.f90 called compile_all_time_dep.f90 claims to use a 149ns bin (rather than the 10ns standard) but this requires that g2_tracking was run with 149ns bin.
                             Or that it be generalized to sum what it reads from Time_Dep_moments_at_END.dat into appropriate bin size. Needs to be done
       Create momentum time correlated distributions
                          - Meanwhile, to generate more correlation distributions for Josh. Find working directory /gm2/data2/dlr10/g-2/mytest/energy_vs_time_vs_turn. Data was originally in file all_Energy_vs_time.dat
                            The program/energy_vs_time.f90 creates Energy_vs_time_0.dat from files with END000 and END028
			    To write the phase space every n turns set the parameter in input.dat
			    <run_energy_vs_time.sh> runs energy_vs_time in each subdirectory
			    <plotting_scripts/energy_vs_time.gnu> to plot <Energy_vs_time_0.dat>
			    <cat.dat> constructed from ls -d 20*/energy_vs_time.dat to create all_Energy_vs_time_0.dat

                            Now that I remember how to do this. Create subdirectories to energy_vs_time_vs_turn with configs
			    001 - shift kickers 100ns earlier

                            /run_2-22-dp looks promising. Need more data.

                            <compute_moments_vs_time_calo.f90> keeps track of hits on planes at markers QUADM1.. if the lattice has these elements. For seeing how width varies around ring.
			    The number of turns is passed through <parameters_bmad.f90>. I had forgotten to set <number_turns> in tracking_master. Fixed
________________________________________________________________________________________________________________________________________________
March 18, 2020 - initialize <bin_width> in tracking_master.f90 so it gets to compute_moments_vs_time.f90. This was necessary when QUADM markers were added in track1_custom.f90 to keep track of
                            hits  between short and long quads. And that was for the circumferential dependence of beta from the bad resistors
____________________________________________________________________________________________________________
August 10., 2019 - In create_phase_space initialize lifetime (muons(i)%coord%r =1.e7) to very long
August 9, 2019
Add <write_phase_space_every_n_turns> parameter to input.dat. If n>0 then phase space is written every n turns to a file with the number of turns in the title. Default is zero.
July 18, 2019
 Add subroutine fit_to_ibms to optimize_incident.f90. To determine incident angle and offset and inflector field to match ibms 1,2,3
 The target ibms values are loaded into first 3 places of inflector_end_target and fourth > 10 flags program to do the right thing
July 5, 2019
 Create ibms_lattice. with superimpose with longitudinal positions from Brynn
 Edit track1_custom to include IBMS1, IBMS2, IBMS3

May 20, To create distribution at end of injection line
                 nmuons = 200000
                 create_new_distribution = T
	      ! muon_file = INJ_TO_RING_phase_space.dat
                 twiss_ref = 'end'
                 start_tracking_at_inflector_exit =  F
		 initial_offsets =  -2.9343E-02  0. 0. 1.6292E-02 0. 0. !Inf = -2mrad, 0mm, -2mrad
	         write_phase_space_file = T
	      To read distribution
	          nmuons = number available
	          create_distribution = F
		  muon_file = 'INJ_TO_RING_phase_space.dat'
		  twiss_ref = 'use_as_is'
  	          start_tracking_at_inflector_exit = T                                                                                  
		  initial_offsets = 0. 0. 0. 0. 0. 0.
		  write_phase_space = F
		  
May 19,  to create distribution at end of injection line to then read with start_tracking_at_inflector, use MARK_INFLECTOR_DS_phase_space.dat (before patch that changes coordinate system). Set 'twiss_ref' = 'use_as_is' so that create_phase_space does not
                try to match beta. and do not reset timing distribution. Add if(twiss_ref /= use_as_is) to call generate_long_time_dist
May 17, tracking_master.f90 - set muons%coord%state = lost$ at start of tracking if lifetime is less than BetaCrossE_start_time.
May 16. Declare ele_init as pointer rather than normal structure in track1_preprocess so that it does not cause memory leak.
May 13. Modify set_dipole_params (in set quad_params.f90) to set radial field
              Add ele_start structure to bmad_parameters and set equal to ele after quad grids are determined in set_quad_param. Refer to ele_start when scaleing for scraping in track1_preprocess
May 7, Modify BetaCrossE starting time. The integrals are initiated internal to track_all_int_efield if %t > start time. write_phase_space modified to write only muons with %t> start_time.
              Add BetaCrossE_start_time to calling sequence for track_all_int_efield, and write_phase_space. Update muon_interface.
May1, create g-2/py and add Josh's script to create input and quad misalignments
May 1, 2019 - tracking_master.f90 - Add BetaCrossE_start_time input variable to start integration at start of data taking.
April 5, 2019 - tracking_master.f90 - In interpolating to muon decay point, check if time between bounding points is <0
April 4, 2019 - track1_preprocess.f90 - quad plates are grids 3-6 (not 2-5), this since. grid(1) is main B-field. grid(2) is radial B field
March 13, 2019 - track1_preprocess and track1_postprocess are modified to change vec(6) at entrance and exit to quad by voltage change.
March 9, 2019 - correct Beta Cross B in track_all_int_efield.f90 to |B| - |beta X B|
March 9, 2019 - add option to initialize offset with respect to closed orbit - logical/initial_offset_from_co in tracking_master.f90
March 8, 2018 - add option to correct acceleration in electrostatic quads by restoring vec(6) after tracking through element. See track_all_int_efield.f90 (If standard track_all is used this will not be operational - logical/no_energy_change
May 17, 2014 - Notes about tracking programs 
Main = tracking_master
All subroutine are in code/ directory
Need to figure out how to rebuild finalfocus/ and magneticfield/ after having put all subroutines into code/
tracking_master now propagates through backleg and inflector
Inflector apertures at each end are defined in lattice file for rectangular aperture.
 The "D" shape of the aperture is accessed in TRACK1_CUSTOM - for these elements (check TRACK1_CUSTOM to see whats incorporated)
 Also scattering in coil ends and cryo window is from TRACK1_CUSTOM
 Scattering is no longer controlled in input.dat. It can be turned off by removing the marker elements from the lattice file or
  editing TRACK1_CUSTOM
   MARK_CRYO_US
   MARK_INFLECTOR_US
   MARK_INFLECTOR_DS

 If in the lattice file 
     inj: line = (inject, inj_to_ring, ring_br) then particles are tracked through the backleg
     inj: line= (injinf, inj_to_inrg, ring_br) then particles are tracked using taylor maps
 
In both cases, the distribution emittance and twiss parameters is defined at the midpoint of the inflector.
  The distribution is propagated to the end of the inflector and then back to the opening of the hole in the iron.
  Note that the taylor maps are not precisely symplectic so the inverse is approximate.

If the number of muons is one 
     then the trajectory through the backleg and fringe and inflector is written to unit 71
     and the twiss parameters are computed assuming the initial values in the lattice file and written to unit 72.

The beam parameters computed from the distribution after propagating through injection line to end of inflector is
written to EndInfAfterScatter.dat

August 11, 2014
- The subroutine optimize_twiss finds the twiss parameters at the start of the injection line (30 cm upstream of iron) that give the specified (in the input file) twiss parameters at the end of element INFA in the inflector.

August 12, 2014
 - The routine get_branch_inverse_matrix inverts the transfer matrix through the injection line. It had been using the full line, from 30cm upstream of iron to end of inflector. Set the endpoint in this routine to be at element 'INFA'. 

August 14, 2014
Modify tracking_master to write phase space for each element in the injection line. Files are named ele%name//"phase_space.dat"
Plot using plotting_scripts/hist_any_file.gnu for example like so   
  gnuplot -e "filename='CRYO_USphase_space.dat'" ../plotting_scripts/hist_any_file.gnu

Add ability to use matrices for propagation through injection channel. The flag in the input file is inj_matrix_tracking. 
Definitely more particles make it through. Remember that the map for the fringe field cuts off at 6mm, and 25mm. 
The code assumes that beyond the boundaries of the map the field is uniform. But of course this gets the focusing effect wrong. 
Of course the transfer matrices won't be right for the 36mm aperture inflector since the reference trajectory will go beyond the 6mm boundary. 

August 15, 2014
The field map for the fringe field cuts off at +6mm in x with respect to the center line
and +-25mm in y.
Beyond the map we assume B has the value at the boundary. This means that for the
nominal 9mm inflector that which the reference orbit is all within the bounds of the map,
that will not be true for all of the particles in the distribution. 
1. Perhaps a reasonable approximation
is to use the matrices computed with respect to the reference to propagate the particle distribution.
2. But for the 18mm inflector even the reference orbit is outside the bounds of the map. Are the
matrices associated with this reference valid? If not then using matricies to propagate phase space in this
case is not sensible. Let's check it out. Compare propagation of beta for 18mm inflector and 9mm.
The answer to this question is that the propagation of the twiss functions is very different using
these approximations for the field map. It therefore is not sensible to use the related matrices to propagate phase space.
In order to calculate with the larger inflector we need a better map.

Try to figure out how to read HeHe's map.

Meanwhile, update repository. Check out on linux. Repeat calcs in injection_line/ and they look OK.
Next step to update g-2

Sanity check.
  With a single muon, fort.71 is trajectory through injection channel, and fort.72 is the beta. 

August 20, 2014
Add comments to "create_phase_space"
Check that random distribution of muons gives capture efficiency consistent with VD...
Note that the emittances in the input file are for 1 sigma and the 95% is 2 sigma (or 4 times the emittance)

August 21, 2014
Add lattice name to input.dat
Add comments to subroutine collect_times

2014_0904
NSF: Adding Wuzheng's larger B-field map for the ring/backleg/hole.  The first 3 lines of the file describe 
the number of gridpoints in the {xyz}-directions, the number of field components, and the arrangement of the 
data in the rest of the file.  The spatial extent of the map can be read from the first/last data lines after
the header: 

  711 cm  <  x  <  731 cm
    0 cm  <  y  <    3 cm
 -430 cm  <  z  <   10 cm

The B-field unit is again Gauss, as it was with the smaller map.  Wuzheng did not include Hy(Oe) in the 
larger map, which helps reduce file size, but makes it more difficult to tell when muons are in the backleg
steel (Hy<By).  

September 6, 2014
Have rearranged reading field maps for fringe and inflector to generalize for other maps, like Wuzeng's larger map. In particular the 2D map that goes all the way
back to the iron. It just occurs to me that I will have to read three different maps to get the hole, fringe from 2D and inflector.
Meanwhile, there is some error in the mac version that effects when the kicker turns off. Tracking through inflector looks OK
but no turns. linux version works fine.

Note that the trajectory through the fringe, etc. every few cm in fort.71 will be the same as element by element in single_particle_by_element.dat
or track_backleg_inflector.dat as long as SCATTERING IS TURNED OFF.

check out Wuzeng larger map from repository.


September 7, 2014
FIeld names with maps  of the magnetic fields in the fringe and inflector are now read from the input.dat file.
There are 2 fringe maps. Both generated by Wuzeng. The larger map has more extensive boundaries. The regions
of overlap have the same fields. Everything works on linux but there is a funy bug on the mac where 
the kicker peak time is screwed up and the kicker is on during the second turn so everything exits.

Also notice looking at time distributions that the zero time is not the time when the particles enter the ring.
This should be fixed. Maybe by using a marker at the end of the injection line with custom_tracking, and custom_tracking sets time to zero.

The kicker timing error seems to have fixed itself. ?

October 7, 2014
Discovered that I had dropped one of the numbers in the twiss line of the input.dat file.
The result was that etayp was set to 0.7 (should have been the phase).
Rerun standard old-inf and find 4.6% capture. 
Start to rerun various optimizations

Also change lattice file for use with wide aperture inflector.
There had been 5cm horizontal aperture on kicker 1. Change to 10cm.
Some small effect.

November 3, 2014
- Trying to understand 
1. Nature of residual CBO for stored beam
2. Nature of residual beam size modulation of stored beam
 - Experiment 1- initial distribution has 50mm-mrad 95% emit, but no energy spread - modulation is very small
 - Experiment 2- initial distribution has 1% energy spread but 0.5mm-mrad emittanc - modulation is large
 - Tune dispersion but best is ~ 8mm. Tune eta', and no help
 - Perhaps the problem is the dispersive kick from the kickers? To test this hypothesis, try to reduce kick but changing 7.7cm 
displacement of branch 0 to branch 1 to 1cm. Sure enough, the modulation (with beam with large espread) is reduced to 1mm.
test:  Change dispersion in inflector from 8 to 2 and adjust kics to reduce CBO. Now the modulation is big. 
test:  Set dispersion back to 8. Sure enough modulation is now very small. This makes good sense. 
test:  Set offset back to 7.7cm and kicks back to nominal for wide inflector - And yes, back to 10mm.

Possibility that beam is running into edge of quad or kicker upstream and that is why the smaller kick works better.
  Rather than because dispersion is generated by kick. But then why does large emittance no energy spread work? 

__________________________________________________________
June 14, 2015
Preparing for CD 2/3 review
Plot sigma_x through injection line and into ring. Find that if betax=1.5 and alpax=0 at end
of inflector that entrance to inflector is limiting aperture. Use $ps/twiss_mismatch.gnu to plot.
(Input file, ring_twiss = 'open'). Add an extra flag to input file:
<use_lattice_twiss>: logical - if true use twiss parameters defined in lattice file to propagate through injection line.
so that it is possible to use twiss set in lattice file. This does not converge so well. Return
to varying betax and alphax at end of inflector through input file and find that if
  twiss     = 1.7642, 10.0, -0.7502, 0, 2.0, 0., 0., 0., 0.7, 0.7, 0., 0.,
 beam just fits through inflector with max of 44.6mm in ring. f=45/7.7 =>95% 
emit=34 mm-mrad - Note this is independent of the distribution. (f defined in plotting script)

Now it would be nice to see if these better optimized values give more muons.
Create new directory BetaTest
Copy input file and lattice file from ../KickTimeTest/127cm-20153028
Set optimized beta in input file - 348 stored ? seems low

----------------------------
I would like a fresh calculation of capture with old kicker vs new (including realistic pulse)
-create /KickTimeTest/821kick-20150614. Copy input from ../../BetaTest. Restore nominal twiss. 

and run as a check - ge 398. Looks reasonable and the 348 with the new betas really was low ???

- Meanwhile, I found that KickTimeTest/127cm_table_20150507/Kick1-3Scan/
has the appropriate run with the full pulse
- Back to  /KickTimeTest/821kick-20150614. Set input for 821 kicker circuit
- We get 217 stored with kickers at kicker_params%kicker_field      =   210.0e-4   210.0e-4  210.0e-4
- Now do scan
**************
Comment out line 175 in fields.f90 that writes to unit 344. This information gives kicker pulse but generates a very large file
**********
------------------------------------------------------
October 12, 2015
code/fields.f90
Edit calculation of quadrupole efield so that
 - between quad plates (0.05) and chamber wall (0.1) the efield is taken to be plate_voltage/(distance to wall)
 - beyond the vacuum chamber wall, quad field is set to zero. (This is important for electron tracking)
 - programs/efield_test.f90 calls fields.f90 and can compute fields. 
___________________________________________
December 23, 2015
Add bmad style electrostatic multipoles to lattice file bmad_es_multipoles.
Turn on/off bmad multipoles (vs straight expansion in em_field_custom) by setting field_calc = custom (or not) in 
definition of FULLRING.
Update set_quad_params to do the right thing with  bmad multipoles
The good thing about the bmad style is that the entrance and exit fringe effect is included
The bad thing is that there is no easy way to deal with muons (or positrons) near or outside the plates)

But maybe the correction to the fringe fixed the peculiar energy dependence of omega_a?
Try that out

____________________________________________________________
Attempt to reproduce tracker

1. (mb) play/'20200501_181949  20200501_181955'  statistics limited. vwidth slightly high. rwidth close after dip. CBOa bit low
2. 20200510_124845  20200510_124857  20200510_124904  20200510_124912 - py_init=1mrad - vwidth high, Everything else pretty close
3. '20200511_185443  20200511_185450  20200511_185527  20200511_185534'  vwidth very close. CBO too big
4. '20200511_130616  20200511_130624  20200511_130641  20200511_130647' vwidth and rwidth both close. CBO too big
5.  20200511_083129  20200511_083252  20200511_083300  20200511_083306' all close. CBO high peak agrees, low peak too neg.
6. '20200512_071716  20200512_071722  20200512_071726  20200512_07173'  vwidth high, rwidth close. CBO damps quicker
7. /'20200513_201758  20200513_201815  20200513_201817  20200513_201821'  vwidth slightly low, rwidth close. CBO big