Skip to content

Commit ac9c27c

Browse files
committed
move all to event files
1 parent 4f1dbe6 commit ac9c27c

File tree

7 files changed

+33
-12
lines changed

7 files changed

+33
-12
lines changed

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jlab.analysis.physics;
22

3+
import org.jlab.detector.base.DetectorType;
34
import org.jlab.io.hipo.HipoDataEvent;
45
import org.jlab.jnp.hipo4.data.Bank;
56
import org.jlab.jnp.hipo4.data.Event;
@@ -15,19 +16,36 @@
1516
public class TestEvent {
1617

1718
public static void main(String args[]) {
18-
//writeDCSector1ElectronEvent();
19-
getDCSector1ElectronEvent(0).show();
19+
write();
20+
//getDCSector1ElectronEvent(0).show();
2021
}
2122

22-
public static void writeDCSector1ElectronEvent(String path) {
23+
public static HipoDataEvent get(DetectorType t) {
24+
HipoReader reader = new HipoReader();
25+
String dir = CLASResources.getResourcePath("etc/data/test");
26+
String stub = t.getName().toLowerCase();
27+
reader.open(String.format("%s/%s.hipo",dir,stub));
28+
Event e = new Event();
29+
reader.getEvent(e, 0);
30+
return new HipoDataEvent(e,reader.getSchemaFactory());
31+
}
32+
33+
private static void write() {
34+
SchemaFactory sf = new SchemaFactory();
35+
sf.initFromDirectory(CLASResources.getResourcePath("etc/bankdefs/hipo4"));
36+
write( "dc.hipo",getDCSector1ElectronEvent(sf).getHipoEvent());
37+
write( "cvt.hipo",getCVTTestEvent(sf).getHipoEvent());
38+
write( "ecal.hipo",getECSector1PhotonEvent(sf).getHipoEvent());
39+
}
40+
41+
private static void write(String path, Event e) {
2342
try (HipoWriterSorted writer = new HipoWriterSorted()) {
2443
writer.setCompressionType(2);
2544
writer.getSchemaFactory().initFromDirectory(CLASResources.getResourcePath("etc/bankdefs/hipo4"));
2645
writer.open(path);
27-
HipoDataEvent e = getDCSector1ElectronEvent(writer.getSchemaFactory());
28-
writer.addEvent(e.getHipoEvent());
46+
writer.addEvent(e);
2947
}
30-
}
48+
}
3149

3250
public static HipoDataEvent getDCSector1ElectronEvent(int event) {
3351
HipoReader reader = new HipoReader();
@@ -299,7 +317,6 @@ public static HipoDataEvent getCVTTestEvent(SchemaFactory schemaFactory) {
299317
return hipoEvent;
300318
}
301319

302-
303320
public static HipoDataEvent getECSector1PhotonEvent(SchemaFactory schemaFactory) {
304321
Event testEvent = new Event();
305322
Bank config = new Bank(schemaFactory.getSchema("RUN::config"), 1);

etc/data/test/cvt.hipo

316 KB
Binary file not shown.

etc/data/test/ecal.hipo

317 KB
Binary file not shown.

reconstruction/cvt/src/test/java/org/jlab/rec/cvt/services/CVTReconstructionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.jlab.analysis.physics.TestEvent;
1212
import org.jlab.analysis.math.ClasMath;
1313
import org.jlab.clas.swimtools.MagFieldsEngine;
14+
import org.jlab.detector.base.DetectorType;
1415
import org.jlab.jnp.hipo4.data.SchemaFactory;
1516
import org.jlab.logging.DefaultLogger;
1617
import org.jlab.utils.CLASResources;
@@ -42,7 +43,7 @@ public void testCVTReconstruction() {
4243
SchemaFactory schemaFactory = new SchemaFactory();
4344
schemaFactory.initFromDirectory(dir);
4445

45-
DataEvent testEvent = TestEvent.getCVTTestEvent(schemaFactory);
46+
DataEvent testEvent = TestEvent.get(DetectorType.CVT);
4647

4748
MagFieldsEngine enf = new MagFieldsEngine();
4849
enf.init();

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.jlab.analysis.math.ClasMath;
1111

1212
import org.jlab.clas.swimtools.MagFieldsEngine;
13+
import org.jlab.detector.base.DetectorType;
1314
import org.jlab.logging.DefaultLogger;
1415
import org.jlab.utils.CLASResources;
1516

@@ -35,7 +36,7 @@ public void testDCReconstruction() {
3536
e.printStackTrace();
3637
}
3738

38-
DataEvent testEvent = TestEvent.getDCSector1ElectronEvent(0);
39+
DataEvent testEvent = TestEvent.get(DetectorType.DC);
3940

4041
MagFieldsEngine enf = new MagFieldsEngine();
4142
enf.init();

reconstruction/eb/src/test/java/org/jlab/service/eb/EBReconstructionTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.jlab.analysis.math.ClasMath;
88
import org.jlab.clas.swimtools.MagFieldsEngine;
99
import cnuphys.magfield.MagneticFields;
10+
import org.jlab.detector.base.DetectorType;
1011

1112
import org.jlab.io.base.DataBank;
1213
import org.jlab.io.base.DataEvent;
@@ -116,7 +117,7 @@ public void testEBReconstruction() {
116117
SchemaFactory schemaFactory = new SchemaFactory();
117118
schemaFactory.initFromDirectory(dir);
118119

119-
DataEvent photonEvent = TestEvent.getECSector1PhotonEvent(schemaFactory);
120+
DataEvent photonEvent = TestEvent.get(DetectorType.ECAL);
120121
processAllEngines(photonEvent);
121122
assertEquals(photonEvent.hasBank("RECHB::Event"), true);
122123
assertEquals(photonEvent.hasBank("RECHB::Particle"), true);
@@ -132,7 +133,7 @@ public void testEBReconstruction() {
132133
assertEquals(photonEvent.getBank("RECHB::Particle").getFloat("py", 0) < 0.15, true);
133134
assertEquals(ClasMath.isWithinXPercent(25.0, photonEvent.getBank("RECHB::Particle").getFloat("pz", 0), 2.266), true);
134135

135-
DataEvent electronEvent = TestEvent.getDCSector1ElectronEvent(schemaFactory);
136+
DataEvent electronEvent = TestEvent.get(DetectorType.DC);
136137
processAllEngines(electronEvent);
137138
assertEquals(electronEvent.hasBank("REC::Event"), true);
138139
assertEquals(electronEvent.hasBank("REC::Particle"), true);

reconstruction/ec/src/test/java/org/jlab/service/ec/ECReconstructionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.jlab.io.base.DataEvent;
77

88
import org.jlab.analysis.physics.TestEvent;
9+
import org.jlab.detector.base.DetectorType;
910
import org.jlab.jnp.hipo4.data.SchemaFactory;
1011
import org.jlab.logging.DefaultLogger;
1112
import org.jlab.utils.system.ClasUtilsFile;
@@ -26,7 +27,7 @@ public void testECReconstruction() {
2627
SchemaFactory schemaFactory = new SchemaFactory();
2728
schemaFactory.initFromDirectory(dir);
2829

29-
DataEvent testEvent = TestEvent.getECSector1PhotonEvent(schemaFactory);
30+
DataEvent testEvent = TestEvent.get(DetectorType.ECAL);
3031

3132
ECEngine engineEC = new ECEngine();
3233
engineEC.init();

0 commit comments

Comments
 (0)