LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-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

HPS-SVN Home

HPS-SVN Home

HPS-SVN  November 2015

HPS-SVN November 2015

Subject:

r3968 - in /java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl: GBLOutput.java GBLOutputDriver.java

From:

[log in to unmask]

Reply-To:

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

Date:

Wed, 18 Nov 2015 22:35:49 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (215 lines)

Author: [log in to unmask]
Date: Wed Nov 18 14:35:46 2015
New Revision: 3968

Log:
Fix MC truth processing.

Modified:
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java	Wed Nov 18 14:35:46 2015
@@ -58,7 +58,6 @@
     private final MaterialSupervisor materialManager;
     private final MultipleScattering _scattering;
     private final double _beamEnergy = 1.1; //GeV
-    private boolean AprimeEvent = false; // do extra checks
     private boolean hasXPlanes = false;
     private boolean addBeamspot = false;
     private double beamspotTiltZOverY = 0; //Math.PI/180* 15;
@@ -140,10 +139,6 @@
         }
     }
 
-    void setAPrimeEventFlag(boolean flag) {
-        this.AprimeEvent = flag;
-    }
-
     void setXPlaneFlag(boolean flag) {
         this.hasXPlanes = flag;
     }
@@ -170,25 +165,61 @@
 
         // Find the truth particle of the track
         MCParticle mcp = null;
-
+        MCParticle ap = null;
+        
+        // MC processing
         if (isMC) {
+            
+            // find the truth particle for this track
             mcp = getMatchedTruthParticle(trk);
 
+            // check if this is an A' event
+            for(MCParticle part : mcParticles) {
+                if(Math.abs(part.getPDGID()) == 622) {
+                    ap = part;
+                    break;
+                }
+            }
+            
             if (mcp == null) {
                 System.out.printf("%s: WARNING!! no truth particle found in event!\n", this.getClass().getSimpleName());
                 this.printMCParticles(mcParticles);
                 //System.exit(1);
-            } else if (_debug > 0) {
-                System.out.printf("%s: truth particle (pdgif %d ) found in event!\n", this.getClass().getSimpleName(), mcp.getPDGID());
-            }
-
-            if (AprimeEvent) {
-                checkAprimeTruth(mcp, mcParticles);
-            }
-        }
+            } else {
+                if (_debug > 0) System.out.printf("%s: truth particle (pdgif %d ) found in event!\n", this.getClass().getSimpleName(), mcp.getPDGID());
+
+                // If this is an A' event, do some more checks
+                if ( ap != null) {
+                    // A few MC files have broken links b/w parents-daughters
+                    // This causes the MC particle to come from the origin even if the decay happen somewhere else
+                    if(this.getAprimeDecayProducts(mcParticles).size()>0) {
+                        //do a full check
+                        checkAprimeTruth(mcp, mcParticles);
+                    }
+                }
+            }
+        }        
 
         // Get track parameters from MC particle 
-        HelicalTrackFit htfTruth = (isMC && mcp != null) ? TrackUtils.getHTF(mcp, -1.0 * this.bFieldVector.z()) : null;
+        HelicalTrackFit htfTruth = null;
+        
+        if( isMC && mcp != null) {
+            // check if we should be using a different origin than the particle tells us
+            Hep3Vector mcp_origin;
+            if( ap != null) {
+                // There is an A' here. Use its origin if different
+                if (_debug > 0) System.out.printf("%s: A' found with origin  %s compared to particle %s (diff: %s)\n", this.getClass().getSimpleName(), ap.getOrigin().toString(), mcp.getOrigin().toString(), VecOp.sub(ap.getOrigin(), mcp.getOrigin()).toString());
+                if(VecOp.sub(ap.getOrigin(), mcp.getOrigin()).magnitude() > 0.00001)
+                    mcp_origin = ap.getOrigin();
+                else
+                    mcp_origin = mcp.getOrigin();
+            } else {
+                // No A', use particle origin
+                mcp_origin = mcp.getOrigin();
+            }
+
+            htfTruth = TrackUtils.getHTF(mcp,mcp_origin, -1.0 * this.bFieldVector.z());
+        }
 
         // Use the truth helix as the initial track for GBL?
         //htf = htfTruth;
@@ -677,11 +708,53 @@
     }
 
     
