Project

General

Profile

Running DAQ Interface » History » Version 159

Version 158 (John Freeman, 03/30/2015 03:23 PM) → Version 159/223 (John Freeman, 03/30/2015 03:25 PM)

{{toc}}

!DAQ_communication_diagram4.png!

h1. Getting help

If, after reading this document (in particular, the "Troubleshooting and FAQ" section) you run into issues, or have questions, please contact:
* DAQInterface
** John Freeman - jcfree@fnal.gov
* RunControl
** Erik Blaufuss - blaufuss@icecube.umd.edu
* Configuration Manager
** Jon Paley - jpaley@anl.gov
* TDU XML-RPC server
** Tom Dealtry - thomas.dealtry@physics.ox.ac.uk

h1. Logbook

Please document all changes, software updates, and operational activities to the ELog:

http://dbweb3.fnal.gov:8080/ECL/lbne_35t

h1. Brief preliminaries

This guide assumes you have access to the lbnedaq account on the LBNE 35 ton gateway node, lbne35t-gateway01.fnal.gov . It also assumes you have a rudimentary knowledge of how to navigate a bash environment in Linux (how to change directories, log onto different machines, perform time-ordered listings of files, edit a file using emacs or vi, etc.).

The installed code is located at lbne35t-gateway01.fnal.gov:/data/lbnedaq/daqarea/lbnerc. If you need access to the lbnedaq lbne35t-gateway01.fnal.gov account, please contact one of the people listed above under "Getting Help". Once you have access, to get started, login and first setup the environment:

<pre>
ssh lbnedaq@lbne35t-gateway01.fnal.gov
cd /data/lbnedaq/daqarea
source fireup
</pre>

This will take you into the /data/lbnedaq/daqarea/lbnerc directory, out of which the DAQ is controlled. For the remainder of this wiki, the assumption is that you've already setup the environment using the above commands.

Finally, when you see an ellipse ("…") in example output, that is to be interpreted as a placeholder for output which is considered irrelevant to the point being explained.

h1. Killing, launching, and getting the status of the DAQ applications

h2. Getting the status

The DAQ application suite consists of RunControl, the configuration manager, DAQInterface (the component which intermediates between RunControl, the configuration manager, and the artdaq processes) and the XML-RPC server for the TDU (the program which allows a sync pulse to be sent to the hardware at the start of DAQ running). The following points about these programs should be observed:
** These applications all need to be running in order for the DAQ to work
** DAQInterface needs to be launched _after_ RunControl, and unlike the other applications, if a DAQInterface process is already found to be running on login, it shouldn't be used, but rather, killed and restarted (unless someone is actively using the DAQ already, of course; a good way to check this is to see when the last time a logfile in /data/lbnedaq/daqlogs/pmt was modified via "ls -ltr /data/lbnedaq/daqlogs/pmt").
** The actual names of the processes are "lbnecontrol" (RunControl), "daqinterface" (DAQInterface), "CfgMgrApp" (the configuration manager) and "tdu" (the TDU XML-RPC server)

In order to determine which DAQ applications are already active, two approaches can be taken, depending on whether or not RunControl is itself active. If it isn't, you'll need to enter the following bash shell command:

<pre>
ps aux | grep -v grep | grep -v emacs | egrep -e lbnecontrol -e daqinterface -e CfgMgrApp -e tdu
</pre>

This will essentially filter for the rows output by the "ps aux" command which correspond to the DAQ applications we're interested in. If RunControl IS alive (and this is something you can see via the above command), then you can use the following command:

<pre>
lbnecmd check
</pre>

You'll then see output similar to the following:
<pre>
lbnecontrol: Available
CfgMgr: **Not Found**
DAQInterface: Available
TDUControl: **Not Found**
...
</pre>

Here, you see that RunControl and DAQInterface already exist, but the configuration manager and the TDU's XML-RPC server do not. In this case, you would not only want to launch the configuration manager and the server, but you would also want to kill and relaunch DAQInterface (again, assuming no-one else was actively using it). How to kill and launch applications is described in the next two sections. Be aware that if you attempt "lbnecmd check" when RunControl is not yet available, you'll simply see "<code>check <code>check failed: '[Errno 111] Connection refused'. Is lbnecontrol running?</code>". running?</code>.

h2. Cleanup: killing RunControl, DAQInterface, the configuration manager, and the TDU XMLRPC server

