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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye
double R_layer = 32.0d;
double DR_layer = 4.0d;

double zoff1 = 0.0d;
double zoff2 = 300.0d;
double zoff1 = -150.0d;
double zoff2 = 150.0d;
Point3D p1 = new Point3D(R_layer, 0, zoff1);
Vector3D n1 = new Vector3D(0, 0, 1);

Expand Down Expand Up @@ -125,21 +125,28 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye
double alphaW_layer = Math.toRadians(round / (numWires));

// shift the wire end point +-20deg in XY plan
double thster = Math.toRadians(20.0d);
double thster = Math.toRadians(-20.0d);
double zl = 300.0d;

// Create AHDC sense wires
for (int wireId = 0; wireId < numWires; wireId++) {
for (int iw = 0; iw < numWires; iw++) {

// The point given by (wx, wy, wz) is the midpoint of the current wire.
double wx = R_layer * Math.cos(alphaW_layer * wireId);
double wy = R_layer * Math.sin(alphaW_layer * wireId);
// start at phi=180
double wirePhiIndex = (numWires/2) + iw - 0.5*(layerId-1);

// the wire id is such that the wire number = (wireId+1) is the first wqual or greater than numWires/2
int wireId = iw + (int) (numWires/2);
if(wireId>numWires-1) wireId -= numWires;

// The point given by (wx, wy, wz) is the origin of the current wire.
double wx = R_layer * Math.cos(alphaW_layer * wirePhiIndex);
double wy = R_layer * Math.sin(alphaW_layer * wirePhiIndex);

// Find the interesection of the current wire with the end-plate
// planes by construciting a long line that passes through the midpoint
double wx_end = R_layer * Math.cos(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId)));
double wy_end = R_layer * Math.sin(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId)));
Line3D line = new Line3D(wx, wy, 0, wx_end, wy_end, zl);
double wx_end = R_layer * Math.cos(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId)));
double wy_end = R_layer * Math.sin(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId)));
Line3D line = new Line3D(wx, wy, -zl/2, wx_end, wy_end, zl/2);

Point3D lPoint = new Point3D();
Point3D rPoint = new Point3D();
Expand All @@ -150,49 +157,49 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye
// Do not change the code above. It is for signal wires positioning

// Construct the cell around the signal wires created above top
double px_0 = (R_layer + 2) * Math.cos(alphaW_layer * wireId);
double py_0 = (R_layer + 2) * Math.sin(alphaW_layer * wireId);
double px_1 = (R_layer + 2) * Math.cos(alphaW_layer * wireId + alphaW_layer / 2);
double py_1 = (R_layer + 2) * Math.sin(alphaW_layer * wireId + alphaW_layer / 2);
double px_2 = (R_layer - 2) * Math.cos(alphaW_layer * wireId + alphaW_layer / 2);
double py_2 = (R_layer - 2) * Math.sin(alphaW_layer * wireId + alphaW_layer / 2);
double px_3 = (R_layer - 2) * Math.cos(alphaW_layer * wireId);
double py_3 = (R_layer - 2) * Math.sin(alphaW_layer * wireId);
double px_4 = (R_layer - 2) * Math.cos(alphaW_layer * wireId - alphaW_layer / 2);
double py_4 = (R_layer - 2) * Math.sin(alphaW_layer * wireId - alphaW_layer / 2);
double px_5 = (R_layer + 2) * Math.cos(alphaW_layer * wireId - alphaW_layer / 2);
double py_5 = (R_layer + 2) * Math.sin(alphaW_layer * wireId - alphaW_layer / 2);
double px_0 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex);
double py_0 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex);
double px_1 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex + alphaW_layer / 2);
double py_1 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex + alphaW_layer / 2);
double px_2 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex + alphaW_layer / 2);
double py_2 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex + alphaW_layer / 2);
double px_3 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex);
double py_3 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex);
double px_4 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex - alphaW_layer / 2);
double py_4 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex - alphaW_layer / 2);
double px_5 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex - alphaW_layer / 2);
double py_5 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex - alphaW_layer / 2);
// bottom (do not forget to add the +20 deg. twist respect to the "straight" version)
double px_6 = (R_layer + 2) * Math.cos(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId)));
double py_6 = (R_layer + 2) * Math.sin(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId)));
double px_7 = (R_layer + 2) * Math.cos(alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double py_7 = (R_layer + 2) * Math.sin(alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double px_8 = (R_layer - 2) * Math.cos(alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double py_8 = (R_layer - 2) * Math.sin(alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double px_9 = (R_layer - 2) * Math.cos(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId)));
double py_9 = (R_layer - 2) * Math.sin(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId)));
double px_10 = (R_layer - 2) * Math.cos(alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double py_10 = (R_layer - 2) * Math.sin(alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double px_11 = (R_layer + 2) * Math.cos(alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double py_11 = (R_layer + 2) * Math.sin(alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double px_6 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId)));
double py_6 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId)));
double px_7 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double py_7 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double px_8 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double py_8 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double px_9 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId)));
double py_9 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId)));
double px_10 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double py_10 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double px_11 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));
double py_11 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId)));

