Print

Print


Commit in lcsim/src/org/lcsim/contrib/seedtracker/analysis on MAIN
SeedTrackDiag.java+135added 1.1
HelixParamHistograms.java+177added 1.1
TrackHitHistograms.java+302added 1.1
+614
3 added files
Moved files into the folder from Pelham.Example1 folder to "complete" the analysis utils histogram package.

lcsim/src/org/lcsim/contrib/seedtracker/analysis
SeedTrackDiag.java added at 1.1
diff -N SeedTrackDiag.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SeedTrackDiag.java	13 Aug 2008 18:35:26 -0000	1.1
@@ -0,0 +1,135 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.seedtracker.analysis;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.lcsim.contrib.seedtracker.SeedCandidate;
+import org.lcsim.contrib.seedtracker.SeedLayer;
+import org.lcsim.contrib.seedtracker.SeedLayer.SeedType;
+import org.lcsim.contrib.seedtracker.analysis.AnalysisUtils;
+import org.lcsim.contrib.seedtracker.diagnostic.EmptySeedTrackerDiagnostics;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+import org.lcsim.fit.circle.CircleFit;
+import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+import org.lcsim.fit.helicaltrack.HelicalTrackFitter.FitStatus;
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+import org.lcsim.fit.line.SlopeInterceptLineFit;
+import org.lcsim.fit.zsegment.ZSegmentFit;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ *
+ * @author Pelham Keahey
+ */
+public class SeedTrackDiag extends EmptySeedTrackerDiagnostics{
+    AIDA aida = AIDA.defaultInstance();
+    //List of MCParticles
+    List<MCParticle> mcheck = new ArrayList<MCParticle>();
+    AnalysisUtils util = new AnalysisUtils();
+    @Override
+    public void setEvent(EventHeader event){
+        super.setEvent(event);
+        
+        
+    }
+    
+    @Override
+    /*
+     * Will print out all the information about tracks in the event that should have been found ,but weren't that met the cuts.
+     */
+    public void fireFitterFitMade(SeedCandidate seed, HelicalTrackFit hfit, CircleFit cfit, SlopeInterceptLineFit lfit, ZSegmentFit zfit, FitStatus fitStatus, boolean success) {
+      
+      List<MCParticle> temp = new ArrayList<MCParticle>();
+      if(fitStatus != FitStatus.Success )return;
+      if (success) return;
+      Set<MCParticle> mcps = new HashSet<MCParticle>();
+      Map<MCParticle,List<HelicalTrackHit>> hitmcmap = new HashMap<MCParticle,List<HelicalTrackHit>>();
+      List<String> idlist = new ArrayList<String>(); 
+      for (SeedLayer l : seed.getSeedStrategy().getLayers(SeedType.Seed)){
+          idlist.add(l.getDetName()+l.getLayer()+l.getBarrelEndcapFlag().toString());
+      }
+      ArrayList<HelicalTrackHit> seedlayerhits = new ArrayList<HelicalTrackHit>();
+      if(seedlayerhits.size()>0)System.out.println("Oh Snap");
+      for(HelicalTrackHit hito : seed.getHits()){
+          mcps.addAll(hito.getMCParticles());
+          if(idlist.contains(hito.getLayerIdentifier())){
+              seedlayerhits.add(hito);
+              for(MCParticle mcp : hito.getMCParticles()){
+              hitmcmap.put(mcp, seedlayerhits);
+              temp.add(mcp);
+              }
+          }                          
+      }
+      for (HelicalTrackHit h : seed.getHits()){
+          Iterator<MCParticle> iter = mcps.iterator();
+          while (iter.hasNext()){
+              MCParticle next = iter.next(); 
+              if (!h.getMCParticles().contains(next)){
+                  //System.out.println(mcps.toString());
+                  iter.remove();
+              }
+          }
+      }
+      if(mcps.isEmpty())return;
+      /*//Check method to see if you are getting the right mc particles in the list
+      List<MCParticle> testlist = util.FindMCParticleInAllHits(seed.getHits());
+      if(testlist.containsAll(temp)){System.out.println("true");}*/
+   /*   for (HelicalTrackHit h : seed.getHits()) {
+          //hitmcmap.get(h).addAll(h.getMCParticles());
+          mcps.addAll(h.getMCParticles());
+      }
+       
+      
+      
+      }*/
+     double costheta = 1/(Math.sqrt(1+((Math.pow(1/hfit.slope(), 2)))));
+     if(hfit.pT(5)>1.1 && Math.abs(hfit.dca()) < 9 && Math.abs(hfit.z0()) < 9 && Math.abs(costheta) < 0.985 ){
+              for(MCParticle mcp : mcps){
+                  boolean flag = true;
+                  if(hitmcmap.containsKey(mcp)){
+                      if(mcheck.contains(mcp)){
+                          flag = false;
+                          break;
+                      }
+                      else{
+                          mcheck.add(mcp);
+                      }
+                      if(flag){
+                      System.out.println("From SeedTrackerDig Tool");
+                      System.out.println("P:"+mcp.getMomentum().toString());
+                      System.out.println("Endpoint:"+mcp.getEndPoint().toString());
+                      System.out.print("SeedlayerHits: ");
+                      for(HelicalTrackHit seedhit : hitmcmap.get(mcp)){
+                      System.out.print(seedhit.getLayerIdentifier()+"(time: "+seedhit.getTime()+")");
+                      System.out.print("("+seedhit.getPosition()[0]+",");
+                      System.out.print(seedhit.getPosition()[1]+",");
+                      System.out.println(+seedhit.getPosition()[2]+")");
+                      }
+                      System.out.println("chisq0: "+hfit.chisq()[0]);
+                      System.out.println("chisq1: "+hfit.chisq()[1]);
+                      System.out.println("chisqtotal: "+hfit.chisqtot());
+                      System.out.println();
+                      aida.histogram1D("Efficiency/NoNHit/Has Fit Missed chsq:",200,0,2).fill(1);
+                      }
+                  }  
+              }
+       
+              
+       /*for(HelicalTrackHit h : seed.getHits()){
+                aida.histogram1D("Efficiency/NoNHit/scattering/"+h.getLayerIdentifier(),200,-10,10).fill(+h.dr());
+                aida.histogram1D("Efficiency/NoNHit/scattering/"+h.getLayerIdentifier(),200,-10,10).fill(+h.drphi());
+        }*/
+      }
+    }  
+  }
+