+    
+    private List<MCParticle> getAprimeDecayProducts(List<MCParticle> mcParticles) {
+        List<MCParticle> pair = new ArrayList<MCParticle>();
+        for (MCParticle mcp : mcParticles) {
+            if (mcp.getGeneratorStatus() != MCParticle.FINAL_STATE) {
+                continue;
+            }
+            boolean hasAprimeParent = false;
+            for (MCParticle parent : mcp.getParents()) {
+                if (Math.abs(parent.getPDGID()) == 622) {
+                    hasAprimeParent = true;
+                }
+            }
+            if (hasAprimeParent) {
+                pair.add(mcp);
+            }
+        }
+        
+        return pair;
+
+    }
+
    
 
     private void checkAprimeTruth(MCParticle mcp, List<MCParticle> mcParticles) {
+        
         List<MCParticle> mcp_pair = getAprimeDecayProducts(mcParticles);
 
+        
+        if (mcp_pair.size() != 2) {
+            System.out.printf("%s: ERROR this event has %d mcp with 622 as parent!!??  \n", this.getClass().getSimpleName(), mcp_pair.size());
+            this.printMCParticles(mcParticles);
+            System.exit(1);
+        }
+        if (Math.abs(mcp_pair.get(0).getPDGID()) != 11 || Math.abs(mcp_pair.get(1).getPDGID()) != 11) {
+            System.out.printf("%s: ERROR decay products are not e+e-? \n", this.getClass().getSimpleName());
+            this.printMCParticles(mcParticles);
+            System.exit(1);
+        }
+        if (mcp_pair.get(0).getPDGID() * mcp_pair.get(1).getPDGID() > 0) {
+            System.out.printf("%s: ERROR decay products have the same sign? \n", this.getClass().getSimpleName());
+            this.printMCParticles(mcParticles);
+            System.exit(1);
+        }
+        
+        
+        
         if (_debug > 0) {
             double invMassTruth = Math.sqrt(Math.pow(mcp_pair.get(0).getEnergy() + mcp_pair.get(1).getEnergy(), 2) - VecOp.add(mcp_pair.get(0).getMomentum(), mcp_pair.get(1).getMomentum()).magnitudeSquared());
             double invMassTruthTrks = getInvMassTracks(TrackUtils.getHTF(mcp_pair.get(0), -1.0 * this.bFieldVector.z()), TrackUtils.getHTF(mcp_pair.get(1), -1.0 * this.bFieldVector.z()));
@@ -896,40 +969,6 @@
         return chi2.e(0, 0);
     }
 
-    private List<MCParticle> getAprimeDecayProducts(List<MCParticle> mcParticles) {
-        List<MCParticle> pair = new ArrayList<MCParticle>();
-        for (MCParticle mcp : mcParticles) {
-            if (mcp.getGeneratorStatus() != MCParticle.FINAL_STATE) {
-                continue;
-            }
-            boolean hasAprimeParent = false;
-            for (MCParticle parent : mcp.getParents()) {
-                if (Math.abs(parent.getPDGID()) == 622) {
-                    hasAprimeParent = true;
-                }
-            }
-            if (hasAprimeParent) {
-                pair.add(mcp);
-            }
-        }
-        if (pair.size() != 2) {
-            System.out.printf("%s: ERROR this event has %d mcp with 622 as parent!!??  \n", this.getClass().getSimpleName(), pair.size());
-            this.printMCParticles(mcParticles);
-            System.exit(1);
-        }
-        if (Math.abs(pair.get(0).getPDGID()) != 11 || Math.abs(pair.get(1).getPDGID()) != 11) {
-            System.out.printf("%s: ERROR decay products are not e+e-? \n", this.getClass().getSimpleName());
-            this.printMCParticles(mcParticles);
-            System.exit(1);
-        }
-        if (pair.get(0).getPDGID() * pair.get(1).getPDGID() > 0) {
-            System.out.printf("%s: ERROR decay products have the same sign? \n", this.getClass().getSimpleName());
-            this.printMCParticles(mcParticles);
-            System.exit(1);
-        }
-        return pair;
-
-    }
 
     private void printMCParticles(List<MCParticle> mcParticles) {
         System.out.printf("%s: printMCParticles \n", this.getClass().getSimpleName());

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java	Wed Nov 18 14:35:46 2015
@@ -79,7 +79,6 @@
         gbl = new GBLOutput(gblFileName, bfield); // if filename is empty no text file is written
         gbl.setDebug(_debug);
         gbl.buildModel(detector);
-        gbl.setAPrimeEventFlag(false);
         gbl.setXPlaneFlag(false);
         gbl.setAddBeamspot(addBeamspot);
         gbl.setBeamspotScatAngle(beamspotScatAngle);

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

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
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