From c9df447e3dad905b72941d79af31e7291b9443d7 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Wed, 6 Sep 2023 18:15:43 -0400 Subject: [PATCH 1/5] refactor: combine environment for `run-groovy` and `run-jshell` --- bin/env.sh | 19 +++++++++++++++++ bin/run-groovy | 56 +++++++------------------------------------------- bin/run-jshell | 53 +++++++---------------------------------------- 3 files changed, 33 insertions(+), 95 deletions(-) diff --git a/bin/env.sh b/bin/env.sh index b674cceef..3d15544c1 100644 --- a/bin/env.sh +++ b/bin/env.sh @@ -13,3 +13,22 @@ if [ -z "$COAT_MAGFIELD_SOLENOIDMAP" ]; then export COAT_MAGFIELD_SOLENOIDMAP=Symm_solenoid_r601_phi1_z1201_13June2018.dat fi +# additional environment variables for groovy or interactive use +# - call as `source $0 groovy` or `source $0 jshell` +if [ $# -ge 1 ]; then + + # add jar files to class path + for lib in clas services utils; do + for jars in $(ls -a $CLAS12DIR/lib/$lib/*.jar); do + JYPATH="${JYPATH:+${JYPATH}:}${jars}" + done + done + + # additional variables and settings for groovy + if [ "$1" == "groovy" ]; then + JYPATH="${JYPATH:+${JYPATH}:}${CLAS12DIR}/lib/packages" + export JAVA_OPTS="-Dsun.java2d.pmoffscreen=false -Djava.util.logging.config.file=$CLAS12DIR/etc/logging/debug.properties -Xms1024m -Xmx2048m -XX:+UseSerialGC" + fi + + export JYPATH +fi diff --git a/bin/run-groovy b/bin/run-groovy index 08aafb960..c08edddeb 100755 --- a/bin/run-groovy +++ b/bin/run-groovy @@ -1,53 +1,11 @@ #!/bin/sh -. `dirname $0`/env.sh +. `dirname $0`/env.sh groovy + +echo """ +**************************************** +* Running COATJAVA Groovy Script * +**************************************** +""" -export CLAS12DIR=`dirname $0`/.. - -#-------------------------------------------------------------- -# Adding supporting COAT jar files -for i in `ls -a $CLAS12DIR/lib/clas/*.jar` -do -#echo "$i" -if [ -z "${JYPATH}" ] ; then -JYPATH="$i" -else -JYPATH=${JYPATH}:"$i" -fi -done -#-------------------------------------------------------------- -# Adding supporting plugins directory -for i in `ls -a $CLAS12DIR/lib/services/*.jar` -do -if [ -z "${JYPATH}" ] ; then -JYPATH="$i" -else -JYPATH=${JYPATH}:"$i" -fi -done -#-------------------------------------------------------------- -# Adding supporting plugins directory -#-------------------------------------------------------------- -# Done loading plugins -#-------------------------------------------------------------- -# Adding supporting plugins directory -for i in `ls -a $CLAS12DIR/lib/utils/*.jar` -do -if [ -z "${JYPATH}" ] ; then -JYPATH="$i" -else -JYPATH=${JYPATH}:"$i" -fi -done -#------------------------------------------------------------- -JYPATH=${JYPATH}:${CLAS12DIR}/lib/packages -echo " " -echo " " -echo "*****************************************" -echo "* Running COAT-JAVA Groovy Scripts *" -echo "* Version : 3a Release : 2016 *" -echo "*****************************************" -echo " " -echo " " -export JAVA_OPTS="-Dsun.java2d.pmoffscreen=false -Djava.util.logging.config.file=$CLAS12DIR/etc/logging/debug.properties -Xms1024m -Xmx2048m -XX:+UseSerialGC" groovy -cp "$JYPATH" "$@" diff --git a/bin/run-jshell b/bin/run-jshell index 562383da8..bad9003b4 100755 --- a/bin/run-jshell +++ b/bin/run-jshell @@ -1,50 +1,11 @@ #!/bin/sh -. `dirname $0`/env.sh +. `dirname $0`/env.sh jshell + +echo """ +********************************* +* Running COATJAVA JShell * +********************************* +""" -export CLAS12DIR=`dirname $0`/.. - -#-------------------------------------------------------------- -# Adding supporting COAT jar files -for i in `ls -a $CLAS12DIR/lib/clas/*.jar` -do -#echo "$i" -if [ -z "${JYPATH}" ] ; then -JYPATH="$i" -else -JYPATH=${JYPATH}:"$i" -fi -done -#-------------------------------------------------------------- -# Adding supporting plugins directory -for i in `ls -a $CLAS12DIR/lib/services/*.jar` -do -if [ -z "${JYPATH}" ] ; then -JYPATH="$i" -else -JYPATH=${JYPATH}:"$i" -fi -done -#-------------------------------------------------------------- -# Adding supporting plugins directory -#-------------------------------------------------------------- -# Done loading plugins -#-------------------------------------------------------------- -# Adding supporting plugins directory -for i in `ls -a $CLAS12DIR/lib/utils/*.jar` -do -if [ -z "${JYPATH}" ] ; then -JYPATH="$i" -else -JYPATH=${JYPATH}:"$i" -fi -done -#------------------------------------------------------------- -echo " " -echo " " -echo "*****************************************" -echo "* Running COAT-JAVA JShell Scripts *" -echo "*****************************************" -echo " " -echo " " jshell --class-path "$JYPATH" "$@" From f1d948fbe2e26bd875bb81b6c49df436a08d3644 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Wed, 6 Sep 2023 18:26:32 -0400 Subject: [PATCH 2/5] fix: do nothing if arg is not `groovy` or `jshell` --- bin/env.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/bin/env.sh b/bin/env.sh index 3d15544c1..e3768b0a0 100644 --- a/bin/env.sh +++ b/bin/env.sh @@ -16,19 +16,22 @@ fi # additional environment variables for groovy or interactive use # - call as `source $0 groovy` or `source $0 jshell` if [ $# -ge 1 ]; then + if [ "$1" == "groovy" -o "$1" == "jshell" ]; then - # add jar files to class path - for lib in clas services utils; do - for jars in $(ls -a $CLAS12DIR/lib/$lib/*.jar); do - JYPATH="${JYPATH:+${JYPATH}:}${jars}" + # add jar files to class path + for lib in clas services utils; do + for jars in $(ls -a $CLAS12DIR/lib/$lib/*.jar); do + JYPATH="${JYPATH:+${JYPATH}:}${jars}" + done done - done - # additional variables and settings for groovy - if [ "$1" == "groovy" ]; then - JYPATH="${JYPATH:+${JYPATH}:}${CLAS12DIR}/lib/packages" - export JAVA_OPTS="-Dsun.java2d.pmoffscreen=false -Djava.util.logging.config.file=$CLAS12DIR/etc/logging/debug.properties -Xms1024m -Xmx2048m -XX:+UseSerialGC" - fi + # additional variables and settings for groovy + if [ "$1" == "groovy" ]; then + JYPATH="${JYPATH:+${JYPATH}:}${CLAS12DIR}/lib/packages" + export JAVA_OPTS="-Dsun.java2d.pmoffscreen=false -Djava.util.logging.config.file=$CLAS12DIR/etc/logging/debug.properties -Xms1024m -Xmx2048m -XX:+UseSerialGC" + fi + + export JYPATH - export JYPATH + fi fi From 6ffbdc723bde0836624689002102f1f235daba47 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Wed, 6 Sep 2023 18:34:57 -0400 Subject: [PATCH 3/5] feat: run Groovy Shell with `coatjava` --- bin/run-groovysh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 bin/run-groovysh diff --git a/bin/run-groovysh b/bin/run-groovysh new file mode 100755 index 000000000..b2b11c62d --- /dev/null +++ b/bin/run-groovysh @@ -0,0 +1,11 @@ +#!/bin/sh + +. `dirname $0`/env.sh groovy + +echo """ +*************************************** +* Running COATJAVA Groovy Shell * +*************************************** +""" + +groovysh -cp "$JYPATH" "$@" From ab6d22393c24cbf364eb34ac5777a3ceb660b816 Mon Sep 17 00:00:00 2001 From: mariangela-bondi Date: Fri, 4 Aug 2023 15:22:13 +0200 Subject: [PATCH 4/5] fix strip geo bug and new uRwell position --- .../geant4/v2/URWELL/URWellConstants.java | 4 +- .../geant4/v2/URWELL/URWellStripFactory.java | 38 ++++++++++++++++++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java index 4d99e1601..8e1455e17 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java @@ -43,7 +43,7 @@ public class URWellConstants { "support_skin1_g10", "support_honeycomb_nomex", "support_skin2_g10"}; // URWELL position in the CLAS12 frame - public final static double TGT2DC0 = 228.078; // cm + public final static double TGT2DC0 = 230.078; // cm // public final static double URWELL2DC0 = 2; // cm public final static double URWELL2DC0[] = new double[NMAXREGIONS]; public final static double DIST2TGT[] = new double[NMAXREGIONS]; @@ -116,7 +116,7 @@ public static synchronized void load( DatabaseConstantProvider cp ) for (int i=0; i y = mx +c; double stereoAngle = URWellConstants.STEREOANGLE; - if (layer % 2 == 0) { + if (layer % 2 != 0) { stereoAngle = -URWellConstants.STEREOANGLE; } double m = Math.tan(Math.toRadians(stereoAngle)); @@ -252,6 +252,32 @@ private Line3d createStrip(int sector, int layer, int strip) { } } + /** + * Provides the given strip line in the Chamber local frame + * @param region (1-2) + * @param sector (1-6) + * @param layer (1-4) + * @param strip (1-N) + * @return the 3D strip line as a Line3d + */ + + private Line3d getChamberStrip(int region, int sector, int chamber, int layer, int strip) { + + + Line3d globalStrip = createStrip(sector, layer, strip); + Geant4Basic chamberVolume = factory.getChamberVolume(sector, chamber, layer, isProto); + + Vector3d origin = chamberVolume.getGlobalTransform().invert().transform(globalStrip.origin()); + Vector3d end = chamberVolume.getGlobalTransform().invert().transform(globalStrip.end()); + + Line3d localStrip = new Line3d(origin, end); + + + return localStrip; + } + + + /** * Provides the given strip line in the sector local frame * @param sector (1-6) @@ -411,11 +437,19 @@ public static void main(String[] args) { URWellGeant4Factory factory = new URWellGeant4Factory(cp,true,2); - URWellStripFactory factory2 = new URWellStripFactory(cp,false,1); + URWellStripFactory factory2 = new URWellStripFactory(cp,true,1); Plane3D plane = factory2.getPlane(6, 1, 200); System.out.println(plane.toString()); + int strip =20; + System.out.println((strip) + " " + factory2.getLocalStripId(strip) + "\n" + factory2.getChamberStrip(1, 6,1,2,strip)) ; + + + // for(int istrip=0; istrip Date: Thu, 31 Aug 2023 14:16:10 +0200 Subject: [PATCH 5/5] restore original position urwell detector 1 --- .../geant4/v2/URWELL/URWellConstants.java | 17 +++++++++-------- .../geant4/v2/URWELL/URWellGeant4Factory.java | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java index 8e1455e17..81b08bf56 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java @@ -43,7 +43,7 @@ public class URWellConstants { "support_skin1_g10", "support_honeycomb_nomex", "support_skin2_g10"}; // URWELL position in the CLAS12 frame - public final static double TGT2DC0 = 230.078; // cm + public final static double TGT2DC0 = 228.078; // cm // public final static double URWELL2DC0 = 2; // cm public final static double URWELL2DC0[] = new double[NMAXREGIONS]; public final static double DIST2TGT[] = new double[NMAXREGIONS]; @@ -115,13 +115,14 @@ public static synchronized void load( DatabaseConstantProvider cp ) // NREGIONS = cp.getInteger( CCDBPATH+"svt/nRegions", 0 ); for (int i=0; i { System.out.println(volume.gemcString());