Skip to content
Closed
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
@@ -0,0 +1,42 @@
package org.jlab.clas.swimtools;

import cnuphys.swim.SwimTrajectory;
import org.jlab.geom.prim.Line3D;
import org.jlab.geom.prim.Point3D;
import org.jlab.geom.prim.Vector3D;

interface ISwim {

public double[] SwimToPlaneTiltSecSys(int sector, double z_cm);

public double[] SwimToPlaneTiltSecSysBdlXZPlane(int sector, double z_cm);

public double[] SwimToPlaneLab(double z_cm);

public double[] SwimToCylinder(double Rad);

public double[] SwimRho(double radius, double accuracy);

public double[] SwimGenCylinder(Point3D axisPoint1, Point3D axisPoint2, double radius, double accuracy);

public double[] SwimPlane(Vector3D n, Point3D p, double accuracy);

public double[] SwimToSphere(double Rad);

public double[] SwimToPlaneBoundary(double d_cm, Vector3D n, int dir);

public double[] SwimToBeamLine(double xB, double yB);

public double[] SwimToLine(Line3D l);

public double[] AdaptiveSwimPlane(double px, double py, double pz, double nx, double ny, double nz, double accuracy);

public double[] AdaptiveSwimCylinder(double a1x, double a1y, double a1z, double a2x, double a2y, double a2z, double radius, double accuracy);

public double[] AdaptiveSwimRho(double radius, double accuracy);

public double[] SwimToZ(double Z, int dir);

public double[] SwimToDCA(SwimTrajectory trk2);

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.jlab.clas.swimtools;

import cnuphys.magfield.MagneticFieldInitializationException;
import cnuphys.magfield.MagneticFields;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -14,16 +15,14 @@

public class MagFieldsEngine extends ReconstructionEngine {

public static Logger LOGGER = Logger.getLogger(MagFieldsEngine.class.getName());
public static final Logger LOGGER = Logger.getLogger(MagFieldsEngine.class.getName());

private String solShift = null;

public MagFieldsEngine() {
super("MagFields", "ziegler", "1.0");
}

AtomicInteger Run = new AtomicInteger(0);

/**
* Choose one of YAML or ENV values.
*
Expand Down Expand Up @@ -57,97 +56,87 @@ public boolean initializeMagneticFields() {
final String mapDir = CLASResources.getResourcePath("etc")+"/data/magfield";

if (torusMap==null) {
LOGGER.log(Level.SEVERE,"["+this.getName()+"] ERROR: torus field is undefined.");
LOGGER.log(Level.SEVERE, "[{0}] ERROR: torus field is undefined.", this.getName());
return false;
}
if (solenoidMap==null) {
LOGGER.log(Level.SEVERE,"["+this.getName()+"] ERROR: solenoid is undefined.");
LOGGER.log(Level.SEVERE, "[{0}] ERROR: solenoid is undefined.", this.getName());
return false;
}

try {
MagneticFields.getInstance().initializeMagneticFields(mapDir, torusMap, solenoidMap);
}
catch (Exception e) {
e.printStackTrace();
catch (MagneticFieldInitializationException | FileNotFoundException e) {
LOGGER.log(Level.SEVERE,"Magfields error",e);
return false;
}

// Field Shifts
solShift = this.getEngineConfigString("magfieldSolenoidShift");

if (solShift != null) {
LOGGER.log(Level.INFO, "[" + this.getName()
+ "] run with solenoid z shift in tracking config chosen based on yaml = " + solShift + " cm");
Swimmer.set_zShift(Float.valueOf(solShift));
LOGGER.log(Level.INFO, "[{0}] run with solenoid z shift in tracking config chosen based on yaml = {1} cm", new Object[]{this.getName(), solShift});
Swimmer.set_zShift(Float.parseFloat(solShift));
} else {
solShift = System.getenv("COAT_MAGFIELD_SOLENOIDSHIFT");
if (solShift != null) {
LOGGER.log(Level.INFO, "[" + this.getName()
+ "] run with solenoid z shift in tracking config chosen based on env = " + solShift + " cm");
Swimmer.set_zShift(Float.valueOf(solShift));
LOGGER.log(Level.INFO, "[{0}] run with solenoid z shift in tracking config chosen based on env = {1} cm", new Object[]{this.getName(), solShift});
Swimmer.set_zShift(Float.parseFloat(solShift));
}
}
if (solShift == null) {
LOGGER.log(Level.INFO, "[" + this.getName() + "] run with solenoid z shift based on CCDB CD position");
LOGGER.log(Level.INFO, "[{0}] run with solenoid z shift based on CCDB CD position", this.getName());
// this.solenoidShift = (float) 0;
}
// torus:
String TorX = this.getEngineConfigString("magfieldTorusXShift");

if (TorX != null) {
LOGGER.log(Level.INFO, "[" + this.getName()
+ "] run with torus x shift in tracking config chosen based on yaml = " + TorX + " cm");
Swimmer.setTorXShift(Float.valueOf(TorX));
LOGGER.log(Level.INFO, "[{0}] run with torus x shift in tracking config chosen based on yaml = {1} cm", new Object[]{this.getName(), TorX});
Swimmer.setTorXShift(Float.parseFloat(TorX));
} else {
TorX = System.getenv("COAT_MAGFIELD_TORUSXSHIFT");
if (TorX != null) {
LOGGER.log(Level.INFO, "[" + this.getName()
+ "] run with torus x shift in tracking config chosen based on env = " + TorX + " cm");
Swimmer.setTorXShift(Float.valueOf(TorX));
LOGGER.log(Level.INFO, "[{0}] run with torus x shift in tracking config chosen based on env = {1} cm", new Object[]{this.getName(), TorX});
Swimmer.setTorXShift(Float.parseFloat(TorX));
}
}
if (TorX == null) {
LOGGER.log(Level.INFO, "[" + this.getName() + "] run with torus x shift in tracking set to 0 cm");
LOGGER.log(Level.INFO, "[{0}] run with torus x shift in tracking set to 0 cm", this.getName());
// this.solenoidShift = (float) 0;
}

String TorY = this.getEngineConfigString("magfieldTorusYShift");

if (TorY != null) {
LOGGER.log(Level.INFO, "[" + this.getName()
+ "] run with torus y shift in tracking config chosen based on yaml = " + TorY + " cm");
Swimmer.setTorYShift(Float.valueOf(TorY));
LOGGER.log(Level.INFO, "[{0}] run with torus y shift in tracking config chosen based on yaml = {1} cm", new Object[]{this.getName(), TorY});
Swimmer.setTorYShift(Float.parseFloat(TorY));
} else {
TorY = System.getenv("COAT_MAGFIELD_TORUSYSHIFT");
if (TorY != null) {
LOGGER.log(Level.INFO, "[" + this.getName()
+ "] run with torus y shift in tracking config chosen based on env = " + TorY + " cm");
Swimmer.setTorYShift(Float.valueOf(TorY));
LOGGER.log(Level.INFO, "[{0}] run with torus y shift in tracking config chosen based on env = {1} cm", new Object[]{this.getName(), TorY});
Swimmer.setTorYShift(Float.parseFloat(TorY));
}
}
if (TorY == null) {
LOGGER.log(Level.INFO, "[" + this.getName() + "] run with torus y shift in tracking set to 0 cm");
// this.solenoidShift = (float) 0;
LOGGER.log(Level.INFO, "[{0}] run with torus y shift in tracking set to 0 cm", this.getName());
}

String TorZ = this.getEngineConfigString("magfieldTorusZShift");

if (TorZ != null) {
LOGGER.log(Level.INFO, "[" + this.getName()
+ "] run with torus z shift in tracking config chosen based on yaml = " + TorZ + " cm");
Swimmer.setTorZShift(Float.valueOf(TorZ));
LOGGER.log(Level.INFO, "[{0}] run with torus z shift in tracking config chosen based on yaml = {1} cm", new Object[]{this.getName(), TorZ});
Swimmer.setTorZShift(Float.parseFloat(TorZ));
} else {
TorZ = System.getenv("COAT_MAGFIELD_TORUSZSHIFT");
if (TorZ != null) {
LOGGER.log(Level.INFO, "[" + this.getName()
+ "] run with torus z shift in tracking config chosen based on env = " + TorZ + " cm");
Swimmer.setTorZShift(Float.valueOf(TorZ));
LOGGER.log(Level.INFO, "[{0}] run with torus z shift in tracking config chosen based on env = {1} cm", new Object[]{this.getName(), TorZ});
Swimmer.setTorZShift(Float.parseFloat(TorZ));
}
}
if (TorZ == null) {
LOGGER.log(Level.INFO, "[" + this.getName() + "] run with torus z shift in tracking set to 0 cm");
// this.solenoidShift = (float) 0;
LOGGER.log(Level.INFO, "[{0}] run with torus z shift in tracking set to 0 cm", this.getName());
}

return true;
Expand All @@ -170,9 +159,10 @@ public boolean processDataEvent(DataEvent event) {
if (newRun == 0)
return true;

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
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/shifts/solenoid");
Swimmer.set_zShift((float) targetPosition.getDoubleValue("z", 0, 0, 0));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jlab.clas.swimtools;

import cnuphys.magfield.CompositeProbe;
Expand Down
Loading