Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class SVTConstants {

// data for alignment shifts
// private static String filenameSectorShiftData = null;
private static double[] GLOBALSHIFTDATA = null;
private static double[][][] LAYERSHIFTDATA = null;

//private static double[][] LAYERSHIFTDATA = null;
Expand Down Expand Up @@ -429,7 +430,8 @@ else if( value == "tube" ) // offset by boxNum to reset row for CCDB table
double xpos = cp.getDouble(ccdbPath+"position/x", 0 );
double ypos = cp.getDouble(ccdbPath+"position/y", 0 );
double zpos = cp.getDouble(ccdbPath+"position/z", 0 );

GLOBALSHIFTDATA = new double[]{xpos, ypos, zpos, 0, 0, 1, 0};

// double[] myShift = {0, 0, 0, -Math.toRadians(0), 0, 0, 0};
LAYERSHIFTDATA = new double[NSECTORS[3]][NLAYERS-2][];
for( int i = 0; i < (NTOTALSECTORS-NSECTORS[3])*2; i++ ) // layeralignment tables doesn't cover region 4
Expand Down Expand Up @@ -834,5 +836,14 @@ public static double[][][] getLayerSectorAlignmentData() {
return LAYERSHIFTDATA;
}

/**
* Returns the layer/sector alignment data
* @return
*/
public static double[] getGlobalAlignmentData() {
if(GLOBALSHIFTDATA == null ) { System.err.println("error: SVTConstants.getGlobalAlignmentData: GLOBALSHIFTDATA requested is null"); }
return GLOBALSHIFTDATA;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void makeVolumes()
if( BUILDSENSORS ) System.out.println(" include sensor active and dead zones ? "+ BUILDSENSORZONES );
//System.out.println(" halve dimensions of boxes ? "+ HALFBOXES );

this.makeCage();
this.makeCage();

for( int region = regionMin-1; region < regionMax; region++ ) // NREGIONS
{
Expand Down Expand Up @@ -278,6 +278,7 @@ public void makeVolumes()
}*/

// FIXME currently using shifts from bottom module of each region
// FIXME global shift should be applied to mother volume
AlignmentFactory.applyShift( sectorVol, SVTConstants.getLayerSectorAlignmentData()[sector][region*2], fidTri3D.center(), scaleT, scaleR );
//System.out.println("S "+sectorVol.gemcString() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private BMTConstants() {
public static Line3D[][] AXES = new Line3D[NLAYERS][NSECTORS]; // detector AXES
public static Transformation3D[][] TOLOCAL = new Transformation3D[NLAYERS][NSECTORS];
public static Transformation3D[][] TOGLOBAL = new Transformation3D[NLAYERS][NSECTORS];
public static Transformation3D TOPOSITION = null;
public static double[] ThetaL_grid = new double[405]; //Lorentz angle grid
public static double[] E_grid = new double[405]; //Electric field value of the grid
public static double[] B_grid = new double[405]; //Magnetic field value of the grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ public Surface getInnerTube() {
Vector3D axis = new Vector3D(0,0,1);
Arc3D base = new Arc3D(origin, center, axis, 2*Math.PI);
Cylindrical3D tube = new Cylindrical3D(base, 2*INNERTUBEDIM[2]);
BMTConstants.TOPOSITION.apply(tube);
Surface surface = new Surface(tube, new Strip(0,0,0), Constants.DEFAULTSWIMACC);
surface.addMaterial("CarbonFiber", INNERTUBEDIM[1]-INNERTUBEDIM[0],
TUBEMAT[0], TUBEMAT[1], TUBEMAT[2], TUBEMAT[3], Units.MM);
Expand All @@ -967,6 +968,7 @@ public Surface getOuterTube() {
Vector3D axis = new Vector3D(0,0,1);
Arc3D base = new Arc3D(origin, center, axis, 2*Math.PI);
Cylindrical3D tube = new Cylindrical3D(base, 2*OUTERTUBEDIM[2]);
BMTConstants.TOPOSITION.apply(tube);
Surface surface = new Surface(tube, new Strip(0,0,0), Constants.DEFAULTSWIMACC);
surface.addMaterial("CarbonFiber", OUTERTUBEDIM[1]-OUTERTUBEDIM[0],
TUBEMAT[0], TUBEMAT[1], TUBEMAT[2], TUBEMAT[3], Units.MM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ public static final synchronized void Load(DatabaseConstantProvider dbprovider)
gemcCenter.rotateY(Math.toRadians(gemcRot.y()));
gemcCenter.rotateX(Math.toRadians(gemcRot.x()));
gemcShift.translateXYZ(-gemcCenter.x(), -gemcCenter.y(), -gemcCenter.z());
BMTConstants.TOPOSITION = new Transformation3D();
BMTConstants.TOPOSITION.translateXYZ(xpos+gemcShift.x(), ypos+gemcShift.y(), zpos+gemcShift.z());
for (int row = 0; row<NLAYERS*NSECTORS; row++) {
int sector = dbprovider.getInteger("/geometry/cvt/mvt/alignment/sector", row);
int layer = dbprovider.getInteger("/geometry/cvt/mvt/alignment/layer", row);
Point3D shift = new Point3D(dbprovider.getDouble("/geometry/cvt/mvt/alignment/deltaX", row),
dbprovider.getDouble("/geometry/cvt/mvt/alignment/deltaY", row),
dbprovider.getDouble("/geometry/cvt/mvt/alignment/deltaZ", row));
shift.translateXYZ(xpos+gemcShift.x(), ypos+gemcShift.y(), zpos+gemcShift.z());
BMTConstants.TOPOSITION.apply(shift);
Vector3D rot = new Vector3D(dbprovider.getDouble("/geometry/cvt/mvt/alignment/rotX", row)+Math.toRadians(gemcRot.x()),
dbprovider.getDouble("/geometry/cvt/mvt/alignment/rotY", row)+Math.toRadians(gemcRot.y()),
dbprovider.getDouble("/geometry/cvt/mvt/alignment/rotZ", row)+Math.toRadians(gemcRot.z()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@ public static double[] getBeamSpot(DataEvent event, IndexedTable beamPos) {
double[] xyBeam = new double[2];
xyBeam[0] = beamPos.getDoubleValue("x_offset", 0, 0, 0)*10;
xyBeam[1] = beamPos.getDoubleValue("y_offset", 0, 0, 0)*10;
if(Constants.getInstance().seedingDebugMode)
System.out.println("BEAM SPOT INFO. (xB, yB) = ("+xyBeam[0]+", "+xyBeam[1]+") mm");
if(event.hasBank("RASTER::position")){
DataBank raster_bank = event.getBank("RASTER::position");
xyBeam[0] += raster_bank.getFloat("x", 0)*10;
xyBeam[1] += raster_bank.getFloat("y", 0)*10;
if(Constants.getInstance().seedingDebugMode)
System.out.println("BEAM SPOT W. RASTER (xB, yB) = ("+xyBeam[0]+", "+xyBeam[1]+") mm");
}
return xyBeam;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,22 +420,22 @@ else if (trkcand.getCrosses().get(c).getType()==BMTType.C) {
}


public List<Seed> reFit(List<Seed> seedlist, Swim swimmer, StraightTrackSeeder trseed) {
public List<Seed> reFit(List<Seed> seedlist, Swim swimmer, StraightTrackSeeder trseed, double xb, double yb) {
List<Seed> filtlist = new ArrayList<>();
if(seedlist==null)
return filtlist;
for (Seed bseed : seedlist) {
if(bseed == null)
continue;
List<Seed> fseeds = this.reFitSeed(bseed, trseed);
List<Seed> fseeds = this.reFitSeed(bseed, trseed, xb, yb);
if(fseeds!=null) {
filtlist.addAll(fseeds);
}
}
return filtlist;
}

public List<Seed> reFitSeed(Seed bseed, StraightTrackSeeder trseed) {
public List<Seed> reFitSeed(Seed bseed, StraightTrackSeeder trseed, double xb, double yb) {

List<Cross> refib = new ArrayList<>();
List<Cross> refi = new ArrayList<>();
Expand All @@ -461,7 +461,7 @@ public List<Seed> reFitSeed(Seed bseed, StraightTrackSeeder trseed) {
}
}
Collections.sort(refi);
List<Seed> seedlist = trseed.findSeed(refi, refib, false);
List<Seed> seedlist = trseed.findSeed(refi, refib, false, xb, yb);
return seedlist;
}

Expand Down Expand Up @@ -497,7 +497,7 @@ public boolean reFitCircle(Seed seed, int iter, double xb, double yb) {
seed.getHelix().setCurvature(pars.rho());
seed.getHelix().setDCA(-pars.doca());
seed.getHelix().setPhiAtDCA(pars.phi());
seed.update_Crosses();
seed.update_Crosses(xb,yb);
}
}
return fitStatus;
Expand Down Expand Up @@ -762,7 +762,8 @@ public double[][] getCovMatInTrackRep(Track trk) {
return tCov;
}

public List<Cross> findCrossesFromClustersOnTrk(List<Cross> allCrosses, List<Cluster> clsOnTrack, Track track) {
public List<Cross> findCrossesFromClustersOnTrk(List<Cross> allCrosses, List<Cluster> clsOnTrack,
Track track, double xb, double yb) {
CrossMaker cm = new CrossMaker();
List<Cross> crosses = new ArrayList<>();
for (Cluster cl1 : clsOnTrack) {//inner layer
Expand Down Expand Up @@ -799,7 +800,9 @@ public List<Cross> findCrossesFromClustersOnTrk(List<Cross> allCrosses, List<Clu
allCrosses.add(this_cross);
}
if (track.getHelix() != null && track.getHelix().getCurvature() != 0) {
double R = this_cross.getPoint().toVector3D().rho();
double Cx = this_cross.getPoint().x()-xb;
double Cy = this_cross.getPoint().y()-yb;
double R = Math.sqrt(Cx * Cx + Cy * Cy);
this_cross.update(track.getHelix().getPointAtRadius(R), track.getHelix().getTrackDirectionAtRadius(R));
this_cross.setAssociatedTrackID(track.getSeed().getClusters().get(0).getAssociatedTrackID());
}
Expand Down Expand Up @@ -886,7 +889,7 @@ Track recovTrkMisClusSearch(Seed seed, org.jlab.clas.tracking.trackrep.Helix hlx
}
//refit adding missing clusters
List<Cluster> clsOnTrack = this.findClustersOnTrk(SVTclusters, seed.getClusters(), fittedTrack, swimmer); //VZ: finds missing clusters; RDV fix 0 error
List<Cross> crsOnTrack = this.findCrossesFromClustersOnTrk(SVTcrosses, clsOnTrack, fittedTrack);
List<Cross> crsOnTrack = this.findCrossesFromClustersOnTrk(SVTcrosses, clsOnTrack, fittedTrack, xb, yb);

if(clsOnTrack.size()>0) {
seed.add_Clusters(clsOnTrack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class TracksFromTargetRec {
private double xb;
private double yb;
public int totTruthHits;

public boolean oldStraightTrackSeeder=false;

public TracksFromTargetRec(Swim swimmer, double[] beamPos) {
this.swimmer = swimmer;
Expand All @@ -75,9 +75,9 @@ public List<Seed> getSeeds(List<ArrayList<Cluster>> clusters, List<ArrayList<Cro
double solenoidValue = Constants.getSolenoidMagnitude(); // already the absolute value
List<Seed> seeds = new ArrayList<>();
// make list of crosses consistent with a track candidate
if(solenoidValue<0.001) {
if(oldStraightTrackSeeder) {
StraightTrackSeeder trseed = new StraightTrackSeeder(xb, yb);
seeds = trseed.findSeed(this.SVTcrosses, this.BMTcrosses, Constants.getInstance().svtOnly);
seeds = trseed.findSeed(this.SVTcrosses, this.BMTcrosses, Constants.getInstance().svtOnly, xb, yb);
// RDV, disabled because it seems to create fake tracks, skipping measurement in KF
// if(Constants.getInstance().EXCLUDELAYERS==true) {
// seeds = recUtil.reFit(seeds, swimmer, trseed); // RDV can we juts refit?
Expand Down Expand Up @@ -223,15 +223,15 @@ public List<Track> getTracks(DataEvent event, boolean initFromMc, boolean kfFilt
if(solenoidValue>0.001 && seed.getHelix().radius() <Constants.getInstance().getRCUT())
continue;
if(Constants.getInstance().seedingDebugMode)
System.out.println("initializing fitter...");
System.out.println("initializing fitter...for "+seed.toString());
kf.init(hlx, cov, xb, yb, 0, surfaces, PDGDatabase.getParticleMass(pid));
kf.runFitter();

if(Constants.getInstance().seedingDebugMode)
System.out.println("KF status ... failed "+kf.setFitFailed+" ndf "+kf.NDF+" helix "+kf.getHelix());
if (kf.setFitFailed == false && kf.NDF>0 && kf.getHelix()!=null) {
Track fittedTrack = new Track(seed, kf, pid);
fittedTrack.update_Crosses(seed.getId());
fittedTrack.update_Crosses(seed.getId(), xb, yb);
for(Cross c : fittedTrack) {
if(c.getDetector()==DetectorType.BST) {
c.getCluster1().setAssociatedTrackID(0);
Expand All @@ -242,7 +242,7 @@ public List<Track> getTracks(DataEvent event, boolean initFromMc, boolean kfFilt
//refit adding missing clusters
List<Cluster> clsOnTrack = recUtil.findClustersOnTrk(this.SVTclusters, seed.getClusters(), fittedTrack, swimmer); //VZ: finds missing clusters; RDV fix 0 error

List<Cross> crsOnTrack = recUtil.findCrossesFromClustersOnTrk(this.SVTcrosses, clsOnTrack, fittedTrack);
List<Cross> crsOnTrack = recUtil.findCrossesFromClustersOnTrk(this.SVTcrosses, clsOnTrack, fittedTrack, xb, yb);

List<Cluster> bmtclsOnTrack = recUtil.findBMTClustersOnTrk(this.BMTclusters, seed.getCrosses(), fittedTrack.getHelix(),
fittedTrack.getP(), fittedTrack.getQ(), swimmer); //VZ: finds missing clusters
Expand Down Expand Up @@ -299,37 +299,40 @@ public List<Track> getTracks(DataEvent event, boolean initFromMc, boolean kfFilt
fittedTrack = recUtil.recovTrkMisClusSearch(seed, hlx, cov, kf2, kf, pid, surfaces, xb, yb,
this.SVTclusters, this.SVTcrosses,
swimmer, solenoidScale, solenoidValue, measure);
// if(fittedTrack!=null) {
// fittedTrack.setStatus(1);
// if(Constants.getInstance().seedingDebugMode)
// System.out.println("RECOVERED..."+fittedTrack.toString());
// }
}
if((Constants.getInstance().KFfailRecovMisCls && fittedTrack==null) ){
//dump seed
kf2.init(hlx, cov, xb, yb, 0, surfaces, PDGDatabase.getParticleMass(pid));
kf2.runFitterNoFiltFailSafe();
if(kf2.getHelix()!=null) {
fittedTrack = new Track(seed, kf2, pid);

if(fittedTrack!=null) {
fittedTrack.setStatus(1);
if(Constants.getInstance().seedingDebugMode)
System.out.println("RECOVERED SEED..."+fittedTrack.toString());
//fittedTrack.setStatus(-1);
for(Cross c : fittedTrack) {
if(c.getDetector()==DetectorType.BST) {
c.getCluster1().setAssociatedTrackID(0);
c.getCluster2().setAssociatedTrackID(0);
System.out.println("RECOVERED..."+fittedTrack.toString());
} else {
if(Constants.getInstance().seedingDebugMode)
System.out.println("FAILED..."+seed.toString());
if(Constants.getInstance().seedingDebugMode)
System.out.println("TRYING TO RUN FAIL SAFE..."+hlx.toString());
//dump seed
kf2.init(hlx, cov, xb, yb, 0, surfaces, PDGDatabase.getParticleMass(pid));
kf2.runFitterNoFiltFailSafe();
if(Constants.getInstance().seedingDebugMode)
System.out.println("RUN FAIL SAFE..."+seed.toString()+" OK "+kf2.getHelix()!=null);
if(kf2.getHelix()!=null) {
fittedTrack = new Track(seed, kf2, pid);
if(Constants.getInstance().seedingDebugMode)
System.out.println("RECOVERED SEED..."+fittedTrack.toString());
//fittedTrack.setStatus(-1);
for(Cross c : fittedTrack) {
if(c.getDetector()==DetectorType.BST) {
c.getCluster1().setAssociatedTrackID(0);
c.getCluster2().setAssociatedTrackID(0);
}
}
}
}
if(fittedTrack!=null && this.missingSVTCrosses(fittedTrack) == false)
tracks.add(fittedTrack);
}
if(fittedTrack!=null && this.missingSVTCrosses(fittedTrack) == false)
tracks.add(fittedTrack);

}
}
}


// reset cross and cluster IDs
if(SVTcrosses!=null) {
for(Cross c : this.SVTcrosses) {
Expand Down Expand Up @@ -361,7 +364,7 @@ public List<Track> getTracks(DataEvent event, boolean initFromMc, boolean kfFilt
int id = it + 1;
tracks.get(it).setId(id);
tracks.get(it).findTrajectory(swimmer, Geometry.getInstance().geOuterSurfaces());
tracks.get(it).update_Crosses(id);
tracks.get(it).update_Crosses(id, xb, yb);
tracks.get(it).update_Clusters(id);
tracks.get(it).setTrackCovMat(recUtil.getCovMatInTrackRep(tracks.get(it)));
if(Constants.getInstance().seedingDebugMode) System.out.println("Fit " + tracks.get(it).toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ public Surface getFaradayCageSurfaces(int i) {
Vector3D axis = new Vector3D(0,0,1);
Arc3D base = new Arc3D(origin, center, axis, 2*Math.PI);
Cylindrical3D fcCylinder = new Cylindrical3D(base, SVTConstants.FARADAYCAGELENGTH[i]);
fcCylinder.translateXYZ(SVTConstants.getGlobalAlignmentData()[0],
SVTConstants.getGlobalAlignmentData()[1],
SVTConstants.getGlobalAlignmentData()[2]);
Surface fcSurface = new Surface(fcCylinder, new Strip(0, 0, 0), Constants.DEFAULTSWIMACC);
fcSurface.addMaterial("FaradayCage"+i,
SVTConstants.FARADAYCAGERMAX[i]-SVTConstants.FARADAYCAGERMIN[i],
Expand Down
Loading