Skip to content
Draft
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 @@ -7,6 +7,8 @@

import org.jlab.geom.DetectorId;
import org.jlab.geom.abs.AbstractDetector;
import org.jlab.geom.prim.Line3D;
import org.jlab.geom.prim.Point3D;

/**
* @author sergeyeva
Expand All @@ -26,4 +28,32 @@ public String getType() {
return "ALERT DC Detector";
}

public void print() {
System.out.println("/////////////////////////");
System.out.println("AHDC geometry");
System.out.println("");
System.out.println("s : sector");
System.out.println("sl : super layer");
System.out.println("l : layer");
System.out.println("c : component");
System.out.println("/////////////////////////");
System.out.println("------------------------------------------------------------------------------");
System.out.println(" | origin | end");
System.out.println("------------------------------------------------------------------------------");
System.out.println("s sl l c | x y z | x y z");
System.out.println("------------------------------------------------------------------------------");
for (int s = 1; s <= getNumSectors(); s++) {
for (int sl = 1; sl <= getSector(s).getNumSuperlayers(); sl++) {
for (int l = 1; l <= getSector(s).getSuperlayer(sl).getNumLayers(); l++) {
for (int c = 1; c <= getSector(s).getSuperlayer(sl).getLayer(l).getNumComponents(); c++) {
Line3D line = getSector(s).getSuperlayer(sl).getLayer(l).getComponent(c).getLine();
Point3D end = line.end();
Point3D origin = line.origin();
System.out.printf("%2d %2d %2d %2d | %7.3f %7.3f %7.3f | %7.3f %7.3f %7.3f\n", s, sl, l, c, origin.x(), origin.y(), origin.z(), end.x(), end.y(), end.z());
}
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,35 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye
Point3D p_9 = new Point3D(px_9, py_9, z_end);
Point3D p_10 = new Point3D(px_10, py_10, z_end);
Point3D p_11 = new Point3D(px_11, py_11, z_end);

// !!! Alignment correction
int layer_row = AlertDCWireIdentifier.layer2number((superlayerId+1)*10 + (layerId+1));
double upstream_rotZ = Math.toRadians(cp.getDouble("/geometry/alert/ahdc/layer_alignment/upstream_rotZ", layer_row));
double downstream_rotZ = Math.toRadians(cp.getDouble("/geometry/alert/ahdc/layer_alignment/downstream_rotZ", layer_row));
int wire_row = AlertDCWireIdentifier.slc2wire(sectorId+1, (superlayerId+1)*10 + (layerId+1), wireId+1);
double wire_rotZ = Math.toRadians(cp.getDouble("/geometry/alert/ahdc/wire_alignment/rotZ", wire_row));

//System.out.printf("%d %d %d, %f , %f, %f\n",sectorId+1, (superlayerId+1)*10 + (layerId+1), wireId+1, Math.toDegrees(upstream_rotZ), Math.toDegrees(downstream_rotZ), Math.toDegrees(wire_rotZ));

p_0.rotateZ(wire_rotZ + upstream_rotZ);
p_1.rotateZ(wire_rotZ + upstream_rotZ);
p_2.rotateZ(wire_rotZ + upstream_rotZ);
p_3.rotateZ(wire_rotZ + upstream_rotZ);
p_4.rotateZ(wire_rotZ + upstream_rotZ);
p_5.rotateZ(wire_rotZ + upstream_rotZ);

p_6.rotateZ(wire_rotZ + downstream_rotZ);
p_7.rotateZ(wire_rotZ + downstream_rotZ);
p_8.rotateZ(wire_rotZ + downstream_rotZ);
p_9.rotateZ(wire_rotZ + downstream_rotZ);
p_10.rotateZ(wire_rotZ + downstream_rotZ);
p_11.rotateZ(wire_rotZ + downstream_rotZ);

lPoint.rotateZ(upstream_rotZ);
rPoint.rotateZ(downstream_rotZ);
wireLine = new Line3D(lPoint, rPoint);


// defining a cell around a wireLine, must be counter-clockwise!
firstF.add(p_0);
firstF.add(p_5);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
package org.jlab.geom.detector.alert.AHDC;

public class AlertDCWireIdentifier {
/** Number between 0 and 575 */
private int num;

/** Always 1 */
private int sector;

/** Can be 11, 21, 22, 31, 32, 41, 42, 51 */
private int layer;

/** component id on a given layer, numerotation starting at 1 */
private int component;

/**
* Ahdc wire id defined with a num ranging from 0 to 575
* @param _num
*/
public AlertDCWireIdentifier(int _num) {
num = _num;
int[] res = wire2slc(_num);
sector = res[0];
layer = res[1];
component = res[2];
}

/**
* Ahdc wire id defined with sector, layer, component identifiers
* @param _sector
* @param _layer can be 11, 21, 22, 31, 32, 41, 51
* @param _component
*/
public AlertDCWireIdentifier(int _sector, int _layer, int _component) {
sector = _sector;
layer = _layer;
component = _layer;
num = slc2wire(_sector, _layer, _component);
}