lcsim/src/org/lcsim/contrib/seedtracker/analysis
HelixParamHistograms.java added at 1.1
diff -N HelixParamHistograms.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HelixParamHistograms.java	13 Aug 2008 18:35:26 -0000	1.1
@@ -0,0 +1,177 @@
+package org.lcsim.contrib.seedtracker.analysis;
+
+
+import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.aida.AIDA;
+import org.lcsim.contrib.seedtracker.analysis.HelixParamCalculator;
+
+/**
+ *
+ * @author Pelham Keahey
+ * Thursday, July 3rd 2008
+ */
+public class HelixParamHistograms {
+    //helix from mc partcle  for layer hit 1st
+    //simtracker hit where is nrg
+    //pos from tracker hit 2nd
+    //compare fitted helix to mcparticle hits r phi z
+    private AIDA aida = AIDA.defaultInstance();
+    //Histrogram Variables
+    private double datom,dtl,ddca,dphi0,dz,dm,dtm;
+    private double mcom,mctl,mcdca,mcphi0,mcz,mcm,mctm;
+    //Error Variables
+    private double  curverror,sloperror,dcaerror,phi0error,z0error;
+       
+    //Constructor for Histrogram Drawer, Calculations done inside as well
+    public HelixParamHistograms(HelicalTrackFit fit,MCParticle mcp,EventHeader event)
+    {
+            
+           
+            HelixParamCalculator calc = new HelixParamCalculator(mcp,event);
+            //************ Data Calculations for MOMENTUM, OMEGA, TRANS. MOMENTUM *********
+            dm    = fit.p(calc.getMagField());
+            datom = fit.curvature();
+            dtm   = fit.pT(calc.getMagField());
+            
+            
+            //************* MCParticles Calculations for MOMENTUM, OMEGA, TRANS. MOMENTUM ******
+            mcm  = calc.getMCMomentum();
+            mcom = calc.getMCOmega();
+            mctm = calc.getMCTransverseMomentum();
+           
+            
+            //************ Tan Lamda Calculations tanL tsnL tan L *************    
+            dtl  = fit.slope();
+            mctl = calc.getSlopeSZPlane();
+            
+            
+            //************ DCA Calculations DCA DCA DCA DCA DCA DCA *************
+            ddca = fit.dca();
+            mcdca = calc.getDCA();
+            
+                      
+            //******* phi0 Calculation phi0 phi0 phi0 phi0 ******************
+            dphi0  = fit.phi0();
+            mcphi0 = calc.getPhi0();
+           
+                        
+            //******* z0 Calculations z0 z0 z0 z0 z0 z0 z0 ************************
+            dz = fit.z0();
+            mcz= calc.getZ0();
+            
+            
+            //Get error for calculating the pull
+            curverror = fit.getCurveError();
+            sloperror = fit.getSlopeError();
+            dcaerror  = fit.getDcaError();
+            phi0error = fit.getPhi0Error();
+            z0error   = fit.getZ0Error();
+
+            
+    }
+    public void DrawDataPositive()
+    {
+             
+        aida.histogram1D("HelixParam/1Dat-Positive/Omega", 300, -1*Math.pow(10, -3), Math.pow(10,-3)).fill(datom);
+        aida.histogram1D("HelixParam/1Dat-Positive/tanL", 200, -8., 8.).fill(dtl);
+        aida.histogram1D("HelixParam/1Dat-Positive/DCA", 200, -.1, .1).fill(ddca);
+        aida.histogram1D("HelixParam/1Dat-Positive/phi0", 200, -1., 3*Math.PI).fill(dphi0);
+        aida.histogram1D("HelixParam/1Dat-Positive/z0" , 200, -.1, .1).fill(dz);
+        aida.histogram1D("HelixParam/1Dat-Positive/Momentum", 200, 0., 200.).fill(dm);
+        aida.histogram1D("HelixParam/1Dat-Positive/Trans.Momentum", 200, 0., 150.).fill(dtm);
+    }  
+    public void DrawDataNegative()
+    {
+        aida.histogram1D("HelixParam/2Dat-Negative/Omega", 300, -1*Math.pow(10, -3), Math.pow(10,-3)).fill(datom);
+        aida.histogram1D("HelixParam/2Dat-Negative/tanL", 200, -8., 8.).fill(dtl);
+        aida.histogram1D("HelixParam/2Dat-Negative/DCA", 200, -.1, .1).fill(ddca);
+        aida.histogram1D("HelixParam/2Dat-Negative/phi0", 200, -1., 3*Math.PI).fill(dphi0);
+        aida.histogram1D("HelixParam/2Dat-Negative/z0" , 200, -.1, .1).fill(dz);
+        aida.histogram1D("HelixParam/2Dat-Negative/Momentum", 200, 0., 200.).fill(dm);
+        aida.histogram1D("HelixParam/2Dat-Negative/Trans.Momentum", 200, 0., 150.).fill(dtm);
+    }
+    public void DrawMCPositive()
+    {
+        
+        aida.histogram1D("HelixParam/3MC-Positive/Omega", 300, -1*Math.pow(10, -3), Math.pow(10,-3)).fill(mcom);
+        aida.histogram1D("HelixParam/3MC-Positive/tanL", 200, -8., 8.).fill(mctl);
+        aida.histogram1D("HelixParam/3MC-Positive/DCA", 200, -.01, .01).fill(mcdca);
+        aida.histogram1D("HelixParam/3MC-Positive/phi0", 200, -1., 3*Math.PI).fill(mcphi0);
+        aida.histogram1D("HelixParam/3MC-Positive/z0" , 200, -.001, .001).fill(mcz);
+        aida.histogram1D("HelixParam/3MC-Positive/Momentum", 200, 0., 200.).fill(mcm);  
+        aida.histogram1D("HelixParam/3MC-Positive/Trans.Momentum", 200, 0., 150.).fill(mctm);
+    }
+    public void DrawMCNegative()
+    {
+        aida.histogram1D("HelixParam/4MC-Negative/Omega", 300, -1*Math.pow(10, -3), Math.pow(10,-3)).fill(mcom);                 
+        aida.histogram1D("HelixParam/4MC-Negative/tanL", 200, -8., 8.).fill(mctl);
+        aida.histogram1D("HelixParam/4MC-Negative/DCA", 200, -.01, .01).fill(mcdca);
+        aida.histogram1D("HelixParam/4MC-Negative/phi0", 200, -1., 3*Math.PI).fill(mcphi0);
+        aida.histogram1D("HelixParam/4MC-Negative/z0" , 200, -.001, .001).fill(mcz);
+        aida.histogram1D("HelixParam/4MC-Negative/Momentum", 200, 0., 200.).fill(mcm);  
+        aida.histogram1D("HelixParam/4MC-Negative/Trans.Momentum", 200, 0., 150.).fill(mctm);
+        
+    }
+    public void DrawResidualPositive()
+    {
+        aida.histogram1D("HelixParam/Residual-Positive/Momentum"      , 200,                -10., 10.).fill(dm-mcm);  
+        aida.histogram1D("HelixParam/Residual-Positive/Trans.Momentum", 200,                 -5., 5.).fill(dtm-mctm); 
+        aida.histogram1D("HelixParam/Residual-Positive/Omega"         , 300, -5*Math.pow(10, -6), 5*Math.pow(10,-6)).fill(datom-mcom);
+        aida.histogram1D("HelixParam/Residual-Positive/tanL"          , 300,                -.01, .01).fill(dtl-mctl);
+        aida.histogram1D("HelixParam/Residual-Positive/DCA"           , 200,                 -.1, .1).fill(ddca-mcdca);   
+        aida.histogram1D("HelixParam/Residual-Positive/phi0"          , 200,               -.002, .002).fill(dphi0-mcphi0);
+        aida.histogram1D("HelixParam/Residual-Positive/z0"            , 200,                 -.1, .1).fill(dz-mcz);
+        
+    }
+    public void DrawResidualNegative()
+    {
+        aida.histogram1D("HelixParam/Residual-Negative/Momentum"      , 200,                -10., 10.).fill(dm-mcm);  
+        aida.histogram1D("HelixParam/Residual-Negative/Trans.Momentum", 200,                 -5., 5.).fill(dtm-mctm); 
+        aida.histogram1D("HelixParam/Residual-Negative/Omega"         , 300, -5*Math.pow(10, -6), 5*Math.pow(10,-6)).fill(datom-mcom);
+        aida.histogram1D("HelixParam/Residual-Negative/tanL"          , 300,                -.01, .01).fill(dtl-mctl);
+        aida.histogram1D("HelixParam/Residual-Negative/DCA"           , 200,                 -.1, .1).fill(ddca-mcdca);   
+        aida.histogram1D("HelixParam/Residual-Negative/phi0"          , 200,               -.002, .002).fill(dphi0-mcphi0);
+        aida.histogram1D("HelixParam/Residual-Negative/z0"            , 200,                 -.1, .1).fill(dz-mcz);
+        
+    }
+    public void DrawResidual()
+    {
+        aida.histogram1D("HelixParam/Residual-both/Momentum"      , 200,                -10., 10.).fill(dm-mcm);  
+        aida.histogram1D("HelixParam/Residual-both/Trans.Momentum", 200,                 -5., 5.).fill(dtm-mctm); 
+        aida.histogram1D("HelixParam/Residual-both/Omega"         , 300, -5*Math.pow(10, -6), 5*Math.pow(10,-6)).fill(datom-mcom);
+        aida.histogram1D("HelixParam/Residual-both/tanL"          , 300,                -.01, .01).fill(dtl-mctl);
+        aida.histogram1D("HelixParam/Residual-both/DCA"           , 200,                 -.1, .1).fill(ddca-mcdca);   
+        aida.histogram1D("HelixParam/Residual-both/phi0"          , 200,               -.002, .002).fill(dphi0-mcphi0);
+        aida.histogram1D("HelixParam/Residual-both/z0"            , 200,                 -.1, .1).fill(dz-mcz);
+        
+    }
+    public void DrawPullPositive()
+    {
+        aida.histogram1D("HelixParam/Pull-Positive/Omega", 300, -10, 10).fill((datom-mcom)/curverror);
+        aida.histogram1D("HelixParam/Pull-Positive/tanL" , 300, -11, 11).fill((dtl-mctl)/sloperror);
+        aida.histogram1D("HelixParam/Pull-Positive/dca"  , 300, -10, 10).fill((ddca-mcdca)/dcaerror);
+        aida.histogram1D("HelixParam/Pull-Positive/phi0" , 300, -11, 11).fill((dphi0-mcphi0)/phi0error);
+        aida.histogram1D("HelixParam/Pull-Positive/z0"   , 300, -50, 50).fill((dz-mcz)/z0error);
+        
+    }
+    public void DrawPullNegative()
+    {
+        aida.histogram1D("HelixParam/Pull-Negative/Omega", 300, -10, 10).fill((datom-mcom)/curverror);
+        aida.histogram1D("HelixParam/Pull-Negative/tanL" , 300, -11, 11).fill((dtl-mctl)/sloperror);
+        aida.histogram1D("HelixParam/Pull-Negative/dca"  , 300, -10, 10).fill((ddca-mcdca)/dcaerror);
+        aida.histogram1D("HelixParam/Pull-Negative/phi0" , 300, -11, 11).fill((dphi0-mcphi0)/phi0error);
+        aida.histogram1D("HelixParam/Pull-Negative/z0"   , 300, -50, 50).fill((dz-mcz)/z0error);
+    }
+    public void DrawPull()
+    {
+        aida.histogram1D("HelixParam/Pull-Both/Omega", 300, -10, 10).fill((datom-mcom)/curverror);
+        aida.histogram1D("HelixParam/Pull-Both/tanL" , 300, -11, 11).fill((dtl-mctl)/sloperror);
+        aida.histogram1D("HelixParam/Pull-Both/dca "  , 300, -10, 10).fill((ddca-mcdca)/dcaerror);
+        aida.histogram1D("HelixParam/Pull-Both/phi0" , 300, -11, 11).fill((dphi0-mcphi0)/phi0error);
+        aida.histogram1D("HelixParam/Pull-Both/z0  "   , 300, -50, 50).fill((dz-mcz)/z0error);
+    }
+    
+    
+}

