~durga/maus/rel709

« back to all changes in this revision

Viewing changes to bin/online/reconstruct_daq_kl_reducer.py

  • Committer: Durga Rajaram
  • Date: 2013-10-01 00:19:57 UTC
  • mfrom: (659.1.74 rc)
  • Revision ID: durga@fnal.gov-20131001001957-iswih60vis9rodw0
Tags: MAUS-v0.7.1
MAUS-v0.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
#################################################################
 
4
###!!! YOU ARE NOT ALLOWED TO MODIFY THIS FILE DIRECTLY    !!!###
 
5
###!!! PLEASE MAKE A COPY OF THIS FILE WITH THE CP COMMAND !!!###
 
6
#################################################################
 
7
 
 
8
"""
 
9
Online analysis to produce reconstructed events from the MICE Experiment.
 
10
"""
 
11
 
 
12
import MAUS
 
13
import io
 
14
 
 
15
def run():
 
16
    """
 
17
    Analyze data from the MICE experiment
 
18
    This reads in and processes data taken from the MICE
 
19
    experiment.
 
20
    """
 
21
    # Set up data cards.
 
22
    data_cards_list = []
 
23
    # batch mode = runs ROOT in batch mode so that canvases are not displayed
 
24
    # 1 = True, Batch Mode
 
25
    # 0 = False, Interactive Mode
 
26
    # setting it to false/0 will cause canvases to pop up on screen and 
 
27
    # will get refreshed every N spills set by the refresh_rate data
 
28
    # card. 
 
29
    data_cards_list.append("root_batch_mode='%d'\n" % 1)
 
30
    # refresh_rate = once in how many spills should canvases be updated
 
31
    data_cards_list.append("refresh_rate='%d'\n" % 5)
 
32
    # Add auto-numbering to the image tags. If False then each
 
33
    # histogram output for successive spills will have the same tag
 
34
    # so there are no spill-specific histograms. This is the
 
35
    # recommended use for online reconstruction.
 
36
    data_cards_list.append("histogram_auto_number=%s\n" % False)
 
37
    # Default image type is eps. For online use, use PNG.
 
38
    data_cards_list.append("histogram_image_type=\"png\"\n")
 
39
    # Directory for images. Default: $MAUS_WEB_MEDIA_RAW if set
 
40
    # else the current directory is used.
 
41
    # Uncomment and change the following if you want to hard
 
42
    # code a different default path.
 
43
    #data_cards_list.append("image_directory='%s'\n" % os.getcwd())
 
44
 
 
45
    # Convert data_cards to string.    
 
46
    data_cards = io.StringIO(unicode("".join(data_cards_list)))
 
47
 
 
48
    # Set up the input that reads from DAQ
 
49
    my_input = MAUS.InputCppDAQOnlineData() # pylint: disable = E1101
 
50
 
 
51
    # Create an empty array of mappers, then populate it
 
52
    # with the functionality you want to use.
 
53
    my_map = MAUS.MapPyGroup()
 
54
    my_map.append(MAUS.MapCppKLDigits())
 
55
    my_map.append(MAUS.MapCppKLCellHits())
 
56
    # Histogram reducer.
 
57
    reducer = MAUS.ReducePyKLPlot()
 
58
    #reducer = MAUS.ReducePyDoNothing()
 
59
    # Save images as EPS and meta-data as JSON.
 
60
    #output_worker = MAUS.OutputPyDoNothing()
 
61
    output_worker = MAUS.OutputPyImage()
 
62
 
 
63
    # Run the workflow.
 
64
    MAUS.Go(my_input, my_map, reducer, output_worker, data_cards) 
 
65
 
 
66
if __name__ == '__main__':
 
67
    run()