From d6dee065afc549be2fe999c74402787291b36f84 Mon Sep 17 00:00:00 2001 From: niwgit Date: Wed, 19 Mar 2025 11:03:00 -0400 Subject: [PATCH 01/11] Implementation of recoil TOF geometry for RGH --- .../v2/recoil_tof/RecoilTOFConstants.java | 50 ++++++ .../v2/recoil_tof/RecoilTOFGeant4Factory.java | 143 ++++++++++++++++++ 2 files changed, 193 insertions(+) create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java create mode 100644 common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFGeant4Factory.java diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java new file mode 100644 index 0000000000..4cb69eb899 --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java @@ -0,0 +1,50 @@ +package org.jlab.detector.geant4.v2.recoil_tof; + + +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.geom.prim.Point3D; + + +public class RecoilTOFConstants { + + public final static int NSECTORS = 2; //number of sectors + public final static int NROWS = 5; //number of rows of bars in a sector + public final static int NCOLUMNS = 63; //number of columns of bars in a sector + + public final static double LONG_BAR_LENGTH = 20; // cm + public final static double SHORT_BAR_LENGTH = 4; // cm + + public final static double BAR_WIDTH = 1; // cm + public final static double BAR_THICKNESS = 0.5; // cm + + public final static double HORIZONTAL_OPENING_ANGLE = 34.; + public final static double RADIUS = 111.5; // cm + + public final static double WIDTH = NCOLUMNS * BAR_WIDTH; + public final static double LENGTH = (NROWS-1) * LONG_BAR_LENGTH + SHORT_BAR_LENGTH; + public final static double THICKNESS = 0.5; // cm + + + public static DatabaseConstantProvider connect( DatabaseConstantProvider cp ) + { + + 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 ) + { + //WIDTH = NCOLUMNS * BAR_WIDTH; + //LENGTH = (NROWS-1) * LONG_BAR_LENGTH + SHORT_BAR_LENGTH; + //THICKNESS = 0.5; // cm + } + +} + + diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFGeant4Factory.java new file mode 100644 index 0000000000..ff42ba3d2e --- /dev/null +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFGeant4Factory.java @@ -0,0 +1,143 @@ +package org.jlab.detector.geant4.v2.recoil_tof; + +import eu.mihosoft.vrl.v3d.Vector3d; +import org.jlab.detector.geant4.v2.Geant4Factory; +import org.jlab.detector.volume.G4World; +import org.jlab.detector.volume.G4Box; +import org.jlab.detector.volume.Geant4Basic; +import org.jlab.detector.calib.utils.DatabaseConstantProvider; + +/** + * Generate GEANT4 volume for the RECOIL TOF detector + * + * @author Nilanga Wickramaarachchi + */ +public final class RecoilTOFGeant4Factory extends Geant4Factory { + + private int nSectors = RecoilTOFConstants.NSECTORS; + private int nRows = RecoilTOFConstants.NROWS; + private int nCols = RecoilTOFConstants.NCOLUMNS; + + public RecoilTOFGeant4Factory( DatabaseConstantProvider cp) { + RecoilTOFConstants.connect(cp ); + this.init(cp); + } + + public void init(DatabaseConstantProvider cp) { + + motherVolume = new G4World("root"); + + for (int isector = 0; isector < nSectors; isector++) { + Geant4Basic sectorVolume = createSector(isector, nRows, nCols); + + sectorVolume.setName("recoil_tof_sector" + (isector + 1)); + sectorVolume.setMother(motherVolume); + } + } + + + public Vector3d getCenterCoordinate(int isector) + { + int is=isector; + Vector3d vCenter = new Vector3d(0, 0, 0); + + vCenter.x = (-1+is*2)*(RecoilTOFConstants.RADIUS)*Math.sin(Math.toRadians(1.5*RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE)); + vCenter.y = 0; + vCenter.z =RecoilTOFConstants.RADIUS*Math.cos(Math.toRadians(1.5*RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE)); + return vCenter; + } + + + + public Geant4Basic createSector(int isector, int nRows, int nCols ) { + + double hlx = RecoilTOFConstants.WIDTH/2+1; + double hly = RecoilTOFConstants.LENGTH/2+1; + double hlz = RecoilTOFConstants.THICKNESS/2+1; + + Vector3d vCenter = this.getCenterCoordinate(isector); + + Geant4Basic sectorVolume = new G4Box("recoil_tof_sector" + (isector + 1), hlx, hly, hlz); + + sectorVolume.rotate("yxz",(-1+isector*2)*Math.toRadians(1.5*RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE+270),0,0); + sectorVolume.translate(vCenter.x, vCenter.y, vCenter.z); + sectorVolume.setId(isector + 1, 0, 0); + + // Bars construction + for (int row = 0; row < nRows; row++) { + for (int col = 0; col < nCols; col++) { + + Geant4Basic barVolume = this.createBar(isector, row, col); + + barVolume.setName("bar_sector" + (isector + 1) + "_row" + (row + 1) + "_column" + (col + 1)); + + barVolume.setMother(sectorVolume); + + barVolume.setId(isector + 1, row +1, col+1, 0); + } + } + + return sectorVolume; + } + + + public Geant4Basic createBar(int iSector, int iRow, int iCol) { + + int nCols = RecoilTOFConstants.NCOLUMNS; + + double barDX = RecoilTOFConstants.BAR_WIDTH/2; + double barDY; + + if (iRow == (nRows - 1) / 2) barDY = RecoilTOFConstants.SHORT_BAR_LENGTH/2; + else barDY = RecoilTOFConstants.LONG_BAR_LENGTH/2; + + double barDZ = RecoilTOFConstants.BAR_THICKNESS/2; + + Geant4Basic barVolume = new G4Box("bar_sector" + (iSector + 1) + "_row" + (iRow + 1) + "_column" + (iCol + 1), barDX, barDY, barDZ); + + // Constants for positioning + double y_start = -(RecoilTOFConstants.LENGTH - RecoilTOFConstants.LONG_BAR_LENGTH)/2; // Starting Y position + double x_spacing = RecoilTOFConstants.BAR_WIDTH; + double x_start = -(RecoilTOFConstants.WIDTH - x_spacing)/2; // starting X position + double dy_long = RecoilTOFConstants.LONG_BAR_LENGTH; + double dy_short = RecoilTOFConstants.SHORT_BAR_LENGTH; + + //Position calculation + double z_pos = 0; + double x_pos = x_start + (iCol * x_spacing); + + double y_pos; + if(iRow < (nRows - 1) / 2) + { + y_pos = y_start + (iRow * dy_long); + } + else if (iRow == (nRows - 1) / 2) // middle row + { + y_pos = 0; + } + else + { + y_pos = y_start + (iRow -1) * dy_long + dy_short; + } + + barVolume.setPosition(x_pos, y_pos, z_pos); + + return barVolume; + } + + + + + public static void main(String[] args) { + DatabaseConstantProvider cp = new DatabaseConstantProvider(11, "default"); + + RecoilTOFConstants.connect(cp); + + RecoilTOFGeant4Factory factory = new RecoilTOFGeant4Factory(cp); + + factory.getAllVolumes().forEach(volume -> { + System.out.println(volume.gemcString()); + }); + + } +} From 4ae199cd1603c3f66499ec1d8e5c84d1dab45cb1 Mon Sep 17 00:00:00 2001 From: niwgit Date: Wed, 2 Apr 2025 10:18:30 -0400 Subject: [PATCH 02/11] Added TDC bank for recoil TOF, change horizontal opening angle and radius --- .../v2/recoil_tof/RecoilTOFConstants.java | 4 ++-- etc/bankdefs/hipo4/data.json | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java index 4cb69eb899..447dd85324 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java @@ -17,8 +17,8 @@ public class RecoilTOFConstants { public final static double BAR_WIDTH = 1; // cm public final static double BAR_THICKNESS = 0.5; // cm - public final static double HORIZONTAL_OPENING_ANGLE = 34.; - public final static double RADIUS = 111.5; // cm + public final static double HORIZONTAL_OPENING_ANGLE = 40.; + public final static double RADIUS = 122.; // cm public final static double WIDTH = NCOLUMNS * BAR_WIDTH; public final static double LENGTH = (NROWS-1) * LONG_BAR_LENGTH + SHORT_BAR_LENGTH; diff --git a/etc/bankdefs/hipo4/data.json b/etc/bankdefs/hipo4/data.json index 5ccc2696e4..0ed99efa3e 100644 --- a/etc/bankdefs/hipo4/data.json +++ b/etc/bankdefs/hipo4/data.json @@ -598,7 +598,7 @@ { "name":"ped" , "type":"S", "info":"pedestal from pulse analysis"} ] }, -{ + { "name" : "URWELL::adc", "group": 22300, "item" : 11, @@ -612,7 +612,21 @@ { "name":"time" , "type":"F", "info":"time"}, { "name":"ped" , "type":"S", "info":"pedestal from pulse analysis"} ] - }, + }, + { + "name" : "RECOILTOF::tdc", + "group": 22700, + "item" : 12, + "info": "TDC bank for the RECOIL TOF", + "entries":[ + { "name":"sector" , "type":"B", "info":"sector"}, + { "name":"row" , "type":"B", "info":"row"}, + { "name":"column" , "type":"B", "info":"column"}, + { "name":"order" , "type":"B", "info":"order: 2 - TDCL , 3 - TDCR"}, + { "name":"TDC" , "type":"I", "info":"TDC value"}, + { "name":"ToT" , "type":"I", "info":"Time Over Threshold"} + ] + }, { "name" : "RAW::adc", "group": 20000, From fb3828a5d69a2587b3598ceaf0a81ecbb552d28a Mon Sep 17 00:00:00 2001 From: niwgit Date: Thu, 3 Apr 2025 16:51:03 -0400 Subject: [PATCH 03/11] Initial implementation of reconstruction for RGH recoil TOF --- .../org/jlab/detector/base/DetectorType.java | 1 + etc/bankdefs/hipo4/recoiltof.json | 87 +++++ reconstruction/pom.xml | 1 + reconstruction/recoiltof/pom.xml | 35 ++ .../rec/recoiltof/banks/RecoBankWriter.java | 127 ++++++ .../rec/recoiltof/cluster/ClusterFinder.java | 173 +++++++++ .../recoiltof/cluster/RECOILTOFCluster.java | 244 ++++++++++++ .../rec/recoiltof/constants/Parameters.java | 36 ++ .../org/jlab/rec/recoiltof/hit/BarHit.java | 117 ++++++ .../org/jlab/rec/recoiltof/hit/HitFinder.java | 119 ++++++ .../jlab/rec/recoiltof/hit/RECOILTOFHit.java | 362 ++++++++++++++++++ .../service/recoiltof/RECOILTOFEngine.java | 92 +++++ 12 files changed, 1394 insertions(+) create mode 100644 etc/bankdefs/hipo4/recoiltof.json create mode 100644 reconstruction/recoiltof/pom.xml create mode 100644 reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/banks/RecoBankWriter.java create mode 100644 reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/cluster/ClusterFinder.java create mode 100644 reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/cluster/RECOILTOFCluster.java create mode 100644 reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java create mode 100644 reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/BarHit.java create mode 100644 reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/HitFinder.java create mode 100644 reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java create mode 100644 reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java 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 a19b4d2933..89ac5018ef 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 @@ -32,6 +32,7 @@ public enum DetectorType { AHDC (24, "AHDC"), ATOF (25, "ATOF"), RECOIL (26, "RECOIL"), + RECOILTOF (27, "RECOILTOF"), TARGET (100, "TARGET"), MAGNETS (101, "MAGNETS"), ECIN (110, "ECIN"), diff --git a/etc/bankdefs/hipo4/recoiltof.json b/etc/bankdefs/hipo4/recoiltof.json new file mode 100644 index 0000000000..03b45fd6d1 --- /dev/null +++ b/etc/bankdefs/hipo4/recoiltof.json @@ -0,0 +1,87 @@ +[ + { + "name": "RECOILTOF::hits", + "group": 22700, + "item": 21, + "info": "Reconstructed RECOILTOF hits", + "entries": [ + { + "name": "id", + "type": "S", + "info": "hit id" + }, { + "name": "sector", + "type": "I", + "info": "recoil tof sector" + }, { + "name": "row", + "type": "I", + "info": "recoil tof row" + },{ + "name": "column", + "type": "I", + "info": "recoil tof column" + },{ + "name": "time", + "type": "F", + "info": "time in ns" + },{ + "name": "x", + "type": "F", + "info": "x position in mm" + }, { + "name": "y", + "type": "F", + "info": "y position in mm" + }, { + "name": "z", + "type": "F", + "info": "z position in mm" + },{ + "name": "energy", + "type": "F", + "info": "deposited energy in MeV" + },{ + "name": "clusterid", + "type": "S", + "info": "id of cluster to which the hit was associated" + } + ] + },{ + "name": "RECOILTOF::clusters", + "group": 22700, + "item": 22, + "info": "Clusters in RECOILTOF", + "entries": [ + { + "name": "id", + "type": "S", + "info": "hit id" + }, { + "name": "N_bar", + "type": "I", + "info": "number of hits from the bars" + },{ + "name": "time", + "type": "F", + "info": "time in ns" + },{ + "name": "x", + "type": "F", + "info": "x position in mm" + }, { + "name": "y", + "type": "F", + "info": "y position in mm" + }, { + "name": "z", + "type": "F", + "info": "z position in mm" + },{ + "name": "energy", + "type": "F", + "info": "energy in MeV" + } + ] + } +] diff --git a/reconstruction/pom.xml b/reconstruction/pom.xml index 76ed7aa839..5cf6c592e4 100644 --- a/reconstruction/pom.xml +++ b/reconstruction/pom.xml @@ -34,6 +34,7 @@ vtx urwell alert + recoiltof bg postproc diff --git a/reconstruction/recoiltof/pom.xml b/reconstruction/recoiltof/pom.xml new file mode 100644 index 0000000000..189b1d70a3 --- /dev/null +++ b/reconstruction/recoiltof/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + org.jlab.clas12.detector + clas12detector-recoiltof + 1.0-SNAPSHOT + jar + + + org.jlab.clas + clas12rec + ../../parent/pom.xml + 11.1.2-SNAPSHOT + + + + + + org.jlab.clas + clas-detector + 11.1.2-SNAPSHOT + + + + org.jlab.clas + clas-analysis + 11.1.2-SNAPSHOT + + + + + diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/banks/RecoBankWriter.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/banks/RecoBankWriter.java new file mode 100644 index 0000000000..f0d4c2a2ea --- /dev/null +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/banks/RecoBankWriter.java @@ -0,0 +1,127 @@ +package org.jlab.rec.recoiltof.banks; + +import java.util.ArrayList; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.rec.recoiltof.cluster.RECOILTOFCluster; +import org.jlab.rec.recoiltof.hit.RECOILTOFHit; +import org.jlab.rec.recoiltof.hit.BarHit; + + +/** + * The {@code RecoBankWriter} writes the banks needed for the recoil tof + * reconstruction: hits and clusters info. + * + * @author pilleux, Nilanga Wickramaarachchi + */ +public class RecoBankWriter { + + /** + * Writes the bank of recoil tof hits. + * + * @param event the {@link DataEvent} in which to add the bank + * @param barHits the {@link ArrayList} of {@link BarHit} containing the bar + * hits to be added to the bank + * + * @return {@link DataBank} the bank with all the hits read in the event. + * + */ + public static DataBank fillRECOILTOFHitBank(DataEvent event, ArrayList barHits) { + + ArrayList hitList = new ArrayList<>(); + hitList.addAll(barHits); + + DataBank bank = event.createBank("RECOILTOF::hits", hitList.size()); + + if (bank == null) { + System.err.println("COULD NOT CREATE A RECOILTOF::hits BANK!!!!!!"); + return null; + } + + for (int i = 0; i < hitList.size(); i++) { + bank.setShort("id", i, (short) (i + 1)); + bank.setShort("clusterid", i, (short) hitList.get(i).getAssociatedClusterIndex()); + bank.setInt("sector", i, (int) hitList.get(i).getSector()); + bank.setInt("row", i, (int) hitList.get(i).getRow()); + bank.setInt("column", i, (int) hitList.get(i).getColumn()); + bank.setFloat("time", i, (float) hitList.get(i).getTime()); + bank.setFloat("x", i, (float) (hitList.get(i).getX())); + bank.setFloat("y", i, (float) (hitList.get(i).getY())); + bank.setFloat("z", i, (float) (hitList.get(i).getZ())); + bank.setFloat("energy", i, (float) hitList.get(i).getEnergy()); + } + return bank; + } + + /** + * Writes the bank of recoiltof clusters. + * + * @param event the {@link DataEvent} in which to add the bank + * @param clusterList the {@link ArrayList} of {@link RECOILTOFCluster} + * containing the clusters info to be added to the bank + * + * @return {@link DataBank} the bank with all the clusters built in the + * event. + * + */ + public static DataBank fillRECOILTOFClusterBank(DataEvent event, ArrayList clusterList) { + + DataBank bank = event.createBank("RECOILTOF::clusters", clusterList.size()); + + if (bank == null) { + System.err.println("COULD NOT CREATE A RECOILTOF::clusters BANK!!!!!!"); + return null; + } + + for (int i = 0; i < clusterList.size(); i++) { + bank.setShort("id", i, (short) (i + 1)); + bank.setInt("N_bar", i, (int) clusterList.get(i).getBarHits().size()); + bank.setFloat("time", i, (float) clusterList.get(i).getTime()); + bank.setFloat("x", i, (float) (clusterList.get(i).getX())); + bank.setFloat("y", i, (float) (clusterList.get(i).getY())); + bank.setFloat("z", i, (float) (clusterList.get(i).getZ())); + bank.setFloat("energy", i, (float) clusterList.get(i).getEnergy()); + } + return bank; + } + + + /** + * Appends the recoil tof banks to an event. + * + * @param event the {@link DataEvent} in which to append the banks + * @param clusterList the {@link ArrayList} of {@link RECOILTOFCluster} + * containing the clusters info to be added to the bank + * @param barHits the {@link ArrayList} of {@link BarHit} containing the bar + * hits info to be added + * + * @return 0 if it worked, 1 if it failed + * + */ + public int appendRECOILTOFBanks(DataEvent event, ArrayList barHits, ArrayList clusterList) { + + DataBank hitbank = this.fillRECOILTOFHitBank(event, barHits); + if (hitbank != null) { + event.appendBank(hitbank); + } else { + return 1; + } + + DataBank clusterbank = fillRECOILTOFClusterBank(event, clusterList); + if (clusterbank != null) { + event.appendBank(clusterbank); + } else { + return 1; + } + + return 0; + } + + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + } + +} diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/cluster/ClusterFinder.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/cluster/ClusterFinder.java new file mode 100644 index 0000000000..f37359147e --- /dev/null +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/cluster/ClusterFinder.java @@ -0,0 +1,173 @@ +package org.jlab.rec.recoiltof.cluster; + +import java.util.ArrayList; +import org.jlab.io.base.DataEvent; +import org.jlab.rec.recoiltof.constants.Parameters; +import org.jlab.rec.recoiltof.hit.RECOILTOFHit; +import org.jlab.rec.recoiltof.hit.BarHit; +import org.jlab.rec.recoiltof.hit.HitFinder; + +/** + * The {@code ClusterFinder} class builds clusters in the recoil tof + * + *

+ * Uses found hits information. Creates a {@link RECOILTOFCluster} matching them. + *

+ * + * @author pilleux, Nilanga Wickramaarachchi + */ +public class ClusterFinder { + + /** + * list of clusters. + */ + private ArrayList clusters; + + /** + * Sets the list of clusters. + * + * @param clusters a {@link ArrayList} of {@link RECOILTOFCluster}. + * + */ + public void setClusters(ArrayList clusters) { + this.clusters = clusters; + } + + /** + * Gets the list of clusters. + * + * @return a {@link ArrayList} of {@link RECOILTOFCluster}. + * + */ + public ArrayList getClusters() { + return clusters; + } + + + /** + * Cluster hits around a given hit, based on the time and geometric + * proximity. + * + * Hits are compared based on their y difference, which + * is distance in mm and time difference. + * + * If the hit satisfies all conditions, it is marked as clustered and added + * to the cluster hit list. + * + * + * @param The type of the hit objects, which must extend + * {@link RECOILTOFHit}. This allows the method to work with different types of + * hits that are subclasses of {@link RECOILTOFHit} (e.g., {@link BarHit}). + * @param i The index from which hits are read in the list to compare + * against the current hit. + * @param hits The list of hits to be clustered, can be any subclass of + * {@link RECOILTOFHit}. + * @param this_hit The hit currently being considered for clustering. + * @param sigma_y The threshold for the y-distance [mm] between the hits. + * @param sigma_t The threshold for the time difference [ns] between the + * hits. + * @param cluster_id The ID of the cluster being formed. + * @param this_cluster_hits The list that will store the clustered hits. + * This list can accept hits of type RECOILTOFHit or BarHit. Clustered hits are + * added to this list. + * + */ + public void clusterHits(int i, ArrayList hits, RECOILTOFHit this_hit, Number sigma_y, double sigma_t, int cluster_id, ArrayList this_cluster_hits) { + // Loop through less energetic clusters + for (int j = i + 1; j < hits.size(); j++) { + T other_hit = hits.get(j); + // Skip already clustered hits + if (other_hit.getIsInACluster()) { + continue; + } + // Check the distance between the hits + double delta_T = Math.abs(this_hit.getTime() - other_hit.getTime()); + //The y distance is a distance in mm + Boolean condition_y; + double delta_Y = Math.abs(this_hit.getY() - other_hit.getY()); + condition_y = (delta_Y <= sigma_y.doubleValue()); + + //If hit is within limits, it is clustered + if (condition_y) { + if (delta_T < sigma_t) { + other_hit.setIsInACluster(true); + other_hit.setAssociatedClusterIndex(cluster_id); + this_cluster_hits.add(other_hit); + } + } + } + } + + + /** + * Builds clusters in the {@link DateEvent} using hits found and stored in a + * {@link HitFinder}. + * + * @param hitfinder the {@link HitFinder} containing the hits that were + * found + * + * @param sigma_y the tolerance for clustering in y [mm] + * + * @param sigma_t the tolerance for clustering in time [ns] + * + */ + public void makeClusters(HitFinder hitfinder, double sigma_y, double sigma_t, DataEvent event) { + + //A list of clusters is built for each event + clusters.clear(); + int cluster_id = 1; + + //Getting the list of hits, they must have been ordered by energy already + ArrayList bar_hits = hitfinder.getBarHits(); + + //Loop through all bar hits + for (int i_bar = 0; i_bar < bar_hits.size(); i_bar++) { + BarHit this_bar_hit = bar_hits.get(i_bar); + //Skip hits that have already been clustered + if (this_bar_hit.getIsInACluster()) { + continue; + } + + ArrayList this_cluster_bar_hits = new ArrayList<>(); + this_bar_hit.setIsInACluster(true); + this_bar_hit.setAssociatedClusterIndex(cluster_id); + this_cluster_bar_hits.add(this_bar_hit); + + //Matching bar hits in clusters + clusterHits(i_bar, bar_hits, this_bar_hit, sigma_y, sigma_t, cluster_id, this_cluster_bar_hits); + + RECOILTOFCluster cluster = new RECOILTOFCluster(this_cluster_bar_hits, event); + clusters.add(cluster); + cluster_id++; + } + } + + /** + * Builds clusters in the {@link DataEvent} using hits found and stored in a + * {@link HitFinder}. + * + * @param event the {@link DataEvent} containing the clusters to be built + * + * @param hitfinder the {@link HitFinder} containing the hits that were + * found + * + */ + public void makeClusters(DataEvent event, HitFinder hitfinder) { + makeClusters(hitfinder, + Parameters.SIGMA_Y_CLUSTERING, + Parameters.SIGMA_T_CLUSTERING, event); + } + + /** + * Default constructor that initializes the list clusters as new empty list. + */ + public ClusterFinder() { + clusters = new ArrayList<>(); + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + } +} diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/cluster/RECOILTOFCluster.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/cluster/RECOILTOFCluster.java new file mode 100644 index 0000000000..84deefd0cc --- /dev/null +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/cluster/RECOILTOFCluster.java @@ -0,0 +1,244 @@ +package org.jlab.rec.recoiltof.cluster; + +import java.util.ArrayList; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Point3D; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.rec.recoiltof.constants.Parameters; +import org.jlab.rec.recoiltof.hit.RECOILTOFHit; +import org.jlab.rec.recoiltof.hit.BarHit; + +/** + * The {@code RECOILTOFCluster} represents clusters in the recoil tof + * + *

+ * Create clusters and compute their basic properties from the hits composing + * them. + *

+ * + * @author pilleux, Nilanga Wickramaarachchi + */ +public class RECOILTOFCluster { + + /** + * list of hits in the bars. + */ + ArrayList barHits; + /** + * cluster properties:position [cm], time [ns], energy[MeV], + * type of the maximum hit (to set resolutions) and index of the maximum hit. + */ + double x, y, z, time, energy; + String typeMaxHit; + int indexMaxHit; + + public ArrayList getBarHits() { + return barHits; + } + + public void setBarHits(ArrayList bar_hits) { + this.barHits = bar_hits; + } + + public double getX() { + return x; + } + + public void setX(double x) { + this.x = x; + } + + public double getY() { + return y; + } + + public void setY(double y) { + this.y = y; + } + + public double getZ() { + return z; + } + + public void setZ(double z) { + this.z = z; + } + + public double getTime() { + return time; + } + + public void setTime(double time) { + this.time = time; + } + + public double getEnergy() { + return energy; + } + + public void setEnergy(double energy) { + this.energy = energy; + } + + + public String getTypeMaxHit() { + return typeMaxHit; + } + + public void setTypeMaxHit(String typeMaxHit) { + this.typeMaxHit = typeMaxHit; + } + + public int getIndexMaxHit() { + return indexMaxHit; + } + + public void setIndexMaxHit(int indexMaxHit) { + this.indexMaxHit = indexMaxHit; + } + + /** + * Compute the cluster properties. + * + * Cluster coordinates and time are defined as the coordinates and time of + * the max energy hit. + * + * TO DO: Test other choices for the definitions. + * + */ + public final void computeClusterProperties() { + this.energy = 0; + double max_energy = -1; + RECOILTOFHit max_energy_hit = new RECOILTOFHit(); + + for (int i_bar = 0; i_bar < this.barHits.size(); i_bar++) { + BarHit this_bar_hit = this.barHits.get(i_bar); + double this_energy = this_bar_hit.getEnergy(); + this.energy += this_energy; + if (this_energy > max_energy) { + max_energy_hit = this_bar_hit; + max_energy = this_energy; + } + } + + this.time = max_energy_hit.getTime(); + this.x = max_energy_hit.getX(); + this.y = max_energy_hit.getY(); + this.z = max_energy_hit.getZ(); + this.typeMaxHit = max_energy_hit.getType(); + } + + + /** + * Computes the energy deposited in the bars. + * + * @return the energy deposited in the bars. + * + */ + public double getEdepBar() { + double energy = 0; + for (int i = 0; i < this.barHits.size(); i++) { + RECOILTOFHit this_hit = this.barHits.get(i); + energy += this_hit.getEnergy(); + } + return energy; + } + + /** + * Compute the cluster phi angle in radians. + * + * @return a double that is angle in radians + * + */ + public double getPhi() { + return Math.atan2(this.y, this.x); + } + + + /** + * Retrieve the hit with maximal energy in the cluster. It must have been + * computed previously. + * + * @return a RECOILTOFHit that is the maximal energy hit in the cluster + * + */ + public final RECOILTOFHit getMaxHit() { + if (this.typeMaxHit == null) { + System.out.print("You did not compute the maximal hit! \n"); + return null; + } + if (null == this.typeMaxHit) { + System.out.print("Unrecognized type! \n"); + return null; + } else { + switch (this.typeMaxHit) { + case "bar" -> { + return this.barHits.get(this.indexMaxHit); + } + default -> { + System.out.print("Unrecognized type! \n"); + return null; + } + } + } + } + + /** + * Computes the sum of TOT in the cluster. + * + * @return an int representing the summed TOT + * + */ + public int getTot() { + int tot = 0; + for (int i = 0; i < this.barHits.size(); i++) { + BarHit this_hit = this.barHits.get(i); + tot += this_hit.getTot(); + } + return tot; + } + + /** + * Returns the TDC of the maximal hit in the cluster. + * + * @return an int representing the TDC of the maximal hit. + * + */ + public int getTdc() { + return this.getMaxHit().getTdc(); + } + + /** + * Constructor that initializes the list of bar hits + * and computes the cluster properties. + * + * @param bar_hits a {@link ArrayList} of {@link BarHit}. + * + */ + public RECOILTOFCluster(ArrayList bar_hits) { + this.barHits = bar_hits; + this.computeClusterProperties(); + } + + /** + * Constructor that initializes the list of bar hits + * and computes the cluster properties. + * + * @param bar_hits a {@link ArrayList} of {@link BarHit}. + * @param event a {@link DataEvent} with which track matching will be done. + * + */ + public RECOILTOFCluster(ArrayList bar_hits, DataEvent event) { + this.barHits = bar_hits; + this.computeClusterProperties(); + } + + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + } + +} diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java new file mode 100644 index 0000000000..70ff971f60 --- /dev/null +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java @@ -0,0 +1,36 @@ +package org.jlab.rec.recoiltof.constants; + +/** + * + * @author npilleux, Nilanga Wickramaarachchi + */ +public class Parameters { + + public static final int NROWS = 5; //number of rows of bars in a sector + public static final int NCOLUMNS = 63; //number of columns of bars in a sector + + public static final double LONG_BAR_LENGTH = 200; // mm + public static final double SHORT_BAR_LENGTH = 40; // mm + + public static final double BAR_WIDTH = 10; // mm + + public static final double WIDTH = NCOLUMNS * BAR_WIDTH; + public static final double LENGTH = (NROWS-1) * LONG_BAR_LENGTH + SHORT_BAR_LENGTH; + + public static final double VEFF = 200.0;//mm/ns + public static final double TDC2TIME = 0.015625;//ns per channel bin + public static final double ATT_L = 1600.0;//mm + public static final double TOT2ENERGY = 1.956 * 0.5 /1000;//to MeV + + //public static double SIGMA_Y_TRACK_MATCHING_BAR = 200;//in mm + public static double SIGMA_Y_CLUSTERING = 40;//in mm + public static double SIGMA_T_CLUSTERING = 100;// in ns + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + // TODO code application logic here + } + +} diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/BarHit.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/BarHit.java new file mode 100644 index 0000000000..f8ed8bd5ab --- /dev/null +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/BarHit.java @@ -0,0 +1,117 @@ +package org.jlab.rec.recoiltof.hit; + +import org.jlab.rec.recoiltof.constants.Parameters; + +/** + * + * Represents a hit in the recoil tof bar. Extends class RECOILTOFHit. Is further defined + * by the two hits upstream and downstream composing a full bar hit. y position, + * time and energy are defined from the up/down hits. + * + * @author npilleux, Nilanga Wickramaarachchi + */ +public class BarHit extends RECOILTOFHit { + + //A bar hit is the combination of a downstream and upstream hits + private RECOILTOFHit hitUp, hitDown; + + public RECOILTOFHit getHitUp() { + return hitUp; + } + + public void setHitUp(RECOILTOFHit hit_up) { + this.hitUp = hit_up; + } + + public RECOILTOFHit getHitDown() { + return hitDown; + } + + public void setHitDown(RECOILTOFHit hit_down) { + this.hitDown = hit_down; + } + + /** + * Computes bar hit y coordinate from up/downstream hit times. + * + */ + public final void computeY() { + this.setY(Parameters.VEFF/2. * (hitUp.getTime() - hitDown.getTime())); + } + + /** + * Computes bar hit time from up/downstream hit times. + * The time is set as the time of the most energetic hit. + * It is corrected for propagation time. + * + */ + public final void computeTime() { + //We pick the most energetic signal as the timing signal + double time_at_sipm, distance_to_sipm; + if(this.hitDown.getEnergy() > this.hitUp.getEnergy()) { + time_at_sipm = this.hitDown.getTime(); + if(this.hitDown.getRow() == 3) distance_to_sipm = Parameters.SHORT_BAR_LENGTH/2. - this.getY(); + else distance_to_sipm = Parameters.LONG_BAR_LENGTH/2. - this.getY(); + } + else { + time_at_sipm = this.hitUp.getTime(); + if(this.hitUp.getRow() == 3) distance_to_sipm = Parameters.SHORT_BAR_LENGTH/2. + this.getY(); + else distance_to_sipm = Parameters.LONG_BAR_LENGTH/2. + this.getY(); + } + this.setTime(time_at_sipm - distance_to_sipm/Parameters.VEFF); + } + + /** + * Computes bar hit energy from up/downstream hits. + * The energy of the up/downstream hits is corrected for attenuation now that y is known. + * The energy of the bar hit is the sum of the energy of the up/downstream hits. + * + */ + public final void computeEnergy() { + this.computeY(); + double distance_hit_to_sipm_up, distance_hit_to_sipm_down; + + if (hitUp.getRow() == 3) distance_hit_to_sipm_up = Parameters.SHORT_BAR_LENGTH / 2. + this.getY(); + else distance_hit_to_sipm_up = Parameters.LONG_BAR_LENGTH / 2. + this.getY(); + + if (hitDown.getRow() == 3) distance_hit_to_sipm_down = Parameters.SHORT_BAR_LENGTH / 2. - this.getY(); + else distance_hit_to_sipm_down = Parameters.LONG_BAR_LENGTH / 2. - this.getY(); + + double Edep_up = hitUp.getEnergy() * Math.exp(distance_hit_to_sipm_up / Parameters.ATT_L); + double Edep_down = hitDown.getEnergy() * Math.exp(distance_hit_to_sipm_down / Parameters.ATT_L); + this.setEnergy(Edep_up + Edep_down); + } + + public BarHit(RECOILTOFHit hit_down, RECOILTOFHit hit_up) { + boolean hits_match = hit_down.matchBar(hit_up); + if (!hits_match) { + throw new UnsupportedOperationException("Hits do not match \n"); + } + this.setType("bar"); + this.setOrder(2);//Fake order for bar hits + this.hitUp = hit_up; + this.hitDown = hit_down; + this.setSector(hit_up.getSector()); + this.setRow(hit_up.getRow()); + this.setColumn(hit_up.getColumn()); + this.setX(hit_up.getX()); + this.setZ(hit_up.getZ()); + this.computeY(); + this.computeTime(); + this.computeEnergy(); + this.setTdc((hit_down.getTdc() + hit_up.getTdc())/2); + this.setTot((hit_down.getTot() + hit_up.getTot())); + } + + public BarHit() { + super(); + this.setType("bar"); + this.setOrder(2);//Fake order for bar hits + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + } +} diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/HitFinder.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/HitFinder.java new file mode 100644 index 0000000000..25ac83a8ae --- /dev/null +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/HitFinder.java @@ -0,0 +1,119 @@ +package org.jlab.rec.recoiltof.hit; + +import java.util.ArrayList; +import java.util.Collections; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; + +/** + * The {@code HitFinder} class finds hits in the recoil tof. + * + *

+ * Uses recoil tof tdc bank information + * + * Creates a {@link ArrayList} of {@link BarHit} for bar hits read. + * + *

+ * + * @author pilleux, Nilanga Wickramaarachchi + */ +public class HitFinder { + + /** + * list of bar hits + */ + private ArrayList barHits; + + /** + * Default constructor that initializes the list of hits as new empty lists. + */ + public HitFinder() { + this.barHits = new ArrayList<>(); + } + + // Getter and Setter for barHits + public ArrayList getBarHits() { + return barHits; + } + + public void setBarHits(ArrayList bar_hits) { + this.barHits = bar_hits; + } + + /** + * + * @param event the {@link DataEvent} containing hits. + * + */ + public void findHits(DataEvent event) { + //For each event a list of bar hits is filled + this.barHits.clear(); + //They are read from the RECOILTOF TDC bank + DataBank bank = event.getBank("RECOILTOF::tdc"); + int nt = bank.rows(); // number of hits + //Hits in the bar downstream and upstream will be matched + ArrayList hit_up = new ArrayList<>(); + ArrayList hit_down = new ArrayList<>(); + + //Looping through all hits + for (int i = 0; i < nt; i++) { + //Getting their properties + int sector = bank.getInt("sector", i); + int row = bank.getInt("row", i); + int column = bank.getInt("column", i); + int order = bank.getInt("order", i); + int tdc = bank.getInt("TDC", i); + int tot = bank.getInt("ToT", i); + + //Building a Hit + RECOILTOFHit hit = new RECOILTOFHit(sector, row, column, order, tdc, tot); + if (hit.getEnergy() < 0.01) { + continue; //energy threshold + } + + //Sorting the hits into upstream and downstream bar hits + //Lists are built for up/down bar to match them after + if (null == hit.getType()) { + System.out.print("Undefined hit type \n"); + } else { + switch (hit.getType()) { + case "bar up" -> + hit_up.add(hit); + case "bar down" -> + hit_down.add(hit); + default -> + System.out.print("Undefined hit type \n"); + } + } + }//End loop through all hits + + //Starting loop through up hits in the bar + for (int i_up = 0; i_up < hit_up.size(); i_up++) { + RECOILTOFHit this_hit_up = hit_up.get(i_up); + int countMatches = 0; + //Starting loop through down hits in the bar + for (int i_down = 0; i_down < hit_down.size(); i_down++) { + RECOILTOFHit this_hit_down = hit_down.get(i_down); + //Matching the hits: if same bar and different order, they make up a bar hit + if (this_hit_up.matchBar(this_hit_down)) { + if (countMatches > 0) { + //If the up hit was already involved in a match, do not make an additionnal match + //Chosing to ignore double matches for now because it happened for <1% of events in cosmic runs + continue; + } + BarHit this_bar_hit = new BarHit(this_hit_down, this_hit_up); + this.barHits.add(this_bar_hit); + countMatches++; + } + } + } + //Once all has been listed, hits are sorted by energy + Collections.sort(this.barHits, (hit1, hit2) -> Double.compare(hit2.getEnergy(), hit1.getEnergy())); + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + } +} diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java new file mode 100644 index 0000000000..7ece3bc4d3 --- /dev/null +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java @@ -0,0 +1,362 @@ +package org.jlab.rec.recoiltof.hit; + +import org.jlab.geom.base.*; +import org.jlab.geom.prim.Point3D; +import org.jlab.rec.recoiltof.constants.Parameters; + +/** + * + * Represents a hit in the recoil tof. Stores info about the sector, row, column, + * order, TDC, ToT. Type is bar up/bar down/ bar. Stores whether + * the hit is part of a cluster. Calculates time, energy based on TDC/ToT. + * + * @author npilleux, Nilanga Wickramaarachchi + */ +public class RECOILTOFHit { + + private int sector, row, column, order; + private int tdc, tot; + private double time, energy, x, y, z; + private String type; + private boolean isInACluster; + private int associatedClusterIndex; + int idTDC; + + public int getSector() { + return sector; + } + + public void setSector(int sector) { + this.sector = sector; + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public int getTdc() { + return tdc; + } + + public void setTdc(int tdc) { + this.tdc = tdc; + } + + public int getTot() { + return tot; + } + + public void setTot(int tot) { + this.tot = tot; + } + + public double getTime() { + return time; + } + + public void setTime(double time) { + this.time = time; + } + + public double getEnergy() { + return energy; + } + + public void setEnergy(double energy) { + this.energy = energy; + } + + public double getX() { + return x; + } + + public void setX(double x) { + this.x = x; + } + + public double getY() { + return y; + } + + public void setY(double y) { + this.y = y; + } + + public double getZ() { + return z; + } + + public void setZ(double z) { + this.z = z; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean getIsInACluster() { + return isInACluster; + } + + public void setIsInACluster(boolean is_in_a_cluster) { + this.isInACluster = is_in_a_cluster; + } + + public int getAssociatedClusterIndex() { + return associatedClusterIndex; + } + + public void setAssociatedClusterIndex(int index) { + this.associatedClusterIndex = index; + } + + public int getIdTDC() { + return idTDC; + } + + public void setIdTDC(int index) { + this.idTDC = index; + } + + + /** + * Assigns a type to the hit. + * + */ + public final String makeType() { + //Type of hit can be bar up, bar down or bar. + //Avoids testing components and order every time. + String itype = "undefined"; + if (this.order == 0) { + itype = "bar down"; + } else if (this.order == 1) { + itype = "bar up"; + } + this.type = itype; + return itype; + } + + /** + * Converts TDC to time (ns). Sets the hit time parameter to a raw time for + * up/down bar hits. + * + * @return 0 if the time was successfully set, or 1 if the hit type is + * unsupported. + */ + public final int convertTdcToTime() { + double tdc2time, veff, distance_to_sipm; + if (null == this.type) { + System.out.print("Null hit type, cannot convert tdc to time."); + return 1; + } else { + switch (this.type) { + case "bar up" -> { + tdc2time = Parameters.TDC2TIME; + veff = Parameters.VEFF; + //The distance will be computed at barhit level when y information is available + distance_to_sipm = 0; + } + case "bar down" -> { + tdc2time = Parameters.TDC2TIME; + veff = Parameters.VEFF; + //The distance will be computed at barhit level when y information is available + distance_to_sipm = 0; + } + case "bar" -> { + System.out.print("Bar hit type, cannot convert tdc to time."); + return 1; + } + default -> { + System.out.print("Undefined hit type, cannot convert tdc to time."); + return 1; + } + } + } + //Hit time. Will need implementation of offsets. + this.time = tdc2time * this.tdc - distance_to_sipm / veff; + return 0; + } + + /** + * Converts ToT to energy (MeV). Sets the hit energy parameter to a raw + * energy for up/down bar hits. + * + * @return 0 if the energy was successfully set, or 1 if the hit type is + * unsupported. + */ + public final int convertTotToEnergy() { + double tot2energy; + if (null == this.type) { + System.out.print("Null hit type, cannot convert tot to energy."); + return 1; + } else { + switch (this.type) { + case "bar up" -> { + tot2energy = Parameters.TOT2ENERGY; + //only half the information in the bar, + //the attenuation will be computed when the full hit is formed + this.energy = tot2energy * this.tot; + } + case "bar down" -> { + tot2energy = Parameters.TOT2ENERGY; + //only half the information in the bar, + //the attenuation will be computed when the full hit is formed + this.energy = tot2energy * this.tot; + } + case "bar" -> { + System.out.print("Bar hit type, cannot convert tot to energy."); + return 1; + } + default -> { + System.out.print("Undefined hit type, cannot convert tot to energy."); + return 1; + } + } + } + return 0; + } + + /** + * Calculates spatial coordinates (mm) for the hit based on row and column number of the bar within a sector. + * The row and column variables are obtained from the bank information. + * + * @return 0 if the coordinates were successfully set, or 1 if the hit type + * is undefined or unsupported. + */ + public final int calculateXYZ() { + + // Constants for positioning + int nRows = Parameters.NROWS; + double y_start = -(Parameters.LENGTH - Parameters.LONG_BAR_LENGTH)/2; // Starting Y position + double x_spacing = Parameters.BAR_WIDTH; + double x_start = -(Parameters.WIDTH - x_spacing)/2; // starting X position + double dy_long = Parameters.LONG_BAR_LENGTH; + double dy_short = Parameters.SHORT_BAR_LENGTH; + + //Position calculation + double z_pos = 0; + double x_pos = x_start + ((this.column-1) * x_spacing); + + double y_pos; + if(this.row-1 < (nRows - 1) / 2) + { + y_pos = y_start + ((this.row-1) * dy_long); + } + else if (this.row-1 == (nRows - 1) / 2) // middle row + { + y_pos = 0; + } + else + { + y_pos = y_start + (this.row -2) * dy_long + dy_short; + } + + this.x = x_pos; + this.y = y_pos; + this.z = z_pos; + return 0; + } + + /** + * Compares two RECOILTOFHit objects to check if they match in the bar. + *
    + *
  • If the sector or row or column of the two hits do not match, the method + * returns {@code false}.
  • + *
  • If both hits are in the same SiPM (i.e., their order is the same), or + * have incorrect order, the method returns {@code false}.
  • + *
+ * If none of these conditions are violated, the method returns + * {@code true}, indicating the two hits match. + * + * @param hit2match The RECOILTOFHit object to compare with the current instance. + * @return {@code true} if the hits match; {@code false} otherwise. + */ + public boolean matchBar(RECOILTOFHit hit2match) { + if (this.getSector() != hit2match.getSector()) { + //Two hits in different sectors + return false; + } else if (this.getRow() != hit2match.getRow()) { + //Two hits in different rows + return false; + } else if (this.getColumn() != hit2match.getColumn()) { + //Two hits in different columns + return false; + } else if (this.getOrder() > 1 || hit2match.getOrder() > 1) { + //At least one hit has incorrect order + return false; + } else { + //Match if one is order 0 and the other is order 1 + return this.getOrder() != hit2match.getOrder(); + } + } + + /** + * Computes the azimuthal angle (phi) of the hit in rad. + * + * @return The azimuthal angle (phi) in radians, in the range [-π, π]. + */ + public double getPhi() { + return Math.atan2(this.y, this.x); + } + + /** + * Constructor for a hit in the recoil tof. Initializes the hit's sector, row, + * column, order, TDC, ToT. Sets the hit's initial state regarding + * clustering. Set up the hit's type, time, energy, and spatial coordinates. + * + * @param sector The sector of the detector where the hit occurred. + * @param row The row of the detector where the hit was detected. + * @param column The column within the row that registered the hit. + * @param order Order of the hit. + * @param tdc TDC value. + * @param tot ToT value. + * + */ + public RECOILTOFHit(int sector, int row, int column, int order, int tdc, int tot) { + this.sector = sector; + this.row = row; + this.column = column; + this.order = order; + this.tdc = tdc; + this.tot = tot; + this.isInACluster = false; + + this.makeType(); + this.convertTdcToTime(); + this.convertTotToEnergy(); + this.calculateXYZ(); + } + + public RECOILTOFHit() { + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + } +} diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java b/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java new file mode 100644 index 0000000000..09cbbb472e --- /dev/null +++ b/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java @@ -0,0 +1,92 @@ +package org.jlab.service.recoiltof; + +import java.util.ArrayList; + +import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; + +import java.util.concurrent.atomic.AtomicInteger; +import org.jlab.clas.swimtools.Swim; +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.io.hipo.HipoDataSource; +import org.jlab.rec.recoiltof.banks.RecoBankWriter; +import org.jlab.rec.recoiltof.cluster.RECOILTOFCluster; +import org.jlab.rec.recoiltof.cluster.ClusterFinder; +import org.jlab.rec.recoiltof.hit.RECOILTOFHit; +import org.jlab.rec.recoiltof.hit.BarHit; +import org.jlab.rec.recoiltof.hit.HitFinder; + +/** + * Service to return reconstructed RECOILTOF hits and clusters + * + * @author npilleux, Nilanga Wickramaarachchi + * + */ +public class RECOILTOFEngine extends ReconstructionEngine { + + public RECOILTOFEngine() { + super("RECOILTOF", "Nilanga Wickramaarachchi", "1.0"); + } + + RecoBankWriter rbc; + + private final AtomicInteger run = new AtomicInteger(0); + + @Override + public boolean processDataEvent(DataEvent event) { + + if (!event.hasBank("RUN::config")) { + return true; + } + + DataBank bank = event.getBank("RUN::config"); + + int newRun = bank.getInt("run", 0); + if (newRun == 0) { + return true; + } + + if (run.get() == 0 || (run.get() != 0 && run.get() != newRun)) { + run.set(newRun); + } + + //Do we need to read the event vx,vy,vz? + //If not, this part can be moved in the initialization of the engine. + double eventVx=0,eventVy=0,eventVz=0; //They should be in CM + + //Hit finder init + HitFinder hitfinder = new HitFinder(); + hitfinder.findHits(event); + + ArrayList BarHits = hitfinder.getBarHits(); + + //Exit if hit list is empty + if (BarHits.isEmpty()) { + // System.out.println("No hits : "); + // event.show(); + return true; + } + + ClusterFinder clusterFinder = new ClusterFinder(); + clusterFinder.makeClusters(event,hitfinder); + ArrayList Clusters = clusterFinder.getClusters(); + + if (BarHits.size() != 0) { + rbc.appendRECOILTOFBanks(event, BarHits, Clusters); + } + return true; + } + + @Override + public boolean init() { + rbc = new RecoBankWriter(); + + this.registerOutputBank("RECOILTOF::hits", "RECOILTOF::clusters"); + + return true; + } + + public static void main(String arg[]) { + } +} From 07835d5120bf108dad404798ac0fdd33de26a509 Mon Sep 17 00:00:00 2001 From: niwgit Date: Mon, 7 Apr 2025 15:25:12 -0400 Subject: [PATCH 04/11] Few changes related to positioning TOF plane and save global coordinates of bar hits --- .../v2/recoil_tof/RecoilTOFConstants.java | 3 +- .../v2/recoil_tof/RecoilTOFGeant4Factory.java | 7 ++- .../rec/recoiltof/constants/Parameters.java | 8 ++- .../org/jlab/rec/recoiltof/hit/BarHit.java | 57 ++++++++++++++----- .../jlab/rec/recoiltof/hit/RECOILTOFHit.java | 52 +++++++++++++++-- .../service/recoiltof/RECOILTOFEngine.java | 3 - 6 files changed, 104 insertions(+), 26 deletions(-) diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java index 447dd85324..746ccd07a6 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java @@ -17,7 +17,8 @@ public class RecoilTOFConstants { public final static double BAR_WIDTH = 1; // cm public final static double BAR_THICKNESS = 0.5; // cm - public final static double HORIZONTAL_OPENING_ANGLE = 40.; + public final static double HORIZONTAL_STARTING_ANGLE = 40.; + public final static double HORIZONTAL_OPENING_ANGLE = 29.; public final static double RADIUS = 122.; // cm public final static double WIDTH = NCOLUMNS * BAR_WIDTH; diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFGeant4Factory.java index ff42ba3d2e..9772a52c5d 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFGeant4Factory.java @@ -41,9 +41,9 @@ public Vector3d getCenterCoordinate(int isector) int is=isector; Vector3d vCenter = new Vector3d(0, 0, 0); - vCenter.x = (-1+is*2)*(RecoilTOFConstants.RADIUS)*Math.sin(Math.toRadians(1.5*RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE)); + vCenter.x = (-1+is*2)*(RecoilTOFConstants.RADIUS)*Math.sin(Math.toRadians(RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE/2+RecoilTOFConstants.HORIZONTAL_STARTING_ANGLE)); vCenter.y = 0; - vCenter.z =RecoilTOFConstants.RADIUS*Math.cos(Math.toRadians(1.5*RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE)); + vCenter.z =RecoilTOFConstants.RADIUS*Math.cos(Math.toRadians(RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE/2+RecoilTOFConstants.HORIZONTAL_STARTING_ANGLE)); return vCenter; } @@ -59,7 +59,8 @@ public Geant4Basic createSector(int isector, int nRows, int nCols ) { Geant4Basic sectorVolume = new G4Box("recoil_tof_sector" + (isector + 1), hlx, hly, hlz); - sectorVolume.rotate("yxz",(-1+isector*2)*Math.toRadians(1.5*RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE+270),0,0); + if(isector==0) sectorVolume.rotate("yxz",Math.toRadians((RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE/2+RecoilTOFConstants.HORIZONTAL_STARTING_ANGLE)),0,0); + if(isector==1) sectorVolume.rotate("yxz",Math.toRadians(-(RecoilTOFConstants.HORIZONTAL_OPENING_ANGLE/2+RecoilTOFConstants.HORIZONTAL_STARTING_ANGLE)),0,0); sectorVolume.translate(vCenter.x, vCenter.y, vCenter.z); sectorVolume.setId(isector + 1, 0, 0); diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java index 70ff971f60..3232531511 100644 --- a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java @@ -16,12 +16,16 @@ public class Parameters { public static final double WIDTH = NCOLUMNS * BAR_WIDTH; public static final double LENGTH = (NROWS-1) * LONG_BAR_LENGTH + SHORT_BAR_LENGTH; - + + public static final double HORIZONTAL_STARTING_ANGLE = 40.; + public static final double HORIZONTAL_OPENING_ANGLE = 29.; + public static final double RADIUS = 1220; // mm + public static final double VEFF = 200.0;//mm/ns public static final double TDC2TIME = 0.015625;//ns per channel bin public static final double ATT_L = 1600.0;//mm public static final double TOT2ENERGY = 1.956 * 0.5 /1000;//to MeV - + //public static double SIGMA_Y_TRACK_MATCHING_BAR = 200;//in mm public static double SIGMA_Y_CLUSTERING = 40;//in mm public static double SIGMA_T_CLUSTERING = 100;// in ns diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/BarHit.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/BarHit.java index f8ed8bd5ab..9d1b3b106f 100644 --- a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/BarHit.java +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/BarHit.java @@ -32,13 +32,43 @@ public void setHitDown(RECOILTOFHit hit_down) { } /** - * Computes bar hit y coordinate from up/downstream hit times. + * Computes bar hit y local coordinate from up/downstream hit times. * */ - public final void computeY() { - this.setY(Parameters.VEFF/2. * (hitUp.getTime() - hitDown.getTime())); + public final void computeLocalY() { + this.setLocalY(Parameters.VEFF/2. * (hitUp.getTime() - hitDown.getTime())); } + /** + * Computes bar hit y coordinate in the global coordinate system. + * + */ + public final void computeGlobalY() { + double localY = this.getLocalY(); + + int nRows = Parameters.NROWS; + double y_start = -(Parameters.LENGTH - Parameters.LONG_BAR_LENGTH)/2; // Starting Y position + double dy_long = Parameters.LONG_BAR_LENGTH; + double dy_short = Parameters.SHORT_BAR_LENGTH; + + double y_pos; // y coordinate of the center of bar wrt to the global coordinate system + if(hitUp.getRow()-1 < (nRows - 1)/2) + { + y_pos = y_start + ((hitUp.getRow()-1) * dy_long); + } + else if (hitUp.getRow()-1 == (nRows-1) / 2) // middle row + { + y_pos = 0; + } + else + { + y_pos = y_start + (hitUp.getRow()-2) * dy_long + dy_short; + } + + this.setY(y_pos + localY); + } + + /** * Computes bar hit time from up/downstream hit times. * The time is set as the time of the most energetic hit. @@ -50,13 +80,13 @@ public final void computeTime() { double time_at_sipm, distance_to_sipm; if(this.hitDown.getEnergy() > this.hitUp.getEnergy()) { time_at_sipm = this.hitDown.getTime(); - if(this.hitDown.getRow() == 3) distance_to_sipm = Parameters.SHORT_BAR_LENGTH/2. - this.getY(); - else distance_to_sipm = Parameters.LONG_BAR_LENGTH/2. - this.getY(); + if(this.hitDown.getRow() == 3) distance_to_sipm = Parameters.SHORT_BAR_LENGTH/2. - this.getLocalY(); + else distance_to_sipm = Parameters.LONG_BAR_LENGTH/2. - this.getLocalY(); } else { time_at_sipm = this.hitUp.getTime(); - if(this.hitUp.getRow() == 3) distance_to_sipm = Parameters.SHORT_BAR_LENGTH/2. + this.getY(); - else distance_to_sipm = Parameters.LONG_BAR_LENGTH/2. + this.getY(); + if(this.hitUp.getRow() == 3) distance_to_sipm = Parameters.SHORT_BAR_LENGTH/2. + this.getLocalY(); + else distance_to_sipm = Parameters.LONG_BAR_LENGTH/2. + this.getLocalY(); } this.setTime(time_at_sipm - distance_to_sipm/Parameters.VEFF); } @@ -68,14 +98,14 @@ public final void computeTime() { * */ public final void computeEnergy() { - this.computeY(); + this.computeLocalY(); double distance_hit_to_sipm_up, distance_hit_to_sipm_down; - if (hitUp.getRow() == 3) distance_hit_to_sipm_up = Parameters.SHORT_BAR_LENGTH / 2. + this.getY(); - else distance_hit_to_sipm_up = Parameters.LONG_BAR_LENGTH / 2. + this.getY(); + if (hitUp.getRow() == 3) distance_hit_to_sipm_up = Parameters.SHORT_BAR_LENGTH / 2. + this.getLocalY(); + else distance_hit_to_sipm_up = Parameters.LONG_BAR_LENGTH / 2. + this.getLocalY(); - if (hitDown.getRow() == 3) distance_hit_to_sipm_down = Parameters.SHORT_BAR_LENGTH / 2. - this.getY(); - else distance_hit_to_sipm_down = Parameters.LONG_BAR_LENGTH / 2. - this.getY(); + if (hitDown.getRow() == 3) distance_hit_to_sipm_down = Parameters.SHORT_BAR_LENGTH / 2. - this.getLocalY(); + else distance_hit_to_sipm_down = Parameters.LONG_BAR_LENGTH / 2. - this.getLocalY(); double Edep_up = hitUp.getEnergy() * Math.exp(distance_hit_to_sipm_up / Parameters.ATT_L); double Edep_down = hitDown.getEnergy() * Math.exp(distance_hit_to_sipm_down / Parameters.ATT_L); @@ -96,7 +126,8 @@ public BarHit(RECOILTOFHit hit_down, RECOILTOFHit hit_up) { this.setColumn(hit_up.getColumn()); this.setX(hit_up.getX()); this.setZ(hit_up.getZ()); - this.computeY(); + this.computeLocalY(); + this.computeGlobalY(); this.computeTime(); this.computeEnergy(); this.setTdc((hit_down.getTdc() + hit_up.getTdc())/2); diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java index 7ece3bc4d3..ef24de4394 100644 --- a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java @@ -16,7 +16,7 @@ public class RECOILTOFHit { private int sector, row, column, order; private int tdc, tot; - private double time, energy, x, y, z; + private double time, energy, x, y, z, local_y; private String type; private boolean isInACluster; private int associatedClusterIndex; @@ -102,6 +102,14 @@ public void setY(double y) { this.y = y; } + public double getLocalY() { + return local_y; + } + + public void setLocalY(double local_y) { + this.local_y = local_y; + } + public double getZ() { return z; } @@ -274,10 +282,46 @@ else if (this.row-1 == (nRows - 1) / 2) // middle row { y_pos = y_start + (this.row -2) * dy_long + dy_short; } + + double[] localCoords = {x_pos, y_pos, z_pos}; - this.x = x_pos; - this.y = y_pos; - this.z = z_pos; + // Calculate center coordinates for the sector + double sector_x = (-1+(this.sector-1)*2)*(Parameters.RADIUS)*Math.sin(Math.toRadians(Parameters.HORIZONTAL_OPENING_ANGLE/2+Parameters.HORIZONTAL_STARTING_ANGLE)); + double sector_y = 0; + double sector_z = Parameters.RADIUS*Math.cos(Math.toRadians(Parameters.HORIZONTAL_OPENING_ANGLE/2+Parameters.HORIZONTAL_STARTING_ANGLE)); + + // Global coordinates of the sector + double[] globalCoordsSector = {sector_x, sector_y, sector_z}; + + // Rotation angle in radians + double thetaY = 0; + + if(this.sector==1) thetaY = Math.toRadians(Parameters.HORIZONTAL_OPENING_ANGLE/2+Parameters.HORIZONTAL_STARTING_ANGLE); + if(this.sector==2) thetaY = Math.toRadians(-(Parameters.HORIZONTAL_OPENING_ANGLE/2+Parameters.HORIZONTAL_STARTING_ANGLE)); + + // Rotation matrix around the Y-axis + double[][] Ry = { + {Math.cos(thetaY), 0, Math.sin(thetaY)}, + {0, 1, 0}, + {-Math.sin(thetaY), 0, Math.cos(thetaY)} + }; + + // Rotate local coordinates + double[] rotatedCoords = new double[3]; + for (int i = 0; i < 3; i++) { + rotatedCoords[i] = Ry[i][0] * localCoords[0] + Ry[i][1] * localCoords[1] + Ry[i][2] * localCoords[2]; + } + + // Calculate global coordinates for the hit + double[] globalCoordsBar = new double[3]; + for (int i = 0; i < 3; i++) { + globalCoordsBar[i] = globalCoordsSector[i] + rotatedCoords[i]; + } + + + this.x = globalCoordsBar[0]; + this.y = globalCoordsBar[1]; + this.z = globalCoordsBar[2]; return 0; } diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java b/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java index 09cbbb472e..6f94b3a610 100644 --- a/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java +++ b/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java @@ -51,9 +51,6 @@ public boolean processDataEvent(DataEvent event) { run.set(newRun); } - //Do we need to read the event vx,vy,vz? - //If not, this part can be moved in the initialization of the engine. - double eventVx=0,eventVy=0,eventVz=0; //They should be in CM //Hit finder init HitFinder hitfinder = new HitFinder(); From 7f9c8920c1f6600ab61a0bdb05accf4683dbe04e Mon Sep 17 00:00:00 2001 From: niwgit Date: Tue, 8 Apr 2025 10:58:39 -0400 Subject: [PATCH 05/11] Added sector info to RECOILTOF::clusters bank --- etc/bankdefs/hipo4/recoiltof.json | 4 ++++ .../jlab/rec/recoiltof/banks/RecoBankWriter.java | 1 + .../rec/recoiltof/cluster/RECOILTOFCluster.java | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/etc/bankdefs/hipo4/recoiltof.json b/etc/bankdefs/hipo4/recoiltof.json index 03b45fd6d1..6f4786bf74 100644 --- a/etc/bankdefs/hipo4/recoiltof.json +++ b/etc/bankdefs/hipo4/recoiltof.json @@ -61,6 +61,10 @@ "name": "N_bar", "type": "I", "info": "number of hits from the bars" + },{ + "name": "sector", + "type": "I", + "info": "sector number" },{ "name": "time", "type": "F", diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/banks/RecoBankWriter.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/banks/RecoBankWriter.java index f0d4c2a2ea..a2027d85a3 100644 --- a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/banks/RecoBankWriter.java +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/banks/RecoBankWriter.java @@ -76,6 +76,7 @@ public static DataBank fillRECOILTOFClusterBank(DataEvent event, ArrayList barHits; /** * cluster properties:position [cm], time [ns], energy[MeV], - * type of the maximum hit (to set resolutions) and index of the maximum hit. + * type of the maximum hit (to set resolutions) and index and sector of the maximum hit. */ double x, y, z, time, energy; String typeMaxHit; - int indexMaxHit; + int indexMaxHit, sectorMaxHit; public ArrayList getBarHits() { return barHits; @@ -98,6 +98,15 @@ public void setIndexMaxHit(int indexMaxHit) { this.indexMaxHit = indexMaxHit; } + public int getSectorMaxHit() { + return sectorMaxHit; + } + + public void setSectorMaxHit(int sectorMaxHit) { + this.sectorMaxHit = sectorMaxHit; + } + + /** * Compute the cluster properties. * @@ -127,6 +136,7 @@ public final void computeClusterProperties() { this.y = max_energy_hit.getY(); this.z = max_energy_hit.getZ(); this.typeMaxHit = max_energy_hit.getType(); + this.sectorMaxHit = max_energy_hit.getSector(); } From d11a68c0f19232777253a55b343c0c193126af0e Mon Sep 17 00:00:00 2001 From: niwgit Date: Wed, 9 Apr 2025 16:11:22 -0400 Subject: [PATCH 06/11] Change sign of rotation angle for coordinate transformation --- .../main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java index ef24de4394..c4a557d49e 100644 --- a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/hit/RECOILTOFHit.java @@ -296,8 +296,8 @@ else if (this.row-1 == (nRows - 1) / 2) // middle row // Rotation angle in radians double thetaY = 0; - if(this.sector==1) thetaY = Math.toRadians(Parameters.HORIZONTAL_OPENING_ANGLE/2+Parameters.HORIZONTAL_STARTING_ANGLE); - if(this.sector==2) thetaY = Math.toRadians(-(Parameters.HORIZONTAL_OPENING_ANGLE/2+Parameters.HORIZONTAL_STARTING_ANGLE)); + if(this.sector==1) thetaY = Math.toRadians(-(Parameters.HORIZONTAL_OPENING_ANGLE/2+Parameters.HORIZONTAL_STARTING_ANGLE)); + if(this.sector==2) thetaY = Math.toRadians(Parameters.HORIZONTAL_OPENING_ANGLE/2+Parameters.HORIZONTAL_STARTING_ANGLE); // Rotation matrix around the Y-axis double[][] Ry = { From 861539a7e86ebd9a07b71e95208c3c79c898dd8a Mon Sep 17 00:00:00 2001 From: niwgit Date: Fri, 11 Apr 2025 12:06:26 -0400 Subject: [PATCH 07/11] Change long bar length in recoil TOF 20 cm -> 27.5 cm --- .../jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java | 2 +- .../main/java/org/jlab/rec/recoiltof/constants/Parameters.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java index 746ccd07a6..e938507fce 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/recoil_tof/RecoilTOFConstants.java @@ -11,7 +11,7 @@ public class RecoilTOFConstants { public final static int NROWS = 5; //number of rows of bars in a sector public final static int NCOLUMNS = 63; //number of columns of bars in a sector - public final static double LONG_BAR_LENGTH = 20; // cm + public final static double LONG_BAR_LENGTH = 27.5; // cm public final static double SHORT_BAR_LENGTH = 4; // cm public final static double BAR_WIDTH = 1; // cm diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java index 3232531511..a32164b9ec 100644 --- a/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java +++ b/reconstruction/recoiltof/src/main/java/org/jlab/rec/recoiltof/constants/Parameters.java @@ -9,7 +9,7 @@ public class Parameters { public static final int NROWS = 5; //number of rows of bars in a sector public static final int NCOLUMNS = 63; //number of columns of bars in a sector - public static final double LONG_BAR_LENGTH = 200; // mm + public static final double LONG_BAR_LENGTH = 275; // mm public static final double SHORT_BAR_LENGTH = 40; // mm public static final double BAR_WIDTH = 10; // mm From c7d4611dd74ff0e52af34db54049ad080606550a Mon Sep 17 00:00:00 2001 From: Nilanga Wickramaarachchi Date: Wed, 29 Oct 2025 13:17:15 -0400 Subject: [PATCH 08/11] Match the coatjava version and corrected parent in pom.xml Co-authored-by: Christopher Dilks --- reconstruction/recoiltof/pom.xml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/reconstruction/recoiltof/pom.xml b/reconstruction/recoiltof/pom.xml index 189b1d70a3..7dcd9f094c 100644 --- a/reconstruction/recoiltof/pom.xml +++ b/reconstruction/recoiltof/pom.xml @@ -6,14 +6,13 @@ org.jlab.clas12.detector clas12detector-recoiltof - 1.0-SNAPSHOT + 13.4.0-SNAPSHOT jar - org.jlab.clas - clas12rec - ../../parent/pom.xml - 11.1.2-SNAPSHOT + org.jlab.clas12 + reconstruction + 13.4.0-SNAPSHOT @@ -21,13 +20,13 @@ org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 13.4.0-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 13.4.0-SNAPSHOT From 9d0557a3cdeb4f259e66a0726a4539078428abe7 Mon Sep 17 00:00:00 2001 From: Nilanga Wickramaarachchi Date: Thu, 30 Oct 2025 13:32:40 -0400 Subject: [PATCH 09/11] Fix dependencies in pom.xml --- reconstruction/recoiltof/pom.xml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/reconstruction/recoiltof/pom.xml b/reconstruction/recoiltof/pom.xml index 7dcd9f094c..96f979d7f3 100644 --- a/reconstruction/recoiltof/pom.xml +++ b/reconstruction/recoiltof/pom.xml @@ -19,16 +19,15 @@ org.jlab.clas - clas-detector + clas-io 13.4.0-SNAPSHOT - org.jlab.clas - clas-analysis + clas-reco 13.4.0-SNAPSHOT - + - + From 173bbe86dd675b56e109e6490a3e63a7192bdc17 Mon Sep 17 00:00:00 2001 From: niwgit Date: Thu, 30 Oct 2025 16:03:19 -0400 Subject: [PATCH 10/11] Added few more dependencies --- reconstruction/recoiltof/pom.xml | 10 ++++++++++ .../org/jlab/service/recoiltof/RECOILTOFEngine.java | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/reconstruction/recoiltof/pom.xml b/reconstruction/recoiltof/pom.xml index 96f979d7f3..d6eac33481 100644 --- a/reconstruction/recoiltof/pom.xml +++ b/reconstruction/recoiltof/pom.xml @@ -17,11 +17,21 @@ + + org.jlab.clas + clas-detector + 13.4.0-SNAPSHOT + org.jlab.clas clas-io 13.4.0-SNAPSHOT + + org.jlab.clas + clas-geometry + 13.4.0-SNAPSHOT + org.jlab.clas clas-reco diff --git a/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java b/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java index 6f94b3a610..bb8daa34a9 100644 --- a/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java +++ b/reconstruction/recoiltof/src/main/java/org/jlab/service/recoiltof/RECOILTOFEngine.java @@ -7,7 +7,6 @@ import org.jlab.io.base.DataEvent; import java.util.concurrent.atomic.AtomicInteger; -import org.jlab.clas.swimtools.Swim; import org.jlab.detector.calib.utils.DatabaseConstantProvider; import org.jlab.io.hipo.HipoDataSource; import org.jlab.rec.recoiltof.banks.RecoBankWriter; From 70bc33357f2cabe271d0cd5c0f0535b74dd6cf6e Mon Sep 17 00:00:00 2001 From: Nilanga Wickramaarachchi Date: Thu, 30 Oct 2025 18:05:56 -0400 Subject: [PATCH 11/11] Remove unused dependencies Co-authored-by: Christopher Dilks --- reconstruction/recoiltof/pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/reconstruction/recoiltof/pom.xml b/reconstruction/recoiltof/pom.xml index d6eac33481..96f979d7f3 100644 --- a/reconstruction/recoiltof/pom.xml +++ b/reconstruction/recoiltof/pom.xml @@ -17,21 +17,11 @@ - - org.jlab.clas - clas-detector - 13.4.0-SNAPSHOT - org.jlab.clas clas-io 13.4.0-SNAPSHOT - - org.jlab.clas - clas-geometry - 13.4.0-SNAPSHOT - org.jlab.clas clas-reco