Nuance - A general purpose neutrino physics simulation
(Documentation last updated June 28, 2001)

Overview of contents:
    1) Building the program
    2) Running the program
       A) Contained atmospheric neutrinos
       B) Upward-muons
       C) Accelerator beams
       D) Stellar collapse
       E) Nucleon decay
       F) Single-energy "test" mode
    3) Reaction codes


1) Building the program

The neutrino simulation itself is in the directory usmc/kinematics/nuance.
The latest release of Pythia (which has been merged with Jetset) is also
necessary to run the simulation, and can be found in usmc/kinematics/pythia61.
The Bartol muon propagation code (which accounts for radiative processes and
range straggling) is in usmc/kinematics/propmu.  The TAUOLA library, which
handles decays of polarized tau leptons, is in usmc/kinematics/tauola.
Imakefiles are provided for all four packages.  You must first build the four
libraries ("make install" in each directory) and then build the executable via
"make exec install.exec" in the usmc/kinematics/nuance directory).


2) Running the program

The program can be run in a variety of modes.  In general you must first run a
job to calculate the rates for all channels you are simulating, and then use the
output of that job to generate events.  The rate file (.fzc) can be reused to
generate many sets of data once it is produced.  

In addition to the flux files (which are in the same directory of the repository),
two card files are used for a given job.  One (nuance_defaults.cards) is a set of default
parameters which the user would normally not change (e.g. the size, geometry,
and composition of the detector, descriptions of all reactions, etc), and the
other (supplied by the user based on examples provided) contains steering input from the
user (which flux to use, what reactions, if any, to skip, how many years or events of data 
to generate, where to write the output, the random number seed, etc) .  Any
cards in the steering file override those in the default parameter file.  You must take
care that any default parameters changed when you calculate the rates are also changed
(identically!) when you generate events.

Sample steering cards files for the most common runs are provided; see the section
corresponding to your analysis.

Nuance now has a command-line interface to make life easier for the user.  Most or all
parameters which the user might want to change between runs can be set using flags on the
command line; thus it should not be necessary to edit the cards file often.  In addition,
the user steering cards file no longer must be named 'nuance.cards' - the user can specify
the name of the steering cards file on the command line.

The recommended syntax for running the program is:

> NUANCE [flags] <steering cards file>

Both the flags and the name of the steering cards file are optional.  Most flags correspond
to a particular card and override any related card given in the steering cards file or
nuance_defaults.cards.  The following cards are recognized:

  Files:
    -i <filename>
         FZ file to read rates from.
         Equivalent to RATI <filename>
    -c <filename>
         FZ file to read cross-sections from (for recalculating rates)
         Equivalent to CRSI <filename>
         (Note the preceding 2 flags are mutually exclusive)
    -o <filename>
         FZ file to write rates and cross-sections to for event generation
         Equivalent to RATO <filename>
    -h <filename>
         HBOOK file for cross-section histos and event Ntuple
         Equivalent to HIST <filename>
    -k <filename>
         Kinematic file for vector output
         Equivalent to TRAC <filename>
    -f <filename>
         Use <filename> for default parameters instead of nuance_defaults.cards
  Steering:
    -t <detector code>
         Detector volume to use as target.  The following are currently implemented:
               SKAL - full SK water volume
               SKID - SK inner detector
               SKOD - SK outer detector, insensitive region, and 25cm inside inner detector
               SKFV - SK 2m fiducial volume
               SK50 - SK up to 50cm outside black sheet
               1KFV - 1kton fiducial region (cylinder 250cm radius and length)
               IMB3 - full IMB water volume
         Equivalent to DETE <detector code>
    -r <integer>
         Specify seed for random numbers
         Equivalent to RAND <integer>
    -n <neutrino_code> [<neutrino_code> ...]
         Specify which neutrino flavors to consider
         Equivalent to NEUT <neutrino_code> [<neutrino_code> ...]
    -proc <process_code> [<process_code> ...]
         Specify exactly which processes to consider (default is all of them)
         Equivalent to PROC card
    -skip <process_code> [<process_code> ...]
         Exclude specific processes
         Equivalent to SKIP card
  Run length:
    -year <number>
         Number of years of data to generate
    -secs <number>
         Number of seconds of data to generate, or the fraction of the total luminosity
         to generate for accelerator beams
    -nevt <integer>
         Number of events to generate
         (Note the preceding 3 cards are mutually exclusive)
  Help:
   -help, -H
         Print usage syntax and help on valid flags
    -d <integer>
         Equivalent to DUMP <integer>


  A)  Atmospheric Neutrino Contained Events

