Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN | |||
HPSRawTrackerHitFitterDriver.java | +71 | added 1.1 | |
HPSFittedRawTrackerHit.java | +8 | -54 | 1.1 -> 1.2 |
HPSShapeFitParameters.java | +104 | -23 | 1.1 -> 1.2 |
HPSTrackerHitMaker.java | +5 | -6 | 1.1 -> 1.2 |
+188 | -83 |
using HPSShapeFitParameters, which I should have been using to begin with; driver-ifying the functionality of HPSTrackerHitMaker
diff -N HPSRawTrackerHitFitterDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSRawTrackerHitFitterDriver.java 24 Apr 2012 16:23:38 -0000 1.1 @@ -0,0 +1,71 @@
+/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.lcsim.hps.recon.tracking; + +import java.util.ArrayList; +import java.util.List; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.util.Driver; +import org.lcsim.util.lcio.LCIOConstants; + +/** + * + * @author mgraham + */ +public class HPSRawTrackerHitFitterDriver extends Driver { + + private HPSShaperFitAlgorithm _shaper = null; + private String rawHitCollectionName = "SVTRawTrackerHits"; + private String fitCollectionName = "SVTShapeFitParameters"; + private String fittedHitCollectionName = "SVTFittedRawTrackerHits"; + private int genericObjectFlags = 1<<LCIOConstants.GOBIT_FIXED; + private int relationFlags = 0; + + public void setFitAlgorithm(String fitAlgorithm) { + //TODO: uncomment once this actually exists +// if (fitAlgorithm=="Analytic") +// _shaper = new HPSShaperAnalyticFitter(); + } + + public void setFitCollectionName(String fitCollectionName) { + this.fitCollectionName = fitCollectionName; + } + + public void setFittedHitCollectionName(String fittedHitCollectionName) { + this.fittedHitCollectionName = fittedHitCollectionName; + } + + public void setRawHitCollectionName(String rawHitCollectionName) { + this.rawHitCollectionName = rawHitCollectionName; + } + + @Override + public void startOfData() { + if (rawHitCollectionName == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + } + + @Override + public void process(EventHeader event) { + List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, rawHitCollectionName); + if (rawHits == null) { + throw new RuntimeException("Event is missing ECal hits collection!"); + } + List<HPSFittedRawTrackerHit> hits = new ArrayList<HPSFittedRawTrackerHit>(); + List<HPSShapeFitParameters> fits = new ArrayList<HPSShapeFitParameters>(); + + // Make a fitted hit from this cluster + for (RawTrackerHit hit : rawHits) { + HPSShapeFitParameters fit = _shaper.fitShape(hit); + fits.add(fit); + HPSFittedRawTrackerHit hth = new HPSFittedRawTrackerHit(hit, fit); + hits.add(hth); + } + event.put(fitCollectionName, fits, HPSShapeFitParameters.class, genericObjectFlags); + event.put(fittedHitCollectionName, hits, HPSFittedRawTrackerHit.class, relationFlags); + } +}
diff -u -r1.1 -r1.2 --- HPSFittedRawTrackerHit.java 24 Apr 2012 15:38:45 -0000 1.1 +++ HPSFittedRawTrackerHit.java 24 Apr 2012 16:23:38 -0000 1.2 @@ -1,78 +1,32 @@
package org.lcsim.hps.recon.tracking;
-import org.lcsim.event.GenericObject;
import org.lcsim.event.RawTrackerHit; import org.lcsim.event.base.BaseLCRelation; /** * * @author meeg
- * @version $Id: HPSFittedRawTrackerHit.java,v 1.1 2012/04/24 15:38:45 meeg Exp $
+ * @version $Id: HPSFittedRawTrackerHit.java,v 1.2 2012/04/24 16:23:38 meeg Exp $
*/ public class HPSFittedRawTrackerHit extends BaseLCRelation {
- public HPSFittedRawTrackerHit(RawTrackerHit hit, TrackerFit fit) {
+ public HPSFittedRawTrackerHit(RawTrackerHit hit, HPSShapeFitParameters fit) {
super(hit, fit); }
- public HPSFittedRawTrackerHit(RawTrackerHit hit, double t0, double amplitude) { - super(hit, new TrackerFit(t0, amplitude)); - } -
public RawTrackerHit getRawTrackerHit() { return (RawTrackerHit) getFrom(); }
- public double getT0() { - return ((TrackerFit)getTo()).getDoubleVal(0);
+ public HPSShapeFitParameters getShapeFitParameters() { + return (HPSShapeFitParameters) getTo();
}
- public double getAmplitude() { - return ((TrackerFit)getTo()).getDoubleVal(1);
+ public double getT0() { + return getShapeFitParameters().getT0();
}
- public static class TrackerFit implements GenericObject { - - private double t0, amplitude; - - public TrackerFit(double t0, double amplitude) { - this.t0 = t0; - this.amplitude = amplitude; - } - - public int getNInt() { - return 0; - } - - public int getNFloat() { - return 0; - } - - public int getNDouble() { - return 2; - } - - public int getIntVal(int i) { - throw new UnsupportedOperationException("TrackerFit only holds two doubles."); - } - - public float getFloatVal(int i) { - throw new UnsupportedOperationException("TrackerFit only holds two doubles."); - } - - public double getDoubleVal(int i) { - switch (i) { - case 0: - return t0; - case 1: - return amplitude; - default: - throw new RuntimeException("blargh!"); - } - } - - public boolean isFixedSize() { - return true; - }
+ public double getAmp() { + return getShapeFitParameters().getAmp();
} }
diff -u -r1.1 -r1.2 --- HPSShapeFitParameters.java 24 Apr 2012 13:41:33 -0000 1.1 +++ HPSShapeFitParameters.java 24 Apr 2012 16:23:38 -0000 1.2 @@ -4,32 +4,113 @@
*/ package org.lcsim.hps.recon.tracking;
+import org.lcsim.event.GenericObject; +
/** * * @author mgraham */
-public class HPSShapeFitParameters {
+public class HPSShapeFitParameters implements GenericObject { + + private double _t0 = Double.NaN; + private double _t0Err = Double.NaN; + private double _amp = Double.NaN; + private double _ampErr = Double.NaN; + private double _tp = Double.NaN; + private double _tpErr = Double.NaN; + + public HPSShapeFitParameters() { + } + + public HPSShapeFitParameters(double t0, double amplitude) { + _t0 = t0; + _amp = amplitude; + } + + public void setT0(double t0) { + _t0 = t0; + } + + public void setAmp(double amp) { + _amp = amp; + } + + public void setTP(double tp) { + _tp = tp; + } + + public double getT0() { + return _t0; + } + + public double getAmp() { + return _amp; + } + + public double getTP() { + return _tp; + } + + public double getT0Err() { + return _t0Err; + } + + public double getAmpErr() { + return _ampErr; + } + + public double getTPErr() { + return _tpErr; + } + + @Override + public int getNInt() { + return 0; + } + + @Override + public int getNFloat() { + return 0; + } + + @Override + public int getNDouble() { + return 6; + } + + @Override + public int getIntVal(int index) { + throw new UnsupportedOperationException("No int values in " + this.getClass().getSimpleName()); + } + + @Override + public float getFloatVal(int index) { + throw new UnsupportedOperationException("No int values in " + this.getClass().getSimpleName()); + } + + @Override + public double getDoubleVal(int index) { + switch (index) { + case 0: + return _t0; + case 1: + return _t0Err; + case 2: + return _amp; + case 3: + return _ampErr; + case 4: + return _tp; + case 5: + return _tpErr; + default: + throw new UnsupportedOperationException("Only 6 double values in " + this.getClass().getSimpleName()); + } + + }
- private double _t0; - private double _t0Err; - private double _amp; - private double _ampErr; - private double _tp; - private double _tpErr; - - public HPSShapeFitParameters(){ - } - - public void setT0(double t0){_t0=t0;} - public void setAmp(double amp){_amp=amp;} - public void setTP(double tp){_tp=tp;} - - public double getT0(){return _t0;} - public double getAmp(){return _amp;} - public double getTP(){return _tp;} - - public double getT0Err(){return _t0Err;} - public double getAmpErr(){return _ampErr;} - public double getTPErr(){return _tpErr;} -
+ @Override + public boolean isFixedSize() { + return true; + }
}
diff -u -r1.1 -r1.2 --- HPSTrackerHitMaker.java 24 Apr 2012 14:08:46 -0000 1.1 +++ HPSTrackerHitMaker.java 24 Apr 2012 16:23:38 -0000 1.2 @@ -24,14 +24,13 @@
_shaper = shaperFit; }
- public List<HPSTrackerHit> makeHits(List<RawTrackerHit> raw_hits) { - List<HPSTrackerHit> hits = new ArrayList<HPSTrackerHit>(); - HPSShapeFitParameters fitResults;
+ public List<HPSFittedRawTrackerHit> makeHits(List<RawTrackerHit> raw_hits) { + List<HPSFittedRawTrackerHit> hits = new ArrayList<HPSFittedRawTrackerHit>();
// Make a pixel hit from this cluster for (RawTrackerHit hit : raw_hits) {
- fitResults = (HPSShapeFitParameters) _shaper.fitShape(hit); - HPSTrackerHit hth = new HPSTrackerHit(hit, fitResults.getT0(), fitResults.getAmp()); - hits.add(hth);
+ HPSShapeFitParameters fit = _shaper.fitShape(hit); + HPSFittedRawTrackerHit hth = new HPSFittedRawTrackerHit(hit, fit); + hits.add(hth);
} return hits; }
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