As of March 30, 2015, a new script called "kill_daq_applications.sh" can be run at the command line to kill the DAQ applications. In order to kill all four applications, one would run:

<pre>
kill_daq_applications.sh -c -d -r -t
</pre>

where each option corresponds to the killing of a particular application: "-c" for the configuration manager, "-d" for DAQInterface, "-r" for RunControl, and "-t" for the TDU XML-RPC server. If only a subset of these four applications are running, then only use the relevant options (e.g., simply run <code>kill_daq_applications.sh -t </code> if the only application running is the TDU server). Running the script without any options at all will print out instructions similar to what you see here. Be aware that it's good etiquette to make sure someone's not currently using the DAQ before you start killing applications.

For the previous instructions for killing the applications (still correct, though more work-intensive), click on "Show", below:

{{collapse()

Killing RunControl has its own special syntax, and is simply:

<pre>
lbnecmd kill
</pre>

The other DAQ applications, however, need to be killed via the standard Linux command <code>kill <pid></code>, where "<pid>" is the process ID of the application. To find the process IDs of all possible DAQ applications, you can run:

<pre>
ps aux | grep -v grep | grep -v emacs | egrep -e lbnecontrol -e daqinterface -e CfgMgrApp -e tdu
</pre>

For each application which exists, a row will appear, the second field of which is that application's process ID. Keep in mind, of course, that if these processes are running, it might mean that someone else is using the DAQ. As the 9th and 10th fields of the row of variables "ps aux" returns concern how long the program has been running, you can use these values as well as your best judgement, then, before deciding these processes are not in active use and killing them.
}}

h2. Launching RunControl, DAQInterface, the configuration manager, and the TDU XMLRPC server

Also as of March 30, 2015, a new script called "launch_daq_applications.sh" can be run at the command line to launch the DAQ applications. In order to launch all four applications, one would run:
<pre>
launch_daq_applications.sh -c -t -r -d <daqinterface configuration file>
</pre>

…where unless you have your own working copy of the DAQInterface configuration file (what this is will be described later in this wiki), "<code><daqinterface configuration file></code>" should be "<code>docs/config.txt</code>". The options refer to the same applications as in the case of kill_daq_applications.sh, and like kill_daq_applications.sh, executing the script without any options will print out instructions. Be aware, however, that DAQInterface will not be launched if RunControl isn't already running. In practice, though, you can launch RunControl in the same launch_daq_applications.sh command by preceding the DAQInterface option with the RunControl option -- so, if the configuration manager and the TDU server are already up and available, then one would only need to execute "<code>launch_daq_applications.sh -r -d <daqinterface configuration file></code>" in order to have the full suite of DAQ applications available for use.

Note that if an application of a given type is already running, launch_daq_applications.sh will not launch a duplicate application, but will instead print a warning to the screen.

For the previous instructions on how to launch the DAQ applications, still correct, but more detailed and labor-demanding, click on "Show" below:

{{collapse()

h3. Launching RunControl

<pre>
rm -f /tmp/lbnecontrol.pid # (This should only be necessary if last RunControl session wasn't killed via "lbnecmd kill")
lbnecmd launch
</pre>

h3. Launching DAQInterface

<pre>
daqinterface -f <daqinterface file> &
</pre>

The "-f <daqinterface file>" is optional; if left out, the lbnerc/docs/config.txt file will be used to configure DAQInterface, otherwise <daqinterface file> will be used. The DAQInterface configuration is not to be confused with run configurations handled by the configuration manager; see the section "The DAQInterface configuration file" for more.

Other "expert" arguments:
<pre>
daqinterface -n daqint -r 5570 -c localhost -H localhost -f <daqinterface file> &
</pre>
Here, the "daqint" argument is arbitrary, and is the name you'll give the DAQInterface process in RunControl; the "5570" argument is the port off of which DAQInterface will run. "-c" refers to the host on which RunControl is running, and "-H" the host on which DAQInterface is running.

If multiple users with different terminals wish to check the DAQ output, it is recommended to try:
<pre>
stdbuf -oL daqinterface -n daqint -r 5570 -c localhost -H localhost -f <daqinterface file> >>~/DI.log 2>&1 &
</pre>
This will launch daqinterface in the background, with all messages being appended to the bottom of the file ~/DI.log (The stdbuf -oL prevents buffering of output to the file, so the file should update in real time)

h3. Launching the configuration manager

Please see the "Starting up the CfgMgrApp on lbne35t-gateway01" section of Jon Paley's documentation here: https://cdcvs.fnal.gov/redmine/projects/fhicl_cfgmgr/wiki

h3. Launching the TDU XMLRPC server

<pre>
tdu -T 192.168.100.201 -P 10001 -H localhost -r 50008 &
</pre>

?Note that if you are using emulators, you don't need to run using the TDU. Remember to set 'TDU XMLRPC port' to less than or equal 0.

See [[Starting and using TDUControl]] for more details.

}}

