Project

General

Profile

MAUSOnlineReconstructionOverview » History » Version 2

Jackson, Mike, 13 March 2012 11:28

1 1 Jackson, Mike
h1. Online Reconstruction Overview
2
3
h2. Run numbers
4
5
Run numbers are assumed to be as follows:
6
7
* -N : Monte Carlo simulation of run N
8
* 0 : pure Monte Carlo simulation
9
* +N : run N
10
11
h2. Transforming spills from an input stream (Input-Transform)
12
13
This is the algorithm used to transform spills from an input stream:
14
<pre>
15
CLEAR document store
16
run_number = None
17
WHILE an input spill is available
18
  GET next spill
19
  IF spill does not have a run number
20
    # Assume pure MC
21
    spill_run_number = 0
22
  IF (spill_run_number != run_number)
23
    # We've changed run.
24
    IF spill is NOT a start_of_run spill
25
      WARN user of missing start_of_run spill
26
    WAIT for current Celery tasks to complete
27
      WRITE result spills to document store
28
    run_number = spill_run_number
29
    CONFIGURE Celery by DEATHing current transforms and BIRTHing new transforms
30
  TRANSFORM spill using Celery
31
  WRITE result spill to document store
32
 DEATH Celery worker transforms
33
</pre>
34
If there is no initial @start_of_run@ spill (or no @spill_num@ in the spills) in the input stream (as can occur when using @simple_histogram_example.py@ or @simulate_mice.py@) then spill_run_number will be 0, run_number will be None and a Celery configuration will be done before the first spill needs to be transformed. 
35
36
Spills are inserted into the document store in the order of their return from Celery workers. This may not be in synch with the order in which they were originally read from the input stream.
37
38
h2. Merging spills and passing results to an output stream (Merge-Output)
39
40
This is the algorithm used to merge spills and pass the results to an output stream:
41
<pre>
42
run_number = None
43 2 Jackson, Mike
end_of_run = None
44 1 Jackson, Mike
is_birthed = FALSE
45
last_time = 01/01/1970
46
WHILE TRUE
47
  READ spills added since last time from document store
48 2 Jackson, Mike
  IF spill IS "end_of_run"
49
    end_of_run = spill
50 1 Jackson, Mike
  IF spill_run_number != run_number
51
    IF is_birthed
52 2 Jackson, Mike
      IF end_of_run == None
53
          end_of_run = {"daq_event_type":"end_of_run", "run_num":run_number}
54
      Send end_of_run to merger
55 1 Jackson, Mike
      DEATH merger and outputter
56
    BIRTH merger and outputter
57
    run_number = spill_run_number
58 2 Jackson, Mike
    end_of_run = None
59 1 Jackson, Mike
    is_birthed = TRUE
60
  MERGE and OUTPUT spill
61
Send END_OF_RUN block to merger
62
DEATH merger and outputter
63
</pre>
64
65
The Input-Transform policy of waiting for the processing of spills from a run to complete before starting processing spills from a new run means that all spills from run N-1 are guaranteed to have a time stamp < spills from run N.
66
67
is_birthed is used to ensure that there is no BIRTH-DEATH-BIRTH redundancy on receipt of the first spill.
68
69
h2. Document store
70
71
Spills are stored in documents in a collection in the document store. 
72
73
Documents are of form @{"_id":ID, "date":DATE, "doc":SPILL}@ where:
74
75
* ID: index of this document in the chain of those successfuly transformed. It has no significance beyond being unique in an execution of Input-Transform loop below. It is not equal to the spill_num (Python @string@)
76
* DATE: date and time to the milli-second noting when the document was added (Python @timestamp@)
77
* DOC: spill document. (Python @string@ holding a valid JSON document)
78
79
h3. Collection names
80
81
For Input-Transform,
82
83
* If configuration parameter @doc_collection_name@ is @None@, @""@, or @auto@ then @HOSTNAME_PID@, where @HOSTNAME@ is the machine name and @PID@ the process ID, is used.
84
* Otherwise the value of @doc_collection_name@ is used.
85
* @doc_collection_name@ has default value @spills@.
86
87
For Merge-Output,
88
89
* If configuration parameter @doc_collection_name@ is @None@, @""@, or undefined then an error is raised.
90
* Otherwise the value of @doc_collection_name@ is used.
91
92
h2. Miscellaneous
93
94
* Currently Celery timeouts are not used, transforming a spill takes as long as it takes.
95
* Celery task retries on failure option is not used. If the transformation of a spill fails first time it can't be expected to succeed on a retry.
96
* If memory leaks arise, e.g. from C++ code, look at Celery rate limitss, which allow the time or number of tasks before sub-process is killed and respawned, to be defined. Soft rate limits would allow @death@ to be run on the transforms first.