\section{Fast simulation}
\label{mc:hdfast}

A fast Monte Carlo package has been developed to understand the
performance of key aspects of the \hd\ detector systems.  This
package consists of a collection of modules, each serving some
particular function.  The modules consist of individual programs
and library routines which use common event input/output formats.
Figure~\ref{fig:mcflow} illustrates this modular structure.  
\begin{figure}[h!]\centering
\begin{tabular}{c}
\mbox{\epsfig{file=ch10_mcflow.eps,width=0.75\textwidth,height=0.75\textwidth}} 
\end{tabular}
\caption[Software overview]{\label{fig:mcflow}
An illustration giving an overview of the \hd\ Monte Carlo software
which emphsizes its modular nature.}
\end{figure}

First, a Monte Carlo four-vector generator is used to create 
phase--space distributed events.  Next is the detector simulation, 
\hdf, which is a fast and flexible simulation program based upon 
the MCFast package developed by the simulation group at Fermilab. 
The Monte Carlo output includes (but is not limited to) the following 
data objects:
\begin{itemize}
\item {generated event}
\item {detector hits}
\item {resolution modified (smeared) event}
\item {time-of-flight information}
\item {dE/dx information}
\item {threshold \v{C}erenkov information}
\item {particle trajectory information}
\end{itemize}

\hdf{} is a fast and flexible simulation program based 
upon the MCFast package developed by the simulation 
group at Fermilab\cite{mcfast}.
MCFast consists of a set of modularized Monte Carlo 
library routines. It is designed to perform parameterized 
tracking by assembling a covariance matrix for each track 
that takes into account  materials, efficiencies, and 
resolutions for all measurement planes, and  use this 
matrix to smear the track parameters randomly. The covariance matrix
is first diagonalized so as to properly account for effects due to 
correlations when parameters are smeared. In principle, 
the distribution of smeared tracks produced by this 
method would be similar to the distribution of real 
tracks that were measured by a real detector(with the 
same parameters) and analyzed with an idealized track 
fitting procedure\cite{mcfast}.

\hdf\ is controlled via a set of user routines which 
act as an interface to the MCFast package. They control 
the tracking and smearing of the four-vectors, in addition 
to the booking and filling of monitoring ntuples and histograms.  
The detector geometry is controlled by an ascii file which is 
read in during program execution. This allows the user to 
quickly create or modify the detector geometry without the 
need to recompile the executable. In addition,  
ROOT\cite{root} was used to develop an event display which 
reads in the ascii geometry file and displays a two-dimensional visualization 
(see Figure \ref{fig:lost_event}) of the detector configuration and 
event track projections. 