h1. Configuring and starting Runs

With the applications launched, you can take the DAQ system through the standard transitions to perform a DAQ run. The "ground state" of the DAQ is called the "stopped" state. Each successful transition brings the DAQ into a different state. Described in more detail later, the chain of states (in quotes) and transitions (in italics) in the DAQ system can be represented as follows:

---

"stopped" -> _init_ -> "ready" -> _start_ -> "running" -> _pause_ -> "ready" -> _resume_ -> "running" -> _stop_ -> "ready" -> _terminate_ -> "stopped"

---

h2. Checking the state of the DAQ

At all stages, you can use the "lbnecmd check" command to see what state DAQInterface is in; example output of this is as follows:
<pre>
lbnecontrol: Available
CfgMgr: Available
DAQInterface: Available
TDUControl: Available

Run number: 797
Run configuration: ganglia_test
Run type: Test
daqint@localhost:5570 (synchronous): running
</pre>

Here, you've already seen how lbnecmd check can tell you whether a given application type has been launched or not; on the bottom line, however, you'll also see a description of the _state_ of the DAQ -- in this case, "running", meaning that it's actively acquiring data.

Note that you'll want to wait for a transition to complete before issuing another one, otherwise you'll receive a warning and the transition request will be ignored. DAQInterface will also report when transitions are complete -- e.g., at the end of the "initialize" transition, you'd see:
<pre>
Initialize transition complete; if running DAQInterface in the background, can press <enter> to return to shell prompt
</pre>
If a high "debug level" has been set for DAQInterface (see below for more on this), this message can get buried in a set of output messages; in this case "lbnecmd check" may be the easiest way to determine what state the system is in.

h2. Selecting a run configuration and DAQ components

*Before initializing or starting a DAQ run*, a configuration and set of DAQ components must be selected. This is done via RunControl.

h3. List and select a configuration:

To see the list of available configurations (queried from the configuration manager):
<pre>
lbnecmd listconfigs
</pre>
This lists all available configs, as well as the current selected config (Note, default config is "No Config"):
<pre>
Available configs (Name : description)

8xssp_with_nova_sync : Sorry, no description found.
6xssp_ext : Sorry, no description found.
2xssp_ssp01_led_ssp02_tstamp : Sorry, no description found.
demo : This is a demo. Testing 1, 2, 3…
...

Current selected config: No Config
</pre>
You can then select a configuration -- for the purposes of this tutorial, let's go with "demo", which creates simulated data without using any hardware:
<pre>
lbnecmd setconfig demo
</pre>
This will return "OK" if successful; "lbnecmd listconfigs" will then show this as the current config. If the specified configuration is not known, an error is returned. Instructions on how to add a configuration are given later in this document.

h3. List and select DAQ components.

You can select which portions of the LBNE DAQ setup you want to use in the upcoming run. These are mapped generally to the ArtDAQ BoardReaderMain processes
that read them out. As an operator, you need to ensure that there are configuration files available in the configuration manager for the DAQ Components that you select here, or DAQInterface will return an error.

To see the list of available DAQ components:
<pre>
lbnecmd listdaqcomps
</pre>
Will return a list of components available and selected (*Default* is ALL available components), e.g.:
<pre>
Available:
component01 (lbnedaq2:5205)
component02 (lbnedaq2:5206)

ssp08 (lbnedaq1:5214)

Selected:
component01 (lbnedaq2:5205)
component02 (lbnedaq2:5206)

ssp08 (lbnedaq1:5214)
</pre>
The components are shown by name, along with the requested host/port to run the component's corresponding BoardReaderMain process on. You can then select a list of DAQ components to use in the run:
<pre>
lbnecmd setdaqcomps component0{1,2}
</pre>
(n.b. the {1,2} in brackets is a Linux bash shell trick which expands <code>component0{1,2}</code> to <code>component01 component02</code>). This will return "OK" if successful ("lbnecmd listdaqcomps" will show this in the "selected" set of components). If the specified components are not known, an error is returned.