Currently the Bartol fluxes (phi-dependent low-energy and phi-independent
high-energy) and Honda fluxes are supported.  Generating data is a two-step
process: first rates are calculated, and then events can be generated.  Since
the rate calculation takes about a day and need only be done once, I
normally do it in a separate job from event generation, but it is possible
to calculate the rates and then generate the data in a single job if you want
to do so.

    i) Calculating event rates

Sample steering cards files are provided for calculating rates with the Bartol
and Honda fluxes:

bartol_water_rate.cards
honda_water_rate.cards

The result of this step is an FZ file containing d(Rate)/d(log(E)) (as a
function of log(E)), cross-section (as a function of log(E)) and the total
integrated rate for each of the ~200 channels simulated.  See the cards
file for additional documentation.

The user may change the default convergence criterion for all integrals using
the ROMB card.  This card takes one parameter and specifies how small the
relative error on an integral must be to stop the numerical integration.  The
default value is 1.e-3.


    ii) Generating events

Sample steering cards files are provided for generating events with the Bartol
and Honda fluxes:

bartol_water_evts.cards
honda_water_evts.cards

The events generated can be written to a text file and/or an HBOOK Ntuple.  The
text file output (specified with the TRAC card) can be read by APDETSIM using the
card VECT-FILE 2 in your APDETSIM steering cards file.  The Ntuple contains quite
a bit of information about the events, and is very useful for checking the results
without detector simulation and reconstruction.

    iii) Recalculating Rates

The above scheme (calculating rates and then generating events) allows the
fastest generation of events, but is expensive if one wants to change the
flux (since the rates would have to be recalculated)  Obviously the
cross-section calculation rather than integration of cross-section * flux takes
most of the time, so there is an option to allow recalculation of event rates
without recalculating the cross-section. Since this is a less frequent need, no
example cards file is provided, but the only change necessary when generating events
is to replace the RATI card with a CRSI card, specifying the FZ file you want to
take the cross-sections from.  Unfortunately, you cannot change the detector
geometry without re-running the rate calculation; this undesirable feature will
be improved in the future.


    iv)  Oscillating the neutrino flux

3-component neutrino oscillations in matter are now supported, via the NOSC
card.  Use the NOSC card with three mixing angles (th12, th13, th23) in degrees,
two mass-squared differences (m2^2-m1^2 and m3^2-m2^2), a CP phase in degrees,
and the height in km of the source and detector.  You must also specify
that you want all three neutrino species to be processed (default is to ignore
tau-type) with a card:

*DO NEUT
   12 -12 14 -14 16 -16

Specifying zero values for either mass-squared difference, or equal values
(which makes the third difference zero) will crash the program.  It is possible
to do 2-component oscillations by setting two of the three mixing angles to zero and
setting one d(m^2) to a very small value.  For instance, to do numu->nutau, with
maximal mixing and delta(m^2) = 2.2e-3, use the card:

*DO NOSC
   0. 0. 45.  1.e-10  2.2e-3  0.  15. -1.

Once you have generated an FZ file with tau neutrino cross-sections, it should
be possible to redo event generation with different oscillation parameters,
using the REDO option described above.

It is also possible to mix the neutrino fluxes in an energy/angle independent
way (for instance, generate nu_taus according to the nu_mu flux - intending to
apply oscillation by weighting the events after they are generated).  For this,
use an NMIX card, explicitly giving the flux mixing matrix.  If 9 entries are
given, the same parameters are used for neutrinos and anti-neutrinos.  If 18
entries are given, the first 9 are for neutrinos and the second 9 are for 
anti-neutrinos.  The order of parameters is 