// Group into points with (x,y,z) coordinates
List<Point3D> firstF = new ArrayList<>();
List<Point3D> secondF = new ArrayList<>();
// first Face
Point3D p_0 = new Point3D(px_0, py_0, 0.0d);
Point3D p_1 = new Point3D(px_1, py_1, 0.0d);
Point3D p_2 = new Point3D(px_2, py_2, 0.0d);
Point3D p_3 = new Point3D(px_3, py_3, 0.0d);
Point3D p_4 = new Point3D(px_4, py_4, 0.0d);
Point3D p_5 = new Point3D(px_5, py_5, 0.0d);
Point3D p_0 = new Point3D(px_0, py_0, -zl/2);
Point3D p_1 = new Point3D(px_1, py_1, -zl/2);
Point3D p_2 = new Point3D(px_2, py_2, -zl/2);
Point3D p_3 = new Point3D(px_3, py_3, -zl/2);
Point3D p_4 = new Point3D(px_4, py_4, -zl/2);
Point3D p_5 = new Point3D(px_5, py_5, -zl/2);
// second Face
Point3D p_6 = new Point3D(px_6, py_6, zl);
Point3D p_7 = new Point3D(px_7, py_7, zl);
Point3D p_8 = new Point3D(px_8, py_8, zl);
Point3D p_9 = new Point3D(px_9, py_9, zl);
Point3D p_10 = new Point3D(px_10, py_10, zl);
Point3D p_11 = new Point3D(px_11, py_11, zl);
Point3D p_6 = new Point3D(px_6, py_6, zl/2);
Point3D p_7 = new Point3D(px_7, py_7, zl/2);
Point3D p_8 = new Point3D(px_8, py_8, zl/2);
Point3D p_9 = new Point3D(px_9, py_9, zl/2);
Point3D p_10 = new Point3D(px_10, py_10, zl/2);
Point3D p_11 = new Point3D(px_11, py_11, zl/2);
// defining a cell around a wireLine, must be counter-clockwise!
firstF.add(p_0);
firstF.add(p_5);
Expand All @@ -207,7 +214,6 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye
secondF.add(p_9);
secondF.add(p_8);
secondF.add(p_7);


// Create the cell and signal wire inside
// PrismaticComponent(int componentId, List<Point3D> firstFace, List<Point3D> secondFace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected ConcaveComponent(int componentId, List<Point3D> firstFace, List<Point3
if (n.dot(direction) > 0.001) {
// System.err.println("PrismaticComponent: #" + componentId + " " + n.dot(direction) + " > 0");
// for (Point3D point : firstFace) System.err.println("\t" + point);
throw new IllegalArgumentException("the first face is not counter-clockwise: componentId=" + componentId);
throw new IllegalArgumentException("the first face is not counter-clockwise: componentId=" + componentId);
}
u = secondFace.get(1).vectorFrom(secondFace.get(0));
v = secondFace.get(2).vectorFrom(secondFace.get(0));
Expand Down
64 changes: 19 additions & 45 deletions reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/Hit.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.jlab.rec.ahdc.Hit;

