DEFINE INSTRUMENT template_body_simple(Par1=1) DECLARE %{ double nbounces; %} INITIALIZE %{ nbounces = 0; %} TRACE COMPONENT origin = Progress_bar() AT (0, 0, 0) RELATIVE ABSOLUTE COMPONENT source_div = Source_div( xwidth=0.2, yheight=0.2, focus_aw=0.001, focus_ah=0.001, lambda0=10, dlambda=9.9, flux=1e14) AT (0, 0, 0) RELATIVE origin COMPONENT l_in = L_monitor( nL=100, filename="l_source.txt", xwidth=0.3, yheight=0.3, Lmin=0, Lmax=20, restore_neutron=1) AT (0, 0, 0.1) RELATIVE origin COMPONENT divergence_monitor = Divergence_monitor( nh=100, nv=100, filename="div.txt", xwidth=0.3, yheight=0.3, maxdiv_h=0.002, maxdiv_v=0.002, restore_neutron=1) AT (0, 0, 0.11) RELATIVE origin COMPONENT guide_gravity = Guide_gravity( w1=0.3, h1=0.3, l=0.3, nslit=50, d=0.00001, reflect="Rplus_Sapphire.rfl") AT (0, 0, 0.15) RELATIVE origin ROTATED (0, 1, 0) RELATIVE origin EXTEND %{ if(SCATTERED) nbounces += GVars.N_reflection[0]; %} COMPONENT l_out = L_monitor( nL=100, filename="l_after.txt", xwidth=1, yheight=1, Lmin=0, Lmax=20, restore_neutron=1) AT (0, 0, 0.31) RELATIVE PREVIOUS COMPONENT UserMonitor = Monitor_nD( user1 = nbounces, username1 = "Number of bounces", options = "auto user1") AT (0,0,1) RELATIVE PREVIOUS FINALLY %{ %} END