~c-e-pidcott/maus/devel

« back to all changes in this revision

Viewing changes to bin/user/online_dq_celery_joy.py

  • Committer: Chris Rogers
  • Date: 2011-12-22 17:56:36 UTC
  • mfrom: (659.1.5 release-candidate)
  • Revision ID: chris.rogers@stfc.ac.uk-20111222175636-rw9uujiup42a7gnt
Tags: MAUS-v0.1.1
ReleaseĀ 0.1.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
import json
 
15
import os
 
16
 
 
17
def run():
 
18
    """Analyze data from the MICE experiment
 
19
 
 
20
    This will read in and process data taken from the MICE experiment. It will
 
21
    eventually include things like cabling information, calibrations, and fits.
 
22
    """
 
23
 
 
24
 
 
25
    # Set up data cards.
 
26
    data_cards_list = []
 
27
    # batch mode = runs ROOT in batch mode so that canvases are not displayed
 
28
    # 1 = True, Batch Mode
 
29
    # 0 = False, Interactive Mode
 
30
    # setting it to false will cause canvases to pop up on screen and 
 
31
    # will get refreshed every N spills set by the refresh_rate data card
 
32
    data_cards_list.append("root_batch_mode='%d'\n" % 1)
 
33
    # refresh_rate = once in how many spills should canvases be updated
 
34
    data_cards_list.append("refresh_rate='%d'\n" % 1)
 
35
 
 
36
 
 
37
    # Add auto-numbering to the image tags. If False then each
 
38
    # histogram output by ReducePyMatplotlibHistogram will have
 
39
    # tags "tdcadc" and so the end result will be just one histogram 
 
40
    # file. If True then there will be N files, one for each spill.
 
41
#    data_cards_list.append("histogram_auto_number=%s\n" % True)
 
42
    # Prefix for file names. Default: auto-generated UUID.
 
43
#    data_cards_list.append("image_file_prefix='%s'\n" % "sample-image")
 
44
    # Directory for images. Default: current directory.
 
45
#    data_cards_list.append("image_directory='%s'\n" % os.getcwd())
 
46
    # Update to use path join.
 
47
    data_cards_list.append("image_directory='%s'\n" % \
 
48
                           (os.getenv('HOME') + "/MAUS/maus-apps/media/raw"))
 
49
    
 
50
    data_cards = io.StringIO(unicode("".join(data_cards_list)))
 
51
 
 
52
    # Set up the input that reads from DAQ
 
53
    my_input = MAUS.InputCppDAQOnlineData()
 
54
#    my_input = MAUS.InputCppDAQData()
 
55
 
 
56
    # Create an empty array of mappers, then populate it
 
57
    # with the functionality you want to use.
 
58
    my_map = MAUS.MapPyGroup()
 
59
    my_map.append(MAUS.MapCppTOFDigits())
 
60
    my_map.append(MAUS.MapCppTOFSlabHits())
 
61
    my_map.append(MAUS.MapCppTOFSpacePoints())
 
62
 
 
63
    reducer = MAUS.ReducePyTOFPlot()
 
64
    # reducer = MAUS.ReducePyHistogramTDCADCCounts()
 
65
 
 
66
    output_worker = MAUS.OutputPyImage()
 
67
 
 
68
    #  The Go() drives all the components you pass in then put all the output
 
69
    #  into a file called 'mausput'
 
70
    MAUS.Go(my_input, my_map, reducer,output_worker,data_cards) 
 
71
 
 
72
if __name__ == '__main__':
 
73
    run()
 
74