Project

General

Profile

Bug #1176 » analyze_data_online_input_transform.py

Rogers, Chris, 23 November 2012 14:55

 
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" % 1)
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.InputCppDAQData()
50
#    my_input = MAUS.InputCppDAQOnlineData()
51
    my_input = MAUS.InputCppDAQOnlineData()
52

    
53
    # Create an empty array of mappers, then populate it
54
    # with the functionality you want to use.
55
    my_map = MAUS.MapPyGroup()
56
    # add ReconSetup map -- analyze_data_offline seems to have it already
57
    my_map.append(MAUS.MapPyReconSetup())
58
    my_map.append(MAUS.MapCppTOFDigits())
59
    my_map.append(MAUS.MapCppTOFSlabHits())
60
    my_map.append(MAUS.MapCppTOFSpacePoints())
61
    my_map.append(MAUS.MapPyCkov())
62
    #my_map.append(MAUS.MapCppSingleStationRecon())
63
    # Histogram reducer.
64
    reducer = MAUS.ReducePyTOFPlot()
65
    #reducer = MAUS.ReducePyDoNothing()
66
    # Save images as EPS and meta-data as JSON.
67
    #output_worker = MAUS.OutputPyImage()
68
    output_worker = MAUS.OutputPyImage()
69

    
70
    # Run the workflow.
71
    MAUS.Go(my_input, my_map, reducer, output_worker, data_cards) 
72

    
73
if __name__ == '__main__':
74
    run()
(2-2/4)