Project

General

Profile

MAUSOnlineReconstructionOverview » History » Version 1

Jackson, Mike, 06 March 2012 10:34

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
is_birthed = FALSE
44
last_time = 01/01/1970
45
WHILE TRUE
46
  READ spills added since last time from document store
47
  IF spill_run_number != run_number
48
    IF is_birthed
49
      Send END_OF_RUN block to merger
50
      DEATH merger and outputter
51
    BIRTH merger and outputter
52
    run_number = spill_run_number
53
    is_birthed = TRUE
54
  MERGE and OUTPUT spill
55
Send END_OF_RUN block to merger
56
DEATH merger and outputter
57
</pre>
58
59
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.
60
61
is_birthed is used to ensure that there is no BIRTH-DEATH-BIRTH redundancy on receipt of the first spill.
62
63
h2. Document store
64
65
Spills are stored in documents in a collection in the document store. 
66
67
Documents are of form @{"_id":ID, "date":DATE, "doc":SPILL}@ where:
68
69
* 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@)
70
* DATE: date and time to the milli-second noting when the document was added (Python @timestamp@)
71
* DOC: spill document. (Python @string@ holding a valid JSON document)
72
73
h3. Collection names
74
75
For Input-Transform,
76
77
* 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.
78
* Otherwise the value of @doc_collection_name@ is used.
79
* @doc_collection_name@ has default value @spills@.
80
81
For Merge-Output,
82
83
* If configuration parameter @doc_collection_name@ is @None@, @""@, or undefined then an error is raised.
84
* Otherwise the value of @doc_collection_name@ is used.
85
86
h2. Miscellaneous
87
88
* Currently Celery timeouts are not used, transforming a spill takes as long as it takes.
89
* 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.
90
* 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.