diff --git a/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java b/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java index 1eded1905b..42a21cb97e 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java @@ -876,165 +876,166 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track)) }//point loop + }// composite Alignment - //Make a gblTrajectory with the points with all the composite derivatives + seed and write the record + //Make a gblTrajectory with the points with all the composite derivatives + seed and write the record - GblTrajectoryJna trajForMPII = null; - GblTrajectoryJna trajForMPII_unconstrained = new GblTrajectoryJna(points_on_traj,1,1,1); + GblTrajectoryJna trajForMPII = null; + GblTrajectoryJna trajForMPII_unconstrained = new GblTrajectoryJna(points_on_traj,1,1,1); - //seed matrix q/p, yT', xT', xT, yT - SymMatrix seedPrecision = new SymMatrix(5); + //seed matrix q/p, yT', xT', xT, yT + SymMatrix seedPrecision = new SymMatrix(5); - if (constrainedFit) - seedPrecision.set(0,0,seed_precision); - if (constrainedTanLFit) - seedPrecision.set(1,1,seed_precision); - if (constrainedPhi0Fit) - seedPrecision.set(2,2,seed_precision); + if (constrainedFit) + seedPrecision.set(0,0,seed_precision); + if (constrainedTanLFit) + seedPrecision.set(1,1,seed_precision); + if (constrainedPhi0Fit) + seedPrecision.set(2,2,seed_precision); - //z0 constraint - //seedPrecision.set(4,4,seed_precision); + //z0 constraint + //seedPrecision.set(4,4,seed_precision); - //d0 constraint - //seedPrecision.set(3,3,1000000); + //d0 constraint + //seedPrecision.set(3,3,1000000); - if (!constrainedFit && !constrainedTanLFit && !constrainedPhi0Fit && !constrainedD0Fit && !constrainedZ0Fit) { - trajForMPII = new GblTrajectoryJna(points_on_traj,1,1,1); - } else { - trajForMPII = new GblTrajectoryJna(points_on_traj,1,seedPrecision,1,1,1); - } + if (!constrainedFit && !constrainedTanLFit && !constrainedPhi0Fit && !constrainedD0Fit && !constrainedZ0Fit) { + trajForMPII = new GblTrajectoryJna(points_on_traj,1,1,1); + } else { + trajForMPII = new GblTrajectoryJna(points_on_traj,1,seedPrecision,1,1,1); + } - if (debugAlignmentDs) trajForMPII.printData(); + if (debugAlignmentDs) trajForMPII.printData(); - //Fit the trajectory to get the Chi2 - trajForMPII_unconstrained.fit(Chi2,Ndf, lostWeight,""); + //Fit the trajectory to get the Chi2 + trajForMPII_unconstrained.fit(Chi2,Ndf, lostWeight,""); - //Avoid to use tracks with terrible Chi2 - if (Chi2.getValue() / Ndf.getValue() > writeMilleChi2Cut) - continue; + //Avoid to use tracks with terrible Chi2 + if (Chi2.getValue() / Ndf.getValue() > writeMilleChi2Cut) + continue; - if (writeMilleBinary) { - /* - System.out.println("DEBUG::Tom::Writing track with " - + points_on_traj.size() + " hits to mille binary."); - */ - trajForMPII.milleOut(mille); - } + if (writeMilleBinary) { + /* + System.out.println("DEBUG::Tom::Writing track with " + + points_on_traj.size() + " hits to mille binary."); + */ + trajForMPII.milleOut(mille); + } - if (correctTrack) { + if (correctTrack) { - //Form the FittedGblTrajectory for the unconstrained fit - FittedGblTrajectory fitTraj = new FittedGblTrajectory(trajForMPII_unconstrained, Chi2.getValue(), Ndf.getValue(), lostWeight.getValue()); + //Form the FittedGblTrajectory for the unconstrained fit + FittedGblTrajectory fitTraj = new FittedGblTrajectory(trajForMPII_unconstrained, Chi2.getValue(), Ndf.getValue(), lostWeight.getValue()); - fitTraj.setSensorMap(sensorMap); - fitTraj.setPathLengthMap(pathLengthMap); + fitTraj.setSensorMap(sensorMap); + fitTraj.setPathLengthMap(pathLengthMap); - Collection hth = track.getTrackerHits(); - List allHthList = TrackUtils.sortHits(hth); - Pair newTrack = MakeGblTracks.makeCorrectedTrack(fitTraj, TrackUtils.getHTF(track), allHthList, 0, bfield); - Track gblTrk = newTrack.getFirst(); + Collection hth = track.getTrackerHits(); + List allHthList = TrackUtils.sortHits(hth); + Pair newTrack = MakeGblTracks.makeCorrectedTrack(fitTraj, TrackUtils.getHTF(track), allHthList, 0, bfield); + Track gblTrk = newTrack.getFirst(); - //System.out.println("DEBUG::Tom::Correct GBL track has "+gblTrk.getTrackerHits().size()+" hits"); + //System.out.println("DEBUG::Tom::Correct GBL track has "+gblTrk.getTrackerHits().size()+" hits"); - if(computeGBLResiduals) { + if(computeGBLResiduals) { - List b_residuals = new ArrayList(); - List b_sigmas = new ArrayList(); - List r_sensors = new ArrayList(); + List b_residuals = new ArrayList(); + List b_sigmas = new ArrayList(); + List r_sensors = new ArrayList(); - int numData[] = new int[1]; - Integer[] sensorsFromMapArray = fitTraj.getSensorMap().keySet().toArray(new Integer[0]); - for (int i_s = 0; i_s < sensorsFromMapArray.length; i_s++) { - int ilabel = sensorsFromMapArray[i_s]; - int mpid = fitTraj.getSensorMap().get(ilabel); - List aResiduals = new ArrayList(); - List aMeasErrors = new ArrayList(); - List aResErrors = new ArrayList(); - List aDownWeights = new ArrayList(); - trajForMPII_unconstrained.getMeasResults(ilabel,numData,aResiduals,aMeasErrors,aResErrors,aDownWeights); - if (numData[0]>1) { - System.out.printf("GBLRefitterDriver::WARNING::We have SCT sensors. Residuals dimensions should be <=1\n"); - } - for (int i=0; i aResiduals = new ArrayList(); + List aMeasErrors = new ArrayList(); + List aResErrors = new ArrayList(); + List aDownWeights = new ArrayList(); + trajForMPII_unconstrained.getMeasResults(ilabel,numData,aResiduals,aMeasErrors,aResErrors,aDownWeights); + if (numData[0]>1) { + System.out.printf("GBLRefitterDriver::WARNING::We have SCT sensors. Residuals dimensions should be <=1\n"); + } + for (int i=0; i u_aResiduals = new ArrayList(); - List u_aMeasErrors = new ArrayList(); - List u_aResErrors = new ArrayList(); - List u_aDownWeights = new ArrayList(); + GblTrajectoryJna gbl_fit_traj_u = new GblTrajectoryJna(points_on_traj,1,1,1); + DoubleByReference Chi2_u = new DoubleByReference(0.); + DoubleByReference lostWeight_u = new DoubleByReference(0.); + IntByReference Ndf_u = new IntByReference(0); + int[] u_numData = new int[1]; + //Fit it once to have exactly the same starting point of gbl_fit_trajectory. + gbl_fit_traj_u.fit(Chi2_u,Ndf_u,lostWeight_u,""); + List u_aResiduals = new ArrayList(); + List u_aMeasErrors = new ArrayList(); + List u_aResErrors = new ArrayList(); + List u_aDownWeights = new ArrayList(); - try { - //Fit removing the measurement - gbl_fit_traj_u.fit(Chi2_u,Ndf_u,lostWeight_u,"",ilabel); - gbl_fit_traj_u.getMeasResults(ilabel,u_numData,u_aResiduals,u_aMeasErrors,u_aResErrors,u_aDownWeights); - for (int i=0; i