How to make a new component available to RunControl is described later in this document.

h2. Initializing, starting, stopping and terminating a Run

For each of these transitions, please recall that while "lbnecmd <cmd>" returns very quickly, the actual issued command can take several seconds or minutes to complete. Before issuing another command, be sure that the transition is complete by using the check command:
<pre>
lbnecmd check
</pre>
For example, before issuing the "start" transition, you can use this command to ensure that the DAQ is in the "ready" state and not still in the "initializing" stage.

First, take DAQInterface from the "stopped" to the "ready" state; this will create the artdaq processes on the hosts you selected (DAQ components), and initialize them with the FHiCL documents:
<pre>
lbnecmd init daq
</pre>

Take DAQInterface from the "ready" to the "running" state, in order to begin taking data:
<pre>
lbnecmd start daq
</pre>
Note that the current run number is displayed when DAQ is in the running state using the "lbnecmd check" command:

Pause the running of the DAQ, putting DAQInterface into the "paused" state. This will cause the current open output file to be closed and given a name reflecting the current run number:
<pre>
lbnecmd pause daq
</pre>

Resume the running of the DAQ, putting returning to the "running" state. This will restart data taking to a new output file:
<pre>
lbnecmd resume daq
</pre>

Halt the running of the DAQ, returning DAQInterface to the "ready" state from the "running" state:
<pre>
lbnecmd stop daq
</pre>
From the ready state, you can start a new run with the same configuration and DAQ components you originally selected.
*NOTE* To select a new configuration or DAQ component set, you must issue the "terminate" command, which will kill all ArtDAQ processes and return DAQInterface to its "stopped" state:

<pre>
lbnecmd terminate daq
</pre>

h2. After your DAQ run.

Once you've completed your run, there are typically two primary outputs: the Root files which contain the data which passed through the DAQ (saved, as of March 25, 2015, in /data/lbnedaq/data on the gateway node), and a set of text files containing information about the run. To access these text files, you'll want to go to the run records directory, which defaults to /data/lbnedaq/run_records/<run_number>. This directory contains the FHiCL documents used to control the ArtDAQ processes in the run, the DAQInterface configuration file used (described later in this wiki), and a metadata file, which, among other things, describes where to find a record of the DAQ's output. An example of this file, for run 778, can be found if we look in /data/lbnedaq/run_records/778 at "metadata_r778.txt":

<pre>
Config name: demo
Component #0: component01
Component #1: component02
lbne-artdaq commit: 0f0f9be1c63a3b487170579c887ce79944eca6f8
lbnerc commit: 92935f2702c5e0aa732fd3cc9ff6758e1a0c288c
/data/lbnedaq/config/ commit: 97d8b222742a41d5d10ea942a063ddfacac3ce93

pmt logfile(s): lbnedaq3:/data/lbnedaq/daqlogs/pmt/pmt-25771*.log

boardreader logfiles:
lbnedaq3:/data/lbnedaq/daqlogs/boardreader/boardreader-20150320163004-lbnedaq2-37365.log
lbnedaq3:/data/lbnedaq/daqlogs/boardreader/boardreader-20150320163004-lbnedaq2-37366.log

eventbuilder logfiles:
lbnedaq3:/data/lbnedaq/daqlogs/eventbuilder/eventbuilder-20150320163004-lbnedaq2-37364.log
lbnedaq3:/data/lbnedaq/daqlogs/eventbuilder/eventbuilder-20150320163004-lbnedaq2-37363.log
lbnedaq3:/data/lbnedaq/daqlogs/eventbuilder/eventbuilder-20150320163004-lbnedaq2-37368.log

aggregator logfiles:
lbnedaq3:/data/lbnedaq/daqlogs/aggregator/aggregator-20150320163004-lbnedaq2-37369.log
lbnedaq3:/data/lbnedaq/daqlogs/aggregator/aggregator-20150320163004-lbnedaq2-37367.log

</pre>
The most significant things saved in this file for the end user of the DAQ system are the configuration chosen and the components chosen for the run (at the top of the file), and the wildcard for the pmt (ArtDAQ Process Management Tool) logfiles, which contain the output of the DAQ system, under "pmt logfile(s)" -- so, in this case, executing <code>ls -ltr /data/lbnedaq/daqlogs/pmt/pmt-25771*.log</code> would list the files containing the output of the DAQ in run 778.

