|
1 | 1 | package org.jlab.analysis.physics; |
2 | 2 |
|
3 | | -import java.io.File; |
4 | 3 | import org.jlab.io.hipo.HipoDataEvent; |
5 | 4 | import org.jlab.jnp.hipo4.data.Bank; |
6 | 5 | import org.jlab.jnp.hipo4.data.Event; |
7 | 6 | import org.jlab.jnp.hipo4.data.SchemaFactory; |
8 | 7 | import org.jlab.jnp.hipo4.io.HipoReader; |
9 | 8 | import org.jlab.jnp.hipo4.io.HipoWriterSorted; |
| 9 | +import org.jlab.utils.CLASResources; |
10 | 10 |
|
11 | 11 | /** |
12 | 12 | * |
|
15 | 15 | public class TestEvent { |
16 | 16 |
|
17 | 17 | public static void main(String args[]) { |
18 | | - writeDCSector1ElectronEvent(); |
| 18 | + //writeDCSector1ElectronEvent(); |
19 | 19 | getDCSector1ElectronEvent(0).show(); |
20 | 20 | } |
21 | 21 |
|
22 | | - public static void writeDCSector1ElectronEvent() { |
23 | | - HipoWriterSorted writer = new HipoWriterSorted(); |
24 | | - writer.setCompressionType(2); |
25 | | - writer.getSchemaFactory().initFromDirectory("/Users/baltzell/sw/coatjava/dev/etc/bankdefs/hipo4"); |
26 | | - writer.open("/Users/baltzell/org.jlab.analysis.physics.TestEvent.hipo"); |
27 | | - HipoDataEvent e = getDCSector1ElectronEvent(writer.getSchemaFactory()); |
28 | | - writer.addEvent(e.getHipoEvent()); |
29 | | - writer.close(); |
| 22 | + public static void writeDCSector1ElectronEvent(String path) { |
| 23 | + try (HipoWriterSorted writer = new HipoWriterSorted()) { |
| 24 | + writer.setCompressionType(2); |
| 25 | + writer.getSchemaFactory().initFromDirectory(CLASResources.getResourcePath("etc/bankdefs/hipo4")); |
| 26 | + writer.open(path); |
| 27 | + HipoDataEvent e = getDCSector1ElectronEvent(writer.getSchemaFactory()); |
| 28 | + writer.addEvent(e.getHipoEvent()); |
| 29 | + } |
30 | 30 | } |
31 | | - |
| 31 | + |
32 | 32 | public static HipoDataEvent getDCSector1ElectronEvent(int event) { |
33 | 33 | HipoReader reader = new HipoReader(); |
| 34 | + reader.open(CLASResources.getResourcePath("etc/data/test/dc.hipo")); |
34 | 35 | Event e = new Event(); |
35 | | - try { |
36 | | - File file = new File(TestEvent.class.getResource("/test/TestEvent.hipo").toURI()); |
37 | | - reader.open(file.getAbsolutePath());//"/Users/baltzell/org.jlab.analysis.physics.TestEvent.hipo"); |
38 | | - reader.getEvent(e, event); |
39 | | - return new HipoDataEvent(e,reader.getSchemaFactory()); |
40 | | - } catch (java.net.URISyntaxException x) { |
41 | | - return null; |
42 | | - } |
| 36 | + reader.getEvent(e, event); |
| 37 | + return new HipoDataEvent(e,reader.getSchemaFactory()); |
43 | 38 | } |
44 | 39 |
|
45 | 40 | public static HipoDataEvent getDCSector1ElectronEvent(SchemaFactory schemaFactory) { |
|
0 commit comments