Running DAQ Interface » History » Version 47

John Freeman, 11/13/2014 02:04 PM

1 31 John Freeman
h1. Running DAQInterface
2 1 John Freeman
3 37 John Freeman
DAQInterface is designed to be run, along with rest of the run control code, on, using the lbnedaq account, or on using one's personal account. For use on lbnedaqtest01, please contact John Freeman at; these instructions will focus the use of DAQInterface on the gateway node.  The code is located at /data/lbnedaq/scratch/DAQInterface/lbnerc. To get started, first setup the environment:
4 1 John Freeman
5 30 John Freeman
6 30 John Freeman
cd /data/lbnedaq/scratch/DAQInterface
7 30 John Freeman
source fireup
8 30 John Freeman
9 1 John Freeman
10 30 John Freeman
This will take you into the /data/lbnedaq/scratch/DAQInterface/lbnerc directory. It's a good idea to check whether lbnecontrol (the run control application) and/or DAQInterface (the component which intermediates between run control and artdaq processes) are already running; if they are, the instructions below won't work. To check this, you can try:
11 1 John Freeman
12 30 John Freeman
13 33 John Freeman
ps aux | grep -v grep | grep lbnecontrol
14 33 John Freeman
ps aux | grep -v grep | grep daqinterface
15 30 John Freeman
16 1 John Freeman
17 33 John Freeman
If these processes are running, it either means that someone else is using DAQInterface, or that someone else who's done with DAQInterface forgot to clean up. 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. 
18 1 John Freeman
19 30 John Freeman
Assuming the processes aren't running, before getting started, take a look at the configuration file, found in docs/config.txt (relative to /data/lbnedaq/scratch/DAQInterface/lbnerc). It should look something like the following:
20 1 John Freeman
21 1 John Freeman
22 30 John Freeman
23 30 John Freeman
lbne-artdaq: /data/lbnedaq/rce/build_lbne-artdaq
24 30 John Freeman
25 30 John Freeman
PMT host: lbnedaq3
26 30 John Freeman
27 30 John Freeman
log directory:   /data/lbnedaq/daqlogs
28 30 John Freeman
29 47 John Freeman
record directory: /data/lbnedaq/scratch/jcfree/TemporarySaveArea/
30 47 John Freeman
31 34 John Freeman
pause before initialization: 0
32 34 John Freeman
33 34 John Freeman
debug level: 1
34 34 John Freeman
35 30 John Freeman
BoardReader host: lbnedaq2
36 30 John Freeman
BoardReader port: 5205
37 30 John Freeman
BoardReader fhicl: /data/lbnedaq/fcl/BoardReader_TPC_lbnedaq2_1.fcl
38 30 John Freeman
39 30 John Freeman
BoardReader host: lbnedaq2
40 30 John Freeman
BoardReader port: 5206
41 30 John Freeman
BoardReader fhicl: /data/lbnedaq/fcl/BoardReader_TPC_lbnedaq2_2.fcl
42 30 John Freeman
43 30 John Freeman
EventBuilder host: lbnedaq3
44 30 John Freeman
EventBuilder port: 5235
45 30 John Freeman
EventBuilder fhicl: /data/lbnedaq/fcl/EventBuilder_lbnedaq2_1.fcl
46 30 John Freeman
47 30 John Freeman
EventBuilder host: lbnedaq3
48 30 John Freeman
EventBuilder port: 5236
49 30 John Freeman
EventBuilder fhicl: /data/lbnedaq/fcl/EventBuilder_lbnedaq2_2.fcl
50 30 John Freeman
51 30 John Freeman
Aggregator host: lbnedaq2
52 30 John Freeman
Aggregator port: 5265
53 30 John Freeman
Aggregator fhicl: /data/lbnedaq/fcl/Aggregator_lbnedaq2_1.fcl
54 30 John Freeman
55 30 John Freeman
Aggregator host: lbnedaq2
56 30 John Freeman
Aggregator port: 5266
57 30 John Freeman
Aggregator fhicl: /data/lbnedaq/fcl/Aggregator_lbnedaq2_2.fcl
58 1 John Freeman
59 30 John Freeman
60 1 John Freeman
61 39 John Freeman
The "lbne-artdaq" parameter allows the user to set the directory in which the desired build of lbne-artdaq to use is located, the "PMT host" parameter is the host on which artdaq's process management tool script (pmt.rb, used by DAQInterface to launch and kill the artdaq processes) will run, and "log directory" is the directory to which lbne-artdaq's output will be sent. The "debug level" parameter 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. The "pause before initialization" parameter allows the user to set a pause, in seconds, between when the artdaq processes start and when they're initialized; it has been observed that a latency of a few seconds is needed for initialization to proceed correctly (though this is not always the case -- on lbne35t-gateway01, with a high setting for "debug level", a pause is not needed; the reason why "debug level" matters in this context is not yet understood).
62 1 John Freeman
63 40 John Freeman
After these individual parameters, every cluster of three lines allows one to define an artdaq process; each line should either contain "BoardReader", "EventBuilder" or "Aggregator", defining the process type, and every cluster of three lines should have the same process type. The three lines let one define the host and port of the artdaq process (to run an artdaq process on the same host as you're on, use "localhost"), as well as the FHiCL document which will be used to initialize it. Best practice is to place those FHiCL documents in the /data/lbnedaq/fcl directory. Please note that the order of processes matters, and that they should be listed front-end to back-end, i.e., BoardReader definitions should appear before EventBuilders should appear before Aggregators. 
64 1 John Freeman
65 36 John Freeman
As of this writing (10/1/14) in the repo there currently exist versions of the config.txt file designed to run under different configurations; docs/config_lbnedaqtest01.txt runs simulated data on lbnedaqtest01, docs/config_lbne35t-gateway01.txt runs simulated data on lbne35t-gateway01, and docs/config_lbne35t-gateway01_RCE.txt runs RCEs on lbne35t-gateway01. If you wish to use a particular configuration, copy it into config.txt and then make any appropriate tweaks. 
66 36 John Freeman
67 30 John Freeman
Once you have the configuration file written to your specifications, you can then start run control and DAQInterface:
68 30 John Freeman
69 30 John Freeman
70 30 John Freeman
lbnecontrol &
71 27 John Freeman
daqinterface -n daqint -r 5570 -c localhost -H localhost &
72 30 John Freeman
73 30 John Freeman
74 1 John Freeman
Here, the "daqint" argument is arbitrary, and is the name you'll give the DAQInterface process; the "5570" argument is the port off of which DAQInterface will run. 
75 1 John Freeman
76 34 John Freeman
Now, you can take DAQ Interface through the standard transitions. At all stages, you can use the "lbnecmd check" command to see what state DAQInterface is in; 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. Without using "lbnecmd check" you can also just look for a message like the following to know that a given transition has completed:
77 34 John Freeman
78 34 John Freeman
79 34 John Freeman
Initialize transition complete; if running DAQInterface in the background, can press <enter> to return to shell prompt
80 34 John Freeman
81 30 John Freeman
82 38 John Freeman
Note that if a high "debug level" has been set, 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. 
83 38 John Freeman
84 30 John Freeman
First, take DAQInterface from the "stopped" to the "ready" state; this will create the artdaq processes on the hosts you specified, and initialize them with the FHiCL documents you specified:
85 29 John Freeman
86 30 John Freeman
lbnecmd init daq
87 29 John Freeman
88 30 John Freeman
89 30 John Freeman
Take DAQInterface from the "ready" to the "running" state, in order to begin datataking:
90 29 John Freeman
91 30 John Freeman
lbnecmd start daq
92 38 John Freeman
93 38 John Freeman
94 38 John Freeman
Pause the running of the DAQ, putting DAQInterface into the "paused" state:
95 38 John Freeman
96 38 John Freeman
lbnecmd pause daq
97 38 John Freeman
98 38 John Freeman
99 38 John Freeman
Resume the running of the DAQ, putting returning to the "running" state:
100 38 John Freeman
101 38 John Freeman
lbnecmd resume daq
102 29 John Freeman
103 30 John Freeman
104 30 John Freeman
Halt the running of the DAQ, returning DAQInterface to the "ready" state from the "running" state:
105 29 John Freeman
106 29 John Freeman
lbnecmd stop daq
107 29 John Freeman
108 30 John Freeman
109 30 John Freeman
Now, return to the "stopped" state, killing all the artdaq processes:
110 29 John Freeman
111 29 John Freeman
lbnecmd terminate daq
112 22 John Freeman
113 21 John Freeman
114 44 John Freeman
Once you've completed your run, there are a few things you can look at. For starters, a record of the DAQ's output will be saved in the subdirectory pmt/ relative to where you specified the output logfiles; thus in the example above you'd find the output in /data/lbnedaq/daqlogs/pmt/. Also, a record of the FHiCL documents sent to the artdaq processes and the docs/config.txt file will have been saved; as of this writing (11/12/14) the directory in which this can be found is /data/lbnedaq/scratch/jcfree/TemporarySaveArea/<run number>, although as you might imagine the plan is to eventually change this directory. PLEASE NOTE that there may be slight differences between the saved FHiCL documents and the FHiCL documents specified in config.txt and/or provided by the choice of configuration. The saved FHiCL document name is standardized to <processtype>_<host>_<port>_r<run number>.fcl, so, e.g, "Aggregator_lbnedaq2_5266_r192.fcl" would be the saved name of /data/lbnedaq/fcl/Aggregator_lbnedaq2_2.fcl, listed in the example config.txt file above, assuming datataking was performed in run 192. More importantly, the FHiCL document actually sent to the artdaq process may be slightly different than the FHiCL document provided for DAQInterface; 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). It is this post-bookkeeping FHiCL document which actually gets sent to the processes which gets saved to the output directory. 
115 42 John Freeman
116 41 John Freeman
* *Running with the configuration manager set up*
117 41 John Freeman
118 46 John Freeman
Note that the rules for running DAQInterface when the configuration manager is used  (described "here": are slightly different than above. The primary issue to keep in mind is that for a given configuration and set of chosen components, the BoardReaderMain and AggregatorMain applications (as well as their hosts and FHiCL documents) will be determined by run control and the configuration manager; thus these applications need not be listed in the docs/config.txt. Indeed, the only applications to list in docs/config.txt are the EventBuilderMain applications, as these deal with details internal to DAQInterface / artdaq (unlike BoardReaderMain, which contains experiment-defined fragment generators, and AggregatorMain, which contains experiment-defined Art modules). An out-of-the-box example of such a configuration file is located in lbnerc/docs/config_cfgmgr.txt; note that unlike in the example config.txt provided above that it only refers to the EventBuilderMain processes. 
119 41 John Freeman
120 1 John Freeman
121 21 John Freeman
122 21 John Freeman
* *Error handling*
123 29 John Freeman
As of this writing (7/14/14) there has not yet been extensive user feedback concerning DAQInterface; despite this, certain potential problems have been anticipated and are handled within DAQInterface. These problems include:
124 18 John Freeman
# An artdaq process returns an error state after a transition request, or an exception is thrown by the XML-RPC library during the request
125 19 John Freeman
# During periodic checks, one or more artdaq processes expected to exist are not found
126 18 John Freeman
127 1 John Freeman
In either case, an error is reported via 0MQ to run control, 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). 
128 18 John Freeman
129 36 John Freeman
In order to see this for yourself, you can deliberately sabotage one of the transitions.  E.g.,  you can replace one of these filenames listed in the config.txt file with one of your own files intentionally designed to be improper FHiCL; this will then trigger a "recover" transition automatically when an "init" transition is requested. The same thing will occur if you use the name of a file which doesn't exist. After the "recover" transition, you can then use the "lbnecmd check" command to see for yourself that DAQ Interface has returned to its original state. Note that currently, if recover sees that the artdaq processes don't exist, it will raise an exception, which will in turn trigger DAQInterface to end itself. In general, setting "debug level" to a high value is a good idea for troubleshooting if something goes wrong (although a sufficiently high value may simply obscure things for the end user). 
130 18 John Freeman
131 18 John Freeman
Please note that if you issue an "init" transition and then follow it with a "terminate" transition, you'll see an exception in the artdaq terminal window which looks like the snippet below; this is because statistics collection which occurs during termination will fail if no data's been collected, which is expected:
132 18 John Freeman
133 18 John Freeman
134 18 John Freeman
Tue Jul 08 14:16:33 -0500 2014:  Time Summary: 
135 18 John Freeman
Tue Jul 08 14:16:33 -0500 2014:  Min: 0
136 18 John Freeman
Tue Jul 08 14:16:33 -0500 2014:  Max: 0
137 18 John Freeman
Tue Jul 08 14:16:33 -0500 2014:  Avg: inf
138 18 John Freeman
Tue Jul 08 14:16:33 -0500 2014: %MSG-s ArtException:  Aggregator-lbnedaqtest01-5265 JobSetup
139 18 John Freeman
Tue Jul 08 14:16:33 -0500 2014: cet::exception caught in art
140 18 John Freeman
Tue Jul 08 14:16:33 -0500 2014: ---- DataCorruption BEGIN
141 18 John Freeman
Tue Jul 08 14:16:33 -0500 2014:   NetMonInputDetail: Could not receive message!
142 18 John Freeman
Tue Jul 08 14:16:33 -0500 2014: ---- DataCorruption END
143 1 John Freeman
Tue Jul 08 14:16:33 -0500 2014: %MSG
144 27 John Freeman
Tue Jul 08 14:16:33 -0500 2014: %MSG-s ArtException:  Aggregator-lbnedaqtest01-5266 JobSetup
145 27 John Freeman
Tue Jul 08 14:16:33 -0500 2014: cet::exception caught in art
146 28 John Freeman
Tue Jul 08 14:16:33 -0500 2014: ---- DataCorruption BEGIN
147 28 John Freeman
Tue Jul 08 14:16:33 -0500 2014:   NetMonInputDetail: Could not receive message!
148 27 John Freeman
Tue Jul 08 14:16:33 -0500 2014: ---- DataCorruption END
149 27 John Freeman
150 1 John Freeman
151 1 John Freeman
* *Troubleshooting*
152 1 John Freeman
** *Your change to doesn't seem to do anything*
153 1 John Freeman
Make sure you kill the existing daqinterface process and restart it
154 1 John Freeman
** *On the initial transition ("lbnecmd init daq"), you see "error: [Errno 111] Connection refused"*
155 36 John Freeman
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 docs/config.txt file. Empirically, it appears there needs to be a pause of at least 4 seconds on 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.
156 45 John Freeman
** *On the initial transition, you see a regularly updating printout saying "Waiting for all processes to be launched"*
157 45 John Freeman
Seeing one or two of these is fine. If, after several seconds, something like the following
158 45 John Freeman
159 45 John Freeman
Waiting for all processes to be launched; if zombie pmt.rb is running on localhost please kill it and this program (PID 31820)
160 45 John Freeman
161 45 John Freeman
keeps getting output to screen, it means there's a problem initializing. In this case, the current (11/12/14) course of action is to externally kill DAQInterface using the PID listed; also, it's possible that there may already be a pmt.rb executable running on the desired host, blocking the launch of a new one due to a port conflict, in which case you should log onto the host (assuming you're not already on it), and run 
162 45 John Freeman
163 45 John Freeman
ps aux | grep -v grep | grep pmt.rb 
164 45 John Freeman
165 45 John Freeman
to see if this is the case. If it's not and you can't think of what might be wrong (is the configuration manager running? have you double-checked docs/config.txt?), then try increasing the debug level in docs/config.txt for your next run-through, as this will likely shed light on the nature of the problem.