{{collapse(Comprehensive details on the contents of the run records directory...)

** The full contents of the metadata file, beyond what's described above, include:
-The git commit hashes of the lbne-artdaq and lbnerc packages used in the run, as well as the commit hash of the configuration directory used by the configuration manager
-The individual artdaq process logfiles

** A copy of the DAQInterface configuration file with a name of the format <code>config_r<run number>.txt</code> is saved. A description of what this file is comes later in the wiki.

** Please note that the FHiCL documents saved in the run records directory will contain the actual FHiCL sent to the artdaq processes for the run, and that this will be slightly different than the contents of the FHiCL documents found in the configuration manager's directory. This is because DAQInterface performs some bookkeeping on FHiCL variables which account for things such as the number of processes of a given type (note that it makes no changes which would affect the physics). The saved FHiCL document name is standardized to <processtype>_<host>_<port>_r<run number>.fcl, so, e.g, "EventBuilder_lbnedaq2_5735_r778.fcl" refers to the FhiCL used to control the EventBuilderMain process on lbnedaq2 at port 5735 during run 778.

** Please also note that the entire subdirectory for the configuration is also saved alongside the FHiCL documents; this is because some FHiCL documents are included via "#include" into the main FHiCL documents for a given process, and this was the way to save them as well as the main FHiCL documents.

}}

{{collapse(How to examine your output Root files...)
Various Art modules may create various types of output. In particular, it's standard for one of the two AggregatorMains running in an artdaq-based DAQ to use Art's RootOutput module, which will save the assembled raw event in an Art-readable *.root file. The location of this output can be found in the FHiCL code used to control RootOutput. The other AggregatorMain typically will run other RootOutput modules designed to create plots, diagnostic printouts, etc.; the nature of the output here is too varied to neatly summarize, but checking the FHiCL code used to control these Art modules should reveal their output location.

To take a quick look at the Art-readable *.root file, with a version of lbne-artdaq newer than 11/25/14, you can do the following:

<pre>
cd <lbne-artdaq basedir>
source setupLBNEARTDAQ
rawEventDump -s <rootfile> -n <max events>
</pre>

where here, <lbne-artdaq basedir> is the parent directory of the lbne-artdaq package, <rootfile> is the Art-readable *.root file produced in a given run, and <max events> is the max events whose info you wish to look at. The output of this command will look something like the following:

<pre>
%MSG-i MF_INIT_OK: art 01-Dec-2014 16:13:59 CST JobSetup
Messagelogger initialization complete.
%MSG
%MSG-i PathConfiguration: art 01-Dec-2014 16:14:00 CST JobSetup
Multiple end paths have been combined into one end path,
"end_path" since order is irrelevant.

%MSG
01-Dec-2014 16:14:00 CST Initiating request to open file /tmp/lbne35t_r000270_sr01_20141201T221127.root
01-Dec-2014 16:14:00 CST Successfully opened file /tmp/lbne35t_r000270_sr01_20141201T221127.root
--------------------------------------------------------------
Package |Version |Timestamp
artdaq-core |v1_04_06 |01-Dec-2014 21:59:51 UTC
artdaq |v1_12_04 |01-Dec-2014 22:01:57 UTC
lbne-artdaq |v0_00_08 |01-Dec-2014 22:00:18 UTC
lbne-artdaq |v0_07_00 |01-Dec-2014 22:02:57 UTC
--------------------------------------------------------------
Begin processing the 1st record. run: 270 subRun: 1 event: 1 at 01-Dec-2014 16:14:00 CST
PROCESS NAME | MODULE LABEL.. | PRODUCT INSTANCE NAME | DATA PRODUCT TYPE............ | PRODUCT FRIENDLY TYPE | SIZE
DAQ......... | daq........... | TOY1................. | std::vector<artdaq::Fragment> | artdaq::Fragments.... | ...2
DAQAG....... | TriggerResults | ..................... | art::TriggerResults.......... | art::TriggerResults.. | ...-

Total products (present, not present): 8 (2, 6).

PROCESS NAME | MODULE LABEL | PRODUCT INSTANCE NAME | DATA PRODUCT TYPE.................... | PRODUCT FRIENDLY TYPE.... | SIZE
DAQAG....... | BuildInfo... | LbneArtdaq........... | std::vector<artdaq::PackageBuildInfo> | artdaq::PackageBuildInfos | ...4

Total products (present, not present): 1 (1, 0).

01-Dec-2014 16:14:00 CST Closed file /tmp/lbne35t_r000270_sr01_20141201T221127.root

TrigReport ---------- Event Summary ------------
TrigReport Events total = 1 passed = 1 failed = 0

TrigReport ------ Modules in End-Path: end_path ------------
TrigReport Trig Bit# Visited Passed Failed Error Name
TrigReport 0 0 1 1 0 0 printBuildInfo
TrigReport 0 0 1 1 0 0 out1

TimeReport ---------- Time Summary ---[sec]----
TimeReport CPU = 0.003361 Real = 0.003000

Art has completed and will exit with status 0.
</pre>
The first thing you see here is the version and build time of the lbne-artdaq package and some of the main packages on which it depends. Then you see a listing of products in the root file, here including two fragments of type TOY1, produced by the ToySimulator fragment generator. Finally, a listing of passed events; the output here is the result of running with "-n 1" as an option, so as we'd expect there's only one event.
}}

