[neutron-mc] Ntuples for McStas

Christopher Crawford chris2 at lns.mit.edu
Wed Nov 1 05:45:29 CET 2006


Dear McStas developers,

   First, thanks for an excellent software package.  We recently used  
McStas to do a detailed optimization of choppers for the Fundamental  
Neutron Physics Beamline (FNPB) Cold Guide at the SNS, and it worked  
very well.  It was easy to use and very extensible.

   Second, I would like to contribute a new component 'Ntuple', which  
produces ROOT ntuples of a McStas simulation, event by event.  An  
ntuple is an array of numbers with one row per event, and one column  
for each variable being booked, for instance, a neutron state  
variable at some point in the instrument.  Such raw data could be  
stored in any number of formats; we chose ROOT because of its  
efficient storage, a simple interactive histogram drawing command,  
and a powerful macro language (interpreted or compiled C++).  One can  
form arbitrary 1-d, 2-d, or 3-d histograms from the ntuple, and  
events can be cut or weighted by other parameters as the histogram is  
drawn.  Here are some possible uses:

	a)  Look at correlations in events, for example before and after an  
interaction.  Or plot the distribution of neutron losses along the  
instrument.

         b)  Investigate the variation of active components in real  
time after the simulation.  For example, one can use the coordinates  
(x,y,t) of a neutron as it crosses a chopper plane to simulate a  
chopper cut as you are booking histograms.  In this way the  
simulation can be replayed hundreds or thousands of times  
realistically during an optimization.  We also implemented both the  
transmission and polarization of a He3 spin filter, an RF spin  
flipper, and a liquid H2 target using similar cuts and weights  
('tx_pol_cuts.C').

   To use this component, you must install ROOT (http://root.cern.ch)  
on your Win32, MacOSX, Linux, or Unix platform.  I have included a  
couple of examples in the attached tgz file; a minimal example can be  
tested with the following files.  Unfortunately it cannot be compiled  
using 'mcrun'.  Instead, use the Makefile: "make Vanadium_ntuple".

     Vanadium_ntuple.instr		- minor modification from  
'vanadium_example.instr'
     Ntuple.comp  			- the new component
     ntuple.cc, h   			- supporting C++ files
     Makefile				- to handle linking C, C++

   As an more complicated example, I include our simulation of the  
FNPB Cold line, and associated ROOT macro files used to analyze the  
ntuple data and optimize the NPDGamma experiment.  These macros may  
or may not be legible.

     Polychromatic.instr   		- FNPB cold beamline
     Flag.comp				- minor modification of Arm.comp, propagates neutron
     SNS_*, sct*.dat			- SNS specific components
     tx_pol_cuts.C			- ROOT macro producing cut strings to simulate  
active components
     chop_width.C			- ROOT macro for plotting and tuning chopper  
opening and closing widths
     p2n_line.C				- ROOT macro to optimize NPDGamma FOM (choppers,  
RFSF)

   ROOT also has excellent facilities for 3-d drawing and histograms,  
but these are already addressed with the current McStas tools.  If  
you have any questions, I would be happy to answer them.

--Chris Crawford,  University of Tennessee

TA-53/MPF-1/D111 P-25 MS H846
LANL, Los Alamos, NM  87545
505-665-9804(o) 665-4121(f) 662-0639(h)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mcstas_ntp.tgz
Type: application/octet-stream
Size: 140293 bytes
Desc: not available
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20061031/97259bb9/attachment.obj>
-------------- next part --------------




More information about the mcstas-users mailing list