From f2aba9ca231d27e529632ef26909713126fbc159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariangela=20Bond=C3=AD?= Date: Thu, 29 Jan 2026 08:54:54 +0100 Subject: [PATCH 1/6] new MUVT and URWT geometry --- .../geant4/v2/MUVT/MUVTConstants.java | 50 ++ .../geant4/v2/MUVT/MUVTGeant4Factory.java | 67 ++ .../geant4/v2/MUVT/MUVTStripFactory.java | 103 +++ .../geant4/v2/URWT/URWTConstants.java | 50 ++ .../geant4/v2/URWT/URWTGeant4Factory.java | 96 +++ .../geant4/v2/URWT/URWTStripFactory.java | 106 +++ .../AbstractMPGDTrapezoidConstants.java | 217 ++++++ .../AbstractMPGDTrapezoidGeant4Factory.java | 350 +++++++++ .../AbstractMPGDTrapezoidStripFactory.java | 674 ++++++++++++++++++ 9 files changed, 1713 insertions(+) create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTConstants.java create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTGeant4Factory.java create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTStripFactory.java create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTConstants.java create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTGeant4Factory.java create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidConstants.java create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidGeant4Factory.java create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidStripFactory.java diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTConstants.java new file mode 100644 index 0000000000..0504e77f7d --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTConstants.java @@ -0,0 +1,50 @@ +package org.jlab.detector.geant4.v2.MUVT; + +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidConstants; + +/** + * URWT-specific constants. + */ +public final class MUVTConstants extends AbstractMPGDTrapezoidConstants { + + + private static final MUVTConstants INSTANCE = + new MUVTConstants( + "/test/muvt/", // CCDB base path + "muvt_global", // global table name + "muvt_material" // material table name + ); + + /** + * Private constructor: only the singleton instance is used. + */ + private MUVTConstants(String ccdbPath, + String globalTable, + String materialTable) { + super(ccdbPath, globalTable, materialTable); + } + + /** + * Returns the singleton instance for URWT constants. + * @return + */ + public static MUVTConstants getInstance() { + return INSTANCE; + } + + /** + * Convenience method to load URWT constants using the given + * {@link DatabaseConstantProvider}.Usage: + DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); + URWTConstants.connect(cp); + // now MUVTConstants.getInstance() is fully initialized + * + * @param cp + * @return + */ + public static DatabaseConstantProvider connect(DatabaseConstantProvider cp) { + return INSTANCE.loadFrom(cp); + } + +} diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTGeant4Factory.java new file mode 100644 index 0000000000..60aafe9f56 --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTGeant4Factory.java @@ -0,0 +1,67 @@ +package org.jlab.detector.geant4.v2.MUVT; + +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidGeant4Factory; + +/** + * Geant4 factory for the muCLAS Forward Vertex Tracker (muVT). + * + * This class specializes the generic + * {@link AbstractMPGDTrapezoidGeant4Factory} by: + * - passing the MUVT-specific constants + * - using "MUVT" as detector name in volume names + * + * All the geometry construction (sectors, regions, material stack) + * is implemented in the base class. + */ +public final class MUVTGeant4Factory extends AbstractMPGDTrapezoidGeant4Factory { + + private final String variation; + + public MUVTGeant4Factory(DatabaseConstantProvider cp, String variation) { + super(MUVTConstants.getInstance(), "muvt"); + this.variation = variation; + MUVTConstants.connect(cp); + init(); + } + + public MUVTGeant4Factory(String variation, int run) { + super(MUVTConstants.getInstance(), "muvt"); + this.variation = variation; + + DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); + MUVTConstants.connect(cp); + cp.disconnect(); + + init(); + } + + + public static void main(String[] args) { + + int run = 11; + String variation = "default"; + + if (args.length > 0) { + try { + run = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + System.err.println("Invalid run number \"" + args[0] + "\", using default 11."); + } + } + if (args.length > 1) { + variation = args[1]; + } + + MUVTGeant4Factory factory = new MUVTGeant4Factory(variation, run); + + System.out.println("MUVT geometry for run " + run + " (variation=\"" + variation + "\")"); + System.out.println("Total volumes: " + factory.getAllVolumes().size()); + + factory.getAllVolumes().forEach(volume -> { + System.out.println(volume.gemcString()); + }); + } +} + + diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTStripFactory.java new file mode 100644 index 0000000000..162bdc8adf --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTStripFactory.java @@ -0,0 +1,103 @@ +package org.jlab.detector.geant4.v2.MUVT; + +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidStripFactory; +import org.jlab.detector.volume.Geant4Basic; + +import java.util.HashMap; +import java.util.Map; + +/** + * MUVT strip factory. + * + * It relies entirely on AbstractMPGDTrapezoidStripFactory for: + * - strip building (component IDs, endpoints) + * - surfaces + * - planes + * + * The ONLY detector-specific thing here is the mapping "volume name -> Geant4Basic", + * used by the abstract class to find the sensitive volume (Sensitivity==1) and its transform. + */ +public final class MUVTStripFactory extends AbstractMPGDTrapezoidStripFactory { + + private final Map volumeByName = new HashMap<>(); + + /** + * Build using an already-configured DatabaseConstantProvider. + */ +public MUVTStripFactory(DatabaseConstantProvider cp, String variation) { + super(MUVTConstants.getInstance(), new MUVTGeant4Factory(cp, variation)); + + MUVTConstants.connect(cp); + + for (Geant4Basic v : geo.getAllVolumes()) { + if (v.getName() != null) { + volumeByName.put(v.getName(), v); + } + } + + buildAll(); +} + + /** + * Convenience constructor: internally creates a DatabaseConstantProvider. + */ + public MUVTStripFactory(String variation, int run) { + super(MUVTConstants.getInstance(), new MUVTGeant4Factory(variation, run)); + + DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); + MUVTConstants.connect(cp); + cp.disconnect(); + + for (Geant4Basic v : geo.getAllVolumes()) { + if (v.getName() != null) { + volumeByName.put(v.getName(), v); + } + } + + buildAll(); + } + + @Override + protected Geant4Basic getVolumeByName(String name) { + return volumeByName.get(name); + } + + + @Override + protected boolean is2DReadout() { + // change to true if your MUVT readout is truly 2D + return true; + } + + /** + * Small test / debug. + */ + public static void main(String[] args) { + + int run = 11; + String variation = "default"; + + if (args.length > 0) { + try { run = Integer.parseInt(args[0]); } catch (Exception ignored) {} + } + if (args.length > 1) variation = args[1]; + + MUVTStripFactory sf = new MUVTStripFactory(variation, run); + + int sector = 2; + int layer = 12; + + System.out.println("MUVT strips: sector=" + sector + " layer=" + layer + + " nComponents=" + sf.getNComponents(sector, layer)); + + // print first strip global/local/tilted + int comp = 10; + System.out.println("Global strip(1): " + sf.getStrip(sector, layer, comp)); + System.out.println("Local strip(1): " + sf.getStripLocal(sector, layer, comp)); + System.out.println("Tilted strip(1): " + sf.getStripTilted(sector, layer, comp)); + + System.out.println("Plane: " + sf.getPlane(sector, layer)); + System.out.println("Surface: " + sf.getSurface(sector, layer)); + } +} diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTConstants.java new file mode 100644 index 0000000000..331c1434fd --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTConstants.java @@ -0,0 +1,50 @@ +package org.jlab.detector.geant4.v2.URWT; + +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidConstants; + +/** + * URWT-specific constants. + */ +public final class URWTConstants extends AbstractMPGDTrapezoidConstants { + + + private static final URWTConstants INSTANCE = + new URWTConstants( + "/test/urwt/", // CCDB base path + "urwt_global", // global table name + "urwt_material" // material table name + ); + + /** + * Private constructor: only the singleton instance is used. + */ + private URWTConstants(String ccdbPath, + String globalTable, + String materialTable) { + super(ccdbPath, globalTable, materialTable); + } + + /** + * Returns the singleton instance for URWT constants. + * @return + */ + public static URWTConstants getInstance() { + return INSTANCE; + } + + /** + * Convenience method to load URWT constants using the given + * {@link DatabaseConstantProvider}.Usage: + DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); + URWTConstants.connect(cp); + // now URWTConstants.getInstance() is fully initialized + * + * @param cp + * @return + */ + public static DatabaseConstantProvider connect(DatabaseConstantProvider cp) { + return INSTANCE.loadFrom(cp); + } + +} diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTGeant4Factory.java new file mode 100644 index 0000000000..d868780f68 --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTGeant4Factory.java @@ -0,0 +1,96 @@ +package org.jlab.detector.geant4.v2.URWT; + +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidGeant4Factory; + +/** + * Geant4 factory for the uRWell Tracker (URWT). + * + * This class specializes the generic {@link AbstractMPGDTrapezoidGeant4Factory} + * by: - passing the URWT-specific constants - using "uRWT" as detector name in + * volume names + * + * All the geometry construction (sectors, regions, material stack) is + * implemented in the base class. + */ +public final class URWTGeant4Factory extends AbstractMPGDTrapezoidGeant4Factory { + + private final String variation; + + public URWTGeant4Factory(DatabaseConstantProvider cp, String variation) { + super(URWTConstants.getInstance(), "urwt"); + this.variation = variation; + URWTConstants.connect(cp); + init(); + } + + public URWTGeant4Factory(String variation, int run) { + super(URWTConstants.getInstance(), "urwt"); + this.variation = variation; + + DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); + URWTConstants.connect(cp); + cp.disconnect(); + + init(); + } + + /** + * + * @param region + * @return + */ + @Override + public SectorDimensions getSectorDimensionsPhysical(int region) { + + if (variation != null && variation.toLowerCase().contains("proto")) { + + double halfThickness = this.getSectorThickness() / 2.0; + double tiltRad = Math.toRadians(C.THTILT); + + // da vertici (mm) + double halfLargeBase = 72.71785; + double halfSmallBase = 50.44350; + double halfHeight = 24.74554; + + return new SectorDimensions(halfThickness, halfHeight, halfLargeBase, halfSmallBase, tiltRad); + } + + return super.getSectorDimensionsPhysical(region); + } + + /** + * Standalone test: builds the URWT geometry and prints all volumes in GEMC + * format. + * + * Usage: java org.jlab.detector.geant4.v2.URWT.URWTGeant4Factory [run] + * [variation] + * + * Defaults: run = 11 variation = "default" + */ + public static void main(String[] args) { + + int run = 11; + String variation = "default"; + + if (args.length > 0) { + try { + run = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + System.err.println("Invalid run number \"" + args[0] + "\", using default 11."); + } + } + if (args.length > 1) { + variation = args[1]; + } + + URWTGeant4Factory factory = new URWTGeant4Factory(variation, run); + + System.out.println("uRWT geometry for run " + run + " (variation=\"" + variation + "\")"); + System.out.println("Total volumes: " + factory.getAllVolumes().size()); + + factory.getAllVolumes().forEach(volume -> { + System.out.println(volume.gemcString()); + }); + } +} diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java new file mode 100644 index 0000000000..d1b2e934c3 --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java @@ -0,0 +1,106 @@ +package org.jlab.detector.geant4.v2.URWT; + +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidStripFactory; +import org.jlab.detector.volume.Geant4Basic; + +import java.util.HashMap; +import java.util.Map; + +/** + * URWT strip factory. + * + * It relies entirely on AbstractMPGDTrapezoidStripFactory for: + * - strip building (component IDs, endpoints) + * - surfaces + * - planes + * + * The ONLY detector-specific thing here is the mapping "volume name -> Geant4Basic", + * used by the abstract class to find the sensitive volume (Sensitivity==1) and its transform. + */ +public final class URWTStripFactory extends AbstractMPGDTrapezoidStripFactory { + + private final Map volumeByName = new HashMap<>(); + + /** + * Build using an already-configured DatabaseConstantProvider. + */ +public URWTStripFactory(DatabaseConstantProvider cp, String variation) { + super(URWTConstants.getInstance(), new URWTGeant4Factory(cp, variation)); + + URWTConstants.connect(cp); + + for (Geant4Basic v : geo.getAllVolumes()) { + if (v.getName() != null) { + volumeByName.put(v.getName(), v); + } + } + + buildAll(); +} + + /** + * Convenience constructor: internally creates a DatabaseConstantProvider. + */ + public URWTStripFactory(String variation, int run) { + super(URWTConstants.getInstance(), new URWTGeant4Factory(variation, run)); + + DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); + URWTConstants.connect(cp); + cp.disconnect(); + + for (Geant4Basic v : geo.getAllVolumes()) { + if (v.getName() != null) { + volumeByName.put(v.getName(), v); + } + } + + buildAll(); + } + + @Override + protected Geant4Basic getVolumeByName(String name) { + return volumeByName.get(name); + } + + /** + * If URWT uses 2D readout (same readout Z for both layers), enable this. + * Otherwise leave it false (default 1D: z = +/- zHalf). + */ + @Override + protected boolean is2DReadout() { + // change to true if your URWT readout is truly 2D + return false; + } + + /** + * Small test / debug. + */ + public static void main(String[] args) { + + int run = 11; + String variation = "urwt1"; + + if (args.length > 0) { + try { run = Integer.parseInt(args[0]); } catch (Exception ignored) {} + } + if (args.length > 1) variation = args[1]; + + URWTStripFactory sf = new URWTStripFactory(variation, run); + + int sector = 1; + int layer = 4; + + System.out.println("URWT strips: sector=" + sector + " layer=" + layer + + " nComponents=" + sf.getNComponents(sector, layer)); + + // print first strip global/local/tilted + int comp = 10; + System.out.println("Global strip(1): " + sf.getStrip(sector, layer, comp)); + System.out.println("Local strip(1): " + sf.getStripLocal(sector, layer, comp)); + System.out.println("Tilted strip(1): " + sf.getStripTilted(sector, layer, comp)); + + System.out.println("Plane: " + sf.getPlane(sector, layer)); + System.out.println("Surface: " + sf.getSurface(sector, layer)); + } +} diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidConstants.java new file mode 100644 index 0000000000..692b96382d --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidConstants.java @@ -0,0 +1,217 @@ +package org.jlab.detector.geant4.v2.mpgd.trapezoid; + +import org.jlab.detector.calib.utils.DatabaseConstantProvider; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.logging.Logger; + +/** + * Generic constants for trapezoidal MPGD-like trackers loaded from CCDB. + * Concrete detectors (e.g. URWT) should extend this class and provide: - CCDB + * base path - global table name - material table name + */ +public abstract class AbstractMPGDTrapezoidConstants { + + // ------------------------------------------------------------------------ + // Logging / verbosity + // ------------------------------------------------------------------------ + public static final Logger LOGGER + = Logger.getLogger(AbstractMPGDTrapezoidConstants.class.getName()); + + public static boolean VERBOSE = false; + + // ------------------------------------------------------------------------ + // CCDB configuration + // ------------------------------------------------------------------------ + /** + * Base CCDB path (e.g. "/test/urwt/"). + */ + protected final String ccdbPath; + + /** + * Name of the global geometry table (e.g. "urwt_global"). + */ + protected final String globalTableName; + + /** + * Name of the material table (e.g. "urwt_material_geo"). + */ + protected final String materialTableName; + + // ------------------------------------------------------------------------ + // Geometry parameters (from global table) + // ------------------------------------------------------------------------ + public int NSECTORS; // number of sectors + public int NLAYERS; // number of layers (readout planes) + public int NCOMPONENTS; // number of components (e.g. strips) per layer + + public double THOPEN; // opening angle between endplate planes (deg) + public double THTILT; // tilt angle (deg) + public double THMIN; // minimum polar angle (deg) + public double THMAX; // maximum polar angle (deg) + public double TGTDET; // distance from target to first plane (cm) + public double DZ; // spacing between regions (cm) + public double TWIDTH; // Trapezoid width: distance from a corner to the oblique (non-parallel) side (cm) + + public double PITCH; // strip pitch (mm) + public double WIDTH; // strip width (mm) + public double STEREOANGLE; // strip stereo angle (deg) + + // ------------------------------------------------------------------------ + // Geometry enlargement (used when building volumes) + // ------------------------------------------------------------------------ + public static final double XENLARGEMENT = 0.15; // cm + public static final double YENLARGEMENT = 0.15; // cm + public static final double ZENLARGEMENT = 0.02; // cm + + // ------------------------------------------------------------------------ + // Material description: (layer, component) -> parameters + // ------------------------------------------------------------------------ + /** + * Simple container for material parameters associated to (layer, + * component). thickness : material thickness (mm) sensitivity: flag or ID + * for sensitivity (as defined in CCDB) + */ + public static class LayerComponentInfo { + + public final double thickness; + public final int sensitivity; + + public LayerComponentInfo(double thickness, int sensitivity) { + this.thickness = thickness; + this.sensitivity = sensitivity; + } + } + + /** + * Material structure: outer key = layer index (from CCDB column "Layer") + * inner key = component index (from CCDB column "Component") value = + * material parameters (thickness, sensitivity) + */ + protected final Map> detectorStructure + = new LinkedHashMap<>(); + + /** + * @param ccdbPath base CCDB path (e.g. "/test/urwt/") + * @param globalTableName name of the global table (e.g. "urwt_global") + * @param materialTableName name of the material table (e.g. + * "urwt_material_geo") + */ + protected AbstractMPGDTrapezoidConstants(String ccdbPath, + String globalTableName, + String materialTableName) { + this.ccdbPath = ccdbPath; + this.globalTableName = globalTableName; + this.materialTableName = materialTableName; + } + + /** + * Read-only access to the material structure. + * + * @return + */ + public Map> getDetectorStructure() { + return detectorStructure; + } + + // ------------------------------------------------------------------------ + // CCDB loading API + // ------------------------------------------------------------------------ + /** + * Loads the relevant CCDB tables into the given provider and fills this + * object's fields. + * + * @param cp + * @return + */ + public DatabaseConstantProvider loadFrom(DatabaseConstantProvider cp) { + cp.loadTable(ccdbPath + globalTableName); + cp.loadTable(ccdbPath + materialTableName); + load(cp); + return cp; + } + + /** + * Reads the already-loaded CCDB tables from the provider and fills geometry + * and material parameters.This method assumes: - global table has at least + * one row - material table has at least one row + * + * @param cp + */ + public synchronized void load(DatabaseConstantProvider cp) { + + // --------------------------- Global table --------------------------- + String globalBase = ccdbPath + globalTableName; + + int nGlobalRows = cp.length(globalBase + "/Nsectors"); + if (nGlobalRows <= 0) { + throw new IllegalStateException("Table " + globalBase + " has no rows in CCDB"); + } + + int row = 0; // global table is expected to have a single row + + NSECTORS = cp.getInteger(globalBase + "/Nsectors", row); + NLAYERS = cp.getInteger(globalBase + "/NLayers", row); + NCOMPONENTS = cp.getInteger(globalBase + "/NComponents", row); + THOPEN = cp.getDouble(globalBase + "/Thopen", row); + THTILT = cp.getDouble(globalBase + "/Thtilt", row); + THMIN = cp.getDouble(globalBase + "/Thmin", row); + THMAX = cp.getDouble(globalBase + "/Thmax", row); + TGTDET = cp.getDouble(globalBase + "/Tgt", row); + DZ = cp.getDouble(globalBase + "/Dz", row); + TWIDTH = cp.getDouble(globalBase + "/TWidth", row); + PITCH = cp.getDouble(globalBase + "/Pitch", row); + WIDTH = cp.getDouble(globalBase + "/Width", row); + STEREOANGLE = cp.getDouble(globalBase + "/StereoAngle", row); + + if (VERBOSE) { + System.out.printf( + "%s global: Nsectors=%d Nlayers=%d Ncomponents=%d Thopen=%.3f Thtilt=%.3f " + + "Thmin=%.3f Thmax=%.3f Tgt=%.3f Dz=%.3f TWidth=%.3f Pitch=%.3f Width=%.3f StereoAngle=%.3f%n", + globalTableName, + NSECTORS, NLAYERS, NCOMPONENTS, + THOPEN, THTILT, THMIN, THMAX, + TGTDET, DZ, TWIDTH, PITCH, WIDTH, STEREOANGLE + ); + } + + // --------------------------- Material table ------------------------ + String matBase = ccdbPath + materialTableName; + + // Use a numeric column (e.g. Layer) to get the number of rows + int nRows = cp.length(matBase + "/Layer"); + + if (VERBOSE) { + System.out.printf("%s material table rows=%d%n", materialTableName, nRows); + } + + detectorStructure.clear(); + + // Expected schema (all numeric): + // Layer (int) + // Component (int) + // thickness (double) mm + // sensitivity (int) + for (int i = 0; i < nRows; i++) { + + int layer = cp.getInteger(matBase + "/Layer", i); + int component = cp.getInteger(matBase + "/Component", i); + double thickness = (cp.getDouble(matBase + "/Thickness", i)) * 0.1; // convert in cm + int sensitivity = cp.getInteger(matBase + "/Sensitivity", i); + + if (VERBOSE) { + System.out.printf( + "%s row %d: layer=%d comp=%d thick=%.5f sens=%d%n", + materialTableName, i, layer, component, thickness, sensitivity + ); + } + + LayerComponentInfo info = new LayerComponentInfo(thickness, sensitivity); + + detectorStructure + .computeIfAbsent(layer, l -> new LinkedHashMap<>()) + .put(component, info); + } + } +} diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidGeant4Factory.java new file mode 100644 index 0000000000..441900b6b1 --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidGeant4Factory.java @@ -0,0 +1,350 @@ +package org.jlab.detector.geant4.v2.mpgd.trapezoid; + +import eu.mihosoft.vrl.v3d.Vector3d; +import org.jlab.detector.geant4.v2.Geant4Factory; +import org.jlab.detector.volume.G4Trap; +import org.jlab.detector.volume.G4World; +import org.jlab.detector.volume.Geant4Basic; + +import java.util.Map; + +/** + * Generic Geant4 factory for trapezoidal MPGD-like trackers. + * + * It builds: - a world volume - NREGIONS = NLAYERS/2 (by convention) - NSECTORS + * per region + * + * The exact geometry parameters and material stack are taken from an + * {@link AbstractMPGDTrapezoidConstants} instance. + * + * Concrete detectors should: - extend this class - pass the appropriate + * constants + detector name in the constructor + */ +public abstract class AbstractMPGDTrapezoidGeant4Factory extends Geant4Factory { + + /** + * Detector constants (geometry + materials from CCDB). + */ + protected final AbstractMPGDTrapezoidConstants C; + + /** + * Short detector name used in volume names (e.g. "uRWT"). + */ + protected final String detectorName; + + public static record SectorDimensions( + double halfThickness, + double halfHeight, + double halfLargeBase, + double halfSmallBase, + double tiltRad + ) { + + } + + /** + * @param constants detector constants (already configured with CCDB + * paths/table names) + * @param detectorName short detector name used in volume names + */ + protected AbstractMPGDTrapezoidGeant4Factory(AbstractMPGDTrapezoidConstants constants, + String detectorName) { + this.C = constants; + this.detectorName = detectorName; + } + + // ------------------------------------------------------------------------ + // Top-level geometry construction + // ------------------------------------------------------------------------ + /** + * Initializes the world volume and constructs all regions and sectors. + * + * This must be called after the constants have been loaded from CCDB. + */ + protected void init() { + + // World volume for this detector + motherVolume = new G4World("root"); + + int NREGIONS = (int) Math.round(C.NLAYERS / 2.0); + for (int iregion = 0; iregion < NREGIONS; iregion++) { + for (int isector = 0; isector < C.NSECTORS; isector++) { + Geant4Basic sectorVolume = createSector(isector, iregion); + sectorVolume.setMother(motherVolume); + } + } + } + + // ------------------------------------------------------------------------ + // Sector geometry helpers + // ------------------------------------------------------------------------ + /** + * Computes the total thickness (mm) of a sector by summing the thickness of + * all material volumes. + * + * @return + */ + public double getSectorThickness() { + return C.getDetectorStructure().values() + .stream() + .flatMap(componentMap -> componentMap.values().stream()) + .mapToDouble(info -> info.thickness) + .sum(); + } + + /** + * + * @param region + * @return + */ + public SectorDimensions getSectorDimensionsPhysical(int region) { + + double baseDistance = C.TGTDET + region * C.DZ; + + double sectorHeight = baseDistance + * (Math.tan(Math.toRadians(C.THMAX - C.THTILT)) + + Math.tan(Math.toRadians(C.THTILT - C.THMIN))); + + double halfThickness = this.getSectorThickness() / 2.0; + double halfHeight = sectorHeight / 2.0; + + // Distance from target to the bottom base along the tilted axis + double W2TGT = (C.TGTDET + region * C.DZ) + / Math.cos(Math.toRadians(C.THTILT - C.THMIN)); + + double YMIN = W2TGT * Math.sin(Math.toRadians(C.THMIN)); // distance from beamline (Y) + double h = sectorHeight * Math.cos(Math.toRadians(C.THTILT)); + double halfSmallBase = 0.5 * (YMIN * Math.tan(Math.toRadians(C.THOPEN) / 2)); + + double halfLargeBase = halfSmallBase + sectorHeight * Math.tan(Math.toRadians(C.THOPEN / 2.0)); + + double tiltRad = Math.toRadians(C.THTILT); + + double twidth_Check = 2 * halfLargeBase * Math.sin(Math.toRadians(C.THOPEN)); + + if (AbstractMPGDTrapezoidConstants.VERBOSE) { + System.out.printf("C.TWIDT=%.3f vs %.3f", C.TWIDTH, twidth_Check); + + System.out.printf("YMIN=%.3f", YMIN); + + System.out.printf( + "SectorDimensionsPhysical [%s] region=%d : height=%.3f | halfT=%.3f halfH=%.3f " + + "halfLarge=%.3f halfSmall=%.3f tilt(deg)=%.3f%n", + detectorName, region, sectorHeight, + halfThickness, halfHeight, + halfLargeBase, halfSmallBase, + C.THTILT + ); + } + + return new SectorDimensions(halfThickness, halfHeight, halfLargeBase, halfSmallBase, tiltRad); + } + + /** + * + * @param region + * @return + */ + public SectorDimensions getSectorDimensionsContainer(int region) { + + SectorDimensions phys = getSectorDimensionsPhysical(region); + + double halfThickness = phys.halfThickness() + AbstractMPGDTrapezoidConstants.ZENLARGEMENT; + double halfHeight = phys.halfHeight() + AbstractMPGDTrapezoidConstants.YENLARGEMENT; + double halfLargeBase = phys.halfLargeBase() + AbstractMPGDTrapezoidConstants.XENLARGEMENT; + double halfSmallBase = phys.halfSmallBase() + AbstractMPGDTrapezoidConstants.XENLARGEMENT; + + return new SectorDimensions(halfThickness, halfHeight, halfLargeBase, halfSmallBase, phys.tiltRad()); + } + + /** + * Computes the sector height (longitudinal extension in the RZ plane) for a + * given region. + * + * @param region + * @return + */ + public double getSectorHeight(int region) { + + double baseDistance = C.TGTDET + region * C.DZ; + + double sectorHeight = baseDistance + * (Math.tan(Math.toRadians(C.THMAX - C.THTILT)) + + Math.tan(Math.toRadians(C.THTILT - C.THMIN))); + + if (AbstractMPGDTrapezoidConstants.VERBOSE) { + System.out.printf( + "SectorHeight [%s] region=%d : baseDistance=%.3f THMIN=%.3f THMAX=%.3f THTILT=%.3f -> height=%.3f%n", + detectorName, + region, + baseDistance, + C.THMIN, C.THMAX, C.THTILT, + sectorHeight + ); + } + + return sectorHeight; + } + + /** + * Computes the barycenter coordinates of a given sector/region in the + * CLAS12 coordinate system. + * + * @param isector + * @param iregion + * @return + */ + public Vector3d getCenterCoordinate(int isector, int iregion) { + + Vector3d vCenter = new Vector3d(0, 0, 0); + + // Distance from target to the bottom base along the tilted axis + double W2TGT = (C.TGTDET + iregion * C.DZ) + / Math.cos(Math.toRadians(C.THTILT - C.THMIN)); + + double YMIN = W2TGT * Math.sin(Math.toRadians(C.THMIN)); // distance from beamline (Y) + double ZMIN = W2TGT * Math.cos(Math.toRadians(C.THMIN)); // Z of the bottom base + + SectorDimensions dimCont = this.getSectorDimensionsContainer(iregion); + double sectorHeight = 2 * dimCont.halfHeight(); + + vCenter.x = 0.0; + vCenter.y = (sectorHeight / 2.0) * Math.cos(Math.toRadians(C.THTILT)) + YMIN; + vCenter.z = -(sectorHeight / 2.0) * Math.sin(Math.toRadians(C.THTILT)) + ZMIN; + + // Rotate to the correct sector around Z (assumes 6 sectors, 60° apart) + vCenter.rotateZ(-Math.toRadians(90.0 - isector * 60.0)); + + return vCenter; + } + + // ------------------------------------------------------------------------ + // Sector + material volume construction + // ------------------------------------------------------------------------ + /** + * Builds a single sector for a given region and returns its volume. + * + * @param isector + * @param iregion + * @return + */ + public Geant4Basic createSector(int isector, int iregion) { + + SectorDimensions dimPhys = this.getSectorDimensionsPhysical(iregion); + SectorDimensions dimCont = this.getSectorDimensionsContainer(iregion); + + Geant4Basic sectorVolume = createSectorVolume(isector, iregion, dimCont); + populateSectorWithDetectorStructure(sectorVolume, isector, iregion, dimPhys); + + return sectorVolume; + } + + /** + * Creates the main trapezoidal sector volume and places it in the world. + * + * @param isector + * @param iregion + * @param dimSect + * @return + */ + protected Geant4Basic createSectorVolume(int isector, + int iregion, + SectorDimensions dimSect) { + + double sectorDZ = dimSect.halfThickness(); + double sectorDY = dimSect.halfHeight(); + double sectorDX1 = dimSect.halfLargeBase(); + double sectorDX0 = dimSect.halfSmallBase(); + double sectorTtilt = dimSect.tiltRad(); + + Vector3d vCenter = this.getCenterCoordinate(isector, iregion); + + Geant4Basic sectorVolume = new G4Trap( + "region_" + detectorName + "_" + (iregion + 1) + "_s" + (isector + 1), + sectorDZ, -sectorTtilt, Math.toRadians(90.0), + sectorDY, sectorDX0, sectorDX1, 0.0, + sectorDY, sectorDX0, sectorDX1, 0.0 + ); + + sectorVolume.rotate("yxz", 0.0, sectorTtilt, Math.toRadians(90.0 - isector * 60.0)); + sectorVolume.translate(vCenter.x, vCenter.y, vCenter.z); + sectorVolume.setId(isector + 1, iregion + 1, 0, 0); + + return sectorVolume; + } + + /** + * Fills the given sector volume with material sub-volumes according to the + * CCDB material structure (layer/component stack).Stacking is done along + * the local Z direction (thickness). + * + * @param sectorVolume + * @param isector + * @param iregion + * @param dimSect + */ + protected void populateSectorWithDetectorStructure(Geant4Basic sectorVolume, + int isector, + int iregion, + SectorDimensions dimSect) { + + double halfThickness = dimSect.halfThickness(); + double halfHeight = dimSect.halfHeight(); + double halfLargeBase = dimSect.halfLargeBase(); + double halfSmallBase = dimSect.halfSmallBase(); + double tiltRad = dimSect.tiltRad(); + + double totalThickness = 2.0 * halfThickness; + double accumulatedThickness = 0.0; + + for (Map.Entry> layerEntry + : C.getDetectorStructure().entrySet()) { + + int LayerId = layerEntry.getKey(); + Map componentMap + = layerEntry.getValue(); + + for (Map.Entry componentEntry + : componentMap.entrySet()) { + + int materialComponentId = componentEntry.getKey(); + AbstractMPGDTrapezoidConstants.LayerComponentInfo info = componentEntry.getValue(); + + double thick = info.thickness; + + // Protect against zero or negative thickness: skip such entries + if (thick <= 0.0) { + System.err.printf( + "WARNING: skipping material volume with non-positive thickness: " + + "layer=%d comp=%d thick=%f%n", + LayerId, materialComponentId, thick + ); + continue; + } + + // place from "front" to "back" along local Z + double localZ = -totalThickness / 2.0 + accumulatedThickness + thick / 2.0; + double localY = -localZ * Math.tan(Math.toRadians(C.THTILT)); + + Geant4Basic matVolume = new G4Trap( + "matVolume", + thick / 2.0, -tiltRad, Math.toRadians(90.0), + halfHeight, halfSmallBase, halfLargeBase, 0.0, + halfHeight, halfSmallBase, halfLargeBase, 0.0 + ); + + matVolume.setName( + "rg_" + detectorName + "_" + (iregion + 1) + + "_s" + (isector + 1) + + "_l" + (LayerId + iregion * 2) + + "_matC" + materialComponentId + ); + + matVolume.setMother(sectorVolume); + matVolume.setPosition(0.0, localY, localZ); + + accumulatedThickness += thick; + } + } + } +} diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidStripFactory.java new file mode 100644 index 0000000000..3b4608e840 --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidStripFactory.java @@ -0,0 +1,674 @@ +package org.jlab.detector.geant4.v2.mpgd.trapezoid; + +import eu.mihosoft.vrl.v3d.Vector3d; +import org.jlab.detector.volume.Geant4Basic; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Plane3D; +import org.jlab.geom.prim.Point3D; +import org.jlab.geom.prim.Trap3D; +import org.jlab.geom.prim.Vector3D; +import org.jlab.utils.groups.IndexedList; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +/** + * Base class implementing strip/surface/plane geometry for trapezoidal MPGD + * detectors. + */ +public abstract class AbstractMPGDTrapezoidStripFactory { + + // ------------------------------------------------------------------------ + // Inputs + // ------------------------------------------------------------------------ + protected final AbstractMPGDTrapezoidConstants C; + protected final AbstractMPGDTrapezoidGeant4Factory geo; + + protected AbstractMPGDTrapezoidStripFactory(AbstractMPGDTrapezoidConstants constants, + AbstractMPGDTrapezoidGeant4Factory geantFactory) { + this.C = constants; + this.geo = geantFactory; + } + + /** + * Detector-specific hook: Must return the volume object given its + * name.Typically implemented by indexing geo.getAllVolumes() into a + * Map. + * + * @param name + * @return + */ + protected abstract Geant4Basic getVolumeByName(String name); + + // ------------------------------------------------------------------------ + // Cached geometry (CLAS12 indices) + // ------------------------------------------------------------------------ + protected final IndexedList globalStrips = new IndexedList<>(3); // (sector, layer, component) + protected final IndexedList localStrips = new IndexedList<>(3); // (sector, layer, component) sensitive-local + protected final IndexedList tiltedStrips = new IndexedList<>(3); // (sector, layer, component) + protected final IndexedList planes = new IndexedList<>(2); // (sector, layer) + protected final IndexedList surfaceLayers = new IndexedList<>(2); // (sector, layer) + protected final IndexedList nComponents = new IndexedList<>(2); // (sector, layer) + + // ------------------------------------------------------------------------ + // Internal geometry containers (mirror the C++ digitizer) + // ------------------------------------------------------------------------ + protected static class StripConstants { + + public double xHalfSmall; // cm + public double xHalfLarge; // cm + public double yHalf; // cm + public double zReadoutLocal; // cm (in sensitive-local) + public double pitch; // cm + public double width; // cm + public double stereoAngle; // rad + } + + protected static class Trap2D { + + Vector3d bl, br, tl, tr; + + static Trap2D fromConstants(StripConstants c) { + Trap2D t = new Trap2D(); + double z = c.zReadoutLocal; + t.bl = new Vector3d(-c.xHalfSmall, -c.yHalf, z); + t.br = new Vector3d(c.xHalfSmall, -c.yHalf, z); + t.tl = new Vector3d(-c.xHalfLarge, c.yHalf, z); + t.tr = new Vector3d(c.xHalfLarge, c.yHalf, z); + return t; + } + + List edges() { + List e = new ArrayList<>(4); + e.add(new Vector3d[]{bl, br}); + e.add(new Vector3d[]{br, tr}); + e.add(new Vector3d[]{tr, tl}); + e.add(new Vector3d[]{tl, bl}); + return e; + } + } + + protected static class StripGeom { + + int internalIndex; + int component; + Vector3d p1Local, p2Local; // endpoints in sensitive-local + double orderXLocal; // local midpoint X ordering key + } + + // ------------------------------------------------------------------------ + // Options / defaults + // ------------------------------------------------------------------------ + /** + * If true: readout is 2D => same zReadoutLocal for both layers.Override in + * detector. + * + * @return + */ + protected boolean is2DReadout() { + return false; + } + + protected int baseLayerForCCDB(int layer) { + if (is2DReadout()) { + return 1; + } + return (layer % 2 == 0) ? 2 : 1; + } + + /** + * Pitch in cm (CCDB stored in mm). Override if detector is different. + */ + protected double defaultPitchCm() { + return C.PITCH * 0.1; + } + + /** + * Width in cm (CCDB stored in mm). Override if detector is different. + */ + protected double defaultWidthCm() { + return C.WIDTH * 0.1; + } + + /** + * Stereo angle in rad (CCDB stored in deg). Override if detector is + * layer-dependent. + */ + protected double defaultStereoAngleRad() { + return Math.toRadians(C.STEREOANGLE); + } + + // ------------------------------------------------------------------------ + // Sensitive volume discovery (Sensitivity==1) + // ------------------------------------------------------------------------ + /** + * Return the CCDB "Component" index (matC) whose Sensitivity==1 for a given + * layer. + * + * @param layer + * @return + */ + protected int getSensitiveMatComponentId(int layer) { + int baseLayer = baseLayerForCCDB(layer); + var layerMap = C.getDetectorStructure().get(baseLayer); + if (layerMap == null) { + throw new IllegalStateException("No detectorStructure entry for layer=" + layer); + } + for (var e : layerMap.entrySet()) { + int matC = e.getKey(); + var info = e.getValue(); + if (info.sensitivity == 1) { + return matC; + } + } + throw new IllegalStateException("No Sensitivity==1 found for layer=" + layer); + } + + /** + * Compute the sensitive half thickness (cm) from CCDB (Sensitivity==1). + * + * @param layer + * @return + */ + protected double getSensitiveHalfThicknessCm(int layer) { + int baseLayer = baseLayerForCCDB(layer); + var layerMap = C.getDetectorStructure().get(baseLayer); + if (layerMap == null) { + throw new IllegalStateException("No detectorStructure entry for layer=" + layer); + } + for (var e : layerMap.entrySet()) { + var info = e.getValue(); + if (info.sensitivity == 1) { + return info.thickness / 2.0; // thickness already cm in your loader + } + } + throw new IllegalStateException("No sensitive thickness (Sensitivity==1) for layerInRegion=" + layer); + } + + /** + * Readout plane z in sensitive-local.Convention: - 1D: even layerInRegion + * => +zHalf, odd => -zHalf - 2D: always +zHalf + * + * @param layer + * @return + */ + protected double findReadoutZLocal(int layer) { + double zHalf = getSensitiveHalfThicknessCm(layer); + if (is2DReadout()) { + return +zHalf; + } + return (layer % 2 == 0) ? (+zHalf) : (-zHalf); + } + + /** + * Build expected sensitive-volume name using the naming convention from + * AbstractMPGDTrapezoidGeant4Factory.populateSectorWithDetectorStructure(): + * + * rg{region}_s{sector}_l{layerGlobal0Based}_matC{matC} + * + * where: - region is 1-based in the name - sector is 1-based in the name - + * matC is the CCDB material "Component" id for Sensitivity==1 + * + * @param region + * @param sector + * @param layer + * @return + */ + protected String getSensitiveVolumeName(int region, int sector, int layer) { + int matC = getSensitiveMatComponentId(layer); + if (is2DReadout()) { + if (layer % 2 == 0) { // layer pari + layer = layer - 1; + } +} + + return "rg_" + geo.detectorName + "_" + region + + "_s" + sector + + "_l" + layer + + "_matC" + matC; + } + + /** + * Transform a point from sensitive-local -> global using the sensitive + * volume transform. + * + * @param region + * @param sector + * @param layer + * @param local + * @return + */ + protected Vector3d toGlobalSensitive(int region, int sector, int layer, Vector3d local) { + String name = getSensitiveVolumeName(region, sector, layer); + Geant4Basic v = getVolumeByName(name); + if (v == null) { + throw new IllegalStateException("Sensitive volume not found: " + name); + } + + return v.getGlobalTransform().transform(local); + } + + // ------------------------------------------------------------------------ + // Strip constants builder (GENERAL: uses geo physical dims + CCDB thickness) + // ------------------------------------------------------------------------ + /** + * Build StripConstants using: - XY trapezoid from + * geo.getSectorDimensionsPhysical(region) (NOT enlarged) - zReadoutLocal + * from CCDB sensitive thickness (findReadoutZLocal) - pitch/width/stereo + * from CCDB + * + * @param region + * @param layer + * @return + */ + protected StripConstants buildStripConstants(int region, int layer) { + + AbstractMPGDTrapezoidGeant4Factory.SectorDimensions phys + = geo.getSectorDimensionsPhysical(region - 1); + + StripConstants sc = new StripConstants(); + sc.yHalf = phys.halfHeight(); + sc.xHalfSmall = phys.halfSmallBase(); + sc.xHalfLarge = phys.halfLargeBase(); + + // sc.zReadoutLocal = findReadoutZLocal(layer); + sc.zReadoutLocal = 0.0; + sc.pitch = defaultPitchCm(); + sc.width = defaultWidthCm(); + if (layer % 2 == 0) { + // layer pari + sc.stereoAngle = -defaultStereoAngleRad(); + } else { + // layer dispari + sc.stereoAngle = defaultStereoAngleRad(); + } + + + return sc; + } + + // ------------------------------------------------------------------------ + // Strip-frame transforms (IDENTICAL to C++) + // ------------------------------------------------------------------------ + protected static double[] toStripFrameXY(double x, double y, StripConstants c) { + double sa = Math.sin(c.stereoAngle); + double ca = Math.cos(c.stereoAngle); + double xs = sa * x + ca * y; + double ys = ca * x - sa * y; + return new double[]{xs, ys}; + } + + // ------------------------------------------------------------------------ + // Line / edge intersection (normal form) + // ------------------------------------------------------------------------ + protected static boolean intersectEdgeWithLineNormal( + Vector3d A, Vector3d B, + Vector3d nXY, double rhs, + Vector3d out + ) { + double nA = nXY.x * A.x + nXY.y * A.y; + double nB = nXY.x * B.x + nXY.y * B.y; + double denom = nB - nA; + + if (Math.abs(denom) < 1e-12) { + return false; + } + + double t = (rhs - nA) / denom; + if (t < 0.0 || t > 1.0) { + return false; + } + + out.x = A.x + t * (B.x - A.x); + out.y = A.y + t * (B.y - A.y); + out.z = A.z + t * (B.z - A.z); + return true; + } + + protected static boolean buildStripSegment(int internalIndex, StripConstants c, Vector3d out1, Vector3d out2) { + + Trap2D tr = Trap2D.fromConstants(c); + + double sa = Math.sin(c.stereoAngle); + double ca = Math.cos(c.stereoAngle); + + // line: ca*x - sa*y = rhs + Vector3d nXY = new Vector3d(ca, -sa, 0.0); + double rhs = (internalIndex + 0.5) * c.pitch; + + List inters = new ArrayList<>(4); + + for (Vector3d[] e : tr.edges()) { + Vector3d P = new Vector3d(0, 0, 0); + if (intersectEdgeWithLineNormal(e[0], e[1], nXY, rhs, P)) { + inters.add(new Vector3d(P.x, P.y, P.z)); + } + } + + if (inters.size() < 2) { + return false; + } + + // choose farthest pair (robust at vertices) + double best = -1; + Vector3d a = null, b = null; + for (int i = 0; i < inters.size(); i++) { + for (int j = i + 1; j < inters.size(); j++) { + double dx = inters.get(i).x - inters.get(j).x; + double dy = inters.get(i).y - inters.get(j).y; + double d2 = dx * dx + dy * dy; + if (d2 > best) { + best = d2; + a = inters.get(i); + b = inters.get(j); + } + } + } + + out1.set(a.x, a.y, a.z); + out2.set(b.x, b.y, b.z); + return true; + } + + /** + * Build full strip list (LOCAL) and assign CLAS12 component IDs by sorting + * on local X midpoint. + * + * @param c + * @return + */ + protected List buildStripCache(StripConstants c) { + + Trap2D tr = Trap2D.fromConstants(c); + + double ys1 = toStripFrameXY(tr.bl.x, tr.bl.y, c)[1]; + double ys2 = toStripFrameXY(tr.br.x, tr.br.y, c)[1]; + double ys3 = toStripFrameXY(tr.tl.x, tr.tl.y, c)[1]; + double ys4 = toStripFrameXY(tr.tr.x, tr.tr.y, c)[1]; + + double ysMin = Math.min(Math.min(ys1, ys2), Math.min(ys3, ys4)); + double ysMax = Math.max(Math.max(ys1, ys2), Math.max(ys3, ys4)); + + int iMin = (int) Math.floor(ysMin / c.pitch) - 2; + int iMax = (int) Math.ceil(ysMax / c.pitch) + 2; + + List tmp = new ArrayList<>(); + + for (int idx = iMin; idx <= iMax; idx++) { + + Vector3d p1 = new Vector3d(0, 0, 0); + Vector3d p2 = new Vector3d(0, 0, 0); + + if (!buildStripSegment(idx, c, p1, p2)) { + continue; + } + + StripGeom s = new StripGeom(); + s.internalIndex = idx; + s.p1Local = p1; + s.p2Local = p2; + + Vector3d mid = new Vector3d( + 0.5 * (p1.x + p2.x), + 0.5 * (p1.y + p2.y), + 0.5 * (p1.z + p2.z) + ); + s.orderXLocal = mid.x; + + tmp.add(s); + } + + tmp.sort(Comparator + .comparingDouble((StripGeom s) -> s.orderXLocal) + .thenComparingInt(s -> s.internalIndex)); + + int comp = 1; + for (StripGeom s : tmp) { + s.component = comp++; + } + + return tmp; + } + + // ------------------------------------------------------------------------ + // Tilted frame + // ------------------------------------------------------------------------ + /** + * + * @param sector + * @param global + * @return + */ + protected Line3D toTilted(int sector, Line3D global) { + Line3D tilted = new Line3D(); + tilted.copy(global); + + double dPhi = 360.0 / C.NSECTORS; + double phi = -Math.toRadians(dPhi * (sector - 1)); + + tilted.rotateZ(phi); + tilted.rotateY(Math.toRadians(-C.THTILT)); + + return tilted; + } + + // ------------------------------------------------------------------------ + // Surface + Plane builders (GLOBAL) + // ------------------------------------------------------------------------ + /** + * + * @param sector + * @param layer + * @return + */ + protected Trap3D createSurface(int sector, int layer) { + + int region = (layer + 1) / 2; + + StripConstants c = buildStripConstants(region, layer); + + Vector3d blL = new Vector3d(-c.xHalfSmall, -c.yHalf, c.zReadoutLocal); + Vector3d brL = new Vector3d(c.xHalfSmall, -c.yHalf, c.zReadoutLocal); + Vector3d tlL = new Vector3d(-c.xHalfLarge, c.yHalf, c.zReadoutLocal); + Vector3d trL = new Vector3d(c.xHalfLarge, c.yHalf, c.zReadoutLocal); + + Vector3d blG = toGlobalSensitive(region, sector, layer, blL); + Vector3d brG = toGlobalSensitive(region, sector, layer, brL); + Vector3d tlG = toGlobalSensitive(region, sector, layer, tlL); + Vector3d trG = toGlobalSensitive(region, sector, layer, trL); + + return new Trap3D( + blG.x, blG.y, blG.z, + brG.x, brG.y, brG.z, + tlG.x, tlG.y, tlG.z, + trG.x, trG.y, trG.z + ); + } + + /** + * + * @param sector + * @param layer + * @return + */ + protected Plane3D createPlane(int sector, int layer) { + + int region = (layer + 1) / 2; + + StripConstants c = buildStripConstants(region, layer); + + // 3 points on the readout plane in sensitive-local + Vector3d p1L = new Vector3d(-c.xHalfSmall, -c.yHalf, c.zReadoutLocal); + Vector3d p2L = new Vector3d(c.xHalfSmall, -c.yHalf, c.zReadoutLocal); + Vector3d p3L = new Vector3d(-c.xHalfLarge, c.yHalf, c.zReadoutLocal); + + // transform to global + Vector3d p1G = toGlobalSensitive(region, sector, layer, p1L); + Vector3d p2G = toGlobalSensitive(region, sector, layer, p2L); + Vector3d p3G = toGlobalSensitive(region, sector, layer, p3L); + + Point3D P1 = new Point3D(p1G.x, p1G.y, p1G.z); + Point3D P2 = new Point3D(p2G.x, p2G.y, p2G.z); + Point3D P3 = new Point3D(p3G.x, p3G.y, p3G.z); + + // normal = (P1->P2) x (P1->P3) + Vector3D v1 = P1.vectorTo(P2); + Vector3D v2 = P1.vectorTo(P3); + Vector3D n = v1.cross(v2); + n.unit(); + + // If you want a stable sign convention, uncomment: + // if (n.z() < 0) n.setXYZ(-n.x(), -n.y(), -n.z()); + return new Plane3D(P1, n); + } + + // ------------------------------------------------------------------------ + // Build orchestration + // ------------------------------------------------------------------------ + public final void buildAll() { + clearCaches(); + fillStripLists(); + fillSurfaceLists(); + fillPlaneLists(); + } + + protected void clearCaches() { + globalStrips.clear(); + localStrips.clear(); + tiltedStrips.clear(); + planes.clear(); + surfaceLayers.clear(); + nComponents.clear(); + } + + protected void fillStripLists() { + + for (int sector = 1; sector <= C.NSECTORS; sector++) { + for (int layer = 1; layer <= C.NLAYERS; layer++) { + + int region = (layer + 1) / 2; + + StripConstants sc = buildStripConstants(region, layer); + List strips = buildStripCache(sc); + + nComponents.add(strips.size(), sector, layer); + + for (StripGeom s : strips) { + + // local line (sensitive-local) + Line3D local = new Line3D( + s.p1Local.x, s.p1Local.y, s.p1Local.z, + s.p2Local.x, s.p2Local.y, s.p2Local.z + ); + + // global endpoints + Vector3d g1 = toGlobalSensitive(region, sector, layer, s.p1Local); + + Vector3d g2 = toGlobalSensitive(region, sector, layer, s.p2Local); + + Line3D global = new Line3D( + g1.x, g1.y, g1.z, + g2.x, g2.y, g2.z + ); + + Line3D tilted = toTilted(sector, global); + + // cache with CLAS12 indices: (sector, layer, component) + localStrips.add(local, sector, layer, s.component); + globalStrips.add(global, sector, layer, s.component); + tiltedStrips.add(tilted, sector, layer, s.component); + } + } + } + } + + protected void fillSurfaceLists() { + for (int sector = 1; sector <= C.NSECTORS; sector++) { + for (int layer = 1; layer <= C.NLAYERS; layer++) { + surfaceLayers.add(createSurface(sector, layer), sector, layer); + } + } + } + + protected void fillPlaneLists() { + for (int sector = 1; sector <= C.NSECTORS; sector++) { + for (int layer = 1; layer <= C.NLAYERS; layer++) { + planes.add(createPlane(sector, layer), sector, layer); + } + } + } + + // ------------------------------------------------------------------------ + // Public API (cached getters) + // ------------------------------------------------------------------------ + /** + * Global strip line in CLAS12 frame. + * + * @param sector + * @param layer + * @param component + * @return + */ + public Line3D getStrip(int sector, int layer, int component) { + return globalStrips.getItem(sector, layer, component); + } + + /** + * Strip line in sensitive-volume local frame. + * + * @param sector + * @param layer + * @param component + * @return + */ + public Line3D getStripLocal(int sector, int layer, int component) { + return localStrips.getItem(sector, layer, component); + } + + /** + * Strip line in legacy tilted frame (debug/plot). + * + * @param sector + * @param layer + * @param component + * @return + */ + public Line3D getStripTilted(int sector, int layer, int component) { + return tiltedStrips.getItem(sector, layer, component); + } + + /** + * Readout plane in global frame. + * + * @param sector + * @param layer + * @return + */ + public Plane3D getPlane(int sector, int layer) { + return planes.getItem(sector, layer); + } + + /** + * Readout trapezoid surface in global frame. + * + * @param sector + * @param layer + * @return + */ + public Trap3D getSurface(int sector, int layer) { + return surfaceLayers.getItem(sector, layer); + } + + /** + * Number of components (strips) for this (sector, layer). + * + * @param sector + * @param layer + * @return + */ + public int getNComponents(int sector, int layer) { + Integer n = nComponents.getItem(sector, layer); + return (n == null) ? 0 : n; + } +} From 1850a91fa4effbdf71aaf753e96ad33d9f0f28c7 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Wed, 4 Feb 2026 14:17:17 -0500 Subject: [PATCH 2/6] propating changes through common tools, reconstruction, and schemas --- CODEOWNERS | 2 +- .../eventmerger/EventMergerConstants.java | 2 +- .../org/jlab/detector/base/DetectorType.java | 2 +- .../geant4/v2/URWT/URWTStripFactory.java | 20 +++--- .../org/jlab/clas/reco/EngineProcessor.java | 2 +- etc/bankdefs/hipo4/data.json | 4 +- etc/bankdefs/hipo4/urwell.json | 24 +++---- reconstruction/pom.xml | 2 +- reconstruction/{urwell => urwt}/pom.xml | 6 +- .../org/jlab/service/urwt/URWRStrip.java} | 42 ++++++------ .../org/jlab/service/urwt/URWTCluster.java} | 40 +++++------ .../org/jlab/service/urwt/URWTConstants.java} | 4 +- .../org/jlab/service/urwt/URWTCross.java} | 26 ++++---- .../org/jlab/service/urwt/URWTEngine.java} | 66 +++++++++---------- 14 files changed, 122 insertions(+), 120 deletions(-) rename reconstruction/{urwell => urwt}/pom.xml (93%) rename reconstruction/{urwell/src/main/java/org/jlab/service/urwell/URWellStrip.java => urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java} (79%) rename reconstruction/{urwell/src/main/java/org/jlab/service/urwell/URWellCluster.java => urwt/src/main/java/org/jlab/service/urwt/URWTCluster.java} (83%) rename reconstruction/{urwell/src/main/java/org/jlab/service/urwell/URWellConstants.java => urwt/src/main/java/org/jlab/service/urwt/URWTConstants.java} (93%) rename reconstruction/{urwell/src/main/java/org/jlab/service/urwell/URWellCross.java => urwt/src/main/java/org/jlab/service/urwt/URWTCross.java} (72%) rename reconstruction/{urwell/src/main/java/org/jlab/service/urwell/URWellEngine.java => urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java} (81%) diff --git a/CODEOWNERS b/CODEOWNERS index 0469d696f7..ea7190a46e 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -88,7 +88,7 @@ reconstruction/rtpc/ @mathieuouillon @Hattawy reconstruction/swaps/ @baltzell @raffaelladevita reconstruction/tof/ @zieglerv @raffaelladevita reconstruction/uber/ @baltzell @raffaelladevita -reconstruction/urwell/ @raffaelladevita @tongtongcao +reconstruction/urwt/ @raffaelladevita @tongtongcao reconstruction/vtx/ @zieglerv # etc diff --git a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/EventMergerConstants.java b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/EventMergerConstants.java index f32d5a9de6..e0311bf64f 100644 --- a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/EventMergerConstants.java +++ b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/EventMergerConstants.java @@ -36,7 +36,7 @@ public class EventMergerConstants { public static final String[] TDCBANKTYPES = {"tot","tdc"}; public static final String[] ADCDETECTORS = {"BAND","BMT", "BST","CND","CTOF","ECAL","FMT","FTCAL", - "FTHODO","FTOF","FTTRK","HTCC","LTCC","URWELL"}; + "FTHODO","FTOF","FTTRK","HTCC","LTCC","URWT"}; public static final String[] TDCDETECTORS = {"BAND","CND","CTOF","DC","ECAL","FTOF"}; diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java index ff90cc4a11..388fa0619a 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java @@ -30,7 +30,7 @@ public enum DetectorType { HEL (20, "HEL"), BAND (21, "BAND"), RASTER (22, "RASTER"), - URWELL (23, "URWELL"), + URWT (23, "URWT"), AHDC (24, "AHDC"), ATOF (25, "ATOF"), RECOIL (26, "RECOIL"), diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java index d1b2e934c3..82cafbddc2 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java @@ -24,20 +24,22 @@ public final class URWTStripFactory extends AbstractMPGDTrapezoidStripFactory { /** * Build using an already-configured DatabaseConstantProvider. + * @param cp + * @param variation */ -public URWTStripFactory(DatabaseConstantProvider cp, String variation) { - super(URWTConstants.getInstance(), new URWTGeant4Factory(cp, variation)); + public URWTStripFactory(DatabaseConstantProvider cp, String variation) { + super(URWTConstants.getInstance(), new URWTGeant4Factory(cp, variation)); - URWTConstants.connect(cp); + URWTConstants.connect(cp); - for (Geant4Basic v : geo.getAllVolumes()) { - if (v.getName() != null) { - volumeByName.put(v.getName(), v); + for (Geant4Basic v : geo.getAllVolumes()) { + if (v.getName() != null) { + volumeByName.put(v.getName(), v); + } } - } - buildAll(); -} + buildAll(); + } /** * Convenience constructor: internally creates a DatabaseConstantProvider. diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java index e3cab74086..81f103bbf9 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java @@ -141,7 +141,7 @@ public void initAll(){ String[] names = new String[]{ "MAGFIELDS", "FTCAL", "FTHODO", "FTTRK", "FTEB", - "URWELL", "DCCR", "DCHB","FTOFHB","EC","RASTER", + "URWT", "DCCR", "DCHB","FTOFHB","EC","RASTER", "CVTFP","CTOF","CND","BAND", "HTCC","LTCC","EBHB", "DCTB","FMT","FTOFTB","CVT","EBTB", diff --git a/etc/bankdefs/hipo4/data.json b/etc/bankdefs/hipo4/data.json index 854f4586ab..fb5190d725 100644 --- a/etc/bankdefs/hipo4/data.json +++ b/etc/bankdefs/hipo4/data.json @@ -583,10 +583,10 @@ ] }, { - "name" : "URWELL::adc", + "name" : "URWT::adc", "group": 22300, "item" : 11, - "info": "ADC bank for the URWELL", + "info": "ADC bank for the URWT", "entries":[ { "name":"sector" , "type":"B", "info":"sector (11-63)"}, { "name":"layer" , "type":"B", "info":"layer (1-2)"}, diff --git a/etc/bankdefs/hipo4/urwell.json b/etc/bankdefs/hipo4/urwell.json index 913309dd6f..3cba3eb6d8 100644 --- a/etc/bankdefs/hipo4/urwell.json +++ b/etc/bankdefs/hipo4/urwell.json @@ -1,13 +1,13 @@ [ { - "name": "URWELL::hits", + "name": "URWT::hits", "group": 22300, "item" : 21, - "info": "URWELL hits", + "info": "URWT hits", "entries": [ {"name":"id", "type":"S", "info":"id of the hit"}, - {"name":"sector", "type":"B", "info":"sector of URWELL"}, - {"name":"layer", "type":"B", "info":"layer of URWELL (1-3:PCAL, 4-6:ECIN, 7-9:ECOUT"}, + {"name":"sector", "type":"B", "info":"sector of URWT"}, + {"name":"layer", "type":"B", "info":"layer of URWT (1-3:PCAL, 4-6:ECIN, 7-9:ECOUT"}, {"name":"strip", "type":"S", "info":"strip number"}, {"name":"energy", "type":"F", "info":"energy of the hit (eV)"}, {"name":"time", "type":"F", "info":"time of the hit (ns)"}, @@ -16,14 +16,14 @@ ] }, { - "name": "URWELL::clusters", + "name": "URWT::clusters", "group": 22300, "item" : 22, - "info": "reconstructed clusters from URWELL", + "info": "reconstructed clusters from URWT", "entries": [ {"name":"id", "type":"S", "info":"id of the cluster"}, - {"name":"sector", "type":"B", "info":"sector of URWELL"}, - {"name":"layer", "type":"B", "info":"layer of URWELL"}, + {"name":"sector", "type":"B", "info":"sector of URWT"}, + {"name":"layer", "type":"B", "info":"layer of URWT"}, {"name":"strip", "type":"S", "info":"seed strip"}, {"name":"energy", "type":"F", "info":"energy of the cluster (eV)"}, {"name":"time", "type":"F", "info":"time of the cluster (ns)"}, @@ -38,14 +38,14 @@ ] }, { - "name": "URWELL::crosses", + "name": "URWT::crosses", "group": 22300, "item" : 23, - "info": "reconstructed crosses from URWELL", + "info": "reconstructed crosses from URWT", "entries": [ {"name":"id", "type":"S", "info":"id of the cross"}, - {"name":"sector", "type":"B", "info":"sector of URWELL"}, - {"name":"region", "type":"B", "info":"region of URWELL"}, + {"name":"sector", "type":"B", "info":"sector of URWT"}, + {"name":"region", "type":"B", "info":"region of URWT"}, {"name":"energy", "type":"F", "info":"energy of the cross (eV)"}, {"name":"time", "type":"F", "info":"time of the cross (ns)"}, {"name":"x", "type":"F", "info":"x coordinate (cm)"}, diff --git a/reconstruction/pom.xml b/reconstruction/pom.xml index 2e22821013..8f9c443280 100644 --- a/reconstruction/pom.xml +++ b/reconstruction/pom.xml @@ -33,7 +33,7 @@ swaps raster vtx - urwell + urwt alert bg postproc diff --git a/reconstruction/urwell/pom.xml b/reconstruction/urwt/pom.xml similarity index 93% rename from reconstruction/urwell/pom.xml rename to reconstruction/urwt/pom.xml index 492d409652..6baba51d51 100644 --- a/reconstruction/urwell/pom.xml +++ b/reconstruction/urwt/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.jlab.clas12.detector - clas12detector-urwell + clas12detector-urwt 13.6.0-SNAPSHOT jar @@ -44,5 +44,5 @@ 13.6.0-SNAPSHOT - - + clas12detector-urwt + diff --git a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellStrip.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java similarity index 79% rename from reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellStrip.java rename to reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java index cbfbfdf4fb..87bb2714e3 100644 --- a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellStrip.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java @@ -1,4 +1,4 @@ -package org.jlab.service.urwell; +package org.jlab.service.urwt; import java.util.ArrayList; import java.util.List; @@ -6,21 +6,21 @@ import org.jlab.detector.base.DetectorDescriptor; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; -import org.jlab.detector.geant4.v2.URWELL.URWellStripFactory; +import org.jlab.detector.geant4.v2.URWT.URWTStripFactory; import org.jlab.geom.prim.Line3D; import org.jlab.io.base.DataEvent; /** - * URWell strip, defined based on ADC bank information and 3D line provided + * URWT strip, defined based on ADC bank information and 3D line provided * by the geometry service * * @author bondi, devita */ -public class URWellStrip implements Comparable { +public class URWRStrip implements Comparable { - private DetectorDescriptor desc = new DetectorDescriptor(DetectorType.URWELL); + private DetectorDescriptor desc = new DetectorDescriptor(DetectorType.URWT); private int chamber = 0; @@ -36,11 +36,11 @@ public class URWellStrip implements Comparable { private double time = 0; - public URWellStrip(int sector, int layer, int component){ + public URWRStrip(int sector, int layer, int component){ this.desc.setSectorLayerComponent(sector, layer, component); } - public URWellStrip(int sector, int layer, int component, int ADC, int TDC){ + public URWRStrip(int sector, int layer, int component, int ADC, int TDC){ this.desc.setSectorLayerComponent(sector, layer, component); this.ADC = ADC; this.TDC = TDC; @@ -135,7 +135,7 @@ public void setStatus(int status) { this.status = status; } - public boolean isNeighbour(URWellStrip strip){ + public boolean isNeighbour(URWRStrip strip){ if(strip.getDescriptor().getSector()==this.desc.getSector()&& strip.getDescriptor().getLayer()==this.desc.getLayer()){ int s1 = strip.getDescriptor().getComponent(); @@ -145,13 +145,13 @@ public boolean isNeighbour(URWellStrip strip){ return false; } - public boolean isInTime(URWellStrip strip) { - return Math.abs(this.getTime() - strip.getTime()) < URWellConstants.COINCTIME; + public boolean isInTime(URWRStrip strip) { + return Math.abs(this.getTime() - strip.getTime()) < URWTConstants.COINCTIME; } @Override public int compareTo(Object o) { - URWellStrip ob = (URWellStrip) o; + URWRStrip ob = (URWRStrip) o; if(ob.getDescriptor().getSector() < this.desc.getSector()) return 1; if(ob.getDescriptor().getSector() > this.desc.getSector()) return -1; if(ob.getDescriptor().getLayer() < this.desc.getLayer()) return 1; @@ -161,14 +161,14 @@ public int compareTo(Object o) { return -1; } - public static List getStrips(DataEvent event, URWellStripFactory factory, ConstantsManager ccdb) { + public static List getStrips(DataEvent event, URWTStripFactory factory, ConstantsManager ccdb) { - List strips = new ArrayList<>(); + List strips = new ArrayList<>(); - if(event.hasBank("URWELL::adc")){ - RawDataBank bank = new RawDataBank("URWELL::adc"); + if(event.hasBank("URWT::adc")){ + RawDataBank bank = new RawDataBank("URWT::adc"); bank.read(event); - //DataBank bank = event.getBank("URWELL::adc"); + //DataBank bank = event.getBank("URWT::adc"); for(int i = 0; i < bank.rows(); i++){ int sector = bank.getByte("sector", i); int layer = bank.getByte("layer", i); @@ -176,19 +176,19 @@ public static List getStrips(DataEvent event, URWellStripFactory fa int adc = bank.getInt("ADC", i); double time = bank.getFloat("time", i); - URWellStrip strip = new URWellStrip(sector, layer, comp); + URWRStrip strip = new URWRStrip(sector, layer, comp); // strip.setTriggerPhase(triggerPhase); strip.setId(bank.trueIndex(i)+1); strip.setADC(adc); strip.setTDC((int) time); - strip.setEnergy(strip.ADC*URWellConstants.ADCTOENERGY); - strip.setTime(strip.TDC*URWellConstants.TDCTOTIME); + strip.setEnergy(strip.ADC*URWTConstants.ADCTOENERGY); + strip.setTime(strip.TDC*URWTConstants.TDCTOTIME); strip.setLine(factory.getStrip(sector, layer, comp)); - strip.setChamber(factory.getChamberIndex(comp)+1); +// strip.setChamber(factory.getChamberIndex(comp)+1); strip.setStatus(0); - if(strip.getEnergy()>URWellConstants.THRESHOLD) strips.add(strip); + if(strip.getEnergy()>URWTConstants.THRESHOLD) strips.add(strip); } } diff --git a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellCluster.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTCluster.java similarity index 83% rename from reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellCluster.java rename to reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTCluster.java index 8f5987754f..683d8bd2a7 100644 --- a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellCluster.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTCluster.java @@ -1,4 +1,4 @@ -package org.jlab.service.urwell; +package org.jlab.service.urwt; import java.util.ArrayList; import java.util.List; @@ -8,20 +8,20 @@ import org.jlab.geom.prim.Point3D; /** - * URWell in-layer cluster + * URWT in-layer cluster * * @author bondi, devita */ -public class URWellCluster extends ArrayList { +public class URWTCluster extends ArrayList { - private DetectorDescriptor desc = new DetectorDescriptor(DetectorType.URWELL); + private DetectorDescriptor desc = new DetectorDescriptor(DetectorType.URWT); private int id; private Line3D clusterLine = new Line3D(); public int indexMaxStrip = -1; private byte clusterStatus = 1; - public URWellCluster(URWellStrip strip){ + public URWTCluster(URWRStrip strip){ this.desc.setSectorLayerComponent(strip.getDescriptor().getSector(), strip.getDescriptor().getLayer(), 0); this.add(strip); @@ -53,7 +53,7 @@ public int getChamber() { public double getEnergy(){ double energy = 0.0; - for(URWellStrip strip : this){ + for(URWRStrip strip : this){ energy += strip.getEnergy(); } return energy; @@ -61,7 +61,7 @@ public double getEnergy(){ public double getTime(){ double time = 0.0; - for(URWellStrip strip : this){ + for(URWRStrip strip : this){ time += strip.getTime()*strip.getEnergy(); } time /= this.getEnergy(); @@ -75,7 +75,7 @@ public double getSeedTime(){ return 0.0; } - public URWellStrip getSeedStrip() { + public URWRStrip getSeedStrip() { return this.get(this.indexMaxStrip); } @@ -83,8 +83,8 @@ public int getMaxStrip(){ return this.get(this.indexMaxStrip).getDescriptor().getComponent(); } - public boolean addStrip(URWellStrip strip){ - for(URWellStrip s : this){ + public boolean addStrip(URWRStrip strip){ + for(URWRStrip s : this){ if(s.isNeighbour(strip)){ this.add(strip); if(strip.getEnergy()>this.get(indexMaxStrip).getEnergy()){ @@ -99,7 +99,7 @@ public boolean addStrip(URWellStrip strip){ public int getADC(){ int adc = 0; - for(URWellStrip s : this){ + for(URWRStrip s : this){ adc+= s.getADC(); } return adc; @@ -111,7 +111,7 @@ public int getADC(){ public void setClusterId(int id){ this.id = id; - for(URWellStrip strip : this){ + for(URWRStrip strip : this){ strip.setClusterId(id); } } @@ -155,20 +155,20 @@ public void redoClusterLine(){ } - public static List createClusters(List stripList){ + public static List createClusters(List stripList){ - List clusterList = new ArrayList<>(); + List clusterList = new ArrayList<>(); if(!stripList.isEmpty()){ for(int loop = 0; loop < stripList.size(); loop++){ //Loop over all strips boolean stripAdded = false; - for(URWellCluster cluster : clusterList) { + for(URWTCluster cluster : clusterList) { if(cluster.addStrip(stripList.get(loop))){ //Add adjacent strip to newly seeded peak stripAdded = true; } } if(!stripAdded){ - URWellCluster newPeak = new URWellCluster(stripList.get(loop)); //Non-adjacent strip seeds new peak + URWTCluster newPeak = new URWTCluster(stripList.get(loop)); //Non-adjacent strip seeds new peak clusterList.add(newPeak); } } @@ -180,9 +180,9 @@ public static List createClusters(List stripList){ return clusterList; } - public static List getClusters(List clusters, int sector, int layer) { - List selectedClusters = new ArrayList<>(); - for(URWellCluster cluster : clusters) { + public static List getClusters(List clusters, int sector, int layer) { + List selectedClusters = new ArrayList<>(); + for(URWTCluster cluster : clusters) { if(cluster.getSector()==sector && cluster.getLayer()==layer) selectedClusters.add(cluster); } @@ -196,7 +196,7 @@ public String toString(){ this.desc.getSector(),this.desc.getLayer(), this.getEnergy())); str.append(this.clusterLine.toString()); str.append("\n"); - for(URWellStrip strip : this){ + for(URWRStrip strip : this){ str.append("\t\t"); str.append(strip.toString()); str.append("\n"); diff --git a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellConstants.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTConstants.java similarity index 93% rename from reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellConstants.java rename to reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTConstants.java index a825418809..09d657ab75 100644 --- a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellConstants.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTConstants.java @@ -1,10 +1,10 @@ -package org.jlab.service.urwell; +package org.jlab.service.urwt; /** * * @author bondi, devita */ -public class URWellConstants { +public class URWTConstants { // geometry diff --git a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellCross.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTCross.java similarity index 72% rename from reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellCross.java rename to reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTCross.java index 90fa1d2c4f..758c83ca03 100644 --- a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellCross.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTCross.java @@ -1,4 +1,4 @@ -package org.jlab.service.urwell; +package org.jlab.service.urwt; import java.util.ArrayList; import java.util.List; @@ -10,7 +10,7 @@ * URWell V-W clusters * @author devita */ -public class URWellCross { +public class URWTCross { private int id; @@ -28,7 +28,7 @@ public class URWellCross { - public URWellCross(URWellCluster c1, URWellCluster c2) { + public URWTCross(URWTCluster c1, URWTCluster c2) { Vector3D dir = c1.getLine().direction().cross(c2.getLine().direction()); Plane3D plane = new Plane3D(c1.getLine().origin(), c1.getLine().direction().cross(dir)); @@ -36,7 +36,7 @@ public URWellCross(URWellCluster c1, URWellCluster c2) { int nint = plane.intersectionSegment(c2.getLine(), point); if(nint==1) { this.sector = c1.getSector(); - this.region = (c1.getLayer()-1)/(URWellConstants.NLAYER/URWellConstants.NREGION)+1; + this.region = (c1.getLayer()-1)/(URWTConstants.NLAYER/URWTConstants.NREGION)+1; this.cross = point; this.energy = c1.getEnergy() + c2.getEnergy(); this.time = (c1.getTime() + c2.getTime())/2; @@ -89,20 +89,20 @@ public int getStatus() { return status; } - public static List createCrosses(List clusters) { + public static List createCrosses(List clusters) { - List crosses = new ArrayList<>(); + List crosses = new ArrayList<>(); - for(int is=0; is clustersV = URWellCluster.getClusters(clusters, is+1, (URWellConstants.NLAYER/URWellConstants.NREGION)*ir+1); - List clustersW = URWellCluster.getClusters(clusters, is+1, (URWellConstants.NLAYER/URWellConstants.NREGION)*ir+2); + for(int is=0; is clustersV = URWTCluster.getClusters(clusters, is+1, (URWTConstants.NLAYER/URWTConstants.NREGION)*ir+1); + List clustersW = URWTCluster.getClusters(clusters, is+1, (URWTConstants.NLAYER/URWTConstants.NREGION)*ir+2); - for(URWellCluster v : clustersV) { - for(URWellCluster w : clustersW) { + for(URWTCluster v : clustersV) { + for(URWTCluster w : clustersW) { if(v.getChamber()==w.getChamber()) { - URWellCross cross = new URWellCross(v, w); + URWTCross cross = new URWTCross(v, w); if(cross.point()!=null) crosses.add(cross); cross.setId(crosses.size()); } diff --git a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellEngine.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java similarity index 81% rename from reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellEngine.java rename to reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java index fcb53c5ad1..a9ef19dd78 100644 --- a/reconstruction/urwell/src/main/java/org/jlab/service/urwell/URWellEngine.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java @@ -1,4 +1,4 @@ -package org.jlab.service.urwell; +package org.jlab.service.urwt; import java.util.List; import java.util.Optional; @@ -8,7 +8,7 @@ import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.URWELL.URWellStripFactory; +import org.jlab.detector.geant4.v2.URWT.URWTStripFactory; import org.jlab.geom.prim.Point3D; import org.jlab.groot.data.H1F; import org.jlab.groot.fitter.DataFitter; @@ -21,18 +21,18 @@ /** * - * URWell reconstruction engine + * URWT reconstruction engine * * @author bondi, devita */ -public class URWellEngine extends ReconstructionEngine { +public class URWTEngine extends ReconstructionEngine { - public static Logger LOGGER = Logger.getLogger(URWellEngine.class.getName()); + public static Logger LOGGER = Logger.getLogger(URWTEngine.class.getName()); - public static URWellStripFactory factory = new URWellStripFactory(); + public URWTStripFactory factory = null; - public URWellEngine() { - super("URWell","bondi","1.0"); + public URWTEngine() { + super("URWT","bondi","1.0"); } @Override @@ -41,13 +41,13 @@ public boolean init() { // init ConstantsManager to read constants from CCDB String variationName = Optional.ofNullable(this.getEngineConfigString("variation")).orElse("default"); DatabaseConstantProvider cp = new DatabaseConstantProvider(11, variationName); - factory.init(cp, false, URWellConstants.NREGION); + factory = new URWTStripFactory(cp, variationName); // register output banks for drop option - this.registerOutputBank("URWELL::hits"); - this.registerOutputBank("URWELL::clusters"); - this.registerOutputBank("URWELL::crosses"); + this.registerOutputBank("URWT::hits"); + this.registerOutputBank("URWT::clusters"); + this.registerOutputBank("URWT::crosses"); - LOGGER.log(Level.INFO, "--> URWells are ready..."); + LOGGER.log(Level.INFO, "--> URWTs are ready..."); return true; } @@ -57,9 +57,9 @@ public boolean init() { @Override public boolean processDataEvent(DataEvent event) { - List strips = URWellStrip.getStrips(event, factory, this.getConstantsManager()); - List clusters = URWellCluster.createClusters(strips); - List crosses = URWellCross.createCrosses(clusters); + List strips = URWRStrip.getStrips(event, factory, this.getConstantsManager()); + List clusters = URWTCluster.createClusters(strips); + List crosses = URWTCross.createCrosses(clusters); this.writeHipoBanks(event, strips, clusters, crosses); @@ -68,11 +68,11 @@ public boolean processDataEvent(DataEvent event) { private void writeHipoBanks(DataEvent de, - List strips, - List clusters, - List crosses){ + List strips, + List clusters, + List crosses){ - DataBank bankS = de.createBank("URWELL::hits", strips.size()); + DataBank bankS = de.createBank("URWT::hits", strips.size()); for(int h = 0; h < strips.size(); h++){ bankS.setShort("id", h, (short) strips.get(h).getId()); bankS.setByte("sector", h, (byte) strips.get(h).getDescriptor().getSector()); @@ -84,7 +84,7 @@ private void writeHipoBanks(DataEvent de, bankS.setShort("clusterId", h, (short) strips.get(h).getClusterId()); } - DataBank bankC = de.createBank("URWELL::clusters", clusters.size()); + DataBank bankC = de.createBank("URWT::clusters", clusters.size()); for(int c = 0; c < clusters.size(); c++){ bankC.setShort("id", c, (short) clusters.get(c).getId()); bankC.setByte("sector", c, (byte) clusters.get(c).get(0).getDescriptor().getSector()); @@ -102,7 +102,7 @@ private void writeHipoBanks(DataEvent de, bankC.setShort("status", c, (short) clusters.get(c).getStatus()); } - DataBank bankX = de.createBank("URWELL::crosses", crosses.size()); + DataBank bankX = de.createBank("URWT::crosses", crosses.size()); for(int c = 0; c < crosses.size(); c++){ bankX.setShort("id", c, (short) crosses.get(c).getId()); bankX.setByte("sector", c, (byte) crosses.get(c).getSector()); @@ -154,14 +154,14 @@ public static void fitGauss(H1F histo) { public static void main (String arg[]) { - URWellEngine engine = new URWellEngine(); + URWTEngine engine = new URWTEngine(); engine.init(); String input = "/Users/devita/urwell3d.hipo"; DataGroup dg = new DataGroup(3, 2); String[] axes = {"x", "y"}; - for(int il=0; il Date: Wed, 4 Feb 2026 19:50:06 -0500 Subject: [PATCH 3/6] some refactoring --- .../v2/{ => mpgd}/MUVT/MUVTConstants.java | 6 ++-- .../v2/{ => mpgd}/MUVT/MUVTGeant4Factory.java | 8 ++--- .../v2/{ => mpgd}/MUVT/MUVTStripFactory.java | 6 ++-- .../v2/{ => mpgd}/URWT/URWTConstants.java | 6 ++-- .../v2/{ => mpgd}/URWT/URWTGeant4Factory.java | 8 ++--- .../v2/{ => mpgd}/URWT/URWTStripFactory.java | 6 ++-- ...tants.java => MPGDTrapezoidConstants.java} | 8 ++--- ...y.java => MPGDTrapezoidGeant4Factory.java} | 30 +++++++++---------- ...ry.java => MPGDTrapezoidStripFactory.java} | 14 ++++----- .../org/jlab/clas/reco/EngineProcessor.java | 2 +- .../java/org/jlab/service/urwt/URWRStrip.java | 2 +- .../org/jlab/service/urwt/URWTEngine.java | 2 +- 12 files changed, 49 insertions(+), 49 deletions(-) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{ => mpgd}/MUVT/MUVTConstants.java (86%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{ => mpgd}/MUVT/MUVTGeant4Factory.java (87%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{ => mpgd}/MUVT/MUVTStripFactory.java (93%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{ => mpgd}/URWT/URWTConstants.java (86%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{ => mpgd}/URWT/URWTGeant4Factory.java (90%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{ => mpgd}/URWT/URWTStripFactory.java (93%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/{AbstractMPGDTrapezoidConstants.java => MPGDTrapezoidConstants.java} (97%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/{AbstractMPGDTrapezoidGeant4Factory.java => MPGDTrapezoidGeant4Factory.java} (90%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/{AbstractMPGDTrapezoidStripFactory.java => MPGDTrapezoidStripFactory.java} (97%) diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTConstants.java similarity index 86% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTConstants.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTConstants.java index 0504e77f7d..382f3b244d 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTConstants.java @@ -1,12 +1,12 @@ -package org.jlab.detector.geant4.v2.MUVT; +package org.jlab.detector.geant4.v2.MPGD.MUVT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidConstants; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidConstants; /** * URWT-specific constants. */ -public final class MUVTConstants extends AbstractMPGDTrapezoidConstants { +public final class MUVTConstants extends MPGDTrapezoidConstants { private static final MUVTConstants INSTANCE = diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTGeant4Factory.java similarity index 87% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTGeant4Factory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTGeant4Factory.java index 60aafe9f56..5a65b0a820 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTGeant4Factory.java @@ -1,20 +1,20 @@ -package org.jlab.detector.geant4.v2.MUVT; +package org.jlab.detector.geant4.v2.MPGD.MUVT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidGeant4Factory; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidGeant4Factory; /** * Geant4 factory for the muCLAS Forward Vertex Tracker (muVT). * * This class specializes the generic - * {@link AbstractMPGDTrapezoidGeant4Factory} by: + * {@link MPGDTrapezoidGeant4Factory} by: * - passing the MUVT-specific constants * - using "MUVT" as detector name in volume names * * All the geometry construction (sectors, regions, material stack) * is implemented in the base class. */ -public final class MUVTGeant4Factory extends AbstractMPGDTrapezoidGeant4Factory { +public final class MUVTGeant4Factory extends MPGDTrapezoidGeant4Factory { private final String variation; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTStripFactory.java similarity index 93% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTStripFactory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTStripFactory.java index 162bdc8adf..acd9a4cac7 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MUVT/MUVTStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTStripFactory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MUVT; +package org.jlab.detector.geant4.v2.MPGD.MUVT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidStripFactory; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidStripFactory; import org.jlab.detector.volume.Geant4Basic; import java.util.HashMap; @@ -18,7 +18,7 @@ * The ONLY detector-specific thing here is the mapping "volume name -> Geant4Basic", * used by the abstract class to find the sensitive volume (Sensitivity==1) and its transform. */ -public final class MUVTStripFactory extends AbstractMPGDTrapezoidStripFactory { +public final class MUVTStripFactory extends MPGDTrapezoidStripFactory { private final Map volumeByName = new HashMap<>(); diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTConstants.java similarity index 86% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTConstants.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTConstants.java index 331c1434fd..03c0bede72 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTConstants.java @@ -1,12 +1,12 @@ -package org.jlab.detector.geant4.v2.URWT; +package org.jlab.detector.geant4.v2.MPGD.URWT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidConstants; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidConstants; /** * URWT-specific constants. */ -public final class URWTConstants extends AbstractMPGDTrapezoidConstants { +public final class URWTConstants extends MPGDTrapezoidConstants { private static final URWTConstants INSTANCE = diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTGeant4Factory.java similarity index 90% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTGeant4Factory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTGeant4Factory.java index d868780f68..b68a2cfa0f 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTGeant4Factory.java @@ -1,19 +1,19 @@ -package org.jlab.detector.geant4.v2.URWT; +package org.jlab.detector.geant4.v2.MPGD.URWT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidGeant4Factory; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidGeant4Factory; /** * Geant4 factory for the uRWell Tracker (URWT). * - * This class specializes the generic {@link AbstractMPGDTrapezoidGeant4Factory} + * This class specializes the generic {@link MPGDTrapezoidGeant4Factory} * by: - passing the URWT-specific constants - using "uRWT" as detector name in * volume names * * All the geometry construction (sectors, regions, material stack) is * implemented in the base class. */ -public final class URWTGeant4Factory extends AbstractMPGDTrapezoidGeant4Factory { +public final class URWTGeant4Factory extends MPGDTrapezoidGeant4Factory { private final String variation; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTStripFactory.java similarity index 93% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTStripFactory.java index 82cafbddc2..0494f3a823 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWT/URWTStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTStripFactory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.URWT; +package org.jlab.detector.geant4.v2.MPGD.URWT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.mpgd.trapezoid.AbstractMPGDTrapezoidStripFactory; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidStripFactory; import org.jlab.detector.volume.Geant4Basic; import java.util.HashMap; @@ -18,7 +18,7 @@ * The ONLY detector-specific thing here is the mapping "volume name -> Geant4Basic", * used by the abstract class to find the sensitive volume (Sensitivity==1) and its transform. */ -public final class URWTStripFactory extends AbstractMPGDTrapezoidStripFactory { +public final class URWTStripFactory extends MPGDTrapezoidStripFactory { private final Map volumeByName = new HashMap<>(); diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidConstants.java similarity index 97% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidConstants.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidConstants.java index 692b96382d..72247d0f2a 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidConstants.java @@ -1,4 +1,4 @@ -package org.jlab.detector.geant4.v2.mpgd.trapezoid; +package org.jlab.detector.geant4.v2.MPGD.trapezoid; import org.jlab.detector.calib.utils.DatabaseConstantProvider; @@ -11,13 +11,13 @@ * Concrete detectors (e.g. URWT) should extend this class and provide: - CCDB * base path - global table name - material table name */ -public abstract class AbstractMPGDTrapezoidConstants { +public abstract class MPGDTrapezoidConstants { // ------------------------------------------------------------------------ // Logging / verbosity // ------------------------------------------------------------------------ public static final Logger LOGGER - = Logger.getLogger(AbstractMPGDTrapezoidConstants.class.getName()); + = Logger.getLogger(MPGDTrapezoidConstants.class.getName()); public static boolean VERBOSE = false; @@ -98,7 +98,7 @@ public LayerComponentInfo(double thickness, int sensitivity) { * @param materialTableName name of the material table (e.g. * "urwt_material_geo") */ - protected AbstractMPGDTrapezoidConstants(String ccdbPath, + protected MPGDTrapezoidConstants(String ccdbPath, String globalTableName, String materialTableName) { this.ccdbPath = ccdbPath; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidGeant4Factory.java similarity index 90% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidGeant4Factory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidGeant4Factory.java index 441900b6b1..ae80730337 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidGeant4Factory.java @@ -1,4 +1,4 @@ -package org.jlab.detector.geant4.v2.mpgd.trapezoid; +package org.jlab.detector.geant4.v2.MPGD.trapezoid; import eu.mihosoft.vrl.v3d.Vector3d; import org.jlab.detector.geant4.v2.Geant4Factory; @@ -15,17 +15,17 @@ * per region * * The exact geometry parameters and material stack are taken from an - * {@link AbstractMPGDTrapezoidConstants} instance. + * {@link MPGDTrapezoidConstants} instance. * * Concrete detectors should: - extend this class - pass the appropriate * constants + detector name in the constructor */ -public abstract class AbstractMPGDTrapezoidGeant4Factory extends Geant4Factory { +public abstract class MPGDTrapezoidGeant4Factory extends Geant4Factory { /** * Detector constants (geometry + materials from CCDB). */ - protected final AbstractMPGDTrapezoidConstants C; + protected final MPGDTrapezoidConstants C; /** * Short detector name used in volume names (e.g. "uRWT"). @@ -47,7 +47,7 @@ public static record SectorDimensions( * paths/table names) * @param detectorName short detector name used in volume names */ - protected AbstractMPGDTrapezoidGeant4Factory(AbstractMPGDTrapezoidConstants constants, + protected MPGDTrapezoidGeant4Factory(MPGDTrapezoidConstants constants, String detectorName) { this.C = constants; this.detectorName = detectorName; @@ -122,7 +122,7 @@ public SectorDimensions getSectorDimensionsPhysical(int region) { double twidth_Check = 2 * halfLargeBase * Math.sin(Math.toRadians(C.THOPEN)); - if (AbstractMPGDTrapezoidConstants.VERBOSE) { + if (MPGDTrapezoidConstants.VERBOSE) { System.out.printf("C.TWIDT=%.3f vs %.3f", C.TWIDTH, twidth_Check); System.out.printf("YMIN=%.3f", YMIN); @@ -149,10 +149,10 @@ public SectorDimensions getSectorDimensionsContainer(int region) { SectorDimensions phys = getSectorDimensionsPhysical(region); - double halfThickness = phys.halfThickness() + AbstractMPGDTrapezoidConstants.ZENLARGEMENT; - double halfHeight = phys.halfHeight() + AbstractMPGDTrapezoidConstants.YENLARGEMENT; - double halfLargeBase = phys.halfLargeBase() + AbstractMPGDTrapezoidConstants.XENLARGEMENT; - double halfSmallBase = phys.halfSmallBase() + AbstractMPGDTrapezoidConstants.XENLARGEMENT; + double halfThickness = phys.halfThickness() + MPGDTrapezoidConstants.ZENLARGEMENT; + double halfHeight = phys.halfHeight() + MPGDTrapezoidConstants.YENLARGEMENT; + double halfLargeBase = phys.halfLargeBase() + MPGDTrapezoidConstants.XENLARGEMENT; + double halfSmallBase = phys.halfSmallBase() + MPGDTrapezoidConstants.XENLARGEMENT; return new SectorDimensions(halfThickness, halfHeight, halfLargeBase, halfSmallBase, phys.tiltRad()); } @@ -172,7 +172,7 @@ public double getSectorHeight(int region) { * (Math.tan(Math.toRadians(C.THMAX - C.THTILT)) + Math.tan(Math.toRadians(C.THTILT - C.THMIN))); - if (AbstractMPGDTrapezoidConstants.VERBOSE) { + if (MPGDTrapezoidConstants.VERBOSE) { System.out.printf( "SectorHeight [%s] region=%d : baseDistance=%.3f THMIN=%.3f THMAX=%.3f THTILT=%.3f -> height=%.3f%n", detectorName, @@ -297,18 +297,18 @@ protected void populateSectorWithDetectorStructure(Geant4Basic sectorVolume, double totalThickness = 2.0 * halfThickness; double accumulatedThickness = 0.0; - for (Map.Entry> layerEntry + for (Map.Entry> layerEntry : C.getDetectorStructure().entrySet()) { int LayerId = layerEntry.getKey(); - Map componentMap + Map componentMap = layerEntry.getValue(); - for (Map.Entry componentEntry + for (Map.Entry componentEntry : componentMap.entrySet()) { int materialComponentId = componentEntry.getKey(); - AbstractMPGDTrapezoidConstants.LayerComponentInfo info = componentEntry.getValue(); + MPGDTrapezoidConstants.LayerComponentInfo info = componentEntry.getValue(); double thick = info.thickness; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidStripFactory.java similarity index 97% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidStripFactory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidStripFactory.java index 3b4608e840..93616cf749 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/AbstractMPGDTrapezoidStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidStripFactory.java @@ -1,4 +1,4 @@ -package org.jlab.detector.geant4.v2.mpgd.trapezoid; +package org.jlab.detector.geant4.v2.MPGD.trapezoid; import eu.mihosoft.vrl.v3d.Vector3d; import org.jlab.detector.volume.Geant4Basic; @@ -17,16 +17,16 @@ * Base class implementing strip/surface/plane geometry for trapezoidal MPGD * detectors. */ -public abstract class AbstractMPGDTrapezoidStripFactory { +public abstract class MPGDTrapezoidStripFactory { // ------------------------------------------------------------------------ // Inputs // ------------------------------------------------------------------------ - protected final AbstractMPGDTrapezoidConstants C; - protected final AbstractMPGDTrapezoidGeant4Factory geo; + protected final MPGDTrapezoidConstants C; + protected final MPGDTrapezoidGeant4Factory geo; - protected AbstractMPGDTrapezoidStripFactory(AbstractMPGDTrapezoidConstants constants, - AbstractMPGDTrapezoidGeant4Factory geantFactory) { + protected MPGDTrapezoidStripFactory(MPGDTrapezoidConstants constants, + MPGDTrapezoidGeant4Factory geantFactory) { this.C = constants; this.geo = geantFactory; } @@ -264,7 +264,7 @@ protected Vector3d toGlobalSensitive(int region, int sector, int layer, Vector3d */ protected StripConstants buildStripConstants(int region, int layer) { - AbstractMPGDTrapezoidGeant4Factory.SectorDimensions phys + MPGDTrapezoidGeant4Factory.SectorDimensions phys = geo.getSectorDimensionsPhysical(region - 1); StripConstants sc = new StripConstants(); diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java index 81f103bbf9..57b60fb0b4 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java @@ -154,7 +154,7 @@ public void initAll(){ "org.jlab.rec.ft.hodo.FTHODOEngine", "org.jlab.rec.ft.trk.FTTRKEngine", "org.jlab.rec.ft.FTEBEngine", - "org.jlab.service.urwell.URWellEngine", + "org.jlab.service.urwt.URWTEngine", "org.jlab.service.dc.DCHBClustering", "org.jlab.service.dc.DCHBPostClusterConv", "org.jlab.service.ftof.FTOFHBEngine", diff --git a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java index 87bb2714e3..64f5c7c614 100644 --- a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java @@ -6,7 +6,7 @@ import org.jlab.detector.base.DetectorDescriptor; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; -import org.jlab.detector.geant4.v2.URWT.URWTStripFactory; +import org.jlab.detector.geant4.v2.MPGD.URWT.URWTStripFactory; import org.jlab.geom.prim.Line3D; import org.jlab.io.base.DataEvent; diff --git a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java index a9ef19dd78..1acc2b296e 100644 --- a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java @@ -8,7 +8,7 @@ import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.URWT.URWTStripFactory; +import org.jlab.detector.geant4.v2.MPGD.URWT.URWTStripFactory; import org.jlab.geom.prim.Point3D; import org.jlab.groot.data.H1F; import org.jlab.groot.fitter.DataFitter; From 68740bb158be1291e3beee886ffea72b07d75bb6 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Thu, 5 Feb 2026 10:49:57 -0500 Subject: [PATCH 4/6] some refactoring --- .../{mpgd => MPGD2}/MUVT/MUVTConstants.java | 4 +- .../MUVT/MUVTGeant4Factory.java | 4 +- .../MUVT/MUVTStripFactory.java | 4 +- .../{mpgd => MPGD2}/URWT/URWTConstants.java | 4 +- .../URWT/URWTGeant4Factory.java | 4 +- .../URWT/URWTStripFactory.java | 4 +- .../trapezoid/MPGDTrapezoidConstants.java | 4 +- .../trapezoid/MPGDTrapezoidGeant4Factory.java | 8 +- .../trapezoid/MPGDTrapezoidStripFactory.java | 2 +- .../geant4/v2/URWELL/URWellConstants.java | 132 ----- .../geant4/v2/URWELL/URWellGeant4Factory.java | 428 ---------------- .../geant4/v2/URWELL/URWellStripFactory.java | 456 ------------------ .../java/org/jlab/service/urwt/URWRStrip.java | 2 +- .../org/jlab/service/urwt/URWTEngine.java | 2 +- 14 files changed, 21 insertions(+), 1037 deletions(-) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{mpgd => MPGD2}/MUVT/MUVTConstants.java (91%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{mpgd => MPGD2}/MUVT/MUVTGeant4Factory.java (93%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{mpgd => MPGD2}/MUVT/MUVTStripFactory.java (95%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{mpgd => MPGD2}/URWT/URWTConstants.java (91%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{mpgd => MPGD2}/URWT/URWTGeant4Factory.java (95%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{mpgd => MPGD2}/URWT/URWTStripFactory.java (96%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{mpgd => MPGD2}/trapezoid/MPGDTrapezoidConstants.java (98%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{mpgd => MPGD2}/trapezoid/MPGDTrapezoidGeant4Factory.java (97%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{mpgd => MPGD2}/trapezoid/MPGDTrapezoidStripFactory.java (99%) delete mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java delete mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellGeant4Factory.java delete mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellStripFactory.java diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTConstants.java similarity index 91% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTConstants.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTConstants.java index 382f3b244d..729589541f 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTConstants.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD.MUVT; +package org.jlab.detector.geant4.v2.MPGD2.MUVT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidConstants; +import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidConstants; /** * URWT-specific constants. diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTGeant4Factory.java similarity index 93% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTGeant4Factory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTGeant4Factory.java index 5a65b0a820..679b707cbb 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTGeant4Factory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD.MUVT; +package org.jlab.detector.geant4.v2.MPGD2.MUVT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidGeant4Factory; +import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidGeant4Factory; /** * Geant4 factory for the muCLAS Forward Vertex Tracker (muVT). diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTStripFactory.java similarity index 95% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTStripFactory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTStripFactory.java index acd9a4cac7..29eb8b8fc1 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/MUVT/MUVTStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTStripFactory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD.MUVT; +package org.jlab.detector.geant4.v2.MPGD2.MUVT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidStripFactory; +import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidStripFactory; import org.jlab.detector.volume.Geant4Basic; import java.util.HashMap; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTConstants.java similarity index 91% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTConstants.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTConstants.java index 03c0bede72..76832bfbd9 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTConstants.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD.URWT; +package org.jlab.detector.geant4.v2.MPGD2.URWT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidConstants; +import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidConstants; /** * URWT-specific constants. diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTGeant4Factory.java similarity index 95% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTGeant4Factory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTGeant4Factory.java index b68a2cfa0f..822096be5f 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTGeant4Factory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD.URWT; +package org.jlab.detector.geant4.v2.MPGD2.URWT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidGeant4Factory; +import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidGeant4Factory; /** * Geant4 factory for the uRWell Tracker (URWT). diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTStripFactory.java similarity index 96% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTStripFactory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTStripFactory.java index 0494f3a823..d02157cac0 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/URWT/URWTStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTStripFactory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD.URWT; +package org.jlab.detector.geant4.v2.MPGD2.URWT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidStripFactory; +import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidStripFactory; import org.jlab.detector.volume.Geant4Basic; import java.util.HashMap; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidConstants.java similarity index 98% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidConstants.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidConstants.java index 72247d0f2a..8515c37e61 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidConstants.java @@ -1,4 +1,4 @@ -package org.jlab.detector.geant4.v2.MPGD.trapezoid; +package org.jlab.detector.geant4.v2.MPGD2.trapezoid; import org.jlab.detector.calib.utils.DatabaseConstantProvider; @@ -101,7 +101,7 @@ public LayerComponentInfo(double thickness, int sensitivity) { protected MPGDTrapezoidConstants(String ccdbPath, String globalTableName, String materialTableName) { - this.ccdbPath = ccdbPath; + this.ccdbPath = ccdbPath.endsWith("/") ? ccdbPath : ccdbPath + "/"; this.globalTableName = globalTableName; this.materialTableName = materialTableName; } diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidGeant4Factory.java similarity index 97% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidGeant4Factory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidGeant4Factory.java index ae80730337..1a80958c9a 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidGeant4Factory.java @@ -1,4 +1,4 @@ -package org.jlab.detector.geant4.v2.MPGD.trapezoid; +package org.jlab.detector.geant4.v2.MPGD2.trapezoid; import eu.mihosoft.vrl.v3d.Vector3d; import org.jlab.detector.geant4.v2.Geant4Factory; @@ -145,7 +145,7 @@ public SectorDimensions getSectorDimensionsPhysical(int region) { * @param region * @return */ - public SectorDimensions getSectorDimensionsContainer(int region) { + public SectorDimensions getSectorContainerDimensions(int region) { SectorDimensions phys = getSectorDimensionsPhysical(region); @@ -205,7 +205,7 @@ public Vector3d getCenterCoordinate(int isector, int iregion) { double YMIN = W2TGT * Math.sin(Math.toRadians(C.THMIN)); // distance from beamline (Y) double ZMIN = W2TGT * Math.cos(Math.toRadians(C.THMIN)); // Z of the bottom base - SectorDimensions dimCont = this.getSectorDimensionsContainer(iregion); + SectorDimensions dimCont = this.getSectorContainerDimensions(iregion); double sectorHeight = 2 * dimCont.halfHeight(); vCenter.x = 0.0; @@ -231,7 +231,7 @@ public Vector3d getCenterCoordinate(int isector, int iregion) { public Geant4Basic createSector(int isector, int iregion) { SectorDimensions dimPhys = this.getSectorDimensionsPhysical(iregion); - SectorDimensions dimCont = this.getSectorDimensionsContainer(iregion); + SectorDimensions dimCont = this.getSectorContainerDimensions(iregion); Geant4Basic sectorVolume = createSectorVolume(isector, iregion, dimCont); populateSectorWithDetectorStructure(sectorVolume, isector, iregion, dimPhys); diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidStripFactory.java similarity index 99% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidStripFactory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidStripFactory.java index 93616cf749..0eb0fab438 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/mpgd/trapezoid/MPGDTrapezoidStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidStripFactory.java @@ -1,4 +1,4 @@ -package org.jlab.detector.geant4.v2.MPGD.trapezoid; +package org.jlab.detector.geant4.v2.MPGD2.trapezoid; import eu.mihosoft.vrl.v3d.Vector3d; import org.jlab.detector.volume.Geant4Basic; 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 deleted file mode 100644 index 81b08bf569..0000000000 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellConstants.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.jlab.detector.geant4.v2.URWELL; - - -import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.geom.prim.Point3D; - - -public class URWellConstants { - - private final static String CCDBPATH = "/geometry/urwell/"; - - public final static int NMAXREGIONS = 2; //max number of regions - public final static int NREGIONS = 1; //number of regions - public final static int NSECTORS = 6; //number of sectors - public final static int NLAYERS = 2; //number of layers - public final static int NCHAMBERS = 3; //number of chambers in a sector - - public final static double XENLARGEMENT = 0.5; // cm - public final static double YENLARGEMENT = 1.; // cm - public final static double ZENLARGEMENT = 0.1; // cm - - // Sector geometrical parameters - public final static double THOPEN = 54.; // opening angle between endplate planes (deg) - public final static double THTILT = 25; // theta tilt (deg) - public final static double THMIN = 4.694; // polar angle to the base of first chamber (deg) - public final static double SECTORHEIGHT = 146.21; //height of each sector (cm) - public final static double DX0CHAMBER0 = 5.197; // halfbase of chamber 1 (cm) - - // Chamber volumes and materials (units are cm) - public final static double[] CHAMBERVOLUMESTHICKNESS = {0.0025, 0.0005,0.3, // window - 0.0025, 0.0005,0.4, // cathode - 0.0005, 0.005, 0.0005, // uRWell + DlC - 0.0005, 0.005, 0.0005, // Capacitive sharing layer1 - 0.0005, 0.005, 0.0005, // Capacitive sharing layer2 - 0.005, 0.0005,0.005, 0.005, 0.0005,0.005, 0.005, // Readout - 0.0127, 0.3, 0.0125}; // support - public final static String[] CHAMBERVOLUMESNAME = {"window_kapton", "window_Al", "window_gas", - "cathode_kapton", "cathode_Al", "cathode_gas", - "muRwell_Cu", "muRwell_kapton", "muRwell_dlc", - "capa_sharing_layer1_glue","capa_sharing_layer1_Cr","capa_sharing_layer1_kapton", - "capa_sharing_layer2_glue","capa_sharing_layer2_Cr","capa_sharing_layer2_kapton", - "readout1_glue", "readout1_Cu", "readout1_kapton", "readout2_glue", "readout2_Cu", "readout2_kapton", "readout3_glue", - "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 URWELL2DC0 = 2; // cm - public final static double URWELL2DC0[] = new double[NMAXREGIONS]; - public final static double DIST2TGT[] = new double[NMAXREGIONS]; - public final static double W2TGT[] = new double[NMAXREGIONS];; - public final static double YMIN[] = new double[NMAXREGIONS]; - public final static double ZMIN[] = new double[NMAXREGIONS]; - - // public final static double DIST2TGT = (TGT2DC0-URWELL2DC0); - // public final static double W2TGT = DIST2TGT/Math.cos(Math.toRadians(THTILT-THMIN)); - // public final static double YMIN = W2TGT*Math.sin(Math.toRadians(THMIN)); // distance from the base chamber1 and beamline - // public final static double ZMIN = W2TGT*Math.cos(Math.toRadians(THMIN)); - public final static double PITCH = 0.1 ; // cm - public final static double STEREOANGLE = 10; // deg - - - - // URWELL - PROTO information // - /* - public final static double DX0_PROTO = 101.2; //cm - public final static double DX1_PROTO = 146.2; //cm - public final static double HEIGHT_PROTO = 50; //cm - */ - // public final static int THILT_PROTO; // theta tilt (deg) - public final static int NREGIONS_PROTO = 1; //number of regions - public final static int NSECTORS_PROTO = 1; //number of sectors - public final static int NCHAMBERS_PROTO = 1; //number of chambers in a sector - - - // URWELL-PROTO position in CLAS12 frame - - // 4 URWELL-PROTO vertex - sensitive plane - public static Point3D Apoint = new Point3D(22.9545, -337.005, 465.9); // {X,Y,Z} - public static Point3D Bpoint = new Point3D(148.906, -264.288, 465.9); // {X,Y,Z} - public static Point3D Cpoint = new Point3D(152.047, -314.276, 445.0); // {X,Y,Z} - public static Point3D Dpoint = new Point3D(64.676, -364.719, 445.0); // {X,Y,Z} - - /* - * @return String a path to a directory in CCDB of the format {@code "/geometry/detector/"} - */ - public static String getCcdbPath() - { - return CCDBPATH; - } - - - - /** - * Loads the the necessary tables for the URWELL geometry for a given DatabaseConstantProvider. - * - * @return DatabaseConstantProvider the same thing - */ - public static DatabaseConstantProvider connect( DatabaseConstantProvider cp ) - { - // cp.loadTable( CCDBPATH +"RWELL"); - - load(cp ); - return cp; - } - - /** - * Reads all the necessary constants from CCDB into static variables. - * Please use a DatabaseConstantProvider to access CCDB and load the following tables: - * @param cp a ConstantProvider that has loaded the necessary tables - */ - - public static synchronized void load( DatabaseConstantProvider cp ) - { - // read constants from svt table -// NREGIONS = cp.getInteger( CCDBPATH+"svt/nRegions", 0 ); - - for (int i=0; i (volume.getName().contains(volumeName))) - .findAny() - .orElse(null); - } - - /** - * Returns the sector volume for the given sector number - * - * @param sector (1-6) - * @return the sector volume - */ - public Geant4Basic getSectorVolume(int region, int sector) { - - int r = region; - int s = sector; - - String volName = "region_uRwell_" + r + "_s" + s; - return this.getAllVolumes().stream() - .filter(volume -> (volume.getName().contains(volName))) - .findAny() - .orElse(null); - } - - - - - - public static void main(String[] args) { - DatabaseConstantProvider cp = new DatabaseConstantProvider(11, "default"); - - URWellConstants.connect(cp); - - URWellGeant4Factory factory = new URWellGeant4Factory(cp, false, 2); - - factory.getAllVolumes().forEach(volume -> { - System.out.println(volume.gemcString()); - }); - - - - } - -} diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellStripFactory.java deleted file mode 100644 index a7ec2edb5f..0000000000 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/URWELL/URWellStripFactory.java +++ /dev/null @@ -1,456 +0,0 @@ -package org.jlab.detector.geant4.v2.URWELL; - - -import eu.mihosoft.vrl.v3d.Vector3d; -import java.util.List; -import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.hits.DetHit; -import org.jlab.detector.volume.Geant4Basic; -import org.jlab.geom.prim.Line3D; -import org.jlab.geom.prim.Plane3D; -import org.jlab.geom.prim.Point3D; -import org.jlab.geom.prim.Vector3D; -import org.jlab.geometry.prim.Line3d; -import org.jlab.geometry.prim.Straight; -import org.jlab.utils.groups.IndexedList; - -/** - * Creates and handles the URWELL detector strips as 3D lines - * - * @author bondi - */ -public final class URWellStripFactory { - - private URWellGeant4Factory factory; - private IndexedList globalStrips = new IndexedList(3); - private IndexedList localStrips = new IndexedList(3); - private IndexedList planeStrips = new IndexedList(3); - private int nRegions; - private int nSectors; - private int nChambers; - private int nLayers; - private boolean isProto; - - public URWellStripFactory() { - } - - /** - * Create the strip factory based on constants from CCDB. - * Currently constants are defined in the URWellConstants class. - * They will be moved to CCDB when finalized). - * @param cp database provide - */ - public URWellStripFactory(DatabaseConstantProvider cp) { - this.init(cp); - } - - /** - * Initialize the factory by the strip maps - * @param cp - */ - public void init(DatabaseConstantProvider cp) { - this.init(cp, false, 1); - } - - /** - * Create the strip factory based on constants from CCDB. - * Currently constants are defined in the URWellConstants class. - * They will be moved to CCDB when finalized). - * @param cp database provide - * @param prototype - * @param regions - */ - public URWellStripFactory(DatabaseConstantProvider cp, boolean prototype, int regions) { - this.init(cp, prototype, regions); - } - - /** - * Initialize the factory by the strip maps - * @param cp - * @param prototype - * @param regions - */ - public void init(DatabaseConstantProvider cp, boolean prototype, int regions) { - factory = new URWellGeant4Factory(cp, prototype, regions); - isProto = prototype; - if(!isProto){ - nRegions = Math.min(URWellConstants.NMAXREGIONS, regions); - nSectors = URWellConstants.NSECTORS; - nChambers = URWellConstants.NCHAMBERS; - nLayers = URWellConstants.NLAYERS; - } - else { - nRegions = URWellConstants.NREGIONS_PROTO; - nSectors = URWellConstants.NSECTORS_PROTO; - nChambers = URWellConstants.NCHAMBERS_PROTO; - nLayers = URWellConstants.NLAYERS; - } - this.fillStripLists(); - this.fillPlaneLists(); - } - - /** - * Calculates the total number of strips in a sector - * - * @return the strip number - */ - public int getNStripSector() { - int nStrips = 0; - for (int i = 0; i < nChambers; i++) { - nStrips += getNStripChamber(i); - } - return nStrips; - } - - /** - * Calculates the number of strips in the given chamber - * - * @param ichamber (0, 1, 2) - * @return the strip number (1-N) - */ - public int getNStripChamber(int ichamber) { - - double[] dim = factory.getChamber_daughter_Dimensions(ichamber); - - double yHalf = dim[0]; - double xHalfSmallBase = dim[1]; - double xHalfLargeBase = dim[2]; - - // C-------------D // - // ------------- // - // ----------- // - // A-------B // - /** - * * number of strip in AB** - */ - int nAB = (int) (2 * xHalfSmallBase / (URWellConstants.PITCH - / Math.sin(Math.toRadians(URWellConstants.STEREOANGLE)))); - - double AC = Math.sqrt((Math.pow((xHalfSmallBase - xHalfLargeBase), 2) + Math.pow((2 * yHalf), 2))); - double theta = Math.acos(2 * yHalf / AC); - int nAC = (int) (AC / (URWellConstants.PITCH - / Math.cos(theta - Math.toRadians(URWellConstants.STEREOANGLE)))); - - int nStrips = nAB + nAC +1 ; - - return nStrips; - } - - /** - * Provides the index of the chamber containing the strip with the given ID - * - * @param strip (1 to N) - * @return the chamber index (0, 1, 2) - */ - public int getChamberIndex(int strip) { - int nStripTotal = 0; - - for(int i=0; i strip ID chamber (from 1 to getNStripChamber) - int nStripTotal = 0; - if (chamberIndex > 0) { - for (int i = 0; i < chamberIndex; i++) { - nStripTotal += this.getNStripChamber(i); - } - } - - //Strip ID: from 1 to getNStripChamber - int cStrip = strip - nStripTotal; - - return cStrip; - } - - /** - * Builds the given strip line in the CLAS12 frame - * @param sector (1-6) - * @param layer (1-2) - * @param strip (1-N) - * @return the 3D strip line as a Line3d - */ - private Line3d createStrip(int sector, int layer, int strip) { - - int chamberIndex = getChamberIndex(strip); - - int cStrip = this.getLocalStripId(strip); - - - // CHAMBER reference frame - // new numeration with stri ID_strip=0 crossing (0,0,0) of chamber - double[] dim = factory.getChamber_daughter_Dimensions(chamberIndex); - - double yHalf = dim[0]; - double xHalfSmallBase = dim[1]; - double xHalfLargeBase = dim[2]; - - - - // Y coordinate of the intersection point between the x=0 and the strip line crossing for B - - double DY = -yHalf - Math.tan(Math.toRadians(URWellConstants.STEREOANGLE)) *xHalfSmallBase; - - // ID of the strip - int nS = (int) (DY * Math.cos(Math.toRadians(URWellConstants.STEREOANGLE)) / URWellConstants.PITCH); - int nCStrip = nS + (cStrip - 1); - - //strip straight line chamber reference frame -> y = mx +c; - double stereoAngle = URWellConstants.STEREOANGLE; - if (layer % 2 != 0) { - stereoAngle = -URWellConstants.STEREOANGLE; - } - double m = Math.tan(Math.toRadians(stereoAngle)); - double c = nCStrip * URWellConstants.PITCH / Math.cos(Math.toRadians(stereoAngle)); - - // Take 2 points in the strip straight line. They needs to define Line object - double oX = -xHalfLargeBase; - double oY = -xHalfLargeBase * m + c; - double oZ = 0; - Vector3d origin = new Vector3d(oX, oY, oZ); - - double eX = xHalfLargeBase; - double eY = xHalfLargeBase * m + c; - double eZ = 0; - Vector3d end = new Vector3d(eX, eY, eZ); - - // Get Chamber Volume - Geant4Basic chamberVolume = factory.getChamberVolume(sector, chamberIndex+1, layer, isProto); - - // 2 point defined before wrt the GLOBAL frame - Vector3d globalOrigin = chamberVolume.getGlobalTransform().transform(origin); - - Vector3d globalEnd = chamberVolume.getGlobalTransform().transform(end); - - - Straight line = new Line3d(globalOrigin, globalEnd); - - // CHECK intersections between line and volume - chamberVolume.makeSensitive(); - List Hits = chamberVolume.getIntersections(line); - - if (Hits.size() >= 1) { - - Vector3d TestOrigin = Hits.get(0).origin(); - Vector3d TestEnd = Hits.get(0).end(); - - return new Line3d(Hits.get(0).origin(), Hits.get(0).end()); - - } else { - return null; - } - } - - /** - * 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) - * @param layer (1-2) - * @param strip (1-N) - * @return the 3D strip line as a Line3d - */ - private Line3d getLocalStrip(int region, int sector, int layer, int strip) { - - Line3d globalStrip = createStrip(sector, layer, strip); - Geant4Basic sVolume = factory.getSectorVolume(region, sector); - - Vector3d origin = sVolume.getGlobalTransform().invert().transform(globalStrip.origin()); - Vector3d end = sVolume.getGlobalTransform().invert().transform(globalStrip.end()); - - Line3d localStrip = new Line3d(origin, end); - - return localStrip; - } - - - private void fillStripLists() { - - for(int ir=0; ir Date: Thu, 5 Feb 2026 10:52:07 -0500 Subject: [PATCH 5/6] some refactoring --- .../geant4/v2/{MPGD2 => MPGD}/MUVT/MUVTConstants.java | 4 ++-- .../geant4/v2/{MPGD2 => MPGD}/MUVT/MUVTGeant4Factory.java | 4 ++-- .../geant4/v2/{MPGD2 => MPGD}/MUVT/MUVTStripFactory.java | 4 ++-- .../geant4/v2/{MPGD2 => MPGD}/URWT/URWTConstants.java | 4 ++-- .../geant4/v2/{MPGD2 => MPGD}/URWT/URWTGeant4Factory.java | 4 ++-- .../geant4/v2/{MPGD2 => MPGD}/URWT/URWTStripFactory.java | 4 ++-- .../v2/{MPGD2 => MPGD}/trapezoid/MPGDTrapezoidConstants.java | 2 +- .../{MPGD2 => MPGD}/trapezoid/MPGDTrapezoidGeant4Factory.java | 2 +- .../{MPGD2 => MPGD}/trapezoid/MPGDTrapezoidStripFactory.java | 2 +- .../urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java | 2 +- .../urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{MPGD2 => MPGD}/MUVT/MUVTConstants.java (91%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{MPGD2 => MPGD}/MUVT/MUVTGeant4Factory.java (93%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{MPGD2 => MPGD}/MUVT/MUVTStripFactory.java (95%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{MPGD2 => MPGD}/URWT/URWTConstants.java (91%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{MPGD2 => MPGD}/URWT/URWTGeant4Factory.java (95%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{MPGD2 => MPGD}/URWT/URWTStripFactory.java (96%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{MPGD2 => MPGD}/trapezoid/MPGDTrapezoidConstants.java (99%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{MPGD2 => MPGD}/trapezoid/MPGDTrapezoidGeant4Factory.java (99%) rename common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/{MPGD2 => MPGD}/trapezoid/MPGDTrapezoidStripFactory.java (99%) diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTConstants.java similarity index 91% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTConstants.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTConstants.java index 729589541f..382f3b244d 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTConstants.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD2.MUVT; +package org.jlab.detector.geant4.v2.MPGD.MUVT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidConstants; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidConstants; /** * URWT-specific constants. diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTGeant4Factory.java similarity index 93% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTGeant4Factory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTGeant4Factory.java index 679b707cbb..5a65b0a820 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTGeant4Factory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD2.MUVT; +package org.jlab.detector.geant4.v2.MPGD.MUVT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidGeant4Factory; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidGeant4Factory; /** * Geant4 factory for the muCLAS Forward Vertex Tracker (muVT). diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTStripFactory.java similarity index 95% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTStripFactory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTStripFactory.java index 29eb8b8fc1..acd9a4cac7 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/MUVT/MUVTStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTStripFactory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD2.MUVT; +package org.jlab.detector.geant4.v2.MPGD.MUVT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidStripFactory; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidStripFactory; import org.jlab.detector.volume.Geant4Basic; import java.util.HashMap; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTConstants.java similarity index 91% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTConstants.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTConstants.java index 76832bfbd9..03c0bede72 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTConstants.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD2.URWT; +package org.jlab.detector.geant4.v2.MPGD.URWT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidConstants; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidConstants; /** * URWT-specific constants. diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTGeant4Factory.java similarity index 95% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTGeant4Factory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTGeant4Factory.java index 822096be5f..b68a2cfa0f 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTGeant4Factory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD2.URWT; +package org.jlab.detector.geant4.v2.MPGD.URWT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidGeant4Factory; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidGeant4Factory; /** * Geant4 factory for the uRWell Tracker (URWT). diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTStripFactory.java similarity index 96% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTStripFactory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTStripFactory.java index d02157cac0..0494f3a823 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/URWT/URWTStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTStripFactory.java @@ -1,7 +1,7 @@ -package org.jlab.detector.geant4.v2.MPGD2.URWT; +package org.jlab.detector.geant4.v2.MPGD.URWT; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD2.trapezoid.MPGDTrapezoidStripFactory; +import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidStripFactory; import org.jlab.detector.volume.Geant4Basic; import java.util.HashMap; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidConstants.java similarity index 99% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidConstants.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidConstants.java index 8515c37e61..d6fbe0b0c3 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidConstants.java @@ -1,4 +1,4 @@ -package org.jlab.detector.geant4.v2.MPGD2.trapezoid; +package org.jlab.detector.geant4.v2.MPGD.trapezoid; import org.jlab.detector.calib.utils.DatabaseConstantProvider; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidGeant4Factory.java similarity index 99% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidGeant4Factory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidGeant4Factory.java index 1a80958c9a..8dc0abcf5e 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidGeant4Factory.java @@ -1,4 +1,4 @@ -package org.jlab.detector.geant4.v2.MPGD2.trapezoid; +package org.jlab.detector.geant4.v2.MPGD.trapezoid; import eu.mihosoft.vrl.v3d.Vector3d; import org.jlab.detector.geant4.v2.Geant4Factory; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidStripFactory.java similarity index 99% rename from common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidStripFactory.java rename to common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidStripFactory.java index 0eb0fab438..93616cf749 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD2/trapezoid/MPGDTrapezoidStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidStripFactory.java @@ -1,4 +1,4 @@ -package org.jlab.detector.geant4.v2.MPGD2.trapezoid; +package org.jlab.detector.geant4.v2.MPGD.trapezoid; import eu.mihosoft.vrl.v3d.Vector3d; import org.jlab.detector.volume.Geant4Basic; diff --git a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java index 4670b263dd..64f5c7c614 100644 --- a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWRStrip.java @@ -6,7 +6,7 @@ import org.jlab.detector.base.DetectorDescriptor; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; -import org.jlab.detector.geant4.v2.MPGD2.URWT.URWTStripFactory; +import org.jlab.detector.geant4.v2.MPGD.URWT.URWTStripFactory; import org.jlab.geom.prim.Line3D; import org.jlab.io.base.DataEvent; diff --git a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java index 38be025fa6..1acc2b296e 100644 --- a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java @@ -8,7 +8,7 @@ import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.detector.geant4.v2.MPGD2.URWT.URWTStripFactory; +import org.jlab.detector.geant4.v2.MPGD.URWT.URWTStripFactory; import org.jlab.geom.prim.Point3D; import org.jlab.groot.data.H1F; import org.jlab.groot.fitter.DataFitter; From e1088070cb702400184bbd58886a993deb5bb6b7 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Thu, 5 Feb 2026 17:40:49 -0500 Subject: [PATCH 6/6] code cleanup and simplification --- .../geant4/v2/MPGD/MUVT/MUVTConstants.java | 48 ++++++------------- .../v2/MPGD/MUVT/MUVTGeant4Factory.java | 17 ++----- .../geant4/v2/MPGD/MUVT/MUVTStripFactory.java | 30 ++++++------ .../geant4/v2/MPGD/URWT/URWTConstants.java | 46 ++++++------------ .../v2/MPGD/URWT/URWTGeant4Factory.java | 20 +++----- .../geant4/v2/MPGD/URWT/URWTStripFactory.java | 19 +++----- .../trapezoid/MPGDTrapezoidConstants.java | 19 +++++--- .../trapezoid/MPGDTrapezoidGeant4Factory.java | 29 +++++------ .../trapezoid/MPGDTrapezoidStripFactory.java | 9 ++-- .../org/jlab/service/urwt/URWTEngine.java | 4 +- 10 files changed, 91 insertions(+), 150 deletions(-) diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTConstants.java index 382f3b244d..17fe3eed46 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTConstants.java @@ -4,47 +4,29 @@ import org.jlab.detector.geant4.v2.MPGD.trapezoid.MPGDTrapezoidConstants; /** - * URWT-specific constants. + * MUVT-specific constants. */ public final class MUVTConstants extends MPGDTrapezoidConstants { - - private static final MUVTConstants INSTANCE = - new MUVTConstants( + private MUVTConstants() { + super( "/test/muvt/", // CCDB base path "muvt_global", // global table name - "muvt_material" // material table name + "muvt_material", // material table name + "muvt" // detector nams ); - - /** - * Private constructor: only the singleton instance is used. - */ - private MUVTConstants(String ccdbPath, - String globalTable, - String materialTable) { - super(ccdbPath, globalTable, materialTable); } - - /** - * Returns the singleton instance for URWT constants. - * @return - */ - public static MUVTConstants getInstance() { - return INSTANCE; + + public MUVTConstants(int run, String variation) { + this(); + DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); + this.load(cp); + cp.disconnect(); } - - /** - * Convenience method to load URWT constants using the given - * {@link DatabaseConstantProvider}.Usage: - DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); - URWTConstants.connect(cp); - // now MUVTConstants.getInstance() is fully initialized - * - * @param cp - * @return - */ - public static DatabaseConstantProvider connect(DatabaseConstantProvider cp) { - return INSTANCE.loadFrom(cp); + + public MUVTConstants(DatabaseConstantProvider cp) { + this(); + this.load(cp); } } diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTGeant4Factory.java index 5a65b0a820..7753288cd8 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTGeant4Factory.java @@ -18,22 +18,15 @@ public final class MUVTGeant4Factory extends MPGDTrapezoidGeant4Factory { private final String variation; + public MUVTGeant4Factory(DatabaseConstantProvider cp, String variation) { - super(MUVTConstants.getInstance(), "muvt"); + super(new MUVTConstants(cp)); this.variation = variation; - MUVTConstants.connect(cp); - init(); } - public MUVTGeant4Factory(String variation, int run) { - super(MUVTConstants.getInstance(), "muvt"); + public MUVTGeant4Factory(int run, String variation) { + super(new MUVTConstants(run, variation)); this.variation = variation; - - DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); - MUVTConstants.connect(cp); - cp.disconnect(); - - init(); } @@ -53,7 +46,7 @@ public static void main(String[] args) { variation = args[1]; } - MUVTGeant4Factory factory = new MUVTGeant4Factory(variation, run); + MUVTGeant4Factory factory = new MUVTGeant4Factory(run, variation); System.out.println("MUVT geometry for run " + run + " (variation=\"" + variation + "\")"); System.out.println("Total volumes: " + factory.getAllVolumes().size()); diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTStripFactory.java index acd9a4cac7..59bc9230eb 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/MUVT/MUVTStripFactory.java @@ -25,29 +25,27 @@ public final class MUVTStripFactory extends MPGDTrapezoidStripFactory { /** * Build using an already-configured DatabaseConstantProvider. */ -public MUVTStripFactory(DatabaseConstantProvider cp, String variation) { - super(MUVTConstants.getInstance(), new MUVTGeant4Factory(cp, variation)); + public MUVTStripFactory(DatabaseConstantProvider cp, String variation) { + super(new MUVTConstants(cp)); - MUVTConstants.connect(cp); - for (Geant4Basic v : geo.getAllVolumes()) { - if (v.getName() != null) { - volumeByName.put(v.getName(), v); + for (Geant4Basic v : geo.getAllVolumes()) { + if (v.getName() != null) { + volumeByName.put(v.getName(), v); + } } + + buildAll(); } - buildAll(); -} /** * Convenience constructor: internally creates a DatabaseConstantProvider. + * @param run + * @param variation */ - public MUVTStripFactory(String variation, int run) { - super(MUVTConstants.getInstance(), new MUVTGeant4Factory(variation, run)); - - DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); - MUVTConstants.connect(cp); - cp.disconnect(); + public MUVTStripFactory(int run, String variation) { + super(new MUVTConstants(run, variation)); for (Geant4Basic v : geo.getAllVolumes()) { if (v.getName() != null) { @@ -78,12 +76,12 @@ public static void main(String[] args) { int run = 11; String variation = "default"; - if (args.length > 0) { + if (args.length > 0) { try { run = Integer.parseInt(args[0]); } catch (Exception ignored) {} } if (args.length > 1) variation = args[1]; - MUVTStripFactory sf = new MUVTStripFactory(variation, run); + MUVTStripFactory sf = new MUVTStripFactory(run, variation); int sector = 2; int layer = 12; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTConstants.java index 03c0bede72..b8a271b257 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTConstants.java @@ -8,43 +8,25 @@ */ public final class URWTConstants extends MPGDTrapezoidConstants { - - private static final URWTConstants INSTANCE = - new URWTConstants( + private URWTConstants() { + super( "/test/urwt/", // CCDB base path "urwt_global", // global table name - "urwt_material" // material table name + "urwt_material", // material table name + "urwt" // detector nams ); - - /** - * Private constructor: only the singleton instance is used. - */ - private URWTConstants(String ccdbPath, - String globalTable, - String materialTable) { - super(ccdbPath, globalTable, materialTable); } - - /** - * Returns the singleton instance for URWT constants. - * @return - */ - public static URWTConstants getInstance() { - return INSTANCE; + + public URWTConstants(int run, String variation) { + this(); + DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); + this.load(cp); + cp.disconnect(); } - - /** - * Convenience method to load URWT constants using the given - * {@link DatabaseConstantProvider}.Usage: - DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); - URWTConstants.connect(cp); - // now URWTConstants.getInstance() is fully initialized - * - * @param cp - * @return - */ - public static DatabaseConstantProvider connect(DatabaseConstantProvider cp) { - return INSTANCE.loadFrom(cp); + + public URWTConstants(DatabaseConstantProvider cp) { + this(); + this.load(cp); } } diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTGeant4Factory.java index b68a2cfa0f..31a0a13d32 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTGeant4Factory.java @@ -18,21 +18,13 @@ public final class URWTGeant4Factory extends MPGDTrapezoidGeant4Factory { private final String variation; public URWTGeant4Factory(DatabaseConstantProvider cp, String variation) { - super(URWTConstants.getInstance(), "urwt"); + super(new URWTConstants(cp)); this.variation = variation; - URWTConstants.connect(cp); - init(); } - public URWTGeant4Factory(String variation, int run) { - super(URWTConstants.getInstance(), "urwt"); + public URWTGeant4Factory(int run, String variation) { + super(new URWTConstants(run, variation)); this.variation = variation; - - DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); - URWTConstants.connect(cp); - cp.disconnect(); - - init(); } /** @@ -41,7 +33,7 @@ public URWTGeant4Factory(String variation, int run) { * @return */ @Override - public SectorDimensions getSectorDimensionsPhysical(int region) { + public SectorDimensions getSectorActiveVolumeDimensions(int region) { if (variation != null && variation.toLowerCase().contains("proto")) { @@ -56,7 +48,7 @@ public SectorDimensions getSectorDimensionsPhysical(int region) { return new SectorDimensions(halfThickness, halfHeight, halfLargeBase, halfSmallBase, tiltRad); } - return super.getSectorDimensionsPhysical(region); + return super.getSectorActiveVolumeDimensions(region); } /** @@ -84,7 +76,7 @@ public static void main(String[] args) { variation = args[1]; } - URWTGeant4Factory factory = new URWTGeant4Factory(variation, run); + URWTGeant4Factory factory = new URWTGeant4Factory(run, variation); System.out.println("uRWT geometry for run " + run + " (variation=\"" + variation + "\")"); System.out.println("Total volumes: " + factory.getAllVolumes().size()); diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTStripFactory.java index 0494f3a823..2c2a735388 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/URWT/URWTStripFactory.java @@ -25,12 +25,9 @@ public final class URWTStripFactory extends MPGDTrapezoidStripFactory { /** * Build using an already-configured DatabaseConstantProvider. * @param cp - * @param variation */ - public URWTStripFactory(DatabaseConstantProvider cp, String variation) { - super(URWTConstants.getInstance(), new URWTGeant4Factory(cp, variation)); - - URWTConstants.connect(cp); + public URWTStripFactory(DatabaseConstantProvider cp) { + super(new URWTConstants(cp)); for (Geant4Basic v : geo.getAllVolumes()) { if (v.getName() != null) { @@ -43,13 +40,11 @@ public URWTStripFactory(DatabaseConstantProvider cp, String variation) { /** * Convenience constructor: internally creates a DatabaseConstantProvider. + * @param run + * @param variation */ - public URWTStripFactory(String variation, int run) { - super(URWTConstants.getInstance(), new URWTGeant4Factory(variation, run)); - - DatabaseConstantProvider cp = new DatabaseConstantProvider(run, variation); - URWTConstants.connect(cp); - cp.disconnect(); + public URWTStripFactory(int run, String variation) { + super(new URWTConstants(run, variation)); for (Geant4Basic v : geo.getAllVolumes()) { if (v.getName() != null) { @@ -88,7 +83,7 @@ public static void main(String[] args) { } if (args.length > 1) variation = args[1]; - URWTStripFactory sf = new URWTStripFactory(variation, run); + URWTStripFactory sf = new URWTStripFactory(run, variation); int sector = 1; int layer = 4; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidConstants.java index d6fbe0b0c3..2857345d8a 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidConstants.java @@ -11,7 +11,7 @@ * Concrete detectors (e.g. URWT) should extend this class and provide: - CCDB * base path - global table name - material table name */ -public abstract class MPGDTrapezoidConstants { +public class MPGDTrapezoidConstants { // ------------------------------------------------------------------------ // Logging / verbosity @@ -39,6 +39,11 @@ public abstract class MPGDTrapezoidConstants { */ protected final String materialTableName; + /** + * Short detector name used in volume names (e.g. "uRWT"). + */ + public final String detectorName; + // ------------------------------------------------------------------------ // Geometry parameters (from global table) // ------------------------------------------------------------------------ @@ -99,11 +104,13 @@ public LayerComponentInfo(double thickness, int sensitivity) { * "urwt_material_geo") */ protected MPGDTrapezoidConstants(String ccdbPath, - String globalTableName, - String materialTableName) { + String globalTableName, + String materialTableName, + String detectorName) { this.ccdbPath = ccdbPath.endsWith("/") ? ccdbPath : ccdbPath + "/"; this.globalTableName = globalTableName; this.materialTableName = materialTableName; + this.detectorName = detectorName; } /** @@ -125,10 +132,10 @@ public Map> getDetectorStructure() { * @param cp * @return */ - public DatabaseConstantProvider loadFrom(DatabaseConstantProvider cp) { + public DatabaseConstantProvider load(DatabaseConstantProvider cp) { cp.loadTable(ccdbPath + globalTableName); cp.loadTable(ccdbPath + materialTableName); - load(cp); + getConstants(cp); return cp; } @@ -139,7 +146,7 @@ public DatabaseConstantProvider loadFrom(DatabaseConstantProvider cp) { * * @param cp */ - public synchronized void load(DatabaseConstantProvider cp) { + public synchronized void getConstants(DatabaseConstantProvider cp) { // --------------------------- Global table --------------------------- String globalBase = ccdbPath + globalTableName; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidGeant4Factory.java index 8dc0abcf5e..82904ccb61 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidGeant4Factory.java @@ -20,18 +20,13 @@ * Concrete detectors should: - extend this class - pass the appropriate * constants + detector name in the constructor */ -public abstract class MPGDTrapezoidGeant4Factory extends Geant4Factory { +public class MPGDTrapezoidGeant4Factory extends Geant4Factory { /** * Detector constants (geometry + materials from CCDB). */ protected final MPGDTrapezoidConstants C; - /** - * Short detector name used in volume names (e.g. "uRWT"). - */ - protected final String detectorName; - public static record SectorDimensions( double halfThickness, double halfHeight, @@ -45,12 +40,10 @@ public static record SectorDimensions( /** * @param constants detector constants (already configured with CCDB * paths/table names) - * @param detectorName short detector name used in volume names */ - protected MPGDTrapezoidGeant4Factory(MPGDTrapezoidConstants constants, - String detectorName) { + protected MPGDTrapezoidGeant4Factory(MPGDTrapezoidConstants constants) { this.C = constants; - this.detectorName = detectorName; + this.init(); } // ------------------------------------------------------------------------ @@ -61,7 +54,7 @@ protected MPGDTrapezoidGeant4Factory(MPGDTrapezoidConstants constants, * * This must be called after the constants have been loaded from CCDB. */ - protected void init() { + protected final void init() { // World volume for this detector motherVolume = new G4World("root"); @@ -97,7 +90,7 @@ public double getSectorThickness() { * @param region * @return */ - public SectorDimensions getSectorDimensionsPhysical(int region) { + public SectorDimensions getSectorActiveVolumeDimensions(int region) { double baseDistance = C.TGTDET + region * C.DZ; @@ -130,7 +123,7 @@ public SectorDimensions getSectorDimensionsPhysical(int region) { System.out.printf( "SectorDimensionsPhysical [%s] region=%d : height=%.3f | halfT=%.3f halfH=%.3f " + "halfLarge=%.3f halfSmall=%.3f tilt(deg)=%.3f%n", - detectorName, region, sectorHeight, + C.detectorName, region, sectorHeight, halfThickness, halfHeight, halfLargeBase, halfSmallBase, C.THTILT @@ -147,7 +140,7 @@ public SectorDimensions getSectorDimensionsPhysical(int region) { */ public SectorDimensions getSectorContainerDimensions(int region) { - SectorDimensions phys = getSectorDimensionsPhysical(region); + SectorDimensions phys = getSectorActiveVolumeDimensions(region); double halfThickness = phys.halfThickness() + MPGDTrapezoidConstants.ZENLARGEMENT; double halfHeight = phys.halfHeight() + MPGDTrapezoidConstants.YENLARGEMENT; @@ -175,7 +168,7 @@ public double getSectorHeight(int region) { if (MPGDTrapezoidConstants.VERBOSE) { System.out.printf( "SectorHeight [%s] region=%d : baseDistance=%.3f THMIN=%.3f THMAX=%.3f THTILT=%.3f -> height=%.3f%n", - detectorName, + C.detectorName, region, baseDistance, C.THMIN, C.THMAX, C.THTILT, @@ -230,7 +223,7 @@ public Vector3d getCenterCoordinate(int isector, int iregion) { */ public Geant4Basic createSector(int isector, int iregion) { - SectorDimensions dimPhys = this.getSectorDimensionsPhysical(iregion); + SectorDimensions dimPhys = this.getSectorActiveVolumeDimensions(iregion); SectorDimensions dimCont = this.getSectorContainerDimensions(iregion); Geant4Basic sectorVolume = createSectorVolume(isector, iregion, dimCont); @@ -260,7 +253,7 @@ protected Geant4Basic createSectorVolume(int isector, Vector3d vCenter = this.getCenterCoordinate(isector, iregion); Geant4Basic sectorVolume = new G4Trap( - "region_" + detectorName + "_" + (iregion + 1) + "_s" + (isector + 1), + "region_" + C.detectorName + "_" + (iregion + 1) + "_s" + (isector + 1), sectorDZ, -sectorTtilt, Math.toRadians(90.0), sectorDY, sectorDX0, sectorDX1, 0.0, sectorDY, sectorDX0, sectorDX1, 0.0 @@ -334,7 +327,7 @@ protected void populateSectorWithDetectorStructure(Geant4Basic sectorVolume, ); matVolume.setName( - "rg_" + detectorName + "_" + (iregion + 1) + "rg_" + C.detectorName + "_" + (iregion + 1) + "_s" + (isector + 1) + "_l" + (LayerId + iregion * 2) + "_matC" + materialComponentId diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidStripFactory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidStripFactory.java index 93616cf749..283adf2b21 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidStripFactory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/MPGD/trapezoid/MPGDTrapezoidStripFactory.java @@ -25,10 +25,9 @@ public abstract class MPGDTrapezoidStripFactory { protected final MPGDTrapezoidConstants C; protected final MPGDTrapezoidGeant4Factory geo; - protected MPGDTrapezoidStripFactory(MPGDTrapezoidConstants constants, - MPGDTrapezoidGeant4Factory geantFactory) { + protected MPGDTrapezoidStripFactory(MPGDTrapezoidConstants constants) { this.C = constants; - this.geo = geantFactory; + this.geo = new MPGDTrapezoidGeant4Factory(constants); } /** @@ -223,7 +222,7 @@ protected String getSensitiveVolumeName(int region, int sector, int layer) { } } - return "rg_" + geo.detectorName + "_" + region + return "rg_" + C.detectorName + "_" + region + "_s" + sector + "_l" + layer + "_matC" + matC; @@ -265,7 +264,7 @@ protected Vector3d toGlobalSensitive(int region, int sector, int layer, Vector3d protected StripConstants buildStripConstants(int region, int layer) { MPGDTrapezoidGeant4Factory.SectorDimensions phys - = geo.getSectorDimensionsPhysical(region - 1); + = geo.getSectorActiveVolumeDimensions(region - 1); StripConstants sc = new StripConstants(); sc.yHalf = phys.halfHeight(); diff --git a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java index 1acc2b296e..de555dbf26 100644 --- a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java @@ -40,8 +40,8 @@ public boolean init() { // init ConstantsManager to read constants from CCDB String variationName = Optional.ofNullable(this.getEngineConfigString("variation")).orElse("default"); - DatabaseConstantProvider cp = new DatabaseConstantProvider(11, variationName); - factory = new URWTStripFactory(cp, variationName); + + factory = new URWTStripFactory(11, variationName); // register output banks for drop option this.registerOutputBank("URWT::hits"); this.registerOutputBank("URWT::clusters");