Skip to content

Commit

Permalink
blow up initial covariance matrix starting from the second iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
tongtongcao committed Sep 15, 2023
1 parent 6d45e37 commit 670e0d1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
public class KFitter extends AKFitter {

private static final double initialCMBlowupFactor = 70;

private StateVecs sv = new StateVecs();
private MeasVecs mv = new MeasVecs();
private StateVec finalSmoothedStateVec = null;
Expand Down Expand Up @@ -192,6 +194,19 @@ public void runFitter() {
break;
}
} else {
double c00 = this.sv.trackTrajB.get(0).CM.get(0, 0);
double c11 = this.sv.trackTrajB.get(0).CM.get(1, 1);
double c22 = this.sv.trackTrajB.get(0).CM.get(2, 2);
double c33 = this.sv.trackTrajB.get(0).CM.get(3, 3);
double c44 = this.sv.trackTrajB.get(0).CM.get(4, 4);
Matrix newCM = new Matrix();
newCM.set(c00*initialCMBlowupFactor, 0, 0, 0, 0,
0, c11*initialCMBlowupFactor, 0, 0, 0,
0, 0, c22*initialCMBlowupFactor, 0, 0,
0, 0, 0, c33*initialCMBlowupFactor, 0,
0, 0, 0, 0, c44*initialCMBlowupFactor);
this.sv.trackTrajB.get(0).CM = newCM;

if (!this.sv.transport(sector, 0, 1, this.sv.trackTrajB.get(0), mv, this.getSwimmer(), forward)) {
this.stopIteration = true;
break;
Expand Down Expand Up @@ -222,19 +237,19 @@ public void runFitter() {
if (this.setFitFailed == false) {
if (this.finalStateVec != null) {
if (!TBT) {
if (Math.abs(sv.trackTrajF.get(svzLength - 1).Q - this.finalStateVec.Q) < 3.3e-3
&& Math.abs(sv.trackTrajF.get(svzLength - 1).x - this.finalStateVec.x) < 7.3e-2
&& Math.abs(sv.trackTrajF.get(svzLength - 1).y - this.finalStateVec.y) < 4.3e-1
&& Math.abs(sv.trackTrajF.get(svzLength - 1).tx - this.finalStateVec.tx) < 9.2e-4
&& Math.abs(sv.trackTrajF.get(svzLength - 1).ty - this.finalStateVec.ty) < 2.1e-3) {
if (Math.abs(sv.trackTrajF.get(svzLength - 1).Q - this.finalStateVec.Q) < 1.6e-3
&& Math.abs(sv.trackTrajF.get(svzLength - 1).x - this.finalStateVec.x) < 1.2e-2
&& Math.abs(sv.trackTrajF.get(svzLength - 1).y - this.finalStateVec.y) < 1.4e-1
&& Math.abs(sv.trackTrajF.get(svzLength - 1).tx - this.finalStateVec.tx) < 2.5e-4
&& Math.abs(sv.trackTrajF.get(svzLength - 1).ty - this.finalStateVec.ty) < 1.0e-3) {
i = totNumIter;
}
} else {
if (Math.abs(sv.trackTrajF.get(svzLength - 1).Q - this.finalStateVec.Q) < 5.5e-5
&& Math.abs(sv.trackTrajF.get(svzLength - 1).x - this.finalStateVec.x) < 5.0e-4
&& Math.abs(sv.trackTrajF.get(svzLength - 1).y - this.finalStateVec.y) < 2.1e-3
&& Math.abs(sv.trackTrajF.get(svzLength - 1).tx - this.finalStateVec.tx) < 8.8e-6
&& Math.abs(sv.trackTrajF.get(svzLength - 1).ty - this.finalStateVec.ty) < 1.4e-5) {
if (Math.abs(sv.trackTrajF.get(svzLength - 1).Q - this.finalStateVec.Q) < 1.1e-5
&& Math.abs(sv.trackTrajF.get(svzLength - 1).x - this.finalStateVec.x) < 5.5e-5
&& Math.abs(sv.trackTrajF.get(svzLength - 1).y - this.finalStateVec.y) < 8.0e-4
&& Math.abs(sv.trackTrajF.get(svzLength - 1).tx - this.finalStateVec.tx) < 2.1e-6
&& Math.abs(sv.trackTrajF.get(svzLength - 1).ty - this.finalStateVec.ty) < 3.5e-6) {
i = totNumIter;
}
}
Expand Down Expand Up @@ -506,7 +521,7 @@ private void calcFinalChisq(int sector, boolean nofilter) {
}

public Matrix propagateToVtx(int sector, double Zf) {
return sv.transport(sector, 0, Zf, sv.trackTrajP.get(0), mv, this.getSwimmer());
return sv.transport(sector, finalStateVec.k, Zf, finalStateVec, mv, this.getSwimmer());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
public class KFitterWithURWell extends AKFitter {

private static final Logger LOGGER = Logger.getLogger(KFitter.class.getName());

private static final double initialCMBlowupFactor = 70;

private StateVecs sv = new StateVecs();
private MeasVecs mv = new MeasVecs();
Expand Down Expand Up @@ -203,6 +205,19 @@ public void runFitter() {
break;
}
} else {
double c00 = this.sv.trackTrajB.get(0).CM.get(0, 0);
double c11 = this.sv.trackTrajB.get(0).CM.get(1, 1);
double c22 = this.sv.trackTrajB.get(0).CM.get(2, 2);
double c33 = this.sv.trackTrajB.get(0).CM.get(3, 3);
double c44 = this.sv.trackTrajB.get(0).CM.get(4, 4);
Matrix newCM = new Matrix();
newCM.set(c00*initialCMBlowupFactor, 0, 0, 0, 0,
0, c11*initialCMBlowupFactor, 0, 0, 0,
0, 0, c22*initialCMBlowupFactor, 0, 0,
0, 0, 0, c33*initialCMBlowupFactor, 0,
0, 0, 0, 0, c44*initialCMBlowupFactor);
this.sv.trackTrajB.get(0).CM = newCM;

if (!this.sv.transport(sector, 0, 1, this.sv.trackTrajB.get(0), mv, this.getSwimmer(), forward)) {
this.stopIteration = true;
break;
Expand Down Expand Up @@ -233,19 +248,19 @@ public void runFitter() {
if (this.setFitFailed == false) {
if (this.finalStateVec != null) {
if (!TBT) {
if (Math.abs(sv.trackTrajF.get(svzLength - 1).Q - this.finalStateVec.Q) < 3.3e-3
&& Math.abs(sv.trackTrajF.get(svzLength - 1).x - this.finalStateVec.x) < 7.3e-2
&& Math.abs(sv.trackTrajF.get(svzLength - 1).y - this.finalStateVec.y) < 4.3e-1
&& Math.abs(sv.trackTrajF.get(svzLength - 1).tx - this.finalStateVec.tx) < 9.2e-4
&& Math.abs(sv.trackTrajF.get(svzLength - 1).ty - this.finalStateVec.ty) < 2.1e-3) {
if (Math.abs(sv.trackTrajF.get(svzLength - 1).Q - this.finalStateVec.Q) < 1.6e-3
&& Math.abs(sv.trackTrajF.get(svzLength - 1).x - this.finalStateVec.x) < 1.2e-2
&& Math.abs(sv.trackTrajF.get(svzLength - 1).y - this.finalStateVec.y) < 1.4e-1
&& Math.abs(sv.trackTrajF.get(svzLength - 1).tx - this.finalStateVec.tx) < 2.5e-4
&& Math.abs(sv.trackTrajF.get(svzLength - 1).ty - this.finalStateVec.ty) < 1.0e-3) {
i = totNumIter;
}
} else {
if (Math.abs(sv.trackTrajF.get(svzLength - 1).Q - this.finalStateVec.Q) < 5.5e-5
&& Math.abs(sv.trackTrajF.get(svzLength - 1).x - this.finalStateVec.x) < 5.0e-4
&& Math.abs(sv.trackTrajF.get(svzLength - 1).y - this.finalStateVec.y) < 2.1e-3
&& Math.abs(sv.trackTrajF.get(svzLength - 1).tx - this.finalStateVec.tx) < 8.8e-6
&& Math.abs(sv.trackTrajF.get(svzLength - 1).ty - this.finalStateVec.ty) < 1.4e-5) {
if (Math.abs(sv.trackTrajF.get(svzLength - 1).Q - this.finalStateVec.Q) < 1.1e-5
&& Math.abs(sv.trackTrajF.get(svzLength - 1).x - this.finalStateVec.x) < 5.5e-5
&& Math.abs(sv.trackTrajF.get(svzLength - 1).y - this.finalStateVec.y) < 8.0e-4
&& Math.abs(sv.trackTrajF.get(svzLength - 1).tx - this.finalStateVec.tx) < 2.1e-6
&& Math.abs(sv.trackTrajF.get(svzLength - 1).ty - this.finalStateVec.ty) < 3.5e-6) {
i = totNumIter;
}
}
Expand Down Expand Up @@ -593,7 +608,7 @@ private void calcFinalChisq(int sector, boolean nofilter) {
}

public Matrix propagateToVtx(int sector, double Zf) {
return sv.transport(sector, 0, Zf, sv.trackTrajP.get(0), mv, this.getSwimmer());
return sv.transport(sector, finalStateVec.k, Zf, finalStateVec, mv, this.getSwimmer());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ public static Constants getInstance() {
public static final double HBINITIALSTATEQUNC = 0.13;

public static final double TBINITIALSTATEUNCSCALE = 1.5;
public static final double TBINITIALSTATEXUNC = 0.11;
public static final double TBINITIALSTATEYUNC = 0.98;
public static final double TBINITIALSTATETXUNC = 0.0024;
public static final double TBINITIALSTATEXUNC = 0.14;
public static final double TBINITIALSTATEYUNC = 1.03;
public static final double TBINITIALSTATETXUNC = 0.0025;
public static final double TBINITIALSTATETYUNC = 0.0091;
public static final double TBINITIALSTATEQUNC = 0.0085;
public static final double TBINITIALSTATEQUNC = 0.0084;

////// With uRWell
public static final double HBINITIALSTATEUNCSCALEUR = 2;
Expand Down

0 comments on commit 670e0d1

Please sign in to comment.