h1. The DAQInterface configuration file

DAQInterface uses some key information stored in a local configuration file, NOT to be confused with the run configuration described elsewhere on this wiki. Examples of this information are location and ports for artdaq processes, location of lbne-artdaq software, debug (log) level, etc). These can be changed while the DAQ is in its "stopped" state. The default DAQInterface configuration file is docs/config.txt (relative to /data/lbnedaq/daqarea/lbnerc); if you wish to change parameters, it's considered best practice not to edit this default file but rather to copy it to a file of the form "<code>docs/config_<your username>.txt</code>", and edit that file, passing it to the DAQInterface executable via the "-f" option as described earlier in this document. It's expected that for normal operations, most parameters should not need to changed too often, and alterations will be primarily of developer or expert interest. If you ARE a developer/expert or are simply curious, take a look at the default DAQInterface configuration file; it should look something like the following:
<pre>

lbne-artdaq: /data/lbnedaq/daqarea/lbne-artdaq-base/build_lbne-artdaq

PMT host: lbnedaq3
PMT port: 5400

pause before initialization: 5

# debug level can range from 0 to 3 (increasing order of verbosity)
debug level: 1

log directory: /data/lbnedaq/daqlogs

record directory: /data/lbnedaq/run_records

# If this file is "config.txt" -- i.e., the standard, non-expert,
# non-testing version of the DAQInterface configuration file -- do not
# set "disable configuration check" to "true"

disable configuration check: false

TDU XMLRPC port: 0

EventBuilder host: lbnedaq2
EventBuilder port: 5235

EventBuilder host: lbnedaq2
EventBuilder port: 5236

Aggregator host: lbnedaq2
Aggregator port: 5265

Aggregator host: lbnedaq2
Aggregator port: 5266

</pre>

The parameters you're most likely to change will be the following:

* *lbne-artdaq* : the directory in which the desired build of lbne-artdaq to use is located; you would change this if you'd modified and built a personal copy of lbne-artdaq for hardware troubleshooting purposes, for example.

* *debug level* : allows the user to set the verbosity level of the output to the screen; setting it to higher values creates greater verbosity, and as a practical matter, the range of settings is currently 0-3. Loosely speaking, "0" means minimal output (not much beyond simply announcing a transition is complete), "1" includes announcements of progress during transitions, "2" includes these announcements plus the values of certain variables as well as lbne-artdaq output, and "3" is primarily of developer interest.

* *disable configuration check* : a boolean which can be set to "true" or "false"; normally this should be set to "false", which means that on the start transition, DAQInterface will intentionally fail and put itself into the "stopped" state if it discovers that edits have been made to the configuration directory since the last commit in that directory. If very frequent edits to the configuration directory are made during hardware debugging, however, switching this feature on to "true" can make life considerably easier.

* *TDU XMLRPC port* : the value of the port through which DAQInterface will communicate with an XML-RPC server linked to the TDU. Needed for DAQInterface to send a sync pulse to the TDU at the beginning of the "start" and "resume" transitions. If this is set to 0 or a negative value, no sync pulse is attempted. For more on the TDU and its code, see Tom Dealtry's Wiki "here":https://cdcvs.fnal.gov/redmine/projects/lbne-daq/wiki/Starting_and_using_TDUControl