import org.jlab.geom.detector.alert.AHDC.AlertDCDetector;
import org.jlab.geom.prim.Line3D;
import org.jlab.geom.prim.Point3D;

public class Hit implements Comparable<Hit> {

Expand All @@ -12,6 +15,7 @@ public class Hit implements Comparable<Hit> {
private final double adc;
private final double time;

private Line3D wireLine;
private double phi;
private double radius;
private int nbOfWires;
Expand All @@ -31,55 +35,21 @@ public Hit(int _Id, int _Super_layer, int _Layer, int _Wire, double _Doca, doubl
this.doca = _Doca;
this.adc = _ADC;
this.time = _Time;
wirePosition();
this.residual_prefit = 0.0;
this.residual = 0.0;
this.trackId = -1; // not defined yet
}

private void wirePosition() {
final double DR_layer = 4.0;
final double round = 360.0;

double numWires = 32.0;
double R_layer = 47.0;

switch (this.superLayerId) {
case 1:
numWires = 47.0;
R_layer = 32.0;
break;
case 2:
numWires = 56.0;
R_layer = 38.0;
break;
case 3:
numWires = 72.0;
R_layer = 48.0;
break;
case 4:
numWires = 87.0;
R_layer = 58.0;
break;
case 5:
numWires = 99.0;
R_layer = 68.0;
break;
}

R_layer = R_layer + DR_layer * (this.layerId-1);
double alphaW_layer = Math.toRadians(round / (numWires));
//should it be at z = 0? in which case, we need to account for the positive or negative stereo angle...
double wx = -R_layer * Math.sin(alphaW_layer * (this.wireId-1) + 0.5*thster * (Math.pow(-1, this.superLayerId-1)));
double wy = -R_layer * Math.cos(alphaW_layer * (this.wireId-1) + 0.5*thster * (Math.pow(-1, this.superLayerId-1)));

public void setWirePosition(AlertDCDetector factory) {

//System.out.println(" superlayer " + this.superLayerId + " layer " + this.layerId + " wire " + this.wireId + " R_layer " + R_layer + " wx " + wx + " wy " + wy);

this.nbOfWires = (int) numWires;
this.phi = Math.atan2(wy, wx);
this.radius = R_layer;
this.x = wx;
this.y = wy;
wireLine = factory.getSector(1).getSuperlayer(superLayerId).getLayer(layerId).getComponent(wireId).getLine();
Point3D end = wireLine.end();
this.nbOfWires = factory.getSector(1).getSuperlayer(superLayerId).getLayer(layerId).getNumComponents();
this.phi = end.vectorFrom(0, 0, 0).phi();
this.radius = end.distance(0, 0, end.z());
this.x = end.x();
this.y = end.y();
}

@Override
Expand All @@ -99,7 +69,7 @@ public int compareTo(Hit arg0) {
public int getId() {
return id;
}

public int getSuperLayerId() {
return superLayerId;
}
Expand All @@ -116,7 +86,11 @@ public double getDoca() {
return doca;
}

public double getRadius() {
public Line3D getLine() {
return wireLine;
}

public double getRadius() {
return radius;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class HitReader {
private ArrayList<Hit> _AHDCHits;
private ArrayList<TrueHit> _TrueAHDCHits;

public HitReader(DataEvent event, boolean simulation) {
public HitReader(DataEvent event, boolean simulation) {
fetch_AHDCHits(event);
if (simulation) fetch_TrueAHDCHits(event);
}
Expand Down
Loading