--- /dev/null
+\section{Event Building}
+
+The four servers lxhadeb01, lxhadeb02, lxhadeb03, lxhadeb04 are the HADES Event Builders.
+
+The Event Builder (EB) is aimed to receive subevents from subsystems and to build a complete event out of them. EB consists of two parts: daq\_netmem (the receiving part) and daq\_evtbuild (the building part). A communication between daq\_netmem and daq\_evtbuild is done via a shared memory. Number of opened in a shared memory buffers (queues) is equal to a number of subsystems. A completed event can be written to different mass storage systems.
+
+The daq\_evtbuild and daq\_netmem can be configured in three ways:
+
+\begin{itemize}
+ \item take default arguments,
+ \item read part of arguments from eb\_p.tcl configuration file (\$DAQ\_SETUP should be set),
+ \item read arguments from a command line.
+\end{itemize}
+
+daq\_evetbuild must be executed before daq\_netmem (as daq\_evtbuild is the one who opens buffers in shared memory).
+
+\subsubsection{daq\_evtbuild options}
+daq\_evtbuild can be executed with the following options:
+
+\begin{description}
+\item [Main options] :
+\begin{description}
+\item [-m nrOfMsgs] Number of data streams.
+\item [-f slowCtrlFile ...]
+\item [-o outPath] Output path for writing data on the local hard disk.
+\item [-d null|tape|file|stdout] Type of data output.
+\item [--filesize max\_size] Maximum size of output file in MB.
+\item [-q queueSize] Size of the queue (shared memory segments) in MBytes.
+\item [-Q queueNr:queueSize] Set different queue sizes in MB for different queue numbers,
+ example: -Q 2:4 -Q 4:8 -Q 5:12
+\item [-r runNumber]
+\item [-S|--shmname shmem\_name] Extension of shared memory segment name.
+\item [-a (agent)] [-p priority]
+\item [-I trigType] Trigger type can be set by Event Builder.
+\item [-T evtId:wordNr:bitMask] EB will read trigger type from the first data stream
+ (evtId is not used now) from wordNr according to bitMask,
+ default: 1:2:f00000
+\item [--online] Switch on online service (default off).
+\item [--lustre path\_to\_lustre] Output path for writing data on the Lustre cluster (if mounted).
+\item [--orapath path] Path to eb\_runinfo2ora.txt for writing data to Oracle.
+\item [--ignore] Ignore trigger mismatch conditions.
+\item [--maxtrigmissmatch number] Maximum number of triggers allowed for missmatch.
+\item [--multidisk] Write data to a disk number provided by daq\_disks via shared memory.
+\end{description}
+\item [Options for debugging] :
+\begin{description}
+\item [-v debug|info|notice|warning|err|alert|crit|emerg]
+\item [--debug trignr] Print trigger numbers of discarded events.
+\item [--debug errbit] Print error bits from the discarded events.
+\item [--debug word] Print debug words from the discarded events.
+\end{description}
+\item [Options for second data stream with a fraction of the data] :
+\begin{description}
+\item [--resnumevents evt\_num] Maximum number of events in a resfile
+\item [--respath path] Path for the res directory.
+\item [--secsizelimit max\_size] Maximum size of second directory with the mirrored data [in MB].
+\item [--ressizelimit max\_file\_num] Maximum number of files in res dir
+\item [--write\_data path] Path to the directory with mirrored data.
+\item [--resdownscale downscale\_factor] downscale factor for the res events
+\end{description}
+\item [Options for writing to tape via RFIO] :
+\begin{description}
+\item [--rfio pathToTapeArchive] Example: --rfio rfiodaq:gstore:/hadaqtest/test002
+\item [--rfiolustre path] Example: --rfiolustre /lustre/hades/daq
+\item [--rfio\_pcoption option] Internal RFIO options (do not set anything if not sure).
+\item [--rfio\_icopymode mode] 0 : Standard RFIO, ignore following arguments,
+ 1 : copy the data to Lustre path after the file is written
+ to a write cache (this is for the high data rates),
+ 2 : for lustre only.
+\item [--rfio\_icopyfrac frac] 0 : Write only to a tape,
+ i (>0) : copy each i-th file to lustre (pcCopyPath). If migration to
+ a tape fails, ignore iCopyFraction and copy each file to lustre.
+\item [--rfio\_imaxfile maxnum] 0 : No file number limit,
+ i (>0) : maximum number of files to be written to a directory.
+\item [--rfio\_ipathconv conv] 0 : default convention, 1 : HADES convention.
+\end{description}
+\item [Options for parallel EB] :
+\begin{description}
+\item [--epicsctrl] Enable synch and distribution of RUN Id by Epics IOCsfor parallel EBs.
+\item [--ebnum num] Number of the event builder.
+\end{description}
+\end{description}
+
+To support data writing to multiple disks the dedicated daq\_disk server runs on each Event Buidler server in the background.
+The other important script cleanup.pl is aimed to clean up disks when they get occupide up to 90\%.
+Both processes are executed in the background at boot time.
+
+\subsubsection{daq\_netmem options}
+daq\_netmem can be executed with the following options:
+
+\begin{description}
+\item [Main options] :
+\begin{description}
+\item [-m nrOfMsgs] Number of input data streams.
+\item [-i inPath] Input, wide format: -i UDP:0.0.0.0:portNr
+ short format: -i portNr
+\item [-p priority] Set priority.
+\item [-S shmem\_name] Extension of shared memory segment name.
+\item [-q queueSize] Size of the queue (shared memory segments) in MBytes.
+\item [-Q queueNr:queueSize] Set different queue sizes in MB for different queue numbers,
+ example: -Q 2:4 -Q 4:8 -Q 5:12
+\item [-d seconds] Maximum delay of incoming data in seconds.
+\end{description}
+\end{description}
+
+\subsubsection{Starting Event Builders}
+
+Communication (synchronization, RUN Id distribution and monitoring) between parallel Event Builders is based on the Input/Output Controller (IOC) processes running on each EB server.
+Parallel Event Builders can be started from lxhadesdaq by /home/hadaq/trbsoft/daq/evtbuild/start\_eb\_gbe.pl.
+The script reads several configuration files.
+
+\begin{description}
+\item[The most important config files are] :
+\begin{description}
+\item[trbsoft/daq/hub/register\_configgbe\_ip.db] port numbers for each EB where incoming data streams arrive.
+\item[trbsoft/daq/cts/register\_cts.db] number of EBs to be started.
+\item[trbsoft/daq/main/data\_sources.db] active data sources the EBs should listen to.
+\item[trbsoft/daq/evtbuild/eb.conf] detailed configuration of Event Builders.
+\end{description}
+\item[Script options] :
+\begin{description}
+ \item[-c|--conf <path/name>] : Path to the config file (default: ../evtbuild/eb.conf).
+ \item[-e|--eb <start|stop>] : Start or stop Event Builders (default: start).
+ \item[-i|--ioc <start|stop>] : Start or stop IOCs (default: start).
+ \item[-n|--nr <rangeOfEBs>] : Range of numbers of Event Bulders to be started.
+ \item[-v|--verb] : More verbouse.
+\end{description}
+\item[Execution examples] :
+\begin{description}
+\item[Start EBs] : start\_eb\_gbe.pl -e start
+\item[Stop EBs] : start\_eb\_gbe.pl -e stop
+\item[Start 6 EBs with the numbers 0,1,2,3,5,7] : start\_eb\_gbe.pl -e start -n 0-3 -n 5 -n 7
+\item[Start Epics IOCs] : start\_eb\_gbe.pl -i start
+\item[Stop Epics IOCs] : start\_eb\_gbe.pl -i stop
+\end{description}
+\end{description}
+
+\subsubsection{Monitoring Event Builders}
+
+As has been already said the monitoring of EBs is based on the IOC processes running on each EB server.
+
+Usually the monitoring is already running at vncserver lxhadesdaq:3.
+
+Before starting the monitoring one should set two env variables:
+\begin{itemize}
+ \item export EPICS\_CA\_ADDR\_LIST=192.168.101.255
+ \item export EPICS\_CA\_AUTO\_ADDR\_LIST=NO
+ \end{itemize}
+
+The monitoring can be started by executing:
+lxhadesdaq: /home/scs/Desktop/DAQ/EB\_Monitor.desktop
+
+\subsubsection{Monitoring Event Builder's Logs}
+
+To learn more details about the running Event Builders on can look at
+the output of the monitoring stript which scans the log files of all the
+EBs.
+\newline
+\newline
+Usually you can find the output of this script at vncserver lxhadesdaq:3.
+\newline
+\newline
+For example the log file of EB 1 running on the lxhadeb01 cab be found on lxhadesdaq
+/home/hadaq/oper/oper\_1/eb1\_log.txt.
+\newline
+\newline
+The script can be started by executing:
+lxhadesdaq: /home/hadaq/Desktop/DAQ/EBLog\_Watch.desktop
+
+\section{Storing data to Oracle database}
+
+\subsubsection{Time stamp and current info on boards}
+
+The DAQ startup script writes the ascii file with all the active boards in the system and the time stamp.
+The daq2ora\_client.pl script reads this ascii file on lxhadesdaq (/home/hadaq/\-oper/daq2ora/\-daq2ora\_2010-08-30\_12.49.50.txt) and stores the info in the Oracle database. The info consists of board unique Id, TRB-Net address, subEvent Id, TDC RC Mode, threshold version for RICH and MDC as well as MDC TDC mask version.
+
+\begin{description}
+\item[Script options] :
+\begin{description}
+ \item[-b|--base name] : A base of file name to read (default: daq2ora).
+ \item[-i|--indir name] : Directory with input files (default: /home/hadaq/oper/daq2ora).
+ \item[-d|--daemon] : Run as a daemon.
+ \item[-o|--oracle] : Do insert to Oracle data base.
+ \item[-p|--sport port] : Port for status server.
+ \item[-v|--verb] : More verbous.
+ \item[-f|--file file] : Given file for insertion to Oracle.
+\end{description}
+\item[More info] :
+\begin{description}
+ \item[Execute on lxhadesdaq] : /home/hadaq/\-trbsoft/daq/oracle/\-daq2ora\_client.pl -o -v -d \&
+ \item[More info can be found here] : http://hades-wiki.gsi.de/\-cgi-bin/\-view/\-DaqSlowControl/\-SoftTools\-\#daq2ora\_client\_pl\_daemon\_to\_inse
+\end{description}
+\end{description}
+
+\subsubsection{RUN Start/Stop info}
+
+The event builder writes the data at RUN start and RUN stop to the ascii file (for example /home/hadaq/\-oper/oper\_1/\-eb\_runinfo2ora\_1.txt is the file on lxhadesdaq writen by event builder 1 running on lxhadeb01. lxhadesdaq mounts /home/hadaq/oper/oper\_1/ from lxhadeb01). The runinfo2ora.pl script reads the files and writes the data in the Oracle database.
+\newline
+\newline
+The script can be executed:
+lxhadesdaq: /home/hadaq/oper/runinfo2ora.pl -f /home/hadaq/oper/oper\_1/eb\_runinfo2ora\_1.txt -f /home/hadaq/oper/oper\_1/eb\_runinfo2ora\_5.txt -f ...
\ No newline at end of file