lcsim/src/org/lcsim/contrib/seedtracker/analysis
TrackHitHistograms.java added at 1.1
diff -N TrackHitHistograms.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrackHitHistograms.java	13 Aug 2008 18:35:26 -0000	1.1
@@ -0,0 +1,302 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.seedtracker.analysis;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.VecOp;
+import java.util.ArrayList;
+import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.EventHeader;
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+import org.lcsim.contrib.seedtracker.analysis.HelixParamCalculator;
+import org.lcsim.util.aida.AIDA;
+import java.util.List;
+import org.lcsim.event.SimTrackerHit;
+import org.lcsim.fit.helicaltrack.HelicalTrackCross;
+import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
+import org.lcsim.fit.helicaltrack.HelixUtils;
+
+/**
+ *
+ * @author Pelham Keahey
+ */
+public class TrackHitHistograms {
+   
+    private AIDA aida = AIDA.defaultInstance();
+    private double phi,r,z;
+    private double phih,rh,zh;
+    private double simr,simz,simphi;
+    HelicalTrackFit fit;
+    MCParticle mcp;
+    EventHeader event;
+    List<HelicalTrackHit> hitlist;
+    
+    /**
+     * 
+     * @param pfit HelicalTrackfit
+     * @param pmcp MCParticle
+     * @param pevent EventHeader
+     * @param phit List of Hits
+     */
+    public TrackHitHistograms(HelicalTrackFit pfit, MCParticle pmcp,EventHeader pevent)
+    {
+        fit=pfit;
+        mcp=pmcp;
+        event = pevent;
+        hitlist = event.get(HelicalTrackHit.class,"HelicalTrackHits");
+       
+        
+    }/**
+      * 
+      * Calculates the hit locations in polar coordinates and displays residual histograms between the hit locations from the mcparticle
+      * and the helicaltrackhits
+     */
+    public void drawMCParticlevHelicalTrackHit()
+    {
+        HelixParamCalculator calc = new HelixParamCalculator(mcp, event);
+        
+        for(HelicalTrackHit hit : hitlist)
+          {
+ 
+            //Calculations for MC particle
+            
+            //find x0,y0 coordinates
+            double x0 = calc.getX0();
+            double y0 = calc.getY0();
+           
+            //find the pathlength of the helix directly from the hit
+            double pathlength=0;
+            double closer=999999999,difference;
+            
+            List<Double> listd;
+            HelixUtils util = new HelixUtils();
+            if(hit.BarrelEndcapFlag().isBarrel()){
+                listd = util.PathToCylinder(fit, hit.r(), 5000, 10);
+                closer = 999999999;
+                if(!listd.isEmpty()){
+                pathlength = listd.get(0);
+                }
+                for(double temp : listd){
+                    BasicHep3Vector tempvec = (BasicHep3Vector) util.PointOnHelix(fit, temp);
+                    difference = Math.abs(hit.z()-tempvec.z());
+                    if(difference<closer){
+                        closer = difference;
+                        pathlength = temp;
+                    }
+                }
+                                
+            }
+            else{
+                pathlength = util.PathToZPlane(fit, hit.z());
+            }
+            
+            //varible for easier calculation temp = C*s/2
+            double temp = ((calc.getMCOmega()*pathlength)/2);
+ 
+            //find x,y coordinates
+            double x = x0 + (((pathlength*Math.sin(temp))/temp)*Math.cos(calc.getPhi0()-temp));
+            double y = y0 + (((pathlength*Math.sin(temp))/temp)*Math.sin(calc.getPhi0()-temp));
+            
+            //Find MC phi, MC radius (r), MC z coordinate EDIT
+            phi = Math.atan2(y, x);
+                if(phi<0)
+                {
+                phi+=2*Math.PI;
+                }
+            r = Math.sqrt(x*x + y*y);
+            z = calc.getZ0() + pathlength*calc.getSlopeSZPlane();
+            
+            //Calculations directly from hit
+            
+            //Calculations directly from HelicalTrackHit 
+            phih = hit.phi();
+            rh = hit.r();
+            zh = hit.z();
+
+        if(hit.getLayerIdentifier().contains("Tracker"))
+            {
+                 if(hit.BarrelEndcapFlag().isBarrel())
+                    {
+                        
+                        //Residual Histograms
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Tracker/Barrel/r*phi/r*phi-"+hit.getLayerIdentifier(), 200, -25, 25).fill((r*phi)-(rh*phih));
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Tracker/Barrel/R/R-"+hit.getLayerIdentifier()  , 200, -.1,.1).fill(r-rh);
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Tracker/Barrel/Z/Z-"+hit.getLayerIdentifier()  , 200, -55,55).fill(z-zh);
+                    } 
+            }
+        if(hit.getLayerIdentifier().contains("Tracker"))
+            {
+                if(hit.BarrelEndcapFlag().isEndcap())
+                    {
+                        
+                        //Residual Histograms
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Tracker/EndCap/r*phi/r*phi-"+hit.getLayerIdentifier(), 200, -25, 25).fill((r*phi)-(rh*phih));
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Tracker/EndCap/R/R-"+hit.getLayerIdentifier()  , 200, -.1,.1).fill(r-rh);
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Tracker/EndCap/Z/Z-"+hit.getLayerIdentifier()  , 200, -5,5).fill(z-zh);
+                    }
+            }
+        if(hit.getLayerIdentifier().contains("Vertex"))
+            {
+                  if(hit.BarrelEndcapFlag().isBarrel())
+                     {
+                      
+                         //Residual Histograms
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Vertex/Barrel/r*phi/r*phi-"+hit.getLayerIdentifier(), 200, -.5, .5).fill((r*phi)-(rh*phih));
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Vertex/Barrel/R/R-"+hit.getLayerIdentifier()  , 200, -.1,.1).fill(r-rh);
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Vertex/Barrel/Z/Z-"+hit.getLayerIdentifier()  , 200, -55,55).fill(z-zh);
+                     }
+            }
+        if(hit.getLayerIdentifier().contains("Vertex"))
+            {
+                  if(hit.BarrelEndcapFlag().isEndcap())
+                     {
+                      
+                         //Residual Histograms
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Vertex/EndCap/r*phi/r*phi-"+hit.getLayerIdentifier(), 200, -30, 30).fill((r*phi)-(rh*phih));
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Vertex/EndCap/R/R-"+hit.getLayerIdentifier()  , 200, -.1,.1).fill(r-rh);
+                        aida.histogram1D("MCParticleVSHelicalTrackFit/Residual-Vertex/EndCap/Z/Z-"+hit.getLayerIdentifier()  , 200, -55,55).fill(z-zh);
+                     }
+            }
+        }
+    }
+    /*
+     * Calculates the hits in polar and displays the residual histograms of simtrackerhits from helicaltrackhits
+     */
+    public void drawSimTrackervHelicalTrack()
+    {
+        
+        List<SimTrackerHit> simhitlist = new ArrayList<SimTrackerHit>();
+            
+            for(List<SimTrackerHit> l : event.get(SimTrackerHit.class))
+             {
+                 simhitlist.addAll(l);
+             }
+            
+            double [] alld;
+            double distancex,distancey,distancez;
+            double closest=999999999,testclose;
+            double zstripdiff;
+            double closestdiff;
+            double smallres;
+            double us,resunmeas;
+            
+            
+            for(HelicalTrackHit hit : hitlist)
+            {
+                if(hit instanceof HelicalTrackCross)
+                {
+                   smallres = 999999999;
+                   HelicalTrackCross cross = (HelicalTrackCross) hit;
+                       
+                   for(HelicalTrackStrip strip : cross.getStrips())
+                    {
+                       SimTrackerHit closesthit =null;
+                       closestdiff = 999999999;
+                     for(SimTrackerHit simhit : simhitlist)
+                     {
+                        BasicHep3Vector simclose = new BasicHep3Vector(simhit.getPoint());
+                        zstripdiff = Math.abs(simclose.z()- strip.origin().z());
+                         if(zstripdiff<closestdiff)
+                         {
+                            closestdiff = zstripdiff;
+                            closesthit = simhit;
+                         }
+                        
+                     }
+                        BasicHep3Vector closesthitvec = new BasicHep3Vector(closesthit.getPoint());
+                        BasicHep3Vector diffvector = new BasicHep3Vector();
+                        diffvector = (BasicHep3Vector) VecOp.sub(closesthitvec, strip.origin());
+                        us = VecOp.dot(diffvector, strip.u());
+                        resunmeas = strip.umeas() - us;
+                        if(resunmeas<smallres)
+                        {
+                            smallres = resunmeas;
+                        }
+                        aida.histogram1D("Unmeasured/EndCaps/"+Math.round(strip.origin().z())+":ZPOS Unmeasured Strip ", 200, -1,1).fill(smallres);
+                        
+                    }
+                 }
+             }
+             for(HelicalTrackHit hit : hitlist)
+             {
+                SimTrackerHit hitholder = null;
+                closest = 999999999;
+                 for(SimTrackerHit simhit : simhitlist)
+                 {
+                    
+                    //Search for the closest points
+                    alld = simhit.getPoint();
+                    distancex = hit.x()-alld[0];
+                    distancey = hit.y()-alld[1];
+                    distancez = hit.z()-alld[2];
+                    testclose = Math.sqrt((distancex*distancex) + (distancey*distancey)+(distancez*distancez));
+                    if(testclose<closest)
+                        {
+                        closest=testclose;
+                        hitholder = simhit;
+                        }
+                    
+                   
+                 }
+                    if(hitholder==null)break;
+                    alld = hitholder.getPoint();
+                    simr = Math.sqrt((alld[0]*alld[0])+(alld[1]*alld[1]));
+                    simz = alld[2];
+                    simphi = Math.atan2(alld[1], alld[0]);
+                    if(simphi<0)
+                        {
+                            simphi+=2*Math.PI;
+                        }
+                    
+                      rh   = hit.r();
+                      zh   = hit.z();
+                      phih = hit.phi();
+          
+          if(hit.getLayerIdentifier().contains("Tracker"))
+          {
+                 
+                 if(hit.BarrelEndcapFlag().isBarrel())
+                    {
+                         //Residual Histograms: SimTrackerHit - HelicalTrackHit
+                         aida.histogram1D("SimTrackerVSHelicalTrack/Tracker/Barrel/Residual/r*phi/R*Phi"+hit.getLayerIdentifier(), 200, -1,1).fill((simr*simphi)-(rh*phih));
+                         aida.histogram1D("SimTrackerVSHelicalTrack/Tracker/Barrel/Residual/R/R"+hit.getLayerIdentifier(), 200, -.5,.5).fill(simr-rh);
+                         aida.histogram1D("SimTrackerVSHelicalTrack/Tracker/Barrel/Residual/Z/Z"+hit.getLayerIdentifier(), 200, -55,55).fill(simz-zh);
+                    }
+                 
+                 else
+                    {
+                        //Residual Histograms: SimTrackerHit - HelicalTrackHit
+                        aida.histogram1D("SimTrackerVSHelicalTrack/Tracker/Endcap/Residual/r*phi/R*Phi"+hit.getLayerIdentifier(), 200, -10, 10).fill((simr*simphi)-(rh*phih));
+                        aida.histogram1D("SimTrackerVSHelicalTrack/Tracker/Endcap/Residual/R/R"+hit.getLayerIdentifier(), 200, -3,3).fill(simr-rh);
+                        aida.histogram1D("SimTrackerVSHelicalTrack/Tracker/Endcap/Residual/Z/Z"+hit.getLayerIdentifier(), 200, -3,3).fill(simz-zh);
+                     }
+          }
+          else
+          {
+                  if(hit.BarrelEndcapFlag().isBarrel())
+                     {
+                        
+                        //Residual Histograms: SimTrackerHit - HelicalTrackHit
+                        aida.histogram1D("SimTrackerVSHelicalTrack/Vertex/Barrel/Residual/r*phi/R*Phi"+hit.getLayerIdentifier(), 200, -1,1).fill((simr*simphi)-(rh*phih));
+                        aida.histogram1D("SimTrackerVSHelicalTrack/Vertex/Barrel/Residual/R/R"+hit.getLayerIdentifier(), 200, -1,1).fill(simr-rh);
+                        aida.histogram1D("SimTrackerVSHelicalTrack/Vertex/Barrel/Residual/Z/Z"+hit.getLayerIdentifier(), 200, -1,1).fill(simz-zh);
+                     }
+                  else
+                  {
+                        
+                        //Residual Histograms: SimTrackerHit - HelicalTrackHit
+                        aida.histogram1D("SimTrackerVSHelicalTrack/Vertex/Endcap/Residual/r*phi/R*Phi"+hit.getLayerIdentifier(), 200, -1, 1).fill((simr*simphi)-(rh*phih));
+                        aida.histogram1D("SimTrackerVSHelicalTrack/Vertex/Endcap/Residual/R/R"+hit.getLayerIdentifier(), 200, -1,1).fill(simr-rh);
+                        aida.histogram1D("SimTrackerVSHelicalTrack/Vertex/Endcap/Residual/Z/Z"+hit.getLayerIdentifier(), 200, -1,1).fill(simz-zh);
+                     }
+          }
+        }
+    }
+   
+    
+             
+    
+}
CVSspam 0.2.8