*DO NMIX
     e->e   mu->e   tau->e
     e->mu  mu->mu  tau->mu
     e->tau mu->tau tau->tau (idem for anti-neutrinos)

So to generate nu_tau events using the nu_mu spectrum, you would use:

*DO NMIX
    0.  0.  0.
    0.  0.  0.
    0.  1.  0.

(in this case you should also include a card

*DO NEUT
  16 -16

to avoid calculating cross-sections for the non-tau neutrinos).

Use the card:

*DO FLHI

to write Ntuples of the fluxes used (after oscillation or mixing, if any) to
the histogram file.


  B) Upward-going Muons

Neutrino-induced muons from the rock surrounding the detector ("upward-going
muons") can be generated.  For the user, the procedure is identical to that
for generating atmospheric neutrino contained events (see above).

In particular, there are again two steps.  First you must generate an FZ file
of event rates (a one-time calculation), and then you can generate as many
events as you wish using this file.  Example cards are provided:

bartol_upmu_rate.cards and bartol_upmu_evts.cards
honda_upmu_rate.cards and honda_upmu_evts.cards

An FZ file containing contained events rates and cross-sections cannot be used
for upward-going muons.  This is because the event rates for upward muons
are weighted differently than contained events for propagation in rock.
The simulation uses the same neutrino interaction model as for contained
events, but all target nucleons are considered to be unbound, and coherent/diffractive
reactions are not simulated (because the nuclear composition of the rock is unknown).
Muons are propagated to the detector using a library provided by
Todor Stanev from Bartol (see Lipari and Stanev, PRD 44, 3543 (1991) for
a description of the model).  99% of the processing time is unfortunately
spent in this library, slowing down the program considerably compared to the
contained-event case.  Several hours are required to create the rate file,
and event generation is considerably slower than for contained events.

Upward- and downward-going neutrino-induced muons are produced, and there is
presently no correction for the finite depth of the detector or the curvature
of the Earth (i.e. the detector is assumed to be surrounded by an infinite
layer of rock in all directions, which is not actually the case).  The same
default structure functions (BEBC) are used as for contained events.  You
can change this to anything in PDFLIB by adding a PDFL card to your cards
file (see nuance_defaults.cards for an example).  Cross-sections include
propagator effects.  You can specify the minimum muon energy you are interested
in as well as angular cuts to avoid generating uninteresting events - see
the comments on the UPMU card in the example cards files.

Neutrino oscillation may be applied to upward-going muons using the same
procedure as for contained events.

Upmu simulation typically involves generating not only "rock" events, but also
events in the outer detector and perhaps some outer region of the inner detector.
The program can generate events in a hollow shell (for example, only in the OD).
See the example cards files:

bartol_od_rate.cards
bartol_od_evts.cards


  C) Accelerator Beams

The program can generate events from any beam based on an HBOOK file which
contains a histogram of the beam.  Several histograms in the same file (for
instance containing different neutrino flavors, or at different horn currents)
can be added together in the same job.  Both contained ("water") and entering
("upmu") events can be generated.  The procedure is the standard one, namely
running a job to calculate rates, and then using the output of that job in
a second job which generates events.  A variety of scale factors are available
to account for the luminosity of the beam and the distance from the source.

See the example cards files (and particular the BEAM cards therein):

k2k_water_rate.cards and k2k_water_evts.cards (for water events)
k2k_upmu_rate.cards and k2k_upmu_evts.cards (for entering events)

Fluxes for the K2K beam are provided in text format in the files cho_cern_xxx_yy.dat.
xxx is the horn current in kAmps, and yy is either "fd" (front detector) or "sk".
Because HBOOK files cannot be committed to the repository, a .kumac file (flux.kumac)
is provided to convert these text files into an HBOOK file which can be read by
the program.  Use the PAW command:

PAW> exec flux k2kflux.hbook

(where k2kflux.hbook is the histogram file created) to do the conversion. The resulting
file contains 32 histograms: 4 neutrino flavors * 4 horn currents * 2 locations.  The
histogram number is encoded as follows:

