\documentclass{chowto}

\title{Run analysis code in your directory}
\howtotype{expert}
\category{general}
\experiment{HKS}
%\maintainer{} % Optional
\author{T. Miyoshi}
\date{May 22 , 2004}

\begin{document}

\begin{abstract}
This document discribes how to run analysis code in your directory.

\end{abstract}

\section{Preparation}

First of all, set evironment variables in your .cshrc or login file:

\begin{verbatim}
> setenv CVSROOT /group/hks/e01011soft
\end{verbatim}

If you can not see work or group directory from your pc, then,

\begin{verbatim}
> setenv CVSROOT <yourname>@cvs.jlab.org:/group/hks/e01011soft
\end{verbatim}

If required, set one more thing,

\begin{verbatim}
> setenv CVS_RSH ssh
\end{verbatim}

Make your analysis directory. For example, assume the name is 
$ana$. Go to $ana$ directory. Then,

\begin{verbatim}
> cvs checkout e01011src
> cvs checkout e01011-replay
\end{verbatim}

Then, source code directory and replay directory is created.

Go to e01011src directory, edit Makefile.in to change
$OFFLINE$ in the 1st line. If your code is in
/work/hallc/hks/$<$yourname$>$/ana/e01011src, then
change it to 

\begin{verbatim}
OFFLINE=/work/hallc/hks/<yourname>/ana/e01011src
\end{verbatim}

Then, go to your e01011-replay directory.
Go to SRC, change 1st line $OFFLINE$ in Makefile 
to the same as above.

\section{Run replay}

When you start today's work everyday, first execute in your
e01011-replay directory,

\begin{verbatim}
> cvs update
\end{verbatim}

to prevent parameter mismatching. Any parameters may be chenged 
while you are in your dream.

Go to e01011-replay/SRC directory. then

\begin{verbatim}
> make
\end{verbatim}

to compile updated program. After the compilation is succeeded,
go back to e01011-replay directory. Then, edit REPLAY.PARM.

Make sure parameters, especially, see if raw data path is correct:
\begin{verbatim}
g_data_source_filename= /????/????_%d.log.0
\end{verbatim}

(Note that run number is filled in \%d when running the code) 

hbook or ntuple is on/off:

; means off, no ';' means on,

\begin{verbatim}
  g_alias_filename    = 'paw/paw%d.kumac'  
  g_histout_filename  = 'paw/%d.hbook'
  coin_ntuple        = 'paw/coin%d.rzdat'
\end{verbatim}

Do not turn on all the ntuple. or ntuple may not be filled correctly
after memory is overflow-ed. The goel is to accumulate coinXXXXX.rzdat.
Before all parameter is settled, we may need to check detector by detector,
in this case we may use some paticular ntuples.

To run replay,

\begin{verbatim}
  ./replay_script <run number>
\end{verbatim}

The $replay_-script$ is just a shell script you can see it
by 'more' or 'less' command. Executable file is in EXE/engine$_-$replay
which is created after make. actually, the options of replay are

\begin{verbatim}
grun=<run number> 
gstart=<the number of events you skip>
gstop=<the number of events you replay>
g_config_filename=<config filename c.f. REPLAY.PARM.test,etc...>
\end{verbatim}

Example:

\begin{verbatim}
./replay_script 50000
\end{verbatim}

Run replay for run number = 50000 to the end.

\begin{verbatim}
./replay_script 50000 gstop=20000
\end{verbatim}

Run replay for run number = 50000 to the 1st 20000 events.

\begin{verbatim}
./replay_script 50000 gstart=10000 gstop=20000
\end{verbatim}

Run replay for run number = 50000 to 20000 events after skipping 
10000 events. Eventually it replays from the 10000th to the 30000th event.

\begin{verbatim}
./replay_script 50000 g_config_filename=REPLAY.PARM.test
\end{verbatim}

use your special config file REPLAY.PARM.test to this replay.

\section{Bugs}

If you have used e01011-replay directory,
new directory e01011-replay/SRC/LIB may not be updated correctly.
Please first do checkout in your ana directory,

\begin{verbatim}
cvs checkout e01011-replay
\end{verbatim}

\end{document}

% Revision history:
% $Log: e01011ana.tex,v $
% Revision 1.1.2.1  2005/05/23 14:19:52  saw
% Initial version
%