{{collapse(Other parameters are as follows…)

* *PMT host* : the host on which artdaq's process management tool script (pmt.rb, used by DAQInterface to launch and kill the artdaq processes) will run
* *PMT port* : pmt.rb's port

* *pause before initialization* : the time in seconds between when the artdaq processes have been created and when they're initialized via FHiCL documents; empirically a pause of 5 seconds seems to be sufficient (less than this an errors can occur; see below in the "Troubleshooting" section for more

* *log directory* : the directory relative to which lbne-artdaq's pmt/*.log output (a record of what it sent to stdout) will be placed, as well as the individual artdaq process logs, found in boardreader/, eventbuilder/, and aggregator/

* *record directory* : the directory to which metadata about the run (FHiCL documents used, DAQInterface configuration file used, etc.) gets sent

After these individual parameters, one defines the EventBuilderMain and AggregatorMain artdaq processes. Specifically, a process is defined in two lines, where each line should contain "EventBuilder" or "Aggregator", and then define the host and port on which the EventBuilderMain or AggregatorMain will run (to run an artdaq process on the same host as you're on, use "localhost"). Please note that the order of processes matters, and that they should be listed front-end to back-end, i.e., EventBuilders should appear before Aggregators.
}}

h1. Adding new configurations to RunControl

{{collapse(Expand for info here…)

Adding a new configuration selectable from RunControl involves two steps: creating a directory with the desired name of the configuration which contains the desired FHiCL documents, and then committing that directory to the git repository.

As of 11/20/14, the FHiCL documents associated with a given configuration are edited within the directory
<pre>
/data/lbnedaq/config/<named_configuration>
</pre>
where "named_configuration" would be the name of the configuration, in this example. Within this directory, the following files are expected:
* Aggregator1.fcl and Aggregator2.fcl, used to initialize the two AggregatorMain processes in the DAQ system
* <named_component>_hw_cfg.fcl, used to initialize the BoardReaderMain process running the fragment generator associated with detector component "named_component". Note that there can be any number of such files associated with a configuration, as long as a given component is registered to RunControl (see below, "Adding new DAQ Components to RunControl")

There are existing examples of configurations currently within /data/lbnedaq/config which can be studied (and even copied) for further guidance; however, please disregard the "tmp1" and "tmp2" configurations. Note that the FHiCL documents in these directories contain some variables which are set to "PLACEHOLDER", e.g.
<pre>
event_builder_count: PLACEHOLDER
</pre>
Note that this is not legal FHiCL, but that DAQInterface will substitute in the appropriate value before using the FHiCL document to initialize an artdaq process; here, for example, it would replace "PLACEHOLDER" with the actual number of EventBuilderMain processes being run.

Once you've added a new configuration to /data/lbnedaq/config, you'll need to perform a git commit. Essentially, /data/lbnedaq/config is not merely a collection of directories naming configurations, but also a git repository. In fact, if you run
<pre>
git log
</pre>
you'll see a history of the commits made to the repository. In order to commit the directory, a couple of steps need to be taken:
* From /data/lbnedaq/config/, run <pre>git add <named_configuration></pre>. This will "stage" the directory to be committed. Running <pre>git status</pre> should show you something like the following:
<pre>
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: helloworld/Aggregator1.fcl
# new file: helloworld/Aggregator2.fcl
# new file: helloworld/component01_hw_cfg.fcl
# new file: helloworld/component02_hw_cfg.fcl
#
</pre>
* Next, run <pre>git commit -m "<commit message>"</pre>. The commit message should be your three initials followed by a colon, the name of the configuration followed by a colon, and then a brief description of the new configuration, including its name, e.g.:
<pre>
git commit -m "JCF: helloworld: This configuration does not exist in the actual repo, it's simply used for documentation purposes"
</pre>
Be aware of rules governing strings delimited by double quotes in bash -- i.e., don't try double quoting a word or phrase inside of your commit description.
</pre>
Now, make sure that the commit took place correctly by running
<pre>
git diff HEAD
</pre>
If your commit is at the head of the master branch, you should see no output; additionally, if you run
<pre>
git log
</pre>
you should be able to see your commit at the top.

* Finally, make sure to push your change to the central repository; to do this, simply execute
<pre>
git push origin
</pre>

and now, if you run

<pre>
git diff origin/master
</pre>

you should again see no output. Pushing to the central repository is important as this is essentially the backup area for configurations; if a user accidentally overwrites something in /data/lbnedaq/config, as long as commits have been pushed to the central repository there will still be a saved record of configurations before the overwrites took place. In fact, as of this writing (12/3/14), if either (A) edits have been made to the /data/lbnedaq/config directory since its most recent commit, or (B) that commit hasn't been pushed to the central repository, DAQInterface will refuse to execute the initialize transition.
}}

h1. Adding new DAQ Components to RunControl

{{collapse(Expand for info here…)
The list of available DAQComponents (maps to BoardReader processes) is maintained by RunControl in the file:
<pre>
/home/lbnedaq/.lbnerc-components
</pre>
Each entry (name: host port) defines:
* name - name of the component, maps to a <name>_hw_cfg.fcl in CfgMgr's configuration directory
* host - hostname where BoardReader process will be started
* port - XMLRPC port to be used, must be unique and used by other processes.

For example:
<pre>
component01: lbnedaq2 5205
component02: lbnedaq2 5206
</pre>
Has two components (component01 and component02) both running on lbnedaq2 on ports 5205 and 5206.

*Note* that you will need to kill and re-launch RunControl if you add a component
}}

h1. Troubleshooting and FAQ

h2. Common RunControl issues

h3. How can I get a list of all RunControl commands?

<pre>
lbnecmd help
</pre>
will list all available commands for RunControl with some details for help.

h3. No real configurations are listed by RunControl

If you run "lbnecmd listconfigs" and see something like:
<pre>
Available configs (Name : description)

dummy : Dummy description
</pre>
Instead of your expected configurations, RunControl is not able to connect to CfgMgr. Please make sure it's running (https://cdcvs.fnal.gov/redmine/projects/fhicl_cfgmgr/wiki/Wiki)

h2. Common DAQInterface issues

As a preliminary: if something goes wrong when running the DAQ, there are two valuable sources of information:
# The pmt logfile(s), containing the output of the artdaq processes (including the output of the Art modules run within them -- so, for example, an exception throw from within a module would appear here). Where to find these logfiles is described in the section "After your DAQ run", earlier in this wiki.
# The RunControl logfile, /home/lbnedaq/.lbnerc.log . This contains both the information sent from DAQInterface to RunControl, as well as diagnostic logging (such as the traceback of exception throws within DAQInterface)

h3. *On the initial transition ("lbnecmd init daq"), you see "<code>pmt.rb -p <port number> was already running on <hostname></code>"*

An instance of artdaq's Process Management Tool program, tasked with creating the artdaq processes, is already running on the host and port you've requested for it in the DAQInterface configuration file passed to the DAQInterface application. This can happen if, for example, the DAQInterface program from a previous session was killed off before the usual "lbnecmd terminate daq" transition was issued, a transition which prompts DAQInterface to kill off the pmt.rb process it has control over. Generally, DAQInterface will clean this up and free the port in the process of returning itself to the "stopped" state, but in case it doesn't, there's a script called "cleanse.sh" which can be used in the following manner:
<pre>
/data/lbnedaq/bin/kill_artdaq_processes.sh <pmt host> <pmt port>
</pre>

This script will both kill off the pmt.rb which is clogging the port, as well as the artdaq processes over which it has control.

h3. *On the initial transition ("lbnecmd init daq"), you see "error: [Errno 111] Connection refused"*

If a "Recover" is triggered and you can see via "lbnecmd check" that DAQInterface is in the "stopped" state, try initializing again. If that doesn't work, you can try increasing the value of the "pause before initialization" variable in the DAQInterface configuration file. Empirically, it appears there needs to be a pause of at least 5 seconds before the FHiCL documents can be successfully sent via XML-RPC to the processes; increasing this value may make it less likely that the "Connection refused" error occurs.

h3. *Regardless of how high the debug level is set to, you don't see any output to screen when you issue transitions to DAQInterface*

Chances are that DAQInterface was started in another terminal, and consequently, it's in that terminal where output will appear. This issue can be circumvented by redirecting DAQInterface output into a file; how this can be accomplished is described elsewhere in this document.

{{collapse(Of developer interest)
h3. *Error handling*

As of this writing (11/14/14) certain potential problems have been anticipated and are handled within DAQInterface. These problems include:
# An artdaq process returns an error state after a transition request, or an exception is thrown by the XML-RPC library during the request
# During periodic checks, one or more artdaq processes expected to exist are not found

In either case, an error is reported via 0MQ to RunControl, and the "Recover" transition is automatically triggered. This transition is a fairly blunt instrument: it will kill any remaining artdaq processes and return DAQInterface to its original state of "stopped" (i.e., one in which it requires the "init" transition before anything else is done).

h3. *Your change to the DAQInterface configuration file or the daqinterface.py code doesn't seem to do anything*

Make sure you kill the existing daqinterface process and restart it

}}