10000 * location (=10000 for KEK, 20000 for SK) +
 1000 * current (=1750, 2000, 2250, or 2500) +
 flavor (=1 for nue, =2 for anue, =3 for numu, =4 for anumu)

Thus the numu flux for horn current 225kA at SK is in histogram 22253, while the
nue flux at KEK for horn current 175kA is in histogram 11751.

The example cards files multiple the numu flux at 4 horn currents by the integrated
luminosity for each current for the March-June 1999 run.  Thus, the flux is the
average flux over the entire run, properly weighted for different horn currents.  The
SECS card specifies what multiple of the March-June 1999 luminosity you want to
generate.  So specifying 20.0 gives you 20 times the integrated luminosity for that
running period.

Neutrino oscillation for the KEK beam is not yet supported by the program.


  D) Stellar Collapse

Nuance will also generate data (in the same two formats listed above)
for stellar collapse.  The model of Spergel, et al (Science, ????) is used to
model the time dependence (cooling) of the neutron star remnant.

Stellar collapse is an exception to the usual two-step procedure (calculate rates
then generate events): there is no need to pre-calculate event rates to generate
stellar collapse data (and it would be impossible anyway since the rates are
time-dependent).  Instead the program calculates event rates for the small number
of possible reactions 'on the fly' as the flux changes with time.  Note that although
a time is generated for each event (and recorded in both the Ntuple and the kinematics
file), there is presently no facility available to use the event time in the detector
simulation (to my knowledge at least).

An example cards file for supernovae is provided in:

nova_water_evts.cards 

See the comments for the NOVA card in the example file for the parameterization of the
neutrino flux.


  E) Nucleon Decay

Bound and free nucleon decays can be generated.  The user may specify any
decay mode (up to five daughter particles).  The Fermi kinematics are inherited
from the neutrino simulation and are at present simple: bound nucleons get
a Fermi momentum selected from a step-function distribution (the Fermi surface
momentum can be adjusted by the user).  The nucleon energy is that of a free
particle minus the binding energy (which the user can also change).

Nucleon decay also requires no preparatory step - simply use the example
cards file provided (pdk_water_evts.cards) to start generating events.


  F) "Test" Mode

Test mode allows the user to study a monoenergetic neutrino beam using a rate file 
previously calculated via some other mode.  You can specify a single reaction to generate,
or take a mixture of reactions at the specified energy.  The energy, direction, and flavor
of the neutrino test beam are specified on the TEST card.  This mode can be useful for, eg, studying
all reactions which lead to a given final state at a fixed energy.

A rate file previously calculated by some other job must be given as input.  See the example
cards file provided (test_water_evts.cards) for more information.

3) Interaction codes

The program does not use the numerical reaction codes internally.  Hence they are arbitrary and
can be changed if desired, although obviously this will create confusion if conventions of
different users are not the same.

Each possible reaction is described in nuance_defaults.cards, with a TZ card "xxCH" for each channel,
where xx = QE,RS,DI,CO,DF,EL for quasi-elastic, resonant, deep-inelastic, coherent, diffractive and
elastic (electron target).  The following are the more important reaction codes:


1:      charged-current, Cabibbo-allowed quasi-elastic scattering from nucleons
2:      neutral-current (quasi-)elastic scattering from nucleons
3 - 16  Resonant single pion production:
	3-5 : charged current neutrino single pi
        6-9 : neutral current neutrino single pi
       10-12: charged current anti-neutrino single pi
       13-16: neutral current anti-neutrino single pi
17-90  Other resonant processes involving more than a single pi; these have very small rates
91     charged current deep-inelastic scattering (neutrino or anti-neutrino)
92     neutral current deep-inelastic scattering (neutrino or anti-neutrino)
93-94  not used
95     charged-current, cabibbo-suppressed quasi-elastic hyperon-production from nucleons (small)
96     neutral-current coherent or diffractive pi0 production
97     charged-current coherent or diffractive charged pi production
98     neutrino + electron elastic scattering
99     neutrino + electron inverse muon decay

