Commit in lcsim on MAIN | |||
pom.xml | +1 | 1.188 -> 1.189 | |
src/org/lcsim/event/base/BaseCalorimeterHit.java | +81 | -61 | 1.13 -> 1.14 |
/BaseHit.java | +3 | -4 | 1.12 -> 1.13 |
/BaseHitWithPosition.java | +7 | -1 | 1.3 -> 1.4 |
/BaseSimCalorimeterHit.java | +21 | -2 | 1.7 -> 1.8 |
/BaseSimTrackerHit.java | +9 | -1 | 1.17 -> 1.18 |
src/org/lcsim/util/lcio/SIOCalorimeterHit.java | +2 | -1 | 1.15 -> 1.16 |
/SIOSimCalorimeterHit.java | +2 | -1 | 1.11 -> 1.12 |
test/org/lcsim/recon/tracking/digitization/sisim/config/SimTrackerHitReadoutDriver_Test.java | +2 | -2 | 1.1 -> 1.2 |
+128 | -73 |
fix lookup of CalHit DetectorElements
diff -u -r1.188 -r1.189 --- pom.xml 10 Jul 2012 00:21:31 -0000 1.188 +++ pom.xml 10 Jul 2012 19:57:14 -0000 1.189 @@ -140,6 +140,7 @@
<exclude>org/lcsim/recon/tracking/seedtracker/SeedTrackerVSTest.java</exclude> <exclude>org/lcsim/CalHitStepPosTest.java</exclude> <exclude>org/lcsim/TestFastMC.java</exclude>
+ <exclude>org/lcsim/TestFastMCGenerator.java</exclude>
</excludes> </configuration> </plugin>
diff -u -r1.13 -r1.14 --- BaseCalorimeterHit.java 11 Apr 2011 12:40:40 -0000 1.13 +++ BaseCalorimeterHit.java 10 Jul 2012 19:57:14 -0000 1.14 @@ -2,126 +2,146 @@
import hep.physics.vec.Hep3Vector;
+import org.lcsim.detector.DetectorElementStore; +import org.lcsim.detector.IDetectorElement; +import org.lcsim.detector.IDetectorElementContainer; +import org.lcsim.detector.identifier.IExpandedIdentifier;
import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierDictionary; +import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.detector.identifier.Identifier; import org.lcsim.event.CalorimeterHit; import org.lcsim.event.util.SamplingFractionManager; import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.Subdetector; +import org.lcsim.geometry.segmentation.SegmentationBase;
/** * Base implementation of CalorimeterHit.
+ *
* @author tonyj * @author jeremym
- * @version $Id: BaseCalorimeterHit.java,v 1.13 2011/04/11 12:40:40 grefe Exp $
+ * @version $Id: BaseCalorimeterHit.java,v 1.14 2012/07/10 19:57:14 jeremy Exp $
*/
-public abstract class BaseCalorimeterHit extends BaseHitWithPosition implements CalorimeterHit -{ - protected double rawEnergy = UNSET_CORRECTED_ENERGY; - protected double corrEnergy = UNSET_CORRECTED_ENERGY;
+public abstract class BaseCalorimeterHit extends BaseHitWithPosition implements CalorimeterHit { + + private static final double UNSET_ENERGY = -1; + protected double rawEnergy = UNSET_ENERGY; + protected double corrEnergy = UNSET_ENERGY;
protected double energyError; protected double[] position; protected Hep3Vector positionVec; protected double time; protected long id; protected int type;
- - private static final double UNSET_CORRECTED_ENERGY = -1; - - public double getTime() - {
+ + public double getTime() {
return time; }
- public int getType() - {
+ public int getType() {
return type; }
- public double getRawEnergy() - { - if( rawEnergy == UNSET_CORRECTED_ENERGY) - { - throw new RuntimeException("No raw energy available for CalorimeterHit");
+ public double getRawEnergy() { + if (rawEnergy == UNSET_ENERGY) { + throw new RuntimeException("No raw energy available for CalorimeterHit.");
} return rawEnergy; }
- public double[] getPosition() - { - if (position == null) - {
+ public double[] getPosition() { + if (position == null) {
calculatePosition(); } return position; }
- public double getCorrectedEnergy() - { - if (corrEnergy == UNSET_CORRECTED_ENERGY) - {
+ public double getCorrectedEnergy() { + if (corrEnergy == UNSET_ENERGY) {
calculateCorrectedEnergy(); } return corrEnergy; }
- public long getCellID() - {
+ public long getCellID() {
return id; }
- public int getLayerNumber() - { - IDDecoder decoder = getIDDecoder(); - decoder.setID(id); - return decoder.getLayer();
+ public int getLayerNumber() { + IDDecoder decoder = getIDDecoder(); + decoder.setID(id); + return decoder.getLayer();
}
- private void calculateCorrectedEnergy() - {
+ private void calculateCorrectedEnergy() {
getIDDecoder().setID(id); corrEnergy = SamplingFractionManager.defaultInstance().getCorrectedEnergy(rawEnergy, getIDDecoder().getLayer(), getSubdetector()); }
- - private void calculatePosition() - { - if (getMetaData() != null) - {
+ + private void calculatePosition() { + if (getMetaData() != null) {
position = new double[3];
- IDDecoder decoder = getIDDecoder();
+ IDDecoder decoder = getIDDecoder();
decoder.setID(id); position[0] = decoder.getX(); position[1] = decoder.getY(); position[2] = decoder.getZ();
+ } else { + throw new RuntimeException("Can't calculate position. MetaData is null.");
} }
- - public IIdentifier getIdentifier() - { - if (compactId == null) - compactId = new Identifier(id); - return compactId; - } - - public double getEnergyError() - {
+ + public IIdentifier getIdentifier() { + if (compactId == null) + compactId = new Identifier(id); + return compactId; + } + + public double getEnergyError() {
return energyError; }
- - public void setType(int type) - { - this.type = type;
+ + public void setType(int type) { + this.type = type; + } + + public IDetectorElement getDetectorElement() { + if (de == null) + findDetectorElementByPosition(); + // setupDetectorElement(); + return de;
}
-
+
/** * Conversion to String for printout.
+ *
* @return String output. */
- public String toString() - {
+ public String toString() {
StringBuffer sb = new StringBuffer("CalorimeterHitImpl: \n");
- sb.append("type: "+type+" energy: "+corrEnergy +" energyError: " + energyError + "\n"); - sb.append("position: "+position[0]+" "+position[1]+" "+position[2]+"\n"); - sb.append("id: "+id+" time: "+time);
+ sb.append("type: " + type + " energy: " + corrEnergy + " energyError: " + energyError + "\n"); + sb.append("position: " + position[0] + " " + position[1] + " " + position[2] + "\n"); + sb.append("id: " + id + " time: " + time);
return sb.toString(); }
-}
\ No newline at end of file
+} + +/* + * protected void setupDetectorElement() { Subdetector subdet = meta.getIDDecoder().getSubdetector(); + * IIdentifierHelper helper = subdet.getDetectorElement().getIdentifierHelper(); SegmentationBase seg = + * (SegmentationBase)subdet.getIDDecoder(); String[] stripFields = seg.getSegmentationFieldNames(); if + * (stripFields == null) throw new RuntimeException("stripFields is null"); IIdentifierDictionary dict = + * helper.getIdentifierDictionary(); int nfields = dict.getNumberOfFields(); IExpandedIdentifier expId = + * helper.unpack(getIdentifier()); for (int i=0; i<nfields; i++) { int idx = + * dict.getFieldIndex(stripFields[i]); expId.setValue(idx, 0); } de = + * findDetectorElement(dict.pack(expId)); if (de == null) throw new + * RuntimeException("DetectorElement not found."); } + * + * private static IDetectorElement findDetectorElement(IIdentifier id) { + * System.out.println("findDetectorElement - " + id.toHexString()); IDetectorElement de = null; + * IDetectorElementContainer srch = DetectorElementStore.getInstance().find(id); if (srch.size() == 0) { + * throw new RuntimeException("No DetectorElement found with id <" + id.toHexString() + ">."); } else if + * (srch.size() == 1) { de = srch.get(0); } else if (srch.size() > 1) { for (IDetectorElement xde : srch) + * { if (!xde.hasChildren()) { de = xde; break; } } } return de; } + */
\ No newline at end of file
diff -u -r1.12 -r1.13 --- BaseHit.java 10 Jul 2012 00:11:24 -0000 1.12 +++ BaseHit.java 10 Jul 2012 19:57:14 -0000 1.13 @@ -41,7 +41,6 @@
if (this.meta == null) { this.meta = meta; }
- setupDetectorElement();
} /**
@@ -150,7 +149,7 @@
* Use the {@link IIdentifier} associated with this hit to find its DetectorElement * in the geometry hierarchy and set a member variable to point to it. */
- private void findDetectorElementByIdentifier() {
+ protected void findDetectorElementByIdentifier() {
if (this.de == null) { IDetectorElementContainer srch = DetectorElementStore.getInstance().find(getIdentifier());
@@ -178,9 +177,9 @@
/** * Setup link to the DetectorElement using the hit's ID. */
- private void setupDetectorElement() {
+ protected void setupDetectorElement() {
try {
- findDetectorElementByIdentifier();
+
//System.out.println("Assigned DetectorElement <" + de.getName() + "> to hit."); } catch (RuntimeException x) { throw new RuntimeException("Failed to find DetectorElement for hit.");
diff -u -r1.3 -r1.4 --- BaseHitWithPosition.java 10 Jul 2012 00:11:24 -0000 1.3 +++ BaseHitWithPosition.java 10 Jul 2012 19:57:14 -0000 1.4 @@ -37,5 +37,11 @@
public Hep3Vector getPositionVec() { return positionVec; }
-
+ + protected void findDetectorElementByPosition() { + //System.out.println("looking for DE for hit at pos " + getPositionVec().toString()); + de = getSubdetector().getDetectorElement().findDetectorElement(getPositionVec()); + if (de == null) + throw new RuntimeException("DetectorElement was not found for hit at position: " + getPositionVec()); + }
}
\ No newline at end of file
diff -u -r1.7 -r1.8 --- BaseSimCalorimeterHit.java 24 Aug 2011 18:51:17 -0000 1.7 +++ BaseSimCalorimeterHit.java 10 Jul 2012 19:57:14 -0000 1.8 @@ -2,11 +2,21 @@
import hep.io.sio.SIORef;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
+import org.lcsim.detector.DetectorElementStore; +import org.lcsim.detector.IDetectorElement; +import org.lcsim.detector.IDetectorElementContainer; +import org.lcsim.detector.identifier.IExpandedIdentifier; +import org.lcsim.detector.identifier.IIdentifier; +import org.lcsim.detector.identifier.IIdentifierDictionary; +import org.lcsim.detector.identifier.IIdentifierHelper; +import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.event.MCParticle; import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.geometry.Subdetector; +import org.lcsim.geometry.segmentation.SegmentationBase;
public class BaseSimCalorimeterHit extends BaseCalorimeterHit implements SimCalorimeterHit {
@@ -133,4 +143,13 @@
{ return particle.length; }
-}
+ + /** + * Set the metadata associated with this hit. By default, this will not override an existing value. + */ + public void setMetaData(LCMetaData meta) { + super.setMetaData(meta); + setupDetectorElement(); + } + +}
\ No newline at end of file
diff -u -r1.17 -r1.18 --- BaseSimTrackerHit.java 10 Jul 2012 00:11:24 -0000 1.17 +++ BaseSimTrackerHit.java 10 Jul 2012 19:57:14 -0000 1.18 @@ -14,7 +14,7 @@
/** * A concrete implementation of SimTrackerHit. * @author Jeremy McCormick
- * @version $Id: BaseSimTrackerHit.java,v 1.17 2012/07/10 00:11:24 jeremy Exp $
+ * @version $Id: BaseSimTrackerHit.java,v 1.18 2012/07/10 19:57:14 jeremy Exp $
*/ public class BaseSimTrackerHit extends BaseHitWithPosition implements SimTrackerHit {
@@ -85,6 +85,14 @@
this.de = de; }
+ /** + * Set the metadata associated with this hit. By default, this will not override an existing value. + */ + public void setMetaData(LCMetaData meta) { + super.setMetaData(meta); + findDetectorElementByIdentifier(); + } +
public void setTime(double time) { this.time = time; }
diff -u -r1.15 -r1.16 --- SIOCalorimeterHit.java 23 Mar 2011 16:36:55 -0000 1.15 +++ SIOCalorimeterHit.java 10 Jul 2012 19:57:14 -0000 1.16 @@ -12,7 +12,7 @@
* SIO-based I/O implementation of the CalorimeterHit interface * * @author Guilherme Lima
- * @version $Id: SIOCalorimeterHit.java,v 1.15 2011/03/23 16:36:55 tonyj Exp $
+ * @version $Id: SIOCalorimeterHit.java,v 1.16 2012/07/10 19:57:14 jeremy Exp $
*/ class SIOCalorimeterHit extends BaseCalorimeterHit {
@@ -37,6 +37,7 @@
position[0] = in.readFloat(); position[1] = in.readFloat(); position[2] = in.readFloat();
+ setPosition(position);
} if (version > 1002) {
diff -u -r1.11 -r1.12 --- SIOSimCalorimeterHit.java 24 Aug 2011 18:51:18 -0000 1.11 +++ SIOSimCalorimeterHit.java 10 Jul 2012 19:57:14 -0000 1.12 @@ -13,7 +13,7 @@
/** * @author Tony Johnson * @author Jeremy McCormick
- * @version $Id: SIOSimCalorimeterHit.java,v 1.11 2011/08/24 18:51:18 jeremy Exp $
+ * @version $Id: SIOSimCalorimeterHit.java,v 1.12 2012/07/10 19:57:14 jeremy Exp $
*/ public class SIOSimCalorimeterHit extends BaseSimCalorimeterHit {
@@ -36,6 +36,7 @@
position[0] = in.readFloat(); position[1] = in.readFloat(); position[2] = in.readFloat();
+ setPosition(position);
} nContributions = in.readInt(); particle = new Object[nContributions];
diff -u -r1.1 -r1.2 --- SimTrackerHitReadoutDriver_Test.java 10 Jul 2012 00:16:45 -0000 1.1 +++ SimTrackerHitReadoutDriver_Test.java 10 Jul 2012 19:57:14 -0000 1.2 @@ -17,7 +17,7 @@
/** * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: SimTrackerHitReadoutDriver_Test.java,v 1.1 2012/07/10 00:16:45 jeremy Exp $
+ * @version $Id: SimTrackerHitReadoutDriver_Test.java,v 1.2 2012/07/10 19:57:14 jeremy Exp $
*/ public class SimTrackerHitReadoutDriver_Test extends TestCase {
@@ -25,7 +25,7 @@
public void testMe() throws Exception { FileCache cache = new FileCache();
- cache.setCacheDirectory(new File("."));
+ cache.setCacheDirectory(new File(".testdata"));
File file = cache.getCachedFile(new URL(url)); LCSimLoop loop = new LCSimLoop(); loop.setLCIORecordSource(file);
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