From 0d6e1ff85d417456aed87c1500c7851cb94df97c Mon Sep 17 00:00:00 2001 From: Nathan Harrison Date: Tue, 18 Jul 2017 17:35:40 -0400 Subject: [PATCH 1/4] Commented out annoying print message --- .../src/main/java/org/jlab/clas/detector/DetectorParticle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java index 4f16d93ba2..7d389a8f6f 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java @@ -629,7 +629,7 @@ public int getCalorimeterHit(List hitList, DetectorType ty double distanceThreshold){ Line3D trajectory = this.detectorTrack.getLastCross(); - System.out.println("find hit in array size = "+ hitList.size()); + //System.out.println("find hit in array size = "+ hitList.size()); Point3D hitPoint = new Point3D(); double minimumDistance = 500.0; int bestIndex = -1; From a768d2d04d3bfb2efb3435c8b5ab60338a5d499d Mon Sep 17 00:00:00 2001 From: Nathan Harrison Date: Tue, 18 Jul 2017 22:33:24 -0400 Subject: [PATCH 2/4] Added CVT unit test --- validation/unit-tests/run-unit-tests.sh | 7 ++ .../src/cvt/CVTReconstructionTest.java | 53 +++++++++++++ .../unit-tests/src/events/TestEvent.java | 77 +++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 validation/unit-tests/src/cvt/CVTReconstructionTest.java diff --git a/validation/unit-tests/run-unit-tests.sh b/validation/unit-tests/run-unit-tests.sh index d8898e0265..06d44921f8 100755 --- a/validation/unit-tests/run-unit-tests.sh +++ b/validation/unit-tests/run-unit-tests.sh @@ -17,6 +17,9 @@ if [ $? != 0 ] ; then echo "RandomEventGenerator compilation failure" ; exit 1 ; javac -cp $classPath src/dc/DCReconstructionTest.java if [ $? != 0 ] ; then echo "DCReconstructionTest compilation failure" ; exit 1 ; fi +javac -cp $classPath src/cvt/CVTReconstructionTest.java +if [ $? != 0 ] ; then echo "CVTReconstructionTest compilation failure" ; exit 1 ; fi + javac -cp $classPath src/ec/ECReconstructionTest.java if [ $? != 0 ] ; then echo "ECReconstructionTest compilation failure" ; exit 1 ; fi @@ -25,6 +28,10 @@ if [ $? != 0 ] ; then echo "ECReconstructionTest compilation failure" ; exit 1 ; java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore dc.DCReconstructionTest if [ $? != 0 ] ; then echo "dc unit test failure" ; exit 1 ; else echo "dc passed unit tests" ; fi +# run cvt junit tests +java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore cvt.CVTReconstructionTest +if [ $? != 0 ] ; then echo "cvt unit test failure" ; exit 1 ; else echo "cvt passed unit tests" ; fi + # run ec junit tests java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore ec.ECReconstructionTest if [ $? != 0 ] ; then echo "ec unit test failure" ; exit 1 ; else echo "ec passed unit tests" ; fi diff --git a/validation/unit-tests/src/cvt/CVTReconstructionTest.java b/validation/unit-tests/src/cvt/CVTReconstructionTest.java new file mode 100644 index 0000000000..6419b3ff4a --- /dev/null +++ b/validation/unit-tests/src/cvt/CVTReconstructionTest.java @@ -0,0 +1,53 @@ +package cvt; + +import org.junit.Test; +import static org.junit.Assert.*; + +import events.TestEvent; + +import org.jlab.io.base.DataEvent; +import org.jlab.rec.cvt.services.CVTReconstruction; +import org.jlab.service.eb.EBHBEngine; +import org.jlab.service.eb.EBTBEngine; + +/** + * + * @author naharrison + */ +public class CVTReconstructionTest { + + @Test + public void testCVTReconstruction() { + + DataEvent testEvent = TestEvent.getCVTTestEvent(); + + CVTReconstruction CVTengine = new CVTReconstruction(); + CVTengine.init(); + CVTengine.processDataEvent(testEvent); + + EBHBEngine EBHBengine = new EBHBEngine(); + EBHBengine.init(); + EBHBengine.processDataEvent(testEvent); + + EBTBEngine EBTBengine = new EBTBEngine(); + EBTBengine.init(); + EBTBengine.processDataEvent(testEvent); + + assertEquals(testEvent.hasBank("REC::Particle"), true); + assertEquals(testEvent.getBank("REC::Particle").rows(), 1); + assertEquals(testEvent.getBank("REC::Particle").getByte("charge", 0), 1); + assertEquals(isWithinXPercent(10.0, testEvent.getBank("REC::Particle").getFloat("px", 0), -0.375), true); + assertEquals(isWithinXPercent(10.0, testEvent.getBank("REC::Particle").getFloat("py", 0), 0.483), true); + assertEquals(isWithinXPercent(10.0, testEvent.getBank("REC::Particle").getFloat("pz", 0), 0.674), true); + assertEquals(isWithinXPercent(30.0, testEvent.getBank("REC::Particle").getFloat("vz", 0), -13.9), true); + } + + + public static boolean isWithinXPercent(double X, double val, double standard) { + if(standard >= 0 && val > (1.0 - (X/100.0))*standard && val < (1.0 + (X/100.0))*standard) return true; + else if(standard < 0 && val < (1.0 - (X/100.0))*standard && val > (1.0 + (X/100.0))*standard) return true; + return false; + } + + +} diff --git a/validation/unit-tests/src/events/TestEvent.java b/validation/unit-tests/src/events/TestEvent.java index 24e2b0cb58..486885a6e3 100644 --- a/validation/unit-tests/src/events/TestEvent.java +++ b/validation/unit-tests/src/events/TestEvent.java @@ -123,6 +123,83 @@ public static HipoDataEvent getDCSector1ElectronEvent() { } + public static HipoDataEvent getCVTTestEvent() { + HipoDataSync writer = new HipoDataSync(); + HipoDataEvent testEvent = (HipoDataEvent) writer.createEvent(); + DataBank config = testEvent.createBank("RUN::config", 1); + DataBank SVTadc = testEvent.createBank("SVT::adc", 7); + + // this event is based on a gemc (4a.1.1 aka 4a.2.0) event with + // torus = -1.0 , solenoid = 1.0 + //