11
from Configuration import Configuration
12
from _InputCppDAQOfflineData import InputCppDAQOfflineData
14
16
Create a JSON document and create a histogram.
16
# Create sample JSON documents with spills containing data
17
# expected by ReducePyScalersTable.
21
json_doc["daq_data"] = {}
22
json_doc["daq_data"]["V830"] = {}
23
scalers = json_doc["daq_data"]["V830"]
24
scalers["phys_event_number"] = "Sample event %d" % i
25
scalers["time_stamp"] = time.time()
33
scalers["channels"] = hits
34
input_docs.append(json.dumps(json_doc))
35
input_docs.append("\n")
36
input_file = io.StringIO(unicode("".join(input_docs)))
18
if not os.environ.get("MAUS_ROOT_DIR"):
19
raise Exception('InitializeFail', 'MAUS_ROOT_DIR unset!')
20
config = Configuration().getConfigJSON()
21
config_json = json.loads(config)
22
datapath = '%s/src/input/InputCppDAQData' % \
23
os.environ.get("MAUS_ROOT_DIR")
25
# Set up a run configuration
27
if os.environ['MAUS_UNPACKER_VERSION'] == "StepIV":
29
config_json["daq_data_path"] = datapath
30
config_json["daq_data_file"] = datafile
38
32
# Set up data cards.
39
33
data_cards_list = []
40
34
data_cards_list.append("output_file_name='%s'\n" % "scalers")
41
35
data_cards_list.append("output_file_auto_number=%s\n" % True)
36
data_cards_list.append("daq_data_path='%s'\n" % datapath)
37
data_cards_list.append("daq_data_file='%s'\n" % datafile)
42
38
data_cards = io.StringIO(unicode("".join(data_cards_list)))
45
input_worker = MAUS.InputPyJSON(input_file)
42
# inputter = InputCppDAQOfflineData(datapath, datafile)
43
# inputter.birth(json.dumps(config_json))
44
inputter = InputCppDAQOfflineData()
47
46
mappers = MAUS.MapPyGroup()
48
47
mappers.append(MAUS.MapPyDoNothing())
50
49
reducer = MAUS.ReducePyScalersTable()
52
output_worker = MAUS.OutputPyFile()
51
outputter = MAUS.OutputPyFile()
54
53
# Execute the workers.
55
MAUS.Go(input_worker, mappers, reducer, output_worker, data_cards)
54
MAUS.Go(inputter, mappers, reducer, outputter, data_cards)
57
56
if __name__ == "__main__":