Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN | |||
DumbShaperFit.java | +8 | -5 | 1.4 -> 1.5 |
HPSShaperAnalyticFitAlgorithm.java | +16 | -12 | 1.6 -> 1.7 |
+24 | -17 |
Fitting algos can now be used without creating a RawTrackerHit
diff -u -r1.4 -r1.5 --- DumbShaperFit.java 4 May 2012 14:06:37 -0000 1.4 +++ DumbShaperFit.java 14 May 2012 19:07:55 -0000 1.5 @@ -11,11 +11,15 @@
public DumbShaperFit() { }
-
+
@Override public HPSShapeFitParameters fitShape(RawTrackerHit rth, ChannelConstants constants) {
- HPSShapeFitParameters fitresults = new HPSShapeFitParameters(); - short[] adcVals=rth.getADCValues();
+ short[] adcVals = rth.getADCValues(); + return this.fitShape(adcVals, constants); + } + + public HPSShapeFitParameters fitShape(short[] adcVals, ChannelConstants constants){ + HPSShapeFitParameters fitresults = new HPSShapeFitParameters();
double[] pedSub={-99.0,-99.0,-99.0,-99.0,-99.0,-99.0}; double maxADC=-99999; int iMax=-1;
@@ -52,8 +56,7 @@
fitresults.setAmp(maxADC); fitresults.setT0(t0);
- -
+
return fitresults; } }
diff -u -r1.6 -r1.7 --- HPSShaperAnalyticFitAlgorithm.java 28 Apr 2012 21:03:47 -0000 1.6 +++ HPSShaperAnalyticFitAlgorithm.java 14 May 2012 19:07:55 -0000 1.7 @@ -13,28 +13,33 @@
*/ public class HPSShaperAnalyticFitAlgorithm implements HPSShaperFitAlgorithm {
- public HPSShapeFitParameters fitShape(RawTrackerHit rth, ChannelConstants constants) { - double minChisq = Double.POSITIVE_INFINITY;
+ public HPSShapeFitParameters fitShape(RawTrackerHit rth, ChannelConstants constants){ + short[] samples = rth.getADCValues(); + return this.fitShape(samples, constants); + } + + public HPSShapeFitParameters fitShape(short[] samples, ChannelConstants constants){ + double minChisq = Double.POSITIVE_INFINITY;
int bestStart = 0; HPSShapeFitParameters fit = new HPSShapeFitParameters();
- for (int i = 0; i < rth.getADCValues().length - 2; i++) { - double chisq = fitSection(rth, constants, fit, i);
+ for(int i = 0; i < samples.length -2; i++){ + double chisq = fitSection(samples, constants, fit, i);
if (chisq < minChisq) { minChisq = chisq; bestStart = i; } }
- fit.setChiSq(fitSection(rth, constants, fit, bestStart));
+ fit.setChiSq(fitSection(samples, constants, fit, bestStart));
return fit; }
- private double fitSection(RawTrackerHit rth, ChannelConstants constants, HPSShapeFitParameters fit, int start) { - int length = rth.getADCValues().length - start;
+ private double fitSection(short[] samples, ChannelConstants constants, HPSShapeFitParameters fit, int start) { + int length = samples.length - start;
double[] y = new double[length]; double[] t = new double[length]; for (int i = 0; i < length; i++) {
- y[i] = rth.getADCValues()[start + i] - constants.getPedestal();
+ y[i] = samples[start + i] - constants.getPedestal();
t[i] = HPSSVTConstants.SAMPLE_INTERVAL * i; }
@@ -69,7 +74,6 @@
double dh_dp = (a[i] * Math.exp(-1.0 * t0 / constants.getTp()) + A * dt_dp * aa) / (aat - t0 * aa) - A * dt_dp / constants.getTp(); time_var += dt_dp * dt_dp; height_var += dh_dp * dh_dp;
-// covar += dt_dp*dh_dp;
} fit.setAmp(A);
@@ -79,15 +83,15 @@
fit.setTp(constants.getTp()); double chisq = 0;
- for (int i = 0; i < rth.getADCValues().length; i++) {
+ for (int i = 0; i < samples.length; i++) {
double ti = HPSSVTConstants.SAMPLE_INTERVAL * i; double fit_y = A * (Math.max(0, (ti - t0)) / constants.getTp()) * Math.exp(1 - (ti - t0) / constants.getTp()) + constants.getPedestal();
- chisq += Math.pow((fit_y - rth.getADCValues()[i]) / constants.getNoise(), 2);
+ chisq += Math.pow((fit_y - samples[i]) / constants.getNoise(), 2);
} fit.setChiSq(chisq); if (A > 0) {
- return chisq / (rth.getADCValues().length - 2); //TODO: p-value would be better here
+ return chisq / (samples.length - 2); //TODO: p-value would be better here
} else { return Double.POSITIVE_INFINITY; }
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1