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  May 2015

HPS-SVN May 2015

Subject:

r2876 - /java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java

From:

[log in to unmask]

Reply-To:

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

Date:

Sat, 2 May 2015 00:11:11 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (125 lines)

Author: [log in to unmask]
Date: Fri May  1 17:11:04 2015
New Revision: 2876

Log:
add track truth mc function. add debug option.

Modified:
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java	Fri May  1 17:11:04 2015
@@ -192,7 +192,7 @@
      * @return position at ECAL
      */
     public static Hep3Vector getTrackPositionAtEcal(Track track) {
-        return extrapolateTrack(track, BeamlineConstants.ECAL_FACE_TESTRUN);
+        return extrapolateTrack(track, BeamlineConstants.ECAL_FACE);
     }
 
     /**
@@ -663,8 +663,18 @@
      * @return helix object based on the MC particle
      */
     public static HelicalTrackFit getHTF(MCParticle mcp, double Bz) {
+        boolean debug = true;
+        if(debug) {
+            System.out.printf("getHTF\n");
+            System.out.printf("mcp org %s mc p %s\n",mcp.getOrigin().toString(),mcp.getMomentum().toString());
+        }
         Hep3Vector org = CoordinateTransformations.transformVectorToTracking(mcp.getOrigin());
         Hep3Vector p = CoordinateTransformations.transformVectorToTracking(mcp.getMomentum());
+
+        if(debug) {
+            System.out.printf("mcp org %s mc p %s (trans)\n",org.toString(),p.toString());
+        }
+
         // Move to x=0 if needed
         double targetX = BeamlineConstants.DIPOLE_EDGELOW_TESTRUN;
         if (org.x() < targetX) {
@@ -681,7 +691,9 @@
             // old.toString(),p.toString(),org.toString());
         }
 
-        // System.out.printf("outside org %s p %s \n",p.toString(),org.toString());
+        if(debug) {
+            System.out.printf("mcp org %s mc p %s (trans2)\n",org.toString(),p.toString());
+        }
 
         HelixParamCalculator helixParamCalculator = new HelixParamCalculator(p, org, -1 * ((int) mcp.getCharge()), Bz);
         double par[] = new double[5];
@@ -691,8 +703,8 @@
         par[HelicalTrackFit.curvatureIndex] = 1.0 / helixParamCalculator.getRadius();
         par[HelicalTrackFit.z0Index] = helixParamCalculator.getZ0();
         HelicalTrackFit htf = getHTF(par);
-        // System.out.printf("d0 %f z0 %f R %f phi %f lambda %s\n",
-        // htf.dca(),htf.z0(),htf.R(),htf.phi0(),htf.slope() );
+         System.out.printf("d0 %f z0 %f R %f phi %f lambda %s\n",
+         htf.dca(),htf.z0(),htf.R(),htf.phi0(),htf.slope() );
         return htf;
     }
 
@@ -735,5 +747,59 @@
         // System.out.printf("%s: straight line track: x0=%f,y0=%f,z0=%f dz/dx=%f dydx=%f targetY=%f targetZ=%f \n",this.getClass().getSimpleName(),slt1.x0(),slt1.y0(),slt1.z0(),slt1.dzdx(),slt1.dydx(),slt1.TargetYZ()[0],slt1.TargetYZ()[1]);
         return slt1;
     }
+    
+    
+    
+    public static MCParticle getMatchedTruthParticle(Track track) {
+        boolean debug = false;
+        
+        Map<MCParticle,Integer> particlesOnTrack = new HashMap<MCParticle,Integer>();
+        
+        if(debug) System.out.printf("getMatchedTruthParticle: getmatched mc particle from %d tracker hits on the track \n",track.getTrackerHits().size());
+        
+        
+        for(TrackerHit hit : track.getTrackerHits()) {
+            List<MCParticle> mcps = ((HelicalTrackHit)hit).getMCParticles();
+            if(mcps==null) {
+                System.out.printf("getMatchedTruthParticle: warning, this hit (layer %d pos=%s) has no mc particles.\n",((HelicalTrackHit)hit).Layer(),((HelicalTrackHit)hit).getCorrectedPosition().toString());
+            } 
+            else {
+                if( debug ) System.out.printf("getMatchedTruthParticle: this hit (layer %d pos=%s) has %d mc particles.\n",((HelicalTrackHit)hit).Layer(),((HelicalTrackHit)hit).getCorrectedPosition().toString(),mcps.size());
+                for(MCParticle mcp : mcps) {
+                    if( !particlesOnTrack.containsKey(mcp) ) {
+                        particlesOnTrack.put(mcp, 0);
+                    }
+                    int c = particlesOnTrack.get(mcp);
+                    particlesOnTrack.put(mcp, c+1);
+                }
+            }
+        }
+        if(debug) {
+            System.out.printf("Track p=[ %f, %f, %f] \n",track.getTrackStates().get(0).getMomentum()[0],track.getTrackStates().get(0).getMomentum()[1],track.getTrackStates().get(0).getMomentum()[1]);
+            System.out.printf("Found %d particles\n",particlesOnTrack.size());
+            for(Map.Entry<MCParticle, Integer> entry : particlesOnTrack.entrySet()) {
+                System.out.printf("%d hits assigned to %d p=%s \n",entry.getValue(),entry.getKey().getPDGID(),entry.getKey().getMomentum().toString());
+            }
+        }
+        Map.Entry<MCParticle,Integer> maxEntry = null;
+        for(Map.Entry<MCParticle,Integer> entry : particlesOnTrack.entrySet()) {
+            if ( maxEntry == null || entry.getValue().compareTo(maxEntry.getValue()) > 0 ) maxEntry = entry;
+            //if ( maxEntry != null ) {
+            //    if(entry.getValue().compareTo(maxEntry.getValue()) < 0) continue;
+            //}
+            //maxEntry = entry;
+        }
+        if(debug) {
+            if (maxEntry != null ) {
+                System.out.printf("Matched particle with pdgId=%d and mom %s to track with charge %d and momentum [%f %f %f]\n",
+                        maxEntry.getKey().getPDGID(),maxEntry.getKey().getMomentum().toString(),
+                        track.getCharge(),track.getTrackStates().get(0).getMomentum()[0],track.getTrackStates().get(0).getMomentum()[1],track.getTrackStates().get(0).getMomentum()[2]);
+            } else {
+                System.out.printf("No truth particle found on this track\n");
+            }
+        }
+        return maxEntry == null ? null : maxEntry.getKey();
+    }
+    
 
 }

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