Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,62 @@
package org.jlab.analysis.physics;

import org.jlab.detector.base.DetectorType;
import org.jlab.io.hipo.HipoDataEvent;
import org.jlab.jnp.hipo4.data.Bank;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.jnp.hipo4.io.HipoReader;
import org.jlab.jnp.hipo4.io.HipoWriterSorted;
import org.jlab.utils.CLASResources;

/**
*
* @author naharrison
*/
public class TestEvent {

public static void main(String args[]) {
write();
//getDCSector1ElectronEvent(0).show();
}

public static HipoDataEvent get(DetectorType t) {
HipoReader reader = new HipoReader();
String dir = CLASResources.getResourcePath("etc/data/test");
String stub = t.getName().toLowerCase();
reader.open(String.format("%s/%s.hipo",dir,stub));
Event e = new Event();
reader.getEvent(e, 0);
return new HipoDataEvent(e,reader.getSchemaFactory());
}

private static void write() {
SchemaFactory sf = new SchemaFactory();
sf.initFromDirectory(CLASResources.getResourcePath("etc/bankdefs/hipo4"));
write( "dc.hipo",getDCSector1ElectronEvent(sf).getHipoEvent());
write( "cvt.hipo",getCVTTestEvent(sf).getHipoEvent());
write( "ecal.hipo",getECSector1PhotonEvent(sf).getHipoEvent());
}

private static void write(String path, Event e) {
try (HipoWriterSorted writer = new HipoWriterSorted()) {
writer.setCompressionType(2);
writer.getSchemaFactory().initFromDirectory(CLASResources.getResourcePath("etc/bankdefs/hipo4"));
writer.open(path);
writer.addEvent(e);
}
}

public static HipoDataEvent getDCSector1ElectronEvent(int event) {
HipoReader reader = new HipoReader();
reader.open(CLASResources.getResourcePath("etc/data/test/dc.hipo"));
Event e = new Event();
reader.getEvent(e, event);
return new HipoDataEvent(e,reader.getSchemaFactory());
}

public static HipoDataEvent getDCSector1ElectronEvent(SchemaFactory schemaFactory) {
Event testEvent = new Event();


Event testEvent = new Event();

// this event is based on a gemc event with
// one generated electron with p=2.5, th=25, ph=0
Expand Down Expand Up @@ -276,7 +317,6 @@ public static HipoDataEvent getCVTTestEvent(SchemaFactory schemaFactory) {
return hipoEvent;
}


public static HipoDataEvent getECSector1PhotonEvent(SchemaFactory schemaFactory) {
Event testEvent = new Event();
Bank config = new Bank(schemaFactory.getSchema("RUN::config"), 1);
Expand Down
Binary file added etc/data/test/cvt.hipo
Binary file not shown.
Binary file added etc/data/test/dc.hipo
Binary file not shown.
Binary file added etc/data/test/ecal.hipo
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jlab.analysis.physics.TestEvent;
import org.jlab.analysis.math.ClasMath;
import org.jlab.clas.swimtools.MagFieldsEngine;
import org.jlab.detector.base.DetectorType;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.logging.DefaultLogger;
import org.jlab.utils.CLASResources;
Expand Down Expand Up @@ -42,7 +43,7 @@ public void testCVTReconstruction() {
SchemaFactory schemaFactory = new SchemaFactory();
schemaFactory.initFromDirectory(dir);

DataEvent testEvent = TestEvent.getCVTTestEvent(schemaFactory);
DataEvent testEvent = TestEvent.get(DetectorType.CVT);

MagFieldsEngine enf = new MagFieldsEngine();
enf.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
import org.jlab.analysis.math.ClasMath;

import org.jlab.clas.swimtools.MagFieldsEngine;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.detector.base.DetectorType;
import org.jlab.logging.DefaultLogger;
import org.jlab.utils.CLASResources;
import org.jlab.utils.system.ClasUtilsFile;

/**
*
Expand All @@ -29,19 +28,15 @@ public void testDCReconstruction() {
System.setProperty("CLAS12DIR", "../../");

String mapDir = CLASResources.getResourcePath("etc")+"/data/magfield";
try {
MagneticFields.getInstance().initializeMagneticFields(mapDir,
"Symm_torus_r2501_phi16_z251_24Apr2018.dat","Symm_solenoid_r601_phi1_z1201_13June2018.dat");
}
catch (Exception e) {
e.printStackTrace();
}

String dir = ClasUtilsFile.getResourceDir("CLAS12DIR", "etc/bankdefs/hipo4");
SchemaFactory schemaFactory = new SchemaFactory();
schemaFactory.initFromDirectory(dir);
try {
MagneticFields.getInstance().initializeMagneticFields(mapDir,
"Symm_torus_r2501_phi16_z251_24Apr2018.dat","Symm_solenoid_r601_phi1_z1201_13June2018.dat");
}
catch (Exception e) {
e.printStackTrace();
}

DataEvent testEvent = TestEvent.getDCSector1ElectronEvent(schemaFactory);
DataEvent testEvent = TestEvent.get(DetectorType.DC);

MagFieldsEngine enf = new MagFieldsEngine();
enf.init();
Expand Down Expand Up @@ -72,7 +67,6 @@ public void testDCReconstruction() {
if(testEvent.hasBank("TimeBasedTrkg::TBTracks")) {
testEvent.getBank("TimeBasedTrkg::TBTracks").show();
}


assertEquals(testEvent.hasBank("TimeBasedTrkg::TBTracks"), true);
assertEquals(testEvent.getBank("TimeBasedTrkg::TBTracks").rows(), 1);
Expand All @@ -90,7 +84,6 @@ public void testDCReconstruction() {
assertEquals(testEvent.getBank("TimeBasedTrkg::TBTracks").getFloat("Vtx0_z", 0) < 0.885, true);
assertEquals(testEvent.getBank("TimeBasedTrkg::TBTracks").getFloat("Vtx0_z", 0) > -0.0753, true);


//Region 1
assertEquals(ClasMath.isWithinXPercent(155, testEvent.getBank("TimeBasedTrkg::TBCrosses").getFloat("x", 0), 4.02), true);
assertEquals(testEvent.getBank("TimeBasedTrkg::TBCrosses").getFloat("y", 0 ) < 9.25, true);
Expand All @@ -106,7 +99,6 @@ public void testDCReconstruction() {
assertEquals(ClasMath.isWithinXPercent(127, testEvent.getBank("TimeBasedTrkg::TBCrosses").getFloat("x", 2), -11.0), true);
assertEquals(testEvent.getBank("TimeBasedTrkg::TBCrosses").getFloat("y", 2 ) < 17.96, true);
assertEquals(testEvent.getBank("TimeBasedTrkg::TBCrosses").getFloat("y", 2 ) > -23.66, true);


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.jlab.analysis.math.ClasMath;
import org.jlab.clas.swimtools.MagFieldsEngine;
import cnuphys.magfield.MagneticFields;
import org.jlab.detector.base.DetectorType;

import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
Expand Down Expand Up @@ -116,7 +117,7 @@ public void testEBReconstruction() {
SchemaFactory schemaFactory = new SchemaFactory();
schemaFactory.initFromDirectory(dir);

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

DataEvent electronEvent = TestEvent.getDCSector1ElectronEvent(schemaFactory);
DataEvent electronEvent = TestEvent.get(DetectorType.DC);
processAllEngines(electronEvent);
assertEquals(electronEvent.hasBank("REC::Event"), true);
assertEquals(electronEvent.hasBank("REC::Particle"), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jlab.io.base.DataEvent;

import org.jlab.analysis.physics.TestEvent;
import org.jlab.detector.base.DetectorType;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.logging.DefaultLogger;
import org.jlab.utils.system.ClasUtilsFile;
Expand All @@ -26,7 +27,7 @@ public void testECReconstruction() {
SchemaFactory schemaFactory = new SchemaFactory();
schemaFactory.initFromDirectory(dir);

DataEvent testEvent = TestEvent.getECSector1PhotonEvent(schemaFactory);
DataEvent testEvent = TestEvent.get(DetectorType.ECAL);

ECEngine engineEC = new ECEngine();
engineEC.init();
Expand Down
Loading