LISTSERV mailing list manager LISTSERV 16.5

Help for LCDET-SVN Archives


LCDET-SVN Archives

LCDET-SVN Archives


LCDET-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

LCDET-SVN Home

LCDET-SVN Home

LCDET-SVN  February 2015

LCDET-SVN February 2015

Subject:

r3524 - in /projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base: BaseCalorimeterHit.java BaseHit.java BaseSimTrackerHit.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the lcdet svn repository <[log in to unmask]>

Date:

Tue, 10 Feb 2015 23:24:29 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (207 lines)

Author: [log in to unmask]
Date: Tue Feb 10 15:24:24 2015
New Revision: 3524

Log:
Small improvements to how position and geometry is found for hits.

Modified:
    projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseCalorimeterHit.java
    projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseHit.java
    projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseSimTrackerHit.java

Modified: projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseCalorimeterHit.java
 =============================================================================
--- projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseCalorimeterHit.java	(original)
+++ projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseCalorimeterHit.java	Tue Feb 10 15:24:24 2015
@@ -84,10 +84,6 @@
     public double getEnergyError() {
         return energyError;
     }
-
-    public IDetectorElement getDetectorElement() {
-        return detectorElement;
-    }
              
     protected void calculateCorrectedEnergy() {
         getIDDecoder().setID(id);

Modified: projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseHit.java
 =============================================================================
--- projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseHit.java	(original)
+++ projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseHit.java	Tue Feb 10 15:24:24 2015
@@ -42,21 +42,8 @@
      * Set the metadata associated with this hit.
      */
     public void setMetaData(LCMetaData meta) {
-        
-        this.metaData = meta;        
-        
-        if (this.detectorElement == null) {
-            // If the DE is not set yet, try to look it up by ID (might be null).
-            detectorElement = findDetectorElement(getIdentifier());
-        }
-        
-        // Calculate the position of the hit.  Might use DE.
-        calculatePosition();
-        
-        if (this.detectorElement == null) {
-            // If DE is still null, attempt to find it from the position.
-            detectorElement = findDetectorElement(positionVec);
-        }
+                
+        this.metaData = meta;               
     }
     
     /**
@@ -72,6 +59,18 @@
      * @return The IDetectorElement for this hit.
      */
     public IDetectorElement getDetectorElement() {
+        if (detectorElement == null) {
+            // Attempt to lookup the geometry using this exact ID.
+            detectorElement = findDetectorElement(getIdentifier());
+            if (detectorElement == null) {
+                // Presumably if the ID lookup fails, this means it has non-geometric fields,
+                // so use the global position instead.
+                if (getPositionVec() != null) {
+                    detectorElement = findDetectorElement(getPositionVec());
+                }                
+                // Just leave it as null!
+            }
+        }
         return detectorElement;
     }
     
@@ -79,7 +78,6 @@
      * Set the @see org.lcsim.detector.IDetectorElement of this hit. By default, this will not override an
      * existing value.
      */
-    // FIXME: This probably should not be in the public API.  Where is this actually called from?
     public void setDetectorElement(IDetectorElement de) {
         this.detectorElement = de;        
     }
@@ -164,6 +162,9 @@
      * @return The position of this hit as a double array of size 3.
      */
     public double[] getPosition() {
+        if (positionVec == null) {
+            calculatePosition();
+        }
         return positionVec.v();
     }
     
@@ -181,8 +182,8 @@
     protected void calculatePosition() { 
         // Was there no position information provided explicitly? 
         if (positionVec == null) {                 
-            // Does the hit ID match the DetectorElement exatly?
-            if (this.detectorElement != null && this.detectorElement.getIdentifier().equals(getIdentifier())) {
+            // Does the hit ID match the DetectorElement exactly?
+            if (this.detectorElement != null && detectorElement.getIdentifier().equals(getIdentifier())) {
                 // Set the position from the DetectorElement.
                 this.positionVec = detectorElement.getGeometry().getPosition();
             } else {
@@ -198,46 +199,49 @@
             }
         }
     }
-    
-    /**
-     * Find a DetectorElement by global position.
-     * @param position The global position.
-     * @return The DetectorElement at position.
-     */
-    private IDetectorElement findDetectorElement(Hep3Vector position) {
+            
+    /**
+     * Find a DetectorElement by its identifier.
+     * @param id The identifier.
+     * @return The DetectorElement matching the identifier.
+     */
+    protected IDetectorElement findDetectorElement(IIdentifier id) {
         IDetectorElement mommy = null;
         if (this.metaData != null) {
             // Use subdetector's volume as top.
             mommy = this.getIDDecoder().getSubdetector().getDetectorElement();
         } 
         if (mommy == null) {
-            // Use the world volume.
-            mommy = ((DetectorElement) DetectorElementStore.getInstance().get(0)).getTop().findDetectorElement(getPositionVec());
-        }            
-        return mommy.findDetectorElement(this.positionVec);       
-    }
-    
-    /**
-     * Find a DetectorElement by its identifier.
-     * @param id The identifier.
-     * @return The DetectorElement matching the identifier.
-     */
-    private IDetectorElement findDetectorElement(IIdentifier id) {
-        IDetectorElement mommy = null;
-        if (this.metaData != null) {
-            // Use subdetector's volume as top.
-            mommy = this.getIDDecoder().getSubdetector().getDetectorElement();
-        } 
-        if (mommy == null) {
-            // Use the world volume.
+            // Use the world volume as top.
             mommy = ((DetectorElement) DetectorElementStore.getInstance().get(0)).getTop();
         }       
+        
+        // Find DetectorElements with exactly matching ID.
         IDetectorElementContainer detectorElements = mommy.findDetectorElement(id);
-        // FIXME: Beware! The container can be null, which should be fixed at some point (detector-framework).
+        
+        // FIXME: Beware! The container itself can be null, which should be fixed (detector-framework).
         if (detectorElements != null && detectorElements.size() == 1) {
             return detectorElements.get(0); 
         } else {
             return null;
         }
     }
-}
+    
+    /**
+     * Find a DetectorElement by its global Cartesian position.
+     * @param position The position.
+     * @return The DetectorElement at the position.
+     */
+    protected IDetectorElement findDetectorElement(Hep3Vector position) {                                                                                     
+        IDetectorElement mommy = null;                                                                                                                      
+        if (this.metaData != null) {                                                                                                                        
+            // Use subdetector's volume as top.                                                                                                             
+            mommy = this.getIDDecoder().getSubdetector().getDetectorElement();                                                                              
+        }                                                                                                                                                   
+        if (mommy == null) {                                                                                                                                
+            // Use the world volume.                                                                                                                        
+            mommy = ((DetectorElement) DetectorElementStore.getInstance().get(0)).getTop().findDetectorElement(getPositionVec());                           
+        }                                                                                                                                                   
+        return mommy.findDetectorElement(this.positionVec);                                                                                                 
+    }
+}

Modified: projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseSimTrackerHit.java
 =============================================================================
--- projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseSimTrackerHit.java	(original)
+++ projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseSimTrackerHit.java	Tue Feb 10 15:24:24 2015
@@ -156,7 +156,11 @@
      * Get the {@see org.lcsim.detector.IDetectorElement} associated with this hit.     
      * @return The IDetectorElement for this hit.
      */
-    public IDetectorElement getDetectorElement() {
+    public IDetectorElement getDetectorElement() {        
+        if (detectorElement == null) {
+            // By default, use the hit's position to lookup the geometry.
+            detectorElement = findDetectorElement(this.getPositionVec());
+        }        
         return detectorElement;
     }
 }

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use