Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read new /geometry/shifts/solenoid and /geometry/shifts/target CCDB tables to set target and solenoid positions independently #213

Merged
merged 2 commits into from
Mar 8, 2024
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 @@ -226,8 +226,8 @@ private void init(String variation, double torusScale, double solenoidScale, lon
this.variation = variation;
ConstantProvider providerDC = GeometryFactory.getConstants(DetectorType.DC, run, variation);
dcDetector = new DCGeant4Factory(providerDC, true, true);
ConstantProvider providerTG = GeometryFactory.getConstants(DetectorType.TARGET, run, variation);
solShift = providerTG.getDouble("/geometry/target/position",0);
ConstantProvider providerMAGNETS = GeometryFactory.getConstants(DetectorType.MAGNETS, run, variation);
solShift = providerMAGNETS.getDouble("/geometry/shifts/solenoid/z",0);
ConstantProvider providerFTOF = GeometryFactory.getConstants(DetectorType.FTOF, run, variation);
ftofDetector = new FTOFGeant4Factory(providerFTOF);
ecalDetector = GeometryFactory.getDetector(DetectorType.ECAL, run, variation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum DetectorType {
RASTER (22, "RASTER"),
URWELL (23, "URWELL"),
TARGET (100, "TARGET"),
MAGNETS (101, "MAGNETS"),
ECIN (110, "ECIN"),
ECOUT (111, "ECOUT"),
ECTOT (112, "ECTOT"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static ConstantProvider getConstants(DetectorType type, int run, String v
if(type==DetectorType.CTOF){
provider.loadTable("/geometry/ctof/ctof");
provider.loadTable("/geometry/ctof/cad");
provider.loadTable("/geometry/target");
provider.loadTable("/geometry/shifts/solenoid");
}

if(type==DetectorType.FTCAL){
Expand All @@ -103,14 +103,17 @@ public static ConstantProvider getConstants(DetectorType type, int run, String v
provider.loadTable("/geometry/cvt/svt/material/box");
provider.loadTable("/geometry/cvt/svt/material/tube");
provider.loadTable("/geometry/cvt/svt/alignment");
provider.loadTable("/geometry/target");
}

if(type==DetectorType.TARGET){
provider.loadTable("/geometry/target");
provider.loadTable("/geometry/shifts/target");
provider.loadTable("/geometry/materials/target");
}

if(type==DetectorType.MAGNETS){
provider.loadTable("/geometry/shifts/solenoid");
}

if(type==DetectorType.FMT){
provider.loadTable("/geometry/fmt/fmt_global");
provider.loadTable("/geometry/fmt/fmt_layer_noshim");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public final class CTOFGeant4Factory extends Geant4Factory {
private final int npaddles = 48;
private final String ctofdbpath = "/geometry/ctof/ctof/";
private final String caddbpath = "/geometry/ctof/cad/";
private final String tgdbpath = "/geometry/target/";
private final String tgdbpath = "/geometry/shifts/solenoid/";
private double globalOffset = 0;

public CTOFGeant4Factory(ConstantProvider cp) {

this.globalOffset = cp.getDouble(tgdbpath+"position", 0);
this.globalOffset = cp.getDouble(tgdbpath+"z", 0);
double cadRadius = cp.getDouble(caddbpath+"radius", 0);
double cadThick = cp.getDouble(caddbpath+"thickness", 0);
double cadAngle = cp.getDouble(caddbpath+"angle", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ public static DatabaseConstantProvider connect( DatabaseConstantProvider cp )
cp.loadTable( ccdbPath +"material/peeksupport");
cp.loadTable( ccdbPath +"layeralignment");
cp.loadTable( ccdbPath +"position");
//shift by target
// cp.loadTable("/geometry/target");

//if( loadAlignmentTables ) cp.loadTable( ccdbPath +"alignment/sector"); // possible future tables
//if( loadAlignmentTables ) cp.loadTable( ccdbPath +"alignment/layer");
Expand Down Expand Up @@ -389,7 +387,7 @@ else if( value == "tube" ) // offset by boxNum to reset row for CCDB table
// | | radius | radius
// | | |
// o==============v===========================v===================================-> z (beamline)
// System.out.println("SVT READ Z SHIFT VALUE "+cp.getDouble("/geometry/target/position", 0));

// LAYERRADIUS and ZSTARTACTIVE are used primarily by the Reconstruction and getStrip()
for( int region = 0; region < NREGIONS; region++ )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public boolean initializeMagneticFields() {
}

private void loadTables() {
String[] ccdbTables = new String[] { "/geometry/target" };
String[] ccdbTables = new String[] { "/geometry/shifts/solenoid" };

requireConstants(Arrays.asList(ccdbTables));
this.getConstantsManager().setVariation("default");
Expand All @@ -173,8 +173,8 @@ public boolean processDataEvent(DataEvent event) {
if (solShift == null) { // if no shift is set in the yaml file or environment, read from CCDB
// will read target position and assume that is representative of the shift of
// the whole CD
IndexedTable targetPosition = this.getConstantsManager().getConstants(newRun, "/geometry/target");
Swimmer.set_zShift((float) targetPosition.getDoubleValue("position", 0, 0, 0));
IndexedTable targetPosition = this.getConstantsManager().getConstants(newRun, "/geometry/shifts/solenoid");
Swimmer.set_zShift((float) targetPosition.getDoubleValue("z", 0, 0, 0));
}

Swimmer.setMagneticFieldsScales(bank.getFloat("solenoid", 0), bank.getFloat("torus", 0), (double) 0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public class CalibrationConstantsLoader {
"/calibration/cnd/Energy",
"/calibration/cnd/time_jitter",
"/geometry/cnd/cndgeom",
"/geometry/target", "/calibration/cnd/cluster",
"/calibration/cnd/double_hits"
"/geometry/shifts/solenoid",
"/calibration/cnd/cluster",
"/calibration/cnd/double_hits"
};

public CalibrationConstantsLoader(int run, ConstantsManager ccdb) {
Expand Down Expand Up @@ -129,7 +130,7 @@ public final void Load(int run, ConstantsManager ccdb) {
INNERRADIUS[0] = 10.*tabJs.get(10).getDoubleValue("InnerRadius", 1, 1, 1);
THICKNESS[0] = 10.*tabJs.get(10).getDoubleValue("Thickness", 1, 1, 1); // not right structure for common tools

ZTARGET[0] = tabJs.get(11).getDoubleValue("position", 0, 0, 0); // not right structure for common tools
ZTARGET[0] = tabJs.get(11).getDoubleValue("z", 0, 0, 0); // not right structure for common tools
//INNERRADIUS[0] = 290.0;
//THICKNESS[0] = 30.0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ private synchronized void load(String variation, int run, IndexedTable svtLorent
private void initTarget(ConstantProvider provider) {
// get target position and half-length from old table
// half-length used for track candidates vertex cut
this.targetPosition = provider.getDouble("/geometry/target/position",0)*10;
this.targetHalfLength = provider.getDouble("/geometry/target/length",0)*10;
this.targetPosition = provider.getDouble("/geometry/shifts/target/z",0)*10;
this.targetHalfLength = provider.getDouble("/geometry/materials/target/length",0)*10/2;
// load target geometry and material, using CCDB table if targetMat yaml
// variable is not specified or differs from LH2/LD2
if("LH2".equals(Constants.getInstance().getTargetType()) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ private Surface getTarget(double xbeam, double ybeam, boolean beamSpot) {
Point3D p = new Point3D(xbeam, ybeam, 0);
Line3D l = new Line3D(p, u);
Surface target = new Surface(l.origin(), l.end(), Constants.DEFAULTSWIMACC);
if(Geometry.getInstance().getTargetCellSurface().lineVolume!=null) {
if(Geometry.getInstance().getTargetCellSurface()!=null &&
Geometry.getInstance().getTargetCellSurface().lineVolume!=null) {
target.lineVolume = Geometry.getInstance().getTargetCellSurface().lineVolume;
}
for(Material m : Geometry.getInstance().getTargetMaterials())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ private synchronized void LoadGeometry(String geoVariation, double[][] shifts) {
}
// Load target
ConstantProvider providerTG = GeometryFactory.getConstants(DetectorType.TARGET, 11, geoVariation);
double targetPosition = providerTG.getDouble("/geometry/target/position",0);
double targetLength = providerTG.getDouble("/geometry/target/length",0);
double targetPosition = providerTG.getDouble("/geometry/shifts/target/z",0);
double targetLength = providerTG.getDouble("/geometry/materials/target/length",0);
// Load other geometries
ConstantProvider providerFTOF = GeometryFactory.getConstants(DetectorType.FTOF, 11, geoVariation);
ftofDetector = new FTOFGeant4Factory(providerFTOF);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class EBCCDBConstants {
"/runcontrol/fcup",
"/runcontrol/hwp",
"/runcontrol/helicity",
"/geometry/target",
"/geometry/shifts/solenoid",
"/calibration/ftof/tres",
//"/calibration/ctof/tres"
};
Expand Down Expand Up @@ -275,7 +275,7 @@ public final void load(int run,ConstantsManager manager) {

loadDouble(EBCCDBEnum.NEUTRON_maxBeta,"neutron_beta","neutron_beta",0,0,0);

loadDouble(EBCCDBEnum.TARGET_POSITION,"/geometry/target","position",0,0,0);
loadDouble(EBCCDBEnum.SOLENOID_POSITION,"/geometry/shifts/solenoid","z",0,0,0);

loadDouble(EBCCDBEnum.FCUP_slope,"/runcontrol/fcup","slope",0,0,0);
loadDouble(EBCCDBEnum.FCUP_offset,"/runcontrol/fcup","offset",0,0,0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum EBCCDBEnum {
FTOF_MATCHING_1B,
FTOF_MATCHING_2,
CTOF_Matching,
TARGET_POSITION,
SOLENOID_POSITION,
RF_BUCKET_LENGTH,
RF_OFFSET,
RF_CYCLES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ public double getStartTime(DetectorParticle trigger,final DetectorType type,fin

final double rfPeriod = this.ccdb.getDouble(EBCCDBEnum.RF_BUCKET_LENGTH);

// The RF calibration is relative to target center:
final double zTarget = this.ccdb.getDouble(EBCCDBEnum.TARGET_POSITION);
// The RF calibration is relative to the solenoid center:
// FIXME the reference point doesn't have to be the solenoid center or
// target center but could be z=0. It only needs to be consistent with
// the one used in RF calibrations
final double zSolenoid = this.ccdb.getDouble(EBCCDBEnum.SOLENOID_POSITION);

// The trigger particles' vertex info:
final double tVertex = trigger.getVertexTime(type,layer,trigger.getPid());
final double dzTargetVertex = zTarget - trigger.vertex().z();
final double dzTargetVertex = zSolenoid - trigger.vertex().z();

// The RF time at the trigger particle's vertex:
// (Note, this is shifted forward by a large integer number of RF periods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public boolean init() {
"/calibration/ft/ftcal/cluster",
"/calibration/ft/ftcal/thetacorr",
"/calibration/ft/ftcal/phicorr",
"/geometry/target"
"/geometry/shifts/solenoid"
};
requireConstants(Arrays.asList(tables));
this.getConstantsManager().setVariation("default");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ public void correctDirection(List<FTParticle> particles, ConstantsManager manage
}

public List<FTParticle> initFTparticles(List<FTResponse> responses, ConstantsManager manager, int run) {
IndexedTable target = manager.getConstants(run, "/geometry/target");
IndexedTable solenoid = manager.getConstants(run, "/geometry/shifts/solenoid");

List<FTParticle> particles = new ArrayList<>();
for (int i = 0; i < responses.size(); i++) {
if (responses.get(i).getType()==DetectorType.FTCAL) {
// start assuming the cluster to be associated to a photon
FTParticle track = new FTParticle(i, 0, this.solenoidField, responses.get(i), 0, 0, target.getDoubleValue("position", 0,0,0));
FTParticle track = new FTParticle(i, 0, this.solenoidField, responses.get(i), 0, 0, solenoid.getDoubleValue("z", 0,0,0));
particles.add(track);
responses.get(i).setAssociation(particles.size()-1);
}
Expand Down