Skip to content

Commit 9b208fa

Browse files
committed
export test event, and read it as a resource
1 parent c32b261 commit 9b208fa

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

common-tools/clas-analysis/src/main/java/org/jlab/analysis/physics/TestEvent.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,49 @@
11
package org.jlab.analysis.physics;
22

3+
import java.io.File;
34
import org.jlab.io.hipo.HipoDataEvent;
45
import org.jlab.jnp.hipo4.data.Bank;
56
import org.jlab.jnp.hipo4.data.Event;
67
import org.jlab.jnp.hipo4.data.SchemaFactory;
8+
import org.jlab.jnp.hipo4.io.HipoReader;
9+
import org.jlab.jnp.hipo4.io.HipoWriterSorted;
710

811
/**
912
*
1013
* @author naharrison
1114
*/
1215
public class TestEvent {
1316

17+
public static void main(String args[]) {
18+
writeDCSector1ElectronEvent();
19+
getDCSector1ElectronEvent(0).show();
20+
}
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();
30+
}
31+
32+
public static HipoDataEvent getDCSector1ElectronEvent(int event) {
33+
HipoReader reader = new HipoReader();
34+
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+
}
43+
}
1444

1545
public static HipoDataEvent getDCSector1ElectronEvent(SchemaFactory schemaFactory) {
16-
Event testEvent = new Event();
17-
18-
46+
Event testEvent = new Event();
1947

2048
// this event is based on a gemc event with
2149
// one generated electron with p=2.5, th=25, ph=0
Binary file not shown.

reconstruction/dc/src/test/java/org/jlab/service/dc/DCReconstructionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void testDCReconstruction() {
4141
SchemaFactory schemaFactory = new SchemaFactory();
4242
schemaFactory.initFromDirectory(dir);
4343

44-
DataEvent testEvent = TestEvent.getDCSector1ElectronEvent(schemaFactory);
44+
DataEvent testEvent = TestEvent.getDCSector1ElectronEvent(0);
4545

4646
MagFieldsEngine enf = new MagFieldsEngine();
4747
enf.init();

0 commit comments

Comments
 (0)