lcsim-contrib/src/main/java/org/lcsim/contrib/Mbussonn/HelixTest
diff -u -r1.1 -r1.2
--- HelixTest.java 23 Jun 2009 22:15:40 -0000 1.1
+++ HelixTest.java 23 Jun 2009 22:24:21 -0000 1.2
@@ -5,34 +5,34 @@
package org.lcsim.contrib.Mbussonn.HelixTest;
-import hep.graphics.heprep.HepRepFactory;
-import hep.graphics.heprep.HepRepInstanceTree;
-import hep.graphics.heprep.HepRepType;
-import hep.physics.matrix.SymmetricMatrix;
-import org.lcsim.contrib.onoprien.util.swim.Helix;
-import hep.physics.vec.Hep3Vector;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.lcsim.contrib.Mbussonn.HelixUtils;
-import org.lcsim.contrib.onoprien.util.swim.IntersectionNone;
-import org.lcsim.contrib.onoprien.util.swim.ZDisk;
-import org.lcsim.contrib.onoprien.util.vector.ConstHep3Vector;
-import org.lcsim.detector.*;
-import org.lcsim.event.Track;
-import org.lcsim.geometry.Detector;
+//import hep.graphics.heprep.HepRepFactory;
+//import hep.graphics.heprep.HepRepInstanceTree;
+//import hep.graphics.heprep.HepRepType;
+//import hep.physics.matrix.SymmetricMatrix;
+//import org.lcsim.contrib.onoprien.util.swim.Helix;
+//import hep.physics.vec.Hep3Vector;
+//import java.util.ArrayList;
+//import java.util.HashSet;
+//import java.util.LinkedList;
+//import java.util.List;
+//import java.util.Map;
+//import java.util.Set;
+//import org.lcsim.contrib.Mbussonn.HelixUtils;
+//import org.lcsim.contrib.onoprien.util.swim.IntersectionNone;
+//import org.lcsim.contrib.onoprien.util.swim.ZDisk;
+//import org.lcsim.contrib.onoprien.util.vector.ConstHep3Vector;
+//import org.lcsim.detector.*;
+//import org.lcsim.event.Track;
+//import org.lcsim.geometry.Detector;
import org.lcsim.util.Driver;
-import org.lcsim.contrib.onoprien.util.swim.Helix.CRep;
-import org.lcsim.contrib.sATLAS.TrackReconstructionDriver;
-import org.lcsim.detector.solids.*;
-import org.lcsim.event.EventHeader;
-import org.lcsim.fit.helicaltrack.HelicalTrackFit;
-import org.lcsim.fit.helicaltrack.HelicalTrackHit;
-import org.lcsim.fit.helicaltrack.MultipleScatter;
-import org.lcsim.util.heprep.HelixPath;
+//import org.lcsim.contrib.onoprien.util.swim.Helix.CRep;
+//import org.lcsim.contrib.sATLAS.TrackReconstructionDriver;
+//import org.lcsim.detector.solids.*;
+//import org.lcsim.event.EventHeader;
+//import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+//import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+//import org.lcsim.fit.helicaltrack.MultipleScatter;
+//import org.lcsim.util.heprep.HelixPath;
/**
*
@@ -40,476 +40,474 @@
*/
public class HelixTest extends Driver {
- private HepRepFactory factory;
- private HepRepInstanceTree instanceTree;
- private HepRepType typeM;
- private List<HelixPath> helixPath = new LinkedList<HelixPath>();
- public HelixTest()
- {
- add(new TrackReconstructionDriver());
-
-
- }
- protected void process(EventHeader event)
- {
- helixPath.clear();
- super.process(event);
- List<Track> tracks = event.getTracks();
- Detector det = event.getDetector();
- Track track = null;
- double xyz[] = {0,0,0};
- Set<Helix> helixlist = new HashSet<Helix>();
- ConstHep3Vector org = new ConstHep3Vector(0.0,0.0,0.0);
- ConstHep3Vector ref =null;
- ConstHep3Vector vec =null;
- ref = new ConstHep3Vector(0,0,0);
-
- Helix helix = null;
- if(tracks.size()>0){
- track = tracks.get(0);
- xyz = track.getReferencePoint();
- ref = new ConstHep3Vector(xyz[0],xyz[1],xyz[2]);
- vec = new ConstHep3Vector(track.getPX(),track.getPY(),track.getPZ());
- helix = new Helix(org , vec,track.getTrackParameter(2));
- helix.setReferencePoint(ref);
- }else{
- throw new UnsupportedOperationException("no tracks founded");
- }
-
- helixlist.add(helix);
- //////////////////////////////////////////////////////////////
- //**********************************************************//
- //************** some helix for test ***********************//Ê
- //**********************************************************//
- // //
- // ConstHep3Vector vec = new ConstHep3Vector(0.0,10,0.00); //
- // Helix helix = new Helix(org , vec, 1/100. ); //
- // helix.setReferencePoint(ref); //
- // helixlist.add(helix); //
- //**********************************************************//
- // int i ; //
- // for(i=50;i<200;i+=50){ //
- // vec = new ConstHep3Vector(0.0,20,(float)i); //
- // helix = new Helix(org , vec, 1./5000); //
- // helix.setReferencePoint(ref); //
- // helixlist.add(helix); //
- // } //
- //**********************************************************//
- // vec = new ConstHep3Vector(0.0,207,-1382); //
- // helix = new Helix(org , vec, 1./5000); //
- // helix.setReferencePoint(ref); //
- // helixlist.add(helix); //
- //**********************************************************//
- //////////////////////////////////////////////////////////////
-
-
-// System.out.println(helix);
-// System.out.println("==== Helix ========");
-// System.out.println("curvature = "+helix.getParameter(CRep.C));
-// System.out.println("dca = "+helix.getParameter(CRep.D0));
-// System.out.println("phi0 = "+helix.getParameter(CRep.PHI0));
-// System.out.println("Z0 = "+helix.getParameter(CRep.Z0));
-// System.out.println(" ");
-// System.out.println("path at 20 = "+helix.findLengthToZ(20));
-// System.out.println(" '' at -20 = "+helix.findLengthToZ(-20));
-// System.out.println("slope = "+helix.getParameter(CRep.TAN_LAMBDA));
-// ZDisk disq =new ZDisk(20.,0.,1000000.);
- //System.out.println("x at z:20 = "+helix.intersect(disq).getPosition().x());
- //System.out.println("y at z:20 = "+helix.intersect(disq).getPosition().y());
-// System.out.println("===== HelixFit ====");
- HelicalTrackFit hf = HelixToHTF(helix);
- System.out.println("curvature = "+hf.curvature());
- System.out.println("dca = "+hf.dca());
- System.out.println("phi0 = "+hf.phi0());
- System.out.println("Z0 = "+hf.z0());
- System.out.println("path at 20 = "+HelixUtils.PathToZPlane(hf, 20));
- //System.out.println("path at -20 = "+HelixUtils.PathToZPlane(hf, -20));
- //System.out.println("x at z:20 = "+HelixUtils.isInterceptingZDisk(hf,0.0, 100.0, 20.0));
-
- //System.out.println("slope = "+hf.slope());
- //System.out.println("===================");
- ISolid trkvol = det.getTrackingVolume().getLogicalVolume().getSolid();
- double smin;
- if (trkvol instanceof Tube) {
- Tube trktube = (Tube) trkvol;
- double rmax = trktube.getOuterRadius();
- double zmax = trktube.getZHalfLength();
- System.out.println("Ecal radius = " + rmax);
- System.out.println("ECal inner Z = " + zmax);
- double s0= HelixUtils.PathToZPlane(hf, zmax);
- List<Double> s1= HelixUtils.PathToCylinder(hf, s0, zmax, 1);
- smin = Math.min(s0,s1.get(0));
-
- }
- else
- {
- throw new UnsupportedOperationException("can't find intersection search bound");
- }
-
-
-
- IPhysicalVolumeNavigator nav = det.getNavigator();
- ILogicalVolume ltrkr = det.getTrackingVolume().getLogicalVolume();
- // Loop over the volumes defined at the compact.xml level
- Set<UniquePV> allVolumes = new HashSet<UniquePV>();
- for (IPhysicalVolume pvtree : ltrkr.getDaughters()) {
- List<UniquePV> pvflat = Flatten(pvtree, nav);
- for(UniquePV pv : pvflat)
- {allVolumes.add(pv);}
- }
- Set<UniquePV> traversedVolumes = new HashSet<UniquePV>();
- int i;
- ////////////////////////////
- ////////////////////////////
- ////////////////////////////
- List<Hep3Vector> thehelixpath = new LinkedList<Hep3Vector>();
- HelicalTrackFit tf = this.HelixToHTF(helix);
- HelixPath hp = new HelixPath();
- for(i=0;i<31;i++)
- thehelixpath.add(HelixUtils.PointOnHelix(tf, i*2000));
- int[] x={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
- hp.setHepRepVertexOrdering(x);
- hp.setVertices(thehelixpath);
- helixPath.add(hp);
- ////////////////////////////
- ////////////////////////////
- ////////////////////////////
- for(Helix he: helixlist){
- traversedVolumes = this.listOfTraverserVolumes(helix, allVolumes);
- System.out.println("==========================================");
- }
- event.put("HelixPath", helixPath, HelixPath.class, 0);
- System.out.println("intersect with "+traversedVolumes.size()+" volumes among "+allVolumes.size());
- return;
- }
-
-
-
-
-
- private Set<UniquePV> listOfTraverserVolumes(Helix helix,Set<UniquePV> listeOfVolumes)
- {
-
- Set<UniquePV> traversedVolumes = new HashSet<UniquePV>();
- for(UniquePV pv: listeOfVolumes){
- try{
- if(intersect(helix,pv))
- {traversedVolumes.add(pv);}
- }
- catch(UnsupportedOperationException e)
- {System.out.println(e);}
- }
- return traversedVolumes;
- }
-
-
-
-
-
-
- private List<UniquePV> Flatten(IPhysicalVolume vol, IPhysicalVolumeNavigator nav) {
-
- LinkedList<UniquePV> pvtree = new LinkedList<UniquePV>();
- List<UniquePV> pvflat = new ArrayList<UniquePV>();
- pvtree.add(new UniquePV(vol, nav));
-
- while (pvtree.size() > 0) {
-
- UniquePV upv = pvtree.poll();
- IPhysicalVolume pv = upv.getPV();
-
- if (pv.getLogicalVolume().getNumberOfDaughters() == 0) {
- pvflat.add(upv);
- } else {
- for (IPhysicalVolume p : pv.getLogicalVolume().getDaughters()) {
- pvtree.add(upv.createDaughterUniquePV(p));
- }
-
- }
- }
-
-
- return pvflat;
- }
-
- /**
- * check i fan helix intersect with a given plan extending a faces ie don't
- * check yet that the intersection is in the face
- * @param hf
- * @param faces
- * @return true if the helix intersect with the list of faces
- */
- private boolean intersectWithFaces(HelicalTrackFit hf, List<Polygon3D> faces){
- for(Polygon3D face: faces){
- Hep3Vector norm = face.getPlane().getNormal();
-
- List<Point3D> vertices = face.getVertices();
- Point3D vx = vertices.get(1);
- double zmin = vx.z();
- double zmax = vx.z();
- List<Hep3Vector> verticesx = new LinkedList<Hep3Vector>();
- for(Hep3Vector vert:vertices){
- zmin = Math.min(zmin, vert.z());
- zmax = Math.max(zmax, vert.z());
- verticesx.add(vert);
- }
- if(Math.abs(norm.z())>0.001){
- if(Math.abs(norm.z())<0.98) // deal with vector who should be parralel to z but arn't because of numerical issues
- {continue;}//System.out.println("skip z!=0 : "+norm.z()+" "+norm);
- if(HelixUtils.isInterceptingZpolygone(hf, zmax,verticesx))//here, z should be close from 1 or -1
- {return true;}//modifie that ...test for now
- else
- {continue;}
- }
- else if(HelixUtils.isInterceptingBoundedXYPlane(hf, norm, verticesx))
- {return true;}
- }
- return false;
- }
-
-
- /**
- * Check if an helix pass through an Unique PV by checking if the helix
- * intersect at least one of it's faces
- * For now it takes an helix in input, but will soon only use HelicalFit
- * @param he
- * @param pv
- * @return true if the helix intersect the Unique PV
- */
- @SuppressWarnings({"unchecked"})
- private boolean intersect(Helix he, UniquePV pv) {
- ISolid solid = pv.getSolid();
- HelicalTrackFit hf = HelixToHTF(he);
- List<Point3D> vtx;
- List<Hep3Vector> vtxx = new LinkedList<Hep3Vector>();
- //System.out.println(solid.getClass());
- if(solid instanceof Box||solid instanceof Trd||solid instanceof Trap)
- {
- AbstractPolyhedron box = (AbstractPolyhedron)solid;
- ITransform3D tr= pv.getLtoGTransform();
- List<Polygon3D> faces =box.getFaces();
- List<Polygon3D> facest = new LinkedList<Polygon3D>();
- for(Polygon3D fc : faces )
- {
- Polygon3D pl = fc.transformed(tr);
- facest.add(pl);
- for(Point3D vt : pl.getVertices())// to be albe do draw each face
- {vtxx.add(vt.getHep3Vector());}
-
- }
- vtx = box.getVertices();
- //for(Point3D vt : vtx)
- // {vtxx.add(vt.transformed(tr));}
- faces.clear();
- faces=null;
- if(intersectWithFaces(hf,facest)){
- HelixPath hp = new HelixPath();
- //hp.setHepRepVertexOrdering(box.getHepRepVertexOrdering());
- int[] x = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
- hp.setHepRepVertexOrdering(x);
- hp.setVertices(vtxx);
- helixPath.add(hp);
- return true;
- }
- return false;
- }
- else if(solid instanceof Tube)
- {
- Tube tube = (Tube) solid;
-// System.out.println("et un de rayon "+tube.getInnerRadius());
- double z0 = pv.getLtoGTransform().getTranslation().z();
-
- double zmax = z0 + tube.getZHalfLength();
- double zmin = z0 - tube.getZHalfLength();
- double rmin = tube.getInnerRadius();
- double rmax = tube.getOuterRadius();
-
-
- ZDisk disque = new ZDisk(zmin,rmin,rmax);
- if(!(he.intersect(disque) instanceof IntersectionNone ))
- {
- if(!(HelixUtils.isInterceptingZDisk(hf, rmin, rmax, zmin))){
- System.out.println("disque zmin intersect in Helix, not in HelixUtil !"+he.intersect(disque).getClass());
-// HelixUtils.rayInterceptingZDisk(hf, rmin, rmax, zmin);
-// Hep3Vector pos = he.intersect(new ZDisk(zmin,0.,100000000.)).getPosition();
-// System.out.println("Helix : "+Math.sqrt(pos.x()*pos.x()+pos.y()*pos.y()));
- //System.out.println("----");
- }
- }
-
- if(HelixUtils.isInterceptingZDisk(hf, rmin, rmax, zmin))
- {
- if((he.intersect(disque) instanceof IntersectionNone ))
- System.out.println("disque zmin intersect in HelixUtil, not in Helix !");
- return true;
- }
-
-
-
- disque = new ZDisk(zmax,rmin,rmax);
- if(HelixUtils.isInterceptingZDisk(hf, rmin, rmax, zmax))
- {
- if( (he.intersect(disque) instanceof IntersectionNone ))
- System.out.println("disque zmax intersect in HelixUtil, not in Helix !");
- return true;
- }
-
-
-
-
- if(HelixUtils.isInterceptingBoundedCylinder(hf, rmin, zmin, zmax)){
-
- return true;
- }
- else{
- //System.out.println("intercept nothing");
- return false;
- }
-
- //throw new UnsupportedOperationException("tube missed");
- }
- else if(solid instanceof Polycone)
- {
- throw new UnsupportedOperationException("polycone not yet implemented");
- }
- {
- System.out.println("Unknown :"+solid.getClass());
- //throw new UnsupportedOperationException("unknown form : "+solid.getClass());
- }
- return false;
- }
-
-
- private boolean isCylinder(double rmin, double rmax, double zmin, double zmax) {
- return (rmax - rmin) * Math.abs(zmax + zmin) < (zmax - zmin) * (rmax + rmin);
- }
-
-
- private HelicalTrackFit HelixToHTF(Helix he){
-
- int dcaIndex = 0;
- int phi0Index = 1;
- int curvatureIndex = 2;
- int z0Index = 3;
- int slopeIndex = 4;
- double[] pars={he.getParameter(CRep.D0),
- he.getParameter(CRep.PHI0),
- he.getParameter(CRep.C),
- he.getParameter(CRep.Z0),
- he.getParameter(CRep.TAN_LAMBDA)};
- SymmetricMatrix cov = null;
- double[] _chisq = new double[2];
- double _nhchisq = 0.;
- int[] _ndf = new int[2];
- Map<HelicalTrackHit, Double> _smap = null;
- Map<HelicalTrackHit, MultipleScatter> _msmap = null;
- HelicalTrackFit helixFakeFit=new HelicalTrackFit(pars, cov,_chisq,_ndf,_smap,_msmap);
- return helixFakeFit;
- //HelicalTrackFit(pars, cov,_chisq, _ndf,smap, Map<HelicalTrackHit, MultipleScatter> msmap)
- }
-
-
- /**
- * A "struct" holding geometry information about a single physical volume
- */
- class VolumeInfo {
- double rmax = 0.0;
- double rmin = 1.e10;
- double zmin = 1.e10;
- double zmax = -1.e10;
- double xmin = 1.e10;
- double xmax = -1.e10;
- double ymin = 1.e10;
- double ymax = -1.e10;
- double ox,oy,oz = 0;
- double size = 0;
- }
-
-
-
- /**
- * A UniquePV is a wrapper around IPhysicalVolumePath which provides
- * some convenience methods and caches transformations.
- */
- class UniquePV {
-
- IPhysicalVolumePath path;
- IPhysicalVolumeNavigator nav;
- ITransform3D transform = null;
-
- /**
- * Generates a top-level UniquePV.
- * @param root The top-level IPhysicalVolume
- * @param navigator The IPhysicalVolumeNavigator associated with the detector
- */
- public UniquePV(IPhysicalVolume root, IPhysicalVolumeNavigator navigator) {
- path = new PhysicalVolumePath();
- nav = navigator;
- path.add(root);
- }
-
- /**
- * Generates a UniquePV from a path. (Shallow copy of path)
- * @param path
- * @param navigator
- */
- public UniquePV(IPhysicalVolumePath path, IPhysicalVolumeNavigator navigator) {
- this.path = path;
-
- nav = navigator;
- }
-
- /**
- * Returns the IPhysicalVolume (the last element of the path)
- */
- public IPhysicalVolume getPV() {
- return path.getLeafVolume();
- }
-
- /**
- * Creates a UniquePV that is a daughter of the current UniquePV (deep copy made)
- * @param daughter
- * @return
- */
- public UniquePV createDaughterUniquePV(IPhysicalVolume daughter) {
- IPhysicalVolumePath np = new PhysicalVolumePath();
- np.addAll(path);
- np.add(daughter);
- return new UniquePV(np, nav);
- }
-
- /**
- * Transforms the given vector from local to global coords.
- * @param v the untransformed local Hep3Vector
- * @return the transformed global Hep3Vector
- */
- public Hep3Vector localToGlobal(Hep3Vector v) {
-
- return getLtoGTransform().transformed(v);
- }
-
- /**
- * Returns the solid associated with the physical volume.
- * @return
- */
- public ISolid getSolid() {
- return this.getPV().getLogicalVolume().getSolid();
- }
-
- /**
- * Returns the local-to-global transform
- * @return an ITransform3D from local coordinates to global coordinates.
- */
- public ITransform3D getLtoGTransform() {
- if (transform == null) {
- transform = nav.getTransform(path);
- }
- return transform;
- }
-
- @Override
- public String toString() {
- return path.toString();
- }
- }
+// private HepRepFactory factory;
+// private HepRepInstanceTree instanceTree;
+// private HepRepType typeM;
+// private List<HelixPath> helixPath = new LinkedList<HelixPath>();
+// public HelixTest()
+// {
+// add(new TrackReconstructionDriver());
+// }
+// protected void process(EventHeader event)
+// {
+// helixPath.clear();
+// super.process(event);
+// List<Track> tracks = event.getTracks();
+// Detector det = event.getDetector();
+// Track track = null;
+// double xyz[] = {0,0,0};
+// Set<Helix> helixlist = new HashSet<Helix>();
+// ConstHep3Vector org = new ConstHep3Vector(0.0,0.0,0.0);
+// ConstHep3Vector ref =null;
+// ConstHep3Vector vec =null;
+// ref = new ConstHep3Vector(0,0,0);
+//
+// Helix helix = null;
+// if(tracks.size()>0){
+// track = tracks.get(0);
+// xyz = track.getReferencePoint();
+// ref = new ConstHep3Vector(xyz[0],xyz[1],xyz[2]);
+// vec = new ConstHep3Vector(track.getPX(),track.getPY(),track.getPZ());
+// helix = new Helix(org , vec,track.getTrackParameter(2));
+// helix.setReferencePoint(ref);
+// }else{
+// throw new UnsupportedOperationException("no tracks founded");
+// }
+//
+// helixlist.add(helix);
+// //////////////////////////////////////////////////////////////
+// //**********************************************************//
+// //************** some helix for test ***********************//Ê
+// //**********************************************************//
+// // //
+// // ConstHep3Vector vec = new ConstHep3Vector(0.0,10,0.00); //
+// // Helix helix = new Helix(org , vec, 1/100. ); //
+// // helix.setReferencePoint(ref); //
+// // helixlist.add(helix); //
+// //**********************************************************//
+// // int i ; //
+// // for(i=50;i<200;i+=50){ //
+// // vec = new ConstHep3Vector(0.0,20,(float)i); //
+// // helix = new Helix(org , vec, 1./5000); //
+// // helix.setReferencePoint(ref); //
+// // helixlist.add(helix); //
+// // } //
+// //**********************************************************//
+// // vec = new ConstHep3Vector(0.0,207,-1382); //
+// // helix = new Helix(org , vec, 1./5000); //
+// // helix.setReferencePoint(ref); //
+// // helixlist.add(helix); //
+// //**********************************************************//
+// //////////////////////////////////////////////////////////////
+//
+//
+//// System.out.println(helix);
+//// System.out.println("==== Helix ========");
+//// System.out.println("curvature = "+helix.getParameter(CRep.C));
+//// System.out.println("dca = "+helix.getParameter(CRep.D0));
+//// System.out.println("phi0 = "+helix.getParameter(CRep.PHI0));
+//// System.out.println("Z0 = "+helix.getParameter(CRep.Z0));
+//// System.out.println(" ");
+//// System.out.println("path at 20 = "+helix.findLengthToZ(20));
+//// System.out.println(" '' at -20 = "+helix.findLengthToZ(-20));
+//// System.out.println("slope = "+helix.getParameter(CRep.TAN_LAMBDA));
+//// ZDisk disq =new ZDisk(20.,0.,1000000.);
+// //System.out.println("x at z:20 = "+helix.intersect(disq).getPosition().x());
+// //System.out.println("y at z:20 = "+helix.intersect(disq).getPosition().y());
+//// System.out.println("===== HelixFit ====");
+// HelicalTrackFit hf = HelixToHTF(helix);
+// System.out.println("curvature = "+hf.curvature());
+// System.out.println("dca = "+hf.dca());
+// System.out.println("phi0 = "+hf.phi0());
+// System.out.println("Z0 = "+hf.z0());
+// System.out.println("path at 20 = "+HelixUtils.PathToZPlane(hf, 20));
+// //System.out.println("path at -20 = "+HelixUtils.PathToZPlane(hf, -20));
+// //System.out.println("x at z:20 = "+HelixUtils.isInterceptingZDisk(hf,0.0, 100.0, 20.0));
+//
+// //System.out.println("slope = "+hf.slope());
+// //System.out.println("===================");
+// ISolid trkvol = det.getTrackingVolume().getLogicalVolume().getSolid();
+// double smin;
+// if (trkvol instanceof Tube) {
+// Tube trktube = (Tube) trkvol;
+// double rmax = trktube.getOuterRadius();
+// double zmax = trktube.getZHalfLength();
+// System.out.println("Ecal radius = " + rmax);
+// System.out.println("ECal inner Z = " + zmax);
+// double s0= HelixUtils.PathToZPlane(hf, zmax);
+// List<Double> s1= HelixUtils.PathToCylinder(hf, s0, zmax, 1);
+// smin = Math.min(s0,s1.get(0));
+//
+// }
+// else
+// {
+// throw new UnsupportedOperationException("can't find intersection search bound");
+// }
+//
+//
+//
+// IPhysicalVolumeNavigator nav = det.getNavigator();
+// ILogicalVolume ltrkr = det.getTrackingVolume().getLogicalVolume();
+// // Loop over the volumes defined at the compact.xml level
+// Set<UniquePV> allVolumes = new HashSet<UniquePV>();
+// for (IPhysicalVolume pvtree : ltrkr.getDaughters()) {
+// List<UniquePV> pvflat = Flatten(pvtree, nav);
+// for(UniquePV pv : pvflat)
+// {allVolumes.add(pv);}
+// }
+// Set<UniquePV> traversedVolumes = new HashSet<UniquePV>();
+// int i;
+// ////////////////////////////
+// ////////////////////////////
+// ////////////////////////////
+// List<Hep3Vector> thehelixpath = new LinkedList<Hep3Vector>();
+// HelicalTrackFit tf = this.HelixToHTF(helix);
+// HelixPath hp = new HelixPath();
+// for(i=0;i<31;i++)
+// thehelixpath.add(HelixUtils.PointOnHelix(tf, i*2000));
+// int[] x={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
+// hp.setHepRepVertexOrdering(x);
+// hp.setVertices(thehelixpath);
+// helixPath.add(hp);
+// ////////////////////////////
+// ////////////////////////////
+// ////////////////////////////
+// for(Helix he: helixlist){
+// traversedVolumes = this.listOfTraverserVolumes(helix, allVolumes);
+// System.out.println("==========================================");
+// }
+// event.put("HelixPath", helixPath, HelixPath.class, 0);
+// System.out.println("intersect with "+traversedVolumes.size()+" volumes among "+allVolumes.size());
+// return;
+// }
+//
+//
+//
+//
+//
+// private Set<UniquePV> listOfTraverserVolumes(Helix helix,Set<UniquePV> listeOfVolumes)
+// {
+//
+// Set<UniquePV> traversedVolumes = new HashSet<UniquePV>();
+// for(UniquePV pv: listeOfVolumes){
+// try{
+// if(intersect(helix,pv))
+// {traversedVolumes.add(pv);}
+// }
+// catch(UnsupportedOperationException e)
+// {System.out.println(e);}
+// }
+// return traversedVolumes;
+// }
+//
+//
+//
+//
+//
+//
+// private List<UniquePV> Flatten(IPhysicalVolume vol, IPhysicalVolumeNavigator nav) {
+//
+// LinkedList<UniquePV> pvtree = new LinkedList<UniquePV>();
+// List<UniquePV> pvflat = new ArrayList<UniquePV>();
+// pvtree.add(new UniquePV(vol, nav));
+//
+// while (pvtree.size() > 0) {
+//
+// UniquePV upv = pvtree.poll();
+// IPhysicalVolume pv = upv.getPV();
+//
+// if (pv.getLogicalVolume().getNumberOfDaughters() == 0) {
+// pvflat.add(upv);
+// } else {
+// for (IPhysicalVolume p : pv.getLogicalVolume().getDaughters()) {
+// pvtree.add(upv.createDaughterUniquePV(p));
+// }
+//
+// }
+// }
+//
+//
+// return pvflat;
+// }
+//
+// /**
+// * check i fan helix intersect with a given plan extending a faces ie don't
+// * check yet that the intersection is in the face
+// * @param hf
+// * @param faces
+// * @return true if the helix intersect with the list of faces
+// */
+// private boolean intersectWithFaces(HelicalTrackFit hf, List<Polygon3D> faces){
+// for(Polygon3D face: faces){
+// Hep3Vector norm = face.getPlane().getNormal();
+//
+// List<Point3D> vertices = face.getVertices();
+// Point3D vx = vertices.get(1);
+// double zmin = vx.z();
+// double zmax = vx.z();
+// List<Hep3Vector> verticesx = new LinkedList<Hep3Vector>();
+// for(Hep3Vector vert:vertices){
+// zmin = Math.min(zmin, vert.z());
+// zmax = Math.max(zmax, vert.z());
+// verticesx.add(vert);
+// }
+// if(Math.abs(norm.z())>0.001){
+// if(Math.abs(norm.z())<0.98) // deal with vector who should be parralel to z but arn't because of numerical issues
+// {continue;}//System.out.println("skip z!=0 : "+norm.z()+" "+norm);
+// if(HelixUtils.isInterceptingZpolygone(hf, zmax,verticesx))//here, z should be close from 1 or -1
+// {return true;}//modifie that ...test for now
+// else
+// {continue;}
+// }
+// else if(HelixUtils.isInterceptingBoundedXYPlane(hf, norm, verticesx))
+// {return true;}
+// }
+// return false;
+// }
+//
+//
+// /**
+// * Check if an helix pass through an Unique PV by checking if the helix
+// * intersect at least one of it's faces
+// * For now it takes an helix in input, but will soon only use HelicalFit
+// * @param he
+// * @param pv
+// * @return true if the helix intersect the Unique PV
+// */
+// @SuppressWarnings({"unchecked"})
+// private boolean intersect(Helix he, UniquePV pv) {
+// ISolid solid = pv.getSolid();
+// HelicalTrackFit hf = HelixToHTF(he);
+// List<Point3D> vtx;
+// List<Hep3Vector> vtxx = new LinkedList<Hep3Vector>();
+// //System.out.println(solid.getClass());
+// if(solid instanceof Box||solid instanceof Trd||solid instanceof Trap)
+// {
+// AbstractPolyhedron box = (AbstractPolyhedron)solid;
+// ITransform3D tr= pv.getLtoGTransform();
+// List<Polygon3D> faces =box.getFaces();
+// List<Polygon3D> facest = new LinkedList<Polygon3D>();
+// for(Polygon3D fc : faces )
+// {
+// Polygon3D pl = fc.transformed(tr);
+// facest.add(pl);
+// for(Point3D vt : pl.getVertices())// to be albe do draw each face
+// {vtxx.add(vt.getHep3Vector());}
+//
+// }
+// vtx = box.getVertices();
+// //for(Point3D vt : vtx)
+// // {vtxx.add(vt.transformed(tr));}
+// faces.clear();
+// faces=null;
+// if(intersectWithFaces(hf,facest)){
+// HelixPath hp = new HelixPath();
+// //hp.setHepRepVertexOrdering(box.getHepRepVertexOrdering());
+// int[] x = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
+// hp.setHepRepVertexOrdering(x);
+// hp.setVertices(vtxx);
+// helixPath.add(hp);
+// return true;
+// }
+// return false;
+// }
+// else if(solid instanceof Tube)
+// {
+// Tube tube = (Tube) solid;
+//// System.out.println("et un de rayon "+tube.getInnerRadius());
+// double z0 = pv.getLtoGTransform().getTranslation().z();
+//
+// double zmax = z0 + tube.getZHalfLength();
+// double zmin = z0 - tube.getZHalfLength();
+// double rmin = tube.getInnerRadius();
+// double rmax = tube.getOuterRadius();
+//
+//
+// ZDisk disque = new ZDisk(zmin,rmin,rmax);
+// if(!(he.intersect(disque) instanceof IntersectionNone ))
+// {
+// if(!(HelixUtils.isInterceptingZDisk(hf, rmin, rmax, zmin))){
+// System.out.println("disque zmin intersect in Helix, not in HelixUtil !"+he.intersect(disque).getClass());
+//// HelixUtils.rayInterceptingZDisk(hf, rmin, rmax, zmin);
+//// Hep3Vector pos = he.intersect(new ZDisk(zmin,0.,100000000.)).getPosition();
+//// System.out.println("Helix : "+Math.sqrt(pos.x()*pos.x()+pos.y()*pos.y()));
+// //System.out.println("----");
+// }
+// }
+//
+// if(HelixUtils.isInterceptingZDisk(hf, rmin, rmax, zmin))
+// {
+// if((he.intersect(disque) instanceof IntersectionNone ))
+// System.out.println("disque zmin intersect in HelixUtil, not in Helix !");
+// return true;
+// }
+//
+//
+//
+// disque = new ZDisk(zmax,rmin,rmax);
+// if(HelixUtils.isInterceptingZDisk(hf, rmin, rmax, zmax))
+// {
+// if( (he.intersect(disque) instanceof IntersectionNone ))
+// System.out.println("disque zmax intersect in HelixUtil, not in Helix !");
+// return true;
+// }
+//
+//
+//
+//
+// if(HelixUtils.isInterceptingBoundedCylinder(hf, rmin, zmin, zmax)){
+//
+// return true;
+// }
+// else{
+// //System.out.println("intercept nothing");
+// return false;
+// }
+//
+// //throw new UnsupportedOperationException("tube missed");
+// }
+// else if(solid instanceof Polycone)
+// {
+// throw new UnsupportedOperationException("polycone not yet implemented");
+// }
+// {
+// System.out.println("Unknown :"+solid.getClass());
+// //throw new UnsupportedOperationException("unknown form : "+solid.getClass());
+// }
+// return false;
+// }
+//
+//
+// private boolean isCylinder(double rmin, double rmax, double zmin, double zmax) {
+// return (rmax - rmin) * Math.abs(zmax + zmin) < (zmax - zmin) * (rmax + rmin);
+// }
+//
+//
+// private HelicalTrackFit HelixToHTF(Helix he){
+//
+// int dcaIndex = 0;
+// int phi0Index = 1;
+// int curvatureIndex = 2;
+// int z0Index = 3;
+// int slopeIndex = 4;
+// double[] pars={he.getParameter(CRep.D0),
+// he.getParameter(CRep.PHI0),
+// he.getParameter(CRep.C),
+// he.getParameter(CRep.Z0),
+// he.getParameter(CRep.TAN_LAMBDA)};
+// SymmetricMatrix cov = null;
+// double[] _chisq = new double[2];
+// double _nhchisq = 0.;
+// int[] _ndf = new int[2];
+// Map<HelicalTrackHit, Double> _smap = null;
+// Map<HelicalTrackHit, MultipleScatter> _msmap = null;
+// HelicalTrackFit helixFakeFit=new HelicalTrackFit(pars, cov,_chisq,_ndf,_smap,_msmap);
+// return helixFakeFit;
+// //HelicalTrackFit(pars, cov,_chisq, _ndf,smap, Map<HelicalTrackHit, MultipleScatter> msmap)
+// }
+//
+//
+// /**
+// * A "struct" holding geometry information about a single physical volume
+// */
+// class VolumeInfo {
+// double rmax = 0.0;
+// double rmin = 1.e10;
+// double zmin = 1.e10;
+// double zmax = -1.e10;
+// double xmin = 1.e10;
+// double xmax = -1.e10;
+// double ymin = 1.e10;
+// double ymax = -1.e10;
+// double ox,oy,oz = 0;
+// double size = 0;
+// }
+//
+//
+//
+// /**
+// * A UniquePV is a wrapper around IPhysicalVolumePath which provides
+// * some convenience methods and caches transformations.
+// */
+// class UniquePV {
+//
+// IPhysicalVolumePath path;
+// IPhysicalVolumeNavigator nav;
+// ITransform3D transform = null;
+//
+// /**
+// * Generates a top-level UniquePV.
+// * @param root The top-level IPhysicalVolume
+// * @param navigator The IPhysicalVolumeNavigator associated with the detector
+// */
+// public UniquePV(IPhysicalVolume root, IPhysicalVolumeNavigator navigator) {
+// path = new PhysicalVolumePath();
+// nav = navigator;
+// path.add(root);
+// }
+//
+// /**
+// * Generates a UniquePV from a path. (Shallow copy of path)
+// * @param path
+// * @param navigator
+// */
+// public UniquePV(IPhysicalVolumePath path, IPhysicalVolumeNavigator navigator) {
+// this.path = path;
+//
+// nav = navigator;
+// }
+//
+// /**
+// * Returns the IPhysicalVolume (the last element of the path)
+// */
+// public IPhysicalVolume getPV() {
+// return path.getLeafVolume();
+// }
+//
+// /**
+// * Creates a UniquePV that is a daughter of the current UniquePV (deep copy made)
+// * @param daughter
+// * @return
+// */
+// public UniquePV createDaughterUniquePV(IPhysicalVolume daughter) {
+// IPhysicalVolumePath np = new PhysicalVolumePath();
+// np.addAll(path);
+// np.add(daughter);
+// return new UniquePV(np, nav);
+// }
+//
+// /**
+// * Transforms the given vector from local to global coords.
+// * @param v the untransformed local Hep3Vector
+// * @return the transformed global Hep3Vector
+// */
+// public Hep3Vector localToGlobal(Hep3Vector v) {
+//
+// return getLtoGTransform().transformed(v);
+// }
+//
+// /**
+// * Returns the solid associated with the physical volume.
+// * @return
+// */
+// public ISolid getSolid() {
+// return this.getPV().getLogicalVolume().getSolid();
+// }
+//
+// /**
+// * Returns the local-to-global transform
+// * @return an ITransform3D from local coordinates to global coordinates.
+// */
+// public ITransform3D getLtoGTransform() {
[truncated at 1000 lines; 13 more skipped]