5 from hpsmc.tools import JavaTool, EvioToLcio, FilterBunches, ExtractEventsWithHitAtHodoEcal
11 java_tool =
JavaTool(name=
"java_tool", java_class=
"java_class")
12 self.assertEqual(java_tool.name,
"java_tool")
13 self.assertEqual(java_tool.java_class,
"java_class")
14 self.assertEqual(java_tool.command,
"java")
17 java_tool =
JavaTool(name=
"java_tool", java_class=
"java_class")
18 self.assertEqual(java_tool.required_config(), [
"hps_java_bin_jar",
"hps_fieldmaps_dir"])
21 java_tool =
JavaTool(name=
"java_tool", java_class=
"java_class")
22 parser = configparser.ConfigParser()
23 config_file = [
'test_helpers/.hpsmc_test_cfg']
24 parser.read(config_file)
25 java_tool.config(parser)
26 self.assertEqual(java_tool.hps_fieldmaps_dir,
"some/fieldmaps/dir")
27 self.assertEqual(java_tool.hps_java_bin_jar,
"some/path/to/hps-java-bin.jar")
28 self.assertEqual(java_tool.conditions_url,
"http://some/path/to/conditions")
31 java_tool =
JavaTool(name=
"java_tool", java_class=
"java_class")
32 parser = configparser.ConfigParser()
33 config_file = [
'test_helpers/.hpsmc_test_cfg']
34 parser.read(config_file)
35 java_tool.config(parser)
37 self.assertTrue(os.path.islink(os.getcwd() +
"/fieldmap"))
38 os.remove(os.getcwd() +
"/fieldmap")
41 java_tool =
JavaTool(name=
"java_tool", java_class=
"java_class")
42 parser = configparser.ConfigParser()
43 config_file = [
'test_helpers/.hpsmc_test_cfg']
44 parser.read(config_file)
45 java_tool.config(parser)
46 self.assertEqual(java_tool.cmd_args(), [
"args",
"-Dorg.hps.conditions.url=http://some/path/to/conditions",
"-cp",
"some/path/to/hps-java-bin.jar",
"java_class"])
52 evio_to_lcio =
EvioToLcio(steering=
"steering_file")
53 self.assertEqual(evio_to_lcio.name,
"evio_to_lcio")
54 self.assertEqual(evio_to_lcio.java_class,
"org.hps.evio.EvioToLcio")
55 self.assertEqual(evio_to_lcio.steering,
"steering_file")
56 self.assertEqual(evio_to_lcio.output_ext,
".slcio")
60 self.assertEqual(evio_to_lcio.required_parameters(), [
"detector",
"steering_files"])
64 self.assertEqual(evio_to_lcio.optional_parameters(), [
"run_number",
"skip_events",
"nevents",
"event_print_interval"])
68 parser = configparser.ConfigParser()
69 config_file = [
'test_helpers/.hpsmc_test_cfg']
70 parser.read(config_file)
71 evio_to_lcio.config(parser)
72 evio_to_lcio.set_parameters({
"steering_files": {
"steering":
"steering_file"},
"detector":
"detector"})
74 self.assertEqual(evio_to_lcio.steering_file,
"steering_file")
77 evio_to_lcio =
EvioToLcio(steering=
"steering", inputs=[
"input1.evio",
"input2.evio"], outputs=[
"output.slcio"])
78 parser = configparser.ConfigParser()
79 config_file = [
'test_helpers/.hpsmc_test_cfg']
80 parser.read(config_file)
81 evio_to_lcio.config(parser)
82 evio_to_lcio.set_parameters({
"steering_files": {
"steering":
"steering_file"},
"detector":
"detector",
"skip_events": 10,
"nevents": 100,
"event_print_interval": 10,
"run_number": 1234})
84 self.assertEqual(evio_to_lcio.cmd_args(), [
"args",
"-Dorg.hps.conditions.url=http://some/path/to/conditions",
"-cp",
"some/path/to/hps-java-bin.jar",
"org.hps.evio.EvioToLcio",
"-DoutputFile=output",
"-d",
"detector",
"-R",
"1234",
"-s",
"10",
"-r",
"-x",
"steering_file",
"-n",
"100",
"-b",
"input1.evio",
"input2.evio",
"-e",
"10"])
90 filter_bunches =
FilterBunches(filter_no_cuts=
True, filter_ecal_pairs=
True, filter_ecal_hit_ecut=1.0, filter_event_interval=10, filter_nevents_read=1, filter_nevents_write=10)
91 self.assertEqual(filter_bunches.name,
"filter_bunches")
92 self.assertEqual(filter_bunches.java_class,
"org.hps.util.FilterMCBunches")
93 self.assertEqual(filter_bunches.append_tok,
'filt')
94 self.assertEqual(filter_bunches.filter_no_cuts,
True)
95 self.assertEqual(filter_bunches.filter_ecal_pairs,
True)
96 self.assertEqual(filter_bunches.filter_ecal_hit_ecut, 1.0)
97 self.assertEqual(filter_bunches.filter_event_interval, 10)
98 self.assertEqual(filter_bunches.filter_nevents_read, 1)
99 self.assertEqual(filter_bunches.filter_nevents_write, 10)
103 self.assertEqual(filter_bunches.optional_parameters(), [
"filter_ecal_hit_ecut",
"filter_event_interval",
"filter_nevents_read",
"filter_nevents_write",
"filter_no_cuts"])
107 self.assertEqual(filter_bunches.required_config(), [
"hps_java_bin_jar"])
111 parser = configparser.ConfigParser()
112 config_file = [
'test_helpers/.hpsmc_test_cfg']
113 parser.read(config_file)
114 filter_bunches.config(parser)
115 self.assertEqual(filter_bunches.hps_java_bin_jar,
"some/path/to/hps-java-bin.jar")
118 filter_bunches =
FilterBunches(inputs=[
"input1.slcio",
"input2.slcio"], outputs=[
"output.slcio"], filter_no_cuts=
True, filter_ecal_pairs=
True, filter_ecal_hit_ecut=1.0, filter_event_interval=10, filter_nevents_read=100, filter_nevents_write=100)
119 parser = configparser.ConfigParser()
120 config_file = [
'test_helpers/.hpsmc_test_cfg']
121 parser.read(config_file)
122 filter_bunches.config(parser)
123 self.assertEqual(filter_bunches.cmd_args(), [
"args",
"-Dorg.hps.conditions.url=http://some/path/to/conditions",
"-cp",
"some/path/to/hps-java-bin.jar",
"org.hps.util.FilterMCBunches",
"-e",
"10",
"input1.slcio",
"input2.slcio",
"output.slcio",
"-d",
"-E",
"1.0",
"-n",
"100",
"-w",
"100",
"-a"])
130 self.assertEqual(extract_events.name,
"filter_events")
131 self.assertEqual(extract_events.java_class,
"org.hps.util.ExtractEventsWithHitAtHodoEcal")
132 self.assertEqual(extract_events.append_tok,
'filt')
133 self.assertEqual(extract_events.num_hodo_hits, 1)
134 self.assertEqual(extract_events.event_interval, 10)
138 self.assertEqual(extract_events.optional_parameters(), [
"num_hodo_hits",
"event_interval"])
141 extract_events =
ExtractEventsWithHitAtHodoEcal(inputs=[
"input1.slcio",
"input2.slcio"], outputs=[
"output.slcio"], num_hodo_hits=1, event_interval=10, nevents=100)
142 parser = configparser.ConfigParser()
143 config_file = [
'test_helpers/.hpsmc_test_cfg']
144 parser.read(config_file)
145 extract_events.config(parser)
146 self.assertEqual(extract_events.cmd_args(), [
"args",
"-Dorg.hps.conditions.url=http://some/path/to/conditions",
"-cp",
"some/path/to/hps-java-bin.jar",
"org.hps.util.ExtractEventsWithHitAtHodoEcal",
"-e",
"10",
"input1.slcio",
"input2.slcio",
"output.slcio",
"-M",
"1",
"-w",
"100"])
149 if __name__ ==
'__main__':