public int getNumber() { return num;}

public int getSectorId() {return sector;}

public int getLayerId() {return layer;}

public int getComponentId() {return component;}

/**
* Convert wire number (number from 0 to 575) to (sector,layer,component) ids
*
* This is the invert operation of {@link #slc2wire(int, int, int)}
*
* @param wire wire number between 0 and 575
* @return a triplet (sector, layer, component) in int[]
*/
public static int[] wire2slc(int wire) {
int layer = -1;
int component = -1;
if (wire < 47) {
layer = 11;
component = wire + 1;
}
else if ((47 <= wire) && (wire < 47 + 56)) {
layer = 21;
component = wire - 47 + 1;
}
else if ((47 + 56 <= wire) && (wire < 47 + 56 + 56)) {
layer = 22;
component = wire - 47 - 56 + 1;
}
else if ((47 + 56 + 56 <= wire) && (wire < 47 + 56 + 56 + 72)) {
layer = 31;
component = wire - 47 - 56 - 56 + 1;
}
else if ((47 + 56 + 56 + 72 <= wire) && (wire < 47 + 56 + 56 + 72 + 72)) {
layer = 32;
component = wire - 47 - 56 - 56 - 72 + 1;
}
else if ((47 + 56 + 56 + 72 + 72 <= wire) && (wire < 47 + 56 + 56 + 72 + 72 + 87)) {
layer = 41;
component = wire - 47 - 56 - 56 - 72 - 72 + 1;
}
else if ((47 + 56 + 56 + 72 + 72 + 87 <= wire) && (wire < 47 + 56 + 56 + 72 + 72 + 87 + 87)) {
layer = 42;
component = wire - 47 - 56 - 56 - 72 - 72 - 87 + 1;
}
else { // ((47 + 56 + 56 + 72 + 72 + 87 + 87 <= wire) && (wire < 47 + 56 + 56 + 72 + 72 + 87 + 87 + 99)) {
layer = 51;
component = wire - 47 - 56 - 56 - 72 - 72 - 87 - 87 + 1;
}
return new int[] {1, layer, component};
}

/**
* Convert (sector, layer, component) to a unique wire id (number betwwen 0 and 575)
*
* @param sector (not used)
* @param layer
* @param component
* @return unique wire id
*/
public static int slc2wire(int sector, int layer, int component) {
if (layer == 11) {
return component - 1;
}
else if (layer == 21) {
return 47 + component - 1;
}
else if (layer == 22) {
return 47 + 56 + component - 1;
}
else if (layer == 31) {
return 47 + 56 + 56 + component - 1;
}
else if (layer == 32) {
return 47 + 56 + 56 + 72 + component - 1;
}
else if (layer == 41) {
return 47 + 56 + 56 + 72 + 72 + component - 1;
}
else if (layer == 42) {
return 47 + 56 + 56 + 72 + 72 + 87 + component - 1;
}
else if (layer == 51) {
return 47 + 56 + 56 + 72 + 72 + 87 + 87 + component - 1;
} else {
return -1; // not a ahdc wire
}
}

/**
* Convert the layer digits (11,21,...,51) to layer number between 0 and 7
*
* @param digit
* @return layer number
*/
public static int layer2number(int digit) {
if (digit == 11) {
return 0;
}
else if (digit == 21) {
return 1;
}
else if (digit == 22) {
return 2;
}
else if (digit == 31) {
return 3;
}
else if (digit == 32) {
return 4;
}
else if (digit == 41) {
return 5;
}
else if (digit == 42) {
return 6;
}
else if (digit == 51) {
return 7;
} else {
return -1;
}
}

/**
* Convert layer number (from 0 to 7) to the superlayer-layer id (11,21,...,51)
*
* @param digit between 1 and 8
* @return layer number between (11,21,...,51)
*/
public static int number2layer(int num) {
if (num == 0) {
return 11;
}
else if (num == 1) {
return 21;
}
else if (num == 2) {
return 22;
}
else if (num == 3) {
return 31;
}
else if (num == 4) {
return 32;
}
else if (num == 5) {
return 41;
}
else if (num == 6) {
return 42;
}
else if (num == 7) {
return 51;
} else {
return -1;
}
}

/**
*
* @param _layer (number 11, 21, 22, ..., 51)
* @return the radius of the _layer
*/
public static double layer2Radius(int _layer) {
if (_layer == 11) {
return 32.0;
}
else if (_layer == 21) {
return 38.0;
}
else if (_layer == 22) {
return 42.0;
}
else if (_layer == 31) {
return 48.0;
}
else if (_layer == 32) {
return 52.0;
}
else if (_layer == 41) {
return 58.0;
}
else if (_layer == 42) {
return 62.0;
}
else if (_layer == 51) {
return 68.0;
} else {
return 0.0;
}
}

/**
*
* @param _layer_num between 1 and 8
* @return the radius of the _layer. See {@link #layer2Radius(int)}
*/
public static double layerNum2Radius(int _layer_num) {
return layer2Radius(number2layer(_layer_num));
}
}
Loading